Skip to content

Commit

Permalink
优化促销。移除结算时促销的依赖。规范部分isxxx字段命名
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Dec 21, 2021
1 parent e4047fb commit 3ba4d24
Show file tree
Hide file tree
Showing 56 changed files with 534 additions and 534 deletions.
15 changes: 15 additions & 0 deletions DB/li_promotions.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

-- 促销重构sql
ALTER TABLE li_coupon DROP COLUMN promotion_status;

ALTER TABLE li_coupon_activity DROP COLUMN promotion_status;
Expand Down Expand Up @@ -36,3 +37,17 @@ ALTER TABLE li_promotion_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4
ALTER TABLE li_seckill DROP COLUMN promotion_status;
ALTER TABLE li_seckill ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID';
ALTER TABLE li_seckill ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型';

ALTER TABLE li_full_discount RENAME COLUMN is_coupon TO coupon_flag;
ALTER TABLE li_full_discount RENAME COLUMN is_free_freight TO free_freight_flag;
ALTER TABLE li_full_discount RENAME COLUMN is_full_minus TO full_minus_flag;
ALTER TABLE li_full_discount RENAME COLUMN is_full_rate TO full_rate_flag;
ALTER TABLE li_full_discount RENAME COLUMN is_gift TO gift_flag;
ALTER TABLE li_full_discount RENAME COLUMN is_point TO point_flag;

ALTER TABLE li_member_coupon RENAME COLUMN is_platform TO platform_flag;

ALTER TABLE li_goods RENAME COLUMN is_auth TO auth_flag;

