From a60d75099a66f1d142e3532c8c61460e03cc093e Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 03 三月 2023 17:07:12 +0800 Subject: [PATCH] 系统管理 --- management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCouponController.java | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCouponController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCouponController.java index b0d0eac..3d745de 100644 --- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCouponController.java +++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCouponController.java @@ -6,9 +6,11 @@ import com.stylefeng.guns.core.util.DateUtil; import com.stylefeng.guns.modular.system.controller.req.CouponSendReq; import com.stylefeng.guns.modular.system.enums.CouponStatusEnum; +import com.stylefeng.guns.modular.system.model.TAgent; import com.stylefeng.guns.modular.system.model.TUserToCoupon; import com.stylefeng.guns.modular.system.service.ITUserToCouponService; import io.swagger.annotations.ApiOperation; +import org.apache.poi.hdf.extractor.TC; import org.springframework.stereotype.Controller; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; @@ -146,6 +148,33 @@ } /** + * 修改优惠券状态 + */ + @RequestMapping(value = "/update-status") + @ResponseBody + public Object updateStatus(Integer id,Integer status) { + TCoupon tCoupon = tCouponService.selectById(id); + + // 查询已启用的新人券数量 + int count = tCouponService.selectCount(new EntityWrapper<TCoupon>().eq("coupon_state", 1) + .eq("coupon_type",2)); + + // 判断是否为新人券,新人券只可启用一条记录 + if(count > 0 && 2 == tCoupon.getCouponType() && 2 == status){ + return new SuccessTip(500,"已有启动的新人券!"); + } + + if(1 == status){ + tCoupon.setCouponState(2); + } + if(2 == status){ + tCoupon.setCouponState(1); + } + tCouponService.updateById(tCoupon); + return SUCCESS_TIP; + } + + /** * 修改 */ @RequestMapping(value = "/update") -- Gitblit v1.7.1