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

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

goblin 帮助前端用店铺券

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