BUG修复:用户更改套餐,积分/用户角色不变更问题
This commit is contained in:
@@ -300,6 +300,19 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("BINARY user_email", email);
|
queryWrapper.eq("BINARY user_email", email);
|
||||||
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
||||||
|
log.info(accountList.toString());
|
||||||
|
if (CollectionUtil.isEmpty(accountList)) {
|
||||||
|
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
||||||
|
}
|
||||||
|
return accountList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 忽略大小写
|
||||||
|
private Account getAccountByEmail(String email) {
|
||||||
|
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("user_email", email);
|
||||||
|
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
||||||
|
log.info(accountList.toString());
|
||||||
if (CollectionUtil.isEmpty(accountList)) {
|
if (CollectionUtil.isEmpty(accountList)) {
|
||||||
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
||||||
}
|
}
|
||||||
@@ -1068,6 +1081,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
int orderId = queryOrderResultSet.getInt("order_id");
|
int orderId = queryOrderResultSet.getInt("order_id");
|
||||||
int customerId = queryOrderResultSet.getInt("customer_id");
|
int customerId = queryOrderResultSet.getInt("customer_id");
|
||||||
double totalSales = queryOrderResultSet.getDouble("total_sales");
|
double totalSales = queryOrderResultSet.getDouble("total_sales");
|
||||||
|
log.info("Code-Create 订单:{}, 顾客id:{}, 付款金额:{}",orderId, customerId, totalSales);
|
||||||
String email = "";
|
String email = "";
|
||||||
String userName = "";
|
String userName = "";
|
||||||
// 为什么一般没有值
|
// 为什么一般没有值
|
||||||
@@ -1094,7 +1108,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
Boolean flag = Boolean.FALSE;
|
Boolean flag = Boolean.FALSE;
|
||||||
try {
|
try {
|
||||||
// 不是新用户 直接延长使用期限
|
// 不是新用户 直接延长使用期限
|
||||||
userInfo = getOneByEmail(email);
|
userInfo = getAccountByEmail(email);
|
||||||
} catch (BusinessException e) {
|
} catch (BusinessException e) {
|
||||||
// 通过邮箱找不到用户 说明是新用户 => 创建用户
|
// 通过邮箱找不到用户 说明是新用户 => 创建用户
|
||||||
flag = Boolean.TRUE;
|
flag = Boolean.TRUE;
|
||||||
@@ -1106,23 +1120,24 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
Account account = extendValidity(validEndTime, totalSales);
|
Account account = extendValidity(validEndTime, totalSales);
|
||||||
|
|
||||||
int systemUserType = 0;
|
int systemUserType = 0;
|
||||||
|
|
||||||
|
// 不管是不是新用户 都要更新用户角色和积分
|
||||||
|
String credits = "0";
|
||||||
|
if (totalSales == 5000.0){
|
||||||
|
log.info("年付用户,初始积分6000");
|
||||||
|
credits = CreditsEventsEnum.INIT_MONTHLY.getValue();
|
||||||
|
systemUserType = 1;
|
||||||
|
}else if (totalSales == 500.0){
|
||||||
|
log.info("月付用户,初始积分5000");
|
||||||
|
credits = CreditsEventsEnum.INIT_MONTHLY.getValue();
|
||||||
|
systemUserType = 2;
|
||||||
|
}else if (totalSales == 0.0){
|
||||||
|
log.info("测试用户,初始积分10");
|
||||||
|
credits = "10";
|
||||||
|
systemUserType = 3;
|
||||||
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
// 是新用户 => 新增一条数据
|
// 是新用户 => 新增一条数据
|
||||||
String credits = "0";
|
|
||||||
if (totalSales == 5000.0){
|
|
||||||
log.info("年付用户,初始积分6000");
|
|
||||||
credits = CreditsEventsEnum.INIT_MONTHLY.getValue();
|
|
||||||
systemUserType = 1;
|
|
||||||
}else if (totalSales == 500.0){
|
|
||||||
log.info("月付用户,初始积分5000");
|
|
||||||
credits = CreditsEventsEnum.INIT_MONTHLY.getValue();
|
|
||||||
systemUserType = 2;
|
|
||||||
}else if (totalSales == 0.0){
|
|
||||||
log.info("测试用户,初始积分10");
|
|
||||||
credits = "10";
|
|
||||||
systemUserType = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean b = addUser(new AccountAddDTO(email,
|
Boolean b = addUser(new AccountAddDTO(email,
|
||||||
StringUtil.isNullOrEmpty(userName) ? email.substring(0, email.indexOf("@")) : userName,
|
StringUtil.isNullOrEmpty(userName) ? email.substring(0, email.indexOf("@")) : userName,
|
||||||
country,
|
country,
|
||||||
@@ -1131,6 +1146,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
if (b) log.info("付费新用户 {} 新增成功!", email);
|
if (b) log.info("付费新用户 {} 新增成功!", email);
|
||||||
} else {
|
} else {
|
||||||
userInfo.setValidEndTime(toDayEnd(account.getValidEndTime()));
|
userInfo.setValidEndTime(toDayEnd(account.getValidEndTime()));
|
||||||
|
userInfo.setCredits(new BigDecimal(credits));
|
||||||
|
userInfo.setSystemUser(systemUserType);
|
||||||
baseMapper.updateById(userInfo);
|
baseMapper.updateById(userInfo);
|
||||||
log.info("付费用户 {} 续订成功", email);
|
log.info("付费用户 {} 续订成功", email);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user