|
|
@ -24,6 +24,7 @@ use App\Service\v3\Interfaces\BadgeServiceInterface; |
|
|
use App\Service\v3\Interfaces\CouponRecServiceInterface; |
|
|
use App\Service\v3\Interfaces\CouponRecServiceInterface; |
|
|
use App\Service\v3\Interfaces\CouponServiceInterface; |
|
|
use App\Service\v3\Interfaces\CouponServiceInterface; |
|
|
use App\Service\v3\Interfaces\GoodsActivityServiceInterface; |
|
|
use App\Service\v3\Interfaces\GoodsActivityServiceInterface; |
|
|
|
|
|
use App\Service\v3\Interfaces\GoodsInventoryServiceInterface; |
|
|
use App\Service\v3\Interfaces\GoodsServiceInterface; |
|
|
use App\Service\v3\Interfaces\GoodsServiceInterface; |
|
|
use App\Service\v3\Interfaces\InitialDeliveryServiceInterface; |
|
|
use App\Service\v3\Interfaces\InitialDeliveryServiceInterface; |
|
|
use App\Service\v3\Interfaces\PaymentServiceInterface; |
|
|
use App\Service\v3\Interfaces\PaymentServiceInterface; |
|
|
@ -102,6 +103,12 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
*/ |
|
|
*/ |
|
|
protected $initialDeliveryService; |
|
|
protected $initialDeliveryService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Inject |
|
|
|
|
|
* @var GoodsInventoryServiceInterface |
|
|
|
|
|
*/ |
|
|
|
|
|
protected $goodsInventoryService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 下单 |
|
|
* 下单 |
|
|
* @param $marketId |
|
|
* @param $marketId |
|
|
@ -224,12 +231,13 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
|
|
|
|
|
|
// 压redis库存
|
|
|
// 压redis库存
|
|
|
// redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放
|
|
|
// redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放
|
|
|
$inventoryKey = 'goods_inventory_sold_'.$cart->activity_type.'_'.$cart->goods_id; // 拼接activity_type和goods_id
|
|
|
|
|
|
if (!$redis->exists($inventoryKey)) { |
|
|
|
|
|
$redis->set($inventoryKey, $cart->num); |
|
|
|
|
|
} else { |
|
|
|
|
|
$redis->incrBy($inventoryKey, intval($cart->num)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// $inventoryKey = 'goods_inventory_sold_'.$cart->activity_type.'_'.$cart->goods_id; // 拼接activity_type和goods_id
|
|
|
|
|
|
// if (!$redis->exists($inventoryKey)) {
|
|
|
|
|
|
// $redis->set($inventoryKey, $cart->num);
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// $redis->incrBy($inventoryKey, intval($cart->num));
|
|
|
|
|
|
// }
|
|
|
|
|
|
$this->goodsInventoryService->doSold($cart->activity_type, $cart->goods_id, $cart->num); |
|
|
$isCacheInventory = true; |
|
|
$isCacheInventory = true; |
|
|
|
|
|
|
|
|
if ($cart->activity_type == 2) { |
|
|
if ($cart->activity_type == 2) { |
|
|
@ -404,14 +412,15 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
if ($isCacheInventory) { |
|
|
if ($isCacheInventory) { |
|
|
// 释redis库存
|
|
|
// 释redis库存
|
|
|
foreach ($carts as $k => &$cart) { |
|
|
foreach ($carts as $k => &$cart) { |
|
|
// 拼接activity_type和goods_id
|
|
|
|
|
|
$inventoryKey = 'goods_inventory_sold_'.$cart->activity_type.'_'.$cart->goods_id; |
|
|
|
|
|
// redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放
|
|
|
|
|
|
if (!$redis->exists($inventoryKey)) { |
|
|
|
|
|
$redis->set($inventoryKey, 0); |
|
|
|
|
|
} else { |
|
|
|
|
|
$redis->decrBy($inventoryKey, intval($cart->num)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// // 拼接activity_type和goods_id
|
|
|
|
|
|
// $inventoryKey = 'goods_inventory_sold_'.$cart->activity_type.'_'.$cart->goods_id;
|
|
|
|
|
|
// // redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放
|
|
|
|
|
|
// if (!$redis->exists($inventoryKey)) {
|
|
|
|
|
|
// $redis->set($inventoryKey, 0);
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// $redis->decrBy($inventoryKey, intval($cart->num));
|
|
|
|
|
|
// }
|
|
|
|
|
|
$this->goodsInventoryService->undoSold($cart->activity_type, $cart->goods_id, $cart->num); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
$this->log->event(LogLabel::ORDER_ONLINE_LOG, ['msg' => $e->getMessage()]); |
|
|
$this->log->event(LogLabel::ORDER_ONLINE_LOG, ['msg' => $e->getMessage()]); |
|
|
@ -477,14 +486,15 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
// 释redis库存
|
|
|
// 释redis库存
|
|
|
$redis = ApplicationContext::getContainer()->get(Redis::class); |
|
|
$redis = ApplicationContext::getContainer()->get(Redis::class); |
|
|
foreach ($orderGoods as $k => &$goodsItem) { |
|
|
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'])); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// // 拼接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']));
|
|
|
|
|
|
// }
|
|
|
|
|
|
$this->goodsInventoryService->undoSold($goodsItem['activity_type'], $goodsItem['goods_id'], $goodsItem['number']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 记录badge
|
|
|
// 记录badge
|
|
|
@ -572,14 +582,15 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
// 释redis库存
|
|
|
// 释redis库存
|
|
|
$redis = ApplicationContext::getContainer()->get(Redis::class); |
|
|
$redis = ApplicationContext::getContainer()->get(Redis::class); |
|
|
foreach ($orderGoods as $k => &$goodsItem) { |
|
|
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'])); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// // 拼接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']));
|
|
|
|
|
|
// }
|
|
|
|
|
|
$this->goodsInventoryService->undoSold($goodsItem['activity_type'], $goodsItem['goods_id'], $goodsItem['number']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 月销流水
|
|
|
// 月销流水
|
|
|
@ -691,19 +702,6 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
$orderIds = Order::query()->where(['order_main_id' => $orderMain->global_order_id])->pluck('id'); |
|
|
$orderIds = Order::query()->where(['order_main_id' => $orderMain->global_order_id])->pluck('id'); |
|
|
$orderGoods = OrderGoods::query()->whereIn('order_id', $orderIds)->get()->toArray(); |
|
|
$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); |
|
|
@ -745,14 +743,15 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
// 释redis库存
|
|
|
// 释redis库存
|
|
|
$redis = ApplicationContext::getContainer()->get(Redis::class); |
|
|
$redis = ApplicationContext::getContainer()->get(Redis::class); |
|
|
foreach ($orderGoods as $k => &$goodsItem) { |
|
|
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'])); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// // 拼接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']));
|
|
|
|
|
|
// }
|
|
|
|
|
|
$this->goodsInventoryService->undoSold($goodsItem['activity_type'], $goodsItem['goods_id'], $goodsItem['number']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 记录badge
|
|
|
// 记录badge
|
|
|
|