Merge remote-tracking branch 'origin/feature/pg' into test
# Conflicts: # framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java
This commit is contained in:
commit
62804941c2
@ -188,6 +188,7 @@ public class GoodsMessageListener implements RocketMQListener<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 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) {
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(goodsIndex);
|
||||
goodsIndex.setPromotionMap(goodsCurrentPromotionMap);
|
||||
goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,12 @@ package cn.lili.timetask.handler.impl.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.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 class BillExecute implements EveryDayExecute {
|
||||
int day = DateUtil.date().dayOfMonth();
|
||||
|
||||
//获取待结算商家列表
|
||||
List<StoreSettlementDay> storeList = storeDetailMapper.getSettlementStore(day);
|
||||
List<StoreSettlementDay> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
61
consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java
Normal file
61
consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java
Normal file
@ -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<StoreSettlementDay> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -78,6 +78,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
可参考 https://blog.csdn.net/u012240455/article/details/80538540
|
||||
*/
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.lili.");
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.hutool.json.");
|
||||
|
||||
return cacheManager;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -5,6 +5,8 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
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 class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
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 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
.and(Sanitizers.LINKS)
|
||||
.and(Sanitizers.BLOCKS)
|
||||
.and(Sanitizers.TABLES)
|
||||
.and(policy)
|
||||
.sanitize(value);
|
||||
}
|
||||
return HtmlUtil.unescape(value);
|
||||
|
@ -331,6 +331,9 @@ public abstract class BaseElasticsearchService {
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"promotionMapJson\": {\n" +
|
||||
" \"type\": \"text\"\n" +
|
||||
" },\n" +
|
||||
" \"thumbnail\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"fields\": {\n" +
|
||||
|
@ -54,10 +54,7 @@ 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.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 商品业务层实现
|
||||
@ -197,6 +194,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.convert.Convert;
|
||||
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.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
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 class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
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 class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
* @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 class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
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 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
//设置规格商品缩略图
|
||||
//如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前
|
||||
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();
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package cn.lili.modules.order.cart.render.impl;
|
||||
|
||||
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.CartRenderStep;
|
||||
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 class CouponRender implements CartRenderStep {
|
||||
* @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<MemberCoupon> memberCouponList = memberCouponService.getMemberCoupons(searchParams);
|
||||
List<MemberCoupon> memberCouponList = memberCouponService.getMemberCoupons(tradeDTO.getMemberId());
|
||||
|
||||
if (!memberCouponList.isEmpty()) {
|
||||
this.checkMemberExistCoupon(tradeDTO, memberCouponList);
|
||||
|
File diff suppressed because one or more lines are too long
@ -3,7 +3,6 @@ package cn.lili.modules.promotion.service;
|
||||
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<MemberCoupon> {
|
||||
/**
|
||||
* 获取会员优惠券列表
|
||||
*
|
||||
* @param pageVo 分页参数
|
||||
* @param param 查询参数
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
List<MemberCoupon> getMemberCoupons(MemberCouponSearchParams param);
|
||||
|
||||
/**
|
||||
* 获取当前用户的优惠券列表(优先读取缓存)
|
||||
*
|
||||
* @param memberId 会员id
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
List<MemberCoupon> getMemberCoupons(String memberId);
|
||||
|
||||
/**
|
||||
* 获取会员优惠券列表
|
||||
*
|
||||
@ -97,27 +103,19 @@ public interface MemberCouponService extends IService<MemberCoupon> {
|
||||
*/
|
||||
long getMemberCouponsNum();
|
||||
|
||||
/**
|
||||
* 更新会员优惠券状态
|
||||
*
|
||||
* @param status 要变更的状态
|
||||
* @param id 会员优惠券id
|
||||
*/
|
||||
void updateMemberCouponStatus(MemberCouponStatusEnum status, String id);
|
||||
|
||||
/**
|
||||
* 使用优惠券
|
||||
*
|
||||
* @param ids 会员优惠券id
|
||||
*/
|
||||
void used(List<String> ids);
|
||||
void used(String memberId, List<String> ids);
|
||||
|
||||
/**
|
||||
* 作废当前会员优惠券
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void cancellation(String id);
|
||||
void cancellation(String memberId, String id);
|
||||
|
||||
/**
|
||||
* 关闭会员优惠券
|
||||
|
@ -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.metadata.IPage;
|
||||
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 @@ import java.util.*;
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheConfig(cacheNames = "{MemberCoupon}")
|
||||
public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, MemberCoupon> implements MemberCouponService {
|
||||
|
||||
/**
|
||||
@ -45,6 +50,12 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Override
|
||||
public void checkCouponLimit(String couponId, String memberId) {
|
||||
Coupon coupon = couponService.getById(couponId);
|
||||
@ -71,6 +82,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
* @param memberName 会员名称
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void receiveBuyerCoupon(String couponId, String memberId, String memberName) {
|
||||
Coupon coupon = couponService.getById(couponId);
|
||||
if (coupon != null && !CouponGetEnum.FREE.name().equals(coupon.getGetType())) {
|
||||
@ -82,6 +94,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void receiveCoupon(String couponId, String memberId, String memberName) {
|
||||
Coupon coupon = couponService.getById(couponId);
|
||||
if (coupon != null) {
|
||||
@ -108,6 +121,22 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
return this.list(param.queryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的优惠券列表(优先读取缓存)
|
||||
*
|
||||
* @param memberId 会员id
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(key = "#memberId")
|
||||
public List<MemberCoupon> 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 class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
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<MemberCoupon> 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<String> ids) {
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void used(String memberId, List<String> ids) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
List<MemberCoupon> memberCoupons = this.listByIds(ids);
|
||||
|
||||
@ -228,7 +236,8 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
* @param id id
|
||||
*/
|
||||
@Override
|
||||
public void cancellation(String id) {
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void cancellation(String memberId, String id) {
|
||||
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(MemberCoupon::getId, id);
|
||||
updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name());
|
||||
@ -245,6 +254,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
LambdaUpdateWrapper<MemberCoupon> memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper<MemberCoupon>()
|
||||
.in(MemberCoupon::getCouponId, couponIds)
|
||||
.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name());
|
||||
this.cache.vagueDel("{MemberCoupon}");
|
||||
this.update(memberCouponLambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
|
@ -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<String, Object> promotionMap;
|
||||
@ApiModelProperty("商品促销活动集合JSON,key 为 促销活动类型,value 为 促销活动实体信息 ")
|
||||
private String promotionMapJson;
|
||||
|
||||
|
||||
public EsGoodsIndex(GoodsSku sku) {
|
||||
@ -381,6 +379,6 @@ public class EsGoodsIndex implements Serializable {
|
||||
}
|
||||
|
||||
public Map<String, Object> getPromotionMap() {
|
||||
return PromotionTools.filterInvalidPromotionsMap(this.promotionMap);
|
||||
return PromotionTools.filterInvalidPromotionsMap(JSONUtil.parseObj(this.promotionMapJson));
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import org.elasticsearch.index.query.TermQueryBuilder;
|
||||
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 class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
//如果存在同类型促销活动删除
|
||||
List<String> 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 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
//如果存在同促销ID的活动删除
|
||||
List<String> 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 class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
//获取活动信息
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
|
||||
//写入促销信息
|
||||
index.setPromotionMap(goodsCurrentPromotionMap);
|
||||
index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -634,16 +635,14 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
* @param promotionMap 促销信息
|
||||
*/
|
||||
private UpdateRequest getGoodsIndexPromotionUpdateRequest(String id, Map<String, Object> 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<String, Object> 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 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
//促销索引
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
|
||||
index.setPromotionMap(goodsCurrentPromotionMap);
|
||||
index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
|
||||
return index;
|
||||
}
|
||||
|
||||
|
@ -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<StoreDetail> {
|
||||
* @param merchantEuid 店铺客服信息
|
||||
*/
|
||||
Boolean editMerchantEuid(String merchantEuid);
|
||||
|
||||
/**
|
||||
* 获取待结算店铺列表
|
||||
*
|
||||
* @param day 结算日
|
||||
* @return 待结算店铺列表
|
||||
*/
|
||||
List<StoreSettlementDay> getSettlementStore(int day);
|
||||
|
||||
/**
|
||||
* 修改店铺的结算日
|
||||
*
|
||||
* @param storeId 店铺ID
|
||||
* @param dateTime 结算日
|
||||
*/
|
||||
void updateSettlementDay(String storeId, DateTime dateTime);
|
||||
}
|
@ -90,7 +90,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
|
||||
.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 class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
|
||||
bill.setSiteCouponCommission(orderBill.getSiteCouponCommission());
|
||||
bill.setPointSettlementPrice(orderBill.getPointSettlementPrice());
|
||||
bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice());
|
||||
//入账金额=订单金额+积分商品+砍价商品
|
||||
orderPrice = CurrencyUtil.add(orderBill.getBillPrice(), orderBill.getPointSettlementPrice(),
|
||||
orderBill.getKanjiaSettlementPrice());
|
||||
//入账金额=订单金额
|
||||
orderPrice = orderBill.getBillPrice();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.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;
|
||||
@ -115,6 +117,28 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
|
||||
return storeService.updateById(store);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待结算店铺列表
|
||||
*
|
||||
* @param day 结算日
|
||||
* @return 待结算店铺列表
|
||||
*/
|
||||
@Override
|
||||
public List<StoreSettlementDay> 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);
|
||||
|
@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 管理端,优惠券接口
|
||||
@ -91,7 +92,8 @@ public class CouponManagerController {
|
||||
@ApiOperation(value = "会员优惠券作废")
|
||||
@PutMapping(value = "/member/cancellation/{id}")
|
||||
public ResultMessage<Object> 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);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
@ -130,8 +129,6 @@ class EsTest {
|
||||
List<EsGoodsIndex> esGoodsIndices = new ArrayList<>();
|
||||
for (GoodsSku goodsSku : list) {
|
||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
|
||||
index.setPromotionMap(goodsCurrentPromotionMap);
|
||||
esGoodsIndices.add(index);
|
||||
cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity());
|
||||
}
|
||||
@ -174,7 +171,6 @@ class EsTest {
|
||||
@Test
|
||||
void updateIndex() {
|
||||
EsGoodsIndex byId = esGoodsIndexService.findById("121");
|
||||
byId.setPromotionMap(null);
|
||||
esGoodsIndexService.updateIndex(byId);
|
||||
Assertions.assertTrue(true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user