From 6771fe5cdad38717cf75621dbd1fd415d73e9f76 Mon Sep 17 00:00:00 2001 From: "674780036@qq.com" <674780036@qq.com> Date: Mon, 26 Feb 2024 00:03:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=94=80=E8=AE=A2=E5=8D=95=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E5=BE=85=E4=BB=98=E6=AC=BE=EF=BC=8C=E5=BE=85=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=AD=89=E7=8A=B6=E6=80=81=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/model/dealer/Order.php | 96 ++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/app/api/model/dealer/Order.php b/app/api/model/dealer/Order.php index b47687a4..17443bda 100644 --- a/app/api/model/dealer/Order.php +++ b/app/api/model/dealer/Order.php @@ -16,6 +16,14 @@ use app\api\service\User as UserService; use app\common\model\Order as OrderModel; use app\common\model\dealer\Order as DealerOrderModel; use app\api\model\Order as OrderApiModel; +use app\common\enum\{ + Setting as SettingEnum, + order\PayStatus as PayStatusEnum, + order\OrderStatus as OrderStatusEnum, + order\DeliveryType as DeliveryTypeEnum, + order\ReceiptStatus as ReceiptStatusEnum, + order\DeliveryStatus as DeliveryStatusEnum +}; /** * 分销商订单模型 @@ -50,6 +58,15 @@ class Order extends DealerOrderModel $query = $this->getNewQuery() ->with(['user.avatar', 'order']) ->where($filter); + if(isset($param['dataType'])){ + $dataTypeFilter = $this->getFilterDataType($param['dataType']); + $orders = OrderModel::where($dataTypeFilter) + ->field('*') + ->select() + ->toArray(); + $order_ids =array_column($orders,'order_id'); + $query = $query->whereIn('order_id',$order_ids); + } if((!empty($_GET['keyword'])) ){ $orders = OrderModel::where('order_no','LIKE','%'.$_GET['keyword'].'%') ->field('*') @@ -100,6 +117,85 @@ class Order extends DealerOrderModel return $filter; } + /** + * 设置订单类型条件 + * @param string $dataType + * @return array + */ + private function getFilterDataType(string $dataType): array + { + // 筛选条件 + $filter = []; + // 订单数据类型 + switch ($dataType) { + case 'all': + break; + 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 = [ + ['pay_status', '=', PayStatusEnum::SUCCESS], + ['delivery_status', '<>', DeliveryStatusEnum::DELIVERED], + ['order_status', 'in', [OrderStatusEnum::NORMAL]], + // ['order_status', 'in', [OrderStatusEnum::NORMAL, OrderStatusEnum::APPLY_CANCEL]] + ]; + break; + //待收货 + case 'receipt': + $filter = [ + ['pay_status', '=', PayStatusEnum::SUCCESS], + ['delivery_status', '=', DeliveryStatusEnum::DELIVERED], + ['receipt_status', '=', ReceiptStatusEnum::NOT_RECEIVED], + ['order_status', '=', OrderStatusEnum::NORMAL] + ]; + 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 = [ + ['order_status', '=', OrderStatusEnum::COMPLETED] + ]; + break; + //待取消 + case 'apply_cancel': + $filter = [ + ['order_status', '=', OrderStatusEnum::APPLY_CANCEL] + ]; + break; + //已取消 + case 'cancel': + $filter = [ + ['order_status', '=', OrderStatusEnum::CANCELLED] + ]; + break; + //已评价 + case 'comment': + $filter = [ + ['is_comment', '=', 0], + ['order_status', '=', OrderStatusEnum::COMPLETED] + ]; + break; + } + return $filter; + } + + /** * 创建分销商订单记录 * @param OrderModel $order 订单记录