diff --git a/app/api/controller/Order.php b/app/api/controller/Order.php index ca59f495..8d7054a7 100644 --- a/app/api/controller/Order.php +++ b/app/api/controller/Order.php @@ -12,19 +12,17 @@ declare (strict_types=1); namespace app\api\controller; -use app\api\model\RecoveryOrder; -use app\common\enum\OrderType; -use app\common\enum\user\UserTypeEnum; -use think\response\Json; use app\api\model\Order as OrderModel; use app\api\model\Setting as SettingModel; -use app\api\service\User as UserService; use app\api\service\Order as OrderService; -use app\common\service\qrcode\Extract as ExtractQRcode; -use cores\exception\BaseException; use app\api\service\TransferRecord; -use app\common\model\TransferRecord as TransferRecordModel; +use app\api\service\User as UserService; +use app\common\enum\OrderType; +use app\common\model\TransferRecord as TransferRecordModel; use app\common\model\UploadFile; +use app\common\service\qrcode\Extract as ExtractQRcode; +use cores\exception\BaseException; +use think\response\Json; /** * 我的订单控制器 @@ -93,6 +91,7 @@ class Order extends Controller ], ]); } + /** * 获取调货单物流跟踪信息 * @param int $orderId 订单ID @@ -104,7 +103,7 @@ class Order extends Controller */ public function expressSearch(string $expressNo): Json { - if(empty($expressNo)) { + if (empty($expressNo)) { return $this->renderError('物流单号不能为空'); } $transferRecordService = new TransferRecord(); @@ -119,6 +118,7 @@ class Order extends Controller return $this->renderError('暂无物流信息'); } + /** * 获取物流跟踪信息 * @param int $orderId 订单ID @@ -164,6 +164,7 @@ class Order extends Controller } return $this->renderError($model->getError()); } + /** * 获取当前用户行为数量 * @return Json @@ -171,8 +172,8 @@ class Order extends Controller */ public function actionCounts(): Json { - $model = new OrderModel; - $counts = $model->getActionCounts(); + $model = new OrderModel; + $counts = $model->getActionCounts(); $data = [ 'reservation_number' => $counts['reservation_number'],//预约记录 'view_number' => $counts['view_number'],//浏览记录 @@ -185,6 +186,7 @@ class Order extends Controller ]; return $this->renderSuccess($data); } + /** * 获取当前用户待处理的订单数量 * @return Json @@ -192,11 +194,11 @@ class Order extends Controller */ public function todoCounts(): Json { - $model = new OrderModel; - $goods_counts = $model->getTodoCounts(OrderType::ORDER); - $service_counts = $model->getTodoCounts(OrderType::SERVER); - $recovery_counts = $model->getTodoCounts(OrderType::RECOVERY); - $dealer_counts = $model->getTodoCounts(OrderType::DEALER); + $model = new OrderModel; + $goods_counts = $model->getTodoCounts(OrderType::ORDER); + $service_counts = $model->getTodoCounts(OrderType::SERVER); + $recovery_counts = $model->getTodoCounts(OrderType::RECOVERY); + $dealer_counts = $model->getTodoCounts(OrderType::DEALER); // var_dump($dealer_counts); $data = [ 'goods_order' => [ @@ -261,13 +263,13 @@ class Order extends Controller * @throws \think\db\exception\ModelNotFoundException */ public function transferList(): Json - { + { $params = $this->request->param(); $where = []; if (!empty($params['search'])) { $where[] = ['goods_sn', 'like', "%{$params["search"]}%"]; } - $list = TransferRecordModel::where('status',1) + $list = TransferRecordModel::where('status', 1) ->where($where) ->order("id desc") ->paginate(10)->each(function ($item, $key) { @@ -282,7 +284,7 @@ class Order extends Controller 'name' => $value, 'price' => $price, 'num' => $goods_num[$seq] ?? 0, - "image" =>'https://imgservice5.suning.cn/uimg1/b2c/image/nXmtUUkwKxasCEBIX90d7w.png' + "image" => 'https://imgservice5.suning.cn/uimg1/b2c/image/nXmtUUkwKxasCEBIX90d7w.png' ]; $total_price += $price; } @@ -290,7 +292,7 @@ class Order extends Controller $item['total_price'] = $total_price; $transfer_image_ids = UploadFile::whereIn('file_id', explode(",", $item['transfer_image_id']))->field('file_id,file_path,file_type,storage,domain')->select(); foreach ($transfer_image_ids as &$transfer_image_id) { - $transfer_image_id['file_path'] = getUrl($transfer_image_id['file_path'],$transfer_image_id['domain']); + $transfer_image_id['file_path'] = getUrl($transfer_image_id['file_path'], $transfer_image_id['domain']); } $chat_image_ids = UploadFile::whereIn('file_id', explode(",", $item['chat_image_id']))->field('file_id,file_path,file_type,storage,domain')->select(); @@ -308,9 +310,9 @@ class Order extends Controller public function editTransfer(): Json { $params = $this->request->param(); - $id = $params['id']??0; + $id = $params['id'] ?? 0; unset($params['id']); - TransferRecordModel::where('id',$id)->update($params); + TransferRecordModel::where('id', $id)->update($params); return $this->renderSuccess('ok'); } @@ -325,13 +327,4 @@ class Order extends Controller } - - - - - - - - - } diff --git a/app/api/model/Order.php b/app/api/model/Order.php index 0a1dd7ee..0e4da0fb 100644 --- a/app/api/model/Order.php +++ b/app/api/model/Order.php @@ -111,30 +111,16 @@ class Order extends OrderModel */ public function getList(string $dataType = 'all') { - $keyword = $_GET['keyword']; // 设置订单类型条件 $dataTypeFilter = $this->getFilterDataType($dataType); // 当前用户ID $userId = UserService::getCurrentLoginUserId(); $query = $this->with(['goods.image']); - if (!empty($keyword) && $keyword !== 'undefined') { - $query->where('order_no', 'like', "%{$keyword}%"); - } $query->where($dataTypeFilter) ->where('user_id', '=', $userId) ->where('is_delete', '=', 0) ->order(['create_time' => 'desc']); - $list = $query->paginate(15)->toArray(); - - //这边后面改成多商户的话需要根据storeid去获取信息 - $service = new StoreService; - $info = $service->data()['storeInfo']->toArray(); - - foreach ($list['data'] as &$v) { - $v['storeInfo'] = $info; - } - - return $list; + return $query->paginate(15); } /** @@ -253,15 +239,12 @@ class Order extends OrderModel switch ($dataType) { case 'all': break; + case 'pay': case 'payment': $filter[] = ['pay_status', '=', PayStatusEnum::PENDING]; $filter[] = ['order_status', '=', OrderStatusEnum::NORMAL]; break; //待付款 - case 'pay': - $filter[] = ['pay_status', '=', PayStatusEnum::PENDING]; - $filter[] = ['order_status', '=', OrderStatusEnum::NORMAL]; - break; //待发货 case 'delivery': $filter = [ @@ -272,6 +255,7 @@ class Order extends OrderModel ]; break; //待收货 + case 'received': case 'receipt': $filter = [ ['pay_status', '=', PayStatusEnum::SUCCESS], @@ -281,14 +265,6 @@ class Order extends OrderModel ]; break; //待收货 - case 'received': - $filter = [ - ['pay_status', '=', PayStatusEnum::SUCCESS], - ['delivery_status', '=', DeliveryStatusEnum::DELIVERED], - ['receipt_status', '=', ReceiptStatusEnum::NOT_RECEIVED], - ['order_status', '=', OrderStatusEnum::NORMAL] - ]; - break; //已完成 case 'complete': $filter = [ @@ -315,6 +291,8 @@ class Order extends OrderModel ]; break; } + //非售后订单 + $filter[] = ['is_refund', '=', 10]; return $filter; } diff --git a/app/store/controller/Order.php b/app/store/controller/Order.php index c0a9c106..b2838094 100644 --- a/app/store/controller/Order.php +++ b/app/store/controller/Order.php @@ -12,8 +12,8 @@ declare (strict_types=1); namespace app\store\controller; -use think\response\Json; use app\store\model\Order as OrderModel; +use think\response\Json; /** * 订单管理 @@ -31,10 +31,45 @@ class Order extends Controller { // 订单列表 $model = new OrderModel; - $list = $model->getList($this->request->param()); + $result = $model->getList($this->request->param()); + $data = $result->items(); + if (!empty($data)) { + foreach ($data as $key => $value) { + $copy_text = "订单号:{$value['order_no']}\n"; + foreach ($value['goods'] as $good) { + $copy_text .= "商品名称:{$good['goods_name']}\n"; + if (!empty($good['goods_no'])) { + $copy_text .= "商品编号:{$good['goods_name']}\n"; + } + $copy_text .= "商品单价:{$good['goods_price']}\n"; + $copy_text .= "商品数量:{$good['total_num']}\n"; + $copy_text .= "商品总价:{$good['total_price']}\n"; + $copy_text .= "\n"; + } + if (!empty($value['address'])) { + $copy_text .= "收件人:{$value['address']['name']}\n"; + $copy_text .= "收件电话:{$value['address']['phone']}\n"; + $address = ''; + if (!empty($value['address']['region'])) { + $address = $value['address']['region']['province'] . $value['address']['region']['city'] . $value['address']['region']['region']; + } + $copy_text .= "收件地址:$address{$value['address']['detail']}\n"; + } + $data[$key]['copy_text'] = $copy_text; + } + } + $list['current_page'] = $result->currentPage(); + $list['last_page'] = $result->lastPage(); + $list['total'] = $result->total(); + $list['data'] = $data; return $this->renderSuccess(compact('dataType', 'list')); } + private function getText() + { + + } + /** * 订单详情 * @param int $orderId diff --git a/app/store/model/Order.php b/app/store/model/Order.php index 3a4ead57..db7603aa 100644 --- a/app/store/model/Order.php +++ b/app/store/model/Order.php @@ -221,6 +221,8 @@ class Order extends OrderModel $params['extractShopId'] > 0 && $filter[] = ['extract_shop_id', '=', (int)$params['extractShopId']]; // 会员ID $params['userId'] > 0 && $filter[] = ['order.user_id', '=', (int)$params['userId']]; + //非售后订单 + $filter[] = ['is_refund', '=', 10]; return $filter; }