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 OrderModel(); $pay_type_list = $order_common_model->getPayType(); return $this->response($this->success($pay_type_list)); } /** * 获取订单来源 */ public function getOrderFromType() { $order_common_model = new OrderModel(); $list = $order_common_model->getOrderFromList([ 'order_scene' => 'cashier' ]); return $this->response($this->success($list)); } /** * 获取订单信息 */ public function info() { $order_id = $this->params[ 'order_id' ] ?? 0; //订单信息 $order_common_model = new OrderModel(); $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 OrderModel(); $order_detail = $order_common_model->getOrderDetail($order_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)); } /** * 订单调价 * @return false|string */ 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 OrderModel(); $result = $order_common_model->orderAdjustMoney($order_id, $adjust_money, $shipping_money); return $this->response($result); } /** * 订单关闭 * @return mixed */ public function close() { $order_id = $this->params[ 'order_id' ] ?? 0; $order_common_model = new OrderModel(); $log_data = [ 'uid' => $this->user_info[ 'uid' ], 'nick_name' => $this->user_info[ 'username' ], 'action_way' => 2 ]; $result = $order_common_model->orderClose($order_id, $log_data,'商家关闭了订单'); return $this->response($result); } /** * 订单删除 */ public function delete() { $order_id = $this->params[ 'order_id' ] ?? 0; $order_common_model = new OrderModel(); $result = $order_common_model->orderDelete($order_id, $this->site_id); return $this->response($result); } /** * 同城配送发货 * @return false|string */ public function localDelivery() { $order_id = $this->params[ 'order_id' ] ?? 0; $deliverer = $this->params[ 'deliverer' ] ?? ''; $deliverer_mobile = $this->params[ 'deliverer_mobile' ] ?? ''; $local_order_model = new LocalOrderModel(); $data = [ 'order_id' => $order_id, 'deliverer' => $deliverer, 'deliverer_mobile' => $deliverer_mobile, 'site_id' => $this->site_id, 'store_id' => $this->store_id ]; $result = $local_order_model->orderGoodsDelivery($data); return $this->response($result); } /** * 门店提货 * @return array|mixed|void */ public function storeDelivery() { $order_id = $this->params[ 'order_id' ] ?? 0; $order_common_model = new OrderCommon(); $condition = array ( [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $this->store_id ], [ 'order_id', '=', $order_id ] ); $order_info = $order_common_model->getOrderInfo($condition, 'delivery_code')[ 'data' ] ?? []; if (empty($order_info)) return $this->response($this->error('', '订单不存在')); $verify_code = $order_info[ 'delivery_code' ]; $info = array ( "verifier_id" => $this->uid, "verifier_name" => $this->user_info[ 'username' ], "verify_from" => 'shop', "store_id" => $this->store_id ); $verify_model = new Verify(); $result = $verify_model->verify($info, $verify_code); return $this->response($result); } /** * 快递发货 * @return false|string */ public function expressDelivery() { $order_model = new OrderModel(); $data = array ( 'type' => 'manual',//发货方式(手动发货、电子面单) 'order_goods_ids' => $this->params[ 'order_goods_ids' ] ?? '',//商品id 'express_company_id' => $this->params[ 'express_company_id' ] ?? 0,//物流公司 'delivery_no' => $this->params[ 'delivery_no' ] ?? '',//快递单号 'order_id' => $this->params[ 'order_id' ] ?? 0,//订单id 'delivery_type' => $this->params[ 'delivery_type' ] ?? 0,//是否需要物流 'site_id' => $this->site_id, 'store_id' => $this->store_id, 'template_id' => 0,//电子面单模板id 'user_info' => $this->user_info ); $log_data = [ 'uid' => $this->user_info[ 'uid' ], 'nick_name' => $this->user_info[ 'username' ], 'action' => '商家对订单进行了发货', 'action_way' => 2, ]; $result = $order_model->orderGoodsDelivery($data, 1, $log_data); return $this->response($result); } /** * 获取门店配送员 */ public function deliverList() { $deliver_model = new ExpressDeliver(); $list = $deliver_model->getDeliverLists([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $this->store_id ] ], 'deliver_id,deliver_name,deliver_mobile'); return $this->response($list); } /** * 获取物流公司 * @return false|string */ public function expressCompany() { $express_company_model = new ExpressCompany(); //店铺物流公司 $result = $express_company_model->getExpressCompanyList([ [ "site_id", "=", $this->site_id ] ]); return $this->response($result); } }