This commit is contained in:
wangjinlei
2024-04-28 10:25:31 +08:00
parent 3980da2fb1
commit dbe836f884
4 changed files with 46 additions and 4 deletions

View File

@@ -257,6 +257,7 @@ public class BuyOrderController {
return R.error(500, "信息中不能含有“+”、“&”符号!");
}
}
buyOrder.setOrderStatus("0");
buyOrderService.save(buyOrder);
//解决购物车相关问题
@@ -904,9 +905,9 @@ public class BuyOrderController {
LambdaQueryWrapper<UserCourseBuyEntity> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(UserCourseBuyEntity::getUserId,orderEntity.getUserId());
wrapper2.eq(UserCourseBuyEntity::getCatalogueId,s.getCatalogueId());
wrapper2.lt(UserCourseBuyEntity::getEndTime,new Date());
wrapper2.gt(UserCourseBuyEntity::getEndTime,new Date());
List<UserCourseBuyEntity> userCourseBuyEntities = userCourseBuyDao.selectList(wrapper2);
if(userCourseBuyEntities.size()>0){
if(userCourseBuyEntities.size()>0){//延长有效期
UserCourseBuyEntity userCourseBuyEntity = userCourseBuyEntities.get(0);
Calendar calendar = Calendar.getInstance();
calendar.setTime(userCourseBuyEntity.getEndTime());
@@ -917,6 +918,7 @@ public class BuyOrderController {
UserCourseBuyEntity userCourseBuyEntity = new UserCourseBuyEntity();
userCourseBuyEntity.setUserId(orderEntity.getUserId());
userCourseBuyEntity.setCourseId(s.getCourseId());
userCourseBuyEntity.setCatalogueId(s.getCatalogueId());
userCourseBuyEntity.setDays(s.getDays());
userCourseBuyEntity.setCreateTime(new Date());
userCourseBuyEntity.setStartTime(new Date());

View File

@@ -226,7 +226,7 @@ public class AliPayServiceImpl implements AliPayService {
LambdaQueryWrapper<UserCourseBuyEntity> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(UserCourseBuyEntity::getUserId,orderEntity.getUserId());
wrapper2.eq(UserCourseBuyEntity::getCatalogueId,s.getCatalogueId());
wrapper2.lt(UserCourseBuyEntity::getEndTime,new Date());
wrapper2.gt(UserCourseBuyEntity::getEndTime,new Date());
List<UserCourseBuyEntity> userCourseBuyEntities = userCourseBuyDao.selectList(wrapper2);
if(userCourseBuyEntities.size()>0){
UserCourseBuyEntity userCourseBuyEntity = userCourseBuyEntities.get(0);
@@ -239,6 +239,7 @@ public class AliPayServiceImpl implements AliPayService {
UserCourseBuyEntity userCourseBuyEntity = new UserCourseBuyEntity();
userCourseBuyEntity.setUserId(orderEntity.getUserId());
userCourseBuyEntity.setCourseId(s.getCourseId());
userCourseBuyEntity.setCatalogueId(s.getCatalogueId());
userCourseBuyEntity.setDays(s.getDays());
userCourseBuyEntity.setCreateTime(new Date());
userCourseBuyEntity.setStartTime(new Date());

View File

@@ -168,6 +168,7 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
UserCourseBuyEntity userCourseBuyEntity = new UserCourseBuyEntity();
userCourseBuyEntity.setUserId(order.getUserId());
userCourseBuyEntity.setCourseId(s.getCourseId());
userCourseBuyEntity.setCatalogueId(s.getCatalogueId());
userCourseBuyEntity.setDays(s.getDays());
userCourseBuyEntity.setCreateTime(new Date());
userCourseBuyEntity.setStartTime(new Date());

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.sociology.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -11,12 +12,15 @@ import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.sociology.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service("sociologyShopProduct")
@@ -68,7 +72,41 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
shopProductCourseEntityMPJLambdaWrapper.eq(ShopProductCourseEntity::getProductId,productId);
List<CourseEntity> courseEntities = shopProductCourseDao.selectJoinList(CourseEntity.class, shopProductCourseEntityMPJLambdaWrapper);
flag.put("courses",courseEntities);
//查询包含此商品的所有商品的列表
List<Integer> book_product_ids = new ArrayList<>();
if(bookEntities.size()>0){
List<Integer> collect = bookEntities.stream().map(BookEntity::getId).collect(Collectors.toList());
LambdaQueryWrapper<ShopProductBookEntity> shopProductBookEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
shopProductBookEntityLambdaQueryWrapper.in(ShopProductBookEntity::getBookId,collect);
shopProductBookEntityLambdaQueryWrapper.groupBy(ShopProductBookEntity::getProductId);
shopProductBookEntityLambdaQueryWrapper.having("count(product_id)>="+collect.size());
List<ShopProductBookEntity> shopProductBookEntities = shopProductBookDao.selectList(shopProductBookEntityLambdaQueryWrapper);
book_product_ids = shopProductBookEntities.stream().map(ShopProductBookEntity::getProductId).collect(Collectors.toList());
}
List<Integer> course_product_ids = new ArrayList<>();
if(courseEntities.size()>0){
List<Integer> collect = courseEntities.stream().map(CourseEntity::getId).collect(Collectors.toList());
LambdaQueryWrapper<ShopProductCourseEntity> shopProductCourseEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
shopProductCourseEntityLambdaQueryWrapper.in(ShopProductCourseEntity::getCourseId,collect);
shopProductCourseEntityLambdaQueryWrapper.groupBy(ShopProductCourseEntity::getProductId);
shopProductCourseEntityLambdaQueryWrapper.having("count(product_id)>="+collect.size());
List<ShopProductCourseEntity> shopProductCourseEntities = shopProductCourseDao.selectList(shopProductCourseEntityLambdaQueryWrapper);
course_product_ids = shopProductCourseEntities.stream().map(ShopProductCourseEntity::getProductId).collect(Collectors.toList());
}
if(book_product_ids.size()==0&&course_product_ids.size()==0){
List<ShopProduct> shopProducts = new ArrayList<>();
shopProducts.add(product);
flag.put("GLProducts",shopProducts);
} else if (book_product_ids.size()>0&&course_product_ids.size()>0) {
List<Integer> intersection = new ArrayList<>(book_product_ids);
intersection.retainAll(course_product_ids);
List<ShopProduct> shopProducts = this.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProduct>().in(ShopProduct::getProductId, intersection));
flag.put("GLProducts",shopProducts);
} else {
List<Integer> is = new ArrayList<>(CollectionUtils.union(book_product_ids, course_product_ids));
List<ShopProduct> shopProducts = this.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProduct>().in(ShopProduct::getProductId, is));
flag.put("GLProducts",shopProducts);
}
return flag;
}
}