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

优化:退款成功 - 平台积分和商户积分相关操作隐藏
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')
->select()
->toArray();
// if (count($lst)) {
// $refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
// ->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number');
// }
foreach ($commissionList as $billTwo) {
$refundPrice = bcadd($refundPrice, $billTwo['number'], 2);
$commissionRefundPrice = 0;
if (count($lst)) {
$commissionRefundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
->where('category', 'brokerage')
->whereIn('type', ['commission_merchants', 'commission_promoter'])
->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'])
->where('uid', $uid)
->where('status', 0)
->field('link_id,number')
->select()
->toArray();
// if (count($lst)) {
// $refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
// ->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number');
// }
$commissionPartnerRefundPrice = 0;
if (count($lst)) {
$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) {
$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)

View File

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