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

Commit 8ce909b2 authored by 胡佳晨's avatar 胡佳晨

goblin 帮助前端用店铺券

parent abb66d3a
...@@ -18,8 +18,10 @@ public class CouponHelpUseParam implements Serializable, Cloneable { ...@@ -18,8 +18,10 @@ public class CouponHelpUseParam implements Serializable, Cloneable {
private List<CouponCanUse2Param> param; private List<CouponCanUse2Param> param;
@ApiModelProperty(dataType = "String", name = "uid", value = "用户id", example = "10", required = false) @ApiModelProperty(dataType = "String", name = "uid", value = "用户id", example = "10", required = false)
private String uid; private String uid;
@ApiModelProperty(dataType = "String", name = "ucouponId", value = "券id", required = true) @ApiModelProperty(dataType = "String", name = "ucouponId", value = "店铺券id", required = false)
private String ucouponId; private String ucouponId;
@ApiModelProperty(dataType = "String", name = "platformUcouponId", value = "平台券id", required = false)
private String platformUcouponId;
private static final CouponHelpUseParam obj = new CouponHelpUseParam(); private static final CouponHelpUseParam obj = new CouponHelpUseParam();
......
...@@ -8,17 +8,22 @@ import lombok.Data; ...@@ -8,17 +8,22 @@ import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@Api @Api
@Data @Data
public class CouponHelpUseVo implements Serializable, Cloneable { public class CouponHelpUseVo implements Serializable, Cloneable {
@ApiModelProperty(name = "param", value = "对象") // @ApiModelProperty(name = "param", value = "对象")
private List<CouponCanUse2Param> param; // private List<CouponCanUse2Param> param;
@ApiModelProperty(name = "couponVo", value = "券vo") // @ApiModelProperty(name = "couponVo", value = "券vo")
private GoblinUserCouponVo couponVo; // private GoblinUserCouponVo couponVo;
@ApiModelProperty(dataType = "String", name = "ucouponId", value = "券id", required = true) @ApiModelProperty(dataType = "String", name = "ucouponId", value = "券id", required = true)
private String ucouponId; private String ucouponId;
@ApiModelProperty(dataType = "String", name = "platformUcouponId", value = "平台券id", required = true)
private String platformUcouponId;
@ApiModelProperty(dataType = "number", name = "price", value = "优惠金额", required = true)
private BigDecimal price;
private static final CouponHelpUseVo obj = new CouponHelpUseVo(); private static final CouponHelpUseVo obj = new CouponHelpUseVo();
......
...@@ -412,10 +412,12 @@ public class GoblinCouponImpl implements GoblinCouponService { ...@@ -412,10 +412,12 @@ public class GoblinCouponImpl implements GoblinCouponService {
public CouponHelpUseVo helpUseCoupon(CouponHelpUseParam params) { public CouponHelpUseVo helpUseCoupon(CouponHelpUseParam params) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
CouponHelpUseVo vo = CouponHelpUseVo.getNew(); CouponHelpUseVo vo = CouponHelpUseVo.getNew();
List<GoblinUserCouponVo> voList = goblinRedisUtils.getUserCouponVos(params.getUid()); GoblinUseResultVo returnVo;
GoblinUseResultVo returnVo = GoblinUseResultVo.getNew();
String ucouponId = params.getUcouponId(); String ucouponId = params.getUcouponId();
String platformUcouponId = params.getPlatformUcouponId();
//店铺券
if(ucouponId!=null && !ucouponId.equals("")) {
List<GoblinUserCouponVo> voList = goblinRedisUtils.getUserCouponVos(params.getUid());
for (GoblinUserCouponVo itemVo : voList) { for (GoblinUserCouponVo itemVo : voList) {
if (itemVo.getUcouponId().equals(ucouponId)) { if (itemVo.getUcouponId().equals(ucouponId)) {
if (itemVo.getUcouponId().equals(ucouponId) && itemVo.getDuedAt().isAfter(now) && itemVo.getState().equals(1)) { if (itemVo.getUcouponId().equals(ucouponId) && itemVo.getDuedAt().isAfter(now) && itemVo.getState().equals(1)) {
...@@ -444,44 +446,46 @@ public class GoblinCouponImpl implements GoblinCouponService { ...@@ -444,44 +446,46 @@ public class GoblinCouponImpl implements GoblinCouponService {
} }
} }
returnVo = mathCouponPrice(itemVo, contentPrice); returnVo = mathCouponPrice(itemVo, contentPrice);
returnVo.setSpuIds(spuIds); // returnVo.setSpuIds(spuIds);
} }
List<String> spuIdList = returnVo.getSpuIds(); // List<String> spuIdList = returnVo.getSpuIds();
BigDecimal voucherPrice = returnVo.getValue(); BigDecimal voucherPrice = returnVo.getValue();
if (spuIdList.size() > 0) { // if (spuIdList.size() > 0) {
for (String spuId : spuIdList) { // for (String spuId : spuIdList) {
for (CouponCanUse2Param paramItem : params.getParam()) { // for (CouponCanUse2Param paramItem : params.getParam()) {
if (paramItem.getSpuId().contains(spuId)) { // if (paramItem.getSpuId().contains(spuId)) {
if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) { // if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) {
voucherPrice = voucherPrice.subtract(paramItem.getPrice()); // voucherPrice = voucherPrice.subtract(paramItem.getPrice());
if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) { // if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) {
paramItem.setPrice(paramItem.getPrice()); // paramItem.setPrice(paramItem.getPrice());
} else { // } else {
paramItem.setPrice(voucherPrice.add(paramItem.getPrice())); // paramItem.setPrice(voucherPrice.add(paramItem.getPrice()));
} // }
} // }
} // }
} // }
} // }
} else { // } else {
for (CouponCanUse2Param paramItem : params.getParam()) { // for (CouponCanUse2Param paramItem : params.getParam()) {
if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) { // if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) {
voucherPrice = voucherPrice.subtract(paramItem.getPrice()); // voucherPrice = voucherPrice.subtract(paramItem.getPrice());
if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) { // if (voucherPrice.compareTo(BigDecimal.ZERO) >= 0) {
paramItem.setPrice(paramItem.getPrice()); // paramItem.setPrice(paramItem.getPrice());
} else { // } else {
paramItem.setPrice(voucherPrice.add(paramItem.getPrice())); // paramItem.setPrice(voucherPrice.add(paramItem.getPrice()));
} // }
} // }
} // }
} // }
vo.setParam(params.getParam()); // vo.setParam(params.getParam());
vo.setCouponVo(itemVo); // vo.setCouponVo(itemVo);
vo.setPrice(voucherPrice);
break; break;
} }
} }
} }
vo.setUcouponId(ucouponId); }vo.setUcouponId(ucouponId);
vo.setPlatformUcouponId(platformUcouponId);
return vo; return vo;
} }
......
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