ALTER TABLE li_goods_sku RENAME COLUMN is_promotion TO promotion_flag;
ALTER TABLE li_goods_sku RENAME COLUMN is_auth TO auth_flag;
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public ResultMessage<Object> crateTrade(@RequestBody TradeParams tradeParams) {
throw se;
} catch (Exception e) {
log.error(ResultCode.ORDER_ERROR.message(), e);
throw new ServiceException(ResultCode.ORDER_ERROR);
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class KanjiaGoodsActivityBuyerController {
public ResultMessage<IPage<KanjiaActivityGoodsListVO>> kanjiaActivityGoodsPage(KanjiaActivityGoodsParams kanjiaActivityGoodsParams, PageVO page) {
// 会员端查询到的肯定是已经开始的活动商品
kanjiaActivityGoodsParams.setPromotionStatus(PromotionsStatusEnum.START.name());
kanjiaActivityGoodsParams.setStartTime(System.currentTimeMillis());
kanjiaActivityGoodsParams.setEndTime(System.currentTimeMillis());
// kanjiaActivityGoodsParams.setStartTime(System.currentTimeMillis());
// kanjiaActivityGoodsParams.setEndTime(System.currentTimeMillis());
return ResultUtil.data(kanJiaActivityGoodsService.kanjiaGoodsVOPage(kanjiaActivityGoodsParams, page));
}

Expand Down
20 changes: 15 additions & 5 deletions consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,20 @@ public void onMessage(MessageExt messageExt) {
this.updateGoodsIndexPromotions(new String(messageExt.getBody()));
break;
case DELETE_GOODS_INDEX_PROMOTIONS:
this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(null, new String(messageExt.getBody()));
BasePromotions promotions = JSONUtil.toBean(new String(messageExt.getBody()), BasePromotions.class);
log.info("删除索引信息: {}", promotions);
if (CharSequenceUtil.isNotEmpty(promotions.getScopeId())) {
this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(Arrays.asList(promotions.getScopeId().split(",")), promotions.getId());
} else {
this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(null, promotions.getId());
}
break;
case UPDATE_GOODS_INDEX:
try {
String goodsIdsJsonStr = new String(messageExt.getBody());
List<Goods> goodsList = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getId, JSONUtil.toList(goodsIdsJsonStr, String.class)));
GoodsSearchParams searchParams = new GoodsSearchParams();
searchParams.setId(ArrayUtil.join(JSONUtil.toList(goodsIdsJsonStr, String.class).toArray(), ","));
List<Goods> goodsList = goodsService.queryListByParams(searchParams);
this.updateGoodsIndex(goodsList);
} catch (Exception e) {
log.error("更新商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody()));
Expand Down Expand Up @@ -224,6 +232,8 @@ private void updateGoodsIndexPromotions(String promotionsJsonStr) {
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
searchParams.setPromotionId(promotions.getId());
List<PromotionGoods> promotionGoodsList = this.promotionGoodsService.listFindAll(searchParams);
List<String> skuIds = promotionGoodsList.stream().map(PromotionGoods::getSkuId).collect(Collectors.toList());
this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(skuIds, promotions.getId());
this.goodsIndexService.updateEsGoodsIndexByList(promotionGoodsList, promotions, esPromotionKey);
} else if (PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name().equals(promotions.getScopeType())) {
GoodsSearchParams searchParams = new GoodsSearchParams();
Expand All @@ -249,7 +259,7 @@ private void updateGoodsIndex(List<Goods> goodsList) {
for (Goods goods : goodsList) {
//如果商品通过审核&&并且已上架
List<GoodsSku> goodsSkuList = this.goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getId()).gt(GoodsSku::getQuantity, 0));
if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name())
if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name())
&& goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())
&& Boolean.FALSE.equals(goods.getDeleteFlag())) {
goodsSkuList.forEach(goodsSku -> {
Expand Down Expand Up @@ -278,7 +288,7 @@ private void updateGoodsIndex(List<Goods> goodsList) {
private void updateGoodsIndex(Goods goods) {
//如果商品通过审核&&并且已上架
List<GoodsSku> goodsSkuList = this.goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getId()));
if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name())
if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name())
&& goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())
&& Boolean.FALSE.equals(goods.getDeleteFlag())) {
this.generatorGoodsIndex(goods, goodsSkuList);
Expand Down Expand Up @@ -322,7 +332,7 @@ private EsGoodsIndex settingUpGoodsIndexData(Goods goods, GoodsSku goodsSku) {
List<GoodsParamsDTO> goodsParamDTOS = JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class);
goodsIndex = new EsGoodsIndex(goodsSku, goodsParamDTOS);
}
goodsIndex.setIsAuth(goods.getIsAuth());
goodsIndex.setAuthFlag(goods.getAuthFlag());
goodsIndex.setMarketEnable(goods.getMarketEnable());
this.settingUpGoodsIndexOtherParam(goodsIndex);
return goodsIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.hutool.json.JSONUtil;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.promotion.entity.dos.Pintuan;
import cn.lili.trigger.TimeTriggerExecutor;
import cn.lili.trigger.message.PintuanOrderMessage;
import cn.lili.trigger.model.TimeExecuteConstant;
Expand Down Expand Up @@ -35,6 +36,10 @@ public void execute(Object object) {
//拼团订单自动处理
orderService.agglomeratePintuanOrder(pintuanOrderMessage.getPintuanId(), pintuanOrderMessage.getOrderSn());
}
Pintuan pintuan = JSONUtil.toBean(JSONUtil.parseObj(object), Pintuan.class);
if (pintuan != null && pintuan.getId() != null) {
this.orderService.checkFictitiousOrder(pintuan.getId(), pintuan.getRequiredNum(), pintuan.getFictitious());
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ public enum ResultCode {
KANJIA_GOODS_ACTIVE_HIGHEST_LOWEST_PRICE_ERROR(48005, "最低砍价金额不能高于最高砍价金额"),
KANJIA_GOODS_ACTIVE_SETTLEMENT_PRICE_ERROR(48006, "结算金额不能高于商品金额"),
KANJIA_GOODS_DELETE_ERROR(48007, "删除砍价商品异常"),
KANJIA_GOODS_UPDATE_ERROR(48012, "更新砍价商品异常"),
KANJIA_ACTIVITY_NOT_FOUND_ERROR(48008, "砍价记录不存在"),
KANJIA_ACTIVITY_LOG_MEMBER_ERROR(48009, "当前会员已经帮砍"),
KANJIA_ACTIVITY_MEMBER_ERROR(48010, "当前会员已经发起此砍价商品活动"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void createMapping(String index) throws Exception {
" }\n" +
" }\n" +
" },\n" +
" \"isAuth\": {\n" +
" \"authFlag\": {\n" +
" \"type\": \"text\",\n" +
" \"fields\": {\n" +
" \"keyword\": {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public RestHighLevelClient elasticsearchClient() {
.setDefaultCredentialsProvider(credential)
.setKeepAliveStrategy(getConnectionKeepAliveStrategy())
.setMaxConnPerRoute(10)
.setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(1).build()));
.setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(Runtime.getRuntime().availableProcessors()).build()));
}

