post(); $pageSize = request()->post('pageSize', 15); $params['user_id'] = $this->userId; $datas = OrderService::make()->getDataList($params, $pageSize); return message(1010, true, $datas); } /** * 数量 * @return array */ public function count() { $status = request()->post('status', 1); $data = OrderService::make()->getCountByStatus($this->userId, $status); return showJson(1010, true, $data); } /** * 下单 * @param OrderValidator $validator * @return array */ public function submit(OrderValidator $validator) { $params = request()->all(); $params = $validator->check($params, 'submit'); if (!is_array($params)) { return showJson($params, false); } try { if (!$result = OrderService::make()->createOrder($this->userId, $params)) { $error = OrderService::make()->getError(); return showJson($error, false, '', $error == 1042||$error == 1045 ? '403' : -1); } else { return showJson(OrderService::make()->getError(), true, $result); } } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage(),'trace'=>$exception->getTrace()]; return showJson(1046, false, $error); } } /** * 支付 * @return array */ public function pay() { $params = request()->all(); $id = isset($params['id'])? $params['id'] : 0; try { if (!$result = OrderService::make()->pay($this->userId, $id)) { $error = OrderService::make()->getError(); return showJson($error, false, '', $error == 2206 ? '405' : -1); } else { return showJson(OrderService::make()->getError(), true, $result); } } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } /** * 取消 * @return array */ public function cancel() { $params = request()->all(); $id = isset($params['id'])? $params['id'] : 0; try { if (!$result = OrderService::make()->cancel($this->userId, $id)) { $error = OrderService::make()->getError(); return showJson($error, false, '', $error == 2206 ? '405' : -1); } else { return showJson(1002, true, $result); } } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } /** * 删除隐藏 * @return array */ public function hide() { $params = request()->all(); $id = isset($params['id'])? $params['id'] : 0; try { if (!$result = OrderService::make()->hide($this->userId, $id)) { $error = OrderService::make()->getError(); return showJson($error, false, '', $error == 2206 ? '405' : -1); } else { return showJson(1002, true, $result); } } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } /** * 收货 * @return array */ public function complete() { $params = request()->all(); $id = isset($params['id'])? $params['id'] : 0; try { if (!$result = OrderService::make()->complete($this->userId, $id)) { $error = OrderService::make()->getError(); return showJson($error, false, '', $error == 2206 ? '405' : -1); } else { return showJson(OrderService::make()->getError(), true, $result); } } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } /** * 售后/退款 * @return array */ public function after() { $params = request()->all(); try { if (!$result = OrderService::make()->after($this->userId, $params)) { $error = OrderService::make()->getError(); return showJson($error, false, '', $error == 2206 ? '405' : -1); } else { return showJson(OrderService::make()->getError(), true, $result); } } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } public function logistics() { $params = request()->all(); $id = isset($params['id'])? $params['id'] : 0; try { if (!$result = OrderService::make()->getDelivery($id)) { $error = OrderService::make()->getError(); return showJson($error, false, '', $error == 2206 ? '405' : -1); } else { return showJson(1010, true, $result); } } catch (\Exception $exception) { $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()]; return showJson(1046, false, $error); } } }