小班进入考试周修改
优惠券修改
This commit is contained in:
@@ -13,6 +13,7 @@ import com.peanut.modules.master.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -58,6 +59,8 @@ public class CouponController {
|
||||
Page<CouponEntity> couponPage = couponService.page(new Page<>(page, limit), wrapper);
|
||||
for (CouponEntity couponEntity : couponPage.getRecords()) {
|
||||
couponService.setRangeList(couponEntity);
|
||||
couponEntity.setGrantCount(couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponEntity.getId())));
|
||||
}
|
||||
return R.ok().put("couponPage",couponPage);
|
||||
}
|
||||
@@ -122,21 +125,13 @@ public class CouponController {
|
||||
//修改优惠劵
|
||||
@RequestMapping("/updateCoupon")
|
||||
public R updateCoupon(@RequestBody CouponEntity couponEntity){
|
||||
int count = couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
.eq(CouponHistory::getCouponId,couponEntity.getId()));
|
||||
if (count>0){
|
||||
return R.error("已有用户拥有优惠券");
|
||||
}
|
||||
CouponEntity c = couponService.getById(couponEntity.getId());
|
||||
if (c.getCurrentState()==0){
|
||||
return R.error("优惠券发放中,请先结束再修改");
|
||||
}
|
||||
couponService.updateById(couponEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除优惠劵
|
||||
@RequestMapping("/delCoupon")
|
||||
@Transactional
|
||||
public R delCoupon(@RequestBody Map<String,Object> params){
|
||||
int couponId = Integer.parseInt(params.get("id").toString());
|
||||
int count = couponHistoryService.count(new LambdaQueryWrapper<CouponHistory>()
|
||||
@@ -149,6 +144,12 @@ public class CouponController {
|
||||
return R.error("优惠券发放中,请先结束再删除");
|
||||
}
|
||||
couponService.removeById(couponId);
|
||||
//删除优惠券商品绑定
|
||||
List<CouponToProduct> ctps = couponToProductService.list(new LambdaQueryWrapper<CouponToProduct>()
|
||||
.eq(CouponToProduct::getCouponId,couponId));
|
||||
for (CouponToProduct ctp:ctps){
|
||||
couponToProductService.removeById(ctp.getId());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user