Browse Source

优化优惠券显示并运行最小优惠券设置为无门槛

zyj
sj 2 years ago
parent
commit
91188fe1a0
  1. 32
      zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java
  2. 12
      zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java
  3. 2
      zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java
  4. 6
      zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java

32
zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java

@ -9,18 +9,24 @@
package co.yixiang.app.modules.coupon.rest; package co.yixiang.app.modules.coupon.rest;
import cn.hutool.core.util.NumberUtil; 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.pojo.ApiResult;
import cn.iocoder.yudao.framework.common.exception.YshopException; import cn.iocoder.yudao.framework.common.exception.YshopException;
import co.yixiang.logging.aop.log.AppLog; import co.yixiang.logging.aop.log.AppLog;
import co.yixiang.app.common.aop.NoRepeatSubmit; import co.yixiang.app.common.aop.NoRepeatSubmit;
import co.yixiang.app.common.bean.LocalUser; import co.yixiang.app.common.bean.LocalUser;
import cn.iocoder.yudao.framework.security.core.annotations.AuthCheck; 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.YxStoreCouponIssueService;
import co.yixiang.modules.activity.service.YxStoreCouponService;
import co.yixiang.modules.activity.service.YxStoreCouponUserService; import co.yixiang.modules.activity.service.YxStoreCouponUserService;
import co.yixiang.modules.activity.vo.StoreCouponUserVo; import co.yixiang.modules.activity.vo.StoreCouponUserVo;
import co.yixiang.modules.activity.vo.YxStoreCouponIssueQueryVo; import co.yixiang.modules.activity.vo.YxStoreCouponIssueQueryVo;
import co.yixiang.modules.activity.vo.YxStoreCouponUserQueryVo; import co.yixiang.modules.activity.vo.YxStoreCouponUserQueryVo;
import co.yixiang.app.modules.coupon.param.YxStoreCouponQueryParam; 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.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
@ -37,6 +43,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -57,6 +64,9 @@ public class CouponController {
private final YxStoreCouponIssueService couponIssueService; private final YxStoreCouponIssueService couponIssueService;
private final YxStoreCouponUserService storeCouponUserService; private final YxStoreCouponUserService storeCouponUserService;
private final YxStoreCouponService storeCouponService;
private final YxStoreProductService yxStoreProductService;
/** /**
* 领券中心优惠券列表 * 领券中心优惠券列表
*/ */
@ -188,7 +198,27 @@ public class CouponController {
@ApiOperation(value = "优惠券订单获取",notes = "优惠券订单获取") @ApiOperation(value = "优惠券订单获取",notes = "优惠券订单获取")
public ApiResult<List<StoreCouponUserVo>> orderCoupon(@PathVariable String cartIds){ public ApiResult<List<StoreCouponUserVo>> orderCoupon(@PathVariable String cartIds){
Long uid = LocalUser.getUser().getUid(); Long uid = LocalUser.getUser().getUid();
return ApiResult.ok(storeCouponUserService.beUsableCouponList(uid,cartIds)); List<StoreCouponUserVo> list=storeCouponUserService.beUsableCouponList(uid,cartIds);
for (StoreCouponUserVo queryVo:list){
String[] idList =queryVo.getProductId().split(",");
List<String> needIdlist;
//因为最多只需要展示三个商品的图
if (idList.length>3){
needIdlist= Arrays.asList(Arrays.copyOf(idList, 3));
}else {
needIdlist= Arrays.asList(idList);
}
List<String> 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));
} }

12
zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java

@ -61,9 +61,9 @@ public class StoreCouponController {
&& StrUtil.isEmpty(resources.getProductId())){ && StrUtil.isEmpty(resources.getProductId())){
throw new YshopException("请选择商品"); throw new YshopException("请选择商品");
} }
if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { // if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) {
throw new YshopException("优惠券金额不能高于最低消费金额"); // throw new YshopException("优惠券金额不能高于最低消费金额");
} // }
return new ResponseEntity<>(yxStoreCouponService.save(resources),HttpStatus.CREATED); return new ResponseEntity<>(yxStoreCouponService.save(resources),HttpStatus.CREATED);
} }
@ -77,9 +77,9 @@ public class StoreCouponController {
&& StrUtil.isEmpty(resources.getProductId())){ && StrUtil.isEmpty(resources.getProductId())){
throw new YshopException("请选择商品"); throw new YshopException("请选择商品");
} }
if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { // if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) {
throw new YshopException("优惠券金额不能高于最低消费金额"); // throw new YshopException("优惠券金额不能高于最低消费金额");
} // }
//这里需要对优惠券开始使用时间和结束时间进行比较 //这里需要对优惠券开始使用时间和结束时间进行比较
yxStoreCouponService.saveOrUpdate(resources); yxStoreCouponService.saveOrUpdate(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);

2
zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java

@ -25,7 +25,7 @@ import java.util.List;
*/ */
@Repository @Repository
public interface YxStoreCouponUserMapper extends CoreMapper<YxStoreCouponUser> { public interface YxStoreCouponUserMapper extends CoreMapper<YxStoreCouponUser> {
@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," + "A.use_end_time as endTime,B.use_min_price as useMinPrice,B.type," +
"B.product_id as productId" + "B.product_id as productId" +
" from yx_store_coupon_user A left join yx_store_coupon B " + " from yx_store_coupon_user A left join yx_store_coupon B " +

6
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.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 优惠券发放记录对象StoreCouponUserVO * 优惠券发放记录对象StoreCouponUserVO
@ -26,7 +27,7 @@ public class StoreCouponUserVo implements Serializable
/** 优惠券名称 */ /** 优惠券名称 */
@ApiModelProperty(value = "优惠券名称") @ApiModelProperty(value = "优惠券名称")
private String couponTitle; private String cname;
/** 优惠券的面值 */ /** 优惠券的面值 */
@ApiModelProperty(value = "优惠券的面值") @ApiModelProperty(value = "优惠券的面值")
@ -49,6 +50,7 @@ public class StoreCouponUserVo implements Serializable
@ApiModelProperty(value = "优惠产品ID") @ApiModelProperty(value = "优惠产品ID")
private String productId; private String productId;
@ApiModelProperty(value = "商品轮播图")
private List<String> image;
} }

Loading…
Cancel
Save