|
@@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCoup
|
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO;
|
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO;
|
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO;
|
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO;
|
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
|
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
|
|
|
+import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
|
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
|
|
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
|
|
|
|
@@ -71,33 +74,12 @@ public class AppCouponController {
|
|
return success(list);
|
|
return success(list);
|
|
}
|
|
}
|
|
|
|
|
|
- // TODO 芋艿:待实现
|
|
|
|
@GetMapping("/page")
|
|
@GetMapping("/page")
|
|
@Operation(summary = "优惠劵列表", description = "我的优惠劵")
|
|
@Operation(summary = "优惠劵列表", description = "我的优惠劵")
|
|
public CommonResult<PageResult<AppCouponRespVO>> takeCoupon(AppCouponPageReqVO pageReqVO) {
|
|
public CommonResult<PageResult<AppCouponRespVO>> takeCoupon(AppCouponPageReqVO pageReqVO) {
|
|
- List<AppCouponRespVO> list = new ArrayList<>();
|
|
|
|
- Random random = new Random();
|
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
|
- AppCouponRespVO vo = new AppCouponRespVO();
|
|
|
|
- vo.setId(i + 1L);
|
|
|
|
- vo.setName("优惠劵" + (i + 1));
|
|
|
|
- vo.setStatus(pageReqVO.getStatus());
|
|
|
|
- vo.setUsePrice(random.nextInt(100) * 100);
|
|
|
|
- vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10)));
|
|
|
|
- vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10));
|
|
|
|
- vo.setDiscountType(random.nextInt(2) + 1);
|
|
|
|
- if (vo.getDiscountType() == 1) {
|
|
|
|
- vo.setDiscountPercent(null);
|
|
|
|
- vo.setDiscountPrice(random.nextInt(50) * 100);
|
|
|
|
- vo.setDiscountLimitPrice(null);
|
|
|
|
- } else {
|
|
|
|
- vo.setDiscountPercent(random.nextInt(90) + 10);
|
|
|
|
- vo.setDiscountPrice(null);
|
|
|
|
- vo.setDiscountLimitPrice(random.nextInt(200) * 100);
|
|
|
|
- }
|
|
|
|
- list.add(vo);
|
|
|
|
- }
|
|
|
|
- return success(new PageResult<>(list, 20L));
|
|
|
|
|
|
+ PageResult<CouponDO> pageResult = couponService.getCouponPage(
|
|
|
|
+ CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId())));
|
|
|
|
+ return success(CouponConvert.INSTANCE.convertAppPage(pageResult));
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/get-unused-count")
|
|
@GetMapping(value = "/get-unused-count")
|