From 91188fe1a050decdb75e6066d2c4c79f881277d7 Mon Sep 17 00:00:00 2001 From: sj <1304317391@qq.com> Date: Mon, 14 Nov 2022 13:58:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=B9=B6=E8=BF=90=E8=A1=8C=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E8=AE=BE=E7=BD=AE=E4=B8=BA=E6=97=A0?= =?UTF-8?q?=E9=97=A8=E6=A7=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/coupon/rest/CouponController.java | 32 ++++++++++++++++++- .../activity/rest/StoreCouponController.java | 12 +++---- .../mapper/YxStoreCouponUserMapper.java | 2 +- .../activity/vo/StoreCouponUserVo.java | 6 ++-- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java index f27cd938..52c77d67 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java @@ -9,18 +9,24 @@ package co.yixiang.app.modules.coupon.rest; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.ApiResult; import cn.iocoder.yudao.framework.common.exception.YshopException; import co.yixiang.logging.aop.log.AppLog; import co.yixiang.app.common.aop.NoRepeatSubmit; import co.yixiang.app.common.bean.LocalUser; import cn.iocoder.yudao.framework.security.core.annotations.AuthCheck; +import co.yixiang.modules.activity.domain.YxStoreCoupon; import co.yixiang.modules.activity.service.YxStoreCouponIssueService; +import co.yixiang.modules.activity.service.YxStoreCouponService; import co.yixiang.modules.activity.service.YxStoreCouponUserService; import co.yixiang.modules.activity.vo.StoreCouponUserVo; import co.yixiang.modules.activity.vo.YxStoreCouponIssueQueryVo; import co.yixiang.modules.activity.vo.YxStoreCouponUserQueryVo; import co.yixiang.app.modules.coupon.param.YxStoreCouponQueryParam; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -37,6 +43,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -57,6 +64,9 @@ public class CouponController { private final YxStoreCouponIssueService couponIssueService; private final YxStoreCouponUserService storeCouponUserService; + private final YxStoreCouponService storeCouponService; + private final YxStoreProductService yxStoreProductService; + /** * 领券中心优惠券列表 */ @@ -188,7 +198,27 @@ public class CouponController { @ApiOperation(value = "优惠券订单获取",notes = "优惠券订单获取") public ApiResult> orderCoupon(@PathVariable String cartIds){ Long uid = LocalUser.getUser().getUid(); - return ApiResult.ok(storeCouponUserService.beUsableCouponList(uid,cartIds)); + List list=storeCouponUserService.beUsableCouponList(uid,cartIds); + for (StoreCouponUserVo queryVo:list){ + String[] idList =queryVo.getProductId().split(","); + List needIdlist; + //因为最多只需要展示三个商品的图 + if (idList.length>3){ + needIdlist= Arrays.asList(Arrays.copyOf(idList, 3)); + }else { + needIdlist= Arrays.asList(idList); + } + List imageList=new ArrayList<>(); + needIdlist.forEach(id->{ + YxStoreProduct yxStoreProduct=yxStoreProductService.getById(id); + if (ObjectUtil.isNotEmpty(yxStoreProduct)&& StringUtils.isNotBlank(yxStoreProduct.getImage())){ + imageList.add(yxStoreProductService.getById(id).getImage()); + } + }); + queryVo.setImage(imageList); + } + return ApiResult.ok(list); +// return ApiResult.ok(storeCouponUserService.beUsableCouponList(uid,cartIds)); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java index 6af063b0..afe4cb3f 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java @@ -61,9 +61,9 @@ public class StoreCouponController { && StrUtil.isEmpty(resources.getProductId())){ throw new YshopException("请选择商品"); } - if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { - throw new YshopException("优惠券金额不能高于最低消费金额"); - } +// if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { +// throw new YshopException("优惠券金额不能高于最低消费金额"); +// } return new ResponseEntity<>(yxStoreCouponService.save(resources),HttpStatus.CREATED); } @@ -77,9 +77,9 @@ public class StoreCouponController { && StrUtil.isEmpty(resources.getProductId())){ throw new YshopException("请选择商品"); } - if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { - throw new YshopException("优惠券金额不能高于最低消费金额"); - } +// if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { +// throw new YshopException("优惠券金额不能高于最低消费金额"); +// } //这里需要对优惠券开始使用时间和结束时间进行比较 yxStoreCouponService.saveOrUpdate(resources); return new ResponseEntity(HttpStatus.NO_CONTENT); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java index 0ca1f6c3..43d090a1 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java @@ -25,7 +25,7 @@ import java.util.List; */ @Repository public interface YxStoreCouponUserMapper extends CoreMapper { - @Select("select A.id,A.coupon_title as couponTitle,A.coupon_price as couponPrice," + + @Select("select A.id,A.coupon_title as cname,A.coupon_price as couponPrice," + "A.use_end_time as endTime,B.use_min_price as useMinPrice,B.type," + "B.product_id as productId" + " from yx_store_coupon_user A left join yx_store_coupon B " + diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java index a3c7da30..3df08737 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java @@ -7,6 +7,7 @@ import lombok.Setter; import java.io.Serializable; import java.util.Date; +import java.util.List; /** * 优惠券发放记录对象StoreCouponUserVO @@ -26,7 +27,7 @@ public class StoreCouponUserVo implements Serializable /** 优惠券名称 */ @ApiModelProperty(value = "优惠券名称") - private String couponTitle; + private String cname; /** 优惠券的面值 */ @ApiModelProperty(value = "优惠券的面值") @@ -49,6 +50,7 @@ public class StoreCouponUserVo implements Serializable @ApiModelProperty(value = "优惠产品ID") private String productId; - + @ApiModelProperty(value = "商品轮播图") + private List image; }