fix: 充值相关
parent
b11b71be2e
commit
01a1e11f9b
|
@ -74,4 +74,12 @@ public class MemberController {
|
||||||
return CommonResult.success(rechargeGearService.memberByPhoneGradeInfo(phone));
|
return CommonResult.success(rechargeGearService.memberByPhoneGradeInfo(phone));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 充值列表记录
|
||||||
|
@Operation(summary = "根据手机号获取充值充值记录")
|
||||||
|
@RequestMapping(value = "/memberOrderInfoByPhone", method = RequestMethod.GET)
|
||||||
|
@PreAuthenticated
|
||||||
|
@TenantIgnore
|
||||||
|
public CommonResult<List<RechargeOrderRespVO>> memberOrderInfoByPhone(@RequestParam String phone) {
|
||||||
|
return CommonResult.success(rechargeOrderService.memberOrderInfoByPhone(phone));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1463,7 +1463,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
||||||
});
|
});
|
||||||
|
|
||||||
List<PhoneRecordDO> infoDOS = phoneRecordMapper.selectList(Wrappers.<PhoneRecordDO>lambdaQuery()
|
List<PhoneRecordDO> infoDOS = phoneRecordMapper.selectList(Wrappers.<PhoneRecordDO>lambdaQuery()
|
||||||
.eq(PhoneRecordDO::getUserId, user.getId())
|
.eq(PhoneRecordDO::getUserId, user.getMobile())
|
||||||
.in(PhoneRecordDO::getRechargeGearId, collect));
|
.in(PhoneRecordDO::getRechargeGearId, collect));
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(infoDOS)) {
|
if (!CollectionUtils.isEmpty(infoDOS)) {
|
||||||
|
@ -1481,7 +1481,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
||||||
MemberUserRespDTO userByMobile = userService.getUserByMobile(request.getUserPhone());
|
MemberUserRespDTO userByMobile = userService.getUserByMobile(request.getUserPhone());
|
||||||
// 初始化一个账号
|
// 初始化一个账号
|
||||||
if (Objects.isNull(userByMobile)) {
|
if (Objects.isNull(userByMobile)) {
|
||||||
userService.saveMemberUser(request.getUserPhone());
|
userService.saveMemberUser(request.getUserPhone(),user.getPromoterId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,33 @@
|
||||||
package cn.iocoder.yudao.module.shop.service.recharge;
|
package cn.iocoder.yudao.module.shop.service.recharge;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.shop.convert.recharge.RechargeGearConvert;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.PhoneRecordDO;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.PhoneRecordDO;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeGearDO;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO;
|
|
||||||
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.PhoneRecordMapper;
|
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.PhoneRecordMapper;
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeGearMapper;
|
||||||
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper;
|
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper;
|
||||||
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderMapper;
|
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderMapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.*;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeGearDO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.shop.convert.recharge.RechargeGearConvert;
|
|
||||||
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeGearMapper;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.shop.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.shop.enums.ErrorCodeConstants.RECHARGE_GEAR_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充值档位 Service 实现类
|
* 充值档位 Service 实现类
|
||||||
|
@ -48,6 +46,8 @@ public class RechargeGearServiceImpl implements RechargeGearService {
|
||||||
private RechargeOrderMapper orderMapper;
|
private RechargeOrderMapper orderMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PhoneRecordMapper phoneRecordMapper;
|
private PhoneRecordMapper phoneRecordMapper;
|
||||||
|
@Autowired
|
||||||
|
private MemberUserApi userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createRechargeGear(RechargeGearCreateReqVO createReqVO) {
|
public Long createRechargeGear(RechargeGearCreateReqVO createReqVO) {
|
||||||
|
@ -104,6 +104,7 @@ public class RechargeGearServiceImpl implements RechargeGearService {
|
||||||
@Override
|
@Override
|
||||||
public List<RechargeGearRespVO> getGradeInfo() {
|
public List<RechargeGearRespVO> getGradeInfo() {
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
MemberUserRespDTO user = userService.getUser(loginUser.getId());
|
||||||
Assert.notNull(loginUser, "登录失效,请重新登录!");
|
Assert.notNull(loginUser, "登录失效,请重新登录!");
|
||||||
List<RechargeGearDO> rechargeGearDOS = rechargeGearMapper.selectList(Wrappers.<RechargeGearDO>lambdaQuery()
|
List<RechargeGearDO> rechargeGearDOS = rechargeGearMapper.selectList(Wrappers.<RechargeGearDO>lambdaQuery()
|
||||||
.eq(RechargeGearDO::getDeleted, 0));
|
.eq(RechargeGearDO::getDeleted, 0));
|
||||||
|
@ -111,7 +112,7 @@ public class RechargeGearServiceImpl implements RechargeGearService {
|
||||||
throw new ServiceException("未初始化档次信息!");
|
throw new ServiceException("未初始化档次信息!");
|
||||||
}
|
}
|
||||||
List<RechargeGearRespVO> rechargeGearRespVOS = RechargeGearConvert.INSTANCE.convertList(rechargeGearDOS);
|
List<RechargeGearRespVO> rechargeGearRespVOS = RechargeGearConvert.INSTANCE.convertList(rechargeGearDOS);
|
||||||
List<PhoneRecordDO> infoDOS = phoneRecordMapper.selectList(Wrappers.<PhoneRecordDO>lambdaQuery().eq(PhoneRecordDO::getUserId, loginUser.getId()));
|
List<PhoneRecordDO> infoDOS = phoneRecordMapper.selectList(Wrappers.<PhoneRecordDO>lambdaQuery().eq(PhoneRecordDO::getPhone, user.getMobile()));
|
||||||
Map<Long, List<PhoneRecordDO>> collect = infoDOS.stream().collect(Collectors.groupingBy(PhoneRecordDO::getRechargeGearId));
|
Map<Long, List<PhoneRecordDO>> collect = infoDOS.stream().collect(Collectors.groupingBy(PhoneRecordDO::getRechargeGearId));
|
||||||
rechargeGearRespVOS.forEach(vo -> {
|
rechargeGearRespVOS.forEach(vo -> {
|
||||||
List<PhoneRecordDO> infoDOS1 = collect.get(vo.getId());
|
List<PhoneRecordDO> infoDOS1 = collect.get(vo.getId());
|
||||||
|
|
|
@ -76,4 +76,6 @@ public interface RechargeOrderService {
|
||||||
List<RechargeOrderRespVO> memberOrderInfo();
|
List<RechargeOrderRespVO> memberOrderInfo();
|
||||||
|
|
||||||
MemberHeadResponse memberHeadInfo();
|
MemberHeadResponse memberHeadInfo();
|
||||||
|
|
||||||
|
List<RechargeOrderRespVO> memberOrderInfoByPhone(String phone);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,4 +171,35 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RechargeOrderRespVO> memberOrderInfoByPhone(String phone) {
|
||||||
|
List<RechargeOrderDO> orderDOS = rechargeOrderMapper.selectList(Wrappers.<RechargeOrderDO>lambdaQuery()
|
||||||
|
.eq(RechargeOrderDO::getUserPhone, phone).eq(RechargeOrderDO::getPaid, 1));
|
||||||
|
if (!CollectionUtils.isEmpty(orderDOS)) {
|
||||||
|
List<RechargeOrderRespVO> rechargeOrderRespVOS = RechargeOrderConvert.INSTANCE.convertList(orderDOS);
|
||||||
|
List<String> collect1 = rechargeOrderRespVOS.stream().map(RechargeOrderBaseVO::getOrderId).collect(Collectors.toList());
|
||||||
|
List<RechargeOrderInfoDO> infoDOS = infoMapper.selectList(Wrappers.<RechargeOrderInfoDO>lambdaQuery().in(RechargeOrderInfoDO::getOrderNo, collect1));
|
||||||
|
Map<String, List<RechargeOrderInfoDO>> collect = infoDOS.stream().collect(Collectors.groupingBy(RechargeOrderInfoDO::getOrderNo));
|
||||||
|
for (RechargeOrderRespVO orderDO : rechargeOrderRespVOS) {
|
||||||
|
StringBuilder grade = new StringBuilder();
|
||||||
|
List<RechargeOrderInfoDO> 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public interface MemberUserApi {
|
||||||
MemberUserRespDTO getInfo();
|
MemberUserRespDTO getInfo();
|
||||||
|
|
||||||
|
|
||||||
void saveMemberUser(String phone);
|
void saveMemberUser(String phone,Long promoterId);
|
||||||
|
|
||||||
PromoterDTO getPromoterDOByUserId(Long userId);
|
PromoterDTO getPromoterDOByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.framework.tenant.core.aop.TenantIgnore;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
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.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.convert.user.UserConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.promoter.PromoterDO;
|
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.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.promoter.PromoterService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import com.thoughtworks.xstream.core.SecurityUtils;
|
import com.thoughtworks.xstream.core.SecurityUtils;
|
||||||
|
@ -31,6 +33,8 @@ public class MemberUserApiImpl implements MemberUserApi {
|
||||||
private MemberUserService userService;
|
private MemberUserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
private PromoterService promoterService;
|
private PromoterService promoterService;
|
||||||
|
@Resource
|
||||||
|
private MemberAuthService authService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
|
@ -103,8 +107,12 @@ public class MemberUserApiImpl implements MemberUserApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveMemberUser(String phone) {
|
public void saveMemberUser(String phone,Long promoterId) {
|
||||||
userService.saveMemberUser(phone);
|
AppAuthSmsLoginReqVO reqVO = new AppAuthSmsLoginReqVO();
|
||||||
|
reqVO.setMobile(phone);
|
||||||
|
reqVO.setPromoterId(promoterId);
|
||||||
|
reqVO.setRealName("初始化账号");
|
||||||
|
authService.initialize(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,6 +44,14 @@ public interface MemberAuthService {
|
||||||
*/
|
*/
|
||||||
Long register(@Valid AppAuthSmsLoginReqVO reqVO);
|
Long register(@Valid AppAuthSmsLoginReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化账号
|
||||||
|
*
|
||||||
|
* @param reqVO 登陆信息
|
||||||
|
* @return 登录结果
|
||||||
|
*/
|
||||||
|
Long initialize(@Valid AppAuthSmsLoginReqVO reqVO);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社交登录,使用 code 授权码
|
* 社交登录,使用 code 授权码
|
||||||
|
|
|
@ -139,6 +139,19 @@ public class MemberAuthServiceImpl implements MemberAuthService {
|
||||||
return memberUserDO.getId();
|
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
|
@Override
|
||||||
public AppAuthLoginRespVO socialLogin(AppAuthSocialLoginReqVO reqVO) {
|
public AppAuthLoginRespVO socialLogin(AppAuthSocialLoginReqVO reqVO) {
|
||||||
// 使用 code 授权码,进行登录。然后,获得到绑定的用户编号
|
// 使用 code 授权码,进行登录。然后,获得到绑定的用户编号
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||||
user.setMobile(mobile);
|
user.setMobile(mobile);
|
||||||
user.setNickname(realName);
|
user.setNickname(realName);
|
||||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||||
user.setPassword(encodePassword(password)); // 加密密码
|
user.setPassword(encodePassword("123456")); // 加密密码
|
||||||
user.setRegisterIp(registerIp);
|
user.setRegisterIp(registerIp);
|
||||||
user.setPromoterId(promoterId);
|
user.setPromoterId(promoterId);
|
||||||
memberUserMapper.insert(user);
|
memberUserMapper.insert(user);
|
||||||
|
|
Loading…
Reference in New Issue