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

Commit 13778009 authored by 胡佳晨's avatar 胡佳晨

提交 店铺券 指定商品逻辑

parent be04c7de
...@@ -6,6 +6,7 @@ import lombok.Data; ...@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
@Data @Data
@ApiModel @ApiModel
...@@ -16,6 +17,8 @@ public class GoblinUseResultVo implements Serializable, Cloneable { ...@@ -16,6 +17,8 @@ public class GoblinUseResultVo implements Serializable, Cloneable {
private BigDecimal value; private BigDecimal value;
@ApiModelProperty(value = "券类型[1-代金券|2-折扣券|3-满减券]", example = "1") @ApiModelProperty(value = "券类型[1-代金券|2-折扣券|3-满减券]", example = "1")
private String couType; private String couType;
@ApiModelProperty(value = "适用spu范围")
private List<String> spuIds;
private static final GoblinUseResultVo obj = new GoblinUseResultVo(); private static final GoblinUseResultVo obj = new GoblinUseResultVo();
......
...@@ -43,6 +43,9 @@ public class GoblinOrderPreParam implements Cloneable{ ...@@ -43,6 +43,9 @@ public class GoblinOrderPreParam implements Cloneable{
private GoblinStoreOrder storeOrder; private GoblinStoreOrder storeOrder;
private GoblinOrderAttr orderAttr; private GoblinOrderAttr orderAttr;
private List<GoblinOrderSku> orderSkuList; private List<GoblinOrderSku> orderSkuList;
private List<String> storeSpuIds;
private List<String> platformSpuIds;
private static final GoblinOrderPreParam obj = new GoblinOrderPreParam(); private static final GoblinOrderPreParam obj = new GoblinOrderPreParam();
......
...@@ -247,7 +247,7 @@ public class GoblinCouponImpl implements GoblinCouponService { ...@@ -247,7 +247,7 @@ public class GoblinCouponImpl implements GoblinCouponService {
returnList.add(vo); returnList.add(vo);
} else { } else {
List<String> spuIds = goblinRedisUtils.getStoreCouponSpuIds(vo.getStoreCouponId()); List<String> spuIds = goblinRedisUtils.getStoreCouponSpuIds(vo.getStoreCouponId());
if (spuIds == null) { if (spuIds == null || spuIds.size() == 0) {
break; break;
} }
//判断是否在可用商品内 //判断是否在可用商品内
......
...@@ -116,6 +116,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -116,6 +116,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
preParam.setStoreName(preParam.getStoreName() + "," + pre.getStoreName()); preParam.setStoreName(preParam.getStoreName() + "," + pre.getStoreName());
preParam.setSkuName(preParam.getSkuName() + "," + pre.getSkuName()); preParam.setSkuName(preParam.getSkuName() + "," + pre.getSkuName());
preParam.setOrderIdList(preParam.getOrderIdList() + "," + pre.getOrderIdList()); preParam.setOrderIdList(preParam.getOrderIdList() + "," + pre.getOrderIdList());
preParam.setPlatformSpuIds(pre.getPlatformSpuIds());
preParam.setStoreSpuIds(pre.getStoreSpuIds());
GoblinOrderSqlParam sqlParam = GoblinOrderSqlParam.getNew(); GoblinOrderSqlParam sqlParam = GoblinOrderSqlParam.getNew();
sqlParam.setStoreOrder(pre.getStoreOrder()); sqlParam.setStoreOrder(pre.getStoreOrder());
...@@ -203,6 +205,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -203,6 +205,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
BigDecimal storeTotalPrice = BigDecimal.ZERO;//订单总金额 BigDecimal storeTotalPrice = BigDecimal.ZERO;//订单总金额
String writeOffCode = ""; //取货码 String writeOffCode = ""; //取货码
List<GoblinOrderSku> goblinOrderSkuList = ObjectUtil.getGoblinOrderSkuArrayList(); List<GoblinOrderSku> goblinOrderSkuList = ObjectUtil.getGoblinOrderSkuArrayList();
List<String> storeSpuIds = CollectionUtil.linkedListString();
List<String> platformSpuIds = CollectionUtil.linkedListString();
String marketId = ""; String marketId = "";
String marketType = ""; String marketType = "";
for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) { for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) {
...@@ -302,7 +306,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -302,7 +306,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
spuIds = spuIds.concat(item.getSpuId() + ","); spuIds = spuIds.concat(item.getSpuId() + ",");
} }
} }
HashMap<String, Object> hashMap = orderUtils.useCoupon(platVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid,goblinOrderSkuList); HashMap<String, Object> hashMap = orderUtils.useCoupon(platVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid, goblinOrderSkuList);
if (hashMap != null) { if (hashMap != null) {
voucherPrice = (BigDecimal) hashMap.get("voucher"); voucherPrice = (BigDecimal) hashMap.get("voucher");
Integer typeVoucher = (Integer) hashMap.get("type"); Integer typeVoucher = (Integer) hashMap.get("type");
...@@ -310,6 +314,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -310,6 +314,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
throw new Exception("平台券不可用"); throw new Exception("平台券不可用");
} else { } else {
platformCodeList.add(platVoucherCode); platformCodeList.add(platVoucherCode);
platformSpuIds = (List<String>) hashMap.get("spuIds");
} }
} }
} }
...@@ -325,6 +330,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -325,6 +330,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
throw new Exception("店铺券不可用"); throw new Exception("店铺券不可用");
} else { } else {
storeCodeList.add(storeVoucherCode); storeCodeList.add(storeVoucherCode);
storeSpuIds = storeCouponVo.getSpuIds();
} }
} }
} }
...@@ -395,6 +401,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -395,6 +401,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
preParam.setStoreOrder(storeOrder); preParam.setStoreOrder(storeOrder);
preParam.setOrderAttr(orderAttr); preParam.setOrderAttr(orderAttr);
preParam.setOrderSkuList(goblinOrderSkuList); preParam.setOrderSkuList(goblinOrderSkuList);
preParam.setStoreSpuIds(storeSpuIds);
preParam.setPlatformSpuIds(platformSpuIds);
return preParam; return preParam;
} }
...@@ -454,16 +462,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -454,16 +462,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
payCode = payInnerResultVo.getCode(); payCode = payInnerResultVo.getCode();
payInnerResultVo.setShowUrl(preParam.getShowUrl()); payInnerResultVo.setShowUrl(preParam.getShowUrl());
payInnerResultVo.setReturnUrl(preParam.getReturnUrl()); payInnerResultVo.setReturnUrl(preParam.getReturnUrl());
// payInnerResultVo = GoblinPayInnerResultVo.getNew();
// payInnerResultVo.setCode("压测 code");
// payInnerResultVo.setOrderCode(preParam.getOrderMasterCode());
// payInnerResultVo.setPayData(null);
// payInnerResultVo.setPayType(preParam.getPayType());
// payInnerResultVo.setPrice(preParam.getPriceActual());
// payCode = payInnerResultVo.getCode();
// payInnerResultVo.setShowUrl(preParam.getShowUrl());
// payInnerResultVo.setReturnUrl(preParam.getReturnUrl());
} else if (preParam.getPayType() == null) { } else if (preParam.getPayType() == null) {
isFree = true; isFree = true;
preParam.setPayType("FREE"); preParam.setPayType("FREE");
...@@ -503,6 +501,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -503,6 +501,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
for (int i = 0; i < item.getOrderSkuList().size(); i++) { for (int i = 0; i < item.getOrderSkuList().size(); i++) {
GoblinOrderSku orderSku = item.getOrderSkuList().get(i); GoblinOrderSku orderSku = item.getOrderSkuList().get(i);
if (item.getStoreOrder().getPriceVoucher().compareTo(BigDecimal.ZERO) > 0) { if (item.getStoreOrder().getPriceVoucher().compareTo(BigDecimal.ZERO) > 0) {
if (preParam.getStoreSpuIds().size() > 0 || preParam.getPlatformSpuIds().size() > 0) {//指定范围商品券
if (preParam.getStoreSpuIds().contains(orderSku.getSpuId()) || preParam.getPlatformSpuIds().contains(orderSku.getSpuId())) {
restVoucherPrice = restVoucherPrice.subtract(orderSku.getSkuPrice()); restVoucherPrice = restVoucherPrice.subtract(orderSku.getSkuPrice());
if (restVoucherPrice.compareTo(BigDecimal.ZERO) > 0) { if (restVoucherPrice.compareTo(BigDecimal.ZERO) > 0) {
orderSku.setPriceVoucher(orderSku.getSkuPrice()); orderSku.setPriceVoucher(orderSku.getSkuPrice());
...@@ -513,7 +513,19 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -513,7 +513,19 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher()); BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO); orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
} }
}
} else {//全部商品券
restVoucherPrice = restVoucherPrice.subtract(orderSku.getSkuPrice());
if (restVoucherPrice.compareTo(BigDecimal.ZERO) > 0) {
orderSku.setPriceVoucher(orderSku.getSkuPrice());
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getSkuPrice());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
} else {
orderSku.setPriceVoucher(restVoucherPrice.add(orderSku.getSkuPrice()));
BigDecimal skuPriceActual = orderSku.getSkuPrice().subtract(orderSku.getPriceVoucher());
orderSku.setSkuPriceActual(skuPriceActual.compareTo(BigDecimal.ZERO) > 0 ? skuPriceActual : BigDecimal.ZERO);
}
}
} }
sqlDataSku.add(new Object[]{ sqlDataSku.add(new Object[]{
orderSku.getOrderSkuId(), orderSku.getOrderId(), orderSku.getSpuId(), orderSku.getSpuName(), orderSku.getSpuPic(), orderSku.getSkuId(), orderSku.getNum(), orderSku.getSkuPrice(), orderSku.getSkuPriceActual(), orderSku.getSkuName(), orderSku.getOrderSkuId(), orderSku.getOrderId(), orderSku.getSpuId(), orderSku.getSpuName(), orderSku.getSpuPic(), orderSku.getSkuId(), orderSku.getNum(), orderSku.getSkuPrice(), orderSku.getSkuPriceActual(), orderSku.getSkuName(),
......
...@@ -159,6 +159,7 @@ public class GoblinOrderUtils { ...@@ -159,6 +159,7 @@ public class GoblinOrderUtils {
voucher = BigDecimal.ZERO; voucher = BigDecimal.ZERO;
break; break;
} }
hashMap.put("spuIds", targetList);
hashMap.put("type", type); hashMap.put("type", type);
hashMap.put("voucher", voucher.setScale(2, BigDecimal.ROUND_HALF_UP)); hashMap.put("voucher", voucher.setScale(2, BigDecimal.ROUND_HALF_UP));
return hashMap; return hashMap;
...@@ -223,6 +224,7 @@ public class GoblinOrderUtils { ...@@ -223,6 +224,7 @@ public class GoblinOrderUtils {
returnVo.setValue(BigDecimal.ZERO); returnVo.setValue(BigDecimal.ZERO);
returnVo.setCouType("-1"); returnVo.setCouType("-1");
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
List<String> spuIds = CollectionUtil.linkedListString();
for (GoblinUserCouponVo vo : voList) { for (GoblinUserCouponVo vo : voList) {
if (vo.getUcouponId().equals(ucouponId) && vo.getDuedAt().isAfter(now)) { if (vo.getUcouponId().equals(ucouponId) && vo.getDuedAt().isAfter(now)) {
//判断券状态 和 触发金额 //判断券状态 和 触发金额
...@@ -249,8 +251,8 @@ public class GoblinOrderUtils { ...@@ -249,8 +251,8 @@ public class GoblinOrderUtils {
SqlMapping.get("goblin_user_coupon.updateState", vo.getState(), vo.getUsedFor(), LocalDateTime.now(), vo.getUcouponId())); SqlMapping.get("goblin_user_coupon.updateState", vo.getState(), vo.getUsedFor(), LocalDateTime.now(), vo.getUcouponId()));
break; break;
} else { } else {
List<String> spuIds = redisUtils.getStoreCouponSpuIds(vo.getStoreCouponId()); spuIds = redisUtils.getStoreCouponSpuIds(vo.getStoreCouponId());
if (spuIds == null) { if (spuIds == null || spuIds.size() == 0) {
break; break;
} }
//判断是否在可用商品内 //判断是否在可用商品内
...@@ -264,7 +266,11 @@ public class GoblinOrderUtils { ...@@ -264,7 +266,11 @@ public class GoblinOrderUtils {
} }
if (vo.getTriggers().compareTo(contentPrice) <= 0) { if (vo.getTriggers().compareTo(contentPrice) <= 0) {
if (vo.getType().equals("1")) {//代金券 if (vo.getType().equals("1")) {//代金券
if (vo.getValFace().compareTo(contentPrice) > 0) {
returnVo.setValue(contentPrice);
} else {
returnVo.setValue(vo.getValFace()); returnVo.setValue(vo.getValFace());
}
returnVo.setCouType(vo.getType()); returnVo.setCouType(vo.getType());
} else if (vo.getType().equals("2")) {//折扣 } else if (vo.getType().equals("2")) {//折扣
BigDecimal tempPrice = contentPrice.multiply(vo.getDiscount()).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal tempPrice = contentPrice.multiply(vo.getDiscount()).setScale(2, BigDecimal.ROUND_HALF_UP);
...@@ -273,8 +279,12 @@ public class GoblinOrderUtils { ...@@ -273,8 +279,12 @@ public class GoblinOrderUtils {
} }
returnVo.setValue(tempPrice); returnVo.setValue(tempPrice);
returnVo.setCouType(vo.getType()); returnVo.setCouType(vo.getType());
} else if (vo.getType().equals("3") && vo.getTriggers().compareTo(contentPrice) <= 0) {//满减 } else if (vo.getType().equals("3")) {//满减
if (vo.getValMinus().compareTo(contentPrice) > 0) {
returnVo.setValue(contentPrice);
} else {
returnVo.setValue(vo.getValMinus()); returnVo.setValue(vo.getValMinus());
}
returnVo.setCouType(vo.getType()); returnVo.setCouType(vo.getType());
} }
vo.setState(5); vo.setState(5);
...@@ -292,6 +302,7 @@ public class GoblinOrderUtils { ...@@ -292,6 +302,7 @@ public class GoblinOrderUtils {
if (!returnVo.getCouType().equals("-1")) { if (!returnVo.getCouType().equals("-1")) {
redisUtils.setUserCouponVos(uid, voList); redisUtils.setUserCouponVos(uid, voList);
} }
returnVo.setSpuIds(spuIds);
return returnVo; return returnVo;
} catch (Exception e) { } catch (Exception e) {
log.error("店铺券错误:{}", e); log.error("店铺券错误:{}", e);
......
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