restBuilder.setRequestConfigCallback(requestConfigBuilder ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class Goods extends BaseEntity {
private String templateId;

@ApiModelProperty(value = "审核状态")
private String isAuth;
private String authFlag;

@ApiModelProperty(value = "审核信息")
private String authMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class GoodsSku extends BaseEntity {
private String freightTemplateId;

@ApiModelProperty(value = "是否是促销商品")
private Boolean isPromotion;
private Boolean promotionFlag;

@ApiModelProperty(value = "促销价")
private Double promotionPrice;
Expand Down Expand Up @@ -130,7 +130,7 @@ public class GoodsSku extends BaseEntity {
* @see GoodsAuthEnum
*/
@ApiModelProperty(value = "审核状态")
private String isAuth;
private String authFlag;

@ApiModelProperty(value = "审核信息")
private String authMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Arrays;

/**
* 商品查询条件
*
Expand Down Expand Up @@ -58,7 +60,7 @@ public class GoodsSearchParams extends PageVO {
* @see GoodsAuthEnum
*/
@ApiModelProperty(value = "审核状态")
private String isAuth;
private String authFlag;

@ApiModelProperty(value = "库存数量")
private Integer quantity;
Expand All @@ -81,7 +83,7 @@ public <T> QueryWrapper<T> queryWrapper() {
queryWrapper.like("goods_name", goodsName);
}
if (CharSequenceUtil.isNotEmpty(id)) {
queryWrapper.eq("id", id);
queryWrapper.in("id", Arrays.asList(id.split(",")));
}
if (CharSequenceUtil.isNotEmpty(storeId)) {
queryWrapper.eq("store_id", storeId);
Expand All @@ -101,8 +103,8 @@ public <T> QueryWrapper<T> queryWrapper() {
if (CharSequenceUtil.isNotEmpty(marketEnable)) {
queryWrapper.eq("market_enable", marketEnable);
}
if (CharSequenceUtil.isNotEmpty(isAuth)) {
queryWrapper.eq("is_auth", isAuth);
if (CharSequenceUtil.isNotEmpty(authFlag)) {
queryWrapper.eq("auth_flag", authFlag);
}
if (quantity != null) {
queryWrapper.le("quantity", quantity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ public interface GoodsService extends IService<Goods> {
*/
IPage<Goods> queryByParams(GoodsSearchParams goodsSearchParams);


/**
* 商品查询
*
* @param goodsSearchParams 查询参数
* @return 商品信息
*/
List<Goods> queryListByParams(GoodsSearchParams goodsSearchParams);

/**
* 批量审核商品
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static String getStockCacheKey(String id) {
/**
* 更新商品sku状态
*
* @param goods 商品信息(Id,MarketEnable/IsAuth)
* @param goods 商品信息(Id,MarketEnable/AuthFlag)
*/
void updateGoodsSkuStatus(Goods goods);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public boolean addCommodity(List<Commodity> commodityList) {
private void checkCommodity(Commodity commodity) {
//商品是否审核通过
GoodsSku goodsSku = goodsSkuService.getById(commodity.getSkuId());
if (!goodsSku.getIsAuth().equals(GoodsAuthEnum.PASS.name())) {
if (!goodsSku.getAuthFlag().equals(GoodsAuthEnum.PASS.name())) {
throw new ServiceException(goodsSku.getGoodsName() + " 未审核通过,不能添加直播商品");
}
//是否已添加规格商品
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.mapper.GoodsMapper;
import cn.lili.modules.goods.service.*;
import cn.lili.modules.goods.service.CategoryService;
import cn.lili.modules.goods.service.GoodsGalleryService;
import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.member.entity.dos.MemberEvaluation;
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
import cn.lili.modules.member.service.MemberEvaluationService;
Expand Down Expand Up @@ -107,11 +110,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
*/
@Autowired
private RocketmqCustomProperties rocketmqCustomProperties;
/**
* 分类-参数
*/
@Autowired
private CategoryParameterGroupService categoryParameterGroupService;

@Autowired
private FreightTemplateService freightTemplateService;
Expand Down Expand Up @@ -255,12 +253,23 @@ public IPage<Goods> queryByParams(GoodsSearchParams goodsSearchParams) {
return this.page(PageUtil.initPage(goodsSearchParams), goodsSearchParams.queryWrapper());
}

/**
* 商品查询
*
* @param goodsSearchParams 查询参数
* @return 商品信息
*/
@Override
public List<Goods> queryListByParams(GoodsSearchParams goodsSearchParams) {
return this.list(goodsSearchParams.queryWrapper());
}

@Override
public boolean auditGoods(List<String> goodsIds, GoodsAuthEnum goodsAuthEnum) {
boolean result = false;
for (String goodsId : goodsIds) {
Goods goods = this.checkExist(goodsId);
goods.setIsAuth(goodsAuthEnum.name());
goods.setAuthFlag(goodsAuthEnum.name());
result = this.updateById(goods);
goodsSkuService.updateGoodsSkuStatus(goods);
//删除之前的缓存
Expand Down Expand Up @@ -384,7 +393,7 @@ public long countStoreGoodsNum(String storeId) {
return this.count(
new LambdaQueryWrapper<Goods>()
.eq(Goods::getStoreId, storeId)
.eq(Goods::getIsAuth, GoodsAuthEnum.PASS.name())
.eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name())
.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()));
}

Expand Down Expand Up @@ -445,7 +454,7 @@ private void checkGoods(Goods goods) {
Setting setting = settingService.get(SettingEnum.GOODS_SETTING.name());
GoodsSetting goodsSetting = JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class);
//是否需要审核
goods.setIsAuth(Boolean.TRUE.equals(goodsSetting.getGoodsCheck()) ? GoodsAuthEnum.TOBEAUDITED.name() : GoodsAuthEnum.PASS.name());
goods.setAuthFlag(Boolean.TRUE.equals(goodsSetting.getGoodsCheck()) ? GoodsAuthEnum.TOBEAUDITED.name() : GoodsAuthEnum.PASS.name());
//判断当前用户是否为店铺
if (Objects.requireNonNull(UserContext.getCurrentUser()).getRole().equals(UserEnums.STORE)) {
StoreVO storeDetail = this.storeService.getStoreDetail();
Expand Down Expand Up @@ -485,9 +494,8 @@ private AuthUser checkStoreAuthority() {
//如果当前会员不为空,且为店铺角色
if (currentUser != null && (currentUser.getRole().equals(UserEnums.STORE) && currentUser.getStoreId() != null)) {
return currentUser;
} else {
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
}
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regen
skuInfo(sku, goods, map, null);
newSkuList.add(sku);
//如果商品状态值不对,则es索引移除
if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())) {
if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())) {
goodsIndexService.deleteIndexById(sku.getId());
this.clearCache(sku.getId());
}
Expand Down Expand Up @@ -234,7 +234,7 @@ public Map<String, Object> getGoodsSkuDetail(String goodsId, String skuId) {

//商品为空||商品下架||商品未审核通过||商品删除,则提示:商品已下架
if (goodsVO == null || goodsVO.getMarketEnable().equals(GoodsStatusEnum.DOWN.name())
|| !goodsVO.getIsAuth().equals(GoodsAuthEnum.PASS.name())
|| !goodsVO.getAuthFlag().equals(GoodsAuthEnum.PASS.name())
|| Boolean.TRUE.equals(goodsVO.getDeleteFlag())) {
throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
}
Expand Down Expand Up @@ -269,8 +269,11 @@ public Map<String, Object> getGoodsSkuDetail(String goodsId, String skuId) {
boolean containsPromotion = promotionMap.keySet().stream().anyMatch(i ->
i.contains(PromotionTypeEnum.SECKILL.name()) || i.contains(PromotionTypeEnum.PINTUAN.name()));
if (containsPromotion && goodsIndex.getPromotionPrice() != null) {
goodsSkuDetail.setPromotionFlag(true);
goodsSkuDetail.setPromotionPrice(goodsIndex.getPromotionPrice());

} else {
goodsSkuDetail.setPromotionFlag(false);
goodsSkuDetail.setPromotionPrice(null);
}

}
Expand Down Expand Up @@ -301,14 +304,14 @@ public Map<String, Object> getGoodsSkuDetail(String goodsId, String skuId) {
/**
* 更新商品sku状态
*
* @param goods 商品信息(Id,MarketEnable/IsAuth)
* @param goods 商品信息(Id,MarketEnable/AuthFlag)
*/
@Override
public void updateGoodsSkuStatus(Goods goods) {
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(GoodsSku::getGoodsId, goods.getId());
updateWrapper.set(GoodsSku::getMarketEnable, goods.getMarketEnable());
updateWrapper.set(GoodsSku::getIsAuth, goods.getIsAuth());
updateWrapper.set(GoodsSku::getAuthFlag, goods.getAuthFlag());
updateWrapper.set(GoodsSku::getDeleteFlag, goods.getDeleteFlag());
boolean update = this.update(updateWrapper);
if (Boolean.TRUE.equals(update)) {
Expand Down Expand Up @@ -525,7 +528,7 @@ public void updateGoodsSkuPromotion(String skuId, Double promotionPrice) {
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(GoodsSku::getId, skuId);
updateWrapper.set(GoodsSku::getPromotionPrice, promotionPrice);
updateWrapper.set(GoodsSku::getIsPromotion, true);
updateWrapper.set(GoodsSku::getPromotionFlag, true);
this.update(updateWrapper);
cache.remove(GoodsSkuService.getCacheKeys(skuId));
}
Expand Down Expand Up @@ -625,7 +628,7 @@ private void goodsInfo(GoodsSku sku, Goods goods) {
sku.setGoodsUnit(goods.getGoodsUnit());
sku.setGrade(100D);
//商品状态
sku.setIsAuth(goods.getIsAuth());
sku.setAuthFlag(goods.getAuthFlag());
sku.setSalesModel(goods.getSalesModel());
//卖家信息
sku.setStoreId(goods.getStoreId());
Expand Down
Loading

0 comments on commit 3ba4d24

Please sign in to comment.