|
|
|
@ -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<List<StoreCouponUserVo>> orderCoupon(@PathVariable String cartIds){ |
|
|
|
|
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));
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|