记得上下班打卡 | git大法好,push需谨慎

Commit 192cbf84 authored by 张国柄's avatar 张国柄

~API:商城优惠券:展示+当前用户已领取数量;

parent 34447015
......@@ -13,7 +13,7 @@ import java.time.LocalDateTime;
@ApiModel(value = "GoblinStoreCouponVo", description = "商铺活动:优惠券详情")
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonIgnoreProperties(value = {"receiveCount"}, ignoreUnknown = true)
public class GoblinStoreCouponVo implements Serializable, Cloneable {
private static final long serialVersionUID = -6233852543461320809L;
@ApiModelProperty(position = 10, value = "卡券ID[64]")
......@@ -63,6 +63,11 @@ public class GoblinStoreCouponVo implements Serializable, Cloneable {
private LocalDateTime endTime;
/* ========================================================================== */
@ApiModelProperty(position = 27, value = "当前用户已领取数量")
private int receiveCount;
private static final GoblinStoreCouponVo obj = new GoblinStoreCouponVo();
public static GoblinStoreCouponVo getNew() {
......
......@@ -11,6 +11,7 @@ import com.liquidnet.service.goblin.service.GoblinCouponService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
......@@ -53,7 +54,21 @@ public class GoblinCouponController {
public ResponseDto<ArrayList<GoblinStoreCouponVo>> getSpuByType(@RequestParam("spuId") @Valid String spuId,
@RequestParam("storeId") @Valid String storeId,
@RequestParam("type") @Valid String type) {
return ResponseDto.success(goblinCouponService.getSpuByType(spuId, storeId, type));
ArrayList<GoblinStoreCouponVo> storeCouponVos = goblinCouponService.getSpuByType(spuId, storeId, type);
if (!CollectionUtils.isEmpty(storeCouponVos)) {
String currentUid = CurrentUtil.getCurrentUid();
if (StringUtils.isNotEmpty(currentUid)) {
List<GoblinUserCouponVo> userCouponVos = goblinRedisUtils.getUserCouponVos(currentUid);
if (!CollectionUtils.isEmpty(userCouponVos))
for (GoblinStoreCouponVo storeCouponVo : storeCouponVos)
for (GoblinUserCouponVo userCouponVo : userCouponVos)
if (storeCouponVo.getStoreCouponId().equals(userCouponVo.getStoreCouponId())) {
storeCouponVo.setReceiveCount(storeCouponVo.getReceiveCount() + 1);
break;
}
}
}
return ResponseDto.success(storeCouponVos);
}
@PostMapping("receive")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment