From 1f21d80dc0156fb8c587af584dfe4f23102af5ae Mon Sep 17 00:00:00 2001 From: 17600048398 <277692624@qq.com> Date: Tue, 18 Apr 2023 10:57:41 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=97=B6=20=E6=97=A0=E6=B3=95=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 64 +++++++++---------- .../member/serviceimpl/ClerkServiceImpl.java | 6 +- .../serviceimpl/MemberSignServiceImpl.java | 14 +++- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/config/application.yml b/config/application.yml index ff9ed60e..9590836f 100644 --- a/config/application.yml +++ b/config/application.yml @@ -24,13 +24,13 @@ spring: boot: admin: client: - url: http://127.0.0.1:8000 + url: http://192.168.0.108:8000 cache: type: redis # Redis redis: - host: 127.0.0.1 - port: 6379 + host: 192.168.31.108 + port: 30379 password: lilishop lettuce: pool: @@ -60,7 +60,7 @@ spring: default-datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://192.168.31.108:30306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop maxActive: 50 @@ -241,16 +241,16 @@ lili: sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6 #域名 domain: - pc: http://127.0.0.1:8888 - wap: http://127.0.0.1:8888 - seller: http://127.0.0.1:8888 - admin: http://127.0.0.1:8888 + pc: http://192.168.0.108:8888 + wap: http://192.168.0.108:8888 + seller: http://192.168.0.108:8888 + admin: http://192.168.0.108:8888 #api地址 api: buyer: https://z171l91606.51mypc.cn - base: http://127.0.0.1:8888 - manager: http://127.0.0.1:8888 - seller: http://127.0.0.1:8888 + base: http://192.168.0.108:8888 + manager: http://192.168.0.108:8888 + seller: http://192.168.0.108:8888 # jwt 细节设定 jwt-setting: @@ -269,7 +269,7 @@ lili: data: elasticsearch: cluster-name: elasticsearch - cluster-nodes: 127.0.0.1:9200 + cluster-nodes: 192.168.31.108:30920 index: number-of-replicas: 0 number-of-shards: 3 @@ -282,26 +282,26 @@ lili: logstash: server: 127.0.0.1:4560 rocketmq: - promotion-topic: lili_promotion_topic - promotion-group: lili_promotion_group - msg-ext-topic: lili_msg_topic - msg-ext-group: lili_msg_group - goods-topic: lili_goods_topic - goods-group: lili_goods_group - order-topic: lili_order_topic - order-group: lili_order_group - member-topic: lili_member_topic - member-group: lili_member_group - other-topic: lili_other_topic - other-group: lili_other_group - notice-topic: lili_notice_topic - notice-group: lili_notice_group - notice-send-topic: lili_send_notice_topic - notice-send-group: lili_send_notice_group - after-sale-topic: lili_after_sale_topic - after-sale-group: lili_after_sale_group + promotion-topic: shop_lili_promotion_topic + promotion-group: shop_lili_promotion_group + msg-ext-topic: shop_lili_msg_topic + msg-ext-group: shop_lili_msg_group + goods-topic: shop_lili_goods_topic + goods-group: shop_lili_goods_group + order-topic: shop_lili_order_topic + order-group: shop_lili_order_group + member-topic: shop_lili_member_topic + member-group: shop_lili_member_group + other-topic: shop_lili_other_topic + other-group: shop_lili_other_group + notice-topic: shop_lili_notice_topic + notice-group: shop_lili_notice_group + notice-send-topic: shop_lili_send_notice_topic + notice-send-group: shop_lili_send_notice_group + after-sale-topic: shop_lili_after_sale_topic + after-sale-group: shop_lili_after_sale_group rocketmq: - name-server: 127.0.0.1:9876 + name-server: 192.168.31.108:30876 isVIPChannel: false producer: group: lili_group @@ -310,7 +310,7 @@ rocketmq: xxl: job: admin: - addresses: http://127.0.0.1:9001/xxl-job-admin + addresses: http://192.168.31.108:30001/xxl-job-admin executor: appname: xxl-job-executor-lilishop address: diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/ClerkServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/ClerkServiceImpl.java index 00558f93..84aea3b4 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/ClerkServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/ClerkServiceImpl.java @@ -189,10 +189,12 @@ public class ClerkServiceImpl extends ServiceImpl implements clerk.setIsSuper(clerkAddDTO.getIsSuper()); //校验此会员是否已经是店员 Clerk temp = this.getClerkByMemberId(clerkAddDTO.getMemberId()); - if (temp != null && !temp.getStoreId().equals(UserContext.getCurrentUser().getStoreId())) { + + //店员信息不为空 + if (temp != null && !temp.getStoreId().equals(clerkAddDTO.getStoreId())) { throw new ServiceException(ResultCode.CLERK_USER_ERROR); } - if (temp != null && temp.getStoreId().equals(UserContext.getCurrentUser().getStoreId())) { + if (temp != null && temp.getStoreId().equals(clerkAddDTO.getStoreId())) { throw new ServiceException(ResultCode.CLERK_ALREADY_EXIT_ERROR); } //部门校验 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 70a5c678..9ec42910 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 @@ -1,5 +1,6 @@ package cn.lili.modules.member.serviceimpl; +import cn.hutool.core.util.ObjectUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; @@ -19,6 +20,7 @@ import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.MemberTagsEnum; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.gson.Gson; import org.apache.rocketmq.spring.core.RocketMQTemplate; @@ -62,8 +64,16 @@ public class MemberSignServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(MemberSign::getMemberId, authUser.getId()); + queryWrapper.eq(MemberSign::getDay,DateUtil.getDayOfStart().intValue()); + List signSize = this.baseMapper.getTodayMemberSign(queryWrapper); + //当日签到信息不为空 + if (!signSize.isEmpty()) { + throw new ServiceException(ResultCode.MEMBER_SIGN_REPEAT); + } //当前签到天数的前一天日期 List signs = this.baseMapper.getBeforeMemberSign(authUser.getId()); //构建参数 From 7b6a150bd2dde6ceaaa9f8699c5bba1dbf522873 Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Wed, 19 Apr 2023 12:08:47 +0800 Subject: [PATCH 02/25] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E8=A2=AB?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E3=80=81=E5=BA=97=E9=93=BA=E8=A2=AB=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E3=80=81=E7=AE=A1=E7=90=86=E5=91=98=E8=A2=AB=E7=A6=81?= =?UTF-8?q?=E7=94=A8=EF=BC=8Ctoken=E6=9C=AA=E8=A2=AB=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/BuyerAuthenticationFilter.java | 2 +- .../statistics/OnlineMemberStatistics.java | 3 +- .../main/java/cn/lili/cache/CachePrefix.java | 12 ++++++ .../common/security/context/UserContext.java | 2 +- .../lili/common/security/token/TokenUtil.java | 13 +++--- .../modules/member/service/MemberService.java | 10 ++++- .../member/serviceimpl/MemberServiceImpl.java | 41 ++++++++++++++++--- .../permission/service/AdminUserService.java | 7 ++++ .../serviceimpl/AdminUserServiceImpl.java | 17 +++++++- .../store/serviceimpl/StoreServiceImpl.java | 16 ++++++-- .../passport/AdminUserManagerController.java | 11 ++++- .../security/ManagerAuthenticationFilter.java | 5 ++- .../security/StoreAuthenticationFilter.java | 10 +++-- 13 files changed, 122 insertions(+), 27 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/security/BuyerAuthenticationFilter.java b/buyer-api/src/main/java/cn/lili/security/BuyerAuthenticationFilter.java index 7372a7d2..7d81a2f8 100644 --- a/buyer-api/src/main/java/cn/lili/security/BuyerAuthenticationFilter.java +++ b/buyer-api/src/main/java/cn/lili/security/BuyerAuthenticationFilter.java @@ -99,7 +99,7 @@ public class BuyerAuthenticationFilter extends BasicAuthenticationFilter { AuthUser authUser = new Gson().fromJson(json, AuthUser.class); //校验redis中是否有权限 - if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER) + jwt)) { + if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER,authUser.getId()) + jwt)) { //构造返回信息 List auths = new ArrayList<>(); auths.add(new SimpleGrantedAuthority("ROLE_" + authUser.getRole().name())); diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java index db9797b0..19f90bb1 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java @@ -72,7 +72,8 @@ public class OnlineMemberStatistics implements EveryHourExecute { calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); - onlineMemberVOS.add(new OnlineMemberVO(calendar.getTime(), cache.keys(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER) + "*").size(), lastNum.get())); + onlineMemberVOS.add(new OnlineMemberVO(calendar.getTime(), cache.keys(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER) + "*").size(), + lastNum.get())); //写入缓存 cache.put(CachePrefix.ONLINE_MEMBER.getPrefix(), onlineMemberVOS); diff --git a/framework/src/main/java/cn/lili/cache/CachePrefix.java b/framework/src/main/java/cn/lili/cache/CachePrefix.java index c1481c65..f25f042d 100644 --- a/framework/src/main/java/cn/lili/cache/CachePrefix.java +++ b/framework/src/main/java/cn/lili/cache/CachePrefix.java @@ -555,4 +555,16 @@ public enum CachePrefix { public String getPrefix(UserEnums user) { return "{" + this.name() + "_" + user.name() + "}_"; } + + /** + * 获取缓存key值 + 用户端 +自定义前缀 + * 例如:三端都有用户体系,需要分别登录,如果用户名一致,则redis中的权限可能会冲突出错 + * + * @param user 角色 + * @param customPrefix 自定义前缀 + * @return 缓存key值 + */ + public String getPrefix(UserEnums user, String customPrefix) { + return "{" + this.name() + "_" + user.name() + "}_" + customPrefix + "_"; + } } 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 a1c86cae..d2770bee 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 @@ -65,7 +65,7 @@ public class UserContext { AuthUser authUser = getAuthUser(accessToken); assert authUser != null; - if (!cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(authUser.getRole()) + accessToken)) { + if (!cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(authUser.getRole(), authUser.getId()) + accessToken)) { throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR); } return authUser; diff --git a/framework/src/main/java/cn/lili/common/security/token/TokenUtil.java b/framework/src/main/java/cn/lili/common/security/token/TokenUtil.java index dc62def6..ce8a9182 100644 --- a/framework/src/main/java/cn/lili/common/security/token/TokenUtil.java +++ b/framework/src/main/java/cn/lili/common/security/token/TokenUtil.java @@ -42,13 +42,13 @@ public class TokenUtil { //访问token String accessToken = createToken(authUser, tokenProperties.getTokenExpireTime()); - cache.put(CachePrefix.ACCESS_TOKEN.getPrefix(authUser.getRole()) + accessToken, 1, + cache.put(CachePrefix.ACCESS_TOKEN.getPrefix(authUser.getRole(), authUser.getId()) + accessToken, 1, tokenProperties.getTokenExpireTime(), TimeUnit.MINUTES); //刷新token生成策略:如果是长时间有效的token(用于app),则默认15天有效期刷新token。如果是普通用户登录,则刷新token为普通token2倍数 Long expireTime = authUser.getLongTerm() ? 15 * 24 * 60L : tokenProperties.getTokenExpireTime() * 2; String refreshToken = createToken(authUser, expireTime); - cache.put(CachePrefix.REFRESH_TOKEN.getPrefix(authUser.getRole()) + refreshToken, 1, expireTime, TimeUnit.MINUTES); + cache.put(CachePrefix.REFRESH_TOKEN.getPrefix(authUser.getRole(), authUser.getId()) + refreshToken, 1, expireTime, TimeUnit.MINUTES); token.setAccessToken(accessToken); token.setRefreshToken(refreshToken); @@ -85,11 +85,12 @@ public class TokenUtil { //如果缓存中有刷新token && - if (cache.hasKey(CachePrefix.REFRESH_TOKEN.getPrefix(userEnums) + oldRefreshToken)) { + if (cache.hasKey(CachePrefix.REFRESH_TOKEN.getPrefix(userEnums, authUser.getId()) + oldRefreshToken)) { Token token = new Token(); //访问token String accessToken = createToken(authUser, tokenProperties.getTokenExpireTime()); - cache.put(CachePrefix.ACCESS_TOKEN.getPrefix(userEnums) + accessToken, 1, tokenProperties.getTokenExpireTime(), TimeUnit.MINUTES); + cache.put(CachePrefix.ACCESS_TOKEN.getPrefix(userEnums, authUser.getId()) + accessToken, 1, tokenProperties.getTokenExpireTime(), + TimeUnit.MINUTES); //如果是信任登录设备,则刷新token长度继续延长 Long expirationTime = tokenProperties.getTokenExpireTime() * 2; @@ -101,10 +102,10 @@ public class TokenUtil { //刷新token生成策略:如果是长时间有效的token(用于app),则默认15天有效期刷新token。如果是普通用户登录,则刷新token为普通token2倍数 String refreshToken = createToken(authUser, expirationTime); - cache.put(CachePrefix.REFRESH_TOKEN.getPrefix(userEnums) + refreshToken, 1, expirationTime, TimeUnit.MINUTES); + cache.put(CachePrefix.REFRESH_TOKEN.getPrefix(userEnums, authUser.getId()) + refreshToken, 1, expirationTime, TimeUnit.MINUTES); token.setAccessToken(accessToken); token.setRefreshToken(refreshToken); - cache.remove(CachePrefix.REFRESH_TOKEN.getPrefix(userEnums) + oldRefreshToken); + cache.remove(CachePrefix.REFRESH_TOKEN.getPrefix(userEnums, authUser.getId()) + oldRefreshToken); return token; } else { throw new ServiceException(ResultCode.USER_AUTH_EXPIRED); 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 e4b6d4d1..430bb1d6 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 @@ -11,11 +11,10 @@ import cn.lili.modules.member.entity.dto.MemberAddDTO; import cn.lili.modules.member.entity.dto.MemberEditDTO; import cn.lili.modules.member.entity.vo.MemberSearchVO; import cn.lili.modules.member.entity.vo.MemberVO; -import cn.lili.modules.member.entity.vo.QRLoginResultVo; import cn.lili.modules.member.entity.vo.QRCodeLoginSessionVo; +import cn.lili.modules.member.entity.vo.QRLoginResultVo; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; -import org.elasticsearch.monitor.os.OsStats; import java.util.List; import java.util.Map; @@ -260,6 +259,13 @@ public interface MemberService extends IService { */ void logout(UserEnums userEnums); + /** + * 登出 + * + * @param userId 用户id + */ + void logout(String userId); + /** * 修改会员是否拥有店铺 * 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 90a97a7c..a798bc4d 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 @@ -19,7 +19,6 @@ import cn.lili.common.security.token.Token; import cn.lili.common.sensitive.SensitiveWordsFilter; import cn.lili.common.utils.*; import cn.lili.common.vo.PageVO; -import cn.lili.modules.connect.config.ConnectAuthEnum; import cn.lili.modules.connect.entity.Connect; import cn.lili.modules.connect.entity.dto.ConnectAuthUser; import cn.lili.modules.connect.service.ConnectService; @@ -309,7 +308,8 @@ public class MemberServiceImpl extends ServiceImpl impleme this.save(member); // 发送会员注册信息 - applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_REGISTER.name(), member)); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), + MemberTagsEnum.MEMBER_REGISTER.name(), member)); } @Override @@ -456,7 +456,8 @@ public class MemberServiceImpl extends ServiceImpl impleme checkMember(memberAddDTO.getUsername(), memberAddDTO.getMobile()); //添加会员 - Member member = new Member(memberAddDTO.getUsername(), new BCryptPasswordEncoder().encode(memberAddDTO.getPassword()), memberAddDTO.getMobile()); + Member member = new Member(memberAddDTO.getUsername(), new BCryptPasswordEncoder().encode(memberAddDTO.getPassword()), + memberAddDTO.getMobile()); registerHandler(member); return member; } @@ -525,7 +526,8 @@ public class MemberServiceImpl extends ServiceImpl impleme memberPointMessage.setPoint(point); memberPointMessage.setType(type); memberPointMessage.setMemberId(memberId); - applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("update member point", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_POINT_CHANGE.name(), memberPointMessage)); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("update member point", + rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_POINT_CHANGE.name(), memberPointMessage)); return true; } return false; @@ -540,6 +542,10 @@ public class MemberServiceImpl extends ServiceImpl impleme updateWrapper.set("disabled", status); updateWrapper.in("id", memberIds); + //如果是禁用 + if (Boolean.FALSE.equals(status)) { + disableMemberLogout(memberIds); + } return this.update(updateWrapper); } @@ -680,8 +686,33 @@ public class MemberServiceImpl extends ServiceImpl impleme @Override public void logout(UserEnums userEnums) { String currentUserToken = UserContext.getCurrentUserToken(); + + AuthUser authUser = UserContext.getAuthUser(currentUserToken); + if (CharSequenceUtil.isNotEmpty(currentUserToken)) { - cache.remove(CachePrefix.ACCESS_TOKEN.getPrefix(userEnums) + currentUserToken); + cache.remove(CachePrefix.ACCESS_TOKEN.getPrefix(userEnums, authUser.getId()) + currentUserToken); + cache.vagueDel(CachePrefix.REFRESH_TOKEN.getPrefix(userEnums, authUser.getId()) ); + } + } + + @Override + public void logout(String userId) { + + cache.vagueDel(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MANAGER, userId)); + cache.vagueDel(CachePrefix.REFRESH_TOKEN.getPrefix(UserEnums.MANAGER, userId)); + } + + /** + * 禁用会员会员token删除 + * + * @param memberIds 会员id + */ + public void disableMemberLogout(List memberIds) { + if (memberIds != null) { + memberIds.forEach(memberId -> { + cache.vagueDel(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER, memberId)); + cache.vagueDel(CachePrefix.REFRESH_TOKEN.getPrefix(UserEnums.MEMBER, memberId)); + }); } } diff --git a/framework/src/main/java/cn/lili/modules/permission/service/AdminUserService.java b/framework/src/main/java/cn/lili/modules/permission/service/AdminUserService.java index edc55c6e..4fc2cdb7 100644 --- a/framework/src/main/java/cn/lili/modules/permission/service/AdminUserService.java +++ b/framework/src/main/java/cn/lili/modules/permission/service/AdminUserService.java @@ -107,4 +107,11 @@ public interface AdminUserService extends IService { */ void logout(UserEnums userEnums); + /** + * 登出 + * + * @param adminUserIds 用户id + */ + void logout(List adminUserIds); + } 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 64f52872..a0da41fa 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 @@ -142,11 +142,24 @@ public class AdminUserServiceImpl extends ServiceImpl adminUserIds) { + if (adminUserIds == null || adminUserIds.isEmpty()) { + return; + } + adminUserIds.forEach(adminUserId -> { + cache.vagueDel(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MANAGER, adminUserId)); + cache.vagueDel(CachePrefix.REFRESH_TOKEN.getPrefix(UserEnums.MANAGER, adminUserId)); + }); + } @Override public AdminUser findByUsername(String username) { @@ -234,6 +247,8 @@ public class AdminUserServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.in("user_id", ids); userRoleService.remove(queryWrapper); + + this.logout(ids); } /** 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 a145a47f..3f8b4dc5 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 @@ -9,6 +9,7 @@ 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.security.enums.UserEnums; import cn.lili.common.utils.BeanUtil; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -227,7 +228,7 @@ public class StoreServiceImpl extends ServiceImpl implements } else { store.setStoreDisable(StoreStatusEnum.REFUSED.value()); } - cache.remove(CachePrefix.STORE.getPrefix()+store.getId()); + cache.remove(CachePrefix.STORE.getPrefix() + store.getId()); return this.updateById(store); } @@ -244,6 +245,13 @@ public class StoreServiceImpl extends ServiceImpl implements if (update) { goodsService.underStoreGoods(id); } + + //删除店员token + clerkService.list(new LambdaQueryWrapper().eq(Clerk::getStoreId, id)).forEach(clerk -> { + cache.vagueDel(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.STORE, clerk.getMemberId())); + cache.vagueDel(CachePrefix.REFRESH_TOKEN.getPrefix(UserEnums.STORE, clerk.getMemberId())); + }); + return update; } @@ -371,7 +379,8 @@ public class StoreServiceImpl extends ServiceImpl implements clerkService.remove(new LambdaQueryWrapper().eq(Clerk::getShopkeeper, true)); List clerkList = new ArrayList<>(); //遍历已开启的店铺 - for (Store store : this.list(new LambdaQueryWrapper().eq(Store::getDeleteFlag, false).eq(Store::getStoreDisable, StoreStatusEnum.OPEN.name()))) { + for (Store store : this.list(new LambdaQueryWrapper().eq(Store::getDeleteFlag, false).eq(Store::getStoreDisable, + StoreStatusEnum.OPEN.name()))) { clerkList.add(new Clerk(store)); } clerkService.saveBatch(clerkList); @@ -381,7 +390,8 @@ public class StoreServiceImpl extends ServiceImpl implements public List getToMemberHistory(String memberId) { AuthUser currentUser = UserContext.getCurrentUser(); List skuIdList = new ArrayList<>(); - for (FootPrint footPrint : footprintService.list(new LambdaUpdateWrapper().eq(FootPrint::getStoreId, currentUser.getStoreId()).eq(FootPrint::getMemberId, memberId))) { + for (FootPrint footPrint : + footprintService.list(new LambdaUpdateWrapper().eq(FootPrint::getStoreId, currentUser.getStoreId()).eq(FootPrint::getMemberId, memberId))) { if (footPrint.getSkuId() != null) { skuIdList.add(footPrint.getSkuId()); } 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 80ca8903..04be319d 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 @@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import javax.validation.constraints.NotNull; +import java.util.ArrayList; import java.util.List; @@ -161,7 +162,7 @@ public class AdminUserManagerController { @ApiOperation(value = "添加用户") public ResultMessage register(@Valid AdminUserDTO adminUser, @RequestParam(required = false) List roles) { - int rolesMaxSize=10; + int rolesMaxSize = 10; try { if (roles != null && roles.size() >= rolesMaxSize) { throw new ServiceException(ResultCode.PERMISSION_BEYOND_TEN); @@ -183,6 +184,14 @@ public class AdminUserManagerController { } user.setStatus(status); adminUserService.updateById(user); + + //登出用户 + if (Boolean.FALSE.equals(status)) { + List userIds = new ArrayList<>(); + userIds.add(userId); + adminUserService.logout(userIds); + } + return ResultUtil.success(); } diff --git a/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java b/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java index ddd981cb..d3849317 100644 --- a/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java +++ b/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java @@ -86,7 +86,8 @@ public class ManagerAuthenticationFilter extends BasicAuthenticationFilter { //如果不是超级管理员, 则鉴权 if (Boolean.FALSE.equals(authUser.getIsSuper())) { //获取缓存中的权限 - Map> permission = (Map>) cache.get(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + authUser.getId()); + Map> permission = + (Map>) cache.get(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + authUser.getId()); //获取数据(GET 请求)权限 if (request.getMethod().equals(RequestMethod.GET.name())) { @@ -143,7 +144,7 @@ public class ManagerAuthenticationFilter extends BasicAuthenticationFilter { AuthUser authUser = new Gson().fromJson(json, AuthUser.class); //校验redis中是否有权限 - if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MANAGER) + jwt)) { + if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MANAGER, authUser.getId()) + jwt)) { //用户角色 List auths = new ArrayList<>(); auths.add(new SimpleGrantedAuthority("ROLE_" + authUser.getRole().name())); diff --git a/seller-api/src/main/java/cn/lili/security/StoreAuthenticationFilter.java b/seller-api/src/main/java/cn/lili/security/StoreAuthenticationFilter.java index d4459ed1..c0b147af 100644 --- a/seller-api/src/main/java/cn/lili/security/StoreAuthenticationFilter.java +++ b/seller-api/src/main/java/cn/lili/security/StoreAuthenticationFilter.java @@ -51,7 +51,8 @@ public class StoreAuthenticationFilter extends BasicAuthenticationFilter { @SneakyThrows @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, + ServletException { //从header中获取jwt String jwt = request.getHeader(SecurityEnum.HEADER_TOKEN.getValue()); //如果没有token 则return @@ -89,7 +90,7 @@ public class StoreAuthenticationFilter extends BasicAuthenticationFilter { AuthUser authUser = new Gson().fromJson(json, AuthUser.class); //校验redis中是否有权限 - if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.STORE) + jwt)) { + if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.STORE, authUser.getId()) + jwt)) { //用户角色 List auths = new ArrayList<>(); auths.add(new SimpleGrantedAuthority("ROLE_" + authUser.getRole().name())); @@ -124,13 +125,14 @@ public class StoreAuthenticationFilter extends BasicAuthenticationFilter { //如果不是超级管理员, 则鉴权 if (!authUser.getIsSuper()) { //获取缓存中的权限 - Map> permission = (Map>) cache.get(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.STORE) + authUser.getId()); + Map> permission = + (Map>) cache.get(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.STORE) + authUser.getId()); //获取数据(GET 请求)权限 if (request.getMethod().equals(RequestMethod.GET.name())) { //如果用户的超级权限和查阅权限都不包含当前请求的api if (match(permission.get(PermissionEnum.SUPER.name()), requestUrl) - ||match(permission.get(PermissionEnum.QUERY.name()), requestUrl)) { + || match(permission.get(PermissionEnum.QUERY.name()), requestUrl)) { } else { ResponseUtil.output(response, ResponseUtil.resultMap(false, 400, "权限不足")); log.error("当前请求路径:{},所拥有权限:{}", requestUrl, JSONUtil.toJsonStr(permission)); From 16608d4950d4ba046bdd94cbd2f00bceea7f1e13 Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Wed, 19 Apr 2023 16:16:01 +0800 Subject: [PATCH 03/25] =?UTF-8?q?fix:=E5=94=AE=E5=90=8E=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E5=BC=82=E5=B8=B8=E6=8A=9B=E5=87=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/AfterSaleServiceImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 c6f9507c..4d319d36 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 @@ -269,14 +269,15 @@ public class AfterSaleServiceImpl extends ServiceImpl Date: Tue, 25 Apr 2023 11:31:54 +0800 Subject: [PATCH 04/25] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=90=8C=E6=AD=A5=E5=88=86=E7=B1=BB=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=20=202.=E4=BF=AE=E6=94=B9=E5=BA=97=E9=93=BA=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=90=8C=E6=AD=A5=E5=AF=B9=E5=BA=94=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/event/impl/StoreChangeEvent.java | 206 ++++++++++++++++++ .../lili/listener/GoodsMessageListener.java | 6 + .../modules/goods/service/GoodsService.java | 6 + .../serviceimpl/CategoryServiceImpl.java | 21 ++ .../goods/serviceimpl/GoodsServiceImpl.java | 10 + .../serviceimpl/GoodsSkuServiceImpl.java | 17 +- .../cn/lili/rocketmq/tags/GoodsTagsEnum.java | 4 + 7 files changed, 267 insertions(+), 3 deletions(-) create mode 100644 consumer/src/main/java/cn/lili/event/impl/StoreChangeEvent.java diff --git a/consumer/src/main/java/cn/lili/event/impl/StoreChangeEvent.java b/consumer/src/main/java/cn/lili/event/impl/StoreChangeEvent.java new file mode 100644 index 00000000..af500156 --- /dev/null +++ b/consumer/src/main/java/cn/lili/event/impl/StoreChangeEvent.java @@ -0,0 +1,206 @@ +package cn.lili.event.impl; + +import cn.lili.event.StoreSettingChangeEvent; +import cn.lili.modules.distribution.service.DistributionGoodsService; +import cn.lili.modules.distribution.service.DistributionOrderService; +import cn.lili.modules.goods.service.DraftGoodsService; +import cn.lili.modules.member.service.MemberEvaluationService; +import cn.lili.modules.message.service.StoreMessageService; +import cn.lili.modules.order.aftersale.service.AfterSaleService; +import cn.lili.modules.order.order.service.OrderComplaintService; +import cn.lili.modules.order.order.service.OrderService; +import cn.lili.modules.order.order.service.ReceiptService; +import cn.lili.modules.order.order.service.StoreFlowService; +import cn.lili.modules.promotion.service.*; +import cn.lili.modules.store.entity.dos.Store; +import cn.lili.modules.store.service.BillService; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author ftyy + * @description: 店铺名称修改同步对应场景 + * @date 2023/4/24 + */ +@Service +public class StoreChangeEvent implements StoreSettingChangeEvent { + /** + * 优惠券活动表 + */ + @Autowired + private CouponActivityService couponActivityService; + + /** + * 砍价活动商品 + */ + @Autowired + private KanjiaActivityGoodsService kanjiaActivityGoodsService; + + /** + * 积分商品 + */ + @Autowired + private PointsGoodsService pointsGoodsService; + + /** + * 促销商品 + */ + @Autowired + private PromotionGoodsService promotionGoodsService; + + /** + * 秒杀活动活动 + */ + @Autowired + private SeckillService seckillService; + + /** + * 优惠券 + */ + @Autowired + private CouponService couponService; + + /** + * 满优惠活动 + */ + @Autowired + private FullDiscountService fullDiscountService; + + /** + * 拼团 + */ + @Autowired + private PintuanService pintuanService; + + /** + * 秒杀活动 + */ + @Autowired + private SeckillApplyService seckillApplyService; + /** + * 订单 + */ + @Autowired + private OrderService orderService; + + /** + * 店铺流水 + */ + @Autowired + private StoreFlowService storeFlowService; + + /** + * 售后 + */ + @Autowired + private AfterSaleService afterSaleService; + + /** + * 订单投诉 + */ + @Autowired + private OrderComplaintService orderComplaintService; + /** + * 发票 + */ + @Autowired + private ReceiptService receiptService; + + /** + * 会员优惠券 + */ + @Autowired + private MemberCouponService memberCouponService; + + /** + * 店铺消息 + */ + @Autowired + private StoreMessageService storeMessageService; + + /** + * 会员评价 + */ + @Autowired + private MemberEvaluationService memberEvaluationService; + + /** + * 结算单 + */ + @Autowired + private BillService billService; + /** + * 分销商品 + */ + @Autowired + private DistributionGoodsService distributionGoodsService; + /** + * 分销订单 + */ + @Autowired + private DistributionOrderService distributionOrderService; + + /** + * 草稿商品 + */ + @Autowired + private DraftGoodsService draftGoodsService; + + + /** + * 店铺名称修改 同步更新相关店铺名称 + * + * @param store 店铺信息 + */ + @Override + public void storeSettingChange(Store store) { + + UpdateWrapper updateWrapper = new UpdateWrapper<>() + .eq("store_id", store.getId()) + .set("store_name", store.getStoreName()); + + //修改会员优惠券中店铺名称 + memberCouponService.update(updateWrapper); + //修改优惠券活动中店铺名称 + couponActivityService.update(updateWrapper); + //修改砍价活动商品中店铺名称 + kanjiaActivityGoodsService.update(updateWrapper); + //修改积分商品中店铺名称 + pointsGoodsService.update(updateWrapper); + //修改促销商品中店铺名称 + promotionGoodsService.update(updateWrapper); + //修改秒杀活动活动中店铺名称 + seckillService.update(updateWrapper); + //修改优惠券中店铺名称 + couponService.update(updateWrapper); + //修改满优惠活动中店铺名称 + fullDiscountService.update(updateWrapper); + //修改拼团中店铺名称 + pintuanService.update(updateWrapper); + //修改秒杀活动中店铺名称 + seckillApplyService.update(updateWrapper); + //修改发票中店铺名称 + receiptService.update(updateWrapper); + //修改订单中的店铺名称 + orderService.update(updateWrapper); + //修改店铺流水中店铺名称 + storeFlowService.update(updateWrapper); + //修改售后中店铺名称 + afterSaleService.update(updateWrapper); + //修改订单投诉中店铺名称 + orderComplaintService.update(updateWrapper); + //修改店铺消息中的店铺名称 + storeMessageService.update(updateWrapper); + //修改会员评价中店铺名称 + memberEvaluationService.update(updateWrapper); + //修改结算单中店铺名称 + billService.update(updateWrapper); + //修改分销订单中店铺名称 + distributionOrderService.update(updateWrapper); + //修改分销商品中店铺名称 + distributionGoodsService.update(updateWrapper); + //修改草稿商品中店铺名称 + draftGoodsService.update(updateWrapper); + } +} diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index e8949915..8661814d 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -234,6 +234,12 @@ public class GoodsMessageListener implements RocketMQListener { log.error("删除店铺商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; + //同步商品分类名称 + case CATEGORY_GOODS_NAME: + //分类ID + String id = new String(messageExt.getBody()); + goodsService.categoryGoodsName(id); + break; //商品评价 case GOODS_COMMENT_COMPLETE: MemberEvaluation memberEvaluation = JSONUtil.toBean(new String(messageExt.getBody()), MemberEvaluation.class); diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java index 7757a7da..165d1d61 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java @@ -184,4 +184,10 @@ public interface GoodsService extends IService { */ long countStoreGoodsNum(String storeId); + /** + * 同步商品分类名称 + * + * @param categoryId 分类ID + */ + void categoryGoodsName(String categoryId); } 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 8410e414..1095544a 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 @@ -4,7 +4,9 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; +import cn.lili.common.event.TransactionCommitSendMQEvent; import cn.lili.common.exception.ServiceException; +import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.vos.CategoryVO; import cn.lili.modules.goods.mapper.CategoryMapper; @@ -12,16 +14,19 @@ import cn.lili.modules.goods.service.CategoryBrandService; import cn.lili.modules.goods.service.CategoryParameterGroupService; import cn.lili.modules.goods.service.CategoryService; import cn.lili.modules.goods.service.CategorySpecificationService; +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; import com.baomidou.mybatisplus.core.toolkit.Wrappers; 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.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -55,6 +60,20 @@ public class CategoryServiceImpl extends ServiceImpl i @Autowired private CategorySpecificationService categorySpecificationService; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + + /** + * rocketMq + */ + @Autowired + private RocketMQTemplate rocketMQTemplate; + /** + * rocketMq配置 + */ + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; + @Override public List dbList(String parentId) { return this.list(new LambdaQueryWrapper().eq(Category::getParentId, parentId)); @@ -244,6 +263,8 @@ public class CategoryServiceImpl extends ServiceImpl i updateWrapper.eq("id", category.getId()); this.baseMapper.update(category, updateWrapper); removeCache(); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("同步商品分类名称", + rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.CATEGORY_GOODS_NAME.name(), category.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 c1ae964b..5bd264f0 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 @@ -494,6 +494,16 @@ public class GoodsServiceImpl extends ServiceImpl implements .eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name())); } + @Override + public void categoryGoodsName(String categoryId) { + //获取分类下的商品 + List list = this.list(new LambdaQueryWrapper().like(Goods::getCategoryPath,categoryId)); + list.parallelStream().forEach(goods->{ + //移除redis中商品缓存 + cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId()); + }); + } + /** * 更新商品状态 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 20962422..1c9c134f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -3,6 +3,7 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; @@ -529,9 +530,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i public void updateStock(String skuId, Integer quantity) { GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId); if (goodsSku != null) { - if (quantity <= 0) { - goodsIndexService.deleteIndexById(goodsSku.getId()); - } + //判断商品sku是否已经下架(修改商品库存为0时 会自动下架商品),再次更新商品库存时 需更新商品索引 + Boolean isFlag = goodsSku.getQuantity()<= 0; + goodsSku.setQuantity(quantity); boolean update = this.update(new LambdaUpdateWrapper().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity)); @@ -546,6 +547,16 @@ public class GoodsSkuServiceImpl extends ServiceImpl i goodsSkus.add(goodsSku); this.updateGoodsStuck(goodsSkus); this.promotionGoodsService.updatePromotionGoodsStock(goodsSku.getId(), quantity); + //商品库存为0是删除商品索引 + if (quantity <= 0) { + goodsIndexService.deleteIndexById(goodsSku.getId()); + } + //商品SKU库存为0并且商品sku状态为上架时更新商品库存 + if(isFlag && StrUtil.equals(goodsSku.getMarketEnable(),GoodsStatusEnum.UPPER.name())) { + List goodsIds = new ArrayList<>(); + goodsIds.add(goodsSku.getGoodsId()); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds)); + } } } diff --git a/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java b/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java index 9aa013fc..86ef5c8b 100644 --- a/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java +++ b/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java @@ -55,6 +55,10 @@ public enum GoodsTagsEnum { * "收藏商品" */ GOODS_COLLECTION("收藏商品"), + /** + * 同步商品分类名称 + */ + CATEGORY_GOODS_NAME("同步商品分类名称"), /** * "购买商品完成" */ From c720d533898df80262f3f5bd7955a6f4030d93db Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Tue, 25 Apr 2023 14:01:49 +0800 Subject: [PATCH 05/25] =?UTF-8?q?fix:=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=97=A0=E6=B3=95=E7=99=BB=E5=BD=95=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/connect/serviceimpl/ConnectServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 e7d5ba1c..11a54878 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 @@ -191,13 +191,13 @@ public class ConnectServiceImpl extends ServiceImpl impl String phone = (String) userInfo.get("purePhoneNumber"); connectAuthUser.setUsername("m" + phone); connectAuthUser.setPhone(phone); - connectAuthUser.setSource(ConnectEnum.WECHAT.name()); - connectAuthUser.setType(ClientTypeEnum.WECHAT_MP.name()); + connectAuthUser.setSource(ClientTypeEnum.WECHAT_MP.name()); + connectAuthUser.setType(ConnectEnum.WECHAT.name()); } else { connectAuthUser.setUsername(UuidUtils.getUUID()); - connectAuthUser.setSource(ConnectEnum.WECHAT.name()); - connectAuthUser.setType(ClientTypeEnum.WECHAT_MP.name()); + connectAuthUser.setSource(ClientTypeEnum.WECHAT_MP.name()); + connectAuthUser.setType(ConnectEnum.WECHAT.name()); } From 959e24f51b3ec7222f6b8bc4d871f327e28914ae Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Tue, 25 Apr 2023 14:16:36 +0800 Subject: [PATCH 06/25] =?UTF-8?q?fix:=E4=BD=BF=E7=94=A8=E7=94=A8=E6=88=B7o?= =?UTF-8?q?penID=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 11a54878..aaea809c 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 @@ -281,7 +281,7 @@ public class ConnectServiceImpl extends ServiceImpl impl //使用OpenID登录 SourceEnum sourceEnum = SourceEnum.getSourceEnum(ConnectEnum.valueOf(authUser.getType()), ClientTypeEnum.valueOf(authUser.getSource())); - queryWrapper.eq(Connect::getUnionId, authUser.getToken().getUnionId()) + queryWrapper.eq(Connect::getUnionId, authUser.getUuid()) .eq(Connect::getUnionType, sourceEnum.name()); } From 279b47379369632551bfe739ec3c308597fbd9d6 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Tue, 25 Apr 2023 17:59:42 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7=E4=B8=BA=E5=94=AF=E4=B8=80=E8=BA=AB=E4=BB=BD=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/event/impl/MemberExecute.java | 8 +-- .../connect/entity/dto/ConnectAuthUser.java | 9 ++- .../connect/request/BaseAuthQQRequest.java | 4 +- .../request/BaseAuthWeChatPCRequest.java | 4 +- .../request/BaseAuthWeChatRequest.java | 4 +- .../connect/request/BaseAuthWeiboRequest.java | 3 +- .../serviceimpl/ConnectServiceImpl.java | 60 ++++++++++--------- 7 files changed, 47 insertions(+), 45 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 27ce3bf7..838a097e 100644 --- a/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java @@ -40,17 +40,13 @@ public class MemberExecute implements MemberLoginEvent, MemberConnectLoginEvent @Override public void memberConnectLogin(Member member, ConnectAuthUser authUser) { - log.info("unionid:"+authUser.getToken().getUnionId()); - log.info("openid:"+authUser.getUuid()); //保存UnionID if (StrUtil.isNotBlank(authUser.getToken().getUnionId())) { - connectService.loginBindUser(member.getId(), authUser.getToken().getUnionId(), authUser.getSource()); + connectService.loginBindUser(member.getId(), authUser.getToken().getUnionId(), authUser.getSource().name()); } //保存OpenID if (StrUtil.isNotBlank(authUser.getUuid())) { - log.info("authUser.getSource():"+authUser.getSource()); - log.info("authUser.getType():"+authUser.getType()); - SourceEnum sourceEnum = SourceEnum.getSourceEnum(ConnectEnum.valueOf(authUser.getSource()), ClientTypeEnum.valueOf(authUser.getType())); + SourceEnum sourceEnum = SourceEnum.getSourceEnum(authUser.getSource(), authUser.getType()); connectService.loginBindUser(member.getId(), authUser.getUuid(), sourceEnum.name()); } diff --git a/framework/src/main/java/cn/lili/modules/connect/entity/dto/ConnectAuthUser.java b/framework/src/main/java/cn/lili/modules/connect/entity/dto/ConnectAuthUser.java index a3b011d3..0c1d5e83 100644 --- a/framework/src/main/java/cn/lili/modules/connect/entity/dto/ConnectAuthUser.java +++ b/framework/src/main/java/cn/lili/modules/connect/entity/dto/ConnectAuthUser.java @@ -1,7 +1,9 @@ package cn.lili.modules.connect.entity.dto; +import cn.lili.common.enums.ClientTypeEnum; import cn.lili.modules.connect.config.ConnectAuthEnum; import cn.lili.modules.connect.entity.enums.AuthUserGender; +import cn.lili.modules.connect.entity.enums.ConnectEnum; import com.alibaba.fastjson.JSONObject; import lombok.AllArgsConstructor; import lombok.Builder; @@ -65,14 +67,15 @@ public class ConnectAuthUser implements Serializable { private AuthUserGender gender; /** * 用户来源 + * 例如:QQ、微信、微博等 */ - private String source; + private ConnectEnum source; /** - * 类型 + * 类型-客户端类型 * 例如:PC、WAP、小程序 */ - private String type; + private ClientTypeEnum type; /** * 用户授权的token信息 */ diff --git a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthQQRequest.java b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthQQRequest.java index 4cf53b78..137d652e 100644 --- a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthQQRequest.java +++ b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthQQRequest.java @@ -69,8 +69,8 @@ public class BaseAuthQQRequest extends BaseAuthRequest { .uuid(openId) .gender(AuthUserGender.getRealGender(object.getString("gender"))) .token(authToken) - .source(ConnectEnum.QQ.name()) - .type(ClientTypeEnum.PC.name()) + .source(ConnectEnum.QQ) + .type(ClientTypeEnum.PC) .build(); } diff --git a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatPCRequest.java b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatPCRequest.java index 43aa3e06..63feaea4 100644 --- a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatPCRequest.java +++ b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatPCRequest.java @@ -62,8 +62,8 @@ public class BaseAuthWeChatPCRequest extends BaseAuthRequest { .uuid(authToken.getOpenId()) .gender(AuthUserGender.getWechatRealGender(object.getString("sex"))) .token(authToken) - .source(ConnectEnum.WECHAT.name()) - .type(ClientTypeEnum.PC.name()) + .source(ConnectEnum.WECHAT) + .type(ClientTypeEnum.PC) .build(); } diff --git a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatRequest.java b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatRequest.java index 283a07f5..6418d9cf 100644 --- a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatRequest.java +++ b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeChatRequest.java @@ -64,8 +64,8 @@ public class BaseAuthWeChatRequest extends BaseAuthRequest { .uuid(openId) .gender(AuthUserGender.getWechatRealGender(object.getString("sex"))) .token(authToken) - .source(ConnectEnum.WECHAT.name()) - .type(ClientTypeEnum.H5.name()) + .source(ConnectEnum.WECHAT) + .type(ClientTypeEnum.H5) .build(); } diff --git a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeiboRequest.java b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeiboRequest.java index 69c26351..e2e79b97 100644 --- a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeiboRequest.java +++ b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthWeiboRequest.java @@ -12,6 +12,7 @@ import cn.lili.modules.connect.entity.dto.AuthToken; import cn.lili.modules.connect.entity.dto.ConnectAuthUser; import cn.lili.modules.connect.entity.enums.AuthResponseStatus; import cn.lili.modules.connect.entity.enums.AuthUserGender; +import cn.lili.modules.connect.entity.enums.ConnectEnum; import cn.lili.modules.connect.exception.AuthException; import cn.lili.common.utils.HttpUtils; import cn.lili.common.utils.IpUtils; @@ -72,7 +73,7 @@ public class BaseAuthWeiboRequest extends BaseAuthRequest { .remark(object.getString("description")) .gender(AuthUserGender.getRealGender(object.getString("gender"))) .token(authToken) - .source(source.toString()) + .source(ConnectEnum.WEIBO) .build(); } 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 aaea809c..9e575b82 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 @@ -191,15 +191,11 @@ public class ConnectServiceImpl extends ServiceImpl impl String phone = (String) userInfo.get("purePhoneNumber"); connectAuthUser.setUsername("m" + phone); connectAuthUser.setPhone(phone); - connectAuthUser.setSource(ClientTypeEnum.WECHAT_MP.name()); - connectAuthUser.setType(ConnectEnum.WECHAT.name()); - } else { connectAuthUser.setUsername(UuidUtils.getUUID()); - connectAuthUser.setSource(ClientTypeEnum.WECHAT_MP.name()); - connectAuthUser.setType(ConnectEnum.WECHAT.name()); } - + connectAuthUser.setSource(ConnectEnum.WECHAT); + connectAuthUser.setType(ClientTypeEnum.WECHAT_MP); AuthToken authToken = new AuthToken(); authToken.setUnionId(unionId); @@ -270,33 +266,39 @@ public class ConnectServiceImpl extends ServiceImpl impl */ private Token unionLoginCallback(ConnectAuthUser authUser, boolean longTerm) { - try { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - //使用UnionId登录 - if (StrUtil.isNotBlank(authUser.getToken().getUnionId())) { - queryWrapper.eq(Connect::getUnionId, authUser.getToken().getUnionId()) - .eq(Connect::getUnionType, authUser.getSource()); - } else { - //使用OpenID登录 - SourceEnum sourceEnum = SourceEnum.getSourceEnum(ConnectEnum.valueOf(authUser.getType()), - ClientTypeEnum.valueOf(authUser.getSource())); - queryWrapper.eq(Connect::getUnionId, authUser.getUuid()) - .eq(Connect::getUnionType, sourceEnum.name()); + Member member =null; + //判断是否传递手机号,如果传递手机号则使用手机号登录 + if(StrUtil.isNotBlank(authUser.getPhone())){ + member = memberService.findByMobile(authUser.getPhone()); } + //如果未查到手机号的会员则使用第三方登录 + if(member==null){ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + //使用UnionId登录 + if (StrUtil.isNotBlank(authUser.getToken().getUnionId())) { + queryWrapper.eq(Connect::getUnionId, authUser.getToken().getUnionId()) + .eq(Connect::getUnionType, authUser.getSource()); + } else { + //使用OpenID登录 + SourceEnum sourceEnum = SourceEnum.getSourceEnum(authUser.getSource(), authUser.getType()); + queryWrapper.eq(Connect::getUnionId, authUser.getUuid()) + .eq(Connect::getUnionType, sourceEnum.name()); + } - //查询绑定关系 - Connect connect = this.getOne(queryWrapper); - Member member = new Member(); - if (connect == null) { - member = memberService.autoRegister(authUser); - } else { - //查询会员 - member = memberService.getById(connect.getUserId()); - //如果未绑定会员,则把刚才查询到的联合登录表数据删除 - if (member == null) { - this.remove(queryWrapper); + //查询绑定关系 + Connect connect = this.getOne(queryWrapper); + + if (connect == null) { member = memberService.autoRegister(authUser); + } else { + //查询会员 + member = memberService.getById(connect.getUserId()); + //如果未绑定会员,则把刚才查询到的联合登录表数据删除 + if (member == null) { + this.remove(queryWrapper); + member = memberService.autoRegister(authUser); + } } } From 25240f445d18c7d38cbcf4b6697c7b29bf6857c4 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Tue, 25 Apr 2023 18:40:39 +0800 Subject: [PATCH 08/25] =?UTF-8?q?fix:=E9=98=BF=E9=87=8C=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E4=BC=A0source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/connect/request/BaseAuthAlipayRequest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthAlipayRequest.java b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthAlipayRequest.java index 911811ad..92c37522 100644 --- a/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthAlipayRequest.java +++ b/framework/src/main/java/cn/lili/modules/connect/request/BaseAuthAlipayRequest.java @@ -12,6 +12,8 @@ import cn.lili.modules.connect.entity.dto.AuthToken; import cn.lili.modules.connect.entity.dto.ConnectAuthUser; import cn.lili.modules.connect.entity.enums.AuthResponseStatus; import cn.lili.modules.connect.entity.enums.AuthUserGender; +import cn.lili.modules.connect.entity.enums.ConnectEnum; +import cn.lili.modules.connect.entity.enums.SourceEnum; import cn.lili.modules.connect.exception.AuthException; import com.alibaba.fastjson.JSONObject; import com.alipay.api.AlipayApiException; @@ -119,7 +121,7 @@ public class BaseAuthAlipayRequest extends BaseAuthRequest { .location(location) .gender(AuthUserGender.getRealGender(response.getGender())) .token(authToken) - .source(source.toString()) + .source(ConnectEnum.ALIPAY) .build(); } From 072d31e8df8a8cb9710dcbdce4efda61a3729f23 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Wed, 26 Apr 2023 05:58:56 +0800 Subject: [PATCH 09/25] =?UTF-8?q?fix:=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=99=BB=E5=BD=95=E8=AE=B0=E5=BD=95=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/member/entity/dos/Member.java | 16 +--------------- .../member/serviceimpl/MemberServiceImpl.java | 6 +++--- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dos/Member.java b/framework/src/main/java/cn/lili/modules/member/entity/dos/Member.java index 964d3f66..b39565fc 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dos/Member.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dos/Member.java @@ -110,7 +110,7 @@ public class Member extends BaseEntity { this.lastLoginDate = new Date(); } - public Member(String username, String password, String mobile, String nickName, String face) { + public Member(String username, String password, String face, String nickName, Integer sex,String mobile) { this.username = username; this.password = password; this.mobile = mobile; @@ -118,20 +118,6 @@ public class Member extends BaseEntity { this.disabled = true; this.haveStore = false; this.face = face; - this.sex = 0; - this.point = 0L; - this.totalPoint = 0L; - this.lastLoginDate = new Date(); - } - - public Member(String username, String password, String face, String nickName, Integer sex) { - this.username = username; - this.password = password; - this.mobile = ""; - this.nickName = nickName; - this.disabled = true; - this.haveStore = false; - this.face = face; this.sex = sex; this.point = 0L; this.totalPoint = 0L; 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 a798bc4d..3407253e 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 @@ -247,9 +247,9 @@ public class MemberServiceImpl extends ServiceImpl impleme authUser.setAvatar("https://i.loli.net/2020/11/19/LyN6JF7zZRskdIe.png"); } try { - String username = UuidUtils.getUUID(); - Member member = new Member(username, UuidUtils.getUUID(), authUser.getAvatar(), authUser.getNickname(), - authUser.getGender() != null ? Convert.toInt(authUser.getGender().getCode()) : 0); +// String username = UuidUtils.getUUID(); + Member member = new Member(authUser.getUsername(), UuidUtils.getUUID(), authUser.getAvatar(), authUser.getNickname(), + authUser.getGender() != null ? Convert.toInt(authUser.getGender().getCode()) : 0,authUser.getPhone()); member.setPassword(DEFAULT_PASSWORD); // 发送会员注册信息 registerHandler(member); From dcf48db2acc60d9cb4bcaeca1dd4b82ce248e041 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Fri, 28 Apr 2023 08:47:09 +0800 Subject: [PATCH 10/25] =?UTF-8?q?fix:=E7=94=A8=E6=88=B7=E5=90=8E=E6=9C=9F?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=99=BB=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E5=AD=98=E7=94=A8=E6=88=B7=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/event/impl/MemberExecute.java | 4 ++++ .../cn/lili/modules/member/service/MemberService.java | 8 ++++++++ .../modules/member/serviceimpl/MemberServiceImpl.java | 9 +++++++++ 3 files changed, 21 insertions(+) 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 838a097e..426c5817 100644 --- a/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/MemberExecute.java @@ -49,6 +49,10 @@ public class MemberExecute implements MemberLoginEvent, MemberConnectLoginEvent SourceEnum sourceEnum = SourceEnum.getSourceEnum(authUser.getSource(), authUser.getType()); connectService.loginBindUser(member.getId(), authUser.getUuid(), sourceEnum.name()); } + //保存手机号,判断用户是否存手机号,如果不存在则保存手机号 + if (StrUtil.isNotBlank(authUser.getPhone())&&StrUtil.isBlank(member.getMobile())) { + memberService.changeMobile(member.getId(),member.getMobile()); + } } } 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 430bb1d6..7b777646 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 @@ -147,6 +147,14 @@ public interface MemberService extends IService { */ boolean changeMobile(String mobile); + /** + * 修改用户手机号 + * @param memberId 会员ID + * @param mobile 手机号 + * @return + */ + boolean changeMobile(String memberId,String mobile); + /** * 通过手机号修改密码 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 3407253e..21f19dee 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 @@ -431,6 +431,15 @@ public class MemberServiceImpl extends ServiceImpl impleme return this.update(lambdaUpdateWrapper); } + @Override + public boolean changeMobile(String memberId, String mobile) { + //修改会员手机号 + LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); + lambdaUpdateWrapper.eq(Member::getId, memberId); + lambdaUpdateWrapper.set(Member::getMobile, mobile); + return this.update(lambdaUpdateWrapper); + } + @Override public boolean resetByMobile(String uuid, String password) { String phone = cache.get(CachePrefix.FIND_MOBILE + uuid).toString(); From 948b67558a51779a6d1f6c720363e5b44cbc40c2 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Fri, 5 May 2023 07:12:39 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F/=E5=85=AC=E4=BC=97=E5=8F=B7=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/WechatMessageExecute.java | 1 - .../serviceimpl/ConnectServiceImpl.java | 2 +- .../wechat/util/WechatMessageUtil.java | 169 +++++++++--------- 3 files changed, 90 insertions(+), 82 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/WechatMessageExecute.java b/consumer/src/main/java/cn/lili/event/impl/WechatMessageExecute.java index 58fd2e27..acb730e8 100644 --- a/consumer/src/main/java/cn/lili/event/impl/WechatMessageExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/WechatMessageExecute.java @@ -39,7 +39,6 @@ public class WechatMessageExecute implements OrderStatusChangeEvent, TradeEvent public void orderChange(OrderMessage orderMessage) { switch (orderMessage.getNewStatus()) { - case PAID: case UNDELIVERED: case DELIVERED: case STAY_PICKED_UP: 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 9e575b82..260e1b34 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 @@ -217,7 +217,7 @@ public class ConnectServiceImpl extends ServiceImpl impl connectQueryDTO.getUnionType()) .eq(CharSequenceUtil.isNotEmpty(connectQueryDTO.getUnionId()), Connect::getUnionId, connectQueryDTO.getUnionId()); - return this.getOne(queryWrapper); + return this.getOne(queryWrapper,false); } @Override diff --git a/framework/src/main/java/cn/lili/modules/wechat/util/WechatMessageUtil.java b/framework/src/main/java/cn/lili/modules/wechat/util/WechatMessageUtil.java index 487bffe3..0ea798f6 100644 --- a/framework/src/main/java/cn/lili/modules/wechat/util/WechatMessageUtil.java +++ b/framework/src/main/java/cn/lili/modules/wechat/util/WechatMessageUtil.java @@ -9,7 +9,6 @@ import cn.lili.common.exception.ServiceException; import cn.lili.common.utils.DateUtil; import cn.lili.common.utils.StringUtils; import cn.lili.modules.connect.entity.Connect; -import cn.lili.modules.connect.entity.enums.ConnectEnum; import cn.lili.modules.connect.entity.enums.SourceEnum; import cn.lili.modules.connect.service.ConnectService; import cn.lili.modules.member.entity.dto.ConnectQueryDTO; @@ -79,47 +78,54 @@ public class WechatMessageUtil { if (order == null) { throw new ServiceException("订单" + sn + "不存在,发送微信公众号消息错误"); } - //获取微信消息 - LambdaQueryWrapper wechatMessageQueryWrapper = new LambdaQueryWrapper(); - wechatMessageQueryWrapper.eq(WechatMessage::getOrderStatus, order.getOrderStatus()); - WechatMessage wechatMessage = wechatMessageService.getOne(wechatMessageQueryWrapper); - if (wechatMessage == null) { - return; - } + if (ClientTypeEnum.H5.name().equals(order.getClientType())) { + //获取微信消息 + LambdaQueryWrapper wechatMessageQueryWrapper = new LambdaQueryWrapper(); + wechatMessageQueryWrapper.eq(WechatMessage::getOrderStatus, order.getOrderStatus()); + WechatMessage wechatMessage = wechatMessageService.getOne(wechatMessageQueryWrapper); - Connect connect = connectService.queryConnect( - ConnectQueryDTO.builder().userId(order.getMemberId()).unionType(ConnectEnum.WECHAT.name()).build() - ); - if (connect == null) { - return; - } + if (wechatMessage == null) { + log.error("未配置微信公众号消息"); + return; + } - log.info("微信消息发送消息:{}", order.getMemberId() + "-" + sn); - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5); + Connect connect = connectService.queryConnect( + ConnectQueryDTO.builder() + .userId(order.getMemberId()) + .unionType(SourceEnum.WECHAT_OFFIACCOUNT_OPEN_ID.name()) + .build() + ); + if (connect == null) { + return; + } - //发送url - String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token; + log.info("微信消息发送消息:{}", order.getMemberId() + "-" + sn); + //获取token + String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5); - Map map = new HashMap<>(4); - //用户id - map.put("touser", connect.getUnionId()); - //模版id - map.put("template_id", wechatMessage.getCode()); - //模版中所需数据 - map.put("data", createData(order, wechatMessage)); + //发送url + String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token; - log.info("参数内容:" + JSONUtil.toJsonStr(map)); - String content = HttpUtil.post(url, JSONUtil.toJsonStr(map)); - JSONObject json = new JSONObject(content); - log.info("微信消息发送结果:" + content); - String errorMessage = json.getStr("errmsg"); - String errcode = json.getStr("errcode"); - //发送失败 - if (!"0".equals(errcode)) { - log.error("消息发送失败:" + errorMessage); - log.error("消息发送请求token:" + token); - log.error("消息发送请求:" + map.get("data")); + Map map = new HashMap<>(4); + //用户id + map.put("touser", connect.getUnionId()); + //模版id + map.put("template_id", wechatMessage.getCode()); + //模版中所需数据 + map.put("data", createData(order, wechatMessage)); + + log.info("参数内容:" + JSONUtil.toJsonStr(map)); + String content = HttpUtil.post(url, JSONUtil.toJsonStr(map)); + JSONObject json = new JSONObject(content); + log.info("微信消息发送结果:" + content); + String errorMessage = json.getStr("errmsg"); + String errcode = json.getStr("errcode"); + //发送失败 + if (!"0".equals(errcode)) { + log.error("消息发送失败:" + errorMessage); + log.error("消息发送请求token:" + token); + log.error("消息发送请求:" + map.get("data")); + } } } @@ -135,53 +141,56 @@ public class WechatMessageUtil { if (order == null) { throw new ServiceException("订单" + sn + "不存在,发送订阅消息错误"); } - //获取微信消息 - LambdaQueryWrapper wechatMPMessageQueryWrapper = new LambdaQueryWrapper(); - wechatMPMessageQueryWrapper.eq(WechatMPMessage::getOrderStatus, order.getOrderStatus()); - WechatMPMessage wechatMPMessage = wechatMPMessageService.getOne(wechatMPMessageQueryWrapper); - if (wechatMPMessage == null) { - log.info("未配置微信消息订阅"); - return; - } + if (ClientTypeEnum.WECHAT_MP.name().equals(order.getClientType())) { - Connect connect = connectService.queryConnect( - ConnectQueryDTO.builder().userId(order.getMemberId()).unionType(SourceEnum.WECHAT_MP_OPEN_ID.name()).build() - ); - if (connect == null) { - return; - } + //获取微信消息 + LambdaQueryWrapper wechatMPMessageQueryWrapper = new LambdaQueryWrapper(); + wechatMPMessageQueryWrapper.eq(WechatMPMessage::getOrderStatus, order.getOrderStatus()); + WechatMPMessage wechatMPMessage = wechatMPMessageService.getOne(wechatMPMessageQueryWrapper); + if (wechatMPMessage == null) { + log.info("未配置微信消息订阅"); + return; + } - log.info("微信消息订阅消息发送:{}", order.getMemberId() + "-" + sn); - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); + Connect connect = connectService.queryConnect( + ConnectQueryDTO.builder().userId(order.getMemberId()).unionType(SourceEnum.WECHAT_MP_OPEN_ID.name()).build() + ); + if (connect == null) { + return; + } - //发送url - String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + token; + log.info("微信消息订阅消息发送:{}", order.getMemberId() + "-" + sn); + //获取token + String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); - Map map = new HashMap<>(4); - //用户id - map.put("touser", connect.getUnionId()); - //模版id - map.put("template_id", wechatMPMessage.getCode()); - //模版中所需数据 - map.put("data", createData(order, wechatMPMessage)); - map.put("page", "pages/order/orderDetail?sn=" + order.getSn()); - log.info("参数内容:" + JSONUtil.toJsonStr(map)); - String content = null; - try { - content = HttpUtil.post(url, JSONUtil.toJsonStr(map)); - } catch (Exception e) { - log.error("微信消息发送错误", e); - } - JSONObject json = new JSONObject(content); - log.info("微信消息发送结果:" + content); - String errorMessage = json.getStr("errmsg"); - String errcode = json.getStr("errcode"); - //发送失败 - if (!"0".equals(errcode)) { - log.error("消息发送失败:" + errorMessage); - log.error("消息发送请求token:" + token); - log.error("消息发送请求:" + map.get("data")); + //发送url + String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + token; + + Map map = new HashMap<>(4); + //用户id + map.put("touser", connect.getUnionId()); + //模版id + map.put("template_id", wechatMPMessage.getCode()); + //模版中所需数据 + map.put("data", createData(order, wechatMPMessage)); + map.put("page", "pages/order/orderDetail?sn=" + order.getSn()); + log.info("参数内容:" + JSONUtil.toJsonStr(map)); + String content = null; + try { + content = HttpUtil.post(url, JSONUtil.toJsonStr(map)); + } catch (Exception e) { + log.error("微信消息发送错误", e); + } + JSONObject json = new JSONObject(content); + log.info("微信小程序消息发送结果:" + content); + String errorMessage = json.getStr("errmsg"); + String errcode = json.getStr("errcode"); + //发送失败 + if (!"0".equals(errcode)) { + log.error("消息发送失败:" + errorMessage); + log.error("消息发送请求token:" + token); + log.error("消息发送请求:" + map.get("data")); + } } } From 621b2e322c4bf404aa9faae6bdfc15dbcf078cd8 Mon Sep 17 00:00:00 2001 From: chc <1501738723@qq.com> Date: Fri, 5 May 2023 13:40:38 +0800 Subject: [PATCH 12/25] =?UTF-8?q?fix:=20=E5=BF=AB=E9=80=92=E9=B8=9F?= =?UTF-8?q?=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/logistics/plugin/kdniao/KdniaoPlugin.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/logistics/plugin/kdniao/KdniaoPlugin.java b/framework/src/main/java/cn/lili/modules/logistics/plugin/kdniao/KdniaoPlugin.java index 4b567388..9e022575 100644 --- a/framework/src/main/java/cn/lili/modules/logistics/plugin/kdniao/KdniaoPlugin.java +++ b/framework/src/main/java/cn/lili/modules/logistics/plugin/kdniao/KdniaoPlugin.java @@ -200,8 +200,9 @@ public class KdniaoPlugin implements LogisticsPlugin { JSONObject obj = JSONObject.parseObject(result); log.info("电子面单响应:{}", result); if (!"100".equals(obj.getString("ResultCode"))) { - resultMap.put("Reason",obj.getString("Reason")); - return resultMap; +// resultMap.put("Reason",obj.getString("Reason")); + throw new ServiceException(obj.getString("Reason")); +// return resultMap; } JSONObject orderJson = JSONObject.parseObject(obj.getString("Order")); From 74941f7243b783cdf9dcad6b6a9ad75df0e8e5c9 Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Sat, 6 May 2023 16:32:42 +0800 Subject: [PATCH 13/25] =?UTF-8?q?feat:=20=E5=85=BC=E5=AE=B9=E6=8F=90?= =?UTF-8?q?=E7=8E=B0=E5=A4=B1=E8=B4=A5=E5=9C=BA=E6=99=AF=EF=BC=8C=E5=AF=B9?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=B6=88=E6=81=AF=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/version4.2.5toMASTER.sql | 1 + .../lili/event/impl/MemberWalletExecute.java | 10 +++++--- .../modules/payment/kit/CashierSupport.java | 3 ++- .../cn/lili/modules/payment/kit/Payment.java | 3 ++- .../kit/plugin/alipay/AliPayPlugin.java | 15 +++++++----- .../kit/plugin/wechat/WechatPlugin.java | 22 ++++++++++------- .../entity/dos/MemberWithdrawApply.java | 6 +++++ .../wallet/entity/dto/TransferResultDTO.java | 24 +++++++++++++++++++ .../wallet/service/MemberWalletService.java | 4 +--- .../serviceimpl/MemberWalletServiceImpl.java | 16 ++++++------- 10 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/wallet/entity/dto/TransferResultDTO.java diff --git a/DB/version4.2.5toMASTER.sql b/DB/version4.2.5toMASTER.sql index 2225ac59..8170a2c5 100644 --- a/DB/version4.2.5toMASTER.sql +++ b/DB/version4.2.5toMASTER.sql @@ -88,3 +88,4 @@ ALTER TABLE li_foot_print ADD `store_id` varchar(255) DEFAULT NULL COMMENT '店 */ ALTER TABLE li_member_withdraw_apply ADD `real_name` varchar(255) DEFAULT NULL; ALTER TABLE li_member_withdraw_apply ADD `connect_number` varchar(255) DEFAULT NULL; +ALTER TABLE li_member_withdraw_apply ADD `error_message` text DEFAULT NULL; diff --git a/consumer/src/main/java/cn/lili/event/impl/MemberWalletExecute.java b/consumer/src/main/java/cn/lili/event/impl/MemberWalletExecute.java index b2fbf5b8..b836b591 100644 --- a/consumer/src/main/java/cn/lili/event/impl/MemberWalletExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/MemberWalletExecute.java @@ -31,15 +31,19 @@ public class MemberWalletExecute implements MemberWithdrawalEvent { case SUCCESS: //提现成功扣减冻结金额 memberWalletService.reduceFrozen( - new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "提现成功,余额提现", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name())); + new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "提现成功,余额提现", + DepositServiceTypeEnum.WALLET_WITHDRAWAL.name())); break; case ERROR: //需要从冻结金额扣减到余额 - memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "提现失败,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name())); + memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), + memberWithdrawalMessage.getMemberId(), "第三方提现失败,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name())); break; case FAIL_AUDITING: //需要从冻结金额扣减到余额 - memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "审核拒绝,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name())); + memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), + memberWithdrawalMessage.getMemberId(), "审核拒绝,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name())); + break; default: break; } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/CashierSupport.java b/framework/src/main/java/cn/lili/modules/payment/kit/CashierSupport.java index e9dca0f8..77f6454a 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/CashierSupport.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/CashierSupport.java @@ -19,6 +19,7 @@ import cn.lili.modules.system.entity.dto.payment.dto.PaymentSupportItem; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply; +import cn.lili.modules.wallet.entity.dto.TransferResultDTO; import cn.lili.modules.wallet.service.MemberWalletService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -149,7 +150,7 @@ public class CashierSupport { * @param paymentMethodEnum 支付渠道 * @param memberWithdrawApply 用户提现申请 */ - public boolean transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply) { + public TransferResultDTO transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply) { Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin()); return payment.transfer(memberWithdrawApply); } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java b/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java index bb96c3e9..c0b92fa7 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java @@ -7,6 +7,7 @@ import cn.lili.modules.payment.entity.RefundLog; import cn.lili.modules.payment.entity.enums.PaymentMethodEnum; import cn.lili.modules.payment.kit.dto.PayParam; import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply; +import cn.lili.modules.wallet.entity.dto.TransferResultDTO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -114,7 +115,7 @@ public interface Payment { /** * 提现 */ - default boolean transfer(MemberWithdrawApply memberWithdrawApply) { + default TransferResultDTO transfer(MemberWithdrawApply memberWithdrawApply) { throw new ServiceException(ResultCode.PAY_ERROR); } 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 f40f277f..1688f519 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 @@ -27,6 +27,7 @@ import cn.lili.modules.system.entity.dto.payment.AlipayPaymentSetting; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply; +import cn.lili.modules.wallet.entity.dto.TransferResultDTO; import com.alibaba.fastjson.JSONObject; import com.alipay.api.AlipayApiException; import com.alipay.api.domain.*; @@ -170,7 +171,8 @@ public class AliPayPlugin implements Payment { payModel.setTimeoutExpress("3m"); payModel.setOutTradeNo(outTradeNo); log.info("支付宝扫码:{}", payModel); - String resultStr = AliPayRequest.tradePrecreatePayToResponse(payModel, notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)).getBody(); + String resultStr = + AliPayRequest.tradePrecreatePayToResponse(payModel, notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)).getBody(); log.info("支付宝扫码交互返回:{}", resultStr); JSONObject jsonObject = JSONObject.parseObject(resultStr); @@ -202,7 +204,8 @@ public class AliPayPlugin implements Payment { refundLog.setIsRefund(true); refundLog.setReceivableNo(refundLog.getOutOrderNo()); } else { - refundLog.setErrorMessage(String.format("错误码:%s,错误原因:%s", alipayTradeRefundResponse.getSubCode(), alipayTradeRefundResponse.getSubMsg())); + refundLog.setErrorMessage(String.format("错误码:%s,错误原因:%s", alipayTradeRefundResponse.getSubCode(), + alipayTradeRefundResponse.getSubMsg())); } refundLogService.save(refundLog); } catch (Exception e) { @@ -237,7 +240,7 @@ public class AliPayPlugin implements Payment { * @param memberWithdrawApply 会员提现申请 */ @Override - public boolean transfer(MemberWithdrawApply memberWithdrawApply) { + public TransferResultDTO transfer(MemberWithdrawApply memberWithdrawApply) { AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel(); model.setOutBizNo(SnowFlake.createStr("T")); model.setRemark("用户提现"); @@ -257,15 +260,15 @@ public class AliPayPlugin implements Payment { AlipayFundTransUniTransferResponse alipayFundTransUniTransferResponse = AliPayApi.uniTransferToResponse(model, null); log.error("支付宝退款,参数:{},支付宝响应:{}", JSONUtil.toJsonStr(model), JSONUtil.toJsonStr(alipayFundTransUniTransferResponse)); if (alipayFundTransUniTransferResponse.isSuccess()) { - return true; + return TransferResultDTO.builder().result(true).build(); } else { log.error(alipayFundTransUniTransferResponse.getSubMsg()); + return TransferResultDTO.builder().result(false).response(alipayFundTransUniTransferResponse.getSubMsg()).build(); } } catch (Exception e) { log.error("用户提现异常:", e); - throw new ServiceException(ResultCode.PAY_ERROR); + return TransferResultDTO.builder().result(false).response(e.getMessage()).build(); } - return false; } /** 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 13617a89..94ce4589 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 @@ -17,7 +17,6 @@ import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.connect.entity.Connect; -import cn.lili.modules.connect.entity.enums.ConnectEnum; import cn.lili.modules.connect.entity.enums.SourceEnum; import cn.lili.modules.connect.service.ConnectService; import cn.lili.modules.member.entity.dto.ConnectQueryDTO; @@ -47,10 +46,10 @@ import cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply; +import cn.lili.modules.wallet.entity.dto.TransferResultDTO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.ss.formula.atp.Switch; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -481,13 +480,15 @@ public class WechatPlugin implements Payment { * @param memberWithdrawApply 会员提现申请 */ @Override - public boolean transfer(MemberWithdrawApply memberWithdrawApply) { + public TransferResultDTO transfer(MemberWithdrawApply memberWithdrawApply) { try { //获取提现设置 - WithdrawalSetting withdrawalSetting = new Gson().fromJson(settingService.get(SettingEnum.WITHDRAWAL_SETTING.name()).getSettingValue(), WithdrawalSetting.class); + WithdrawalSetting withdrawalSetting = new Gson().fromJson(settingService.get(SettingEnum.WITHDRAWAL_SETTING.name()).getSettingValue(), + WithdrawalSetting.class); //获取用户OPENID - WechatConnectSetting wechatConnectSetting = new Gson().fromJson(settingService.get(SettingEnum.WECHAT_CONNECT.name()).getSettingValue(), WechatConnectSetting.class); + WechatConnectSetting wechatConnectSetting = new Gson().fromJson(settingService.get(SettingEnum.WECHAT_CONNECT.name()).getSettingValue() + , WechatConnectSetting.class); String source = ""; for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) { if (wechatConnectSettingItem.getAppId().equals(withdrawalSetting.getWechatAppId())) { @@ -548,12 +549,13 @@ public class WechatPlugin implements Payment { log.info("微信提现响应 {}", response); String body = response.getBody(); JSONObject jsonObject = JSONUtil.parseObj(body); - return jsonObject.getStr("batch_id") != null ? true : false; + + return TransferResultDTO.builder().result(jsonObject.getStr("batch_id") != null).response(body).build(); //根据自身业务进行接下来的任务处理 } catch (Exception e) { e.printStackTrace(); + return TransferResultDTO.builder().result(false).response(e.getMessage()).build(); } - return false; } @@ -670,7 +672,8 @@ public class WechatPlugin implements Payment { String transactionId = jsonObject.getStr("transaction_id"); String refundId = jsonObject.getStr("refund_id"); - RefundLog refundLog = refundLogService.getOne(new LambdaQueryWrapper().eq(RefundLog::getPaymentReceivableNo, transactionId)); + RefundLog refundLog = refundLogService.getOne(new LambdaQueryWrapper().eq(RefundLog::getPaymentReceivableNo, + transactionId)); if (refundLog != null) { refundLog.setIsRefund(true); refundLog.setReceivableNo(refundId); @@ -683,7 +686,8 @@ public class WechatPlugin implements Payment { String transactionId = jsonObject.getStr("transaction_id"); String refundId = jsonObject.getStr("refund_id"); - RefundLog refundLog = refundLogService.getOne(new LambdaQueryWrapper().eq(RefundLog::getPaymentReceivableNo, transactionId)); + RefundLog refundLog = refundLogService.getOne(new LambdaQueryWrapper().eq(RefundLog::getPaymentReceivableNo, + transactionId)); if (refundLog != null) { refundLog.setReceivableNo(refundId); refundLog.setErrorMessage(ciphertext.getStr("summary")); diff --git a/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java b/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java index cb5ee344..ac54ce73 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java +++ b/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java @@ -67,4 +67,10 @@ public class MemberWithdrawApply extends BaseEntity { @ApiModelProperty(value = "第三方平台账号") private String connectNumber; + /** + * 支付宝登录账号 + */ + @ApiModelProperty(value = "第三方错误消息") + private String errorMessage; + } diff --git a/framework/src/main/java/cn/lili/modules/wallet/entity/dto/TransferResultDTO.java b/framework/src/main/java/cn/lili/modules/wallet/entity/dto/TransferResultDTO.java new file mode 100644 index 00000000..fb672a1c --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/wallet/entity/dto/TransferResultDTO.java @@ -0,0 +1,24 @@ +package cn.lili.modules.wallet.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +/** + * 转账结果 + * + * @author liushuai(liushuai711 @ gmail.com) + * @version v4.0 + * @Description: + * @since 2023/5/6 16:10 + */ +@Data +@Builder +public class TransferResultDTO { + + @ApiModelProperty(value = "错误信息") + private String response; + @ApiModelProperty(value = "是否成功") + private Boolean result; + +} diff --git a/framework/src/main/java/cn/lili/modules/wallet/service/MemberWalletService.java b/framework/src/main/java/cn/lili/modules/wallet/service/MemberWalletService.java index c0b0c416..4b3a9349 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/service/MemberWalletService.java +++ b/framework/src/main/java/cn/lili/modules/wallet/service/MemberWalletService.java @@ -6,7 +6,6 @@ import cn.lili.modules.wallet.entity.dos.MemberWallet; import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO; import cn.lili.modules.wallet.entity.vo.MemberWalletVO; import com.baomidou.mybatisplus.extension.service.IService; -import org.springframework.web.bind.annotation.RequestParam; /** * 会员预存款业务层 @@ -102,8 +101,7 @@ public interface MemberWalletService extends IService { * 提现公共方法 * * @param withdrawApplyId 会员零钱提现Id - * @return 操作状态 */ - Boolean withdrawal(String withdrawApplyId); + void withdrawal(String withdrawApplyId); } \ No newline at end of file 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 f2943876..ac0c65e0 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 @@ -22,6 +22,7 @@ import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply; import cn.lili.modules.wallet.entity.dos.WalletLog; import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO; import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage; +import cn.lili.modules.wallet.entity.dto.TransferResultDTO; import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum; import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum; import cn.lili.modules.wallet.entity.vo.MemberWalletVO; @@ -312,7 +313,7 @@ public class MemberWalletServiceImpl extends ServiceImpl Date: Mon, 8 May 2023 17:37:29 +0800 Subject: [PATCH 14/25] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96es=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=B4=A2=E5=BC=95sku=E5=8F=96=E5=88=86=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=B8=BA=E5=A4=8D=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/listener/GoodsMessageListener.java | 6 +++++- .../modules/search/serviceimpl/EsGoodsIndexServiceImpl.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 8661814d..8ed979cb 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -382,7 +382,11 @@ public class GoodsMessageListener implements RocketMQListener { List esGoodsIndices = new ArrayList<>(); for (GoodsSku goodsSku : goodsSkuList) { EsGoodsIndex goodsIndex = this.settingUpGoodsIndexData(goods, goodsSku); - goodsIndex.setSkuSource(skuSource--); + skuSource--; + if (skuSource <= 0) { + skuSource = 1; + } + goodsIndex.setSkuSource(skuSource); log.info("goodsSku:{}", goodsSku); log.info("生成商品索引 {}", goodsIndex); esGoodsIndices.add(goodsIndex); 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 6a77c8e5..32359149 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 @@ -235,6 +235,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements if (count >= 1) { skuSource -= count; } + if (skuSource <= 0) { + skuSource = 1; + } esGoodsIndex.setSkuSource(skuSource); From 5e6fde594b368b39b260a234505e7e952dca8329 Mon Sep 17 00:00:00 2001 From: chc <1501738723@qq.com> Date: Mon, 8 May 2023 17:59:01 +0800 Subject: [PATCH 15/25] =?UTF-8?q?fix:=20=E5=BA=97=E9=93=BA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=98=AF=E8=87=AA=E6=8F=90=E3=80=81=E6=A5=BC=E5=B1=82?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/store/entity/dos/Store.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java b/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java index ba05c5dc..6ff831b7 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java @@ -100,6 +100,20 @@ public class Store extends BaseEntity { @ApiModelProperty(value = "udesk IM标识") private String merchantEuid; + public Boolean getPageShow() { + if(pageShow == null){ + return false; + } + return pageShow; + } + + public Boolean getSelfPickFlag() { + if(selfPickFlag == null){ + return false; + } + return selfPickFlag; + } + @ApiModelProperty(value = "默认页面是否开启") private Boolean pageShow; @@ -116,6 +130,8 @@ public class Store extends BaseEntity { descriptionScore = 5.0; goodsNum = 0; collectionNum = 0; + this.selfPickFlag = false; + this.pageShow = false; } public Store(Member member, AdminStoreApplyDTO adminStoreApplyDTO) { @@ -130,6 +146,8 @@ public class Store extends BaseEntity { descriptionScore = 5.0; goodsNum = 0; collectionNum = 0; + this.selfPickFlag = false; + this.pageShow = false; } } \ No newline at end of file From 49b2c2f7a30462a122d61797aa1c234caa4ce68e Mon Sep 17 00:00:00 2001 From: chc <1501738723@qq.com> Date: Mon, 8 May 2023 18:35:57 +0800 Subject: [PATCH 16/25] =?UTF-8?q?fix:=20=E5=AF=BC=E5=85=A5=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=A2=9E=E5=8A=A0=E5=A1=AB=E5=86=99=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/GoodsImportServiceImpl.java | 21 +++++++++++++------ .../goods/GoodsImportController.java | 12 +++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsImportServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsImportServiceImpl.java index d65e9afb..349ac5d9 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsImportServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsImportServiceImpl.java @@ -1,9 +1,11 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.convert.Convert; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelUtil; import cn.lili.common.exception.ServiceException; +import cn.lili.common.security.context.UserContext; import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.dos.GoodsUnit; import cn.lili.modules.goods.entity.dto.GoodsImportDTO; @@ -31,10 +33,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Slf4j @Service @@ -51,10 +50,12 @@ public class GoodsImportServiceImpl implements GoodsImportService { @Autowired private GoodsService goodsService; + private static final int COLUMS = 15; + @Override public void download(HttpServletResponse response) { - String storeId = "1376369067769724928"; -// //Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId(); +// String storeId = "1376369067769724928"; + String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId(); //创建Excel工作薄对象 Workbook workbook = new HSSFWorkbook(); //生成一个表格 设置:页签 @@ -165,6 +166,14 @@ public class GoodsImportServiceImpl implements GoodsImportService { List> read = excelReader.read(1, excelReader.getRowCount()); for (List objects : read) { GoodsImportDTO goodsImportDTO = new GoodsImportDTO(); + if (objects.size() < COLUMS){ + throw new ServiceException("请将表格内容填写完全!"); + } + for (Object object : objects) { + if( CharSequenceUtil.isEmpty(object.toString()) || CharSequenceUtil.isBlank(object.toString())){ + throw new ServiceException("请将表格内容填写完全!"); + } + } String categoryId = objects.get(2).toString().substring(0, objects.get(2).toString().indexOf("-")); diff --git a/seller-api/src/main/java/cn/lili/controller/goods/GoodsImportController.java b/seller-api/src/main/java/cn/lili/controller/goods/GoodsImportController.java index 517751ae..a2110c7e 100644 --- a/seller-api/src/main/java/cn/lili/controller/goods/GoodsImportController.java +++ b/seller-api/src/main/java/cn/lili/controller/goods/GoodsImportController.java @@ -29,15 +29,9 @@ public class GoodsImportController { @PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @ApiOperation(value = "上传文件,商品批量添加") - public ResultMessage importExcel(@RequestPart("files") MultipartFile files) { - try { - goodsImportService.importExcel(files); - return ResultUtil.success(ResultCode.SUCCESS); - } catch (Exception e) { - e.printStackTrace(); - throw new ServiceException(ResultCode.ERROR); - } - + public ResultMessage importExcel(@RequestPart("files") MultipartFile files) throws Exception { + goodsImportService.importExcel(files); + return ResultUtil.success(ResultCode.SUCCESS); } From c286d05ad8a1a1adece4654beab48e14c1e562c8 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 8 May 2023 18:49:37 +0800 Subject: [PATCH 17/25] =?UTF-8?q?fix:=20=E4=BF=83=E9=94=80=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0=E5=92=8C=E6=BB=A1=E5=87=8F=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E8=8C=83=E5=9B=B4=E5=95=86=E5=93=81=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/cart/render/impl/FullDiscountRender.java | 4 ++++ .../promotion/serviceimpl/AbstractPromotionsServiceImpl.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java index 24618c4b..270caba9 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java @@ -16,6 +16,7 @@ import cn.lili.modules.order.cart.render.util.PromotionPriceUtil; import cn.lili.modules.order.order.entity.dto.DiscountPriceItem; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.promotion.entity.dos.FullDiscount; +import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -70,6 +71,9 @@ public class FullDiscountRender implements CartRenderStep { cart.setFullDiscount(fullDiscountVO); Map skuPriceDetail = new HashMap<>(16); for (CartSkuVO cartSkuVO : cart.getSkuList()) { + if (PromotionsScopeTypeEnum.PORTION_GOODS.name().equals(fullDiscountVO.getScopeType()) && fullDiscountVO.getScopeId() != null && !fullDiscountVO.getScopeId().contains(cartSkuVO.getGoodsSku().getId())) { + continue; + } skuPriceDetail.put(cartSkuVO.getGoodsSku().getId(), cartSkuVO.getPriceDetailDTO().getGoodsPrice()); } if (!skuPriceDetail.isEmpty()) { 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 3a16eb86..a92abfb5 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 @@ -112,9 +112,9 @@ public abstract class AbstractPromotionsServiceImpl, T e List promotionsList = this.list(new QueryWrapper().in("id", ids)); for (T t : promotionsList) { if (startTime != null && endTime != null) { - this.checkPromotions(t); t.setStartTime(new Date(startTime)); t.setEndTime(new Date(endTime)); + this.checkPromotions(t); } else { t.setStartTime(null); t.setEndTime(null); From ae93661763b266b6fef0bb40839100dc197f07ea Mon Sep 17 00:00:00 2001 From: misworga831 Date: Tue, 9 May 2023 13:59:23 +0800 Subject: [PATCH 18/25] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96es=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=A6=82=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E8=B6=85=E8=BF=8710000=E6=9D=A1=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseElasticsearchService.java | 1 + .../serviceimpl/EsGoodsIndexServiceImpl.java | 31 ++++++++++++++----- .../serviceimpl/EsGoodsSearchServiceImpl.java | 3 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index f5c9fb4f..7f08ddf7 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -90,6 +90,7 @@ public abstract class BaseElasticsearchService { request.settings(Settings.builder() .put("index.number_of_shards", elasticsearchProperties.getIndex().getNumberOfShards()) .put("index.number_of_replicas", elasticsearchProperties.getIndex().getNumberOfReplicas()) + .put("index.max_result_window", 100000) //最大查询结果数 .put("index.mapping.total_fields.limit", 2000)); //创建索引 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 32359149..e2c34666 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 @@ -66,6 +66,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.SearchHit; +import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.stereotype.Service; @@ -178,7 +179,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements skuCountQueryWrapper.eq("auth_flag", GoodsAuthEnum.PASS.name()); skuCountQueryWrapper.eq("market_enable", GoodsStatusEnum.UPPER.name()); skuCountQueryWrapper.eq("delete_flag", false); - skuCountQueryWrapper.ge("quantity", 0); + skuCountQueryWrapper.gt("quantity", 0); resultMap = new HashMap<>(); resultMap.put(KEY_SUCCESS, 0L); resultMap.put(KEY_FAIL, 0L); @@ -675,14 +676,30 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Override public void deleteEsGoodsPromotionByPromotionKey(String promotionsKey) { ThreadUtil.execAsync(() -> { - BulkRequest bulkRequest = new BulkRequest(); - for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { - UpdateRequest updateRequest = this.removePromotionByPromotionKey(goodsIndex, promotionsKey); - if (updateRequest != null) { - bulkRequest.add(updateRequest); + for (int i = 0; ; i++) { + BulkRequest bulkRequest = new BulkRequest(); + + NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder(); + nativeSearchQueryBuilder.withQuery(QueryBuilders.matchAllQuery()); + nativeSearchQueryBuilder.withPageable(PageRequest.of(i, 1000)); + try { + SearchHits esGoodsIndices = this.restTemplate.search(nativeSearchQueryBuilder.build(), EsGoodsIndex.class); + if (esGoodsIndices.isEmpty() || esGoodsIndices.getSearchHits().isEmpty()) { + break; + } + for (SearchHit searchHit : esGoodsIndices.getSearchHits()) { + EsGoodsIndex goodsIndex = searchHit.getContent(); + UpdateRequest updateRequest = this.removePromotionByPromotionKey(goodsIndex, promotionsKey); + if (updateRequest != null) { + bulkRequest.add(updateRequest); + } + } + this.executeBulkUpdateRequest(bulkRequest); + } catch (Exception e) { + log.error("删除索引中指定的促销活动id的促销活动失败!key: {}", promotionsKey, e); + return; } } - this.executeBulkUpdateRequest(bulkRequest); }); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 6078d77e..708400e7 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -84,11 +84,12 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { //如果搜索词不为空,且明显不是sql注入,那么就将搜索词加入热搜词 //PS:线上环境运行很多客户反馈被sql攻击,写在了搜索热词里,这里控制命中关键字就不做热词统计,如果线上比较严格可以调用关键词替换,不过不建议这么做 - if (CharSequenceUtil.isNotBlank(searchDTO.getKeyword()) && !SqlFilter.hit(searchDTO.getKeyword())) { + if (CharSequenceUtil.isNotBlank(searchDTO.getKeyword()) && Boolean.FALSE.equals(SqlFilter.hit(searchDTO.getKeyword()))) { cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), searchDTO.getKeyword()); } NativeSearchQueryBuilder searchQueryBuilder = createSearchQueryBuilder(searchDTO, pageVo); NativeSearchQuery searchQuery = searchQueryBuilder.build(); + searchQuery.setTrackTotalHits(true); log.debug("searchGoods DSL:{}", searchQuery.getQuery()); SearchHits search = restTemplate.search(searchQuery, EsGoodsIndex.class); return SearchHitSupport.searchPageFor(search, searchQuery.getPageable()); From a33e053bc73b628e6eaab6647c8c6d039b29fdac Mon Sep 17 00:00:00 2001 From: misworga831 Date: Tue, 9 May 2023 13:59:55 +0800 Subject: [PATCH 19/25] =?UTF-8?q?fix:=20=E7=89=B9=E6=AE=8A=E6=83=85?= =?UTF-8?q?=E5=86=B5=E5=A4=84=E7=90=86=EF=BC=8C=E5=A6=82=E5=8F=82=E4=B8=8E?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E4=BF=83=E9=94=80=E6=B4=BB=E5=8A=A8=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=95=86=E5=93=81=E5=9C=A8=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E4=BF=83=E9=94=80=E8=AE=A1=E7=AE=97=E5=90=8E=E7=9A=84=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=B8=8D=E8=B6=B3=E4=BB=A5=E6=BB=A1=E8=B6=B3=E4=B8=8E?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E5=8F=82=E4=B8=8E=E7=9A=84=E4=BF=83=E9=94=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=9A=84=E4=BC=98=E6=83=A0=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cart/render/util/PromotionPriceUtil.java | 176 ++++++++++++------ 1 file changed, 124 insertions(+), 52 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java index dc1c2348..f6e2a2aa 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java @@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 促销价格计算业务层实现 @@ -66,7 +67,7 @@ public class PromotionPriceUtil { List skuVOList = tradeDTO.getSkuList(); // 获取map分配sku的总数,如果是最后一个商品分配金额,则将金额从百分比改为总金额扣减,避免出现小数除不尽 - Integer count = skuPromotionDetail.size(); + int count = skuPromotionDetail.size(); //已优惠金额 Double deducted = 0D; @@ -81,12 +82,12 @@ public class PromotionPriceUtil { count--; //sku 优惠金额 - Double skuDiscountPrice = 0d; + Double skuDiscountPrice; //非最后一个商品,则按照比例计算 if (count > 0) { //商品金额占比 - Double point = CurrencyUtil.div(cartSkuVO.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4); + double point = CurrencyUtil.div(cartSkuVO.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4); //商品优惠金额 skuDiscountPrice = CurrencyUtil.mul(discountPrice, point); //累加已优惠金额 @@ -96,64 +97,135 @@ public class PromotionPriceUtil { else { skuDiscountPrice = CurrencyUtil.sub(discountPrice, deducted); } - //优惠券金额,则计入优惠券 ,其他则计入总的discount price - if (promotionTypeEnum == PromotionTypeEnum.COUPON) { - cartSkuVO.getPriceDetailDTO().setCouponPrice( - CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getCouponPrice(), skuDiscountPrice)); - - cartSkuVO.getPriceDetailDTO().addDiscountPriceItem( - DiscountPriceItem.builder() - .goodsId(cartSkuVO.getGoodsSku().getGoodsId()) - .skuId(cartSkuVO.getGoodsSku().getId()) - .discountPrice(skuDiscountPrice) - .promotionTypeEnum(PromotionTypeEnum.COUPON) - .promotionId(activityId) - .build() - ); - - } else if (promotionTypeEnum == PromotionTypeEnum.PLATFORM_COUPON) { - - cartSkuVO.getPriceDetailDTO().setSiteCouponPrice( - CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getCouponPrice(), skuDiscountPrice)); - - cartSkuVO.getPriceDetailDTO().setCouponPrice( - CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getCouponPrice(), cartSkuVO.getPriceDetailDTO().getSiteCouponPrice())); - - - cartSkuVO.getPriceDetailDTO().addDiscountPriceItem( - DiscountPriceItem.builder() - .goodsId(cartSkuVO.getGoodsSku().getGoodsId()) - .skuId(cartSkuVO.getGoodsSku().getId()) - .discountPrice(skuDiscountPrice) - .promotionTypeEnum(PromotionTypeEnum.PLATFORM_COUPON) - .promotionId(activityId) - .build() - ); - - } else { - cartSkuVO.getPriceDetailDTO().setDiscountPrice( - CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getDiscountPrice(), skuDiscountPrice)); - - //目前剩余的只有满减金额活动。后续如果需要调整,这里建议传递活动类型进来 - cartSkuVO.getPriceDetailDTO().addDiscountPriceItem( - DiscountPriceItem.builder() - .goodsId(cartSkuVO.getGoodsSku().getGoodsId()) - .skuId(cartSkuVO.getGoodsSku().getId()) - .discountPrice(skuDiscountPrice) - .promotionTypeEnum(PromotionTypeEnum.FULL_DISCOUNT) - .promotionId(activityId) - .build() - ); - } + calculateCartSkuPromotionsPrice(cartSkuVO, skuDiscountPrice, promotionTypeEnum, activityId); } } } + calculateNotEnoughPromotionsPrice(skuVOList, skuPromotionDetail, discountPrice, totalPrice, promotionTypeEnum, activityId); } + /** + * 计算购物车商品优惠金额 + * + * @param cartSkuVO 购物车商品 + * @param skuDiscountPrice 商品优惠金额 + * @param promotionTypeEnum 优惠类型 + * @param activityId 优惠活动id + */ + private static void calculateCartSkuPromotionsPrice(CartSkuVO cartSkuVO, Double skuDiscountPrice, PromotionTypeEnum promotionTypeEnum, String activityId) { + //优惠券金额,则计入优惠券 ,其他则计入总的discount price + if (promotionTypeEnum == PromotionTypeEnum.COUPON) { + + cartSkuVO.getPriceDetailDTO().setCouponPrice( + CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getCouponPrice(), skuDiscountPrice)); + + cartSkuVO.getPriceDetailDTO().addDiscountPriceItem( + DiscountPriceItem.builder() + .goodsId(cartSkuVO.getGoodsSku().getGoodsId()) + .skuId(cartSkuVO.getGoodsSku().getId()) + .discountPrice(skuDiscountPrice) + .promotionTypeEnum(PromotionTypeEnum.COUPON) + .promotionId(activityId) + .build() + ); + + } else if (promotionTypeEnum == PromotionTypeEnum.PLATFORM_COUPON) { + + cartSkuVO.getPriceDetailDTO().setSiteCouponPrice( + CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getCouponPrice(), skuDiscountPrice)); + + cartSkuVO.getPriceDetailDTO().setCouponPrice( + CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getCouponPrice(), cartSkuVO.getPriceDetailDTO().getSiteCouponPrice())); + + + cartSkuVO.getPriceDetailDTO().addDiscountPriceItem( + DiscountPriceItem.builder() + .goodsId(cartSkuVO.getGoodsSku().getGoodsId()) + .skuId(cartSkuVO.getGoodsSku().getId()) + .discountPrice(skuDiscountPrice) + .promotionTypeEnum(PromotionTypeEnum.PLATFORM_COUPON) + .promotionId(activityId) + .build() + ); + + } else { + cartSkuVO.getPriceDetailDTO().setDiscountPrice( + CurrencyUtil.add(cartSkuVO.getPriceDetailDTO().getDiscountPrice(), skuDiscountPrice)); + + //目前剩余的只有满减金额活动。后续如果需要调整,这里建议传递活动类型进来 + cartSkuVO.getPriceDetailDTO().addDiscountPriceItem( + DiscountPriceItem.builder() + .goodsId(cartSkuVO.getGoodsSku().getGoodsId()) + .skuId(cartSkuVO.getGoodsSku().getId()) + .discountPrice(skuDiscountPrice) + .promotionTypeEnum(PromotionTypeEnum.FULL_DISCOUNT) + .promotionId(activityId) + .build() + ); + } + } + + /** + * 特殊情况处理,如参与多个促销活动,部分商品在其他促销计算后的金额不足以满足与当前参与的促销活动的优惠金额 + * + * @param skuVOList 获取购物车信息 + * @param skuPromotionDetail 参与活动的商品,以及商品总金额 + * @param discountPrice 需要分发的优惠金额 + * @param totalPrice 计算总金额 + * @param promotionTypeEnum 优惠类型 + * @param activityId 优惠活动id + */ + private static void calculateNotEnoughPromotionsPrice(List skuVOList, Map skuPromotionDetail, Double discountPrice, Double totalPrice, PromotionTypeEnum promotionTypeEnum, String activityId) { + // 特殊情况处理,如参与多个促销活动,部分商品在其他促销计算后的金额不足以满足与当前参与的促销活动的优惠金额 + // 但当前购物车内存在当前当前促销活动的其他商品且剩余金额也满足分摊不足商品的不足金额,则分摊到其他商品上 + // 满足当前促销的总优惠金额 + if (skuPromotionDetail == null || skuPromotionDetail.isEmpty()) { + return; + } + long matchPromotionsZeroCount = skuVOList.stream().filter(l -> l.getPriceDetailDTO().getFlowPrice() == 0 && skuPromotionDetail.containsKey(l.getGoodsSku().getId())).count(); + long matchPromotionsCount = skuVOList.stream().filter(l -> skuPromotionDetail.containsKey(l.getGoodsSku().getId())).count(); + if (matchPromotionsZeroCount == matchPromotionsCount) { + return; + } + // 获取剩余金额不足优惠金额的商品 + List unEnoughSku = skuVOList.stream().filter(k -> { + if (skuPromotionDetail.containsKey(k.getGoodsSku().getId()) && skuPromotionDetail.size() >= 2) { + //商品金额占比 + double point = CurrencyUtil.div(k.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4); + //商品优惠金额 + Double skuDiscountPrice = CurrencyUtil.mul(discountPrice, point); + return skuDiscountPrice > k.getPriceDetailDTO().getCouponPrice(); + } + return false; + }).collect(Collectors.toList()); + if (!unEnoughSku.isEmpty()) { + for (CartSkuVO cartSkuVO : skuVOList) { + if (unEnoughSku.isEmpty()) { + return; + } + if (skuPromotionDetail.containsKey(cartSkuVO.getGoodsSku().getId()) && unEnoughSku.stream().noneMatch(k -> k.getGoodsSku().getId().equals(cartSkuVO.getGoodsSku().getId()))) { + // 商品金额占比 + double point = CurrencyUtil.div(cartSkuVO.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4); + // 商品优惠金额 + Double skuDiscountPrice = CurrencyUtil.mul(discountPrice, point); + // 商品优惠金额 - 不足优惠金额 = 差额 + Double sub = CurrencyUtil.sub(skuDiscountPrice, unEnoughSku.get(0).getPriceDetailDTO().getCouponPrice()); + // 分摊到其他商品: 其他商品原优惠金额 + 差额 + calculateCartSkuPromotionsPrice(cartSkuVO, sub, promotionTypeEnum, activityId); + // 从不足商品列表中移除 + unEnoughSku.remove(0); + } + } + } else { + return; + } + calculateNotEnoughPromotionsPrice(skuVOList, skuPromotionDetail, discountPrice, totalPrice, promotionTypeEnum, activityId); + } + /** * 检查活动有效时间 * From b4aef1461cfe01b6ada5b42ba7a6e7f5320ca525 Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Wed, 10 May 2023 14:03:16 +0800 Subject: [PATCH 20/25] =?UTF-8?q?fix:=20=E8=AE=A2=E5=8D=95=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=9E=81=E7=AB=AF=E6=83=85=E5=86=B5=EF=BC=8C=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E4=B8=9A=E5=8A=A1=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E5=81=9A=E4=B8=80=E4=B8=8B=E5=85=BC=E5=AE=B9=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=85=8D=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=AE=A2=E5=8D=95=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=A0=E6=B3=95=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/order/OrderEveryDayTaskExecute.java | 58 +++++++++++++------ .../properties/RocketmqCustomProperties.java | 1 + .../MemberEvaluationServiceImpl.java | 3 + 3 files changed, 44 insertions(+), 18 deletions(-) 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 6370b260..8e9f2e6a 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 @@ -2,8 +2,6 @@ package cn.lili.timetask.handler.impl.order; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; @@ -88,14 +86,30 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { throw new ServiceException(ResultCode.ORDER_SETTING_ERROR); } - //自动确认收货 - completedOrder(orderSetting); - //自动好评 - memberEvaluation(orderSetting); - //关闭允许售后申请 - closeAfterSale(orderSetting); - //关闭允许投诉 - closeComplaint(orderSetting); + try { + //自动确认收货 + completedOrder(orderSetting); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + try { + //自动好评 + memberEvaluation(orderSetting); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + try { + //关闭允许售后申请 + closeAfterSale(orderSetting); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + try { + //关闭允许投诉 + closeComplaint(orderSetting); + } catch (Exception e) { + log.error(e.getMessage(), e); + } } /** @@ -115,12 +129,16 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { queryWrapper.le(Order::getLogisticsTime, receiveTime); List list = orderService.list(queryWrapper); - //判断是否有符合条件的订单,进行订单完成处理 - if (!list.isEmpty()) { - List receiveSnList = list.stream().map(Order::getSn).collect(Collectors.toList()); - for (String orderSn : receiveSnList) { - orderService.systemComplete(orderSn); + try { + //判断是否有符合条件的订单,进行订单完成处理 + if (!list.isEmpty()) { + List receiveSnList = list.stream().map(Order::getSn).collect(Collectors.toList()); + for (String orderSn : receiveSnList) { + orderService.systemComplete(orderSn); + } } + } catch (Exception e) { + log.error(e.getMessage(), e); } } @@ -152,7 +170,12 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { memberEvaluationDTO.setDescriptionScore(5); memberEvaluationDTO.setServiceScore(5); - memberEvaluationService.addMemberEvaluation(memberEvaluationDTO, false); + try { + memberEvaluationService.addMemberEvaluation(memberEvaluationDTO, false); + + } catch (Exception e) { + log.error(e.getMessage(), e); + } } } } @@ -164,7 +187,6 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { * @param orderSetting 订单设置 */ private void closeAfterSale(OrderSetting orderSetting) { - //订单关闭售后申请时间 = 当前时间 - 自动关闭售后申请天数 DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseAfterSale()); @@ -187,7 +209,7 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { orderItemService.update(lambdaUpdateWrapper); //修改订售后状态 List orderItemsList = orderItems.stream() - .map((orderItem)->{ + .map((orderItem) -> { orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.EXPIRED.name()); return orderItem; }) diff --git a/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java b/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java index 934057ac..cfc001ff 100644 --- a/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java +++ b/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java @@ -19,6 +19,7 @@ import org.springframework.stereotype.Component; @ConfigurationProperties(prefix = "lili.data.rocketmq") public class RocketmqCustomProperties { + private String promotionTopic; private String promotionGroup; 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 94e7239f..6877a97a 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 @@ -122,6 +122,9 @@ public class MemberEvaluationServiceImpl extends ServiceImpl Date: Wed, 10 May 2023 14:07:30 +0800 Subject: [PATCH 21/25] =?UTF-8?q?refactor:=20=E5=8E=BB=E9=99=A4=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E6=97=A0=E6=95=88=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/event/impl/DistributionOrderExecute.java | 5 ----- .../handler/impl/order/OrderEveryDayTaskExecute.java | 4 ---- 2 files changed, 9 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/DistributionOrderExecute.java b/consumer/src/main/java/cn/lili/event/impl/DistributionOrderExecute.java index 53812919..9c09c638 100644 --- a/consumer/src/main/java/cn/lili/event/impl/DistributionOrderExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/DistributionOrderExecute.java @@ -39,11 +39,6 @@ public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDa */ @Autowired private DistributionOrderService distributionOrderService; - /** - * 分销订单持久层 - */ - @Resource - private DistributionOrderMapper distributionOrderMapper; @Autowired private SettingService settingService; 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 8e9f2e6a..b0e73078 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 @@ -9,7 +9,6 @@ import cn.lili.modules.distribution.service.DistributionOrderService; import cn.lili.modules.member.entity.dto.MemberEvaluationDTO; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.service.MemberEvaluationService; -import cn.lili.modules.order.aftersale.service.AfterSaleService; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.enums.CommentStatusEnum; @@ -67,9 +66,6 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { @Autowired private MemberEvaluationService memberEvaluationService; - @Autowired - private AfterSaleService afterSaleService; - @Autowired private DistributionOrderService distributionOrderService; From c0a370ad4743e5efcbfe620df2ceb5a8bf34721f Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Wed, 10 May 2023 14:44:55 +0800 Subject: [PATCH 22/25] =?UTF-8?q?fix:=E4=BA=A4=E6=98=93=E6=8A=95=E8=AF=89?= =?UTF-8?q?=EF=BC=8C=E4=BA=A4=E6=98=93=E5=94=AE=E5=90=8E=EF=BC=8C=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E8=AE=BE=E7=BD=AE=E4=B8=AD=E6=8F=8F=E8=BF=B0=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=9A=E8=AE=BE=E7=BD=AE=E4=B8=BA0?= =?UTF-8?q?=E5=88=99=E8=A1=A8=E7=A4=BA=E4=B8=8D=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/impl/order/OrderEveryDayTaskExecute.java | 8 ++++++++ .../order/cart/render/util/PromotionPriceUtil.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) 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 b0e73078..53024820 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 @@ -183,6 +183,10 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { * @param orderSetting 订单设置 */ private void closeAfterSale(OrderSetting orderSetting) { + //为0则不限制 + if (orderSetting.getCloseAfterSale() == null || orderSetting.getCloseAfterSale() == 0) { + return; + } //订单关闭售后申请时间 = 当前时间 - 自动关闭售后申请天数 DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseAfterSale()); @@ -223,6 +227,10 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { */ private void closeComplaint(OrderSetting orderSetting) { + //为0则不限制 + if (orderSetting.getCloseComplaint() == null || orderSetting.getCloseComplaint() == 0) { + return; + } //订单关闭交易投诉申请时间 = 当前时间 - 自动关闭交易投诉申请天数 DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseComplaint()); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java index f6e2a2aa..319b353b 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java @@ -29,7 +29,8 @@ public class PromotionPriceUtil { * @param discountPrice 需要分发的优惠金额 * @param promotionTypeEnum 促销类型 */ - public static void recountPrice(TradeDTO tradeDTO, Map skuPromotionDetail, Double discountPrice, PromotionTypeEnum promotionTypeEnum, String activityId) { + public static void recountPrice(TradeDTO tradeDTO, Map skuPromotionDetail, Double discountPrice, + PromotionTypeEnum promotionTypeEnum, String activityId) { // sku 促销信息非空判定 if (skuPromotionDetail == null || skuPromotionDetail.size() == 0) { @@ -116,7 +117,8 @@ public class PromotionPriceUtil { * @param promotionTypeEnum 优惠类型 * @param activityId 优惠活动id */ - private static void calculateCartSkuPromotionsPrice(CartSkuVO cartSkuVO, Double skuDiscountPrice, PromotionTypeEnum promotionTypeEnum, String activityId) { + private static void calculateCartSkuPromotionsPrice(CartSkuVO cartSkuVO, Double skuDiscountPrice, PromotionTypeEnum promotionTypeEnum, + String activityId) { //优惠券金额,则计入优惠券 ,其他则计入总的discount price if (promotionTypeEnum == PromotionTypeEnum.COUPON) { @@ -179,14 +181,16 @@ public class PromotionPriceUtil { * @param promotionTypeEnum 优惠类型 * @param activityId 优惠活动id */ - private static void calculateNotEnoughPromotionsPrice(List skuVOList, Map skuPromotionDetail, Double discountPrice, Double totalPrice, PromotionTypeEnum promotionTypeEnum, String activityId) { + private static void calculateNotEnoughPromotionsPrice(List skuVOList, Map skuPromotionDetail, Double discountPrice, + Double totalPrice, PromotionTypeEnum promotionTypeEnum, String activityId) { // 特殊情况处理,如参与多个促销活动,部分商品在其他促销计算后的金额不足以满足与当前参与的促销活动的优惠金额 // 但当前购物车内存在当前当前促销活动的其他商品且剩余金额也满足分摊不足商品的不足金额,则分摊到其他商品上 // 满足当前促销的总优惠金额 if (skuPromotionDetail == null || skuPromotionDetail.isEmpty()) { return; } - long matchPromotionsZeroCount = skuVOList.stream().filter(l -> l.getPriceDetailDTO().getFlowPrice() == 0 && skuPromotionDetail.containsKey(l.getGoodsSku().getId())).count(); + long matchPromotionsZeroCount = + skuVOList.stream().filter(l -> l.getPriceDetailDTO().getFlowPrice() == 0 && skuPromotionDetail.containsKey(l.getGoodsSku().getId())).count(); long matchPromotionsCount = skuVOList.stream().filter(l -> skuPromotionDetail.containsKey(l.getGoodsSku().getId())).count(); if (matchPromotionsZeroCount == matchPromotionsCount) { return; From 1f0281869291d71921dc25bb56e25aa536de1964 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Wed, 10 May 2023 14:50:19 +0800 Subject: [PATCH 23/25] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81=E4=BF=83=E9=94=80=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E7=89=B9=E6=AE=8A=E6=83=85=E5=86=B5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/cart/render/util/PromotionPriceUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java index f6e2a2aa..dc0d6578 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java @@ -203,9 +203,12 @@ public class PromotionPriceUtil { return false; }).collect(Collectors.toList()); if (!unEnoughSku.isEmpty()) { + if (unEnoughSku.size() == skuVOList.size()) { + return; + } for (CartSkuVO cartSkuVO : skuVOList) { if (unEnoughSku.isEmpty()) { - return; + break; } if (skuPromotionDetail.containsKey(cartSkuVO.getGoodsSku().getId()) && unEnoughSku.stream().noneMatch(k -> k.getGoodsSku().getId().equals(cartSkuVO.getGoodsSku().getId()))) { // 商品金额占比 From a0619abfc4801aa8b4d1ce49c7475efb32a764de Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Thu, 11 May 2023 11:21:27 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=8F=82=E8=80=83?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-api/README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 im-api/README.md diff --git a/im-api/README.md b/im-api/README.md new file mode 100644 index 00000000..f3e99eee --- /dev/null +++ b/im-api/README.md @@ -0,0 +1,56 @@ +### IM 配置文档 + +#### websocket连接中,ws=http协议,wss=https协议,在前端配置时也许注意同步修改(PS:微信小程序只支持https) + +微信小程序配置需额外配置:前往微信平台,登陆自己的小程序 +https://mp.weixin.qq.com/ + +配置内容: 开发 -> 开发设置 -> 服务器域名 -> socket合法域名 -> 添加 https://im-api.pickmall.cn(参考) + +##### https NGINX配置参考 + +``` +server { +listen 443 ssl; +ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem"; +ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key"; +ssl_session_cache shared:SSL:1m; +ssl_session_timeout 10m; +ssl_ciphers HIGH:!aNULL:!MD5; +ssl_prefer_server_ciphers on; +include /etc/nginx/default.d/*.conf; +server_name im-api.pickmall.cn; + +location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header X-real-ip $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://127.0.0.1:8885; + } +} +``` + +##### http 参考配置 + +``` +server { +listen 8885; +ssl_session_cache shared:SSL:1m; +ssl_session_timeout 10m; +ssl_ciphers HIGH:!aNULL:!MD5; +ssl_prefer_server_ciphers on; +include /etc/nginx/default.d/*.conf; +server_name im-api.pickmall.cn; + +location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header X-real-ip $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://127.0.0.1:8885; + } +} +``` From d413de75d3acfb671c1053b867253d00116053ba Mon Sep 17 00:00:00 2001 From: misworga831 Date: Wed, 17 May 2023 14:16:16 +0800 Subject: [PATCH 25/25] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81=E4=BF=83=E9=94=80=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E7=89=B9=E6=AE=8A=E6=83=85=E5=86=B5=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=B8=AD=E4=BC=98=E6=83=A0=E5=88=B8=E9=87=91=E9=A2=9D=E4=B8=BA?= =?UTF-8?q?0=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=88=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E5=95=86=E5=93=81=E4=BF=83=E9=94=80=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E6=83=85=E5=86=B5=E5=A4=84=E7=90=86=E5=8F=AA?= =?UTF-8?q?=E5=A4=84=E7=90=86=E4=BC=98=E6=83=A0=E5=88=B8=E4=B8=8D=E8=B6=B3?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/cart/render/util/PromotionPriceUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java index 0885628f..d375c16f 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/util/PromotionPriceUtil.java @@ -172,7 +172,7 @@ public class PromotionPriceUtil { } /** - * 特殊情况处理,如参与多个促销活动,部分商品在其他促销计算后的金额不足以满足与当前参与的促销活动的优惠金额 + * 特殊情况处理,如参与多个促销活动,部分商品在其他促销计算后的金额不足以满足与当前参与的促销活动的优惠金额(只计算使用优惠券不足的情况) * * @param skuVOList 获取购物车信息 * @param skuPromotionDetail 参与活动的商品,以及商品总金额 @@ -202,7 +202,7 @@ public class PromotionPriceUtil { double point = CurrencyUtil.div(k.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4); //商品优惠金额 Double skuDiscountPrice = CurrencyUtil.mul(discountPrice, point); - return skuDiscountPrice > k.getPriceDetailDTO().getCouponPrice(); + return k.getPriceDetailDTO().getCouponPrice() > 0 && skuDiscountPrice > k.getPriceDetailDTO().getCouponPrice(); } return false; }).collect(Collectors.toList());