main
parent
5eec9481ce
commit
72a98693ee
|
|
@ -1,20 +1,20 @@
|
||||||
package com.ruoyi.app.service.impl;
|
package com.ruoyi.app.service.impl;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.ruoyi.app.domain.AppSchool;
|
import com.ruoyi.app.domain.*;
|
||||||
import com.ruoyi.app.domain.AppUser;
|
|
||||||
import com.ruoyi.app.domain.vo.AppRegisterVo;
|
import com.ruoyi.app.domain.vo.AppRegisterVo;
|
||||||
import com.ruoyi.app.mapper.AppSchoolMapper;
|
import com.ruoyi.app.mapper.*;
|
||||||
import com.ruoyi.app.mapper.AppUserMapper;
|
|
||||||
import com.ruoyi.app.utils.aliyun.sms.SendNoteUtil;
|
import com.ruoyi.app.utils.aliyun.sms.SendNoteUtil;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
||||||
import com.ruoyi.common.core.utils.mail.AliMailUtil;
|
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.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
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.apache.http.util.EntityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.app.mapper.AppRegisterMapper;
|
|
||||||
import com.ruoyi.app.domain.AppRegister;
|
|
||||||
import com.ruoyi.app.service.IAppRegisterService;
|
import com.ruoyi.app.service.IAppRegisterService;
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
|
|
@ -48,6 +46,16 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SendNoteUtil sendNoteUtil;
|
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);
|
AppRegister appRegister = appRegisterMapper.selectAppRegisterById(id);
|
||||||
Assert.isTrue(appRegister != null, "该申请不存在");
|
Assert.isTrue(appRegister != null, "该申请不存在");
|
||||||
Assert.isTrue(appRegister.getStatus() != null && appRegister.getStatus() == 0, "该申请已审核");
|
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.setStatus(1);
|
||||||
appRegister.setUpdateTime(DateUtils.getNowDate());
|
appRegister.setUpdateTime(DateUtils.getNowDate());
|
||||||
int i = appRegisterMapper.updateAppRegister(appRegister);
|
int i = appRegisterMapper.updateAppRegister(appRegister);
|
||||||
|
|
@ -162,6 +177,10 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
|
||||||
appUser.setCityId(appRegister.getCityId() != null ? appRegister.getCityId() : null);
|
appUser.setCityId(appRegister.getCityId() != null ? appRegister.getCityId() : null);
|
||||||
appUser.setTownId(appRegister.getTownId() != null ? appRegister.getTownId() : null);
|
appUser.setTownId(appRegister.getTownId() != null ? appRegister.getTownId() : null);
|
||||||
appUserMapper.insertAppUser(appUser);
|
appUserMapper.insertAppUser(appUser);
|
||||||
|
if (appExchangeCode != null && appExchangeCode.getId() != null) {
|
||||||
|
useExchange(appExchangeCode,appUser.getId());
|
||||||
|
}
|
||||||
|
|
||||||
sendNoteUtil.sendMessage(appRegister.getPhone());
|
sendNoteUtil.sendMessage(appRegister.getPhone());
|
||||||
HttpClient httpClient = HttpClients.createDefault();
|
HttpClient httpClient = HttpClients.createDefault();
|
||||||
String pushId = appRegister.getPushId() != null ? appRegister.getPushId() : null;
|
String pushId = appRegister.getPushId() != null ? appRegister.getPushId() : null;
|
||||||
|
|
@ -178,10 +197,50 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
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
|
@Override
|
||||||
public int rejectAppRegister(AppRegister appRegister) {
|
public int rejectAppRegister(AppRegister appRegister) {
|
||||||
AppRegister register = appRegisterMapper.selectAppRegisterById(appRegister.getId());
|
AppRegister register = appRegisterMapper.selectAppRegisterById(appRegister.getId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue