|
|
@ -5,6 +5,7 @@ |
|
|
|
*/ |
|
|
|
package com.shop.cereshop.business.service.tool.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
@ -18,6 +19,7 @@ import com.shop.cereshop.business.param.tool.*; |
|
|
|
import com.shop.cereshop.business.redis.service.api.StringRedisService; |
|
|
|
import com.shop.cereshop.business.service.log.CerePlatformLogService; |
|
|
|
import com.shop.cereshop.business.service.redis.CereRedisKeyServcice; |
|
|
|
import com.shop.cereshop.business.service.shop.CerePlatformShopService; |
|
|
|
import com.shop.cereshop.business.service.tool.CereShopCouponDetailService; |
|
|
|
import com.shop.cereshop.business.service.tool.CereShopCouponService; |
|
|
|
import com.shop.cereshop.commons.constant.CoReturnFormat; |
|
|
@ -25,6 +27,9 @@ import com.shop.cereshop.commons.constant.IntegerEnum; |
|
|
|
import com.shop.cereshop.commons.constant.StringEnum; |
|
|
|
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser; |
|
|
|
import com.shop.cereshop.commons.domain.common.Page; |
|
|
|
import com.shop.cereshop.commons.domain.common.PageParam; |
|
|
|
import com.shop.cereshop.commons.domain.live.CereLiveProduct; |
|
|
|
import com.shop.cereshop.commons.domain.shop.CerePlatformShop; |
|
|
|
import com.shop.cereshop.commons.domain.tool.CereShopCoupon; |
|
|
|
import com.shop.cereshop.commons.domain.tool.CereShopCouponDetail; |
|
|
|
import com.shop.cereshop.commons.domain.tool.CereShopCouponExclude; |
|
|
@ -65,6 +70,9 @@ public class CereShopCouponServiceImpl implements CereShopCouponService { |
|
|
|
@Autowired |
|
|
|
private CereShopCouponExcludeDAO cereShopCouponExcludeDAO; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CerePlatformShopService platformShopService; |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class}) |
|
|
|
public void save(ShopCouponSaveParam param, CerePlatformBusinessUser user) throws CoBusinessException,Exception { |
|
|
@ -72,13 +80,16 @@ public class CereShopCouponServiceImpl implements CereShopCouponService { |
|
|
|
List<Long> ids=null; |
|
|
|
List<Long> excludeIds = null; |
|
|
|
if(IntegerEnum.APPLY_TYPE_ALL.getCode().equals(param.getApplyType())){ |
|
|
|
//如果是全部商品,查询本店所有有效商品id |
|
|
|
//如果是全部商品,查询商家所有有效商品id |
|
|
|
ids=cereShopCouponDAO.findProductIdsByShopId(param.getShopId()); |
|
|
|
}else if(IntegerEnum.APPLY_TYPE_SHOP.getCode().equals(param.getApplyType())){ |
|
|
|
//如果是指定店铺,获取指定店铺下所有商品 |
|
|
|
ids=cereShopCouponDAO.findProductIdsByShopIds(param.getIds()); |
|
|
|
}else if(IntegerEnum.APPLY_TYPE_YES.getCode().equals(param.getApplyType())){ |
|
|
|
//如果是指定商品可用 |
|
|
|
ids=param.getIds(); |
|
|
|
}else { |
|
|
|
//如果是指定商品不可用,查询本店所有不在这个范围内的有效商品id |
|
|
|
//如果是指定商品不可用,查询本商家所有不在这个范围内的有效商品id |
|
|
|
ids=cereShopCouponDAO.findProductIdsByShopIdAndIds(param.getShopId(),param.getIds()); |
|
|
|
excludeIds = param.getIds(); |
|
|
|
} |
|
|
@ -210,6 +221,9 @@ public class CereShopCouponServiceImpl implements CereShopCouponService { |
|
|
|
if(IntegerEnum.APPLY_TYPE_ALL.getCode().equals(param.getApplyType())){ |
|
|
|
//如果是全部商品,查询本店所有有效商品id |
|
|
|
ids=cereShopCouponDAO.findProductIdsByShopId(param.getShopId()); |
|
|
|
}else if(IntegerEnum.APPLY_TYPE_SHOP.getCode().equals(param.getApplyType())){ |
|
|
|
//如果是指定店铺,获取指定店铺下所有商品 |
|
|
|
ids=cereShopCouponDAO.findProductIdsByShopIds(param.getIds()); |
|
|
|
}else if(IntegerEnum.APPLY_TYPE_YES.getCode().equals(param.getApplyType())){ |
|
|
|
//如果是指定商品可用 |
|
|
|
ids=param.getIds(); |
|
|
@ -331,7 +345,14 @@ public class CereShopCouponServiceImpl implements CereShopCouponService { |
|
|
|
ShopCouponDetail detail=cereShopCouponDAO.getById(shopCouponId); |
|
|
|
if(detail!=null){ |
|
|
|
//查询商品明细数据 |
|
|
|
detail.setProducts(cereShopCouponDetailService.findProducts(shopCouponId)); |
|
|
|
List<ToolProduct> products = cereShopCouponDetailService.findProducts(shopCouponId); |
|
|
|
detail.setProducts(products); |
|
|
|
if (IntegerEnum.APPLY_TYPE_SHOP.getCode().equals(detail.getApplyType())){ |
|
|
|
//指定店铺,获取店铺id |
|
|
|
List<Long> shopIds = products.stream().map(ToolProduct::getShopId).distinct().collect(Collectors.toList()); |
|
|
|
detail.setIds(shopIds); |
|
|
|
} |
|
|
|
|
|
|
|
if (IntegerEnum.APPLY_TYPE_NO.getCode().equals(detail.getApplyType())) { |
|
|
|
detail.setExcludeIds(cereShopCouponExcludeDAO.selectList(Wrappers.<CereShopCouponExclude>lambdaQuery() |
|
|
|
.eq(CereShopCouponExclude::getShopCouponId, shopCouponId)).stream().map(CereShopCouponExclude::getProductId) |
|
|
@ -396,7 +417,7 @@ public class CereShopCouponServiceImpl implements CereShopCouponService { |
|
|
|
@Override |
|
|
|
public Page getProducts(ToolProductNewParam param) throws CoBusinessException { |
|
|
|
PageHelper.startPage(param.getPage(),param.getPageSize()); |
|
|
|
List<ToolProduct> list=cereShopCouponDAO.getProductsNew(param.getShopIds(), param.getActivityId(), param.getQueryType()); |
|
|
|
List<ToolProduct> list=cereShopCouponDAO.getProductsNew(param.getBusinessId(), param.getActivityId(), param.getQueryType()); |
|
|
|
PageInfo<ToolProduct> pageInfo=new PageInfo<>(list); |
|
|
|
Page page=new Page(pageInfo.getList(),pageInfo.getTotal()); |
|
|
|
return page; |
|
|
@ -528,4 +549,22 @@ public class CereShopCouponServiceImpl implements CereShopCouponService { |
|
|
|
Page page=new Page(pageInfo.getList(),pageInfo.getTotal()); |
|
|
|
return page; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Page getShops(ToolProductNewParam param) throws CoBusinessException { |
|
|
|
PageHelper.startPage(param.getPage(),param.getPageSize()); |
|
|
|
List<CerePlatformShop> list; |
|
|
|
if (ObjectUtils.isNotEmpty(param.getActivityId())){ |
|
|
|
//查看店铺,获取全部已设置优惠券的商品,过滤商品的店铺id,去获取店铺信息 |
|
|
|
List<ToolProduct> prodList = cereShopCouponDAO.getProductsNew(param.getBusinessId(), param.getActivityId(), param.getQueryType()); |
|
|
|
//去重获取店铺id |
|
|
|
List<Long> shopIds = prodList.stream().map(ToolProduct::getShopId).distinct().collect(Collectors.toList()); |
|
|
|
list = platformShopService.getByIdList(shopIds); |
|
|
|
}else { |
|
|
|
list = cereShopCouponDAO.getShops(param.getBusinessId()); |
|
|
|
} |
|
|
|
PageInfo<CerePlatformShop> pageInfo=new PageInfo<>(list); |
|
|
|
Page page=new Page(pageInfo.getList(),pageInfo.getTotal()); |
|
|
|
return page; |
|
|
|
} |
|
|
|
} |