VIP改版
This commit is contained in:
@@ -6,11 +6,9 @@ import com.peanut.common.utils.MD5Utils;
|
||||
import com.peanut.common.utils.MailUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.entity.ClassUser;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.UserInviteRegister;
|
||||
import com.peanut.modules.common.entity.UserVip;
|
||||
import com.peanut.modules.common.service.ClassEntityService;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.common.service.UserInviteRegisterService;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
@@ -23,7 +21,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
@@ -117,13 +114,10 @@ public class UserController {
|
||||
public R getUserInfo(){
|
||||
int uid = ShiroUtils.getUId();
|
||||
MyUserEntity userEntity = userService.getById(uid);
|
||||
if(!userEntity.getVip().equals("0")){
|
||||
List<UserVip> userVips = userVipService.getBaseMapper().selectList(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId, uid).eq(UserVip::getState,0));
|
||||
if (userVips.size()==1){
|
||||
userEntity.setUserVip(userVips.get(0));
|
||||
}
|
||||
}
|
||||
List<UserVip> userVips = userVipService.list(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId, uid)
|
||||
.eq(UserVip::getState,0));
|
||||
userEntity.setUserVips(userVips);
|
||||
return R.ok().put("result",userEntity);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,17 @@ package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
import com.peanut.modules.common.dao.UserVipDao;
|
||||
import com.peanut.modules.common.dao.VipBuyConfigDao;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.BuyOrderService;
|
||||
import com.peanut.modules.common.service.JfTransactionDetailsService;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.master.service.CourseCatalogueService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,11 +24,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.transaction.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 超V管理
|
||||
@@ -50,13 +46,200 @@ public class UserVipController {
|
||||
@Autowired
|
||||
private MyUserDao myUserDao;
|
||||
@Autowired
|
||||
private VipBuyConfigDao vipBuyConfigDao;
|
||||
@Autowired
|
||||
private UserVipDao userVipDao;
|
||||
private VipBuyConfigService vipBuyConfigService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private JfTransactionDetailsService jfTransactionDetailsService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private CourseCatalogueService courseCatalogueService;
|
||||
|
||||
|
||||
//获取用户类型
|
||||
@RequestMapping("/getUserVipType")
|
||||
public R getUserVipType() {
|
||||
List<Map<String,Object>> resList = new ArrayList();
|
||||
List<UserVip> l4 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,4).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> l5 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,5).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> l6 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,6).orderByDesc(UserVip::getEndTime));
|
||||
if (l4.size()>0&&l5.size()>0&&l6.size()>0&&l4.get(0).getState()==0&&l5.get(0).getState()==0&&l6.get(0).getState()==0){
|
||||
Date t4 = l4.get(0).getEndTime();
|
||||
Date t5 = l5.get(0).getEndTime();
|
||||
Date t6 = l6.get(0).getEndTime();
|
||||
Map map = new HashMap();
|
||||
map.put("type",1);
|
||||
map.put("endTime",t4.getTime()<t5.getTime()?(t4.getTime()<t6.getTime()?t4:(t5.getTime()<t6.getTime()?t5:t6)):(t5.getTime()<t6.getTime()?t5:t6));
|
||||
resList.add(map);
|
||||
}else {
|
||||
if (l4.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",4);
|
||||
map.put("endTime",l4.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
if (l5.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",5);
|
||||
map.put("endTime",l5.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
if (l6.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",6);
|
||||
map.put("endTime",l6.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
}
|
||||
List<UserVip> l7 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,7).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> l8 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,8).orderByDesc(UserVip::getEndTime));
|
||||
if (l7.size()>0&&l8.size()>0&&l7.get(0).getState()==0&&l8.get(0).getState()==0){
|
||||
Date t7 = l7.get(0).getEndTime();
|
||||
Date t8 = l8.get(0).getEndTime();
|
||||
Map map = new HashMap();
|
||||
map.put("type",2);
|
||||
map.put("endTime",t7.getTime()<t8.getTime()?t7:t8);
|
||||
resList.add(map);
|
||||
}else {
|
||||
if (l7.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",7);
|
||||
map.put("endTime",l7.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
if (l8.size()>0){
|
||||
Map map = new HashMap();
|
||||
map.put("type",8);
|
||||
map.put("endTime",l8.get(0).getEndTime());
|
||||
resList.add(map);
|
||||
}
|
||||
}
|
||||
resList = resList.stream().sorted((map1,map2)->{
|
||||
return Long.compare(((Date)map2.get("endTime")).getTime(),((Date)map1.get("endTime")).getTime());
|
||||
}).collect(Collectors.toList());
|
||||
return R.ok().put("list", resList);
|
||||
}
|
||||
|
||||
|
||||
//vip商品列表
|
||||
@RequestMapping("/getVipBuyConfigList")
|
||||
public R getVipBuyConfigList() {
|
||||
List<List> ll = new ArrayList<>();
|
||||
ll.add(Arrays.asList(1));
|
||||
ll.add(Arrays.asList(4,5,6));
|
||||
ll.add(Arrays.asList(2));
|
||||
ll.add(Arrays.asList(7,8));
|
||||
List<Map<String,Object>> resList = new ArrayList<>();
|
||||
for (List l : ll) {
|
||||
LambdaQueryWrapper<VipBuyConfigEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.select(VipBuyConfigEntity::getType,VipBuyConfigEntity::getTitle);
|
||||
wrapper.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())));
|
||||
wrapper.in(VipBuyConfigEntity::getType,l);
|
||||
wrapper.groupBy(VipBuyConfigEntity::getType);
|
||||
List<Map<String,Object>> list = vipBuyConfigService.listMaps(wrapper);
|
||||
for (Map<String,Object> map:list){
|
||||
Map originalPriceAndCourseCount = getOriginalPriceAndCourseCount(map.get("type").toString());
|
||||
map.put("originalPrice",originalPriceAndCourseCount.get("originalPrice"));//模块下课程一年原价
|
||||
map.put("courseCount",originalPriceAndCourseCount.get("courseCount"));//模块下课程数量
|
||||
map.put("tip",null);//提示到期
|
||||
map.put("vcbList",null);//vip商品列表
|
||||
map.put("yanqiList",null);//延期商品列表
|
||||
map.put("state",null);//有效状态
|
||||
boolean flag = false;
|
||||
if ("1".equals(map.get("type").toString())){
|
||||
List<UserVip> uv4 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,4).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> uv5 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,5).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> uv6 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,6).orderByDesc(UserVip::getEndTime));
|
||||
if (uv4.size() > 0 && uv5.size() > 0 && uv6.size() > 0){//办理过
|
||||
if (uv4.get(0).getState()==0&&uv5.get(0).getState()==0&&uv6.get(0).getState()==0){
|
||||
long l4 = uv4.get(0).getEndTime().getTime();
|
||||
long l5 = uv5.get(0).getEndTime().getTime();
|
||||
long l6 = uv6.get(0).getEndTime().getTime();
|
||||
if (l4<l5){
|
||||
if (l4<l6){
|
||||
map.put("tip",(l4-new Date().getTime())/60/60/24/1000);
|
||||
}else {
|
||||
map.put("tip",(l6-new Date().getTime())/60/60/24/1000);
|
||||
}
|
||||
}else {
|
||||
if (l5<l6){
|
||||
map.put("tip",(l5-new Date().getTime())/60/60/24/1000);
|
||||
}else {
|
||||
map.put("tip",(l6-new Date().getTime())/60/60/24/1000);
|
||||
}
|
||||
}
|
||||
map.put("state",0);
|
||||
}else {
|
||||
map.put("state",1);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}else if ("2".equals(map.get("type").toString())){
|
||||
List<UserVip> uv7 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,7).orderByDesc(UserVip::getEndTime));
|
||||
List<UserVip> uv8 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,8).orderByDesc(UserVip::getEndTime));
|
||||
if (uv7.size() > 0 && uv8.size() > 0){
|
||||
if (uv7.get(0).getState()==0&&uv8.get(0).getState()==0){
|
||||
if (uv7.get(0).getEndTime().getTime()<uv8.get(0).getEndTime().getTime()){
|
||||
map.put("tip",(uv7.get(0).getEndTime().getTime()-new Date().getTime())/60/60/24/1000);
|
||||
}else {
|
||||
map.put("tip",(uv8.get(0).getEndTime().getTime()-new Date().getTime())/60/60/24/1000);
|
||||
}
|
||||
map.put("state",0);
|
||||
}else {
|
||||
map.put("state",1);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}else {
|
||||
List<UserVip> userVips = userVipService.list(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,map.get("type")).orderByDesc(UserVip::getEndTime));
|
||||
if (userVips.size()>0){
|
||||
if (userVips.get(0).getState()==0){
|
||||
map.put("tip",(userVips.get(0).getEndTime().getTime()-new Date().getTime())/60/60/24/1000);
|
||||
map.put("state",0);
|
||||
}else {
|
||||
map.put("state",1);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (flag){
|
||||
List<VipBuyConfigEntity> yanqiList = vipBuyConfigService.list(new LambdaQueryWrapper<VipBuyConfigEntity>()
|
||||
.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())))
|
||||
.eq(VipBuyConfigEntity::getType,map.get("type")+"1"));
|
||||
map.put("yanqiList",yanqiList);
|
||||
}else {
|
||||
List<VipBuyConfigEntity> vcbList = vipBuyConfigService.list(new LambdaQueryWrapper<VipBuyConfigEntity>()
|
||||
.and(r->r.eq(VipBuyConfigEntity::getDateType,0).or(f->f.eq(VipBuyConfigEntity::getDateType,1).lt(VipBuyConfigEntity::getStartTime,new Date()).gt(VipBuyConfigEntity::getEndTime,new Date())))
|
||||
.eq(VipBuyConfigEntity::getType,map.get("type")));
|
||||
map.put("vcbList",vcbList);
|
||||
}
|
||||
}
|
||||
list = list.stream().sorted((map1,map2)->{
|
||||
return Long.compare((Long) (map1.get("tip")==null?0l:map1.get("tip")),(Long)(map2.get("tip")==null?0l:map2.get("tip")));
|
||||
}).collect(Collectors.toList());
|
||||
list = list.stream().sorted((map1,map2)->{
|
||||
return (map1.get("vcbList")==null?0:(int)map1.get("type"))>(map2.get("vcbList")==null?0:(int)map2.get("type"))?
|
||||
1:((map1.get("vcbList")==null?0:(int)map1.get("type"))==(map2.get("vcbList")==null?0:(int)map2.get("type"))?0:-1);
|
||||
}).collect(Collectors.toList());
|
||||
resList.addAll(list);
|
||||
}
|
||||
return R.ok().put("res", resList);
|
||||
}
|
||||
|
||||
//是否是这门课的vip
|
||||
@RequestMapping("/ownCourseCatalogueByVip")
|
||||
public R ownCourseCatalogueByVip(@RequestBody Map<String,Object> params) {
|
||||
UserVip userVip = userVipService.ownCourseCatalogueByVip(Integer.parseInt(params.get("courseId").toString()));
|
||||
return R.ok().put("userVip", userVip);
|
||||
}
|
||||
|
||||
//当前课程属于什么会员
|
||||
@RequestMapping("/getCourseVipModule")
|
||||
public R getCourseVipModule(@RequestBody Map<String,Object> params) {
|
||||
return R.ok().put("list", userVipService.getCourseVipModule(Integer.parseInt(params.get("courseId").toString())));
|
||||
}
|
||||
|
||||
@RequestMapping("/getMyVipHistory")
|
||||
public R getMyVipHistory(String userId) {
|
||||
@@ -70,9 +253,8 @@ public class UserVipController {
|
||||
|
||||
@RequestMapping("/placeVipOrder")
|
||||
@Transactional
|
||||
public R placeVipOrder(@RequestBody BuyOrder buyOrder) throws Exception {
|
||||
public R placeVipOrder(@RequestBody BuyOrder buyOrder){
|
||||
int uid = ShiroUtils.getUId();
|
||||
|
||||
buyOrder.setOrderStatus("0");
|
||||
buyOrder.setOrderType("vip");
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
@@ -94,9 +276,15 @@ public class UserVipController {
|
||||
if(buyOrder.getJfDeduction()!=null&&buyOrder.getJfDeduction().compareTo(BigDecimal.ZERO) > 0){
|
||||
jfTransactionDetailsService.recordJfTransaction(buyOrder, user, buyOrder.getJfDeduction());
|
||||
}
|
||||
//开通用户vip,并且对已开通的课程做延期
|
||||
openVipForUser(buyOrder);
|
||||
//开通用户vip
|
||||
userVipService.openVipForUser(buyOrder);
|
||||
} else {
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.error(500, "余额不足!");
|
||||
}
|
||||
}
|
||||
@@ -138,92 +326,6 @@ public class UserVipController {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void openVipForUser(BuyOrder buyOrder) throws Exception {
|
||||
VipBuyConfigEntity vipBuyConfigEntity = vipBuyConfigDao.selectById(buyOrder.getVipBuyConfigId());
|
||||
MyUserEntity userEntity = myUserDao.selectById(buyOrder.getUserId());
|
||||
String u_v_type = userEntity.getVip();
|
||||
if(vipBuyConfigEntity.getType()==1){//超v
|
||||
if(u_v_type.equals("0")){//初次办理
|
||||
UserVip userVip = new UserVip();
|
||||
userVip.setUserId(userEntity.getId());
|
||||
userVip.setType(1);
|
||||
userVip.setStartTime(new Date());
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||
userVip.setEndTime(threeYearsDate);
|
||||
userVipDao.insert(userVip);
|
||||
userEntity.setVip("1");
|
||||
myUserDao.updateById(userEntity);
|
||||
}else if(u_v_type.equals("1")){//vip延期
|
||||
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
if(userVips.size()!=1){
|
||||
throwExceptionMethod();
|
||||
}
|
||||
UserVip userVip = userVips.get(0);
|
||||
Date endTime = userVip.getEndTime();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(endTime);
|
||||
calendar.add(Calendar.YEAR,vipBuyConfigEntity.getYear());
|
||||
userVip.setEndTime(calendar.getTime());
|
||||
userVipDao.updateById(userVip);
|
||||
}else if (u_v_type.equals("2")||u_v_type.equals("3")){//医学vip或国学vip升级
|
||||
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
if(userVips.size()!=1){
|
||||
throwExceptionMethod();
|
||||
}
|
||||
UserVip userVip1 = userVips.get(0);
|
||||
userVip1.setEndTime(new Date());
|
||||
userVip1.setState(1);
|
||||
userVipDao.updateById(userVip1);
|
||||
UserVip userVip = new UserVip();
|
||||
userVip.setUserId(userEntity.getId());
|
||||
userVip.setType(1);
|
||||
userVip.setStartTime(new Date());
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||
userVip.setEndTime(threeYearsDate);
|
||||
userVipDao.insert(userVip);
|
||||
userEntity.setVip("1");
|
||||
myUserDao.updateById(userEntity);
|
||||
|
||||
}
|
||||
}
|
||||
if(vipBuyConfigEntity.getType()==2||vipBuyConfigEntity.getType()==3){//医学vip或国学vip
|
||||
if(userEntity.getVip().equals("2")||userEntity.getVip().equals("3")){//续费
|
||||
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||
if(userVips.size()!=1){
|
||||
throwExceptionMethod();
|
||||
}
|
||||
UserVip userVip = userVips.get(0);
|
||||
Date endTime = userVip.getEndTime();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(endTime);
|
||||
calendar.add(Calendar.YEAR,vipBuyConfigEntity.getYear());
|
||||
userVip.setEndTime(calendar.getTime());
|
||||
userVipDao.updateById(userVip);
|
||||
}else{//新办理
|
||||
UserVip userVip = new UserVip();
|
||||
userVip.setUserId(userEntity.getId());
|
||||
userVip.setType(vipBuyConfigEntity.getType());
|
||||
userVip.setStartTime(new Date());
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||
userVip.setEndTime(threeYearsDate);
|
||||
userVipDao.insert(userVip);
|
||||
userEntity.setVip(vipBuyConfigEntity.getType().toString());
|
||||
myUserDao.updateById(userEntity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void throwExceptionMethod() throws Exception {
|
||||
throw new Exception("开通vip异常");
|
||||
}
|
||||
|
||||
private boolean useJfCoin(MyUserEntity user,BigDecimal jf){
|
||||
if(jf==null){
|
||||
return true;
|
||||
@@ -245,4 +347,64 @@ public class UserVipController {
|
||||
};
|
||||
}
|
||||
|
||||
public Map getOriginalPriceAndCourseCount(String type) {
|
||||
Map map = new HashMap();
|
||||
map.put("courseCount",0);
|
||||
map.put("originalPrice",0);
|
||||
if ("4".equals(type)||"5".equals(type)||"6".equals(type)){
|
||||
List list = new ArrayList<>();
|
||||
if ("4".equals(type)){
|
||||
userVipService.bottomLabel(1,list);
|
||||
}else if ("5".equals(type)){
|
||||
userVipService.bottomLabel(2,list);
|
||||
}else if ("6".equals(type)){
|
||||
userVipService.bottomLabel(5,list);
|
||||
}
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_medicine where del_flag = 0 and medical_id in ("+String.join(",",list.toString().replace("[","").replace("]",""))+") group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}else if ("7".equals(type)){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_sociology where del_flag = 0 group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}else if ("8".equals(type)){
|
||||
List list = new ArrayList<>();
|
||||
userVipService.bottomLabel(4,list);
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_medicine where del_flag = 0 and medical_id in ("+String.join(",",list.toString().replace("[","").replace("]",""))+") group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
if ("0".equals(map.get("courseCount").toString())){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> pWrapper = new MPJLambdaWrapper();
|
||||
pWrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_psyche where del_flag = 0 group by course_id");
|
||||
pWrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(pWrapper);
|
||||
}
|
||||
}else if ("2".equals(type)){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_sociology where del_flag = 0 group by course_id\n" +
|
||||
"union \n" +
|
||||
"select course_id from course_to_psyche where del_flag = 0 group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}else if ("1".equals(type)){
|
||||
MPJLambdaWrapper<CourseCatalogueEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.inSql(CourseCatalogueEntity::getCourseId,
|
||||
"select course_id from course_to_medicine where del_flag = 0 group by course_id\n" +
|
||||
"union \n" +
|
||||
"select course_id from course_to_sociology where del_flag = 0 group by course_id\n" +
|
||||
"union \n" +
|
||||
"select course_id from course_to_psyche where del_flag = 0 group by course_id");
|
||||
wrapper.select("count(1) as courseCount,sum(fee) as originalPrice");
|
||||
map = courseCatalogueService.getMap(wrapper);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user