diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java index ae181e67f..cc7bca07b 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java @@ -74,4 +74,12 @@ public class MemberController { return CommonResult.success(rechargeGearService.memberByPhoneGradeInfo(phone)); } + // 充值列表记录 + @Operation(summary = "根据手机号获取充值充值记录") + @RequestMapping(value = "/memberOrderInfoByPhone", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult> memberOrderInfoByPhone(@RequestParam String phone) { + return CommonResult.success(rechargeOrderService.memberOrderInfoByPhone(phone)); + } } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java index 700953576..f738d88d6 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java @@ -1463,7 +1463,7 @@ public class StoreOrderServiceImpl extends ServiceImpl infoDOS = phoneRecordMapper.selectList(Wrappers.lambdaQuery() - .eq(PhoneRecordDO::getUserId, user.getId()) + .eq(PhoneRecordDO::getUserId, user.getMobile()) .in(PhoneRecordDO::getRechargeGearId, collect)); if (!CollectionUtils.isEmpty(infoDOS)) { @@ -1481,7 +1481,7 @@ public class StoreOrderServiceImpl extends ServiceImpl getGradeInfo() { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + MemberUserRespDTO user = userService.getUser(loginUser.getId()); Assert.notNull(loginUser, "登录失效,请重新登录!"); List rechargeGearDOS = rechargeGearMapper.selectList(Wrappers.lambdaQuery() .eq(RechargeGearDO::getDeleted, 0)); @@ -111,7 +112,7 @@ public class RechargeGearServiceImpl implements RechargeGearService { throw new ServiceException("未初始化档次信息!"); } List rechargeGearRespVOS = RechargeGearConvert.INSTANCE.convertList(rechargeGearDOS); - List infoDOS = phoneRecordMapper.selectList(Wrappers.lambdaQuery().eq(PhoneRecordDO::getUserId, loginUser.getId())); + List infoDOS = phoneRecordMapper.selectList(Wrappers.lambdaQuery().eq(PhoneRecordDO::getPhone, user.getMobile())); Map> collect = infoDOS.stream().collect(Collectors.groupingBy(PhoneRecordDO::getRechargeGearId)); rechargeGearRespVOS.forEach(vo -> { List infoDOS1 = collect.get(vo.getId()); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java index 3fe88778c..c9c9a089f 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java @@ -76,4 +76,6 @@ public interface RechargeOrderService { List memberOrderInfo(); MemberHeadResponse memberHeadInfo(); + + List memberOrderInfoByPhone(String phone); } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java index 0169f12e2..8813f9654 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java @@ -171,4 +171,35 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { return response; } + @Override + public List memberOrderInfoByPhone(String phone) { + List orderDOS = rechargeOrderMapper.selectList(Wrappers.lambdaQuery() + .eq(RechargeOrderDO::getUserPhone, phone).eq(RechargeOrderDO::getPaid, 1)); + if (!CollectionUtils.isEmpty(orderDOS)) { + List rechargeOrderRespVOS = RechargeOrderConvert.INSTANCE.convertList(orderDOS); + List collect1 = rechargeOrderRespVOS.stream().map(RechargeOrderBaseVO::getOrderId).collect(Collectors.toList()); + List infoDOS = infoMapper.selectList(Wrappers.lambdaQuery().in(RechargeOrderInfoDO::getOrderNo, collect1)); + Map> collect = infoDOS.stream().collect(Collectors.groupingBy(RechargeOrderInfoDO::getOrderNo)); + for (RechargeOrderRespVO orderDO : rechargeOrderRespVOS) { + StringBuilder grade = new StringBuilder(); + List infoDOS1 = collect.get(orderDO.getOrderId()); + for (RechargeOrderInfoDO infoDO : infoDOS1) { + if (infoDO.getPrice().compareTo(new BigDecimal("240")) == 0) { + grade.append("套餐1,"); + } else if (infoDO.getPrice().compareTo(new BigDecimal("400")) == 0) { + grade.append("套餐2,"); + } else if (infoDO.getPrice().compareTo(new BigDecimal("640")) == 0) { + grade.append("套餐3"); + } + } + orderDO.setGrade(grade.toString()); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + orderDO.setStringCreateTime(orderDO.getCreateTime().format(formatter)); + } + + return rechargeOrderRespVOS; + } + return null; + } + } diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java index 8e511b3a4..62faaf15c 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java @@ -80,7 +80,7 @@ public interface MemberUserApi { MemberUserRespDTO getInfo(); - void saveMemberUser(String phone); + void saveMemberUser(String phone,Long promoterId); PromoterDTO getPromoterDOByUserId(Long userId); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java index abb82eedb..17603857a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java @@ -5,9 +5,11 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.member.api.user.dto.PromoterDTO; +import cn.iocoder.yudao.module.member.controller.app.auth.vo.AppAuthSmsLoginReqVO; import cn.iocoder.yudao.module.member.convert.user.UserConvert; import cn.iocoder.yudao.module.member.dal.dataobject.promoter.PromoterDO; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.service.auth.MemberAuthService; import cn.iocoder.yudao.module.member.service.promoter.PromoterService; import cn.iocoder.yudao.module.member.service.user.MemberUserService; import com.thoughtworks.xstream.core.SecurityUtils; @@ -31,6 +33,8 @@ public class MemberUserApiImpl implements MemberUserApi { private MemberUserService userService; @Resource private PromoterService promoterService; + @Resource + private MemberAuthService authService; @Override @TenantIgnore @@ -103,8 +107,12 @@ public class MemberUserApiImpl implements MemberUserApi { } @Override - public void saveMemberUser(String phone) { - userService.saveMemberUser(phone); + public void saveMemberUser(String phone,Long promoterId) { + AppAuthSmsLoginReqVO reqVO = new AppAuthSmsLoginReqVO(); + reqVO.setMobile(phone); + reqVO.setPromoterId(promoterId); + reqVO.setRealName("初始化账号"); + authService.initialize(reqVO); } @Override diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java index d1f32cfd8..67c527d96 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java @@ -44,6 +44,14 @@ public interface MemberAuthService { */ Long register(@Valid AppAuthSmsLoginReqVO reqVO); + /** + * 初始化账号 + * + * @param reqVO 登陆信息 + * @return 登录结果 + */ + Long initialize(@Valid AppAuthSmsLoginReqVO reqVO); + /** * 社交登录,使用 code 授权码 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java index 3a6df452f..2bfe917b5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java @@ -139,6 +139,19 @@ public class MemberAuthServiceImpl implements MemberAuthService { return memberUserDO.getId(); } + @Override + public Long initialize(AppAuthSmsLoginReqVO reqVO) { + // 校验验证码 + String userIp = getClientIP(); + // 用户已经存在 + MemberUserDO user = userService.getUserByMobile(reqVO.getMobile()); + if (user != null) { + throw new ServiceException(ErrorCodeConstants.AUTH_MOBILE_EXISTS); + } + MemberUserDO memberUserDO = userService.createUserIfAbsent(reqVO.getMobile(),reqVO.getRealName(), userIp,reqVO.getPromoterId()); + return memberUserDO.getId(); + } + @Override public AppAuthLoginRespVO socialLogin(AppAuthSocialLoginReqVO reqVO) { // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index 86a5f2110..c5243d4ff 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -101,7 +101,7 @@ public class MemberUserServiceImpl implements MemberUserService { user.setMobile(mobile); user.setNickname(realName); user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 - user.setPassword(encodePassword(password)); // 加密密码 + user.setPassword(encodePassword("123456")); // 加密密码 user.setRegisterIp(registerIp); user.setPromoterId(promoterId); memberUserMapper.insert(user);