Skip to content

Commit

Permalink
拼团活动被异常操作后,商品索引没有更新问题处理
Browse files Browse the repository at this point in the history
  • Loading branch information
chopper711 committed Oct 27, 2021
1 parent ab0b7f1 commit dd1bf2e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
6 changes: 2 additions & 4 deletions framework/src/main/java/cn/lili/common/enums/ResultCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public enum ResultCode {
* 购物车
*/
CART_ERROR(30001, "读取结算页的购物车异常"),
CART_PINTUAN_NOT_EXIST_ERROR(30002, "拼团活动不存在错误"),
CART_PINTUAN_NOT_EXIST_ERROR(30002, "拼团活动已关闭,请稍后重试"),
CART_PINTUAN_LIMIT_ERROR(30003, "购买数量超过拼团活动限制数量"),
SHIPPING_NOT_APPLY(30005, "购物商品不支持当前收货地址配送"),

Expand Down Expand Up @@ -449,9 +449,7 @@ public enum ResultCode {
CUSTOM_WORDS_SECRET_KEY_ERROR(90002, "秘钥验证失败!"),
CONNECT_NOT_EXIST(90000, "登录方式不存在!"),
ELASTICSEARCH_INDEX_INIT_ERROR(90003, "索引初始化失败!"),
PURCHASE_ORDER_DEADLINE_ERROR(90004,"供求单,已超过报名截止时间")

;
PURCHASE_ORDER_DEADLINE_ERROR(90004, "供求单,已超过报名截止时间");

private final Integer code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ static String getStockCacheKey(String id) {
*/
void updateGoodsSkuStatus(Goods goods);

/**
* 发送生成ES商品索引
*
* @param goods 商品信息
*/
void generateEs(Goods goods);

/**
* 更新SKU库存
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public void updateGoodsSkuCommentNum(String skuId) {
*
* @param goods 商品信息
*/
private void generateEs(Goods goods) {
public void generateEs(Goods goods) {
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
//发送mq消息
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goods), RocketmqSendCallbackBuilder.commonCallback());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.member.entity.dos.MemberAddress;
import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO;
Expand All @@ -36,6 +37,7 @@
import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams;
import cn.lili.modules.promotion.service.*;
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.search.service.EsGoodsSearchService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -92,6 +94,11 @@ public class CartServiceImpl implements CartService {
*/
@Autowired
private EsGoodsSearchService esGoodsSearchService;
/**
* ES商品
*/
@Autowired
private GoodsService goodsService;
/**
* 拼团
*/
Expand Down Expand Up @@ -689,6 +696,8 @@ private void checkPintuan(CartSkuVO cartSkuVO) {
cartSkuVO.setUtilPrice(promotionGoods.getPrice());
cartSkuVO.setPurchasePrice(promotionGoods.getPrice());
} else {
//如果拼团活动被异常处理,则在这里安排mq重新写入商品索引
goodsSkuService.generateEs(goodsService.getById(cartSkuVO.getGoodsSku().getGoodsId()));
throw new ServiceException(ResultCode.CART_PINTUAN_NOT_EXIST_ERROR);
}
//检测拼团限购数量
Expand Down

0 comments on commit dd1bf2e

Please sign in to comment.