优化:推广佣金显示中添加平台抽成相关佣金
This commit is contained in:
parent
82d40201f9
commit
f0c9d80f19
|
|
@ -8,6 +8,7 @@ namespace app\common\model\store\order;
|
|||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\community\Community;
|
||||
use app\common\model\store\platformCommission\Record;
|
||||
use app\common\model\store\product\ProductGroupUser;
|
||||
use app\common\model\store\service\StoreService;
|
||||
use app\common\model\store\shipping\Express;
|
||||
|
|
@ -183,4 +184,11 @@ class StoreOrder extends BaseModel
|
|||
{
|
||||
return StoreRefundOrder::where('order_id',$this->order_id)->where('status',3)->sum('refund_price');
|
||||
}
|
||||
|
||||
public function platformCommission()
|
||||
{
|
||||
return $this->hasMany(Record::class, 'order_id', 'order_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ class LegumesLogRepository extends BaseRepository{
|
|||
'uid',
|
||||
'sum(order_money) as total_order_money',
|
||||
'sum(get_legumes) as total_get_legumes',
|
||||
'sum(refund_order_money) as total_refund_order_money',
|
||||
'sum(refund_get_legumes) as total_refund_get_legumes',
|
||||
'sum(get_integral) as total_get_integral',
|
||||
'sum(use_integral) as total_use_integral',
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1095,12 +1095,16 @@ class UserRepository extends BaseRepository
|
|||
$all[] = -1;
|
||||
$query = app()->make(StoreOrderRepository::class)->usersOrderQuery($where, $all, (!isset($where['level']) || !$where['level'] || $where['level'] == -1) ? $uid : 0);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->field('uid,order_sn,pay_time,extension_one,extension_two,is_selfbuy')->with([
|
||||
$list = $query->page($page, $limit)->field('uid,order_id,order_sn,pay_time,extension_one,extension_two,is_selfbuy')->with([
|
||||
'user' => function ($query) {
|
||||
$query->field('avatar,nickname,uid');
|
||||
},
|
||||
'orderProduct'
|
||||
'orderProduct',
|
||||
'platformCommission' => function($query){
|
||||
$query->field('order_id,(commission_partner_money + commission_merchants_money + commission_promoter_money) as total_platform_commission');
|
||||
}
|
||||
])->select()->toArray();
|
||||
|
||||
foreach ($list as $k => $item) {
|
||||
if ($item['is_selfbuy']) {
|
||||
if ($item['uid'] == $uid) {
|
||||
|
|
@ -1114,6 +1118,9 @@ class UserRepository extends BaseRepository
|
|||
$list[$k]['brokerage'] = in_array($item['uid'], $ids) ? $item['extension_one'] : $item['extension_two'];
|
||||
}
|
||||
unset($list[$k]['extension_one'], $list[$k]['extension_two']);
|
||||
// 处理佣金 + 平台抽成相关佣金
|
||||
$sumPlatformCommission = (float)array_sum(array_column($item['platformCommission'],'total_platform_commission'));
|
||||
$list[$k]['brokerage'] = (float)sprintf("%.2f",$list[$k]['brokerage'] + $sumPlatformCommission);
|
||||
}
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue