| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | | import com.ruoyi.account.api.vo.ExchangeRecordVO; |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/t-app-coupon") |
| | | public class TAppCouponController { |
| | | @Autowired |
| | | private TAppCouponService tAppCouponService; |
| | | |
| | | /** |
| | | * 管理后台远程调用 根据优惠券ids 查询对应的发放数量 |
| | | * @return 优惠券ids 查询每个优惠券的发放数量 |
| | | */ |
| | | @PostMapping("/getCountByCouponIds") |
| | | public R<List<Integer>> getCountByCouponIds(String couponIds) { |
| | | // 最终结果 和优惠券id一一对应 |
| | | List<Integer> res = new ArrayList<>(); |
| | | String[] split = couponIds.split(","); |
| | | // 查询每个优惠券的发放数量 |
| | | List<TAppCoupon> couponId = tAppCouponService.list(new QueryWrapper<TAppCoupon>() |
| | | .in("coupon_id", Arrays.asList(split))); |
| | | for (String s : split) { |
| | | res.add(tAppCouponService.list(new QueryWrapper<TAppCoupon>() |
| | | .eq("coupon_id", s)).size()); |
| | | } |
| | | return R.ok(res); |
| | | } |
| | | |
| | | /** |
| | | * 后台远程调用 根据优惠券id 查询使用数量 |
| | | * @param couponId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getUseCountByCouponId") |
| | | public R<Integer> getUseCountByCouponId(Integer couponId){ |
| | | return R.ok(tAppCouponService.list(new QueryWrapper<TAppCoupon>() |
| | | .eq("coupon_id", couponId) |
| | | .eq("status",2)).size()); |
| | | } |
| | | /** |
| | | * 后台远程调用 根据优惠券id 查询领取记录 |
| | | * @param couponId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getExchangeRecordByCouponId") |
| | | public R<PageInfo<ExchangeRecordVO>> getUseCountByCouponId(ExchangeRecordGoodsQuery couponId){ |
| | | return R.ok(tAppCouponService.pagelist(couponId)); |
| | | } |
| | | } |
| | | |