|
|
|
@ -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 订单记录 |
|
|
|
|