params[ 'page' ] ?? 1; $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS; $search_text = $this->params[ 'search_text' ] ?? ''; $order_status = $this->params[ 'order_status' ] ?? 'all'; $start_time = $this->params[ 'start_time' ] ?? ''; $end_time = $this->params[ 'end_time' ] ?? ''; $trade_type = $this->params[ 'trade_type' ] ?? ''; $order_from = $this->params[ 'order_from' ] ?? ''; $pay_type = $this->params[ 'pay_type' ] ?? ''; $condition = [ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $this->store_id ], [ 'is_delete', '=', 0 ], [ 'order_type', '=', 'o2o' ], ]; //订单状态 if ($order_status != 'all' && !empty($order_status)) { if ($order_status == $order_common_model::ORDER_REFUNDING) { $condition[] = [ 'is_exist_refund', '=', 1 ]; } else { $condition[] = [ 'order_status', '=', $order_status ]; } } //订单时间 if (!empty($start_time) && empty($end_time)) { $condition[] = [ 'create_time', '>=', date_to_time($start_time) ]; } elseif (empty($start_time) && !empty($end_time)) { $condition[] = [ 'create_time', '<=', date_to_time($end_time) ]; } elseif (!empty($start_time) && !empty($end_time)) { $condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ]; } //订单内容 if ($search_text != '') { $condition[] = [ 'order_no|out_trade_no|order_name|nickname', 'like', '%' . $search_text . '%' ]; } //收货方式 if ($trade_type != '') { $condition[] = [ 'trade_type', '=', $trade_type ]; } //订单来源 if ($order_from != '') { $condition[] = [ 'order_from', '=', $order_from ]; } //订单支付 if ($pay_type != '') { $condition[] = [ 'pay_type', '=', $pay_type ]; } $order = 'create_time desc'; $field = '*'; $list = $order_common_model->getOrderPageList($condition, $page, $page_size, $order, $field); return $this->response($list); } /** * 获取支付方式 */ public function getOrderPayType() { $order_common_model = new OrderCommonModel(); $pay_type_list = $order_common_model->getPayType('o2o'); return $this->response($this->success($pay_type_list)); } /** * 获取订单状态 */ public function getOrderStatus() { $trade_type = $this->params[ 'trade_type' ] ?? 'service'; $order_common_model = new OrderCommonModel(); $list = $order_common_model->getOrderStatusList([ 'trade_type' => $trade_type, ]); return $this->response($this->success($list)); } /** * 获取订单来源 */ public function getOrderFromType() { $order_common_model = new OrderCommonModel(); $list = $order_common_model->getOrderFromList('o2o'); return $this->response($this->success($list)); } /** * 获取订单信息 */ public function info() { $order_id = $this->params[ 'order_id' ] ?? 0; //订单信息 $order_common_model = new OrderCommonModel(); $condition = array ( [ 'order_id', '=', $order_id ], [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $this->store_id ], ); $res = $order_common_model->getOrderInfo($condition)[ 'data' ]; return $this->response($res); } /** * 订单详情 */ public function detail() { $order_id = $this->params[ 'order_id' ] ?? 0; //订单详情 $order_common_model = new OrderCommonModel(); $order_detail = $order_common_model->getOrderDetail($order_id, $this->site_id)[ 'data' ]; if (empty($order_detail)) return $this->response($this->error(null, '无法获取订单数据')); //查询订单日志 $order_log_model = new OrderLog(); $log_condition = [ [ 'order_id', '=', $order_id ], ]; $order_detail[ 'order_log_list' ] = $order_log_model->getOrderLogList($log_condition, '*', 'action_time desc,id desc')[ 'data' ]; return $this->response($this->success($order_detail)); } /** * 卖家备注 */ public function orderRemark() { $order_id = $this->params[ 'order_id' ] ?? 0; $remark = $this->params[ 'remark' ] ?? ''; $order_common_model = new OrderCommonModel(); $data = array ( "remark" => $remark, "order_id" => $order_id, "site_id" => $this->site_id, "uid" => $this->uid ); $result = $order_common_model->orderUpdateRemark($data); return $this->response($result); } /** * 订单调价 * @return mixed */ public function adjustPrice() { $order_id = $this->params[ 'order_id' ] ?? 0; $adjust_money = $this->params[ 'adjust_money' ] ?? 0; $shipping_money = $this->params[ 'shipping_money' ] ?? 0; $order_common_model = new OrderCommonModel(); $params = array ( 'order_id' => $order_id, 'adjust_money' => $adjust_money, 'shipping_money' => $shipping_money, 'site_id' => $this->site_id, 'uid' => $this->uid ); $result = $order_common_model->orderAdjustMoney($params); return $this->response($result); } /** * 订单关闭 * @return mixed */ public function close() { $order_id = $this->params[ 'order_id' ] ?? 0; $order_common_model = new OrderCommonModel(); $order_close_params = array ( 'order_id' => $order_id, 'site_id' => $this->site_id, 'uid' => $this->uid ); $result = $order_common_model->orderClose($order_close_params); return $this->response($result); } /** * 订单删除 */ public function delete() { $order_id = $this->params[ 'order_id' ] ?? 0; $order_common_model = new OrderCommonModel(); $result = $order_common_model->orderDelete($order_id, $this->site_id); return $this->response($result); } }