|
|
@ -639,6 +639,22 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
|
|
|
|
|
|
$orderMain = $this->check($globalOrderId, $userId, OrderState::REFUNDING); |
|
|
$orderMain = $this->check($globalOrderId, $userId, OrderState::REFUNDING); |
|
|
|
|
|
|
|
|
|
|
|
$orderIds = Order::query()->where(['order_main_id' => $orderMain->global_order_id])->pluck('id'); |
|
|
|
|
|
$orderGoods = OrderGoods::query()->whereIn('order_id', $orderIds)->get()->toArray(); |
|
|
|
|
|
|
|
|
|
|
|
// 释redis库存
|
|
|
|
|
|
$redis = ApplicationContext::getContainer()->get(Redis::class); |
|
|
|
|
|
foreach ($orderGoods as $k => &$goodsItem) { |
|
|
|
|
|
// 拼接activity_type和goods_id
|
|
|
|
|
|
$inventoryKey = 'goods_inventory_sold_'.$goodsItem['activity_type'].'_'.$goodsItem['goods_id']; |
|
|
|
|
|
// redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放
|
|
|
|
|
|
if (!$redis->exists($inventoryKey)) { |
|
|
|
|
|
$redis->set($inventoryKey, 0); |
|
|
|
|
|
} else { |
|
|
|
|
|
$redis->decrBy($inventoryKey, intval($goodsItem['number'])); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 微信退款
|
|
|
// 微信退款
|
|
|
if ($orderMain->pay_type == Payment::WECHAT) { |
|
|
if ($orderMain->pay_type == Payment::WECHAT) { |
|
|
return $this->paymentService->undo($orderMain->global_order_id, $userId); |
|
|
return $this->paymentService->undo($orderMain->global_order_id, $userId); |
|
|
|