Browse Source

限购种数提示语

master
weigang 5 years ago
parent
commit
ef2e854fbe
  1. 3
      app/Service/v3/Implementations/GoodsActivityService.php
  2. 6
      app/Service/v3/Implementations/OrderOnlineService.php
  3. 4
      app/Service/v3/Implementations/ShopCartUpdateService.php

3
app/Service/v3/Implementations/GoodsActivityService.php

@ -158,6 +158,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface
$sourceGoods = GoodsActivity::query()
->whereIn('id', $goodsIds)
->orderByRaw('FIELD(`id`,'.implode(',', $goodsIds).')')
->get()->toArray();
// $redis = ApplicationContext::getContainer()->get(Redis::class);
@ -200,7 +201,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface
}
if ($goods['type_limit'] != 0 && $buyNum[$goods['type_limit']] > $goods['type_limit']) {
return false;
return $sourceGoods[$key-1]['name'];
}
}

6
app/Service/v3/Implementations/OrderOnlineService.php

@ -230,7 +230,7 @@ class OrderOnlineService implements OrderOnlineServiceInterface
// 用户购物车数据
$cartIds = explode(',', $storeItem->cart_ids);
$shopcartIds = array_merge($shopcartIds, $cartIds);
$carts = ShoppingCart::query()->whereIn('id', $cartIds)->where(['market_id' => $marketId, 'user_id' => $userId])->get();
$carts = ShoppingCart::query()->whereIn('id', $cartIds)->where(['market_id' => $marketId, 'user_id' => $userId])->orderBy('updated_at ASC')->get();
foreach ($carts as $k => &$cart) {
// 查个商品,做商品有效的判断检查
$goods = [];
@ -443,9 +443,9 @@ class OrderOnlineService implements OrderOnlineServiceInterface
// 判断是否有购买多个特价商品
$check = $this->goodsActivityService->checkOrderActivityCount($activityGoodsIds);
if(!$check){
if($check !== true){
$this->log->event(LogLabel::ORDER_ONLINE_LOG, ['msg' => '同一订单中有活动商品不可同时购买多款', 'data' => json_encode($dataOrderGoods)]);
throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT);
throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT, '[商品:' . $check . ']');
}
// 订单成功,做一些处理

4
app/Service/v3/Implementations/ShopCartUpdateService.php

@ -50,8 +50,8 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface
->pluck('goods_id')->toArray();
array_push($goodsArr,$goodsId);
$checkGoodsActivity = $this->goodsActivityService->checkOrderActivityCount($goodsArr);
if(!$checkGoodsActivity){
throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT);
if($checkGoodsActivity !== true){
throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT, '[商品:' . $checkGoodsActivity . ']');
}
$goodsCheck = $this->goodsActivityService->check($goods,$num,$userId);
}else{

Loading…
Cancel
Save