修复一下bug
This commit is contained in:
@@ -17,6 +17,7 @@ import com.peanut.modules.book.vo.request.ProductRequestVo;
|
||||
import com.peanut.modules.book.vo.request.ProductTransportVo;
|
||||
import com.peanut.modules.book.vo.response.BuyOrderResponseVo;
|
||||
import com.peanut.modules.book.vo.response.OrderAddressResponseVo;
|
||||
import com.peanut.modules.common.dao.UserCourseBuyDao;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
@@ -87,6 +88,8 @@ public class BuyOrderController {
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
@Autowired
|
||||
private UserCourseBuyDao userCourseBuyDao;
|
||||
|
||||
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.POST)
|
||||
public R decomposeShipment(@RequestBody BuyOrderListRequestVo requestVo) {
|
||||
@@ -273,6 +276,7 @@ public class BuyOrderController {
|
||||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "0");
|
||||
recordTransaction(buyOrder, user, totalPrice);
|
||||
addEbookToUser(buyOrderProductList, buyOrder, 0);
|
||||
addCourseToUser(buyOrder);
|
||||
} else {
|
||||
return R.error(500, "花生币余额不足!");
|
||||
}
|
||||
@@ -894,6 +898,37 @@ public class BuyOrderController {
|
||||
}
|
||||
}
|
||||
|
||||
private void addCourseToUser(BuyOrder orderEntity){
|
||||
List<ShopProductCourseEntity> orderCourse = buyOrderService.getOrderCourse(orderEntity.getOrderSn());
|
||||
for ( ShopProductCourseEntity s : orderCourse){
|
||||
LambdaQueryWrapper<UserCourseBuyEntity> wrapper2 = new LambdaQueryWrapper<>();
|
||||
wrapper2.eq(UserCourseBuyEntity::getUserId,orderEntity.getUserId());
|
||||
wrapper2.eq(UserCourseBuyEntity::getCatalogueId,s.getCatalogueId());
|
||||
wrapper2.lt(UserCourseBuyEntity::getEndTime,new Date());
|
||||
List<UserCourseBuyEntity> userCourseBuyEntities = userCourseBuyDao.selectList(wrapper2);
|
||||
if(userCourseBuyEntities.size()>0){
|
||||
UserCourseBuyEntity userCourseBuyEntity = userCourseBuyEntities.get(0);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(userCourseBuyEntity.getEndTime());
|
||||
calendar.add(Calendar.DAY_OF_MONTH,180);
|
||||
userCourseBuyEntity.setEndTime(calendar.getTime());
|
||||
userCourseBuyDao.updateById(userCourseBuyEntity);
|
||||
}else{
|
||||
UserCourseBuyEntity userCourseBuyEntity = new UserCourseBuyEntity();
|
||||
userCourseBuyEntity.setUserId(orderEntity.getUserId());
|
||||
userCourseBuyEntity.setCourseId(s.getCourseId());
|
||||
userCourseBuyEntity.setDays(s.getDays());
|
||||
userCourseBuyEntity.setCreateTime(new Date());
|
||||
userCourseBuyEntity.setStartTime(new Date());
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date());
|
||||
cal.add(Calendar.DAY_OF_MONTH,s.getDays());
|
||||
userCourseBuyEntity.setEndTime(cal.getTime());
|
||||
userCourseBuyDao.insert(userCourseBuyEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
* TODO 新版本上线后删除此方法
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.peanut.modules.book.to.UserOrderDto;
|
||||
import com.peanut.modules.book.vo.UserOrderVo;
|
||||
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
|
||||
import com.peanut.modules.book.vo.response.BuyOrderResponseVo;
|
||||
import com.peanut.modules.common.entity.ShopProductCourseEntity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -61,4 +62,6 @@ public interface BuyOrderService extends IService<BuyOrder> {
|
||||
Map<String, Object> decomposeShipment(BuyOrderListRequestVo requestVo);
|
||||
|
||||
String mytest() throws IOException;
|
||||
|
||||
List<ShopProductCourseEntity> getOrderCourse(String orderSn);
|
||||
}
|
||||
@@ -596,6 +596,18 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopProductCourseEntity> getOrderCourse(String orderSn) {
|
||||
// BuyOrder one = this.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>().eq(BuyOrder::getOrderSn, orderSn));
|
||||
MPJLambdaWrapper<BuyOrder> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(ShopProductCourseEntity.class);
|
||||
wrapper.leftJoin(BuyOrderProduct.class,BuyOrderProduct::getOrderId,BuyOrder::getOrderId);
|
||||
wrapper.leftJoin(ShopProductCourseEntity.class,ShopProductCourseEntity::getProductId,BuyOrderProduct::getProductId);
|
||||
wrapper.eq(BuyOrder::getOrderSn,orderSn);
|
||||
List<ShopProductCourseEntity> shopProductCourseEntities = this.getBaseMapper().selectJoinList(ShopProductCourseEntity.class, wrapper);
|
||||
return shopProductCourseEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuyOrderResponseVo orderDetail(String orderSn) {
|
||||
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
|
||||
@@ -15,7 +16,7 @@ import java.util.List;
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface BuyOrderDao extends BaseMapper<BuyOrder> {
|
||||
public interface BuyOrderDao extends MPJBaseMapper<BuyOrder> {
|
||||
List<BuyOrder> orderList(BuyOrderListRequestVo requestVo);
|
||||
int orderListCount(BuyOrderListRequestVo requestVo);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.peanut.common.utils.CopyUtils;
|
||||
import com.peanut.common.utils.OrderUtils;
|
||||
import com.peanut.modules.common.dao.BuyOrderProductDao;
|
||||
import com.peanut.modules.common.dao.ShopProductBookDao;
|
||||
import com.peanut.modules.common.dao.UserCourseBuyDao;
|
||||
import com.peanut.modules.common.dao.UserEbookBuyDao;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
@@ -59,6 +60,8 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
private UserEbookBuyDao userEbookBuyDao;
|
||||
@Autowired
|
||||
private PayRefundOrderService refundOrderService;
|
||||
@Autowired
|
||||
private UserCourseBuyDao userCourseBuyDao;
|
||||
|
||||
@Override
|
||||
public String pay(AlipayDTO payDto) {
|
||||
@@ -216,6 +219,39 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
userEbookBuyDao.insert(entity);
|
||||
}
|
||||
|
||||
|
||||
//开通course,start
|
||||
List<ShopProductCourseEntity> orderCourse = buyOrderService.getOrderCourse(orderEntity.getOrderSn());
|
||||
for ( ShopProductCourseEntity s : orderCourse){
|
||||
LambdaQueryWrapper<UserCourseBuyEntity> wrapper2 = new LambdaQueryWrapper<>();
|
||||
wrapper2.eq(UserCourseBuyEntity::getUserId,orderEntity.getUserId());
|
||||
wrapper2.eq(UserCourseBuyEntity::getCatalogueId,s.getCatalogueId());
|
||||
wrapper2.lt(UserCourseBuyEntity::getEndTime,new Date());
|
||||
List<UserCourseBuyEntity> userCourseBuyEntities = userCourseBuyDao.selectList(wrapper2);
|
||||
if(userCourseBuyEntities.size()>0){
|
||||
UserCourseBuyEntity userCourseBuyEntity = userCourseBuyEntities.get(0);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(userCourseBuyEntity.getEndTime());
|
||||
calendar.add(Calendar.DAY_OF_MONTH,180);
|
||||
userCourseBuyEntity.setEndTime(calendar.getTime());
|
||||
userCourseBuyDao.updateById(userCourseBuyEntity);
|
||||
}else{
|
||||
UserCourseBuyEntity userCourseBuyEntity = new UserCourseBuyEntity();
|
||||
userCourseBuyEntity.setUserId(orderEntity.getUserId());
|
||||
userCourseBuyEntity.setCourseId(s.getCourseId());
|
||||
userCourseBuyEntity.setDays(s.getDays());
|
||||
userCourseBuyEntity.setCreateTime(new Date());
|
||||
userCourseBuyEntity.setStartTime(new Date());
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date());
|
||||
cal.add(Calendar.DAY_OF_MONTH,s.getDays());
|
||||
userCourseBuyEntity.setEndTime(cal.getTime());
|
||||
userCourseBuyDao.insert(userCourseBuyEntity);
|
||||
}
|
||||
}
|
||||
//开通course,end
|
||||
|
||||
|
||||
List<Integer> collect = buyOrderProductDao.selectList(new LambdaQueryWrapper<BuyOrderProduct>().eq(BuyOrderProduct::getOrderId, orderEntity.getOrderId())).stream().map(BuyOrderProduct::getProductId).collect(Collectors.toList());
|
||||
if(collect.contains(128)||collect.contains(129)||collect.contains(130)||collect.contains(131)||collect.contains(136)||collect.contains(137)){
|
||||
MyUserEntity userInfo = userService.getById(orderEntity.getUserId());
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.modules.common.dao.BuyOrderProductDao;
|
||||
import com.peanut.modules.common.dao.PayWechatOrderDao;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.common.dao.UserCourseBuyDao;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.pay.refund.entity.PayRefundOrder;
|
||||
import com.peanut.modules.pay.refund.service.PayRefundOrderService;
|
||||
@@ -66,6 +67,8 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private PayRefundOrderService refundOrderService;
|
||||
@Autowired
|
||||
private UserCourseBuyDao userCourseBuyDao;
|
||||
|
||||
@Override
|
||||
public void prepay(WechatPaymentInfo paymentInfo){
|
||||
@@ -122,6 +125,9 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
||||
if ("order".equals(order.getOrderType())) {
|
||||
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
||||
BigDecimal realMoney = orderEntity.getRealMoney();
|
||||
|
||||
|
||||
//开通book,start
|
||||
// 查询订单的所有 book_id
|
||||
List<Integer> orderBookIdList = shopProductBookService.getOrderBookId(order.getOrderSn());
|
||||
// 去重
|
||||
@@ -141,6 +147,39 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
||||
userEbookBuyEntities.add(entity);
|
||||
}
|
||||
userEbookBuyService.saveBatch(userEbookBuyEntities);
|
||||
//开通book,end
|
||||
|
||||
//开通course,start
|
||||
List<ShopProductCourseEntity> orderCourse = buyOrderService.getOrderCourse(order.getOrderSn());
|
||||
for ( ShopProductCourseEntity s : orderCourse){
|
||||
LambdaQueryWrapper<UserCourseBuyEntity> wrapper2 = new LambdaQueryWrapper<>();
|
||||
wrapper2.eq(UserCourseBuyEntity::getUserId,order.getUserId());
|
||||
wrapper2.eq(UserCourseBuyEntity::getCatalogueId,s.getCatalogueId());
|
||||
wrapper2.lt(UserCourseBuyEntity::getEndTime,new Date());
|
||||
List<UserCourseBuyEntity> userCourseBuyEntities = userCourseBuyDao.selectList(wrapper2);
|
||||
if(userCourseBuyEntities.size()>0){
|
||||
UserCourseBuyEntity userCourseBuyEntity = userCourseBuyEntities.get(0);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(userCourseBuyEntity.getEndTime());
|
||||
calendar.add(Calendar.DAY_OF_MONTH,180);
|
||||
userCourseBuyEntity.setEndTime(calendar.getTime());
|
||||
userCourseBuyDao.updateById(userCourseBuyEntity);
|
||||
}else{
|
||||
UserCourseBuyEntity userCourseBuyEntity = new UserCourseBuyEntity();
|
||||
userCourseBuyEntity.setUserId(order.getUserId());
|
||||
userCourseBuyEntity.setCourseId(s.getCourseId());
|
||||
userCourseBuyEntity.setDays(s.getDays());
|
||||
userCourseBuyEntity.setCreateTime(new Date());
|
||||
userCourseBuyEntity.setStartTime(new Date());
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date());
|
||||
cal.add(Calendar.DAY_OF_MONTH,s.getDays());
|
||||
userCourseBuyEntity.setEndTime(cal.getTime());
|
||||
userCourseBuyDao.insert(userCourseBuyEntity);
|
||||
}
|
||||
}
|
||||
//开通course,end
|
||||
|
||||
//手摸脚模购买后会开启用户的脉穴的功能
|
||||
List<Integer> collect = buyOrderProductDao.selectList(new LambdaQueryWrapper<BuyOrderProduct>().eq(BuyOrderProduct::getOrderId, order.getOrderId())).stream().map(BuyOrderProduct::getProductId).collect(Collectors.toList());
|
||||
if(collect.contains(128)||collect.contains(129)||collect.contains(130)||collect.contains(131)||collect.contains(136)||collect.contains(137)){
|
||||
|
||||
@@ -62,6 +62,17 @@ public class CourseController {
|
||||
return R.ok().put("courses",sociologyCourseList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取课程目录章节详情
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getCourseCatalogueChapterDetail")
|
||||
public R getCourseCatalogueChapterDetail(@RequestBody ParamTo param){
|
||||
Map<String, Object> chapterDetail = courseCatalogueChapterService.getChapterDetail(param.getId());
|
||||
return R.ok().put("data",chapterDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取课程详情
|
||||
* @param param
|
||||
|
||||
@@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CourseCatalogueChapterService extends IService<CourseCatalogueChapterEntity> {
|
||||
List<CourseCatalogueChapterEntity> getCourseCatalogueChapterList(int id);
|
||||
|
||||
Map<String,Object> getChapterDetail(Integer chapterId);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.peanut.modules.sociology.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterEntity;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
|
||||
@@ -21,4 +22,5 @@ public interface CourseService extends IService<CourseEntity> {
|
||||
|
||||
Map<String, Object> getCourseDetail(Integer id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,17 +3,23 @@ package com.peanut.modules.sociology.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.CourseCatalogueChapterDao;
|
||||
import com.peanut.modules.common.dao.CourseCatalogueChapterVideoDao;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterEntity;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterVideoEntity;
|
||||
import com.peanut.modules.sociology.service.CourseCatalogueChapterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("sociologyCourseCatalogueChapterService")
|
||||
public class CourseCatalogueChapterServiceImpl extends ServiceImpl<CourseCatalogueChapterDao, CourseCatalogueChapterEntity> implements CourseCatalogueChapterService {
|
||||
|
||||
@Autowired
|
||||
private CourseCatalogueChapterVideoDao courseCatalogueChapterVideoDao;
|
||||
@Override
|
||||
public List<CourseCatalogueChapterEntity> getCourseCatalogueChapterList(int id) {
|
||||
LambdaQueryWrapper<CourseCatalogueChapterEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
@@ -22,4 +28,14 @@ public class CourseCatalogueChapterServiceImpl extends ServiceImpl<CourseCatalog
|
||||
List<CourseCatalogueChapterEntity> list = this.list(wrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getChapterDetail(Integer chapterId) {
|
||||
CourseCatalogueChapterEntity byId = this.getById(chapterId);
|
||||
HashMap<String, Object> flag = new HashMap<>();
|
||||
flag.put("detail",byId);
|
||||
List<CourseCatalogueChapterVideoEntity> courseCatalogueChapterVideoEntities = courseCatalogueChapterVideoDao.selectList(new LambdaQueryWrapper<CourseCatalogueChapterVideoEntity>().eq(CourseCatalogueChapterVideoEntity::getChapterId, chapterId));
|
||||
flag.put("videos",courseCatalogueChapterVideoEntities);
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.leftJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.eq(CourseToSociologyEntity::getSociologyId,param.getId());
|
||||
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()),CourseEntity.class, wrapper);
|
||||
return courseEntityPage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user