xuhy
2024-08-22 95f5b047f67c727370866a5ba683bd9eb1ad86b0
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -1,6 +1,7 @@
package com.ruoyi.account.controller;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.account.api.dto.CouponListDto;
import com.ruoyi.account.api.dto.GrantCouponDto;
@@ -31,6 +32,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -49,6 +51,8 @@
public class TAppCouponController {
    @Autowired
    private TAppCouponService tAppCouponService;
    @Resource
    private OtherClient otherClient;
    @Autowired
    private TAppUserCarService appUserCarService;
@@ -58,11 +62,11 @@
    private ChargingPileClient chargingPileClient;
    @Autowired
    private ChargingOrderClient chargingOrderClient;
    @Resource
    private ChargingGunClient chargingGunClient;
    /**
     * 小程序扫一扫 添加车辆
     * @param dto
@@ -144,8 +148,8 @@
     * 管理后台远程调用 根据优惠券ids 查询对应的发放数量
     * @return 优惠券ids 查询每个优惠券的发放数量
     */
    @PostMapping("/getCountByCouponIds")
    public R<List<Integer>> getCountByCouponIds( String couponIds) {
    @PostMapping("/getCountByCouponIds/{couponIds}")
    public R<List<Integer>> getCountByCouponIds(@PathVariable("couponIds")String couponIds) {
        // 最终结果 和优惠券id一一对应
        List<Integer> res = new ArrayList<>();
        String[] split = couponIds.split(",");
@@ -164,8 +168,8 @@
     * @param couponId
     * @return
     */
    @PostMapping("/getUseCountByCouponId")
    public R<Integer> getUseCountByCouponId(Integer couponId){
    @PostMapping("/getUseCountByCouponId/{couponId}")
    public R<Integer> getUseCountByCouponId(@PathVariable("couponId") Integer couponId){
        return R.ok(tAppCouponService.list(new QueryWrapper<TAppCoupon>()
                .eq("coupon_id", couponId)
                .eq("status",2)).size());
@@ -193,6 +197,8 @@
            tAppCoupon.setEndTime(dto.getEndTime());
            tAppCoupon.setWaysToObtain(dto.getWaysToObtain());
            tAppCoupon.setStatus(1);
            R<TCoupon> couponById = otherClient.getCouponById(Integer.valueOf(s));
            tAppCoupon.setCouponJson(JSON.toJSONString(couponById.getData()));
            res.add(tAppCoupon);
        }
        tAppCouponService.saveBatch(res);