luodangjia
2024-08-24 25c2e11cf8045a2a59bc5c661a7d96e5b372b318
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -32,6 +32,7 @@
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -193,12 +194,15 @@
    private TAppUserTagService appUserTagService;
    @Autowired
    private TAppUserService appUserService;
    /**
     * 后台远程调用 给用户发放优惠券
     */
    @PostMapping("/grantCoupon")
    public R  grantCoupon(@RequestBody GrantCouponDto dto){
        List<TAppCoupon> res = new ArrayList<>();
        TCoupon coupon = otherClient.getCouponById(dto.getCouponId()).getData();
        switch (dto.getType()){
            case 1:
                // 根据标签ids 查询用户ids
@@ -212,6 +216,7 @@
                    tAppCoupon.setEndTime(dto.getEndTime());
                    tAppCoupon.setWaysToObtain(dto.getWaysToObtain());
                    tAppCoupon.setStatus(1);
                    tAppCoupon.setCouponJson(JSON.toJSONString(coupon));
                    res.add(tAppCoupon);
                }
                tAppCouponService.saveBatch(res);
@@ -228,6 +233,7 @@
                    tAppCoupon.setEndTime(dto.getEndTime());
                    tAppCoupon.setWaysToObtain(dto.getWaysToObtain());
                    tAppCoupon.setStatus(1);
                    tAppCoupon.setCouponJson(JSON.toJSONString(coupon));
                    res.add(tAppCoupon);
                }
                tAppCouponService.saveBatch(res);
@@ -240,6 +246,7 @@
                    tAppCoupon.setEndTime(dto.getEndTime());
                    tAppCoupon.setWaysToObtain(dto.getWaysToObtain());
                    tAppCoupon.setStatus(1);
                    tAppCoupon.setCouponJson(JSON.toJSONString(coupon));
                    res.add(tAppCoupon);
                }
                tAppCouponService.saveBatch(res);