优化:佣金统计 - 添加已退款佣金处理

优化:退款成功 - 平台积分和商户积分相关操作隐藏
This commit is contained in:
wuhui_zzw 2024-01-03 13:58:49 +08:00
parent dfc2785eb5
commit dcd4be4234
2 changed files with 52 additions and 44 deletions

View File

@ -131,31 +131,39 @@ class UserBillDao extends BaseDao
->field('link_id,number') ->field('link_id,number')
->select() ->select()
->toArray(); ->toArray();
// if (count($lst)) { $commissionRefundPrice = 0;
// $refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid) if (count($lst)) {
// ->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number'); $commissionRefundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
// } ->where('category', 'brokerage')
foreach ($commissionList as $billTwo) { ->whereIn('type', ['commission_merchants', 'commission_promoter'])
$refundPrice = bcadd($refundPrice, $billTwo['number'], 2); ->sum('number');
}
foreach ($commissionList as $billTwo) {
$commissionRefundPrice = bcadd($commissionRefundPrice, $billTwo['number'], 2);
} }
// 合伙人分红 // 合伙人分红
$commissionPartnerList = UserBill::getDB()->where('category', 'brokerage') $commissionPartnerList = UserBill::getDB()
->where('category', 'brokerage')
->whereIn('type', ['commission_partner']) ->whereIn('type', ['commission_partner'])
->where('uid', $uid) ->where('uid', $uid)
->where('status', 0) ->where('status', 0)
->field('link_id,number') ->field('link_id,number')
->select() ->select()
->toArray(); ->toArray();
// if (count($lst)) { $commissionPartnerRefundPrice = 0;
// $refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid) if (count($lst)) {
// ->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number'); $commissionPartnerRefundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))
// } ->where('uid', $uid)
->where('category', 'brokerage')
->whereIn('type', ['commission_partner'])
->sum('number');
}
foreach ($commissionPartnerList as $billThree) { foreach ($commissionPartnerList as $billThree) {
$refundPrice = bcadd($refundPrice, $billThree['number'], 2); $commissionPartnerRefundPrice = bcadd($commissionPartnerRefundPrice, $billThree['number'], 2);
} }
return $refundPrice;
return (float)sprintf("%.2f",(float)$refundPrice + (float)$commissionRefundPrice + (float)$commissionPartnerList);
} }
public function lockIntegral($uid = null, $order_id = null) public function lockIntegral($uid = null, $order_id = null)

View File

@ -1350,39 +1350,39 @@ class StoreRefundOrderRepository extends BaseRepository
// $refundOrder->order // $refundOrder->order
// ],1)); // ],1));
if ($refundOrder->integral > 0) { if ($refundOrder->integral > 0) {
$make = app()->make(UserRepository::class); // $make = app()->make(UserRepository::class);
$make->update($refundOrder->uid, ['integral' => Db::raw('integral+' . $refundOrder->integral)]); // $make->update($refundOrder->uid, ['integral' => Db::raw('integral+' . $refundOrder->integral)]);
$userIntegral = $make->get($refundOrder->uid)->integral; // $userIntegral = $make->get($refundOrder->uid)->integral;
$make1 = app()->make(UserBillRepository::class); // $make1 = app()->make(UserBillRepository::class);
// 判断:根据订单抵扣使用积分 退还平台积分或者商户积分 // 判断:根据订单抵扣使用积分 退还平台积分或者商户积分
if((float)$refundOrder->order->use_mer_integral > 0){ // if((float)$refundOrder->order->use_mer_integral > 0){
// 使用的商户积分 // // 使用的商户积分
app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)$refundOrder->mer_id,(float)sprintf('%.2f',$refundOrder->integral)); // app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)$refundOrder->mer_id,(float)sprintf('%.2f',$refundOrder->integral));
$mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '商户积分'; // $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '商户积分';
}else{ // }else{
// 使用的平台积分 // // 使用的平台积分
app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)0,(float)sprintf('%.2f',$refundOrder->integral)); // app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)0,(float)sprintf('%.2f',$refundOrder->integral));
$mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '平台积分'; // $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '平台积分';
} // }
$make1->incBill($refundOrder->uid, 'integral', 'refund', [ // $make1->incBill($refundOrder->uid, 'integral', 'refund', [
'link_id' => $refundOrder->order_id, // 'link_id' => $refundOrder->order_id,
'status' => 1, // 'status' => 1,
'title' => '订单退款', // 'title' => '订单退款',
'number' => $refundOrder->integral, // 'number' => $refundOrder->integral,
'mark' => $mark, // 'mark' => $mark,
'balance' => $userIntegral // 'balance' => $userIntegral
]); // ]);
$make1->incBill($refundOrder->uid, 'mer_integral', 'refund', [ // $make1->incBill($refundOrder->uid, 'mer_integral', 'refund', [
'link_id' => $refundOrder->order_id, // 'link_id' => $refundOrder->order_id,
'status' => 1, // 'status' => 1,
'title' => '订单退款', // 'title' => '订单退款',
'number' => $refundOrder->integral, // 'number' => $refundOrder->integral,
'mark' => $mark, // 'mark' => $mark,
'balance' => $userIntegral, // 'balance' => $userIntegral,
'mer_id' => $refundOrder->mer_id // 'mer_id' => $refundOrder->mer_id
]); // ]);
} }
//退还赠送积分 //退还赠送积分