修复一下bug

This commit is contained in:
wangjinlei
2024-04-23 16:36:04 +08:00
parent 3cbd29de4b
commit ba2fa6baf3
12 changed files with 174 additions and 2 deletions

View File

@@ -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 新版本上线后删除此方法