|
|
|
@ -15,6 +15,7 @@ namespace app\api\model\dealer; |
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分销商订单模型 |
|
|
|
@ -46,21 +47,36 @@ class Order extends DealerOrderModel |
|
|
|
|
// 检索查询条件 |
|
|
|
|
$filter = $this->getFilter($param); |
|
|
|
|
// 获取分销商订单列表 |
|
|
|
|
$list = $this->getNewQuery() |
|
|
|
|
$query = $this->getNewQuery() |
|
|
|
|
->with(['user.avatar', 'order']) |
|
|
|
|
->where($filter) |
|
|
|
|
->where('first_user_id|second_user_id|third_user_id', '=', $userId) |
|
|
|
|
->where($filter); |
|
|
|
|
if((!empty($_GET['keyword'])) ){ |
|
|
|
|
$orders = OrderModel::where('order_no','LIKE','%'.$_GET['keyword'].'%') |
|
|
|
|
->field('*') |
|
|
|
|
->select() |
|
|
|
|
->toArray(); |
|
|
|
|
$order_ids =array_column($orders,'order_id'); |
|
|
|
|
$query = $query->whereIn('order_id',$order_ids); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$list = $query->where('first_user_id|second_user_id|third_user_id', '=', $userId) |
|
|
|
|
->where('is_invalid', '=', 0) |
|
|
|
|
->order(['create_time' => 'desc']) |
|
|
|
|
->paginate(15); |
|
|
|
|
// 数据整理 |
|
|
|
|
foreach ($list as &$item) { |
|
|
|
|
$with = ['goods' => ['image'], 'extract_shop', 'delivery.express']; |
|
|
|
|
$where = ['order_id' => $item['order_id']]; |
|
|
|
|
// 查询订单记录 |
|
|
|
|
$order_goods = OrderApiModel::detail($where, $with); |
|
|
|
|
// 我的佣金 |
|
|
|
|
$money = [ |
|
|
|
|
$item['first_user_id'] => $item['first_money'], |
|
|
|
|
$item['second_user_id'] => $item['second_money'], |
|
|
|
|
$item['third_user_id'] => $item['third_money'], |
|
|
|
|
]; |
|
|
|
|
$item['goods'] = $order_goods['goods']; |
|
|
|
|
$item['my_money'] = $money[$userId]; |
|
|
|
|
} |
|
|
|
|
return $list; |
|
|
|
@ -97,11 +113,12 @@ class Order extends DealerOrderModel |
|
|
|
|
// 分销订单模型 |
|
|
|
|
$model = new static; |
|
|
|
|
// 分销商基本设置 |
|
|
|
|
$setting = Setting::getItem('basic'); |
|
|
|
|
$setting = Setting::getItem('basic'); |
|
|
|
|
// 是否开启分销功能 |
|
|
|
|
if (!$setting['is_open']) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取当前买家的所有上级分销商用户id |
|
|
|
|
$dealerUser = $model->getDealerUserId((int)$order['user_id'], (int)$setting['level'], (bool)$setting['self_buy']); |
|
|
|
|
// 非分销订单 |
|
|
|
|