|
@@ -3,6 +3,7 @@ package com.zhongzheng.modules.user.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
@@ -191,6 +192,9 @@ public class UserExamGoodsServiceImpl extends ServiceImpl<UserExamGoodsMapper, U
|
|
|
|
|
|
@Override
|
|
|
public Boolean delNum(UserExamGoodsQueryBo bo) {
|
|
|
+ if(Validator.isEmpty(bo.getUserId())||Validator.isEmpty(bo.getGoodsId())||Validator.isEmpty(bo.getOrderGoodsId())){
|
|
|
+ throw new CustomException("考试次数修改参数缺失");
|
|
|
+ }
|
|
|
UserExamGoodsSupplement entity = iUserExamGoodsSupplementService.getOne(new LambdaQueryWrapper<UserExamGoodsSupplement>().eq(UserExamGoodsSupplement::getOrderGoodsId, bo.getOrderGoodsId()));
|
|
|
if(Validator.isNotEmpty(entity)){
|
|
|
UserExamGoodsVo examGoodsVo = queryById(entity.getUserExamGoodsId());
|
|
@@ -198,7 +202,14 @@ public class UserExamGoodsServiceImpl extends ServiceImpl<UserExamGoodsMapper, U
|
|
|
if(entity.getStatus()==1){
|
|
|
//补考
|
|
|
if((examGoodsVo.getExamNumber().longValue()-examGoodsVo.getExpendNumber().longValue())>entity.getExamNumber()){
|
|
|
- //剩余次数大于购买时绑定次数
|
|
|
+ //减去补考次数
|
|
|
+ LambdaUpdateWrapper<UserExamGoods> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
+ objectLambdaUpdateWrapper.eq(UserExamGoods::getUserId, bo.getUserId());
|
|
|
+ objectLambdaUpdateWrapper.eq(UserExamGoods::getGoodsId, bo.getGoodsId());
|
|
|
+
|
|
|
+ objectLambdaUpdateWrapper.set(UserExamGoods::getExamNumber, examGoodsVo.getExamNumber().longValue()-entity.getExamNumber().longValue());
|
|
|
+ objectLambdaUpdateWrapper.set(UserExamGoods::getUpdateTime,DateUtils.getNowTime());
|
|
|
+ update(null, objectLambdaUpdateWrapper);
|
|
|
return true;
|
|
|
}else{
|
|
|
throw new CustomException("剩余次数不满足退款");
|
|
@@ -207,7 +218,14 @@ public class UserExamGoodsServiceImpl extends ServiceImpl<UserExamGoodsMapper, U
|
|
|
else if(entity.getStatus()==2){
|
|
|
//前培
|
|
|
if((examGoodsVo.getDoNumber().longValue()-examGoodsVo.getExpendBefore().longValue())>entity.getDoNumber()){
|
|
|
- //剩余次数大于购买时绑定次数
|
|
|
+ //减去前培次数
|
|
|
+ LambdaUpdateWrapper<UserExamGoods> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
+ objectLambdaUpdateWrapper.eq(UserExamGoods::getUserId, bo.getUserId());
|
|
|
+ objectLambdaUpdateWrapper.eq(UserExamGoods::getGoodsId, bo.getGoodsId());
|
|
|
+
|
|
|
+ objectLambdaUpdateWrapper.set(UserExamGoods::getExamNumber, examGoodsVo.getDoNumber().longValue()-entity.getDoNumber().longValue());
|
|
|
+ objectLambdaUpdateWrapper.set(UserExamGoods::getUpdateTime,DateUtils.getNowTime());
|
|
|
+ update(null, objectLambdaUpdateWrapper);
|
|
|
return true;
|
|
|
}else{
|
|
|
throw new CustomException("剩余次数不满足退款");
|