Merge remote-tracking branch 'origin/main'

main
王宇航 2024-06-26 18:29:17 +08:00
commit 9f40061534
2 changed files with 67 additions and 8 deletions

View File

@ -1,20 +1,20 @@
package com.ruoyi.app.service.impl;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.lang.Assert;
import cn.hutool.http.HttpUtil;
import com.ruoyi.app.domain.AppSchool;
import com.ruoyi.app.domain.AppUser;
import com.ruoyi.app.domain.*;
import com.ruoyi.app.domain.vo.AppRegisterVo;
import com.ruoyi.app.mapper.AppSchoolMapper;
import com.ruoyi.app.mapper.AppUserMapper;
import com.ruoyi.app.mapper.*;
import com.ruoyi.app.utils.aliyun.sms.SendNoteUtil;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.common.core.utils.mail.AliMailUtil;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
@ -22,8 +22,6 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.app.mapper.AppRegisterMapper;
import com.ruoyi.app.domain.AppRegister;
import com.ruoyi.app.service.IAppRegisterService;
import javax.mail.MessagingException;
@ -48,6 +46,16 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
@Autowired
private SendNoteUtil sendNoteUtil;
@Autowired
private AppOrderMapper appOrderMapper;
@Autowired
private AppOrderPayMapper appOrderPayMapper;
@Autowired
private AppExchangeCodeMapper appExchangeCodeMapper;
/**
*
*
@ -138,6 +146,13 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
AppRegister appRegister = appRegisterMapper.selectAppRegisterById(id);
Assert.isTrue(appRegister != null, "该申请不存在");
Assert.isTrue(appRegister.getStatus() != null && appRegister.getStatus() == 0, "该申请已审核");
AppExchangeCode appExchangeCode = null;
if (org.apache.commons.lang3.StringUtils.isNotBlank(appRegister.getInvitationCode())) {
appExchangeCode = appExchangeCodeMapper.selectAppExchangeCodeByCode(appRegister.getInvitationCode());
if (appExchangeCode == null || appExchangeCode.getUserId() != null) {
Assert.isTrue(false, "该兑换码不存在或已被使用,请检查该兑换码是否正确!");
}
}
appRegister.setStatus(1);
appRegister.setUpdateTime(DateUtils.getNowDate());
int i = appRegisterMapper.updateAppRegister(appRegister);
@ -162,6 +177,10 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
appUser.setCityId(appRegister.getCityId() != null ? appRegister.getCityId() : null);
appUser.setTownId(appRegister.getTownId() != null ? appRegister.getTownId() : null);
appUserMapper.insertAppUser(appUser);
if (appExchangeCode != null && appExchangeCode.getId() != null) {
useExchange(appExchangeCode,appUser.getId());
}
sendNoteUtil.sendMessage(appRegister.getPhone());
HttpClient httpClient = HttpClients.createDefault();
String pushId = appRegister.getPushId() != null ? appRegister.getPushId() : null;
@ -178,10 +197,50 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
e.printStackTrace();
}
}
return i;
}
private void useExchange(AppExchangeCode appExchangeCode,Long userId){
AppExchangeCode entity = new AppExchangeCode();
entity.setUserId(userId);
entity.setUserTime(new Date());
entity.setId(appExchangeCode.getId());
appExchangeCodeMapper.updateAppExchangeCode(entity);
// 生成订单信息
AppOrder order = new AppOrder();
order.setOutTradeNo(appExchangeCode.getCode());
order.setPrice("0");
order.setUserId(userId);
order.setPayStatus(2);
order.setPaySoure(3);
order.setCreateTime(new Date());
order.setLevel(appExchangeCode.getLevel());
appOrderMapper.insertAppOrder(order);
// 修改用户信息
AppUser appUser = appUserMapper.selectAppUserById(order.getUserId());
AppUser userEntity = new AppUser();
userEntity.setId(appUser.getId());
userEntity.setIsMember(0);
userEntity.setOrderId(order.getId());
// 开始时间,结束时间
Date startDate = appUser.getOrderStartTime();
if (null == startDate) {
startDate = new Date();
}
Date endDate = appUser.getOrderEndTime();
if (endDate == null) {
endDate = startDate;
}
endDate = order.getLevel() == 1 ? DateUtils.dateAddTime(endDate,3,7)
: (order.getLevel() == 2 ? DateUtils.dateAddTime(endDate,4,31) : DateUtils.dateAddTime(endDate,5,365));
userEntity.setOrderStartTime(startDate);
userEntity.setOrderEndTime(endDate);
userEntity.setUpdateTime(new Date());
appUserMapper.updateAppUser(userEntity);
}
@Override
public int rejectAppRegister(AppRegister appRegister) {
AppRegister register = appRegisterMapper.selectAppRegisterById(appRegister.getId());

View File

@ -178,7 +178,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join app_school s on s.id = a.school
left join app_user_fans f on f.user_id = a.id
left join app_user_fans fa on fa.friend_id = a.id
left join app_user_friend r on r.user_id = a.id
left join app_user_friend r on r.user_id = a.id and r.status = 0
left join app_dynamic_like l on l.dynamic_user_id = a.id
left join app_town t on t.id = a.address
where a.id = #{id}