调试供应链订单退款

This commit is contained in:
luofei 2024-02-03 13:39:14 +08:00
parent ca226a4d2a
commit 097964d352
3 changed files with 14 additions and 19 deletions

View File

@ -162,15 +162,17 @@ class CommissionDao
if ($refunded > 0) { if ($refunded > 0) {
return; return;
} }
// 退佣金和红包 // 退佣金和红包、保证金
$financeRecord = FinancialRecord::where('order_id', $refundOrder->order['order_id']) $financeRecord = FinancialRecord::where('order_id', $refundOrder->order['order_id'])
->whereIn('financial_type', ['commission_to_store', 'commission_to_courier', 'commission_to_promoter']) ->whereIn('financial_type', ['commission_to_store', 'commission_to_courier', 'commission_to_promoter', 'auto_margin'])
->field('user_id uid,user_info nickname,number,mer_id,financial_type')->select()->toArray(); ->field('user_id uid,user_info nickname,number,mer_id,financial_type')->select()->toArray();
if (empty($financeRecord)) { if (empty($financeRecord)) {
return; return;
} }
$userIds = [];
$financeDao = new FinancialDao(); $financeDao = new FinancialDao();
foreach ($financeRecord as $item) { foreach ($financeRecord as $item) {
$userIds[] = $item['uid'];
$financeDao->user = $item; $financeDao->user = $item;
$financeDao->order = $refundOrder->order; $financeDao->order = $refundOrder->order;
$financeDao->platformIn($item['number'], $item['financial_type'] . '_refund', $item['mer_id']); $financeDao->platformIn($item['number'], $item['financial_type'] . '_refund', $item['mer_id']);
@ -180,9 +182,11 @@ class CommissionDao
} }
$financeDao->save(); $financeDao->save();
// TODO 服务团队退红包 // 服务团队退红包
// $redPacks = UserBill::whereIn(''); $redPacks = UserBill::whereIn('uid', $userIds)->where('extra->order_id',$refundOrder->order['order_id'])->select()->toArray();
// (new StoreConsumptionUserDao())->refundByCommission($item['uid'], $refundOrder->order->order_id, $redPack); foreach ($redPacks as $redPack) {
(new StoreConsumptionUserDao())->refundByCommission($redPack['uid'], $refundOrder->order['order_id'], $redPack['number']);
}
$promotionCode = User::where('uid', $refundOrder['uid'])->value('promotion_code'); $promotionCode = User::where('uid', $refundOrder['uid'])->value('promotion_code');
if ($promotionCode) { if ($promotionCode) {

View File

@ -256,18 +256,19 @@ class StoreConsumptionUserDao extends BaseDao
// 写入红包日志 // 写入红包日志
/** @var $userBillRepository UserBillRepository */ /** @var $userBillRepository UserBillRepository */
$userBillRepository = app()->make(UserBillRepository::class); $userBillRepository = app()->make(UserBillRepository::class);
$mark = ['order_amount' => $amount, 'coupon_user_id' => $model['coupon_user_id']]; $extra = ['order_amount' => $amount, 'coupon_user_id' => $model['coupon_user_id']];
if ($this->orderType == 2) { if ($this->orderType == 2) {
$mark['order_id'] = $groupOrderIds; $extra['order_id'] = $groupOrderIds;
} else { } else {
$mark['group_order_id'] = $groupOrderIds; $extra['group_order_id'] = $groupOrderIds;
} }
$userBillRepository->incBill($userId, 'red_pack', "red_pack_{$type}", [ $userBillRepository->incBill($userId, 'red_pack', "red_pack_{$type}", [
'link_id' => $model['coupon_user_id'], 'link_id' => $model['coupon_user_id'],
'status' => 1, 'status' => 1,
'title' => '获得' . $title, 'title' => '获得' . $title,
'number' => $couponPrice, 'number' => $couponPrice,
'mark' => json_encode($mark, JSON_UNESCAPED_UNICODE), 'mark' => '获得' . $title . $couponPrice . ",订单金额:{$amount}",
'extra' => json_encode($extra, JSON_UNESCAPED_UNICODE),
'balance' => 0 'balance' => 0
]); ]);
} }

View File

@ -1210,16 +1210,6 @@ class StoreRefundOrderRepository extends BaseRepository
->whereIn('product_id', $productIds) ->whereIn('product_id', $productIds)
->whereIn('activity_id', 2) ->whereIn('activity_id', 2)
->update(['status' => 0]); ->update(['status' => 0]);
app()->make(FinancialRecordRepository::class)->dec([
'order_id' => $refundOrder->refund_order_id,
'order_sn' => $refundOrder->refund_order_sn,
'user_info' => $refundOrder->user->nickname,
'user_id' => $refundOrder->uid,
'financial_type' => 'refund_order',
'type' => 1,
'number' => $refundOrder->refund_price,
], $refundOrder->mer_id);
} }
public function getRefundMerPrice(StoreRefundOrder $refundOrder, $refundPrice = null) public function getRefundMerPrice(StoreRefundOrder $refundOrder, $refundPrice = null)