From 0b6b275355ad50386f65a24abc3e04b7f62ce9c5 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 17 Sep 2020 16:55:58 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/UserCenterBlockService.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Service/v3/Implementations/UserCenterBlockService.php b/app/Service/v3/Implementations/UserCenterBlockService.php index 55b8386..2572c42 100644 --- a/app/Service/v3/Implementations/UserCenterBlockService.php +++ b/app/Service/v3/Implementations/UserCenterBlockService.php @@ -34,11 +34,11 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface 'type' => 'user', 'title' => '常用功能', 'items' => [ - ['name' => '收货地址', 'icon' => $img_host . 'user_icons/user_addr.png', 'type' => 'page', 'path' => '/pages/address/userAddress/userAddress','command'=>'user_addr'], - ['name' => '当面付订单查询', 'icon' => $img_host . 'user_icons/offline_orders.png', 'type' => 'page', 'path' => '/pages/facepay/facepay','command'=>'offline_orders'], - ['name' => '在线客服', 'icon' => $img_host . 'user_icons/online_kf.png', 'type' => 'page', 'path' => '','command'=>'online_kf'], - ['name' => '联系服务站', 'icon' => $img_host . 'user_icons/contact_fwz.png', 'type' => 'page', 'path' => '/pages/contactMarket/contactMarket','command'=>'contact_fwz'], - ['name' => '关于懒族', 'icon' => $img_host . 'user_icons/about_lz.png', 'type' => 'page', 'path' => '/pages/aboutUs/aboutUs','command'=>'about'], + ['name' => '收货地址', 'icon' => $img_host . 'user_icons/user_addr2.png', 'type' => 'page', 'path' => '/pages/address/userAddress/userAddress','command'=>'user_addr'], + ['name' => '当面付订单查询', 'icon' => $img_host . 'user_icons/offline_orders2.png', 'type' => 'page', 'path' => '/pages/facepay/facepay','command'=>'offline_orders'], + ['name' => '在线客服', 'icon' => $img_host . 'user_icons/online_kf2.png', 'type' => 'page', 'path' => '','command'=>'online_kf'], + ['name' => '联系服务站', 'icon' => $img_host . 'user_icons/contact_fwz2.png', 'type' => 'page', 'path' => '/pages/contactMarket/contactMarket','command'=>'contact_fwz'], + ['name' => '关于懒族', 'icon' => $img_host . 'user_icons/about_lz2.png', 'type' => 'page', 'path' => '/pages/aboutUs/aboutUs','command'=>'about'], ] ] ]; @@ -47,7 +47,7 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface 'type' => 'store_user', 'title' => '商家相关', 'items' => [ - ['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login'] + ['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter2.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login'] ] ]; @@ -69,7 +69,7 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface 'type' => 'sp_user', 'title' => '服务专员', 'items' => [ - ['name' => '评价', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/zh_cjdianc/pages/appraise/index?service_personnel_id='.$item['data']['id'],'command'=>'sp_login'] + ['name' => '评价', 'icon' => $img_host . 'user_icons/service2.png', 'type' => 'page', 'path' => '/zh_cjdianc/pages/appraise/index?service_personnel_id='.$item['data']['id'],'command'=>'sp_login'] ] ]; } From a74aad5c5e9bea17b8e91c92b7bbc5042ca5619d Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Thu, 17 Sep 2020 17:07:21 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/OrderOnlineController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index 8c717c1..9c74126 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -107,7 +107,7 @@ class OrderOnlineController extends BaseController $distance = $this->locationService->getDistanceByTencent($market->lng,$market->lat,$address->lng,$address->lat); } - if(isset($distance) && $distance > 8000){ + if(isset($distance) && $distance < 8000){ $distributionPrice = $this->distributionPriceService->do($distance); $res['location'] = [ 'address' => $address, From 7c7af0140d46dcb063e3ea4e719f48622f74927d Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Thu, 17 Sep 2020 17:25:14 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E9=85=8D=E9=80=81=E8=B4=B9=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/v3/ErrorCode.php | 8 +++++++- app/Service/v3/Implementations/UserAddressService.php | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php index d6bbf3f..1798098 100644 --- a/app/Constants/v3/ErrorCode.php +++ b/app/Constants/v3/ErrorCode.php @@ -347,5 +347,11 @@ class ErrorCode extends AbstractConstants * 超出配送范围 * @Message("您的地址超出配送范围,请重新选择地址") */ - const LOCATION_LONG_DISTANCE= 1302; + const LOCATION_LONG_DISTANCE = 1302; + + /** + * 超出配送范围 + * @Message("获取收货地址失败") + */ + const LOCATION_USER_ADDRESS = 1303; } \ No newline at end of file diff --git a/app/Service/v3/Implementations/UserAddressService.php b/app/Service/v3/Implementations/UserAddressService.php index ed5cadc..0851fe2 100644 --- a/app/Service/v3/Implementations/UserAddressService.php +++ b/app/Service/v3/Implementations/UserAddressService.php @@ -85,6 +85,10 @@ class UserAddressService implements UserAddressServiceInterface { $address = $this->get($userAddressId); $market = Market::query()->select('lng','lat')->find($marketId); + if(empty($address['address']->lng) || empty($address['address']->lat) || empty($market->lng) || empty($market->lat)){ + throw new ErrorCodeException(ErrorCode::LOCATION_USER_ADDRESS); + } + var_dump($address->lng,$market); $distance = $this->locationService->getDistanceByTencent($address['address']->lng,$address['address']->lat,$market->lng,$market->lat); $distributionPrice = $this->distributionPriceService->do($distance); $res['address'] = $address; From 4832bbe22a886d4e92e99d05a20b719827fe9e12 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Thu, 17 Sep 2020 17:26:46 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Coupon.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Model/v3/Coupon.php b/app/Model/v3/Coupon.php index 35607c5..f3df3bf 100644 --- a/app/Model/v3/Coupon.php +++ b/app/Model/v3/Coupon.php @@ -17,7 +17,8 @@ class Coupon extends Model ]; protected $casts = [ - 'activity_available' => 'array' + 'activity_available' => 'array', + 'tags' => 'array' ]; public function getFullAmountTextAttribute() From 67cf86ebe376ae8ba64fdc7ccc3428484e8eee4b Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Thu, 17 Sep 2020 17:38:41 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=BA=97=E9=93=BA=20=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/StoreController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Controller/v3/StoreController.php b/app/Controller/v3/StoreController.php index d81e327..2afc46e 100644 --- a/app/Controller/v3/StoreController.php +++ b/app/Controller/v3/StoreController.php @@ -54,6 +54,13 @@ class StoreController extends BaseController $data = $this->storeService->detail($params['store_id']); $data['is_collected'] = (bool)$this->collectService->check($params['user_id'],$params['store_id']); $data['goods_types'] = $this->categoryService->allForStore($params['store_id']); + $data['in_business'] = $this->storeService->check($params['store_id']); + if($data['in_business'] === true) + { + $data['in_business_text'] = '营业中'; + }else{ + $data['in_business_text'] = '休息中'; + } return $this->success(['store' => $data]); } From 636c214516fc67e6c566e9e983fb1d705f9840b2 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 17 Sep 2020 17:57:30 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=8E=8B=E5=BA=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/OrderOfflineController.php | 2 +- .../Implementations/GoodsActivityService.php | 8 ++- .../v3/Implementations/GoodsService.php | 11 +++- .../v3/Implementations/OrderOnlineService.php | 61 ++++++++++++++++++- 4 files changed, 75 insertions(+), 7 deletions(-) diff --git a/app/Controller/v3/OrderOfflineController.php b/app/Controller/v3/OrderOfflineController.php index e929c3b..52d1003 100644 --- a/app/Controller/v3/OrderOfflineController.php +++ b/app/Controller/v3/OrderOfflineController.php @@ -47,7 +47,7 @@ class OrderOfflineController extends BaseController $params = $validator->validated(); $store = $this->storeService->detail($params['store_id']); - return $this->success(['store' => $store, 'digit_length' => 8]); + return $this->success(['store' => $store, 'digit_length' => 7]); } /** diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index 1bbd217..5bb2122 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -12,6 +12,7 @@ use App\Constants\v3\Store; use App\Constants\v3\Goods; use App\Model\v3\GoodsActivity; use App\Model\v3\GoodsActivityBanner; +use Hyperf\Redis\Redis; use Hyperf\Utils\ApplicationContext; class GoodsActivityService implements GoodsActivityServiceInterface @@ -24,6 +25,9 @@ class GoodsActivityService implements GoodsActivityServiceInterface public function check(GoodsActivity $goods, $num, $userId) { + $redis = ApplicationContext::getContainer()->get(Redis::class); + $inventoryKey = 'goods_inventory_sold_2_'.$goods->id; // 拼接activity_type和goods_id + if (empty($goods)) { return ErrorCode::GOODS_ACTIVITY_NOT_EXISTS; } @@ -44,7 +48,9 @@ class GoodsActivityService implements GoodsActivityServiceInterface } // 商品库存不足 - if($goods->is_infinite != 1 && $goods->inventory < $num){ + // 获取冻结的库存 + $inventoryFrozen = (int)$redis->get($inventoryKey); + if($goods->is_infinite != 1 && $goods->inventory < ($num+$inventoryFrozen)){ return ErrorCode::GOODS_ACTIVITY_INVENTORY_ERROR; } diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index bf240f3..57fb1c3 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -10,6 +10,9 @@ use App\Model\v3\Goods; use App\Model\v3\GoodsBanner; use App\Constants\v3\Store; use App\Constants\v3\goods as goodsConstants; +use Hyperf\Redis\Redis; +use Hyperf\Utils\ApplicationContext; + class GoodsService implements GoodsServiceInterface { public function do($goodsId) @@ -17,10 +20,12 @@ class GoodsService implements GoodsServiceInterface } - public function check(Goods $goods,$num = 1) { + $redis = ApplicationContext::getContainer()->get(Redis::class); + $inventoryKey = 'goods_inventory_sold_1_'.$goods->id; // 拼接activity_type和goods_id + if (empty($goods)) { return ErrorCode::GOODS_NOT_EXISTS; } @@ -34,7 +39,9 @@ class GoodsService implements GoodsServiceInterface return ErrorCode::GOODS_ON_SALE_NO; } // 商品库存不足 - if($goods->is_infinite != 1 && $goods->inventory < $num){ + // 获取冻结的库存 + $inventoryFrozen = (int)$redis->get($inventoryKey); + if($goods->is_infinite != 1 && $goods->inventory < ($num+$inventoryFrozen)){ return ErrorCode::GOODS_INVENTORY_ERROR; } diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index 50fd29c..caf974d 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -34,6 +34,7 @@ use Hyperf\Database\Model\Model; use Hyperf\DbConnection\Db; use Hyperf\Di\Annotation\Inject; use App\Service\v3\Interfaces\OrderOnlineServiceInterface; +use Hyperf\Redis\Redis; use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Utils\ApplicationContext; @@ -115,6 +116,8 @@ class OrderOnlineService implements OrderOnlineServiceInterface */ public function do($marketId, $userId, $userAddrId, $storeList, $totalMoney, $deliveryTimeNote='尽快送达', $serviceMoney=0, $receiveCouponIds=null, $plat=''){ + $redis = ApplicationContext::getContainer()->get(Redis::class); + $carts = []; Db::beginTransaction(); try { @@ -335,6 +338,18 @@ class OrderOnlineService implements OrderOnlineServiceInterface Db::commit(); + // 压redis库存 + 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, $cart->num); + } else { + $redis->incrBy($inventoryKey, $cart->num); + } + } + // 清除购物车 $this->shopCartUpdateService->doClear($userId, $marketId); @@ -345,6 +360,17 @@ class OrderOnlineService implements OrderOnlineServiceInterface return $this->paymentService->do($globalOrderId, $totalAmount, $userId, config('wechat.notify_url.online')); } catch (Exception $e) { Db::rollBack(); + // 释redis库存 + 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, $cart->num); + } + } $this->log->event(LogLabel::ORDER_ONLINE_LOG, ['msg' => $e->getMessage()]); throw new ErrorCodeException(ErrorCode::ORDER_ONLINE_FAIL); } @@ -388,15 +414,31 @@ class OrderOnlineService implements OrderOnlineServiceInterface // 撤销活动商品购买记录 $orders = Order::query()->where(['order_main_id' => $globalOrderId])->get()->toArray(); $orderGoods = OrderGoods::query() - ->where('activity_type', 2) + // ->where('activity_type', 2) ->whereIn('order_id', array_values(array_column($orders, 'id'))) - ->get(); + ->get() + ->toArray(); foreach ($orderGoods as $key => &$goods) { - $this->goodsActivityService->clearCacheRecord($goods->goods_id, $goods->number, $orderMain->user_id); + if ($goods['activity_type'] == 2) { + $this->goodsActivityService->clearCacheRecord($goods['goods_id'], $goods['number'], $orderMain['user_id']); + } } Db::commit(); + // 释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, $goodsItem['number']); + } + } + // 记录badge $orderChildIds = array_values(array_column($orders, 'store_id')); $this->badgeService->doByOrder($orderMain->user_id, $orderChildIds, $orderMain->global_order_id, OrderState::CANCELED); @@ -479,6 +521,19 @@ class OrderOnlineService implements OrderOnlineServiceInterface Db::commit(); + // 释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, $goodsItem['number']); + } + } + // 月销流水 $statistics = []; foreach ($orders as $key => &$order) { From 2d837cb959d084328a4c83c6284701e50d25939e Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 17 Sep 2020 18:51:05 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/OrderOnlineService.php | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index caf974d..5a7c06c 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -217,6 +217,17 @@ class OrderOnlineService implements OrderOnlineServiceInterface 'cover_img' => $goods->cover_img ?: '', 'spec' => json_encode($goods->spec), ]; + + // 拼接activity_type和goods_id + $inventoryKey = 'goods_inventory_sold_'.$cart->activity_type.'_'.$cart->goods_id; + + // 压redis库存 + // redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放 + if (!$redis->exists($inventoryKey)) { + $redis->set($inventoryKey, $cart->num); + } else { + $redis->incrBy($inventoryKey, $cart->num); + } } // 子订单数据 @@ -338,18 +349,6 @@ class OrderOnlineService implements OrderOnlineServiceInterface Db::commit(); - // 压redis库存 - 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, $cart->num); - } else { - $redis->incrBy($inventoryKey, $cart->num); - } - } - // 清除购物车 $this->shopCartUpdateService->doClear($userId, $marketId); From cf5a9e1c93414416b62056fbd232167fe39eaf03 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 17 Sep 2020 19:12:25 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=86=8D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/GoodsActivityService.php | 8 ++++++++ app/Service/v3/Implementations/GoodsService.php | 7 +++++++ app/Service/v3/Implementations/OrderOnlineService.php | 11 ----------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index 5bb2122..da5516a 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -54,6 +54,14 @@ class GoodsActivityService implements GoodsActivityServiceInterface return ErrorCode::GOODS_ACTIVITY_INVENTORY_ERROR; } + // 压redis库存 + // redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放 + if (!$redis->exists($inventoryKey)) { + $redis->set($inventoryKey, $num); + } else { + $redis->incrBy($inventoryKey, $num); + } + // 是否超过限购数量 if ($goods->restrict_num != 0 && $goods->restrict_num < $num) { return ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT; diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 57fb1c3..1198ce8 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -44,6 +44,13 @@ class GoodsService implements GoodsServiceInterface if($goods->is_infinite != 1 && $goods->inventory < ($num+$inventoryFrozen)){ return ErrorCode::GOODS_INVENTORY_ERROR; } + // 压redis库存 + // redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放 + if (!$redis->exists($inventoryKey)) { + $redis->set($inventoryKey, $num); + } else { + $redis->incrBy($inventoryKey, $num); + } // 是否超过限购数量 if ($goods->restrict_num != 0 && $goods->restrict_num < $num) { diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index 5a7c06c..a2824dd 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -217,17 +217,6 @@ class OrderOnlineService implements OrderOnlineServiceInterface 'cover_img' => $goods->cover_img ?: '', 'spec' => json_encode($goods->spec), ]; - - // 拼接activity_type和goods_id - $inventoryKey = 'goods_inventory_sold_'.$cart->activity_type.'_'.$cart->goods_id; - - // 压redis库存 - // redis记录当前商品的购买数量,压库存,下单失败、下单成功扣库存成功、订单取消的时候释放 - if (!$redis->exists($inventoryKey)) { - $redis->set($inventoryKey, $cart->num); - } else { - $redis->incrBy($inventoryKey, $cart->num); - } } // 子订单数据