From f723c11a84020e009af63558eec8eee357ee35a4 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 14:48:05 +0800 Subject: [PATCH 01/60] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../verification/service/impl/VerificationServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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..8908f057 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 @@ -159,7 +159,8 @@ public class VerificationServiceImpl implements VerificationService { if (cache.remove(cacheResult(verificationEnums, uuid))) { return true; } - throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); +// throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); + return true; } /** From f720e001329489f4c6e09b55ee7eb1641bb35b68 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 15:42:32 +0800 Subject: [PATCH 02/60] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E9=BB=98=E8=AE=A4=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/SliderImageController.java | 2 +- .../service/impl/VerificationServiceImpl.java | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) 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..de483c78 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 @@ -26,7 +26,7 @@ public class SliderImageController { @Autowired private VerificationService verificationService; - @LimitPoint(name = "slider_image", key = "verification") +// @LimitPoint(name = "slider_image", key = "verification") @GetMapping("/{verificationEnums}") @ApiOperation(value = "获取校验接口,一分钟同一个ip请求10次") public ResultMessage getSliderImage(@RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) { 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 8908f057..284426df 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 @@ -132,18 +132,19 @@ public class VerificationServiceImpl implements VerificationService { */ @Override public boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums) { - Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid)); - if (randomX == null) { - throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); - } - log.debug("{}{}", randomX, xPos); - //验证结果正确 && 删除标记成功 - if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) { - //验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致 - cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime()); - return true; - } - throw new ServiceException(ResultCode.VERIFICATION_ERROR); +// Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid)); +// if (randomX == null) { +// throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); +// } +// log.debug("{}{}", randomX, xPos); +// //验证结果正确 && 删除标记成功 +// if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) { + //验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致 + cache.remove(cacheKey(verificationEnums, uuid)); + cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime()); + return true; +// } +// throw new ServiceException(ResultCode.VERIFICATION_ERROR); } /** From 3904bfd91d32467c7482d515119fac5e48f883fe Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 15:53:17 +0800 Subject: [PATCH 03/60] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/serviceimpl/MemberServiceImpl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 3a995b4f..bb993750 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 @@ -134,15 +134,15 @@ public class MemberServiceImpl extends ServiceImpl impleme @Override public Token usernameLogin(String username, String password) { Member member = this.findMember(username); - //判断用户是否存在 - if (member == null || !member.getDisabled()) { - throw new ServiceException(ResultCode.USER_NOT_EXIST); - } - //判断密码是否输入正确 - if (!new BCryptPasswordEncoder().matches(password, member.getPassword())) { - throw new ServiceException(ResultCode.USER_PASSWORD_ERROR); - } - loginBindUser(member); +// //判断用户是否存在 +// if (member == null || !member.getDisabled()) { +// throw new ServiceException(ResultCode.USER_NOT_EXIST); +// } +// //判断密码是否输入正确 +// if (!new BCryptPasswordEncoder().matches(password, member.getPassword())) { +// throw new ServiceException(ResultCode.USER_PASSWORD_ERROR); +// } +// loginBindUser(member); return memberTokenGenerate.createToken(member.getUsername(), false); } From 37393bb7f8cfb1796f67c08809e3b8d5d4bdb15a Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 16:55:06 +0800 Subject: [PATCH 04/60] =?UTF-8?q?=E4=BF=AE=E6=94=B9api=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E6=8F=90=E4=BA=A4=E5=8F=82=E6=95=B0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/controller/order/CartController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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..884547e2 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 @@ -236,8 +236,8 @@ public class CartController { @ApiOperation(value = "创建交易") - @PostMapping(value = "/create/trade", consumes = "application/json", produces = "application/json") - public ResultMessage crateTrade(@RequestBody TradeParams tradeParams) { + @PostMapping(value = "/create/trade") + public ResultMessage crateTrade(TradeParams tradeParams) { try { //读取选中的列表 return ResultUtil.data(this.cartService.createTrade(tradeParams)); From 7a8dd54e5caccde97a3518470bd37adaa8e52853 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 17:01:28 +0800 Subject: [PATCH 05/60] =?UTF-8?q?=E7=BB=99=E4=BA=88=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E9=BB=98=E8=AE=A4=E6=94=B6=E8=B4=A7=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/cart/entity/dto/TradeDTO.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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..f6a56cd6 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,20 @@ public class TradeDTO implements Serializable { */ private MemberAddress memberAddress; + public MemberAddress getMemberAddress() { + MemberAddress memberAddress = new MemberAddress(); + memberAddress.setId("1376445134773682176"); + memberAddress.setConsigneeAddressIdPath("1371783040145031560,1371783040145031818,1371783040145031888,1371783040145031895"); + memberAddress.setConsigneeAddressPath("河北省,廊坊市,三河市,燕郊镇"); + memberAddress.setAlias("DEFAULT"); + memberAddress.setMobile("13232323232"); + memberAddress.setName("NMNNN"); + memberAddress.setIsDefault(true); + memberAddress.setLat("131.13"); + memberAddress.setLon("131.13"); + return memberAddress; + } + /** * 客户端类型 */ From 366d1b884636c02b337a8822b6310f4e2e3a9454 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 17:10:19 +0800 Subject: [PATCH 06/60] =?UTF-8?q?=E5=AF=B9=E9=99=90=E6=B5=81=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/controller/common/SliderImageController.java | 2 +- .../src/main/java/cn/lili/controller/common/SmsController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 de483c78..85e9f653 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 @@ -34,7 +34,7 @@ public class SliderImageController { } - @LimitPoint(name = "slider_image", key = "verification_pre_check", limit = 600) +// @LimitPoint(name = "slider_image", key = "verification_pre_check", limit = 600) @PostMapping("/{verificationEnums}") @ApiOperation(value = "验证码预校验") public ResultMessage verificationImage(Integer xPos, @RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) { diff --git a/common-api/src/main/java/cn/lili/controller/common/SmsController.java b/common-api/src/main/java/cn/lili/controller/common/SmsController.java index d6f9e506..41657ac5 100644 --- a/common-api/src/main/java/cn/lili/controller/common/SmsController.java +++ b/common-api/src/main/java/cn/lili/controller/common/SmsController.java @@ -30,7 +30,7 @@ public class SmsController { @Autowired private VerificationService verificationService; - @LimitPoint(name = "sms_send", key = "sms") +// @LimitPoint(name = "sms_send", key = "sms") @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "mobile", value = "手机号"), @ApiImplicitParam(paramType = "header", dataType = "String", name = "uuid", value = "uuid"), From c1ca4764f0db7bd3766b23be38d0df12a3e71ba5 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 17:15:53 +0800 Subject: [PATCH 07/60] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E9=AA=8C=E8=AF=81=E6=9A=82=E6=97=B6=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/sms/impl/SmsUtilAliImplService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java index 19e999b9..7b12692e 100644 --- a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java @@ -132,14 +132,14 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { @Override public boolean verifyCode(String mobile, VerificationEnums verificationEnums, String uuid, String code) { - Object result = cache.get(cacheKey(verificationEnums, mobile, uuid)); - if (code.equals(result)) { +// Object result = cache.get(cacheKey(verificationEnums, mobile, uuid)); +// if (code.equals(result)) { //校验之后,删除 cache.remove(cacheKey(verificationEnums, mobile, uuid)); return true; - } else { - return false; - } +// } else { +// return false; +// } } From 9bed8e57df74a4e4011289a5dcb9600f891c17e3 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 18:34:23 +0800 Subject: [PATCH 08/60] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer-api/src/main/resources/application.yml | 5 ++--- common-api/src/main/resources/application.yml | 4 ++-- config/application.yml | 2 +- consumer/src/main/resources/application.yml | 4 ++-- manager-api/src/main/resources/application.yml | 2 +- seller-api/src/main/resources/application.yml | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/buyer-api/src/main/resources/application.yml b/buyer-api/src/main/resources/application.yml index 1a6abf13..43f1ad58 100644 --- a/buyer-api/src/main/resources/application.yml +++ b/buyer-api/src/main/resources/application.yml @@ -110,7 +110,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: true + show: false # 忽略TOKEN 鉴权 的url ignored: @@ -176,8 +176,7 @@ logging: config: classpath:logback-spring.xml # 输出级别 level: - cn.lili: debug - org.hibernate: debug + root: error # org.springframework: debug 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/config/application.yml b/config/application.yml index 796fb0ee..b20fa5a5 100644 --- a/config/application.yml +++ b/config/application.yml @@ -113,7 +113,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: true + show: false # 忽略鉴权url ignored: 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/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/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: From cc7d2c0c82d20c8ee4d5e524a8511770dcb336fa Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 18:55:37 +0800 Subject: [PATCH 09/60] =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f6a56cd6..14101279 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 @@ -109,7 +109,7 @@ public class TradeDTO implements Serializable { public MemberAddress getMemberAddress() { MemberAddress memberAddress = new MemberAddress(); memberAddress.setId("1376445134773682176"); - memberAddress.setConsigneeAddressIdPath("1371783040145031560,1371783040145031818,1371783040145031888,1371783040145031895"); + memberAddress.setConsigneeAddressIdPath("1401797451706269749,1401797451706270007,1401797451706270104,1401797451706270108"); memberAddress.setConsigneeAddressPath("河北省,廊坊市,三河市,燕郊镇"); memberAddress.setAlias("DEFAULT"); memberAddress.setMobile("13232323232"); From eddcbc2ecb44c6b50a232c0bfe18566aa94ce84f Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 11 Jan 2022 11:12:19 +0800 Subject: [PATCH 10/60] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BA=8B=E4=BB=B6=EF=BC=8C=E5=AF=B9token?= =?UTF-8?q?=E5=A4=84=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 2 +- .../java/cn/lili/event/MemberLoginEvent.java | 19 ++++++ .../cn/lili/event/MemberRegisterEvent.java | 2 +- .../cn/lili/event/impl/MemberExecute.java | 25 ++++++++ .../lili/listener/MemberMessageListener.java | 22 +++++++ .../java/cn/lili/common/enums/ResultCode.java | 3 +- .../token/base/AbstractTokenGenerate.java | 4 +- .../serviceimpl/ConnectServiceImpl.java | 6 +- .../member/serviceimpl/MemberServiceImpl.java | 62 +++++++++---------- .../member/token/MemberTokenGenerate.java | 18 ++++-- .../member/token/StoreTokenGenerate.java | 12 ++-- .../serviceimpl/AdminUserServiceImpl.java | 2 +- .../system/token/ManagerTokenGenerate.java | 14 ++--- .../cn/lili/rocketmq/tags/MemberTagsEnum.java | 4 ++ 14 files changed, 136 insertions(+), 59 deletions(-) create mode 100644 consumer/src/main/java/cn/lili/event/MemberLoginEvent.java create mode 100644 consumer/src/main/java/cn/lili/event/impl/MemberExecute.java diff --git a/config/application.yml b/config/application.yml index b20fa5a5..796fb0ee 100644 --- a/config/application.yml +++ b/config/application.yml @@ -113,7 +113,7 @@ spring: props: #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 sql: - show: false + show: true # 忽略鉴权url ignored: 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/MemberExecute.java b/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java new file mode 100644 index 00000000..5411002f --- /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.updateById(member); + } +} 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/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 6b621a35..b335862d 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/security/token/base/AbstractTokenGenerate.java b/framework/src/main/java/cn/lili/common/security/token/base/AbstractTokenGenerate.java index 48418b65..67865f2d 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 @@ -16,11 +16,11 @@ 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(Object user, Boolean longTerm); /** * 刷新token 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/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index bb993750..aaebfe37 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 @@ -17,6 +17,7 @@ import cn.lili.common.security.token.Token; import cn.lili.common.sensitive.SensitiveWordsFilter; import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.CookieUtil; +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; @@ -143,7 +144,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 @@ -168,7 +169,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); } /** @@ -196,12 +197,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; @@ -235,13 +234,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 @@ -281,13 +290,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 @@ -331,9 +336,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; } @@ -430,10 +433,11 @@ public class MemberServiceImpl extends ServiceImpl impleme * @param mobilePhone 手机号 * @return 会员 */ - private Member findByPhone(String mobilePhone) { + private List 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.selectList(queryWrapper); } /** @@ -589,13 +593,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) != null) { + throw new ServiceException(ResultCode.USER_EXIST); } } } \ No newline at end of file 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 79528c99..bd065b3b 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,5 +1,6 @@ package cn.lili.modules.member.token; +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; @@ -9,6 +10,9 @@ 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; @@ -28,11 +32,16 @@ public class MemberTokenGenerate extends AbstractTokenGenerate { private MemberService memberService; @Autowired private TokenUtil tokenUtil; + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; + + @Autowired + private RocketMQTemplate rocketMQTemplate; @Override - public Token createToken(String username, Boolean longTerm) { + public Token createToken(Object user, Boolean longTerm) { - Member member = memberService.findByUsername(username); + Member member = (Member) user; //获取客户端类型 String clientType = ThreadContextHolder.getHttpRequest().getHeader("clientType"); @@ -50,11 +59,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(), 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 a1a2c595..072407fc 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 @@ -32,20 +32,20 @@ public class StoreTokenGenerate extends AbstractTokenGenerate { private TokenUtil tokenUtil; @Override - public Token createToken(String username, Boolean longTerm) { + public Token createToken(Object user, Boolean longTerm) { //生成token - Member member = memberService.findByUsername(username); + Member member = (Member) user; if (!member.getHaveStore()) { throw new ServiceException(ResultCode.STORE_NOT_OPEN); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Store::getMemberId, member.getId()); Store store = storeService.getOne(queryWrapper); - AuthUser user = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), store.getStoreLogo(), UserEnums.STORE); + AuthUser authUser = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), store.getStoreLogo(), UserEnums.STORE); - user.setStoreId(store.getId()); - user.setStoreName(store.getStoreName()); - return tokenUtil.createToken(username, user, longTerm, 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/permission/serviceimpl/AdminUserServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java index 7bd421b3..f1b92e8c 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 @@ -119,7 +119,7 @@ public class AdminUserServiceImpl extends ServiceImpl 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/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("会员登录"), /** * 会员签到 */ From b0843aa744ad05b019b579e505d6977864803b89 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 11 Jan 2022 11:16:17 +0800 Subject: [PATCH 11/60] =?UTF-8?q?token=E7=9B=B8=E5=85=B3=E7=B1=BB=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=B3=9B=E5=9E=8B=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/token/base/AbstractTokenGenerate.java | 4 ++-- .../lili/modules/member/token/MemberTokenGenerate.java | 9 ++------- .../cn/lili/modules/member/token/StoreTokenGenerate.java | 8 ++------ .../lili/modules/system/token/ManagerTokenGenerate.java | 6 ++---- 4 files changed, 8 insertions(+), 19 deletions(-) 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 67865f2d..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,7 +11,7 @@ import cn.lili.common.security.token.Token; * @version v1.0 * 2020-11-13 10:13 */ -public abstract class AbstractTokenGenerate { +public abstract class AbstractTokenGenerate { /** * 生成token @@ -20,7 +20,7 @@ public abstract class AbstractTokenGenerate { * @param longTerm 是否长时间有效 * @return TOKEN对象 */ - public abstract Token createToken(Object user, Boolean longTerm); + public abstract Token createToken(T user, Boolean longTerm); /** * 刷新token 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 bd065b3b..d903d549 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 @@ -26,10 +26,7 @@ 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 @@ -39,9 +36,7 @@ public class MemberTokenGenerate extends AbstractTokenGenerate { private RocketMQTemplate rocketMQTemplate; @Override - public Token createToken(Object user, Boolean longTerm) { - - Member member = (Member) user; + public Token createToken(Member member, Boolean longTerm) { //获取客户端类型 String clientType = ThreadContextHolder.getHttpRequest().getHeader("clientType"); 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 072407fc..558289df 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 @@ -23,18 +23,14 @@ import org.springframework.stereotype.Component; * @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 private TokenUtil tokenUtil; @Override - public Token createToken(Object user, Boolean longTerm) { - //生成token - Member member = (Member) user; + public Token createToken(Member member, Boolean longTerm) { if (!member.getHaveStore()) { throw new ServiceException(ResultCode.STORE_NOT_OPEN); } 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 3b14383e..cef1db51 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,7 +29,7 @@ import java.util.Map; * @since 2020/11/16 10:51 */ @Component -public class ManagerTokenGenerate extends AbstractTokenGenerate { +public class ManagerTokenGenerate extends AbstractTokenGenerate { @Autowired private TokenUtil tokenUtil; @@ -40,9 +40,7 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate { @Override - public Token createToken(Object user, Boolean longTerm) { - //生成token - AdminUser adminUser = (AdminUser) user; + public Token createToken(AdminUser adminUser, Boolean longTerm) { AuthUser authUser = new AuthUser(adminUser.getUsername(), adminUser.getId(), adminUser.getAvatar(), UserEnums.MANAGER, adminUser.getNickName(), adminUser.getIsSuper()); From 4a3c978e073484ea8f4ec566b7f73a59a88c9fbe Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 11 Jan 2022 11:23:38 +0800 Subject: [PATCH 12/60] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/member/serviceimpl/MemberServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 aaebfe37..5902d3fb 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 @@ -593,8 +593,9 @@ public class MemberServiceImpl extends ServiceImpl impleme * @param mobilePhone 手机号 */ private void checkMember(String userName, String mobilePhone) { + List members = findMember(userName, mobilePhone); //判断手机号是否存在 - if (findMember(userName, mobilePhone) != null) { + if (members != null && !members.isEmpty()) { throw new ServiceException(ResultCode.USER_EXIST); } } From 5f0241768d553bf253a47edc8d4ea40bb6e54865 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 11 Jan 2022 14:48:11 +0800 Subject: [PATCH 13/60] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=BA=8B=E5=8A=A1?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java | 1 - 1 file changed, 1 deletion(-) 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 { /** From eec361121868437633863d449aefb77318cdb48c Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 11 Jan 2022 15:16:02 +0800 Subject: [PATCH 14/60] =?UTF-8?q?=E4=BC=98=E5=8C=96sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/member/mapper/FootprintMapper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 From 0460e219f9ca61a3f71c1a3b0c08f288a6be607f Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 11 Jan 2022 16:34:18 +0800 Subject: [PATCH 15/60] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=97=B6=E5=87=8F=E5=B0=91=E4=B8=80=E6=AC=A1redis?= =?UTF-8?q?=E7=9A=84=E8=AF=BB=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 2 +- .../modules/order/cart/render/TradeBuilder.java | 15 ++++++++------- .../order/cart/service/CartServiceImpl.java | 4 +--- .../order/order/serviceimpl/TradeServiceImpl.java | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/config/application.yml b/config/application.yml index 796fb0ee..5021c081 100644 --- a/config/application.yml +++ b/config/application.yml @@ -183,7 +183,7 @@ mybatis-plus: logging: # 输出级别 level: - cn.lili: info + root: error # org.hibernate: debug # org.springframework: debug # org.springframework.data.mongodb.core: debug 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 b67959f7..d6d77784 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; /** @@ -85,19 +86,17 @@ 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 (checkedWay.equals(CartTypeEnum.PINTUAN)) { + } else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) { renderCartBySteps(tradeDTO, RenderStepStatement.pintuanTradeRender); - } else { + } else { renderCartBySteps(tradeDTO, RenderStepStatement.tradeRender); } @@ -128,7 +127,9 @@ public class TradeBuilder { for (CartRenderStep render : cartRenderSteps) { try { if (render.step().equals(step)) { + Date date = new Date(); render.render(tradeDTO); + log.error(render.getClass().getName() + "-" + (System.currentTimeMillis() - date.getTime())); } } catch (ServiceException e) { throw e; 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 c6938fa5..52808dbf 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 @@ -552,10 +552,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; } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index f7dbbd88..ef47d67d 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -1 +1 @@ -package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional(rollbackFor = Exception.class) public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, 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(ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file +package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional(rollbackFor = Exception.class) public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 如果包含不支持配送的商品 抛出异常 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file From 1c28e0bd5f74ee7c8fd32e8db90d58c5b6df7928 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 11 Jan 2022 17:34:00 +0800 Subject: [PATCH 16/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=97=B6=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E4=BF=A1=E6=81=AF=EF=BC=88=E5=A2=9E=E5=8A=A0redis?= =?UTF-8?q?=E5=AD=98=E5=82=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/cart/render/impl/CouponRender.java | 10 +--- .../order/serviceimpl/TradeServiceImpl.java | 2 +- .../service/MemberCouponService.java | 22 ++++--- .../serviceimpl/MemberCouponServiceImpl.java | 58 +++++++++++-------- .../promotion/CouponManagerController.java | 4 +- 5 files changed, 49 insertions(+), 47 deletions(-) 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 0157b7bc..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 @@ -2,7 +2,6 @@ package cn.lili.modules.order.cart.render.impl; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.PromotionTypeEnum; -import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.StringUtils; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; @@ -13,11 +12,8 @@ import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.cart.render.util.PromotionPriceUtil; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.promotion.entity.dos.MemberCoupon; -import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; import cn.lili.modules.promotion.entity.enums.CouponTypeEnum; -import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; -import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.vos.MemberCouponVO; import cn.lili.modules.promotion.service.MemberCouponService; import org.springframework.beans.factory.annotation.Autowired; @@ -64,11 +60,7 @@ public class CouponRender implements CartRenderStep { * @param tradeDTO 交易dto */ private void renderCouponRule(TradeDTO tradeDTO) { - MemberCouponSearchParams searchParams = new MemberCouponSearchParams(); - searchParams.setMemberId(UserContext.getCurrentUser().getId()); - searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name()); - searchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); - List memberCouponList = memberCouponService.getMemberCoupons(searchParams); + List memberCouponList = memberCouponService.getMemberCoupons(tradeDTO.getMemberId()); if (!memberCouponList.isEmpty()) { this.checkMemberExistCoupon(tradeDTO, memberCouponList); diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index f7dbbd88..da858217 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -1 +1 @@ -package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional(rollbackFor = Exception.class) public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, 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(ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file +package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional(rollbackFor = Exception.class) public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId() ,ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java index 6f4178cf..dadf18d6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java @@ -3,7 +3,6 @@ package cn.lili.modules.promotion.service; import cn.lili.common.vo.PageVO; import cn.lili.modules.promotion.entity.dos.MemberCoupon; import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; -import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -55,12 +54,19 @@ public interface MemberCouponService extends IService { /** * 获取会员优惠券列表 * - * @param pageVo 分页参数 * @param param 查询参数 * @return 会员优惠券列表 */ List getMemberCoupons(MemberCouponSearchParams param); + /** + * 获取当前用户的优惠券列表(优先读取缓存) + * + * @param memberId 会员id + * @return 会员优惠券列表 + */ + List getMemberCoupons(String memberId); + /** * 获取会员优惠券列表 * @@ -97,27 +103,19 @@ public interface MemberCouponService extends IService { */ long getMemberCouponsNum(); - /** - * 更新会员优惠券状态 - * - * @param status 要变更的状态 - * @param id 会员优惠券id - */ - void updateMemberCouponStatus(MemberCouponStatusEnum status, String id); - /** * 使用优惠券 * * @param ids 会员优惠券id */ - void used(List ids); + void used(String memberId, List ids); /** * 作废当前会员优惠券 * * @param id id */ - void cancellation(String id); + void cancellation(String memberId, String id); /** * 关闭会员优惠券 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index acea35dc..0c851736 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.promotion.serviceimpl; +import cn.lili.cache.Cache; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.AuthUser; @@ -24,6 +25,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,6 +41,7 @@ import java.util.*; */ @Service @Transactional(rollbackFor = Exception.class) +@CacheConfig(cacheNames = "{MemberCoupon}") public class MemberCouponServiceImpl extends ServiceImpl implements MemberCouponService { /** @@ -45,6 +50,12 @@ public class MemberCouponServiceImpl extends ServiceImpl getMemberCoupons(String memberId) { + MemberCouponSearchParams searchParams = new MemberCouponSearchParams(); + searchParams.setMemberId(Objects.requireNonNull(UserContext.getCurrentUser()).getId()); + searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name()); + searchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); + return this.getMemberCoupons(searchParams); + } + /** * 获取会员优惠券列表 * @@ -177,31 +206,10 @@ public class MemberCouponServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(MemberCoupon::getId, id).set(MemberCoupon::getMemberCouponStatus, status.name()); - this.update(updateWrapper); - } else { - throw new ServiceException(ResultCode.COUPON_MEMBER_STATUS_ERROR); - } - } - @Override - public void used(List ids) { + @CacheEvict(key = "#memberId") + public void used(String memberId, List ids) { if (ids != null && !ids.isEmpty()) { List memberCoupons = this.listByIds(ids); @@ -228,7 +236,8 @@ public class MemberCouponServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(MemberCoupon::getId, id); updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); @@ -245,6 +254,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/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java index f46cb888..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 @@ -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); } From 05818baf7a4dad1fb9e38156f975edbb103dd385 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 11 Jan 2022 17:34:48 +0800 Subject: [PATCH 17/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9=EF=BC=8C=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E8=B7=AF=E5=9F=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer-api/src/main/resources/application.yml | 6 +++--- config/application.yml | 4 ++-- .../modules/goods/service/CategoryService.java | 15 +++++++++++++++ .../goods/serviceimpl/CategoryServiceImpl.java | 5 +++++ .../modules/order/cart/render/TradeBuilder.java | 2 -- .../order/cart/render/impl/CommissionRender.java | 2 +- .../store/service/FreightTemplateService.java | 7 +++++++ 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/buyer-api/src/main/resources/application.yml b/buyer-api/src/main/resources/application.yml index 43f1ad58..246a0680 100644 --- a/buyer-api/src/main/resources/application.yml +++ b/buyer-api/src/main/resources/application.yml @@ -69,10 +69,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 diff --git a/config/application.yml b/config/application.yml index 5021c081..0753c11f 100644 --- a/config/application.yml +++ b/config/application.yml @@ -72,8 +72,8 @@ spring: url: jdbc:mysql://192.168.0.116: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: 20 maxWait: 60000 minIdle: 5 timeBetweenEvictionRunsMillis: 60000 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/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index ab31d983..e7c5dee0 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 @@ -60,6 +60,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/order/cart/render/TradeBuilder.java b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java index d6d77784..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 @@ -127,9 +127,7 @@ public class TradeBuilder { for (CartRenderStep render : cartRenderSteps) { try { if (render.step().equals(step)) { - Date date = new Date(); render.render(tradeDTO); - log.error(render.getClass().getName() + "-" + (System.currentTimeMillis() - date.getTime())); } } catch (ServiceException e) { throw e; 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 4df13428..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 @@ -66,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); } 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 From 65e7f9750a98aab7cecb7cbd5d58da4706346dd8 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 12 Jan 2022 11:20:27 +0800 Subject: [PATCH 18/60] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96uuid?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=8C=E4=B8=BA=E5=8E=8B=E6=B5=8B?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=9A=84=E5=90=8C=E4=B8=80token=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/controller/common/UploadController.java | 3 --- .../lili/common/security/context/UserContext.java | 14 ++++++++++++++ .../lili/common/security/enums/SecurityEnum.java | 2 +- .../order/cart/service/CartServiceImpl.java | 5 +++-- 4 files changed, 18 insertions(+), 6 deletions(-) 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/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..6ecf8ee6 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,20 @@ public class UserContext { return null; } + /** + * 根据request获取用户信息 + * + * @return 授权用户 + */ + public static String getUuid() { + if (RequestContextHolder.getRequestAttributes() != null) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String uuid = request.getHeader(SecurityEnum.UUID.getValue()); + return uuid; + } + 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/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 52808dbf..bf975b0a 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 @@ -229,8 +229,9 @@ public class CartServiceImpl implements CartService { //缓存key,默认使用购物车 if (cartTypeEnum != null) { - AuthUser currentUser = UserContext.getCurrentUser(); - return cartTypeEnum.getPrefix() + currentUser.getId(); +// AuthUser currentUser = UserContext.getCurrentUser(); +// return cartTypeEnum.getPrefix() + currentUser.getId(); + return cartTypeEnum.getPrefix() + UserContext.getUuid(); } throw new ServiceException(ResultCode.ERROR); } From 9e74c154132c62b75a90dcbdacab175c548be82d Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 12 Jan 2022 19:46:07 +0800 Subject: [PATCH 19/60] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/listener/GoodsMessageListener.java | 2 +- .../listener/NoticeSendMessageListener.java | 9 +--- .../goods/service/GoodsSkuService.java | 8 ---- .../serviceimpl/GoodsSkuServiceImpl.java | 33 +++------------ .../entity/dto/EvaluationQueryParams.java | 41 +++++++++++-------- .../service/MemberEvaluationService.java | 21 ++++++++++ .../modules/member/service/MemberService.java | 7 ++++ .../MemberEvaluationServiceImpl.java | 30 ++++++++++++++ .../member/serviceimpl/MemberServiceImpl.java | 10 +++++ .../order/cart/service/CartServiceImpl.java | 33 ++++----------- .../service/MemberCouponService.java | 8 ++++ .../promotion/service/PromotionService.java | 7 ++-- .../serviceimpl/MemberCouponServiceImpl.java | 11 +++++ .../serviceimpl/PromotionServiceImpl.java | 15 ++++--- .../search/service/EsGoodsIndexService.java | 4 +- .../serviceimpl/EsGoodsIndexServiceImpl.java | 27 +++++++++--- 16 files changed, 160 insertions(+), 106 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 4b9f3053..8f9d2ed4 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -390,7 +390,7 @@ public class GoodsMessageListener implements RocketMQListener { } if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) { - Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(goodsIndex); + Map goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(goodsIndex.getStoreId(), goodsIndex.getId()); goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); } } 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/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/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 0badc920..fe4cec56 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 @@ -28,7 +28,7 @@ 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; @@ -251,11 +251,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()); } //商品规格 @@ -503,12 +499,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); @@ -532,22 +527,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的集合 * 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/service/MemberEvaluationService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java index 44878063..1b600ce9 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 @@ -88,5 +88,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 a4256c17..a93c18ad 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 @@ -220,4 +220,11 @@ public interface MemberService extends IService { * @param userEnums token角色类型 */ void logout(UserEnums userEnums); + + /** + * 获取所有会员的手机号 + * + * @return 所有会员的手机号 + */ + List getAllMemberMobile(); } \ No newline at end of file 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..09cb1155 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; @@ -191,6 +196,31 @@ 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/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 3a995b4f..4da302b2 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 @@ -582,6 +582,16 @@ public class MemberServiceImpl extends ServiceImpl impleme } } + /** + * 获取所有会员的手机号 + * + * @return 所有会员的手机号 + */ + @Override + public List getAllMemberMobile() { + return this.baseMapper.getAllMemberMobile(); + } + /** * 检测会员 * 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 c6938fa5..25f3d9c2 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 @@ -7,7 +7,6 @@ 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; @@ -35,6 +34,7 @@ import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.dos.MemberCoupon; 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; @@ -47,11 +47,7 @@ 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; @@ -115,16 +111,6 @@ public class CartServiceImpl implements CartService { */ @Autowired private KanjiaActivityService kanjiaActivityService; - /** - * rocketMq - */ - @Autowired - private RocketMQTemplate rocketMQTemplate; - /** - * rocketMq配置 - */ - @Autowired - private RocketmqCustomProperties rocketmqCustomProperties; /** * 交易 */ @@ -516,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); } @@ -565,11 +550,7 @@ 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())) || 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 dadf18d6..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 @@ -96,6 +96,14 @@ public interface MemberCouponService extends IService { */ List getAllScopeMemberCoupon(String memberId, List storeId); + /** + * 获取会员优惠券 + * + * @param param 查询参数 + * @return 会员优惠券列表 + */ + MemberCoupon getMemberCoupon(MemberCouponSearchParams param); + /** * 获取会员优惠券数量 * 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/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index 0c851736..87d807dc 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 @@ -196,6 +196,17 @@ public class MemberCouponServiceImpl extends ServiceImpl 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())) { @@ -132,7 +131,7 @@ public class PromotionServiceImpl implements PromotionService { 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()); @@ -146,7 +145,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()); 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 6ff46c49..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 @@ -178,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 fc6e9dd0..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; @@ -32,8 +33,11 @@ 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; @@ -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; @@ -587,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.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; } @@ -756,7 +773,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } } //促销索引 - Map goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index); + Map goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(index.getStoreId(), index.getId()); index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); return index; } From f8260c3b29fd62da5eee5dfa19aaafea14963f61 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 13 Jan 2022 17:04:01 +0800 Subject: [PATCH 20/60] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E4=B8=BA=E9=83=A8=E5=88=86=E5=95=86?= =?UTF-8?q?=E5=93=81=E3=80=82=E9=83=A8=E5=88=86=E5=95=86=E5=93=81=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E4=BC=98=E6=83=A0=E5=88=B8=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 25f3d9c2..7d3e6539 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 @@ -676,7 +676,7 @@ public class CartServiceImpl implements CartService { return cartSkuVOS.stream().filter(i -> i.getGoodsSku().getCategoryPath().indexOf("," + memberCoupon.getScopeId() + ",") <= 0).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()); From b93d10eeea1b317f3a9b83f1037b54b9f83bfe12 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 13 Jan 2022 17:38:36 +0800 Subject: [PATCH 21/60] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E4=B8=BA=E9=83=A8=E5=88=86=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E3=80=82=E9=83=A8=E5=88=86=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E4=BD=BF=E7=94=A8=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 7d3e6539..f6d0a46d 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 @@ -673,13 +673,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 -> 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<>(); } From def6247e9f4c59956b7bc59665408b6b1bfb7e5a Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 17 Jan 2022 17:42:42 +0800 Subject: [PATCH 22/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=AB=AF=E7=99=BB=E5=BD=95=E5=92=8Cxss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter/XssHttpServletRequestWrapper.java | 52 +++---------------- .../passport/AdminUserManagerController.java | 2 +- 2 files changed, 7 insertions(+), 47 deletions(-) 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 ad694aea..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 @@ -7,7 +7,6 @@ import cn.hutool.json.JSONUtil; import lombok.extern.slf4j.Slf4j; import org.owasp.html.HtmlPolicyBuilder; import org.owasp.html.PolicyFactory; -import org.owasp.html.Sanitizers; import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; @@ -32,33 +31,6 @@ 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", - "id", - "price", - "prop", - "reply", - "profile", - "privateKey", - "wechatpay", - }; - //允许的标签 private static final String[] allowedTags = {"h1", "h2", "h3", "h4", "h5", "h6", "span", "strong", @@ -74,8 +46,10 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { "footer", "header", "hgroup", "section", "summary"}; //带有超链接的标签 - private static final String[] linkTags = {"img", "video", "source", "a", "iframe"}; + 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); @@ -284,19 +258,11 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { .allowElements(allowedTags) //内容标签转化为div .allowElements((elementName, attributes) -> "div", needTransformTags) - .allowAttributes("src", "href", "target", "width", "height").onElements(linkTags) - //校验链接中的是否为http -// .allowUrlProtocols("https") + .allowAttributes(allowAttributes).onElements(linkTags) + .allowStyling() .toFactory(); // basic prepackaged policies for links, tables, integers, images, styles, blocks - value = Sanitizers.FORMATTING - .and(Sanitizers.STYLES) - .and(Sanitizers.IMAGES) - .and(Sanitizers.LINKS) - .and(Sanitizers.BLOCKS) - .and(Sanitizers.TABLES) - .and(policy) - .sanitize(value); + value = policy.sanitize(value); } return HtmlUtil.unescape(value); } @@ -309,12 +275,6 @@ 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/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..80adbfff 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 @@ -62,7 +62,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, From 575458afb39b26874fcc4bb582692e03a20a80fd Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 18 Jan 2022 09:50:26 +0800 Subject: [PATCH 23/60] =?UTF-8?q?1=E3=80=81=E5=8E=BB=E9=99=A4=E9=9D=9E?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E4=BA=8B=E5=8A=A1=202=E3=80=81=E5=AF=B9?= =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E5=A4=9A=E8=8A=82=E7=82=B9=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E6=97=B6=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9B=B8=E5=90=8C=E7=9A=84=E9=9B=AA=E8=8A=B1=E7=AE=97?= =?UTF-8?q?=E6=B3=95id=E9=97=AE=E9=A2=98=E8=BF=9B=E8=A1=8C=E5=A4=84?= =?UTF-8?q?=E7=90=86=203=E3=80=81=E5=85=B6=E4=BB=96=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/RechargeTradeBuyerController.java | 1 - .../MemberWithdrawApplyBuyerController.java | 1 - .../wallet/RechargeBuyerController.java | 1 - buyer-api/src/main/resources/application.yml | 19 ++++-- .../src/main/java/cn/lili/cache/Cache.java | 8 +++ .../java/cn/lili/cache/impl/RedisCache.java | 10 +++- .../java/cn/lili/common/utils/SnowFlake.java | 33 ++++++++--- .../lili/common/utils/SnowflakeInitiator.java | 58 +++++++++++++++++++ .../DistributionCashServiceImpl.java | 1 - .../DistributionGoodsServiceImpl.java | 1 - .../DistributionOrderServiceImpl.java | 1 - .../DistributionSelectedGoodsServiceImpl.java | 1 - .../serviceimpl/DistributionServiceImpl.java | 1 - .../file/serviceimpl/FileServiceImpl.java | 1 - .../goods/serviceimpl/BrandServiceImpl.java | 1 - .../serviceimpl/CategoryBrandServiceImpl.java | 1 - .../CategoryParameterGroupServiceImpl.java | 1 - .../serviceimpl/CategoryServiceImpl.java | 1 - .../CategorySpecificationServiceImpl.java | 1 - .../serviceimpl/DraftGoodsServiceImpl.java | 1 - .../serviceimpl/GoodsGalleryServiceImpl.java | 1 - .../goods/serviceimpl/GoodsServiceImpl.java | 1 - .../serviceimpl/GoodsSkuServiceImpl.java | 1 - .../serviceimpl/GoodsWordsServiceImpl.java | 1 - .../StoreGoodsLabelServiceImpl.java | 1 - .../GoodsCollectionServiceImpl.java | 1 - .../serviceimpl/MemberAddressServiceImpl.java | 1 - .../MemberEvaluationServiceImpl.java | 1 - .../member/serviceimpl/MemberServiceImpl.java | 8 +-- .../serviceimpl/MessageServiceImpl.java | 1 - .../serviceimpl/ShortLinkServiceImpl.java | 1 - .../serviceimpl/AfterSaleLogServiceImpl.java | 1 - .../AfterSaleReasonServiceImpl.java | 1 - .../serviceimpl/AfterSaleServiceImpl.java | 1 - .../serviceimpl/OrderItemServiceImpl.java | 1 - .../serviceimpl/OrderPriceServiceImpl.java | 1 - .../order/serviceimpl/OrderServiceImpl.java | 2 +- .../serviceimpl/StoreFlowServiceImpl.java | 1 - .../order/serviceimpl/TradeServiceImpl.java | 2 +- .../ArticleCategoryServiceImpl.java | 1 - .../page/serviceimpl/ArticleServiceImpl.java | 1 - .../page/serviceimpl/FeedbackServiceImpl.java | 1 - .../serviceimpl/PaymentServiceImpl.java | 1 - .../serviceimpl/RefundLogServiceImpl.java | 1 - .../serviceimpl/AdminUserServiceImpl.java | 1 - .../DepartmentRoleServiceImpl.java | 1 - .../serviceimpl/DepartmentServiceImpl.java | 1 - .../serviceimpl/RoleMenuServiceImpl.java | 1 - .../serviceimpl/RoleServiceImpl.java | 1 - .../serviceimpl/SystemLogServiceImpl.java | 1 - .../serviceimpl/UserRoleServiceImpl.java | 1 - .../AbstractPromotionsServiceImpl.java | 1 - .../serviceimpl/CouponServiceImpl.java | 1 - .../serviceimpl/FullDiscountServiceImpl.java | 1 - .../KanjiaActivityGoodsServiceImpl.java | 1 - .../KanjiaActivityLogServiceImpl.java | 1 - .../KanjiaActivityServiceImpl.java | 1 - .../serviceimpl/MemberCouponServiceImpl.java | 1 - .../serviceimpl/PintuanServiceImpl.java | 1 - .../PointsGoodsCategoryServiceImpl.java | 1 - .../serviceimpl/PointsGoodsServiceImpl.java | 1 - .../PromotionGoodsServiceImpl.java | 1 - .../serviceimpl/PromotionServiceImpl.java | 1 - .../serviceimpl/SeckillApplyServiceImpl.java | 1 - .../serviceimpl/SeckillServiceImpl.java | 1 - .../aop/aspect/PageViewInterceptor.java | 2 - .../BillStatisticsServiceImpl.java | 1 - ...DistributionCashStatisticsServiceImpl.java | 1 - ...MemberEvaluationStatisticsServiceImpl.java | 1 - .../SeckillStatisticsServiceImpl.java | 1 - .../store/serviceimpl/BillServiceImpl.java | 1 - .../FreightTemplateServiceChildImpl.java | 1 - .../FreightTemplateServiceImpl.java | 1 - .../serviceimpl/StoreAddressServiceImpl.java | 1 - .../serviceimpl/StoreDetailServiceImpl.java | 1 - .../store/serviceimpl/StoreServiceImpl.java | 1 - .../serviceimpl/AppVersionServiceImpl.java | 1 - .../system/serviceimpl/RegionServiceImpl.java | 1 - .../impl/VerificationSourceServiceImpl.java | 1 - .../serviceimpl/MemberWalletServiceImpl.java | 1 - .../MemberWithdrawApplyServiceImpl.java | 1 - .../serviceimpl/RechargeServiceImpl.java | 1 - .../serviceimpl/WalletLogServiceImpl.java | 1 - .../WechatMPMessageServiceImpl.java | 1 - .../serviceimpl/WechatMessageServiceImpl.java | 1 - .../java/cn/lili/test/script/ScriptTest.java | 1 - .../MemberMessageManagerController.java | 1 - .../order/OrderLogManagerController.java | 1 - .../order/PaymentLogManagerController.java | 1 - .../order/RefundLogManagerController.java | 1 - .../other/VerificationSourceController.java | 1 - .../passport/AdminUserManagerController.java | 1 - .../setting/LogManagerController.java | 1 - .../setting/RegionManagerController.java | 1 - .../store/StoreMessageManagerController.java | 1 - .../MemberWithdrawApplyManagerController.java | 1 - .../wallet/RechargeManagerController.java | 1 - .../wallet/WalletLogManagerController.java | 1 - .../WechatMPMessageManagerController.java | 1 - ...CategoryParameterGroupStoreController.java | 1 - .../CategorySpecificationStoreController.java | 1 - .../goods/CategoryStoreController.java | 1 - .../goods/GoodsUnitStoreController.java | 1 - .../settings/LogStoreController.java | 1 - 104 files changed, 116 insertions(+), 121 deletions(-) create mode 100644 framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java 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..6071e61b 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 @@ -26,7 +26,6 @@ import javax.validation.constraints.Min; @RestController @Api(tags = "买家端,预存款充值记录接口") @RequestMapping("/buyer/trade/recharge") -@Transactional(rollbackFor = Exception.class) public class RechargeTradeBuyerController { @Autowired 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 246a0680..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: 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/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/common/utils/SnowFlake.java b/framework/src/main/java/cn/lili/common/utils/SnowFlake.java index d7a788cc..18379ea7 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,30 @@ 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); + log.error(workerId+""+datacenterId); + } public static long getId() { return snowflake.nextId(); @@ -29,12 +42,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/modules/distribution/serviceimpl/DistributionCashServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java index 4f3235be..d93247e2 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java @@ -40,7 +40,6 @@ import java.util.Date; * @since 2020-03-126 18:04:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class DistributionCashServiceImpl extends ServiceImpl 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 92ffc97b..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 { /** 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/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 e7c5dee0..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"; 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 b52dba6e..90ebd4c4 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 @@ -63,7 +63,6 @@ import java.util.*; * @since 2020-02-23 15:18:56 */ @Service -@Transactional(rollbackFor = Exception.class) public class GoodsServiceImpl extends ServiceImpl implements GoodsService { 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 0badc920..7f15c9c3 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 @@ -63,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 { /** 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/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..36f6403c 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 @@ -51,7 +51,6 @@ import java.util.Map; * @since 2020-02-25 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberEvaluationServiceImpl extends ServiceImpl implements MemberEvaluationService { /** 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 5902d3fb..70625701 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 @@ -63,7 +63,6 @@ import java.util.Objects; * @since 2021-03-29 14:10:16 */ @Service -@Transactional(rollbackFor = Exception.class) public class MemberServiceImpl extends ServiceImpl implements MemberService { /** @@ -433,11 +432,11 @@ public class MemberServiceImpl extends ServiceImpl impleme * @param mobilePhone 手机号 * @return 会员 */ - private List findMember(String mobilePhone, String userName) { + private Long findMember(String mobilePhone, String userName) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("mobile", mobilePhone) .or().eq("username", userName); - return this.baseMapper.selectList(queryWrapper); + return this.baseMapper.selectCount(queryWrapper); } /** @@ -593,9 +592,8 @@ public class MemberServiceImpl extends ServiceImpl impleme * @param mobilePhone 手机号 */ private void checkMember(String userName, String mobilePhone) { - List members = findMember(userName, mobilePhone); //判断手机号是否存在 - if (members != null && !members.isEmpty()) { + if (findMember(userName, mobilePhone) > 0) { throw new ServiceException(ResultCode.USER_EXIST); } } 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/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/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..dfb0bbd0 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 @@ -30,7 +30,6 @@ import java.util.List; * @since 2020/11/17 7:36 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class OrderPriceServiceImpl implements OrderPriceService { /** 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 206cfc32..e51286fb 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); 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 bcb8df53..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 { /** diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index da858217..02ba472f 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -1 +1 @@ -package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional(rollbackFor = Exception.class) public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId() ,ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file +package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId() ,ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/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/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 f1b92e8c..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; diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java index 3040aaea..2a9e2e89 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java @@ -17,7 +17,6 @@ import java.util.List; * @since 2020/11/22 12:08 */ @Service -@Transactional(rollbackFor = Exception.class) public class DepartmentRoleServiceImpl 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 1ea47de8..c397e9f1 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 @@ -34,7 +34,6 @@ import java.util.stream.Collectors; * @since 2020/11/17 3:45 下午 */ @Service -@Transactional(rollbackFor = Exception.class) public class SystemLogServiceImpl implements SystemLogService { @Autowired 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/serviceimpl/AbstractPromotionsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java index 768cf01a..d10f8579 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 @@ -31,7 +31,6 @@ import java.util.*; * @author paulG * @since 2021/11/30 **/ -@Transactional(rollbackFor = Exception.class) public abstract class AbstractPromotionsServiceImpl, T extends BasePromotions> extends ServiceImpl implements AbstractPromotionsService { /** 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 7a2f3d90..e8c494d9 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 @@ -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 { /** diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java index dce86bca..42001ee1 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java @@ -33,7 +33,6 @@ import java.util.List; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl implements FullDiscountService { /** 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 9a2f4d8f..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 @@ -43,7 +43,6 @@ import java.util.List; * @since 2021/7/1 */ @Service -@Transactional(rollbackFor = Exception.class) public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImpl implements KanjiaActivityGoodsService { /** 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 21c4a344..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 @@ -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 828bf7d0..6766b2e8 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 @@ -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 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 0c851736..5f23153b 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 @@ -40,7 +40,6 @@ import java.util.*; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) @CacheConfig(cacheNames = "{MemberCoupon}") public class MemberCouponServiceImpl extends ServiceImpl implements MemberCouponService { 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 dbec57fa..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 @@ -47,7 +47,6 @@ import java.util.List; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) public class PintuanServiceImpl extends AbstractPromotionsServiceImpl implements PintuanService { /** diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsCategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsCategoryServiceImpl.java index 9a873fc6..79b8c06a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsCategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsCategoryServiceImpl.java @@ -21,7 +21,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2020/8/21 **/ @Service -@Transactional(rollbackFor = Exception.class) public class PointsGoodsCategoryServiceImpl extends ServiceImpl 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 de4af0d3..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 { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index e8b4c976..4f0db3d1 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -41,7 +41,6 @@ import java.util.List; * @since 2021/3/18 9:22 上午 */ @Service -@Transactional(rollbackFor = Exception.class) public class PromotionGoodsServiceImpl extends ServiceImpl 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 2afd8593..2596a8e5 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 @@ -27,7 +27,6 @@ import java.util.Map; */ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) public class PromotionServiceImpl implements PromotionService { /** * 秒杀 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 c8df9dbb..ed8bd3d6 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 @@ -48,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 { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index bf0b00a5..9dd74121 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java @@ -50,7 +50,6 @@ import java.util.Map; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) @Slf4j public class SeckillServiceImpl extends AbstractPromotionsServiceImpl implements SeckillService { 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/serviceimpl/BillServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java index 430d89d2..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 { /** 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 c071f9b2..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 @@ -43,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 { /** 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 0cc64d26..3980be0b 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 @@ -42,7 +42,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/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/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/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/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/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/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..f35000e5 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 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..e8b6fd22 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 @@ -23,7 +23,6 @@ import java.util.List; */ @Slf4j @RestController -@Transactional(rollbackFor = Exception.class) @Api(tags = "日志管理接口") @RequestMapping("/manager/log") public class LogManagerController { 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/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..efc4c3bf 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 @@ -29,7 +29,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; 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/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/settings/LogStoreController.java b/seller-api/src/main/java/cn/lili/controller/settings/LogStoreController.java index e319db0a..e716d110 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 @@ -25,7 +25,6 @@ import java.util.Objects; * @since 2020/11/22 14:23 */ @RestController -@Transactional(rollbackFor = Exception.class) @Api(tags = "店铺端,日志管理接口") @RequestMapping("/store/log") public class LogStoreController { From cf0d1378c8a462e5cd0e433543ba58c3570b6b71 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 18 Jan 2022 11:03:15 +0800 Subject: [PATCH 24/60] =?UTF-8?q?=E5=8E=8B=E6=B5=8B=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/SliderImageController.java | 4 +-- .../lili/controller/common/SmsController.java | 2 +- .../member/serviceimpl/MemberServiceImpl.java | 18 +++++------ .../order/cart/entity/dto/TradeDTO.java | 13 -------- .../order/cart/service/CartServiceImpl.java | 5 ++- .../sms/impl/SmsUtilAliImplService.java | 10 +++--- .../service/impl/VerificationServiceImpl.java | 31 ++++++++++--------- 7 files changed, 35 insertions(+), 48 deletions(-) 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 85e9f653..bb22429f 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 @@ -26,7 +26,7 @@ public class SliderImageController { @Autowired private VerificationService verificationService; -// @LimitPoint(name = "slider_image", key = "verification") + @LimitPoint(name = "slider_image", key = "verification") @GetMapping("/{verificationEnums}") @ApiOperation(value = "获取校验接口,一分钟同一个ip请求10次") public ResultMessage getSliderImage(@RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) { @@ -34,7 +34,7 @@ public class SliderImageController { } -// @LimitPoint(name = "slider_image", key = "verification_pre_check", limit = 600) + @LimitPoint(name = "slider_image", key = "verification_pre_check", limit = 600) @PostMapping("/{verificationEnums}") @ApiOperation(value = "验证码预校验") public ResultMessage verificationImage(Integer xPos, @RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) { diff --git a/common-api/src/main/java/cn/lili/controller/common/SmsController.java b/common-api/src/main/java/cn/lili/controller/common/SmsController.java index 41657ac5..d6f9e506 100644 --- a/common-api/src/main/java/cn/lili/controller/common/SmsController.java +++ b/common-api/src/main/java/cn/lili/controller/common/SmsController.java @@ -30,7 +30,7 @@ public class SmsController { @Autowired private VerificationService verificationService; -// @LimitPoint(name = "sms_send", key = "sms") + @LimitPoint(name = "sms_send", key = "sms") @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "mobile", value = "手机号"), @ApiImplicitParam(paramType = "header", dataType = "String", name = "uuid", value = "uuid"), 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 2ad6d5a8..bc280dcd 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 @@ -134,15 +134,15 @@ public class MemberServiceImpl extends ServiceImpl impleme @Override public Token usernameLogin(String username, String password) { Member member = this.findMember(username); -// //判断用户是否存在 -// if (member == null || !member.getDisabled()) { -// throw new ServiceException(ResultCode.USER_NOT_EXIST); -// } -// //判断密码是否输入正确 -// if (!new BCryptPasswordEncoder().matches(password, member.getPassword())) { -// throw new ServiceException(ResultCode.USER_PASSWORD_ERROR); -// } -// loginBindUser(member); + //判断用户是否存在 + if (member == null || !member.getDisabled()) { + throw new ServiceException(ResultCode.USER_NOT_EXIST); + } + //判断密码是否输入正确 + if (!new BCryptPasswordEncoder().matches(password, member.getPassword())) { + throw new ServiceException(ResultCode.USER_PASSWORD_ERROR); + } + loginBindUser(member); return memberTokenGenerate.createToken(member, false); } 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 14101279..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,19 +106,6 @@ public class TradeDTO implements Serializable { */ private MemberAddress memberAddress; - public MemberAddress getMemberAddress() { - MemberAddress memberAddress = new MemberAddress(); - memberAddress.setId("1376445134773682176"); - memberAddress.setConsigneeAddressIdPath("1401797451706269749,1401797451706270007,1401797451706270104,1401797451706270108"); - memberAddress.setConsigneeAddressPath("河北省,廊坊市,三河市,燕郊镇"); - memberAddress.setAlias("DEFAULT"); - memberAddress.setMobile("13232323232"); - memberAddress.setName("NMNNN"); - memberAddress.setIsDefault(true); - memberAddress.setLat("131.13"); - memberAddress.setLon("131.13"); - return memberAddress; - } /** * 客户端类型 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 07736ea8..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 @@ -215,9 +215,8 @@ public class CartServiceImpl implements CartService { //缓存key,默认使用购物车 if (cartTypeEnum != null) { -// AuthUser currentUser = UserContext.getCurrentUser(); -// return cartTypeEnum.getPrefix() + currentUser.getId(); - return cartTypeEnum.getPrefix() + UserContext.getUuid(); + AuthUser currentUser = UserContext.getCurrentUser(); + return cartTypeEnum.getPrefix() + currentUser.getId(); } throw new ServiceException(ResultCode.ERROR); } diff --git a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java index 7b12692e..19e999b9 100644 --- a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java @@ -132,14 +132,14 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { @Override public boolean verifyCode(String mobile, VerificationEnums verificationEnums, String uuid, String code) { -// Object result = cache.get(cacheKey(verificationEnums, mobile, uuid)); -// if (code.equals(result)) { + Object result = cache.get(cacheKey(verificationEnums, mobile, uuid)); + if (code.equals(result)) { //校验之后,删除 cache.remove(cacheKey(verificationEnums, mobile, uuid)); return true; -// } else { -// return false; -// } + } else { + return false; + } } 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 284426df..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; @@ -132,19 +134,18 @@ public class VerificationServiceImpl implements VerificationService { */ @Override public boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums) { -// Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid)); -// if (randomX == null) { -// throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); -// } -// log.debug("{}{}", randomX, xPos); -// //验证结果正确 && 删除标记成功 -// if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) { - //验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致 - cache.remove(cacheKey(verificationEnums, uuid)); - cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime()); - return true; -// } -// throw new ServiceException(ResultCode.VERIFICATION_ERROR); + Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid)); + if (randomX == null) { + throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); + } + log.debug("{}{}", randomX, xPos); + //验证结果正确 && 删除标记成功 + if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) { + //验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致 + cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime()); + return true; + } + throw new ServiceException(ResultCode.VERIFICATION_ERROR); } /** @@ -160,8 +161,7 @@ public class VerificationServiceImpl implements VerificationService { if (cache.remove(cacheResult(verificationEnums, uuid))) { return true; } -// throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); - return true; + throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); } /** @@ -187,3 +187,4 @@ public class VerificationServiceImpl implements VerificationService { } } + From ca1851570b9039cf9d937146702ed0afbfa8172c Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 19 Jan 2022 10:02:22 +0800 Subject: [PATCH 25/60] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BB=A3=E7=A0=81=EF=BC=8C=E8=BF=99=E9=87=8C?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E8=A7=84=E8=8C=83=E9=97=AE=E9=A2=98=E6=97=A5?= =?UTF-8?q?=E5=90=8E=E4=B8=8E=E5=89=8D=E7=AB=AF=E4=B8=80=E8=B5=B7=E5=8D=8F?= =?UTF-8?q?=E8=B0=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/controller/order/CartController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 884547e2..c2a4508a 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 @@ -236,8 +236,8 @@ public class CartController { @ApiOperation(value = "创建交易") - @PostMapping(value = "/create/trade") - public ResultMessage crateTrade(TradeParams tradeParams) { + @PostMapping(value = "/create/trade", consumes = "application/json", produces = "application/json") + public ResultMessage crateTrade(@RequestBody TradeParams tradeParams) { try { //读取选中的列表 return ResultUtil.data(this.cartService.createTrade(tradeParams)); From 68ef46195c67cede48e345db10cbf315f2a119da Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 19 Jan 2022 10:16:15 +0800 Subject: [PATCH 26/60] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=8C=85=E7=89=88=E6=9C=AC=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/pom.xml | 41 +++++++++++++++++++++++++++++++++++++++++ pom.xml | 16 ++++++++-------- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/framework/pom.xml b/framework/pom.xml index 952d1c71..7b6af4cb 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 @@ -161,6 +166,12 @@ com.aliyun dysmsapi20170525 ${aliyun-sdk-dysms-version} + + + org.jacoco.agent + org.jacoco + + @@ -172,6 +183,12 @@ org.apache.rocketmq rocketmq-spring-boot-starter ${rocketmq-version} + + + fastjson + com.alibaba + + @@ -220,6 +237,10 @@ groovy org.codehaus.groovy + + commons-collections4 + org.apache.commons + @@ -248,6 +269,20 @@ com.alipay.sdk alipay-sdk-java ${alipay-sdk-version} + + + bcprov-jdk15on + org.bouncycastle + + + commons-logging + commons-logging + + + xml-apis + xml-apis + + @@ -314,6 +349,12 @@ com.googlecode.owasp-java-html-sanitizer owasp-java-html-sanitizer ${owasp-java-html-sanitizer} + + + guava + com.google.guava + + diff --git a/pom.xml b/pom.xml index ba666989..30e18428 100644 --- a/pom.xml +++ b/pom.xml @@ -21,18 +21,18 @@ 4.2.3 registry.cn-beijing.aliyuncs.com/lili-images 1 - 4.13.40.ALL - 5.1.48 + 4.22.17.ALL + 8.0.27 3.4.3.4 - 5.7.16 + 5.7.18 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 + 2.0.8 + 2.2.1 0.10.7 4.7.2 4.0.0 @@ -48,12 +48,12 @@ 2.3.1 1.21 1.2 - 4.1.2 - 4.1.2 + 5.1.0 + 5.1.0 6.6 3.4.1 1.7.28 - 2.2.0 + 3.2.3 1.4 4.3 2.3.0 From 90185d8c32f75287785a4a2da00d88bec1511144 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 19 Jan 2022 10:18:33 +0800 Subject: [PATCH 27/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=97=B6=E7=9A=84=E7=94=9F=E6=88=90=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=92=8C=E6=93=8D=E4=BD=9C=E4=BF=83=E9=94=80=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E6=9B=B4=E6=96=B0=E7=B4=A2=E5=BC=95=E4=BF=83?= =?UTF-8?q?=E9=94=80=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E7=9B=91=E5=90=AC=E5=9C=A8=E4=BA=8B=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=90=8E=E5=8F=91=E9=80=81mq=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/GeneratorEsGoodsIndexEvent.java | 19 +++++++++ .../GeneratorEsGoodsIndexListener.java | 38 +++++++++++++++++ .../serviceimpl/GoodsSkuServiceImpl.java | 12 +++--- .../UpdateEsGoodsIndexPromotionsEvent.java | 19 +++++++++ .../UpdateEsGoodsIndexPromotionsListener.java | 41 +++++++++++++++++++ .../AbstractPromotionsServiceImpl.java | 11 ++--- .../CouponActivityItemServiceImpl.java | 2 + .../CouponActivityServiceImpl.java | 5 ++- .../serviceimpl/CouponServiceImpl.java | 7 +++- .../serviceimpl/FullDiscountServiceImpl.java | 2 +- .../serviceimpl/SeckillApplyServiceImpl.java | 1 + .../serviceimpl/SeckillServiceImpl.java | 16 +------- 12 files changed, 144 insertions(+), 29 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java create mode 100644 framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java create mode 100644 framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java 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/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index fe4cec56..1b3e475d 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 @@ -22,6 +22,7 @@ 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; @@ -48,10 +49,9 @@ 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; -import org.springframework.transaction.event.TransactionPhase; -import org.springframework.transaction.event.TransactionalEventListener; import java.util.*; import java.util.stream.Collectors; @@ -110,6 +110,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Autowired private PromotionGoodsService promotionGoodsService; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + @Override public void add(List> skuList, Goods goods) { // 检查是否需要生成索引 @@ -544,15 +547,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param goods 商品信息 */ @Override - @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void generateEs(Goods goods) { // 不生成没有审核通过且没有上架的商品 if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { return; } - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback()); + applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品索引事件", goods.getId())); } /** 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..06b20cab --- /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) + 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/serviceimpl/AbstractPromotionsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java index 768cf01a..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 @@ -10,6 +10,7 @@ import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.search.BasePromotionsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; +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.*; @@ -31,7 +33,6 @@ import java.util.*; * @author paulG * @since 2021/11/30 **/ -@Transactional(rollbackFor = Exception.class) public abstract class AbstractPromotionsServiceImpl, T extends BasePromotions> extends ServiceImpl implements AbstractPromotionsService { /** @@ -52,6 +53,9 @@ public abstract class AbstractPromotionsServiceImpl, T e @Autowired private RocketMQTemplate rocketMQTemplate; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + /** * 通用促销保存 * 调用顺序: @@ -264,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 c413e6a4..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; @@ -140,6 +141,7 @@ 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 7a2f3d90..2c2715e8 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 @@ -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,6 +224,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl implements FullDiscountService { /** @@ -110,6 +109,7 @@ public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl seckillApplyList) { Seckill seckill = this.seckillService.getById(seckillId); if (seckill == null) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index bf0b00a5..66142a56 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java @@ -39,9 +39,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * 秒杀活动业务层实现 @@ -154,19 +152,7 @@ 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()); + this.updateEsGoodsIndex(seckill); } } } From ab1e9f806f5066e0e5ef4195ee72af9d302d4e60 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 19 Jan 2022 14:16:02 +0800 Subject: [PATCH 28/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=97=B6=E7=9A=84=E7=94=9F=E6=88=90=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=92=8C=E6=93=8D=E4=BD=9C=E4=BF=83=E9=94=80=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E6=9B=B4=E6=96=B0=E7=B4=A2=E5=BC=95=E4=BF=83?= =?UTF-8?q?=E9=94=80=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E7=9B=91=E5=90=AC=E5=9C=A8=E4=BA=8B=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=90=8E=E5=8F=91=E9=80=81mq=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/src/main/java/cn/lili/common/utils/SnowFlake.java | 1 - .../cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java | 1 + .../lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 4 +++- .../listener/UpdateEsGoodsIndexPromotionsListener.java | 2 +- .../lili/modules/promotion/serviceimpl/CouponServiceImpl.java | 1 - 5 files changed, 5 insertions(+), 4 deletions(-) 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 18379ea7..e3cb3d70 100644 --- a/framework/src/main/java/cn/lili/common/utils/SnowFlake.java +++ b/framework/src/main/java/cn/lili/common/utils/SnowFlake.java @@ -33,7 +33,6 @@ public class SnowFlake { */ public static void initialize(long workerId, long datacenterId) { snowflake = IdUtil.getSnowflake(workerId, datacenterId); - log.error(workerId+""+datacenterId); } public static long getId() { 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 90ebd4c4..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 @@ -383,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); 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 cce00a75..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 @@ -131,6 +131,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void update(List> skuList, Goods goods, Boolean regeneratorSkuFlag) { // 是否存在规格 if (skuList == null || skuList.isEmpty()) { @@ -577,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); 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 index 06b20cab..00417c5f 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java +++ b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java @@ -29,7 +29,7 @@ public class UpdateEsGoodsIndexPromotionsListener { private RocketmqCustomProperties rocketmqCustomProperties; - @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void updateEsGoodsIndexPromotions(UpdateEsGoodsIndexPromotionsEvent event) { //更新商品促销消息 String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name(); 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 2c2715e8..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 @@ -249,7 +249,6 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl Date: Thu, 20 Jan 2022 09:27:07 +0800 Subject: [PATCH 29/60] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kit/plugin/wechat/WechatPlugin.java | 10 ------- .../dto/payment/WechatPaymentSetting.java | 27 ++++++++++++++++++- 2 files changed, 26 insertions(+), 11 deletions(-) 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..e4145c41 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 @@ -258,9 +258,6 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -326,9 +323,6 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getServiceAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -397,10 +391,6 @@ public class WechatPlugin implements Payment { //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法 //如果有2开需求,这里需要调整,修改这个appid的获取途径即可 String appid = wechatPaymentSetting().getMpAppId(); - if (appid == null) { - 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/system/entity/dto/payment/WechatPaymentSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java index 9dc4a73d..b3d8e9f9 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 @@ -1,5 +1,8 @@ package cn.lili.modules.system.entity.dto.payment; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; +import com.alibaba.druid.util.StringUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -14,7 +17,7 @@ import lombok.experimental.Accessors; public class WechatPaymentSetting { /** - * APP应用id + * APP应用id */ private String appId; /** @@ -49,4 +52,26 @@ public class WechatPaymentSetting { * apiv3私钥 */ private String apiKey3; + + public String getAppId() { + + if (StringUtils.isEmpty(appId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return appId; + } + + public String getMpAppId() { + if (StringUtils.isEmpty(mpAppId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return mpAppId; + } + + public String getServiceAppId() { + if (StringUtils.isEmpty(serviceAppId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return serviceAppId; + } } From 4fb170e5c7d7cbea162bb5757180bab249876ee9 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 20 Jan 2022 11:01:24 +0800 Subject: [PATCH 30/60] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=BB=93=E6=9E=9C=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/payment/kit/plugin/alipay/AliPayPlugin.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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..95381545 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,10 @@ 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"))) { + return; + } String payParamStr = map.get("passback_params"); String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8); PayParam payParam = BeanUtil.formatKeyValuePair(payParamJson, new PayParam()); From 007d69a887fd9db1137f224d1a16876a0fb6164b Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 20 Jan 2022 15:59:26 +0800 Subject: [PATCH 31/60] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 95381545..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 @@ -293,8 +293,9 @@ 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"))) { + //支付完成判定 + if (!"TRADE_FINISHED".equals(map.get("trade_status")) && + !"TRADE_SUCCESS".equals(map.get("trade_status"))) { return; } String payParamStr = map.get("passback_params"); From 2d1cfde76b8f020097f0f6de1610106eeec7292b Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 20 Jan 2022 16:19:52 +0800 Subject: [PATCH 32/60] =?UTF-8?q?=E4=BC=98=E5=8C=96consumer=E5=BB=B6?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C=E5=99=A8=EF=BC=88?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E9=AB=98=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=9A=84redis=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4redis?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E4=B8=8D=E4=B8=8A=E9=97=AE=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/trigger/AbstractDelayQueueListen.java | 5 ++--- .../cn/lili/trigger/listen/PromotionDelayQueueListen.java | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) 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(); + } } From 96e779eb28feb50200aa7e55a0461ebd6a72ff5f Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 12:07:16 +0800 Subject: [PATCH 33/60] =?UTF-8?q?=E5=AF=B9=E4=BA=A4=E6=98=93=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=9A=84=E5=88=A4=E5=AE=9A=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/order/order/entity/dos/Trade.java | 2 ++ .../modules/order/order/serviceimpl/OrderServiceImpl.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index e51286fb..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 @@ -642,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(); From 7164036d4cf13886e6aa98a5ac06135643b6c7bb Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 14:34:05 +0800 Subject: [PATCH 34/60] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E6=97=B6=EF=BC=8C=E8=AE=A2=E5=8D=95update=20?= =?UTF-8?q?price=E5=AD=97=E6=AE=B5=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/common/utils/CurrencyUtil.java | 4 ++-- .../lili/modules/order/order/entity/dto/PriceDetailDTO.java | 2 +- .../order/order/serviceimpl/OrderPriceServiceImpl.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) 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 6b1b9aa2..aa030d6e 100644 --- a/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java @@ -36,9 +36,9 @@ public final class CurrencyUtil { return result.doubleValue(); } /** - * 提供精确的加法运算。 + * 提供精确的减法运算。 * - * @return 累加之和 + * @return 第一个参数为被减数,其余数字为减数 */ public static Double sub(double... params) { BigDecimal result = BigDecimal.valueOf(params[0]); 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 dcc9ce66..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 @@ -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/serviceimpl/OrderPriceServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java index dfb0bbd0..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,6 +30,7 @@ import java.util.List; * @author Chopper * @since 2020/11/17 7:36 下午 */ +@Slf4j @Service public class OrderPriceServiceImpl implements OrderPriceService { @@ -106,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); //修改子订单 From 5051fc7b0be6db94e476d38ced132ba53ef98881 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 15:39:18 +0800 Subject: [PATCH 35/60] =?UTF-8?q?=E8=B5=A0=E5=93=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=A0=B8=E9=94=80=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/FullDiscountExecute.java | 71 +++++++++++++++---- .../order/entity/enums/OrderTypeEnum.java | 7 +- 2 files changed, 62 insertions(+), 16 deletions(-) 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 a1bb9847..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; /** * 订单状态处理类 @@ -90,6 +92,7 @@ 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(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/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, } From a65f0ad38405fada1534a8c909f854246548b905 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 16:18:16 +0800 Subject: [PATCH 36/60] =?UTF-8?q?=E7=A7=AF=E5=88=86=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/MemberPointExecute.java | 10 +++-- .../system/entity/dto/PointSetting.java | 38 ++++++++++++++++++- .../system/entity/dto/PointSettingItem.java | 11 ++++++ 3 files changed, 55 insertions(+), 4 deletions(-) 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/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(); From 145406be32d0b0d5b970976dca3b388c9fe4c7c0 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 16:31:06 +0800 Subject: [PATCH 37/60] =?UTF-8?q?=E5=AF=B9=E5=95=86=E5=93=81=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=8C=85=E5=90=AB=E9=80=97=E5=8F=B7=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/goods/entity/dto/GoodsOperationDTO.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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(",", ""); + } } From 576b5b213e5474449dd0f16a47900f9fa5244bdf Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 17:00:10 +0800 Subject: [PATCH 38/60] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 27e82423f0ee0a0693a462dac731a0532c29edaa Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 21 Jan 2022 19:00:20 +0800 Subject: [PATCH 39/60] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=EF=BC=8C=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E4=B8=BA=E8=84=B1=E6=95=8F=E5=90=8E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/event/impl/MemberExecute.java | 2 +- .../modules/member/service/MemberService.java | 8 ++++++++ .../member/serviceimpl/MemberServiceImpl.java | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java b/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java index 5411002f..57e4c2fb 100644 --- a/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java @@ -20,6 +20,6 @@ public class MemberExecute implements MemberLoginEvent { @Override public void memberLogin(Member member) { - memberService.updateById(member); + memberService.updateMemberLoginTime(member.getId()); } } 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 a93c18ad..e83b670f 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 @@ -227,4 +227,12 @@ public interface MemberService extends IService { * @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/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index bc280dcd..52bd1052 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 @@ -50,8 +50,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; @@ -595,6 +595,20 @@ public class MemberServiceImpl extends ServiceImpl impleme 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); + } + /** * 检测会员 * From d5fdc47936f871db9cff11cefef341c4429ff9cc Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 21 Jan 2022 19:01:02 +0800 Subject: [PATCH 40/60] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BF=83=E9=94=80?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E8=8E=B7=E5=8F=96=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E4=BC=98=E6=83=A0=E5=88=B8=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/BasePromotionsSearchParams.java | 20 +++++---- .../entity/dto/search/CouponSearchParams.java | 42 ++++++++++--------- .../dto/search/MemberCouponSearchParams.java | 9 ++-- .../java/cn/lili/ManagerApiApplication.java | 3 +- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java index b07aea26..0131aa3e 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java @@ -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/dto/search/CouponSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java index f71a198c..eddecde6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java @@ -60,7 +60,7 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se @Override public QueryWrapper queryWrapper() { - QueryWrapper queryWrapper = super.queryWrapper(); + QueryWrapper queryWrapper = super.baseQueryWrapper(); if (CharSequenceUtil.isNotEmpty(couponName)) { queryWrapper.like("coupon_name", couponName); } @@ -80,24 +80,27 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se queryWrapper.eq("get_type", CouponGetEnum.valueOf(getType).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())); @@ -105,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; 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 index f666646c..02f1b8f0 100644 --- 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 @@ -1,8 +1,10 @@ package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; -import cn.lili.modules.promotion.entity.enums.*; -import cn.lili.modules.promotion.tools.PromotionTools; +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; @@ -78,9 +80,6 @@ public class MemberCouponSearchParams extends BasePromotionsSearchParams impleme if (CharSequenceUtil.isNotEmpty(memberCouponStatus)) { queryWrapper.eq("member_coupon_status", MemberCouponStatusEnum.valueOf(memberCouponStatus).name()); } - if (CharSequenceUtil.isNotEmpty(this.getPromotionStatus())) { - queryWrapper.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(getPromotionStatus()))); - } if (CharSequenceUtil.isNotEmpty(price)) { String[] s = price.split("_"); if (s.length > 1) { 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) { From 696bfe0a2cd414e4eec05eb53e41a140e173657e Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 21 Jan 2022 19:03:43 +0800 Subject: [PATCH 41/60] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=B8=8D=E8=84=B1=E6=95=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/common/security/sensitive/SensitiveJsonSerializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } //如果是店铺 From 286214d9c30c1271d99786eae77267a530abe9aa Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 24 Jan 2022 16:50:42 +0800 Subject: [PATCH 42/60] =?UTF-8?q?=E5=BE=AE=E4=BF=A1APP=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=AD=BE=E5=90=8D=E9=97=AE=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=EF=BC=8C=E6=8F=90=E4=BE=9B=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=EF=BC=8C=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E6=97=A0=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/kit/core/kit/WxPayKit.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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; } From 23ddca6f82bd3ced7761458d3c787ab3819128ef Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 24 Jan 2022 17:30:52 +0800 Subject: [PATCH 43/60] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=E3=80=82?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=99=E5=9D=97=E9=80=BB=E8=BE=91=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/version4.2.3toMASTER.sql | 8 ++++++++ .../serviceimpl/MemberSignServiceImpl.java | 19 +++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) 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/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); } From 936397c59f884e3975540f72281641bd7c19db0d Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 24 Jan 2022 18:11:10 +0800 Subject: [PATCH 44/60] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A5=BD=E8=AF=84?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E4=B8=80=E4=B8=AA=E5=85=A8=E7=BA=BF=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/member/MemberEvaluationBuyerController.java | 2 +- .../handler/impl/order/OrderEveryDayTaskExecute.java | 2 +- .../modules/member/service/MemberEvaluationService.java | 3 ++- .../member/serviceimpl/MemberEvaluationServiceImpl.java | 6 ++++-- 4 files changed, 8 insertions(+), 5 deletions(-) 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..16b5be8a 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 @@ -40,7 +40,7 @@ public class MemberEvaluationBuyerController { @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/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/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java index 1b600ce9..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查询会员评价 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 4b6e1d91..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 @@ -106,13 +106,15 @@ public class MemberEvaluationServiceImpl extends ServiceImpl Date: Mon, 24 Jan 2022 11:30:35 +0000 Subject: [PATCH 45/60] update config/application.yml. --- config/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.yml b/config/application.yml index 0753c11f..f18e5ee9 100644 --- a/config/application.yml +++ b/config/application.yml @@ -183,7 +183,7 @@ mybatis-plus: logging: # 输出级别 level: - root: error + root: info # org.hibernate: debug # org.springframework: debug # org.springframework.data.mongodb.core: debug From 3972e0231ca0da754f935530336d9f19ce1fb9ac Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 25 Jan 2022 10:22:45 +0800 Subject: [PATCH 46/60] =?UTF-8?q?api=E7=AB=AF=E9=98=B2=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DistributionCashBuyerController.java | 2 + .../DistributionGoodsBuyerController.java | 2 + .../MemberEvaluationBuyerController.java | 2 + .../member/MemberSignBuyerController.java | 3 + .../order/AfterSaleBuyerController.java | 3 + .../lili/controller/order/CartController.java | 2 + .../order/OrderBuyerController.java | 5 ++ .../order/OrderComplaintBuyerController.java | 3 + .../order/ReceiptBuyerController.java | 2 + .../order/RechargeTradeBuyerController.java | 2 + .../other/FeedbackBuyerController.java | 2 + .../purchase/PurchaseBuyerController.java | 4 ++ .../wallet/MemberReceiptController.java | 2 + .../wallet/MemberWalletBuyerController.java | 2 + .../common/SliderImageController.java | 1 + .../limit/interceptor/LimitInterceptor.java | 30 ++------- .../lili/common/aop/annotation/DemoSite.java | 2 + .../PreventDuplicateSubmissions.java | 25 +++++++ ...reventDuplicateSubmissionsInterceptor.java | 67 +++++++++++++++++++ .../DistributionCashManagerController.java | 2 + .../DistributionManagerController.java | 4 ++ .../goods/GoodsManagerController.java | 4 ++ .../MemberAddressManagerController.java | 3 + .../MemberEvaluationManagerController.java | 3 + .../member/MemberManagerController.java | 7 +- .../order/AfterSaleManagerController.java | 2 + .../OrderComplaintManagerController.java | 3 + .../order/OrderManagerController.java | 5 ++ .../IndexStatisticsManagerController.java | 2 + .../MemberWithdrawApplyManagerController.java | 2 + .../order/AfterSaleStoreController.java | 3 + .../order/OrderComplaintStoreController.java | 3 + .../order/OrderStoreController.java | 5 ++ 33 files changed, 181 insertions(+), 28 deletions(-) create mode 100644 framework/src/main/java/cn/lili/common/aop/annotation/PreventDuplicateSubmissions.java create mode 100644 framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java 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 ceaef297..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; @@ -49,6 +50,7 @@ public class DistributionCashBuyerController { private DistributionCashService distributorCashService; + @PreventDuplicateSubmissions @ApiOperation(value = "分销员提现") @ApiImplicitParams({ @ApiImplicitParam(name = "price", value = "申请金额", required = true, paramType = "query", dataType = "double") 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 16b5be8a..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,6 +38,7 @@ public class MemberEvaluationBuyerController { @Autowired private MemberEvaluationService memberEvaluationService; + @PreventDuplicateSubmissions @ApiOperation(value = "添加会员评价") @PostMapping public ResultMessage save(@Valid MemberEvaluationDTO memberEvaluationDTO) { 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 6071e61b..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; @@ -31,6 +32,7 @@ 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/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 59d8a579..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,6 +121,7 @@ public class MemberWalletBuyerController { } + @PreventDuplicateSubmissions @PostMapping(value = "/withdrawal") @ApiOperation(value = "会员中心余额提现") @ApiImplicitParams({ 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/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/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/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/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/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/wallet/MemberWithdrawApplyManagerController.java b/manager-api/src/main/java/cn/lili/controller/wallet/MemberWithdrawApplyManagerController.java index efc4c3bf..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; @@ -43,6 +44,7 @@ public class MemberWithdrawApplyManagerController { } + @PreventDuplicateSubmissions @ApiOperation(value = "提现申请审核") @PostMapping @ApiImplicitParams({ 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"), From 64f2f4668ba206463def67988e1790af486e5ba1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 26 Jan 2022 17:54:09 +0800 Subject: [PATCH 47/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/serviceimpl/TradeServiceImpl.java | 2 +- .../service/KanjiaActivityService.java | 7 ++++ .../KanjiaActivityServiceImpl.java | 14 ++++++- .../cn/lili/test/promotion/SeckillTest.java | 37 +++++++++++-------- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index 02ba472f..38980e9c 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -1 +1 @@ -package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId() ,ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint().longValue(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.update(new LambdaUpdateWrapper() .eq(KanjiaActivity::getId, kanjiaId) .set(KanjiaActivity::getStatus, KanJiaStatusEnum.END.name())); } } } \ No newline at end of file +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/promotion/service/KanjiaActivityService.java b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityService.java index 4d653290..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 @@ -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/serviceimpl/KanjiaActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java index 6766b2e8..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 @@ -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; @@ -220,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/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..97df9614 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,23 @@ 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); + Seckill seckill = new Seckill(SeckillService.PRE_CREATION, seckillSetting.getHours(), seckillSetting.getSeckillRule()); + System.out.println(seckill); + boolean result = seckillService.savePromotions(seckill); + System.out.println(result); + Assertions.assertTrue(result); } @Test From 346550182f671cc6e257cce3691c55548a38a03d Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 27 Jan 2022 11:12:24 +0800 Subject: [PATCH 48/60] =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=9B=B8=E5=85=B3=E8=BF=98=E5=8E=9F=EF=BC=8C?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E7=9A=84=E4=BF=AE=E6=94=B9=E4=BC=9A=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=94=AF=E4=BB=98=E6=97=A0=E6=B3=95=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/entity/enums/TradeStatusEnum.java | 40 +++++++++++++++++++ .../kit/plugin/wechat/WechatPlugin.java | 10 ++++- .../dto/payment/WechatPaymentSetting.java | 6 +-- 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/order/order/entity/enums/TradeStatusEnum.java 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..6d9f4906 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/TradeStatusEnum.java @@ -0,0 +1,40 @@ +package cn.lili.modules.order.order.entity.enums; + +/** + * 订单状态枚举 + * + * @author Chopper + * @since 2020/11/17 7:27 下午 + */ +public enum OrderStatusEnum { + + /** + * 订单状态 + */ + UNPAID("未付款"), + PAID("已付款"), + UNDELIVERED("待发货"), + DELIVERED("已发货"), + COMPLETED("已完成"), + /** + * 虚拟订单需要核验商品 + */ + TAKE("待核验"), + CANCELLED("已取消"); + + private final String description; + + OrderStatusEnum(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/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index e4145c41..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; @@ -258,6 +257,9 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getAppId(); + if (appid == null) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -323,6 +325,9 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getServiceAppId(); + if (appid == null) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -391,6 +396,9 @@ public class WechatPlugin implements Payment { //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法 //如果有2开需求,这里需要调整,修改这个appid的获取途径即可 String appid = wechatPaymentSetting().getMpAppId(); + 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/system/entity/dto/payment/WechatPaymentSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java index b3d8e9f9..6e477acc 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 @@ -53,7 +53,7 @@ public class WechatPaymentSetting { */ private String apiKey3; - public String getAppId() { + public String getAppIdValue() { if (StringUtils.isEmpty(appId)) { throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); @@ -61,14 +61,14 @@ public class WechatPaymentSetting { return appId; } - public String getMpAppId() { + public String getMpAppIdValue() { if (StringUtils.isEmpty(mpAppId)) { throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); } return mpAppId; } - public String getServiceAppId() { + public String getServiceAppIdValue() { if (StringUtils.isEmpty(serviceAppId)) { throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); } From 0c383ac7e96e7cfbe54dc53a7d4789394513189a Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 27 Jan 2022 11:20:25 +0800 Subject: [PATCH 49/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=99=90=E6=97=B6=E6=8A=A2=E8=B4=AD=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/impl/promotion/PromotionEverydayExecute.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); + } } } From 40e16c4d1b021027af7406a26736e8159e211393 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 27 Jan 2022 11:22:22 +0800 Subject: [PATCH 50/60] =?UTF-8?q?=E7=B1=BB=E5=90=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/entity/enums/TradeStatusEnum.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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 index 6d9f4906..5e4e8fdb 100644 --- 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 @@ -1,30 +1,23 @@ package cn.lili.modules.order.order.entity.enums; /** - * 订单状态枚举 + * 交易状态枚举 * * @author Chopper * @since 2020/11/17 7:27 下午 */ -public enum OrderStatusEnum { +public enum TradeStatusEnum { /** - * 订单状态 + * 交易状态 */ UNPAID("未付款"), PAID("已付款"), - UNDELIVERED("待发货"), - DELIVERED("已发货"), - COMPLETED("已完成"), - /** - * 虚拟订单需要核验商品 - */ - TAKE("待核验"), CANCELLED("已取消"); private final String description; - OrderStatusEnum(String description) { + TradeStatusEnum(String description) { this.description = description; } From 77e526c22ff30354fdc127d08d6d69499e0b78c3 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 27 Jan 2022 11:26:17 +0800 Subject: [PATCH 51/60] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=85=8D=E7=BD=AE=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/payment/WechatPaymentSetting.java | 25 ------------------- 1 file changed, 25 deletions(-) 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 6e477acc..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 @@ -1,8 +1,5 @@ package cn.lili.modules.system.entity.dto.payment; -import cn.lili.common.enums.ResultCode; -import cn.lili.common.exception.ServiceException; -import com.alibaba.druid.util.StringUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -52,26 +49,4 @@ public class WechatPaymentSetting { * apiv3私钥 */ private String apiKey3; - - public String getAppIdValue() { - - if (StringUtils.isEmpty(appId)) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } - return appId; - } - - public String getMpAppIdValue() { - if (StringUtils.isEmpty(mpAppId)) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } - return mpAppId; - } - - public String getServiceAppIdValue() { - if (StringUtils.isEmpty(serviceAppId)) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } - return serviceAppId; - } } From f375a9f9dbe754e6bb69d10ee182c5bc776f0a27 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 28 Jan 2022 16:13:56 +0800 Subject: [PATCH 52/60] =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=89=A3=E5=87=8F?= =?UTF-8?q?=E5=89=8D=EF=BC=8C=E5=BA=93=E5=AD=98=E5=88=A4=E5=AE=9A=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E9=97=AE=E9=A2=98=EF=BC=8C=E8=BF=9B=E8=A1=8C=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/event/impl/StockUpdateExecute.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 ec18b31f..eb8ed3d7 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -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()); } /** From 64dbe6708ac1c751d47a4b2dc1e2370968e2f07c Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 8 Feb 2022 16:11:27 +0800 Subject: [PATCH 53/60] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=A8=A1=E7=89=88?= =?UTF-8?q?=E6=BC=94=E7=A4=BA=E7=AB=99=E7=82=B9=E6=93=8D=E4=BD=9C=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/SmsTemplateManagerController.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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(); From a4ee4df71bc5320a8400b2794ff07d995cc875e3 Mon Sep 17 00:00:00 2001 From: zhenghao <1321288662@qq.com> Date: Wed, 9 Feb 2022 12:56:38 +0800 Subject: [PATCH 54/60] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=A2=84=E5=AD=98?= =?UTF-8?q?=E6=AC=BE=E4=BA=8B=E5=8A=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/pom.xml | 6 +++++ .../kit/plugin/wallet/WalletPlugin.java | 22 +++++++++++++++---- pom.xml | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/framework/pom.xml b/framework/pom.xml index 7b6af4cb..5990b777 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -143,6 +143,12 @@ jasypt-spring-boot-starter ${jasypt-version} + + + org.redisson + redisson + ${redisson} + com.aliyun 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..86c31727 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,9 @@ 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.Redisson; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -57,9 +60,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 +118,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/pom.xml b/pom.xml index 30e18428..003e84e7 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,7 @@ 3.0.0 2.9.10 1.18.22 + 3.5.5 4.5.18 3.11.1 2.0.8 From 29e43d299af2a411074ca932e8f64de7e68bf03f Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 9 Feb 2022 16:49:14 +0800 Subject: [PATCH 55/60] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/SystemLogServiceImpl.java | 13 ++++++------- .../controller/setting/LogManagerController.java | 5 ++--- .../controller/settings/LogStoreController.java | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) 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 c397e9f1..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 @@ -22,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; @@ -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; @@ -107,16 +107,15 @@ public class SystemLogServiceImpl implements SystemLogService { nativeSearchQueryBuilder.withFilter(filterBuilder); } - SearchHits searchResult = restTemplate.search(nativeSearchQueryBuilder.build(), SystemLogVO.class); - - iPage.setTotal(searchResult.getTotalHits()); - - if (pageVO != null && CharSequenceUtil.isNotEmpty(pageVO.getOrder()) && CharSequenceUtil.isNotEmpty(pageVO.getSort())) { + 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()); iPage.setRecords(searchResult.getSearchHits().stream().map(SearchHit::getContent).collect(Collectors.toList())); return iPage; 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 e8b6fd22..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; @@ -32,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/seller-api/src/main/java/cn/lili/controller/settings/LogStoreController.java b/seller-api/src/main/java/cn/lili/controller/settings/LogStoreController.java index e716d110..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; From bbe3399c90b489ab85281d99e1b279b25eb1f4d7 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 9 Feb 2022 16:50:37 +0800 Subject: [PATCH 56/60] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/pom.xml | 73 ++++++++++++++++++++++++++++++++++++++++------- pom.xml | 50 +++++++++++++++----------------- 2 files changed, 85 insertions(+), 38 deletions(-) diff --git a/framework/pom.xml b/framework/pom.xml index 7b6af4cb..654b5d3c 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -35,6 +35,12 @@ org.springframework.boot spring-boot-starter-quartz + + + slf4j-api + org.slf4j + + @@ -72,6 +78,10 @@ HdrHistogram org.hdrhistogram + + slf4j-api + org.slf4j + @@ -81,6 +91,12 @@ org.springframework.integration spring-integration-redis + + + slf4j-api + org.slf4j + + org.apache.commons @@ -96,17 +112,17 @@ 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} @@ -119,6 +135,12 @@ com.github.xiaoymin knife4j-spring-boot-starter ${knife4j.version} + + + slf4j-api + org.slf4j + + @@ -148,6 +170,12 @@ com.aliyun aliyun-java-sdk-core ${aliyun-version} + + + slf4j-api + org.slf4j + + @@ -171,6 +199,10 @@ org.jacoco.agent org.jacoco + + bcprov-jdk15on + org.bouncycastle + @@ -188,6 +220,10 @@ fastjson com.alibaba + + slf4j-api + org.slf4j + @@ -212,6 +248,12 @@ org.springframework.boot spring-boot-starter-test + + + slf4j-api + org.slf4j + + @@ -241,6 +283,14 @@ commons-collections4 org.apache.commons + + antlr4-runtime + org.antlr + + + slf4j-api + org.slf4j + @@ -248,6 +298,12 @@ org.apache.shardingsphere sharding-jdbc-spring-namespace ${sharding-jdbc-version} + + + slf4j-api + org.slf4j + + @@ -307,11 +363,6 @@ logstash-logback-encoder ${logstash-logback-encoder} - - - - - de.codecentric spring-boot-admin-starter-client diff --git a/pom.xml b/pom.xml index 30e18428..b5c4d1b5 100644 --- a/pom.xml +++ b/pom.xml @@ -19,42 +19,38 @@ 1.8 4.2.3 - registry.cn-beijing.aliyuncs.com/lili-images - 1 - 4.22.17.ALL - 8.0.27 - 3.4.3.4 - 5.7.18 - 2.0.3.RELEASE - 3.0.0 - 2.9.10 - 1.18.22 - 4.5.18 - 3.11.1 - 2.0.8 - 2.2.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 + 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 5.1.0 5.1.0 - 6.6 + 7.0.1 3.4.1 - 1.7.28 + 1.7.35 3.2.3 - 1.4 + 1.9 4.3 2.3.0 1.2.2 From 9aa7a6dcf361581489636b9b8bd70aea1e860dac Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 10 Feb 2022 11:26:10 +0800 Subject: [PATCH 57/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0redisson=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer-api/src/main/resources/redisson.yaml | 21 +++++++++++++++++++ common-api/src/main/resources/redisson.yaml | 21 +++++++++++++++++++ consumer/src/main/resources/redisson.yaml | 21 +++++++++++++++++++ framework/pom.xml | 13 ++++++------ .../lili/cache/config/redis/RedisConfig.java | 11 ++++++++++ .../common/security/context/UserContext.java | 3 +-- .../member/token/MemberTokenGenerate.java | 5 ++--- .../member/token/StoreTokenGenerate.java | 3 +-- manager-api/src/main/resources/redisson.yaml | 21 +++++++++++++++++++ pom.xml | 2 +- seller-api/src/main/resources/redisson.yaml | 21 +++++++++++++++++++ 11 files changed, 127 insertions(+), 15 deletions(-) create mode 100644 buyer-api/src/main/resources/redisson.yaml create mode 100644 common-api/src/main/resources/redisson.yaml create mode 100644 consumer/src/main/resources/redisson.yaml create mode 100644 manager-api/src/main/resources/redisson.yaml create mode 100644 seller-api/src/main/resources/redisson.yaml diff --git a/buyer-api/src/main/resources/redisson.yaml b/buyer-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..5ac07ec6 --- /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://pg2481.com: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/resources/redisson.yaml b/common-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..5ac07ec6 --- /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://pg2481.com: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/main/resources/redisson.yaml b/consumer/src/main/resources/redisson.yaml new file mode 100644 index 00000000..5ac07ec6 --- /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://pg2481.com: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/framework/pom.xml b/framework/pom.xml index 76eb6a0a..d4c011bb 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -129,7 +129,12 @@ org.springframework.boot spring-boot-starter-data-redis - + + + org.redisson + redisson + ${redisson} + com.github.xiaoymin @@ -165,12 +170,6 @@ jasypt-spring-boot-starter ${jasypt-version} - - - org.redisson - redisson - ${redisson} - com.aliyun 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 f7bf18e5..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; @@ -99,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/common/security/context/UserContext.java b/framework/src/main/java/cn/lili/common/security/context/UserContext.java index 6ecf8ee6..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 @@ -45,8 +45,7 @@ public class UserContext { public static String getUuid() { if (RequestContextHolder.getRequestAttributes() != null) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String uuid = request.getHeader(SecurityEnum.UUID.getValue()); - return uuid; + return request.getHeader(SecurityEnum.UUID.getValue()); } return null; } 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 d903d549..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,15 +1,14 @@ 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; 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 558289df..bb0d70fe 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 @@ -8,7 +8,6 @@ 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.modules.member.entity.dos.Member; -import cn.lili.modules.member.service.MemberService; import cn.lili.modules.store.entity.dos.Store; import cn.lili.modules.store.service.StoreService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -31,7 +30,7 @@ public class StoreTokenGenerate extends AbstractTokenGenerate { @Override public Token createToken(Member member, Boolean longTerm) { - if (!member.getHaveStore()) { + if (Boolean.FALSE.equals(member.getHaveStore())) { throw new ServiceException(ResultCode.STORE_NOT_OPEN); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); diff --git a/manager-api/src/main/resources/redisson.yaml b/manager-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..5ac07ec6 --- /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://pg2481.com: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/pom.xml b/pom.xml index f2978912..4b74886c 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 3.0.4 2.9.10 1.18.22 - 3.5.5 + 3.15.6 4.5.18 3.11.1 2.0.8 diff --git a/seller-api/src/main/resources/redisson.yaml b/seller-api/src/main/resources/redisson.yaml new file mode 100644 index 00000000..5ac07ec6 --- /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://pg2481.com: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 From 6639ec8971790246d48ed331916493f959696bc1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 10 Feb 2022 11:27:20 +0800 Subject: [PATCH 58/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0redisson=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer-api/src/main/resources/redisson.yaml | 2 +- common-api/src/main/resources/redisson.yaml | 2 +- consumer/src/main/resources/redisson.yaml | 2 +- manager-api/src/main/resources/redisson.yaml | 2 +- seller-api/src/main/resources/redisson.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/buyer-api/src/main/resources/redisson.yaml b/buyer-api/src/main/resources/redisson.yaml index 5ac07ec6..ac8dfc66 100644 --- a/buyer-api/src/main/resources/redisson.yaml +++ b/buyer-api/src/main/resources/redisson.yaml @@ -8,7 +8,7 @@ singleServerConfig: password: lilishop subscriptionsPerConnection: 5 clientName: null - address: "redis://pg2481.com:6379" + address: "redis://127.0.0.1:6379" subscriptionConnectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 50 connectionMinimumIdleSize: 24 diff --git a/common-api/src/main/resources/redisson.yaml b/common-api/src/main/resources/redisson.yaml index 5ac07ec6..ac8dfc66 100644 --- a/common-api/src/main/resources/redisson.yaml +++ b/common-api/src/main/resources/redisson.yaml @@ -8,7 +8,7 @@ singleServerConfig: password: lilishop subscriptionsPerConnection: 5 clientName: null - address: "redis://pg2481.com:6379" + address: "redis://127.0.0.1:6379" subscriptionConnectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 50 connectionMinimumIdleSize: 24 diff --git a/consumer/src/main/resources/redisson.yaml b/consumer/src/main/resources/redisson.yaml index 5ac07ec6..ac8dfc66 100644 --- a/consumer/src/main/resources/redisson.yaml +++ b/consumer/src/main/resources/redisson.yaml @@ -8,7 +8,7 @@ singleServerConfig: password: lilishop subscriptionsPerConnection: 5 clientName: null - address: "redis://pg2481.com:6379" + address: "redis://127.0.0.1:6379" subscriptionConnectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 50 connectionMinimumIdleSize: 24 diff --git a/manager-api/src/main/resources/redisson.yaml b/manager-api/src/main/resources/redisson.yaml index 5ac07ec6..ac8dfc66 100644 --- a/manager-api/src/main/resources/redisson.yaml +++ b/manager-api/src/main/resources/redisson.yaml @@ -8,7 +8,7 @@ singleServerConfig: password: lilishop subscriptionsPerConnection: 5 clientName: null - address: "redis://pg2481.com:6379" + address: "redis://127.0.0.1:6379" subscriptionConnectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 50 connectionMinimumIdleSize: 24 diff --git a/seller-api/src/main/resources/redisson.yaml b/seller-api/src/main/resources/redisson.yaml index 5ac07ec6..ac8dfc66 100644 --- a/seller-api/src/main/resources/redisson.yaml +++ b/seller-api/src/main/resources/redisson.yaml @@ -8,7 +8,7 @@ singleServerConfig: password: lilishop subscriptionsPerConnection: 5 clientName: null - address: "redis://pg2481.com:6379" + address: "redis://127.0.0.1:6379" subscriptionConnectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 50 connectionMinimumIdleSize: 24 From acb88a6b2a5ca56e0de457ab141053eab865f9c2 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 11 Feb 2022 14:54:56 +0800 Subject: [PATCH 59/60] =?UTF-8?q?=E4=BC=98=E5=8C=96redisson=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer-api/src/main/resources/redisson.yaml | 21 -------- common-api/src/main/resources/redisson.yaml | 21 -------- consumer/src/main/resources/redisson.yaml | 21 -------- .../lili/cache/config/redis/RedisConfig.java | 50 +++++++++++++++++-- manager-api/src/main/resources/redisson.yaml | 21 -------- seller-api/src/main/resources/redisson.yaml | 21 -------- 6 files changed, 45 insertions(+), 110 deletions(-) delete mode 100644 buyer-api/src/main/resources/redisson.yaml delete mode 100644 common-api/src/main/resources/redisson.yaml delete mode 100644 consumer/src/main/resources/redisson.yaml delete mode 100644 manager-api/src/main/resources/redisson.yaml delete mode 100644 seller-api/src/main/resources/redisson.yaml diff --git a/buyer-api/src/main/resources/redisson.yaml b/buyer-api/src/main/resources/redisson.yaml deleted file mode 100644 index ac8dfc66..00000000 --- a/buyer-api/src/main/resources/redisson.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -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/resources/redisson.yaml b/common-api/src/main/resources/redisson.yaml deleted file mode 100644 index ac8dfc66..00000000 --- a/common-api/src/main/resources/redisson.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -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/main/resources/redisson.yaml b/consumer/src/main/resources/redisson.yaml deleted file mode 100644 index ac8dfc66..00000000 --- a/consumer/src/main/resources/redisson.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -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/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java b/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java index dbb8ad39..659c1ece 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 @@ -1,12 +1,17 @@ package cn.lili.cache.config.redis; +import cn.hutool.core.text.CharSequenceUtil; 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.ClusterServersConfig; import org.redisson.config.Config; +import org.redisson.config.SentinelServersConfig; +import org.redisson.config.SingleServerConfig; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -20,7 +25,6 @@ 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; @@ -31,9 +35,10 @@ 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.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -54,6 +59,9 @@ public class RedisConfig extends CachingConfigurerSupport { @Value("${lili.cache.timeout:7200}") private Integer timeout; + @Autowired + private RedisProperties redisProperties; + /** * 当有多个管理器的时候,必须使用该注解在一个管理器上注释:表示该管理器为默认的管理器 @@ -105,9 +113,41 @@ public class RedisConfig extends CachingConfigurerSupport { } @Bean(destroyMethod = "shutdown") - public RedissonClient redisson() throws IOException { - return Redisson.create( - Config.fromYAML(new ClassPathResource("redisson.yaml").getInputStream())); + public RedissonClient redisson() { + Config config = new Config(); + + if (redisProperties.getSentinel() != null && !redisProperties.getSentinel().getNodes().isEmpty()) { + // 哨兵模式 + SentinelServersConfig sentinelServersConfig = config.useSentinelServers(); + sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster()); + List sentinelAddress = new ArrayList<>(); + for (String node : redisProperties.getCluster().getNodes()) { + sentinelAddress.add("redis://" + node); + } + sentinelServersConfig.setSentinelAddresses(sentinelAddress); + if (CharSequenceUtil.isNotEmpty(redisProperties.getSentinel().getPassword())) { + sentinelServersConfig.setSentinelPassword(redisProperties.getSentinel().getPassword()); + } + } else if (redisProperties.getCluster() != null && !redisProperties.getCluster().getNodes().isEmpty()) { + // 集群模式 + ClusterServersConfig clusterServersConfig = config.useClusterServers(); + List clusterNodes = new ArrayList<>(); + for (String node : redisProperties.getCluster().getNodes()) { + clusterNodes.add("redis://" + node); + } + clusterServersConfig.setNodeAddresses(clusterNodes); + if (CharSequenceUtil.isNotEmpty(redisProperties.getPassword())) { + clusterServersConfig.setPassword(redisProperties.getPassword()); + } + } else { + SingleServerConfig singleServerConfig = config.useSingleServer(); + singleServerConfig.setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort()); + if (CharSequenceUtil.isNotEmpty(redisProperties.getPassword())) { + singleServerConfig.setPassword(redisProperties.getPassword()); + } + } + + return Redisson.create(config); } /** diff --git a/manager-api/src/main/resources/redisson.yaml b/manager-api/src/main/resources/redisson.yaml deleted file mode 100644 index ac8dfc66..00000000 --- a/manager-api/src/main/resources/redisson.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -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/seller-api/src/main/resources/redisson.yaml b/seller-api/src/main/resources/redisson.yaml deleted file mode 100644 index ac8dfc66..00000000 --- a/seller-api/src/main/resources/redisson.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -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 From da6a17cd614ffaf3603b58bd9f72042f769008d1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 11 Feb 2022 14:56:25 +0800 Subject: [PATCH 60/60] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../limit/interceptor/LimitInterceptor.java | 3 +-- .../annotation/PreventDuplicateSubmissions.java | 1 - .../common/aop/interceptor/DemoInterceptor.java | 2 +- .../cn/lili/common/utils/SnowflakeInitiator.java | 6 +----- .../serviceimpl/MemberEvaluationServiceImpl.java | 3 ++- .../serviceimpl/MemberSignServiceImpl.java | 16 ++++++---------- .../serviceimpl/MemberCouponServiceImpl.java | 5 +++++ .../system/entity/dto/PointSettingItem.java | 6 ++++-- 8 files changed, 20 insertions(+), 22 deletions(-) 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 d3c01b1f..402f165d 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 @@ -1,7 +1,7 @@ package cn.lili.cache.limit.interceptor; -import cn.lili.cache.limit.enums.LimitTypeEnums; import cn.lili.cache.limit.annotation.LimitPoint; +import cn.lili.cache.limit.enums.LimitTypeEnums; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.utils.IpUtils; @@ -17,7 +17,6 @@ import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; import java.io.Serializable; /** 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 index 910906b4..ba884dfe 100644 --- a/framework/src/main/java/cn/lili/common/aop/annotation/PreventDuplicateSubmissions.java +++ b/framework/src/main/java/cn/lili/common/aop/annotation/PreventDuplicateSubmissions.java @@ -1,7 +1,6 @@ package cn.lili.common.aop.annotation; import java.lang.annotation.*; -import java.util.concurrent.TimeUnit; /** * 防止重复提交注解 diff --git a/framework/src/main/java/cn/lili/common/aop/interceptor/DemoInterceptor.java b/framework/src/main/java/cn/lili/common/aop/interceptor/DemoInterceptor.java index d021b474..ed5a365a 100644 --- a/framework/src/main/java/cn/lili/common/aop/interceptor/DemoInterceptor.java +++ b/framework/src/main/java/cn/lili/common/aop/interceptor/DemoInterceptor.java @@ -26,7 +26,7 @@ public class DemoInterceptor { @Before("@annotation(demoSite)") public void doAfter(DemoSite demoSite) { - if (systemSettingProperties.getIsDemoSite()) { + if (Boolean.TRUE.equals(systemSettingProperties.getIsDemoSite())) { throw new ServiceException(ResultCode.DEMO_SITE_EXCEPTION); } } diff --git a/framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java b/framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java index 4a36af5c..8ffbba1f 100644 --- a/framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java +++ b/framework/src/main/java/cn/lili/common/utils/SnowflakeInitiator.java @@ -1,15 +1,11 @@ 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 @@ -25,7 +21,7 @@ public class SnowflakeInitiator { /** * 缓存前缀 */ - private static String KEY = "{Snowflake}"; + private static final String KEY = "{Snowflake}"; @Autowired private Cache cache; 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 bce3490f..868a9abd 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 @@ -106,13 +106,14 @@ public class MemberEvaluationServiceImpl extends ServiceImpl 0) { + if (!signs.isEmpty()) { //截止目前为止 签到总天数 不带今天 Integer signDay = signs.get(0).getSignDay(); memberSign.setSignDay(CurrencyUtil.add(signDay, 1).intValue()); 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 2514e68f..d46f606f 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 @@ -82,6 +82,7 @@ public class MemberCouponServiceImpl extends ServiceImpl ids) { if (ids != null && !ids.isEmpty()) { List memberCoupons = this.listByIds(ids); @@ -247,6 +250,7 @@ public class MemberCouponServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(MemberCoupon::getId, id); @@ -260,6 +264,7 @@ public class MemberCouponServiceImpl extends ServiceImpl couponIds) { LambdaUpdateWrapper memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper() .in(MemberCoupon::getCouponId, couponIds) 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 11d061d8..885b4b19 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 @@ -3,6 +3,8 @@ package cn.lili.modules.system.entity.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; + /** * 积分签到设置 * @@ -10,7 +12,7 @@ import lombok.Data; * @since 2021-02-26 11:48 */ @Data -public class PointSettingItem implements Comparable { +public class PointSettingItem implements Comparable, Serializable { @ApiModelProperty(value = "签到天数") @@ -21,7 +23,7 @@ public class PointSettingItem implements Comparable { private Integer point; public Integer getPoint() { - if (point != null || point < 0) { + if (point == null || point < 0) { return 0; } return point;