付款时优惠卷列表

This commit is contained in:
wuchunlei
2024-09-27 13:19:58 +08:00
parent cb9e0adbf9
commit 092d388959
7 changed files with 143 additions and 68 deletions

View File

@@ -50,6 +50,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
@Autowired
private ClassExamUserDao classExamUserDao;
@Autowired
private CourseCatalogueDao courseCatalogueDao;
@Autowired
private CourseCatalogueChapterDao courseCatalogueChapterDao;
@Autowired
private RabbitTemplate rabbitTemplate;
@@ -288,13 +290,17 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
List<ClassCourse> courses = classCourseDao.selectList(new LambdaQueryWrapper<ClassCourse>()
.eq(ClassCourse::getModelId,classEntity.getModelId()));
for (ClassCourse classCourse:courses){
List<UserCourseBuyEntity> ucb = userCourseBuyDao.selectList(new LambdaQueryWrapper<UserCourseBuyEntity>()
.eq(UserCourseBuyEntity::getUserId,classUser.getUserId())
.eq(UserCourseBuyEntity::getCourseId,classCourse.getCourseId()));
if (ucb.size() == 0){
flag = true;
CourseEntity c = courseDao.selectById(classCourse.getCourseId());
sb.append("用户"+ user.getTel()+"未购买课程"+c.getTitle()+";\n");
List<CourseCatalogueEntity> catalogues = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>()
.eq(CourseCatalogueEntity::getCourseId,classCourse.getCourseId()));
for (CourseCatalogueEntity catalog:catalogues){
int ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
.eq(UserCourseBuyEntity::getUserId,classUser.getUserId())
.eq(UserCourseBuyEntity::getCatalogueId,catalog.getId()));
if (ucbCount == 0){
flag = true;
CourseEntity c = courseDao.selectById(classCourse.getCourseId());
sb.append("用户"+ user.getTel()+"未购买课程"+c.getTitle()+"-"+catalog.getTitle()+";\n");
}
}
}
if (flag) {

View File

@@ -2,28 +2,24 @@ package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.DateUtil;
import com.peanut.common.utils.DateUtils;
import com.peanut.common.utils.R;
import com.peanut.common.utils.ShiroUtils;
import com.peanut.config.DelayQueueConfig;
import com.peanut.modules.common.dao.CouponDao;
import com.peanut.modules.common.dao.CouponHistoryDao;
import com.peanut.modules.common.dao.CourseDao;
import com.peanut.modules.common.dao.CourseMedicineDao;
import com.peanut.modules.common.entity.CouponEntity;
import com.peanut.modules.common.entity.CouponHistory;
import com.peanut.modules.common.entity.CourseEntity;
import com.peanut.modules.common.entity.CourseMedicine;
import com.peanut.modules.common.dao.*;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.CouponService;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Slf4j
@Service("commonCouponService")
@@ -39,6 +35,10 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
private CourseMedicineDao courseMedicineDao;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private ShopProductDao shopProductDao;
@Autowired
private ShopProductCourseDao shopProductCourseDao;
@Override
public CouponEntity getByIdSetRange(int id) {
@@ -107,7 +107,6 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
return R.error("优惠卷已放完");
}
}
private MessagePostProcessor messagePostProcessor(long date) {
return message -> {
message.getMessageProperties().setDelay((int)date);
@@ -115,4 +114,76 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
};
}
@Override
public List<CouponHistory> getCouponListPayment(Map<String, Object> params) {
List<CouponHistory> res = new ArrayList<>();
List<CouponHistory> couponHistoryList = couponHistoryDao.selectList(new LambdaQueryWrapper<CouponHistory>()
.eq(CouponHistory::getUserId, ShiroUtils.getUId())
.eq(CouponHistory::getStatus,0));
if (couponHistoryList.size() > 0) {
for (CouponHistory couponHistory : couponHistoryList) {
if (couponHistory.getEffectType()==0){
res.add(couponHistory);
}else {
List<ShopProduct> shopProductList = shopProductDao.selectList(new MPJLambdaWrapper<ShopProduct>()
.leftJoin(BuyOrderProduct.class,BuyOrderProduct::getProductId,ShopProduct::getProductId)
.eq(BuyOrderProduct::getOrderId,params.get("orderId").toString()));
for (ShopProduct shopProduct : shopProductList) {
Set<Integer> set = getShopProductByCoupon(couponHistory.getCouponId());
if(!set.add(shopProduct.getProductId())){
res.add(couponHistory);
}
}
}
}
}
return res;
}
@Override
public Set<Integer> getShopProductByCoupon(int couponId) {
Set<Integer> set = new HashSet<>();
CouponEntity couponEntity = couponDao.selectById(couponId);
if (couponEntity!=null){
String[] strs = couponEntity.getRangeInfo().split(",");
if (couponEntity.getCouponRange()==1) {
for (String courseId : strs) {
List<ShopProductCourseEntity> shopProductCourseList = shopProductCourseDao.selectList(new LambdaQueryWrapper<ShopProductCourseEntity>()
.eq(ShopProductCourseEntity::getCourseId,courseId));
for (ShopProductCourseEntity shopProductCourseEntity : shopProductCourseList) {
set.add(shopProductCourseEntity.getProductId());
}
}
}else if (couponEntity.getCouponRange()==2) {
for (String courseMedical : strs) {
MPJLambdaWrapper<ShopProductCourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.leftJoin(CourseToMedicine.class,CourseToMedicine::getCourseId,ShopProductCourseEntity::getCourseId);
List l = new ArrayList();
getCourseMedicalIds(Integer.parseInt(courseMedical),l);
wrapper.in(CourseToMedicine::getMedicalId,l);
wrapper.selectAll(ShopProductCourseEntity.class);
List<ShopProductCourseEntity> shopProductCourseList = shopProductCourseDao.selectList(wrapper);
for (ShopProductCourseEntity shopProductCourseEntity : shopProductCourseList) {
set.add(shopProductCourseEntity.getProductId());
}
}
}
}
return set;
}
public void getCourseMedicalIds(int courseMedicalId,List<Integer> list){
CourseMedicine courseMedicine = courseMedicineDao.selectById(courseMedicalId);
if (courseMedicine.getIsLast()==1){
list.add(courseMedicine.getId());
}else {
List<CourseMedicine> cms = courseMedicineDao.selectList(new LambdaQueryWrapper<CourseMedicine>()
.eq(CourseMedicine::getPid,courseMedicine.getId()));
for (CourseMedicine cm : cms) {
getCourseMedicalIds(cm.getId(),list);
}
}
}
}