Files
nuttyreading-server/src/main/java/com/peanut/modules/common/controller/UserVipController.java
wyn 24264b82ff Merge remote-tracking branch 'origin/wyn-课程表' into wyn
# Conflicts:
#	src/main/java/com/peanut/modules/common/service/CourseMedicineService.java
2026-05-19 10:42:00 +08:00

559 lines
29 KiB
Java

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.HttpContextUtil;
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.entity.*;
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;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.transaction.Transactional;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 超V管理
*/
@Slf4j
@RestController("commonUserVip")
@RequestMapping("common/userVip")
public class UserVipController {
@Autowired
private UserVipService userVipService;
@Autowired
private BuyOrderService buyOrderService;
@Autowired
private WxpayService wxpayService;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private MyUserDao myUserDao;
@Autowired
private VipBuyConfigService vipBuyConfigService;
@Autowired
private TransactionDetailsService transactionDetailsService;
@Autowired
private JfTransactionDetailsService jfTransactionDetailsService;
@Autowired
private CourseCatalogueService courseCatalogueService;
//获取用户类型
@RequestMapping("/getUserVipType")
public R getUserVipType() {
List<Map<String,Object>> resList = new ArrayList();
//根部不同平台返回不同列表
HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
String appType = request.getHeader("appType")==null?"":request.getHeader("appType");
if (!"psyche".equals(appType)){
List<UserVip> l4 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,4).orderByDesc(UserVip::getEndTime));
List<UserVip> l9 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,9).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));
List<UserVip> l10 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,10).orderByDesc(UserVip::getEndTime));
if (l4.size()>0&&l9.size()>0&&l5.size()>0&&l6.size()>0&&l10.size()>0){
Date t4 = l4.get(0).getEndTime();
Date t9 = l9.get(0).getEndTime();
Date t5 = l5.get(0).getEndTime();
Date t6 = l6.get(0).getEndTime();
Date t10 = l10.get(0).getEndTime();
if (t4.getTime()==t9.getTime()&&t9.getTime()==t5.getTime()&&t5.getTime()==t6.getTime()&&t6.getTime()==t10.getTime()){
Map map = new HashMap();
map.put("type",1);
map.put("endTime",t4);
resList.add(map);
}else {
List<Map<String,Object>> tempList = new ArrayList();
Map map4 = new HashMap();
map4.put("type",4);
map4.put("endTime",t4);
tempList.add(map4);
Map map9 = new HashMap();
map9.put("type",9);
map9.put("endTime",t9);
tempList.add(map9);
Map map5 = new HashMap();
map5.put("type",5);
map5.put("endTime",t5);
tempList.add(map5);
Map map6 = new HashMap();
map6.put("type",6);
map6.put("endTime",t6);
tempList.add(map6);
Map map10 = new HashMap();
map10.put("type",10);
map10.put("endTime",t10);
tempList.add(map10);
tempList = tempList.stream().sorted((map1,map2)->{
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
}).collect(Collectors.toList());
resList.addAll(tempList);
Map map1 = new HashMap();
map1.put("type",1);
map1.put("endTime",tempList.get(0).get("endTime"));
resList.add(map1);
}
}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 (l9.size()>0){
Map map = new HashMap();
map.put("type",9);
map.put("endTime",l9.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);
}
if (l10.size()>0){
Map map = new HashMap();
map.put("type",10);
map.put("endTime",l10.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){
Date t7 = l7.get(0).getEndTime();
Date t8 = l8.get(0).getEndTime();
if (t7.getTime()==t8.getTime()){
Map map = new HashMap();
map.put("type",2);
map.put("endTime",t7);
resList.add(map);
}else {
List<Map<String,Object>> tempList = new ArrayList();
Map map7 = new HashMap();
map7.put("type",7);
map7.put("endTime",t7);
tempList.add(map7);
Map map8 = new HashMap();
map8.put("type",8);
map8.put("endTime",t8);
tempList.add(map8);
tempList = tempList.stream().sorted((map1,map2)->{
return Long.compare(((Date)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
}).collect(Collectors.toList());
resList.addAll(tempList);
Map map2 = new HashMap();
map2.put("type",2);
map2.put("endTime",tempList.get(0).get("endTime"));
resList.add(map2);
}
}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)map1.get("endTime")).getTime(),((Date)map2.get("endTime")).getTime());
}).collect(Collectors.toList());
return R.ok().put("list", resList);
}
//vip商品列表
@RequestMapping("/getVipBuyConfigList")
public R getVipBuyConfigList() {
List<List> ll = new ArrayList<>();
//根部不同平台返回不同列表
HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
String appType = request.getHeader("appType")==null?"":request.getHeader("appType");
if ("psyche".equals(appType)){
ll.add(Arrays.asList(8,7));
ll.add(Arrays.asList(2));
}else {
ll.add(Arrays.asList(1));
ll.add(Arrays.asList(4));
ll.add(Arrays.asList(9));
ll.add(Arrays.asList(5));
ll.add(Arrays.asList(6));
ll.add(Arrays.asList(10));
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);
if ("psyche".equals(appType)){
wrapper.orderByDesc(VipBuyConfigEntity::getType);
}
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> uv9 = userVipService.list(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId,ShiroUtils.getUId()).eq(UserVip::getType,9).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 && uv9.size() > 0 && uv5.size() > 0 && uv6.size() > 0){//办理过
if (uv4.get(0).getState()==0&&uv9.get(0).getState()==0&&uv5.get(0).getState()==0&&uv6.get(0).getState()==0){
long l4 = uv4.get(0).getEndTime().getTime();
long l9 = uv9.get(0).getEndTime().getTime();
long l5 = uv5.get(0).getEndTime().getTime();
long l6 = uv6.get(0).getEndTime().getTime();
List<Long> tempList = new ArrayList();
tempList.add(l4);
tempList.add(l9);
tempList.add(l5);
tempList.add(l6);
tempList = tempList.stream().sorted((long1,long2)->{
return Long.compare(long1,long2);
}).collect(Collectors.toList());
map.put("tip",(tempList.get(0)-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 Long.compare((Long) (map1.get("vcbList")==null?0l:1l),(Long)(map2.get("vcbList")==null?0l:1l));
}).collect(Collectors.toList());
resList.addAll(list);
}
return R.ok().put("res", resList);
}
//vip配置列表
@RequestMapping("/vipBuyConfigList")
public R vipBuyConfigList() {
List<List> ll = new ArrayList<>();
ll.add(Arrays.asList(1));
ll.add(Arrays.asList(4));
ll.add(Arrays.asList(9));
ll.add(Arrays.asList(5));
ll.add(Arrays.asList(6));
ll.add(Arrays.asList(10));
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("vcbList",null);//vip商品列表
map.put("yanqiList",null);//延期商品列表
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);
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);
}
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()));
Map<String,Object> userVipInfo = new HashMap<>();
if(userVip!=null){
userVipInfo.put("id",userVip.getId());
userVipInfo.put("userId",userVip.getUserId());
userVipInfo.put("type",userVip.getType());
userVipInfo.put("startTime",userVip.getStartTime());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
userVipInfo.put("endTime",sdf.format(userVip.getEndTime()));
userVipInfo.put("state",userVip.getState());
userVipInfo.put("delFlag",userVip.getDelFlag());
userVipInfo.put("user",userVip.getUser());
userVipInfo.put("userVipLogs",userVip.getUserVipLogs());
}else{
userVipInfo = null;
}
return R.ok().put("userVip", userVipInfo);
}
//当前课程属于什么会员
@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) {
LambdaQueryWrapper<UserVip> wrapper = new LambdaQueryWrapper();
wrapper.eq(UserVip::getUserId,userId);
wrapper.orderByAsc(UserVip::getState);
wrapper.orderByAsc(UserVip::getEndTime);
List<UserVip> userVips = userVipService.list(wrapper);
return R.ok().put("result", userVips);
}
@RequestMapping("/placeVipOrder")
@Transactional
public R placeVipOrder(@RequestBody BuyOrder buyOrder){
int uid = ShiroUtils.getUId();
buyOrder.setOrderStatus("0");
buyOrder.setPaymentDate(new Date());
buyOrder.setOrderType("vip");
String timeId = IdWorker.getTimeId().substring(0, 32);
buyOrder.setOrderSn(timeId);
buyOrder.setUserId(uid);
buyOrder.setPaymentDate(new Date());
buyOrderService.save(buyOrder);
BigDecimal totalPrice = buyOrder.getRealMoney();
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
MyUserEntity user = myUserDao.selectById(buyOrder.getUserId());
if (usePeanutCoin(user, totalPrice)&&useJfCoin(user,buyOrder.getJfDeduction())) {
// 更新订单状态
buyOrder.setPaymentDate(new Date());
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "2");
//记录用户虚拟币消费
if(totalPrice.compareTo(BigDecimal.ZERO)>0){
transactionDetailsService.recordTransaction(buyOrder, user, totalPrice);
}
//记录用户积分消费情况
if(buyOrder.getJfDeduction()!=null&&buyOrder.getJfDeduction().compareTo(BigDecimal.ZERO) > 0){
jfTransactionDetailsService.recordJfTransaction(buyOrder, user, buyOrder.getJfDeduction());
}
//开通用户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, "余额不足!");
}
}
//下单微信支付预付款订单
if(Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())){
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>().eq(BuyOrder::getOrderSn, timeId));
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
paymentInfo.setBuyOrderId(buyOrderEntity.getOrderId());
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
// paymentInfo.setAppName(buyOrder.getAppName());
if (buyOrder.getCome()==2){
paymentInfo.setAppName("wumen");
} else if (buyOrder.getCome()==1) {
paymentInfo.setAppName("zmzm");
} else if (buyOrder.getCome()==3) {
paymentInfo.setAppName("xlkj");
} else if (buyOrder.getCome()==4) {
paymentInfo.setAppName("thyy");
}else {
paymentInfo.setAppName(buyOrder.getAppName());
}
wxpayService.prepay(paymentInfo);
}
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
buyOrder.getOrderId(),
messagePostProcessor()
);
return R.ok().put("orderSn", timeId).put("money",buyOrder.getRealMoney());
}
private boolean usePeanutCoin(MyUserEntity user, BigDecimal totalPrice) {
if (user.getPeanutCoin().compareTo(totalPrice) >= 0) {
if(totalPrice.compareTo(BigDecimal.ZERO)==0){//纯积分支付,虚拟币不用支付
return true;
}
user.setPeanutCoin(user.getPeanutCoin().subtract(totalPrice));
myUserDao.updateById(user);
return true;
}
return false;
}
private boolean useJfCoin(MyUserEntity user,BigDecimal jf){
if(jf==null){
return true;
}
if(user.getJf().compareTo(jf)>=0){
user.setJf(user.getJf().subtract(jf));
myUserDao.updateById(user);
return true;
}else{
return false;
}
}
private MessagePostProcessor messagePostProcessor() {
return message -> {
//设置有效期30分钟
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
return message;
};
}
public Map getOriginalPriceAndCourseCount(String type) {
Map map = new HashMap();
map.put("courseCount",0);
map.put("originalPrice",0);
if ("4".equals(type)||"9".equals(type)||"5".equals(type)||"6".equals(type)||"10".equals(type)){
List list = new ArrayList<>();
if ("4".equals(type)){
userVipService.bottomLabel(1,list);
}else if ("9".equals(type)){
userVipService.bottomLabel(74,list);
}else if ("5".equals(type)){
userVipService.bottomLabel(2,list);
}else if ("6".equals(type)){
userVipService.bottomLabel(5,list);
}else if ("10".equals(type)){
userVipService.bottomLabel(109,list);
}
if (list.size()>0){
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)){
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;
}
}