|
@@ -454,10 +454,10 @@ class OrderService extends BaseService
|
|
|
|
|
|
|
|
// 商品库存扣除
|
|
// 商品库存扣除
|
|
|
if ($orderGoods) {
|
|
if ($orderGoods) {
|
|
|
- foreach ($orderGoods as $goods) {
|
|
|
|
|
- $id = isset($goods['goods_id']) ? $goods['goods_id'] : 0;
|
|
|
|
|
- $num = isset($goods['num']) ? $goods['num'] : 0;
|
|
|
|
|
- $skuId = isset($goods['sku_id']) ? $goods['sku_id'] : 0;
|
|
|
|
|
|
|
+ foreach ($orderGoods as $item) {
|
|
|
|
|
+ $id = isset($item['goods_id']) ? $item['goods_id'] : 0;
|
|
|
|
|
+ $num = isset($item['num']) ? $item['num'] : 0;
|
|
|
|
|
+ $skuId = isset($item['sku_id']) ? $item['sku_id'] : 0;
|
|
|
if ($id && !GoodsModel::where(['id' => $id])->update(['stock' => DB::raw("stock - {$num}"), 'update_time' => time()])) {
|
|
if ($id && !GoodsModel::where(['id' => $id])->update(['stock' => DB::raw("stock - {$num}"), 'update_time' => time()])) {
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
RedisService::clear($cacheLockKey);
|
|
RedisService::clear($cacheLockKey);
|
|
@@ -476,7 +476,6 @@ class OrderService extends BaseService
|
|
|
// 清空购物车结算商品
|
|
// 清空购物车结算商品
|
|
|
if($submitType == 'cart'){
|
|
if($submitType == 'cart'){
|
|
|
$skuIds = $goods ? array_column($goods, 'sku_id') : [];
|
|
$skuIds = $goods ? array_column($goods, 'sku_id') : [];
|
|
|
- var_dump($skuIds);
|
|
|
|
|
CartModel::whereIn('goods_id',$ids)->whereIn('sku_id',$skuIds)->where(['user_id'=>$userId,'mark'=>1])->update(['mark'=>0,'num'=>0,'update_time'=>time()]);
|
|
CartModel::whereIn('goods_id',$ids)->whereIn('sku_id',$skuIds)->where(['user_id'=>$userId,'mark'=>1])->update(['mark'=>0,'num'=>0,'update_time'=>time()]);
|
|
|
RedisService::clear("caches:goods:cartCount:{$userId}");
|
|
RedisService::clear("caches:goods:cartCount:{$userId}");
|
|
|
}
|
|
}
|