diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 070b3b08d..4b9f30532 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -188,6 +188,7 @@ public void onMessage(MessageExt messageExt) { case GOODS_AUDIT: Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class); updateGoodsNum(goods); + updateGoodsIndex(goods); break; //删除商品 case GOODS_DELETE: @@ -390,7 +391,7 @@ private void settingUpGoodsIndexOtherParam(EsGoodsIndex goodsIndex) { if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) { Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(goodsIndex); - goodsIndex.setPromotionMap(goodsCurrentPromotionMap); + goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); } } diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java index f197ab070..958402dbd 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java @@ -3,13 +3,12 @@ import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.lili.modules.store.entity.dto.StoreSettlementDay; -import cn.lili.modules.store.mapper.StoreDetailMapper; import cn.lili.modules.store.service.BillService; +import cn.lili.modules.store.service.StoreDetailService; import cn.lili.timetask.handler.EveryDayExecute; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.Resource; import java.util.List; /** @@ -29,8 +28,8 @@ public class BillExecute implements EveryDayExecute { /** * 店铺详情 */ - @Resource - private StoreDetailMapper storeDetailMapper; + @Autowired + private StoreDetailService storeDetailService; /** * 1.查询今日待结算的商家 @@ -44,18 +43,18 @@ public void execute() { int day = DateUtil.date().dayOfMonth(); //获取待结算商家列表 - List storeList = storeDetailMapper.getSettlementStore(day); + List storeList = storeDetailService.getSettlementStore(day); //获取当前时间 - DateTime endTime =DateUtil.date(); + DateTime endTime = DateUtil.date(); //批量商家结算 for (StoreSettlementDay storeSettlementDay : storeList) { //生成结算单 - billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(),endTime); + billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime); //修改店铺结算时间 - storeDetailMapper.updateSettlementDay(storeSettlementDay.getStoreId(), endTime); + storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime); } } } diff --git a/consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java b/consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java new file mode 100644 index 000000000..969fa7fc0 --- /dev/null +++ b/consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java @@ -0,0 +1,61 @@ +package cn.lili.buyer.test.bill; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.lili.modules.store.entity.dto.StoreSettlementDay; +import cn.lili.modules.store.service.BillService; +import cn.lili.modules.store.service.StoreDetailService; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import java.util.List; + +/** + * @author paulG + * @since 2022/1/10 + **/ +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class BillTest { + + + /** + * 结算单 + */ + @Autowired + private BillService billService; + + /** + * 店铺详情 + */ + @Autowired + private StoreDetailService storeDetailService; + + @Test + void createBillTest() { + //获取当前天数 + int day = DateUtil.date().dayOfMonth(); + + //获取待结算商家列表 + List storeList = storeDetailService.getSettlementStore(day); + + //获取当前时间 + DateTime endTime = DateUtil.date(); + //批量商家结算 + for (StoreSettlementDay storeSettlementDay : storeList) { + + //生成结算单 + billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime); + + //修改店铺结算时间 + storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime); + } + Assertions.assertTrue(true); + } + + +} diff --git a/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java b/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java index 62d505b2b..f7bf18e51 100644 --- a/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java +++ b/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java @@ -78,6 +78,7 @@ public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { 可参考 https://blog.csdn.net/u012240455/article/details/80538540 */ ParserConfig.getGlobalInstance().addAccept("cn.lili."); + ParserConfig.getGlobalInstance().addAccept("cn.hutool.json."); return cacheManager; } diff --git a/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java b/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java index 68006dac0..44dfa6871 100644 --- a/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java +++ b/framework/src/main/java/cn/lili/common/enums/PromotionTypeEnum.java @@ -23,7 +23,7 @@ public enum PromotionTypeEnum { /** * 有促销库存的活动类型 */ - static PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS}; + static final PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS}; private final String description; diff --git a/framework/src/main/java/cn/lili/common/security/filter/XssHttpServletRequestWrapper.java b/framework/src/main/java/cn/lili/common/security/filter/XssHttpServletRequestWrapper.java index 2aca42cb3..ad694aea4 100644 --- a/framework/src/main/java/cn/lili/common/security/filter/XssHttpServletRequestWrapper.java +++ b/framework/src/main/java/cn/lili/common/security/filter/XssHttpServletRequestWrapper.java @@ -5,6 +5,8 @@ import cn.hutool.http.HtmlUtil; import cn.hutool.json.JSONUtil; import lombok.extern.slf4j.Slf4j; +import org.owasp.html.HtmlPolicyBuilder; +import org.owasp.html.PolicyFactory; import org.owasp.html.Sanitizers; import javax.servlet.ReadListener; @@ -57,6 +59,24 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { "wechatpay", }; + //允许的标签 + private static final String[] allowedTags = {"h1", "h2", "h3", "h4", "h5", "h6", + "span", "strong", + "img", "video", "source", "iframe", "code", + "blockquote", "p", "div", + "ul", "ol", "li", + "table", "thead", "caption", "tbody", "tr", "th", "td", "br", + "a" + }; + + //需要转化的标签 + private static final String[] needTransformTags = {"article", "aside", "command", "datalist", "details", "figcaption", "figure", + "footer", "header", "hgroup", "section", "summary"}; + + //带有超链接的标签 + private static final String[] linkTags = {"img", "video", "source", "a", "iframe"}; + + public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); } @@ -257,6 +277,17 @@ public int read() { private String cleanXSS(String value) { if (value != null) { + // 自定义策略 + PolicyFactory policy = new HtmlPolicyBuilder() + .allowStandardUrlProtocols() + //所有允许的标签 + .allowElements(allowedTags) + //内容标签转化为div + .allowElements((elementName, attributes) -> "div", needTransformTags) + .allowAttributes("src", "href", "target", "width", "height").onElements(linkTags) + //校验链接中的是否为http +// .allowUrlProtocols("https") + .toFactory(); // basic prepackaged policies for links, tables, integers, images, styles, blocks value = Sanitizers.FORMATTING .and(Sanitizers.STYLES) @@ -264,6 +295,7 @@ private String cleanXSS(String value) { .and(Sanitizers.LINKS) .and(Sanitizers.BLOCKS) .and(Sanitizers.TABLES) + .and(policy) .sanitize(value); } return HtmlUtil.unescape(value); diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index 59fe971d5..5cc50ec41 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -331,6 +331,9 @@ public void createMapping(String index) throws Exception { " }\n" + " }\n" + " },\n" + + " \"promotionMapJson\": {\n" + + " \"type\": \"text\"\n" + + " },\n" + " \"thumbnail\": {\n" + " \"type\": \"text\",\n" + " \"fields\": {\n" + diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 683bf93b1..b52dba6ec 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -54,10 +54,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; +import java.util.*; /** * 商品业务层实现 @@ -197,6 +194,9 @@ public void editGoods(GoodsOperationDTO goodsOperationDTO, String goodsId) { if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) { this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId()); } + if (GoodsAuthEnum.TOBEAUDITED.name().equals(goods.getAuthFlag())) { + this.deleteEsGoods(Collections.singletonList(goodsId)); + } cache.remove(CachePrefix.GOODS.getPrefix() + goodsId); } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 8f458c699..0badc9202 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; @@ -51,6 +50,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; import java.util.*; import java.util.stream.Collectors; @@ -171,7 +172,7 @@ public void update(List> skuList, Goods goods, Boolean regen this.updateBatchById(newSkuList); } this.updateStock(newSkuList); - if (!newSkuList.isEmpty()) { + if (GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag()) && !newSkuList.isEmpty()) { generateEs(goods); } } @@ -564,6 +565,7 @@ public List getSkuIdsByGoodsId(String goodsId) { * @param goods 商品信息 */ @Override + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void generateEs(Goods goods) { // 不生成没有审核通过且没有上架的商品 if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { @@ -572,16 +574,6 @@ public void generateEs(Goods goods) { String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); //发送mq消息 rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback()); -// ThreadUtil.execAsync(() -> { -// try { -// // 延时执行,防止商品未保存完成就去生成商品索引导致生成索引时找不到商品问题 -// Thread.sleep(2000); -// -// } catch (InterruptedException e) { -// log.error("发送商品索引信息失败!", e); -// Thread.currentThread().interrupt(); -// } -// }); } /** @@ -716,7 +708,7 @@ private void skuInfo(GoodsSku sku, Goods goods, Map map, EsGoods } //设置规格商品缩略图 //如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前 - if (spec.getValue() != null && StrUtil.isNotEmpty(spec.getValue().toString())) { + if (CharSequenceUtil.isNotEmpty(spec.getValue().toString())) { thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail(); small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall(); } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java index 0157b7bc7..f06633e77 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java @@ -2,7 +2,6 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.PromotionTypeEnum; -import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.StringUtils; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; @@ -13,11 +12,8 @@ import cn.lili.modules.order.cart.render.util.PromotionPriceUtil; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.promotion.entity.dos.MemberCoupon; -import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; import cn.lili.modules.promotion.entity.enums.CouponTypeEnum; -import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; -import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.vos.MemberCouponVO; import cn.lili.modules.promotion.service.MemberCouponService; import org.springframework.beans.factory.annotation.Autowired; @@ -64,11 +60,7 @@ public void render(TradeDTO tradeDTO) { * @param tradeDTO 交易dto */ private void renderCouponRule(TradeDTO tradeDTO) { - MemberCouponSearchParams searchParams = new MemberCouponSearchParams(); - searchParams.setMemberId(UserContext.getCurrentUser().getId()); - searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name()); - searchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); - List memberCouponList = memberCouponService.getMemberCoupons(searchParams); + List memberCouponList = memberCouponService.getMemberCoupons(tradeDTO.getMemberId()); if (!memberCouponList.isEmpty()) { this.checkMemberExistCoupon(tradeDTO, memberCouponList); diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index ef47d67d0..da858217b 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -1 +1 @@ -package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional(rollbackFor = Exception.class) public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 如果包含不支持配送的商品 抛出异常 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file +package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional(rollbackFor = Exception.class) public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId() ,ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java index 6f4178cfd..dadf18d6a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java @@ -3,7 +3,6 @@ import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.MemberCoupon; import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; -import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -55,12 +54,19 @@ public interface MemberCouponService extends IService { /** * 获取会员优惠券列表 * - * @param pageVo 分页参数 * @param param 查询参数 * @return 会员优惠券列表 */ List getMemberCoupons(MemberCouponSearchParams param); + /** + * 获取当前用户的优惠券列表(优先读取缓存) + * + * @param memberId 会员id + * @return 会员优惠券列表 + */ + List getMemberCoupons(String memberId); + /** * 获取会员优惠券列表 * @@ -97,27 +103,19 @@ public interface MemberCouponService extends IService { */ long getMemberCouponsNum(); - /** - * 更新会员优惠券状态 - * - * @param status 要变更的状态 - * @param id 会员优惠券id - */ - void updateMemberCouponStatus(MemberCouponStatusEnum status, String id); - /** * 使用优惠券 * * @param ids 会员优惠券id */ - void used(List ids); + void used(String memberId, List ids); /** * 作废当前会员优惠券 * * @param id id */ - void cancellation(String id); + void cancellation(String memberId, String id); /** * 关闭会员优惠券 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index acea35dcf..0c851736c 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.promotion.serviceimpl; +import cn.lili.cache.Cache; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.AuthUser; @@ -24,6 +25,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,6 +41,7 @@ */ @Service @Transactional(rollbackFor = Exception.class) +@CacheConfig(cacheNames = "{MemberCoupon}") public class MemberCouponServiceImpl extends ServiceImpl implements MemberCouponService { /** @@ -45,6 +50,12 @@ public class MemberCouponServiceImpl extends ServiceImpl getMemberCoupons(MemberCouponSearchParams param) { return this.list(param.queryWrapper()); } + /** + * 获取当前用户的优惠券列表(优先读取缓存) + * + * @param memberId 会员id + * @return 会员优惠券列表 + */ + @Override + @Cacheable(key = "#memberId") + public List getMemberCoupons(String memberId) { + MemberCouponSearchParams searchParams = new MemberCouponSearchParams(); + searchParams.setMemberId(Objects.requireNonNull(UserContext.getCurrentUser()).getId()); + searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name()); + searchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); + return this.getMemberCoupons(searchParams); + } + /** * 获取会员优惠券列表 * @@ -177,31 +206,10 @@ public long getMemberCouponsNum() { return this.count(queryWrapper); } - /** - * 更新会员优惠券状态 - * - * @param status 要变更的状态 - * @param id 会员优惠券id - */ - @Override - public void updateMemberCouponStatus(MemberCouponStatusEnum status, String id) { - MemberCoupon memberCoupon = this.getById(id); - if (memberCoupon == null) { - throw new ServiceException(ResultCode.COUPON_MEMBER_NOT_EXIST); - } - String memberCouponStatus = memberCoupon.getMemberCouponStatus(); - if (memberCouponStatus.equals(MemberCouponStatusEnum.NEW.name()) || memberCouponStatus.equals(MemberCouponStatusEnum.USED.name())) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(MemberCoupon::getId, id).set(MemberCoupon::getMemberCouponStatus, status.name()); - this.update(updateWrapper); - } else { - throw new ServiceException(ResultCode.COUPON_MEMBER_STATUS_ERROR); - } - } - @Override - public void used(List ids) { + @CacheEvict(key = "#memberId") + public void used(String memberId, List ids) { if (ids != null && !ids.isEmpty()) { List memberCoupons = this.listByIds(ids); @@ -228,7 +236,8 @@ public void used(List ids) { * @param id id */ @Override - public void cancellation(String id) { + @CacheEvict(key = "#memberId") + public void cancellation(String memberId, String id) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(MemberCoupon::getId, id); updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); @@ -245,6 +254,7 @@ public void closeMemberCoupon(List couponIds) { LambdaUpdateWrapper memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper() .in(MemberCoupon::getCouponId, couponIds) .set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); + this.cache.vagueDel("{MemberCoupon}"); this.update(memberCouponLambdaUpdateWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index 9576d6b93..cd5372de9 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -1,5 +1,6 @@ package cn.lili.modules.search.entity.dos; +import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.elasticsearch.EsSuffix; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -260,9 +261,6 @@ public class EsGoodsIndex implements Serializable { @ApiModelProperty(value = "商品类型", required = true) private String goodsType; - /** - * @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum - */ @ApiModelProperty(value = "商品sku基础分数", required = true) private Integer skuSource; @@ -280,8 +278,8 @@ public class EsGoodsIndex implements Serializable { * value 为 促销活动实体信息 */ @Field(type = FieldType.Nested) - @ApiModelProperty("商品促销活动集合,key 为 促销活动类型,value 为 促销活动实体信息 ") - private Map promotionMap; + @ApiModelProperty("商品促销活动集合JSON,key 为 促销活动类型,value 为 促销活动实体信息 ") + private String promotionMapJson; public EsGoodsIndex(GoodsSku sku) { @@ -381,6 +379,6 @@ public void setGoodsSku(GoodsSku sku) { } public Map getPromotionMap() { - return PromotionTools.filterInvalidPromotionsMap(this.promotionMap); + return PromotionTools.filterInvalidPromotionsMap(JSONUtil.parseObj(this.promotionMapJson)); } } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 1fb665ff4..fc6e9dd04 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -46,6 +46,7 @@ import org.elasticsearch.index.reindex.BulkByScrollResponse; import org.elasticsearch.index.reindex.UpdateByQueryRequest; import org.elasticsearch.script.Script; +import org.elasticsearch.script.ScriptType; import org.mybatis.spring.MyBatisSystemException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -451,7 +452,7 @@ public void deleteEsGoodsPromotionIndexByList(List skuIds, PromotionType //如果存在同类型促销活动删除 List collect = promotionMap.keySet().stream().filter(i -> i.contains(promotionType.name())).collect(Collectors.toList()); collect.forEach(promotionMap::remove); - goodsIndex.setPromotionMap(promotionMap); + goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionMap)); updateIndex(goodsIndex); } } else { @@ -503,7 +504,7 @@ private UpdateRequest removePromotionByPromotionId(EsGoodsIndex goodsIndex, Stri //如果存在同促销ID的活动删除 List collect = promotionMap.keySet().stream().filter(i -> i.split("-")[1].equals(promotionId)).collect(Collectors.toList()); collect.forEach(promotionMap::remove); - goodsIndex.setPromotionMap(promotionMap); + goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionMap)); return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), promotionMap); } return null; @@ -598,7 +599,7 @@ public EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List //获取活动信息 Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index); //写入促销信息 - index.setPromotionMap(goodsCurrentPromotionMap); + index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); return index; } @@ -634,16 +635,14 @@ private UpdateRequest updateGoodsIndexPromotion(EsGoodsIndex goodsIndex, String * @param promotionMap 促销信息 */ private UpdateRequest getGoodsIndexPromotionUpdateRequest(String id, Map promotionMap) { - JSONObject jsonObject = JSONUtil.parseObj(promotionMap); - jsonObject.setDateFormat("yyyy-MM-dd HH:mm:ss"); - String s = jsonObject.toString(); - String promotionsStr = s.replace("{", "[").replace("}", "]"); - UpdateRequest updateRequest = new UpdateRequest(); updateRequest.index(getIndexName()); updateRequest.id(id); updateRequest.retryOnConflict(5); - updateRequest.script(new Script("ctx._source." + "promotionMap" + "=" + promotionsStr + ";")); + Map params = new HashMap<>(); + params.put("promotionMap", JSONUtil.toJsonStr(promotionMap)); + Script script = new Script(ScriptType.INLINE, "painless", "ctx._source.promotionMapJson=params.promotionMap;", params); + updateRequest.script(script); return updateRequest; } @@ -758,7 +757,7 @@ private EsGoodsIndex wrapperEsGoodsIndex(GoodsSku goodsSku, Goods goods) { } //促销索引 Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index); - index.setPromotionMap(goodsCurrentPromotionMap); + index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); return index; } diff --git a/framework/src/main/java/cn/lili/modules/store/service/StoreDetailService.java b/framework/src/main/java/cn/lili/modules/store/service/StoreDetailService.java index e90ccc9ed..07995f462 100644 --- a/framework/src/main/java/cn/lili/modules/store/service/StoreDetailService.java +++ b/framework/src/main/java/cn/lili/modules/store/service/StoreDetailService.java @@ -1,9 +1,11 @@ package cn.lili.modules.store.service; +import cn.hutool.core.date.DateTime; import cn.lili.modules.store.entity.dos.Store; import cn.lili.modules.store.entity.dos.StoreDetail; import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO; import cn.lili.modules.store.entity.dto.StoreSettingDTO; +import cn.lili.modules.store.entity.dto.StoreSettlementDay; import cn.lili.modules.store.entity.vos.StoreBasicInfoVO; import cn.lili.modules.store.entity.vos.StoreDetailVO; import cn.lili.modules.store.entity.vos.StoreManagementCategoryVO; @@ -120,4 +122,20 @@ public interface StoreDetailService extends IService { * @param merchantEuid 店铺客服信息 */ Boolean editMerchantEuid(String merchantEuid); + + /** + * 获取待结算店铺列表 + * + * @param day 结算日 + * @return 待结算店铺列表 + */ + List getSettlementStore(int day); + + /** + * 修改店铺的结算日 + * + * @param storeId 店铺ID + * @param dateTime 结算日 + */ + void updateSettlementDay(String storeId, DateTime dateTime); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java index ccb7a506c..430d89d25 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java @@ -90,7 +90,7 @@ public void createBill(String storeId, Date startTime, DateTime endTime) { .eq("store_id", storeId) .eq("flow_type", FlowTypeEnum.PAY.name()) .between("create_time", startTime, endTime)); - Double orderPrice = 0D; + double orderPrice = 0D; if (orderBill != null) { bill.setOrderPrice(orderBill.getOrderPrice()); bill.setCommissionPrice(orderBill.getCommissionPrice()); @@ -98,9 +98,8 @@ public void createBill(String storeId, Date startTime, DateTime endTime) { bill.setSiteCouponCommission(orderBill.getSiteCouponCommission()); bill.setPointSettlementPrice(orderBill.getPointSettlementPrice()); bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice()); - //入账金额=订单金额+积分商品+砍价商品 - orderPrice = CurrencyUtil.add(orderBill.getBillPrice(), orderBill.getPointSettlementPrice(), - orderBill.getKanjiaSettlementPrice()); + //入账金额=订单金额 + orderPrice = orderBill.getBillPrice(); } diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java index 342f138f5..c071f9b23 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.store.serviceimpl; +import cn.hutool.core.date.DateTime; import cn.hutool.core.map.MapUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.properties.RocketmqCustomProperties; @@ -14,6 +15,7 @@ import cn.lili.modules.store.entity.dos.StoreDetail; import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO; import cn.lili.modules.store.entity.dto.StoreSettingDTO; +import cn.lili.modules.store.entity.dto.StoreSettlementDay; import cn.lili.modules.store.entity.vos.StoreBasicInfoVO; import cn.lili.modules.store.entity.vos.StoreDetailVO; import cn.lili.modules.store.entity.vos.StoreManagementCategoryVO; @@ -115,6 +117,28 @@ public Boolean editMerchantEuid(String merchantEuid) { return storeService.updateById(store); } + /** + * 获取待结算店铺列表 + * + * @param day 结算日 + * @return 待结算店铺列表 + */ + @Override + public List getSettlementStore(int day) { + return this.baseMapper.getSettlementStore(day); + } + + /** + * 修改店铺的结算日 + * + * @param storeId 店铺ID + * @param dateTime 结算日 + */ + @Override + public void updateSettlementDay(String storeId, DateTime dateTime) { + this.baseMapper.updateSettlementDay(storeId, dateTime); + } + @Override public StoreBasicInfoVO getStoreBasicInfoDTO(String storeId) { return this.baseMapper.getStoreBasicInfoDTO(storeId); diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java index f46cb8881..b78c98c00 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Objects; /** * 管理端,优惠券接口 @@ -91,7 +92,8 @@ public ResultMessage delAllByIds(@PathVariable List ids) { @ApiOperation(value = "会员优惠券作废") @PutMapping(value = "/member/cancellation/{id}") public ResultMessage cancellation(@PathVariable String id) { - memberCouponService.cancellation(id); + AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); + memberCouponService.cancellation(currentUser.getId(), id); return ResultUtil.success(ResultCode.COUPON_CANCELLATION_SUCCESS); } diff --git a/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java b/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java index d3dc5fdf2..3ecf49f32 100644 --- a/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java +++ b/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * @author paulG @@ -130,8 +129,6 @@ void init() { List esGoodsIndices = new ArrayList<>(); for (GoodsSku goodsSku : list) { EsGoodsIndex index = new EsGoodsIndex(goodsSku); - Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index); - index.setPromotionMap(goodsCurrentPromotionMap); esGoodsIndices.add(index); cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); } @@ -174,7 +171,6 @@ void searchAll() { @Test void updateIndex() { EsGoodsIndex byId = esGoodsIndexService.findById("121"); - byId.setPromotionMap(null); esGoodsIndexService.updateIndex(byId); Assertions.assertTrue(true); }