vip调整
This commit is contained in:
parent
dfe96567ea
commit
ca9c42183e
|
|
@ -1,21 +1,15 @@
|
||||||
package org.jeecg.modules.api.controller;
|
package org.jeecg.modules.api.controller;
|
||||||
|
|
||||||
|
|
||||||
import java.security.AlgorithmParameters;
|
|
||||||
import java.security.Key;
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.KeyGenerator;
|
import javax.crypto.KeyGenerator;
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.xkcoding.http.HttpUtil;
|
import com.xkcoding.http.HttpUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
|
@ -24,12 +18,11 @@ import org.jeecg.common.exception.JeecgBootException;
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
import org.jeecg.common.system.util.JwtUtil;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.common.util.*;
|
import org.jeecg.common.util.*;
|
||||||
|
import org.jeecg.modules.mini.dto.VipDTO;
|
||||||
|
import org.jeecg.modules.mini.service.MiniUserService;
|
||||||
import org.jeecg.modules.system.entity.SysUser;
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
import org.jeecg.modules.system.model.WxModel;
|
import org.jeecg.modules.system.model.WxModel;
|
||||||
import org.jeecg.modules.system.service.ISysUserService;
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
import org.jeecg.modules.wx.service.WechatPayService;
|
|
||||||
import org.jeecg.modules.yx.entity.YxOrder;
|
|
||||||
import org.jeecg.modules.yx.entity.YxVipCard;
|
|
||||||
import org.jeecg.modules.yx.service.IYxOrderService;
|
import org.jeecg.modules.yx.service.IYxOrderService;
|
||||||
import org.jeecg.modules.yx.service.IYxUserScoreService;
|
import org.jeecg.modules.yx.service.IYxUserScoreService;
|
||||||
import org.jeecg.modules.yx.service.IYxVipCardService;
|
import org.jeecg.modules.yx.service.IYxVipCardService;
|
||||||
|
|
@ -42,9 +35,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.security.spec.AlgorithmParameterSpec;
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description
|
* @Description
|
||||||
|
|
@ -55,149 +45,5 @@ import java.util.Map;
|
||||||
@RestController
|
@RestController
|
||||||
@Api(tags = "微信接口")
|
@Api(tags = "微信接口")
|
||||||
public class WxController {
|
public class WxController {
|
||||||
@Value("${wx.appId}")
|
|
||||||
private String wxAppId;
|
|
||||||
@Value("${wx.appSecret}")
|
|
||||||
private String wxAppSecret;
|
|
||||||
@Autowired
|
|
||||||
private RedisUtil redisUtil;
|
|
||||||
@Autowired
|
|
||||||
private ISysUserService sysUserService;
|
|
||||||
@Autowired
|
|
||||||
private IYxUserScoreService yxUserScoreService;
|
|
||||||
@Autowired
|
|
||||||
private IYxVipCardService yxVipCardService;
|
|
||||||
@Autowired
|
|
||||||
private IYxOrderService yxOrderService;
|
|
||||||
public static final String AES = "AES";
|
|
||||||
public static final String AES_CBC_PADDING = "AES/CBC/PKCS7Padding";
|
|
||||||
|
|
||||||
@PostMapping(value = "/editUserInfo")
|
|
||||||
public Result<?> editUserInfo(@RequestBody SysUser sysUser){
|
|
||||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
||||||
AssertUtils.notNull(user,"获取当前用户信息失败");
|
|
||||||
try {
|
|
||||||
String id = user.getId();
|
|
||||||
LambdaUpdateWrapper<SysUser> objectLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
||||||
objectLambdaUpdateWrapper.eq(SysUser::getId,id);
|
|
||||||
objectLambdaUpdateWrapper.set(SysUser::getRealname,sysUser.getRealname());
|
|
||||||
sysUserService.update(objectLambdaUpdateWrapper);
|
|
||||||
}catch (Exception e){
|
|
||||||
throw new JeecgBootException(e);
|
|
||||||
}
|
|
||||||
return Result.OK("保存成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/login")
|
|
||||||
public Result<?> wechatLogin(@RequestBody WxModel wxModel) {
|
|
||||||
String url = "https://api.weixin.qq.com/sns/jscode2session" +
|
|
||||||
"?appid=" + wxAppId +
|
|
||||||
"&secret=" + wxAppSecret +
|
|
||||||
"&grant_type=authorization_code" +
|
|
||||||
"&js_code=" + wxModel.code;
|
|
||||||
String s = HttpUtil.get(url);
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
|
||||||
AssertUtils.notNull(jsonObject, "登录失败");
|
|
||||||
String openId = jsonObject.getString("openid");
|
|
||||||
String sessionKey = jsonObject.getString("session_key");
|
|
||||||
SysUser user = sysUserService.getByWxOpenId(openId);
|
|
||||||
if (user == null) {
|
|
||||||
String salt = oConvertUtils.randomGen(8);
|
|
||||||
//新用户
|
|
||||||
user = new SysUser();
|
|
||||||
user.setWxOpenId(openId);
|
|
||||||
user.setUsername(salt);
|
|
||||||
user.setRealname("用户+" + salt);
|
|
||||||
user.setSalt(salt);
|
|
||||||
String encryptPassword = PasswordUtil.encrypt(salt, "123456", salt);
|
|
||||||
user.setPassword(encryptPassword);
|
|
||||||
user.setStatus(1);
|
|
||||||
//解密手机号
|
|
||||||
user.setPhone(phoneDecrypt(wxModel.getEncryptedData(), sessionKey, wxModel.getIv()));
|
|
||||||
user.setUserIdentity(CommonConstant.USER_IDENTITY_1);
|
|
||||||
user.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
||||||
user.setOrgCode(null);
|
|
||||||
sysUserService.saveUser(user, null, null, null);
|
|
||||||
//默认用户有一个 分数信息
|
|
||||||
yxUserScoreService.setDefaultScore(user.getId());
|
|
||||||
}
|
|
||||||
String username = user.getUsername();
|
|
||||||
String syspassword = user.getPassword();
|
|
||||||
//1.生成token
|
|
||||||
String token = JwtUtil.sign(username, syspassword);
|
|
||||||
// 设置token缓存有效时间
|
|
||||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
|
||||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
|
|
||||||
JSONObject obj = new JSONObject();
|
|
||||||
LoginUser loginUser=new LoginUser();
|
|
||||||
BeanUtils.copyProperties(user,loginUser);
|
|
||||||
//获取vip信息
|
|
||||||
List<YxVipCard> yxVipCards = yxVipCardService.selectByUserId(loginUser.getId());
|
|
||||||
if (CollectionUtils.isNotEmpty(yxVipCards)) {
|
|
||||||
loginUser.setVipFlag(true);
|
|
||||||
}
|
|
||||||
if (!loginUser.isVipFlag()) {
|
|
||||||
//获取订单信息
|
|
||||||
List<YxOrder> yxOrderList = yxOrderService.findListByPaymentUserId(loginUser.getId());
|
|
||||||
if (CollectionUtils.isNotEmpty(yxOrderList)) {
|
|
||||||
long count = yxOrderList.stream().filter(y -> y.getOrderStatus().equals("1")).count();
|
|
||||||
loginUser.setVipFlag(count>0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
obj.put("token", token);
|
|
||||||
obj.put("openId",openId);
|
|
||||||
obj.put("sessionKey",sessionKey);
|
|
||||||
obj.put("userInfo", loginUser);
|
|
||||||
return Result.OK(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解密手机号
|
|
||||||
*/
|
|
||||||
@PostMapping("/phoneNumberDecrypt")
|
|
||||||
public Result<?> phoneDecrypt(@RequestBody WxModel wxModel){
|
|
||||||
//判断密文信息是否为空
|
|
||||||
if (StringUtils.isNotBlank(wxModel.getSessionKey()) && StringUtils.isNotBlank(wxModel.getEncryptedData()) && StringUtils.isNotBlank(wxModel.getIv())) {
|
|
||||||
//解密出手机号
|
|
||||||
String phoneNumber = phoneDecrypt(wxModel.getEncryptedData(), wxModel.getSessionKey(), wxModel.getIv());
|
|
||||||
//获取该用户
|
|
||||||
SysUser sysUser = sysUserService.getByWxOpenId(wxModel.getOpenId());
|
|
||||||
if (sysUser!=null) {
|
|
||||||
//更新用户手机号
|
|
||||||
sysUser.setPhone(phoneNumber);
|
|
||||||
sysUserService.updateById(sysUser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result.OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String phoneDecrypt(String encrypted, String sessionKey, String iv) {
|
|
||||||
String phoneNumber = null;
|
|
||||||
try {
|
|
||||||
byte[] encrypdata = cn.hutool.core.codec.Base64.decode(encrypted);
|
|
||||||
byte[] ivData = cn.hutool.core.codec.Base64.decode(iv);
|
|
||||||
byte[] sessionKeyByte = cn.hutool.core.codec.Base64.decode(sessionKey);
|
|
||||||
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData);
|
|
||||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
|
||||||
SecretKeySpec keySpec = new SecretKeySpec(sessionKeyByte, "AES");
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
|
|
||||||
//解析解密后的手机号
|
|
||||||
String data = new String(cipher.doFinal(encrypdata), "UTF-8");
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
|
||||||
phoneNumber = jsonObject.getString("phoneNumber");
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("解密与微信绑定的手机号失败", e);
|
|
||||||
}
|
|
||||||
return phoneNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 初始化密钥
|
|
||||||
*/
|
|
||||||
public static void init() throws Exception {
|
|
||||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
|
||||||
KeyGenerator.getInstance(AES).init(128);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,129 +64,13 @@ public class MiniArticleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MiniArticleService miniArticleService;
|
private MiniArticleService miniArticleService;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String rulesEnrollProbability = "文1+专0.66700";
|
|
||||||
String[] split = rulesEnrollProbability.split("\\+");
|
|
||||||
String w=null,z=null;
|
|
||||||
BigDecimal wb=null;
|
|
||||||
BigDecimal zb=null;
|
|
||||||
for (String s : split) {
|
|
||||||
w = null;
|
|
||||||
z = null;
|
|
||||||
if (s.contains("文")) {
|
|
||||||
wb = new BigDecimal(s.replace("文",""));
|
|
||||||
}
|
|
||||||
if (s.contains("专")) {
|
|
||||||
zb = new BigDecimal(s.replace("专",""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
|
||||||
}
|
|
||||||
@ApiOperation(value = "文章列表")
|
@ApiOperation(value = "文章列表")
|
||||||
@GetMapping(value = "/page")
|
@GetMapping(value = "/page")
|
||||||
public Result<?> articlePage(QueryArticleVO queryArticleVO) {
|
public Result<?> articlePage(QueryArticleVO queryArticleVO) {
|
||||||
if(false){
|
|
||||||
LambdaQueryWrapper<YxSchoolMajor> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.isNotNull(YxSchoolMajor::getRulesEnrollProbability);
|
|
||||||
queryWrapper.like(YxSchoolMajor::getRulesEnrollProbability,"专");
|
|
||||||
queryWrapper.like(YxSchoolMajor::getRulesEnrollProbability,"文");
|
|
||||||
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"+");
|
|
||||||
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"文过专排");
|
|
||||||
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"专过文排");
|
|
||||||
//queryWrapper.notIn(YxHistoryMajorEnroll::getRulesEnrollProbability,"文+专","专+文");
|
|
||||||
List<YxSchoolMajor> list = yxSchoolMajorService.list(queryWrapper);
|
|
||||||
for (YxSchoolMajor yxSchoolMajor : list) {
|
|
||||||
String[] split = yxSchoolMajor.getRulesEnrollProbability().split("专");
|
|
||||||
String w=null,z=null;
|
|
||||||
BigDecimal wb=null;
|
|
||||||
BigDecimal zb=null;
|
|
||||||
for (String s : split) {
|
|
||||||
w = null;
|
|
||||||
z = null;
|
|
||||||
if (s.contains("文")) {
|
|
||||||
wb = new BigDecimal(s.replace("文",""));
|
|
||||||
}else{
|
|
||||||
zb = new BigDecimal(s.replace("专",""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println(yxSchoolMajor.getRulesEnrollProbability()+":");
|
|
||||||
System.out.print("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
|
||||||
System.out.println();
|
|
||||||
yxSchoolMajor.setRulesEnrollProbability("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
|
||||||
}
|
|
||||||
yxSchoolMajorService.updateBatchById(list);
|
|
||||||
return Result.OK();
|
|
||||||
}
|
|
||||||
if(false){
|
|
||||||
LambdaQueryWrapper<YxHistoryMajorEnroll> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.isNotNull(YxHistoryMajorEnroll::getRulesEnrollProbability);
|
|
||||||
queryWrapper.like(YxHistoryMajorEnroll::getRulesEnrollProbability,"专");
|
|
||||||
queryWrapper.like(YxHistoryMajorEnroll::getRulesEnrollProbability,"文");
|
|
||||||
queryWrapper.notLike(YxHistoryMajorEnroll::getRulesEnrollProbability,"+");
|
|
||||||
queryWrapper.notLike(YxHistoryMajorEnroll::getRulesEnrollProbability,"文过专排");
|
|
||||||
queryWrapper.notLike(YxHistoryMajorEnroll::getRulesEnrollProbability,"专过文排");
|
|
||||||
//queryWrapper.notIn(YxHistoryMajorEnroll::getRulesEnrollProbability,"文+专","专+文");
|
|
||||||
List<YxHistoryMajorEnroll> list = yxHistoryMajorEnrollService.list(queryWrapper);
|
|
||||||
for (YxHistoryMajorEnroll yxSchoolMajor : list) {
|
|
||||||
String[] split = yxSchoolMajor.getRulesEnrollProbability().split("专");
|
|
||||||
String w=null,z=null;
|
|
||||||
BigDecimal wb=null;
|
|
||||||
BigDecimal zb=null;
|
|
||||||
for (String s : split) {
|
|
||||||
w = null;
|
|
||||||
z = null;
|
|
||||||
if (s.contains("文")) {
|
|
||||||
wb = new BigDecimal(s.replace("文",""));
|
|
||||||
}else{
|
|
||||||
zb = new BigDecimal(s.replace("专",""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println(yxSchoolMajor.getRulesEnrollProbability()+":");
|
|
||||||
System.out.print("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
|
||||||
System.out.println();
|
|
||||||
yxSchoolMajor.setRulesEnrollProbability("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
|
||||||
}
|
|
||||||
yxHistoryMajorEnrollService.updateBatchById(list);
|
|
||||||
return Result.OK();
|
|
||||||
}
|
|
||||||
if(false){
|
|
||||||
LambdaQueryWrapper<YxSchoolMajor> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.isNotNull(YxSchoolMajor::getRulesEnrollProbability);
|
|
||||||
queryWrapper.like(YxSchoolMajor::getRulesEnrollProbability,"+");
|
|
||||||
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"*");
|
|
||||||
queryWrapper.notIn(YxSchoolMajor::getRulesEnrollProbability,"文+专","专+文");
|
|
||||||
List<YxSchoolMajor> yxSchoolMajorList = yxSchoolMajorService.list(queryWrapper);
|
|
||||||
for (YxSchoolMajor yxSchoolMajor : yxSchoolMajorList) {
|
|
||||||
System.out.println(yxSchoolMajor.getRulesEnrollProbability()+":");
|
|
||||||
String[] split = yxSchoolMajor.getRulesEnrollProbability().split("\\+");
|
|
||||||
String w=null,z=null;
|
|
||||||
BigDecimal wb=null;
|
|
||||||
BigDecimal zb=null;
|
|
||||||
for (String s : split) {
|
|
||||||
w = null;
|
|
||||||
z = null;
|
|
||||||
try {
|
|
||||||
if (s.contains("文")) {
|
|
||||||
wb = new BigDecimal(s.replace("文",""));
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
System.out.println("--"+yxSchoolMajor.getRulesEnrollProbability());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (s.contains("专")) {
|
|
||||||
zb = new BigDecimal(s.replace("专",""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.print("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
|
||||||
System.out.println();
|
|
||||||
yxSchoolMajor.setRulesEnrollProbability("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
|
||||||
}
|
|
||||||
yxSchoolMajorService.updateBatchById(yxSchoolMajorList);
|
|
||||||
return Result.OK();
|
|
||||||
}
|
|
||||||
//分页
|
//分页
|
||||||
Integer pageNum = queryArticleVO.getPageNum();
|
Integer pageNum = queryArticleVO.getPageNum();
|
||||||
Integer pageSize = queryArticleVO.getPageSize();
|
Integer pageSize = queryArticleVO.getPageSize();
|
||||||
|
String schoolId = queryArticleVO.getSchoolId();
|
||||||
Integer type = queryArticleVO.getType();
|
Integer type = queryArticleVO.getType();
|
||||||
if (null == type) {
|
if (null == type) {
|
||||||
type = 0;
|
type = 0;
|
||||||
|
|
@ -205,6 +89,7 @@ public class MiniArticleController {
|
||||||
//redis不存在,从数据库获取
|
//redis不存在,从数据库获取
|
||||||
LambdaQueryWrapper<YxArticle> yxArticleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<YxArticle> yxArticleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
yxArticleLambdaQueryWrapper.eq(YxArticle::getType, type);
|
yxArticleLambdaQueryWrapper.eq(YxArticle::getType, type);
|
||||||
|
yxArticleLambdaQueryWrapper.eq(StringUtils.isNotBlank(schoolId),YxArticle::getSchoolId,schoolId);
|
||||||
yxArticleLambdaQueryWrapper.orderByDesc(YxArticle::getCreateTime, YxArticle::getUpdateTime);
|
yxArticleLambdaQueryWrapper.orderByDesc(YxArticle::getCreateTime, YxArticle::getUpdateTime);
|
||||||
pageList = yxArticleService.page(new Page<>(pageNum, pageSize), yxArticleLambdaQueryWrapper);
|
pageList = yxArticleService.page(new Page<>(pageNum, pageSize), yxArticleLambdaQueryWrapper);
|
||||||
//json = JSONArray.toJSONString(pageList);
|
//json = JSONArray.toJSONString(pageList);
|
||||||
|
|
@ -305,4 +190,106 @@ public class MiniArticleController {
|
||||||
public Result<?> articleContent(@PathVariable String articleId) {
|
public Result<?> articleContent(@PathVariable String articleId) {
|
||||||
return Result.OK(miniArticleService.getArticleDtoById(articleId));
|
return Result.OK(miniArticleService.getArticleDtoById(articleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*if(false){
|
||||||
|
LambdaQueryWrapper<YxSchoolMajor> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.isNotNull(YxSchoolMajor::getRulesEnrollProbability);
|
||||||
|
queryWrapper.like(YxSchoolMajor::getRulesEnrollProbability,"专");
|
||||||
|
queryWrapper.like(YxSchoolMajor::getRulesEnrollProbability,"文");
|
||||||
|
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"+");
|
||||||
|
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"文过专排");
|
||||||
|
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"专过文排");
|
||||||
|
//queryWrapper.notIn(YxHistoryMajorEnroll::getRulesEnrollProbability,"文+专","专+文");
|
||||||
|
List<YxSchoolMajor> list = yxSchoolMajorService.list(queryWrapper);
|
||||||
|
for (YxSchoolMajor yxSchoolMajor : list) {
|
||||||
|
String[] split = yxSchoolMajor.getRulesEnrollProbability().split("专");
|
||||||
|
String w=null,z=null;
|
||||||
|
BigDecimal wb=null;
|
||||||
|
BigDecimal zb=null;
|
||||||
|
for (String s : split) {
|
||||||
|
w = null;
|
||||||
|
z = null;
|
||||||
|
if (s.contains("文")) {
|
||||||
|
wb = new BigDecimal(s.replace("文",""));
|
||||||
|
}else{
|
||||||
|
zb = new BigDecimal(s.replace("专",""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(yxSchoolMajor.getRulesEnrollProbability()+":");
|
||||||
|
System.out.print("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
||||||
|
System.out.println();
|
||||||
|
yxSchoolMajor.setRulesEnrollProbability("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
||||||
|
}
|
||||||
|
yxSchoolMajorService.updateBatchById(list);
|
||||||
|
return Result.OK();
|
||||||
|
}
|
||||||
|
if(false){
|
||||||
|
LambdaQueryWrapper<YxHistoryMajorEnroll> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.isNotNull(YxHistoryMajorEnroll::getRulesEnrollProbability);
|
||||||
|
queryWrapper.like(YxHistoryMajorEnroll::getRulesEnrollProbability,"专");
|
||||||
|
queryWrapper.like(YxHistoryMajorEnroll::getRulesEnrollProbability,"文");
|
||||||
|
queryWrapper.notLike(YxHistoryMajorEnroll::getRulesEnrollProbability,"+");
|
||||||
|
queryWrapper.notLike(YxHistoryMajorEnroll::getRulesEnrollProbability,"文过专排");
|
||||||
|
queryWrapper.notLike(YxHistoryMajorEnroll::getRulesEnrollProbability,"专过文排");
|
||||||
|
//queryWrapper.notIn(YxHistoryMajorEnroll::getRulesEnrollProbability,"文+专","专+文");
|
||||||
|
List<YxHistoryMajorEnroll> list = yxHistoryMajorEnrollService.list(queryWrapper);
|
||||||
|
for (YxHistoryMajorEnroll yxSchoolMajor : list) {
|
||||||
|
String[] split = yxSchoolMajor.getRulesEnrollProbability().split("专");
|
||||||
|
String w=null,z=null;
|
||||||
|
BigDecimal wb=null;
|
||||||
|
BigDecimal zb=null;
|
||||||
|
for (String s : split) {
|
||||||
|
w = null;
|
||||||
|
z = null;
|
||||||
|
if (s.contains("文")) {
|
||||||
|
wb = new BigDecimal(s.replace("文",""));
|
||||||
|
}else{
|
||||||
|
zb = new BigDecimal(s.replace("专",""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(yxSchoolMajor.getRulesEnrollProbability()+":");
|
||||||
|
System.out.print("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
||||||
|
System.out.println();
|
||||||
|
yxSchoolMajor.setRulesEnrollProbability("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
||||||
|
}
|
||||||
|
yxHistoryMajorEnrollService.updateBatchById(list);
|
||||||
|
return Result.OK();
|
||||||
|
}
|
||||||
|
if(false){
|
||||||
|
LambdaQueryWrapper<YxSchoolMajor> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.isNotNull(YxSchoolMajor::getRulesEnrollProbability);
|
||||||
|
queryWrapper.like(YxSchoolMajor::getRulesEnrollProbability,"+");
|
||||||
|
queryWrapper.notLike(YxSchoolMajor::getRulesEnrollProbability,"*");
|
||||||
|
queryWrapper.notIn(YxSchoolMajor::getRulesEnrollProbability,"文+专","专+文");
|
||||||
|
List<YxSchoolMajor> yxSchoolMajorList = yxSchoolMajorService.list(queryWrapper);
|
||||||
|
for (YxSchoolMajor yxSchoolMajor : yxSchoolMajorList) {
|
||||||
|
System.out.println(yxSchoolMajor.getRulesEnrollProbability()+":");
|
||||||
|
String[] split = yxSchoolMajor.getRulesEnrollProbability().split("\\+");
|
||||||
|
String w=null,z=null;
|
||||||
|
BigDecimal wb=null;
|
||||||
|
BigDecimal zb=null;
|
||||||
|
for (String s : split) {
|
||||||
|
w = null;
|
||||||
|
z = null;
|
||||||
|
try {
|
||||||
|
if (s.contains("文")) {
|
||||||
|
wb = new BigDecimal(s.replace("文",""));
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
System.out.println("--"+yxSchoolMajor.getRulesEnrollProbability());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (s.contains("专")) {
|
||||||
|
zb = new BigDecimal(s.replace("专",""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.print("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
||||||
|
System.out.println();
|
||||||
|
yxSchoolMajor.setRulesEnrollProbability("文*"+wb.stripTrailingZeros().toPlainString()+"+专*"+zb.stripTrailingZeros().toPlainString());
|
||||||
|
}
|
||||||
|
yxSchoolMajorService.updateBatchById(yxSchoolMajorList);
|
||||||
|
return Result.OK();
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
||||||
import org.jeecg.modules.yx.service.IYxMajorService;
|
import org.jeecg.modules.yx.service.IYxMajorService;
|
||||||
|
import org.jeecg.modules.yx.service.IYxSchoolMajorService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -23,7 +24,14 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
public class MiniMajorController {
|
public class MiniMajorController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IYxMajorService yxMajorService;
|
private IYxMajorService yxMajorService;
|
||||||
|
@Autowired
|
||||||
|
private IYxSchoolMajorService yxSchoolMajorService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取院校当前其他推荐专业")
|
||||||
|
@GetMapping(value = "/schoolOtherMajor")
|
||||||
|
public Result<?> schoolOtherMajor(QueryRecommendMajorVO queryRecommendMajorVO){
|
||||||
|
return Result.OK(yxSchoolMajorService.schoolOtherMajor(queryRecommendMajorVO));
|
||||||
|
}
|
||||||
@ApiOperation(value = "专业介绍")
|
@ApiOperation(value = "专业介绍")
|
||||||
@GetMapping("/majorInfo")
|
@GetMapping("/majorInfo")
|
||||||
public Result<?> schoolInfo(QueryRecommendMajorVO queryRecommendMajorVO){
|
public Result<?> schoolInfo(QueryRecommendMajorVO queryRecommendMajorVO){
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,189 @@
|
||||||
|
package org.jeecg.modules.mini.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.xkcoding.http.HttpUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
import org.jeecg.common.exception.JeecgBootException;
|
||||||
|
import org.jeecg.common.system.util.JwtUtil;
|
||||||
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
|
import org.jeecg.common.util.AssertUtils;
|
||||||
|
import org.jeecg.common.util.PasswordUtil;
|
||||||
|
import org.jeecg.common.util.RedisUtil;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.modules.mini.dto.VipDTO;
|
||||||
|
import org.jeecg.modules.mini.service.MiniUserService;
|
||||||
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
|
import org.jeecg.modules.system.model.WxModel;
|
||||||
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
|
import org.jeecg.modules.yx.service.IYxOrderService;
|
||||||
|
import org.jeecg.modules.yx.service.IYxUserScoreService;
|
||||||
|
import org.jeecg.modules.yx.service.IYxVipCardService;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.KeyGenerator;
|
||||||
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author ZhouWenTao
|
||||||
|
* @Date 2024/3/8 12:18
|
||||||
|
*/
|
||||||
|
@RequestMapping("/mini/user")
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "小程序用户接口")
|
||||||
|
public class MiniUserController {
|
||||||
|
@Value("${wx.appId}")
|
||||||
|
private String wxAppId;
|
||||||
|
@Value("${wx.appSecret}")
|
||||||
|
private String wxAppSecret;
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
@Autowired
|
||||||
|
private IYxUserScoreService yxUserScoreService;
|
||||||
|
@Autowired
|
||||||
|
private IYxVipCardService yxVipCardService;
|
||||||
|
@Autowired
|
||||||
|
private IYxOrderService yxOrderService;
|
||||||
|
@Autowired
|
||||||
|
private MiniUserService miniUserService;
|
||||||
|
public static final String AES = "AES";
|
||||||
|
public static final String AES_CBC_PADDING = "AES/CBC/PKCS7Padding";
|
||||||
|
|
||||||
|
@PostMapping(value = "/editUserInfo")
|
||||||
|
@ApiOperation(value = "编辑用户信息")
|
||||||
|
public Result<?> editUserInfo(@RequestBody SysUser sysUser) {
|
||||||
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
AssertUtils.notNull(user, "获取当前用户信息失败");
|
||||||
|
try {
|
||||||
|
String id = user.getId();
|
||||||
|
LambdaUpdateWrapper<SysUser> objectLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
objectLambdaUpdateWrapper.eq(SysUser::getId, id);
|
||||||
|
objectLambdaUpdateWrapper.set(SysUser::getRealname, sysUser.getRealname());
|
||||||
|
sysUserService.update(objectLambdaUpdateWrapper);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new JeecgBootException(e);
|
||||||
|
}
|
||||||
|
return Result.OK("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/phoneLogin")
|
||||||
|
@ApiOperation(value = "小程序手机号登录")
|
||||||
|
public Result<?> wechatLogin(@NotNull @RequestBody WxModel wxModel) {
|
||||||
|
String url = "https://api.weixin.qq.com/sns/jscode2session" +
|
||||||
|
"?appid=" + wxAppId +
|
||||||
|
"&secret=" + wxAppSecret +
|
||||||
|
"&grant_type=authorization_code" +
|
||||||
|
"&js_code=" + wxModel.code;
|
||||||
|
String s = HttpUtil.get(url);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||||
|
AssertUtils.notNull(jsonObject, "登录失败");
|
||||||
|
String openId = jsonObject.getString("openid");
|
||||||
|
String sessionKey = jsonObject.getString("session_key");
|
||||||
|
SysUser user = sysUserService.getByWxOpenId(openId);
|
||||||
|
if (user == null) {
|
||||||
|
String salt = oConvertUtils.randomGen(8);
|
||||||
|
//新用户
|
||||||
|
user = new SysUser();
|
||||||
|
user.setWxOpenId(openId);
|
||||||
|
user.setUsername(salt);
|
||||||
|
user.setRealname("用户+" + salt);
|
||||||
|
user.setSalt(salt);
|
||||||
|
String encryptPassword = PasswordUtil.encrypt(salt, "123456", salt);
|
||||||
|
user.setPassword(encryptPassword);
|
||||||
|
user.setStatus(1);
|
||||||
|
//解密手机号
|
||||||
|
user.setPhone(phoneDecrypt(wxModel.getEncryptedData(), sessionKey, wxModel.getIv()));
|
||||||
|
user.setUserIdentity(CommonConstant.USER_IDENTITY_1);
|
||||||
|
user.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||||
|
user.setOrgCode(null);
|
||||||
|
sysUserService.saveUser(user, null, null, null);
|
||||||
|
}
|
||||||
|
String username = user.getUsername();
|
||||||
|
String syspassword = user.getPassword();
|
||||||
|
//1.生成token
|
||||||
|
String token = JwtUtil.sign(username, syspassword);
|
||||||
|
// 设置token缓存有效时间
|
||||||
|
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||||
|
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
BeanUtils.copyProperties(user, loginUser);
|
||||||
|
//获取vip信息
|
||||||
|
VipDTO vipDTO = miniUserService.getUserVip(user.getId());
|
||||||
|
if (vipDTO!=null) {
|
||||||
|
obj.put("vipInfo",vipDTO);
|
||||||
|
}else{
|
||||||
|
obj.put("vipInfo",null);
|
||||||
|
}
|
||||||
|
obj.put("token", token);
|
||||||
|
obj.put("openId", openId);
|
||||||
|
obj.put("sessionKey", sessionKey);
|
||||||
|
obj.put("userInfo", loginUser);
|
||||||
|
return Result.OK(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密手机号
|
||||||
|
*/
|
||||||
|
@PostMapping("/phoneNumberDecrypt")
|
||||||
|
public Result<?> phoneDecrypt(@RequestBody WxModel wxModel) {
|
||||||
|
//判断密文信息是否为空
|
||||||
|
if (StringUtils.isNotBlank(wxModel.getSessionKey()) && StringUtils.isNotBlank(wxModel.getEncryptedData()) && StringUtils.isNotBlank(wxModel.getIv())) {
|
||||||
|
//解密出手机号
|
||||||
|
String phoneNumber = phoneDecrypt(wxModel.getEncryptedData(), wxModel.getSessionKey(), wxModel.getIv());
|
||||||
|
//获取该用户
|
||||||
|
SysUser sysUser = sysUserService.getByWxOpenId(wxModel.getOpenId());
|
||||||
|
if (sysUser != null) {
|
||||||
|
//更新用户手机号
|
||||||
|
sysUser.setPhone(phoneNumber);
|
||||||
|
sysUserService.updateById(sysUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String phoneDecrypt(String encrypted, String sessionKey, String iv) {
|
||||||
|
String phoneNumber = null;
|
||||||
|
try {
|
||||||
|
byte[] encrypdata = cn.hutool.core.codec.Base64.decode(encrypted);
|
||||||
|
byte[] ivData = cn.hutool.core.codec.Base64.decode(iv);
|
||||||
|
byte[] sessionKeyByte = cn.hutool.core.codec.Base64.decode(sessionKey);
|
||||||
|
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData);
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||||
|
SecretKeySpec keySpec = new SecretKeySpec(sessionKeyByte, "AES");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
|
||||||
|
//解析解密后的手机号
|
||||||
|
String data = new String(cipher.doFinal(encrypdata), "UTF-8");
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
|
phoneNumber = jsonObject.getString("phoneNumber");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("解密与微信绑定的手机号失败", e);
|
||||||
|
}
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 初始化密钥
|
||||||
|
*/
|
||||||
|
public static void init() throws Exception {
|
||||||
|
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||||
|
KeyGenerator.getInstance(AES).init(128);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,8 @@ import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.exception.JeecgBootException;
|
import org.jeecg.common.exception.JeecgBootException;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.common.util.AssertUtils;
|
import org.jeecg.common.util.AssertUtils;
|
||||||
|
import org.jeecg.modules.mini.dto.VipDTO;
|
||||||
|
import org.jeecg.modules.mini.service.MiniUserService;
|
||||||
import org.jeecg.modules.system.entity.SysUser;
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
import org.jeecg.modules.system.service.ISysUserService;
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
import org.jeecg.modules.yx.entity.YxOrder;
|
import org.jeecg.modules.yx.entity.YxOrder;
|
||||||
|
|
@ -43,13 +45,23 @@ public class MiniVipController {
|
||||||
private IYxOrderService yxOrderService;
|
private IYxOrderService yxOrderService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IYxVipSkuService yxVipSkuService;
|
private IYxVipSkuService yxVipSkuService;
|
||||||
|
@Autowired
|
||||||
|
private MiniUserService miniUserService;
|
||||||
|
@GetMapping(value = "/getVipInfo")
|
||||||
|
@ApiOperation(value = "获取vip信息")
|
||||||
|
public Result<?> vipInfo(){
|
||||||
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
AssertUtils.notNull(loginUser,"未获取到登录信息");
|
||||||
|
VipDTO userVip = miniUserService.getUserVip(loginUser.getId());
|
||||||
|
return Result.OK(userVip);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/sku/all")
|
@GetMapping(value = "/sku/all")
|
||||||
@ApiOperation(value = "获取全部商品信息")
|
@ApiOperation(value = "获取全部商品信息")
|
||||||
public Result<?> skuAll(){
|
public Result<?> skuAll(){
|
||||||
LambdaQueryWrapper<YxVipSku> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<YxVipSku> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(YxVipSku::getSaleable, "1");
|
queryWrapper.eq(YxVipSku::getSaleable, "1");
|
||||||
queryWrapper.orderByAsc(YxVipSku::getSkuPrice);
|
queryWrapper.orderByDesc(YxVipSku::getSkuPrice);
|
||||||
List<YxVipSku> list = yxVipSkuService.list(queryWrapper);
|
List<YxVipSku> list = yxVipSkuService.list(queryWrapper);
|
||||||
return Result.OK(list);
|
return Result.OK(list);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.jeecg.modules.wx.controller;
|
package org.jeecg.modules.mini.controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description
|
* @Description
|
||||||
|
|
@ -38,6 +38,8 @@ import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.exception.JeecgBootException;
|
import org.jeecg.common.exception.JeecgBootException;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.common.util.AssertUtils;
|
import org.jeecg.common.util.AssertUtils;
|
||||||
|
import org.jeecg.modules.mini.dto.VipDTO;
|
||||||
|
import org.jeecg.modules.mini.service.MiniUserService;
|
||||||
import org.jeecg.modules.system.entity.SysUser;
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
import org.jeecg.modules.system.service.ISysUserService;
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
import org.jeecg.modules.yx.entity.YxOrder;
|
import org.jeecg.modules.yx.entity.YxOrder;
|
||||||
|
|
@ -55,6 +57,7 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -76,6 +79,8 @@ public class WxPayApiController {
|
||||||
private IYxOrderService yxOrderService;
|
private IYxOrderService yxOrderService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IYxVipSkuService yxVipSkuService;
|
private IYxVipSkuService yxVipSkuService;
|
||||||
|
@Autowired
|
||||||
|
private MiniUserService miniUserService;
|
||||||
/**微信小程序appid**/
|
/**微信小程序appid**/
|
||||||
@Value("${wx.appId}")
|
@Value("${wx.appId}")
|
||||||
String appid;
|
String appid;
|
||||||
|
|
@ -120,6 +125,13 @@ public class WxPayApiController {
|
||||||
//获取库存信息
|
//获取库存信息
|
||||||
YxVipSku yxVipSku = yxVipSkuService.getBySkuCode(skuCode);
|
YxVipSku yxVipSku = yxVipSkuService.getBySkuCode(skuCode);
|
||||||
AssertUtils.notNull(yxVipSku,"获取商品信息失败,请联系管理员");
|
AssertUtils.notNull(yxVipSku,"获取商品信息失败,请联系管理员");
|
||||||
|
//判断用户是否已购买过该会员
|
||||||
|
VipDTO userVip = miniUserService.getUserVip(user.getId());
|
||||||
|
if (userVip!=null) {
|
||||||
|
//如果这个会员已经买过了,提示不可重复购买
|
||||||
|
AssertUtils.notTrue(skuCode.equals(userVip.getSkuCode()),"该权益您已购买!不可重复购买");
|
||||||
|
}
|
||||||
|
|
||||||
YxOrder yxOrder = new YxOrder();
|
YxOrder yxOrder = new YxOrder();
|
||||||
String orderCode = PayKit.generateStr();
|
String orderCode = PayKit.generateStr();
|
||||||
String openId = user.getWxOpenId();
|
String openId = user.getWxOpenId();
|
||||||
|
|
@ -172,6 +184,7 @@ public class WxPayApiController {
|
||||||
String jsonStr = JSONUtil.toJsonStr(map);
|
String jsonStr = JSONUtil.toJsonStr(map);
|
||||||
//==============创建订单信息 Start
|
//==============创建订单信息 Start
|
||||||
yxOrder.setOrderCode(orderCode);//orderCode
|
yxOrder.setOrderCode(orderCode);//orderCode
|
||||||
|
yxOrder.setSkuCode(skuCode);//vip商品Code
|
||||||
yxOrder.setOrderStatus("0");//订单状态
|
yxOrder.setOrderStatus("0");//订单状态
|
||||||
yxOrder.setTotalAmount(totalAmount);//金额
|
yxOrder.setTotalAmount(totalAmount);//金额
|
||||||
yxOrder.setPaymentUserId(user.getId());//付款人
|
yxOrder.setPaymentUserId(user.getId());//付款人
|
||||||
|
|
@ -215,7 +228,7 @@ public class WxPayApiController {
|
||||||
String tradeState = plainTextJson.getString("trade_state");
|
String tradeState = plainTextJson.getString("trade_state");
|
||||||
if ("SUCCESS".equals(tradeState)) {
|
if ("SUCCESS".equals(tradeState)) {
|
||||||
//支付成功
|
//支付成功
|
||||||
yxOrderService.update(new LambdaUpdateWrapper<YxOrder>().set(YxOrder::getOrderCode,outTradeNo).set(YxOrder::getOrderStatus,"2"));
|
yxOrderService.update(new LambdaUpdateWrapper<YxOrder>().set(YxOrder::getOrderCode,outTradeNo).set(YxOrder::getPaymentTime,new Date()).set(YxOrder::getOrderStatus,"2"));
|
||||||
}
|
}
|
||||||
//支付成功,修改订单信息
|
//支付成功,修改订单信息
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.jeecg.modules.mini.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description vip信息
|
||||||
|
* @Author ZhouWenTao
|
||||||
|
* @Date 2024/3/8 11:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class VipDTO implements Serializable {
|
||||||
|
/**
|
||||||
|
* vip商品编码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "vip编码")
|
||||||
|
private String skuCode;
|
||||||
|
/**
|
||||||
|
* vip等级
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "vip等级")
|
||||||
|
private Integer vipLevel = 0;
|
||||||
|
/**
|
||||||
|
* vip激活时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date activationTime;
|
||||||
|
/**
|
||||||
|
* vip有效期至
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "有效期至")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date validTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
package org.jeecg.modules.mini.service;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jeecg.common.util.RedisUtil;
|
||||||
|
import org.jeecg.modules.mini.dto.VipDTO;
|
||||||
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
|
import org.jeecg.modules.yx.entity.YxOrder;
|
||||||
|
import org.jeecg.modules.yx.entity.YxVipCard;
|
||||||
|
import org.jeecg.modules.yx.service.IYxOrderService;
|
||||||
|
import org.jeecg.modules.yx.service.IYxVipCardService;
|
||||||
|
import org.jeecg.modules.yx.service.IYxVipSkuService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 小程序端 用户service
|
||||||
|
* @Author ZhouWenTao
|
||||||
|
* @Date 2024/3/8 10:42
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class MiniUserService {
|
||||||
|
@Resource
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
@Resource
|
||||||
|
private IYxVipCardService yxVipCardService;
|
||||||
|
@Resource
|
||||||
|
private IYxOrderService yxOrderService;
|
||||||
|
@Resource
|
||||||
|
private IYxVipSkuService yxVipSkuService;
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
public static SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
/**
|
||||||
|
* 根据userId获取用户VIP信息
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public VipDTO getUserVip(String userId) {
|
||||||
|
VipDTO vipDTO=new VipDTO();
|
||||||
|
Integer level = 0;//等级
|
||||||
|
String skuCode = null;//vip商品编码
|
||||||
|
Date activationTime = null;//激活时间
|
||||||
|
Date validTime = null;//有效期至
|
||||||
|
|
||||||
|
//先判断是不是VIP激活的
|
||||||
|
List<YxVipCard> vipCardList = yxVipCardService.selectByUserId(userId);
|
||||||
|
if (CollectionUtils.isNotEmpty(vipCardList)) {
|
||||||
|
YxVipCard yxVipCard = vipCardList.get(0);
|
||||||
|
skuCode =yxVipCard.getSkuCode();
|
||||||
|
validTime = yxVipCard.getValidDate();
|
||||||
|
activationTime = yxVipCard.getUsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断支付订单中的
|
||||||
|
if(StringUtils.isBlank(skuCode) || vipDTO.getVipLevel()<2){
|
||||||
|
List<YxOrder> yxOrderList = yxOrderService.findListByPaymentUserId(userId);
|
||||||
|
List<YxOrder> paymentOrderList = yxOrderList.stream().filter(y -> "2".equals(y.getOrderStatus())).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(paymentOrderList)) {
|
||||||
|
YxOrder yxOrder = paymentOrderList.get(0);
|
||||||
|
skuCode = yxOrder.getSkuCode();
|
||||||
|
activationTime = yxOrder.getPaymentTime();
|
||||||
|
try {
|
||||||
|
//有效期至(开通时间那年的8月-31日)
|
||||||
|
Calendar calendar=Calendar.getInstance();
|
||||||
|
calendar.setTime(activationTime);
|
||||||
|
int year = calendar.get(Calendar.YEAR);
|
||||||
|
validTime = simpleDateFormat.parse(year+"-08-31 23:59:59");
|
||||||
|
}catch (ParseException e){
|
||||||
|
//转换vip订单有效期出错
|
||||||
|
log.error("转换vip订单有效期出错,userId:"+userId+",orderId:"+yxOrder.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取到了vip信息
|
||||||
|
if (StringUtils.isNoneBlank(skuCode)) {
|
||||||
|
if ("1001".equals(skuCode)) {
|
||||||
|
vipDTO.setVipLevel(1);
|
||||||
|
}else if("1002".equals(skuCode)){
|
||||||
|
vipDTO.setVipLevel(2);
|
||||||
|
}else if("1003".equals(skuCode)){
|
||||||
|
vipDTO.setVipLevel(3);
|
||||||
|
}else if("1004".equals(skuCode)){
|
||||||
|
vipDTO.setVipLevel(4);
|
||||||
|
}else{
|
||||||
|
vipDTO.setVipLevel(9);
|
||||||
|
}
|
||||||
|
vipDTO.setSkuCode(skuCode);
|
||||||
|
vipDTO.setActivationTime(activationTime);
|
||||||
|
vipDTO.setValidTime(validTime);
|
||||||
|
}
|
||||||
|
return vipDTO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.jeecg.modules.wx.model;
|
package org.jeecg.modules.mini.wx.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.jeecg.modules.wx.service;
|
package org.jeecg.modules.mini.wx.service;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.jeecg.modules.wx.vo;
|
package org.jeecg.modules.mini.wx.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.jeecg.modules.wx.vo;
|
package org.jeecg.modules.mini.wx.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -99,15 +99,6 @@ public class YxScoreController {
|
||||||
AssertUtils.notTrue(professionalScore.compareTo(YxConstant.bigDecimal300) > 0,"[统考成绩]最高分为300");
|
AssertUtils.notTrue(professionalScore.compareTo(YxConstant.bigDecimal300) > 0,"[统考成绩]最高分为300");
|
||||||
AssertUtils.notTrue(professionalScore.compareTo(YxConstant.bigDecimal0) < 0,"[统考成绩]最低分为0");
|
AssertUtils.notTrue(professionalScore.compareTo(YxConstant.bigDecimal0) < 0,"[统考成绩]最低分为0");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*String professionalScore = requestBody.getString("professionalScore");String culturalScore = requestBody.getString("culturalScore");String chineseScore = requestBody.getString("chineseScore");String englishScore = requestBody.getString("englishScore");
|
|
||||||
if (!StringUtils.isNumeric(professionalScore)) {return Result.error("统考成绩仅可输入数字");}if (!StringUtils.isNumeric(culturalScore)) {return Result.error("文化成绩仅可输入数字");}
|
|
||||||
if (!StringUtils.isNumeric(chineseScore)) {return Result.error("语文成绩仅可输入数字");}if (!StringUtils.isNumeric(englishScore)) {return Result.error("英语成绩仅可输入数字");}
|
|
||||||
yxUserScore.setProfessionalScore(new BigDecimal(professionalScore));//专业成绩,统考分
|
|
||||||
yxUserScore.setCulturalScore(new BigDecimal(culturalScore));//文化成绩分
|
|
||||||
yxUserScore.setChineseScore(new BigDecimal(chineseScore));//语文成绩
|
|
||||||
yxUserScore.setEnglishScore(new BigDecimal(englishScore));//英语成绩*/
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(professionalCategoryChildren)) {
|
if (StringUtils.isBlank(professionalCategoryChildren)) {
|
||||||
if (!professionalCategoryChildren.contains("音乐表演声乐")) {
|
if (!professionalCategoryChildren.contains("音乐表演声乐")) {
|
||||||
yxUserScore.setYybysy(YxConstant.bigDecimal0);
|
yxUserScore.setYybysy(YxConstant.bigDecimal0);
|
||||||
|
|
@ -123,7 +114,6 @@ public class YxScoreController {
|
||||||
yxUserScore.setXjysby(YxConstant.bigDecimal0);
|
yxUserScore.setXjysby(YxConstant.bigDecimal0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============判断 批次 start
|
//==============判断 批次 start
|
||||||
LambdaQueryWrapper<YxHistoryScoreControlLine> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<YxHistoryScoreControlLine> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(YxHistoryScoreControlLine::getYear,YxConstant.nowYear);//24年省控线
|
lambdaQueryWrapper.eq(YxHistoryScoreControlLine::getYear,YxConstant.nowYear);//24年省控线
|
||||||
|
|
@ -214,6 +204,16 @@ public class YxScoreController {
|
||||||
yxVolunteer.setVolunteerName(sdf.format(new Date())+"志愿表");
|
yxVolunteer.setVolunteerName(sdf.format(new Date())+"志愿表");
|
||||||
yxVolunteer.setScoreId(yxUserScore.getId());
|
yxVolunteer.setScoreId(yxUserScore.getId());
|
||||||
yxVolunteer = yxVolunteerService.addNew(yxVolunteer);
|
yxVolunteer = yxVolunteerService.addNew(yxVolunteer);
|
||||||
|
|
||||||
|
//获取志愿单推荐数量
|
||||||
|
ArtRecommendMajorBaseDTO artRecommendMajorBaseDTO = yxSchoolMajorService.recommendMajorCount(new QueryRecommendMajorVO());
|
||||||
|
yxUserScore.setJwtNum(artRecommendMajorBaseDTO.getJwt());
|
||||||
|
yxUserScore.setKcjNum(artRecommendMajorBaseDTO.getKcj());
|
||||||
|
yxUserScore.setKbdNum(artRecommendMajorBaseDTO.getKbd());
|
||||||
|
yxUserScore.setNlqNum(artRecommendMajorBaseDTO.getNan());
|
||||||
|
yxUserScoreService.updateById(yxUserScore);
|
||||||
|
|
||||||
|
//返回对象
|
||||||
JSONObject responseBody=JSONObject.parseObject(JSONObject.toJSONString(yxUserScore));
|
JSONObject responseBody=JSONObject.parseObject(JSONObject.toJSONString(yxUserScore));
|
||||||
responseBody.put("volunteer",yxVolunteer);
|
responseBody.put("volunteer",yxVolunteer);
|
||||||
return Result.OK(responseBody);
|
return Result.OK(responseBody);
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@ public class YxOrder implements Serializable {
|
||||||
@Excel(name = "购买用户id", width = 15)
|
@Excel(name = "购买用户id", width = 15)
|
||||||
@ApiModelProperty(value = "购买用户id")
|
@ApiModelProperty(value = "购买用户id")
|
||||||
private java.lang.String paymentUserId;
|
private java.lang.String paymentUserId;
|
||||||
|
/**支付日期*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "支付日期")
|
||||||
|
private java.util.Date paymentTime;
|
||||||
/**创建人*/
|
/**创建人*/
|
||||||
@ApiModelProperty(value = "创建人")
|
@ApiModelProperty(value = "创建人")
|
||||||
private java.lang.String createBy;
|
private java.lang.String createBy;
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,17 @@ public class YxUserScore implements Serializable {
|
||||||
@ApiModelProperty(value = "戏剧影视表演")
|
@ApiModelProperty(value = "戏剧影视表演")
|
||||||
private BigDecimal xjysby;
|
private BigDecimal xjysby;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "可保底专业数量")
|
||||||
|
private Integer kbdNum;
|
||||||
|
@ApiModelProperty(value = "较稳妥专业数量")
|
||||||
|
private Integer jwtNum;
|
||||||
|
@ApiModelProperty(value = "可冲击专业数量")
|
||||||
|
private Integer kcjNum;
|
||||||
|
@ApiModelProperty(value = "难录取专业数量")
|
||||||
|
private Integer nlqNum;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===================
|
//===================
|
||||||
/*是否是vip 0-不是,1-是*/
|
/*是否是vip 0-不是,1-是*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,22 @@ public class YxVipCard implements Serializable {
|
||||||
@Excel(name = "卡号", width = 15)
|
@Excel(name = "卡号", width = 15)
|
||||||
@ApiModelProperty(value = "卡号")
|
@ApiModelProperty(value = "卡号")
|
||||||
private java.lang.String cardNum;
|
private java.lang.String cardNum;
|
||||||
|
/**对应产品编号*/
|
||||||
|
@Excel(name = "对应产品编号", width = 15)
|
||||||
|
@ApiModelProperty(value = "对应产品编号")
|
||||||
|
private java.lang.String skuCode;
|
||||||
/**有效日期*/
|
/**有效日期*/
|
||||||
@Excel(name = "有效日期", width = 15, format = "yyyy-MM-dd")
|
@Excel(name = "有效日期", width = 15, format = "yyyy-MM-dd")
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
@ApiModelProperty(value = "有效日期")
|
@ApiModelProperty(value = "有效日期")
|
||||||
private java.util.Date validDate;
|
private java.util.Date validDate;
|
||||||
|
/**使用时间*/
|
||||||
|
@Excel(name = "使用时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "使用时间")
|
||||||
|
private java.util.Date usedTime;
|
||||||
/**兑换用户id*/
|
/**兑换用户id*/
|
||||||
@Excel(name = "兑换用户id", width = 15)
|
@Excel(name = "兑换用户id", width = 15)
|
||||||
@ApiModelProperty(value = "兑换用户id")
|
@ApiModelProperty(value = "兑换用户id")
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface YxOrderMapper extends BaseMapper<YxOrder> {
|
public interface YxOrderMapper extends BaseMapper<YxOrder> {
|
||||||
|
|
||||||
|
List<YxOrder> findListByPaymentUserId(String paymentUserId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,10 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="org.jeecg.modules.yx.mapper.YxOrderMapper">
|
<mapper namespace="org.jeecg.modules.yx.mapper.YxOrderMapper">
|
||||||
|
|
||||||
|
<select id="findListByPaymentUserId" resultType="org.jeecg.modules.yx.entity.YxOrder">
|
||||||
|
SELECT o.* FROM yx_order o
|
||||||
|
LEFT JOIN yx_vip_sku vsku ON vsku.sku_code = o.sku_code
|
||||||
|
WHERE o.payment_user_id = #{paymentUserId}
|
||||||
|
ORDER BY vsku.sku_code,o.payment_time DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.yx.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.art.dto.ArtRecommendMajorBaseDTO;
|
import org.jeecg.modules.art.dto.ArtRecommendMajorBaseDTO;
|
||||||
import org.jeecg.modules.art.dto.RecommendMajorDTO;
|
import org.jeecg.modules.art.dto.RecommendMajorDTO;
|
||||||
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
||||||
|
|
@ -82,4 +83,9 @@ public interface IYxSchoolMajorService extends IService<YxSchoolMajor> {
|
||||||
计算录取率
|
计算录取率
|
||||||
*/
|
*/
|
||||||
void recommendMajorListSetEnrollProbability(List<RecommendMajorDTO> recommendMajorList, YxUserScore activeCurrentUserScore);
|
void recommendMajorListSetEnrollProbability(List<RecommendMajorDTO> recommendMajorList, YxUserScore activeCurrentUserScore);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取院校下其他可报专业
|
||||||
|
*/
|
||||||
|
ArtRecommendMajorBaseDTO schoolOtherMajor(QueryRecommendMajorVO queryRecommendMajorVO);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,8 @@ public class MusicService{
|
||||||
if (!"高职高专".equals(activeCurrentUserScore.getBatch())) {
|
if (!"高职高专".equals(activeCurrentUserScore.getBatch())) {
|
||||||
if ("文过专排主科".equals(recommendMajorDTO.getRulesEnrollProbability())) {
|
if ("文过专排主科".equals(recommendMajorDTO.getRulesEnrollProbability())) {
|
||||||
professionalScore2 = activeCurrentUserScore.getProfessionalScore();
|
professionalScore2 = activeCurrentUserScore.getProfessionalScore();
|
||||||
professionalScore3 = zxcj;
|
professionalScore3 = activeCurrentUserScore.getProfessionalScore().multiply(YxConstant.bigDecimal05);
|
||||||
}if ("1".equals(recommendMajorDTO.getCheckMaster())) {
|
}else if ("1".equals(recommendMajorDTO.getCheckMaster())) {
|
||||||
professionalScore2 = activeCurrentUserScore.getProfessionalScore();
|
professionalScore2 = activeCurrentUserScore.getProfessionalScore();
|
||||||
professionalScore3 = zxcj;
|
professionalScore3 = zxcj;
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@ public class YxOrderServiceImpl extends ServiceImpl<YxOrderMapper, YxOrder> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<YxOrder> findListByPaymentUserId(String paymentUserId) {
|
public List<YxOrder> findListByPaymentUserId(String paymentUserId) {
|
||||||
LambdaQueryWrapper<YxOrder> yxOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
return baseMapper.findListByPaymentUserId(paymentUserId);
|
||||||
yxOrderLambdaQueryWrapper.eq(YxOrder::getPaymentUserId,paymentUserId);
|
|
||||||
return list(yxOrderLambdaQueryWrapper);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ public class YxSchoolMajorServiceImpl extends ServiceImpl<YxSchoolMajorMapper, Y
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//没有往年录取分数线信息
|
//没有往年录取分数线信息
|
||||||
if (CollectionUtils.isEmpty(historyMajorEnrollList) ||!ScoreUtil.hasComputeEnrollProbabilityPermissions(nowBatch,recommendMajorDTO.getBatch())) {
|
if (CollectionUtils.isEmpty(historyMajorEnrollList) || ! (ScoreUtil.hasComputeEnrollProbabilityPermissions(nowBatch, recommendMajorDTO.getBatch()))) {
|
||||||
recommendMajorDTO.setEnrollProbability(YxConstant.bigDecimal0);
|
recommendMajorDTO.setEnrollProbability(YxConstant.bigDecimal0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1201,4 +1201,115 @@ public class YxSchoolMajorServiceImpl extends ServiceImpl<YxSchoolMajorMapper, Y
|
||||||
}
|
}
|
||||||
recommendMajorList.sort((a, b) -> b.getEnrollProbability().compareTo(a.getEnrollProbability()));
|
recommendMajorList.sort((a, b) -> b.getEnrollProbability().compareTo(a.getEnrollProbability()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArtRecommendMajorBaseDTO schoolOtherMajor(QueryRecommendMajorVO queryRecommendMajorVO) {
|
||||||
|
YxUserScore activeCurrentUserScore = yxUserScoreService.getActiveCurrentUserScore();
|
||||||
|
//院校编号,专业类别
|
||||||
|
String schoolCode = queryRecommendMajorVO.getSchoolCode();
|
||||||
|
String professionalCategory = queryRecommendMajorVO.getProfessionalCategory();
|
||||||
|
String nowBatch = queryRecommendMajorVO.getBatch();
|
||||||
|
//有子级专业
|
||||||
|
if (StringUtils.isNotBlank(activeCurrentUserScore.getProfessionalCategoryChildren()) && !"高职高专".equals(queryRecommendMajorVO.getBatch()) && !"高职高专".equals(queryRecommendMajorVO.getBatch())) {
|
||||||
|
queryRecommendMajorVO.setPCategoryChildrenList(new ArrayList<>(Arrays.asList(activeCurrentUserScore.getProfessionalCategoryChildren().split(","))));
|
||||||
|
}
|
||||||
|
List<RecommendMajorDTO> recommendMajorList = this.recommendMajorList(queryRecommendMajorVO);
|
||||||
|
//记录总数
|
||||||
|
String paneName = queryRecommendMajorVO.getPaneName();
|
||||||
|
////计算录取概率
|
||||||
|
if ("高职高专".equals(queryRecommendMajorVO.getBatch())) {
|
||||||
|
zhuanService.zhuanRecommendMajorListSetEnrollProbability(recommendMajorList, activeCurrentUserScore);
|
||||||
|
} else {
|
||||||
|
if (YxConstant.betaMajorTypeList.contains(professionalCategory)) {
|
||||||
|
//如果当前专业是(美术设计类,书法类,体育类)
|
||||||
|
//不需要换算为往年分数
|
||||||
|
betaRecommendMajorListSetEnrollProbability(recommendMajorList, activeCurrentUserScore);
|
||||||
|
} else {
|
||||||
|
if ("音乐类".equals(professionalCategory)) {
|
||||||
|
//音乐类的
|
||||||
|
musicService.musicRecommendMajorListSetEnrollProbability(recommendMajorList, activeCurrentUserScore);
|
||||||
|
} else if ("表演类".equals(professionalCategory)) {
|
||||||
|
biaoyanService.biaoyanRecommendMajorListSetEnrollProbability(recommendMajorList, activeCurrentUserScore);
|
||||||
|
} else if ("舞蹈类".equals(professionalCategory)) {
|
||||||
|
wuDaoService.wudaoRecommendMajorListSetEnrollProbability(recommendMajorList, activeCurrentUserScore);
|
||||||
|
} else if ("播音与主持类".equals(professionalCategory)) {
|
||||||
|
boYinService.boYinRecommendMajorListSetEnrollProbability(recommendMajorList, activeCurrentUserScore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recommendMajorList.sort((a, b) -> b.getEnrollProbability().compareTo(a.getEnrollProbability()));
|
||||||
|
//判断 paneName
|
||||||
|
if (StringUtils.isNotBlank(paneName) && !paneName.equals("全部")) {
|
||||||
|
BigDecimal bigDecimal80 = new BigDecimal("80");
|
||||||
|
BigDecimal bigDecimal50 = new BigDecimal("50");
|
||||||
|
BigDecimal bigDecimal30 = new BigDecimal("30");
|
||||||
|
BigDecimal bigDecimal93 = new BigDecimal("93");
|
||||||
|
BigDecimal bigDecimal92 = new BigDecimal("92");
|
||||||
|
BigDecimal bigDecimal74 = new BigDecimal("74");
|
||||||
|
BigDecimal bigDecimal73 = new BigDecimal("73");
|
||||||
|
BigDecimal bigDecimal60 = new BigDecimal("60");
|
||||||
|
switch (paneName) {
|
||||||
|
case "可保底":
|
||||||
|
recommendMajorList = recommendMajorList.stream().filter(r -> r.getEnrollProbability().compareTo(bigDecimal93) >= 0).collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
case "较稳妥":
|
||||||
|
recommendMajorList = recommendMajorList.stream().filter(r -> r.getEnrollProbability().compareTo(bigDecimal92) < 0 && r.getEnrollProbability().compareTo(bigDecimal74) >= 0).collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
case "可冲击":
|
||||||
|
recommendMajorList = recommendMajorList.stream().filter(r -> r.getEnrollProbability().compareTo(bigDecimal73) < 0 && r.getEnrollProbability().compareTo(bigDecimal60) >= 0).collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
case "难录取":
|
||||||
|
recommendMajorList = recommendMajorList.stream().filter(r -> r.getEnrollProbability().compareTo(bigDecimal60) < 0).collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//插入 院校标签
|
||||||
|
if (CollectionUtils.isNotEmpty(recommendMajorList)) {
|
||||||
|
Set<String> schoolIdSet = recommendMajorList.stream().map(RecommendMajorDTO::getSchoolId).collect(Collectors.toSet());
|
||||||
|
List<YxSchool> schoolList = yxSchoolMapper.selectBatchIds(schoolIdSet);
|
||||||
|
if (CollectionUtils.isNotEmpty(schoolList)) {
|
||||||
|
Map<String, YxSchool> yxSchoolMap = schoolList.stream().collect(Collectors.toMap(YxSchool::getId, s -> s));
|
||||||
|
YxSchool school = null;
|
||||||
|
Set<String> tagsList;
|
||||||
|
for (RecommendMajorDTO recommendMajorDTO : recommendMajorList) {
|
||||||
|
school = yxSchoolMap.get(recommendMajorDTO.getSchoolId());
|
||||||
|
if (school == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tagsList = new HashSet<>();
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(school.getSchoolType())) {
|
||||||
|
tagsList.add(school.getSchoolType());//学校层次
|
||||||
|
}
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(school.getSchoolNature())) {
|
||||||
|
tagsList.add(school.getSchoolNature());//办学性质
|
||||||
|
}
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(school.getInstitutionType())) {
|
||||||
|
String[] split = school.getInstitutionType().split(" ");
|
||||||
|
for (String s : split) {
|
||||||
|
tagsList.add(s + "类");//院校类型
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断 是否是 985,211
|
||||||
|
if (1 == school.getIs211()) {
|
||||||
|
tagsList.add("211");
|
||||||
|
}
|
||||||
|
if (1 == school.getIs985()) {
|
||||||
|
tagsList.add("985");
|
||||||
|
}
|
||||||
|
if ("双一流".equals(school.getSfsyl())) {
|
||||||
|
tagsList.add("双一流");
|
||||||
|
}
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(school.getGzsz())) {
|
||||||
|
tagsList.add(school.getGzsz());
|
||||||
|
}
|
||||||
|
recommendMajorDTO.setTagsList(tagsList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int total = recommendMajorList.size();
|
||||||
|
ArtRecommendMajorBaseDTO artRecommendMajorBaseDTO=new ArtRecommendMajorBaseDTO();
|
||||||
|
artRecommendMajorBaseDTO.setList(recommendMajorList);
|
||||||
|
return artRecommendMajorBaseDTO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ public class ScoreUtil {
|
||||||
}
|
}
|
||||||
//将两个批次设置为数字等级,数字越小 权限越多 1st.
|
//将两个批次设置为数字等级,数字越小 权限越多 1st.
|
||||||
int nowLevel = "本科A段".equals(nowBatch) ? 1 : "本科B段".equals(nowBatch) ? 2 : "本科".equals(nowBatch) ? 3 : 4;
|
int nowLevel = "本科A段".equals(nowBatch) ? 1 : "本科B段".equals(nowBatch) ? 2 : "本科".equals(nowBatch) ? 3 : 4;
|
||||||
int majorLevel = "本科A段".equals(majorBatch) ? 1 : "本科B段".equals(majorBatch) ? 2 : "本科".equals(majorBatch) ? 3 : 4;
|
int majorLevel = "提前批".equals(majorBatch)?1: "本科A段".equals(majorBatch) ? 1 : "本科B段".equals(majorBatch) ? 2 : "本科".equals(majorBatch) ? 3 : 4;
|
||||||
return nowLevel<=majorLevel;
|
return nowLevel<=majorLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue