diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java index 612fa1c4..2212239a 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java @@ -63,7 +63,7 @@ public class ShopBaseProductCategoryController { public CommonResult getList(ShopBaseProductCategory category) { QueryWrapper queryWrapper = new QueryWrapper<>(); new FilterUtils().applyStoreFilter(queryWrapper); - queryWrapper.eq("category_is_enable", 1); + //queryWrapper.eq("category_is_enable", 1); Integer category_parent_id = category.getCategory_parent_id(); if (category_parent_id == null) category_parent_id = 0; return CommonResult.success(shopBaseProductCategoryService.getCategoryTree(queryWrapper, category_parent_id)); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java index f16ca52f..886b31ce 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/user/service/impl/ShopUserCartServiceImpl.java @@ -16,6 +16,7 @@ import com.suisung.mall.common.api.ResultCode; import com.suisung.mall.common.api.StateCode; import com.suisung.mall.common.constant.CommonConstant; import com.suisung.mall.common.domain.UserDto; +import com.suisung.mall.common.enums.DicEnum; import com.suisung.mall.common.exception.ApiException; import com.suisung.mall.common.exception.ApiUserException; import com.suisung.mall.common.feignService.AccountService; @@ -38,6 +39,7 @@ import com.suisung.mall.common.service.MessageService; import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.common.utils.StringUtils; +import com.suisung.mall.core.web.service.RedisService; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.shop.base.service.AccountBaseConfigService; import com.suisung.mall.shop.base.service.ShopBaseStateCodeService; @@ -50,6 +52,7 @@ import com.suisung.mall.shop.product.pojo.vo.FixOrderVo; import com.suisung.mall.shop.product.pojo.vo.ProductVo; import com.suisung.mall.shop.product.service.*; import com.suisung.mall.shop.store.service.*; +import com.suisung.mall.shop.sync.keymanage.RedisKey; import com.suisung.mall.shop.user.mapper.ShopUserCartMapper; import com.suisung.mall.shop.user.service.ShopUserCartService; import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService; @@ -157,6 +160,12 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl= 0 ? Math.max(1, cart_quantity) : Math.min(-1, cart_quantity)); // 购买商品数量 data.put("cart_type", cart_type); @@ -3160,4 +3173,55 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl shopStoreActivityBaseQueryWrapper=new QueryWrapper<>(); + shopStoreActivityBaseQueryWrapper.eq("activity_id", activityId); + List shopStoreActivityBases= shopStoreActivityBaseService.list(shopStoreActivityBaseQueryWrapper); + if(shopStoreActivityBases.isEmpty()){ + throw new ApiException("活动不存在"); + } + ShopStoreActivityBase shopStoreActivityBase=shopStoreActivityBases.get(0); + Integer person_limit= shopStoreActivityBase.getPerson_limit(); + Integer order_limit=shopStoreActivityBase.getOrder_limit(); + String is_new_person_shop=shopStoreActivityBase.getIs_new_person_shop(); + if(DicEnum.YESORNO_1.getCode().equals(is_new_person_shop)){ + Integer store_id=shopStoreActivityBase.getStore_id(); + boolean isNewUser=checkoutNewPerson(user_id,store_id); + if(!isNewUser){ + throw new ApiException("店铺新人才能购买"); + } + + } + return true; + } + + /** + * 检查是否为新用户 + * @param user_id + */ + private boolean checkoutNewPerson(Integer user_id,Integer store_id){ + boolean isNewUser=false; + String key= RedisKey.store_member_storeId_userId+":"+store_id+":"+user_id; + if(!redisService.hasKey(key)) { + QueryWrapper shopStoreMemberQueryWrapper=new QueryWrapper(); + shopStoreMemberQueryWrapper.eq("userId",user_id); + shopStoreMemberQueryWrapper.eq("store_id",store_id); + long count=shopStoreMemberService.count(shopStoreMemberQueryWrapper); + if(count==0){ + Map userData=new HashMap(); + userData.put(key,user_id); + redisService.lPush(key,userData); + isNewUser=true; + } + }else { + isNewUser=true; + } + return isNewUser; + } + }