Esempio n. 1
0
 /**
  * 取消订单
  */
 public function Cancel($f3)
 {
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $order_id = $validator->required('订单ID非法')->digits('订单ID非法')->min(1, true, '订单ID非法')->validate('order_id');
     if (!$this->validate($validator)) {
         goto out;
     }
     $userInfo = AuthHelper::getAuthUser();
     // 查询订单
     $orderBasicService = new OrderBasicService();
     $orderInfo = $orderBasicService->loadOrderInfoById($order_id, 1);
     // 缓存 1 秒钟
     if ($orderInfo->isEmpty() || $userInfo['user_id'] != $orderInfo['user_id'] || OrderBasicService::OS_UNCONFIRMED != $orderInfo['order_status'] || !$this->verifyOrderSystem($orderInfo)) {
         $this->addFlashMessage('订单ID非法');
         goto out;
     }
     // 取消订单
     $orderPaymentService = new OrderPaymentService();
     if ($orderPaymentService->cancelUnpayOrderInfo($order_id)) {
         // 重新加载 authUser,因为退款可能导致用户 余额 之类发生变化
         //AuthHelper::reloadAuthUser();
     }
     $this->addFlashMessage('成功取消订单');
     out:
     // 从这里退出
     RouteHelper::reRoute($this, '/My/Order');
 }