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

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

平台券指定商品满减券折扣券逻辑

parent abdbab98
...@@ -17,6 +17,10 @@ public class CandyUseResultVo implements Serializable, Cloneable { ...@@ -17,6 +17,10 @@ public class CandyUseResultVo implements Serializable, Cloneable {
private BigDecimal value; private BigDecimal value;
@ApiModelProperty(value = "券类型[-1-不可用 | 1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]",example = "1") @ApiModelProperty(value = "券类型[-1-不可用 | 1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]",example = "1")
private Integer couType; private Integer couType;
@ApiModelProperty(value = "目标数组")
private List<String> targetIds;
@ApiModelProperty(value = "满减金额[满多少]")
private BigDecimal fullValue;
private static final CandyUseResultVo obj = new CandyUseResultVo(); private static final CandyUseResultVo obj = new CandyUseResultVo();
......
...@@ -323,6 +323,8 @@ public class CandyCouponServiceImpl implements ICandyCouponService { ...@@ -323,6 +323,8 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
userCreateTime = null; userCreateTime = null;
} }
CandyUseResultVo vo = CandyUseResultVo.getNew(); CandyUseResultVo vo = CandyUseResultVo.getNew();
List<String> targetIds = CollectionUtil.linkedListString();
BigDecimal fullValue = BigDecimal.ZERO;
List<CandyUserCouponBasicDto> dtoList = CouponBaseUtil.useCoupon(redisDataUtils.getCouponByUid(uid, userCreateTime), uCouponId, content); List<CandyUserCouponBasicDto> dtoList = CouponBaseUtil.useCoupon(redisDataUtils.getCouponByUid(uid, userCreateTime), uCouponId, content);
if (dtoList == null) { if (dtoList == null) {
vo.setCouType(-1); vo.setCouType(-1);
...@@ -342,6 +344,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService { ...@@ -342,6 +344,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
case 2: case 2:
if (dto.getValOver().compareTo(new BigDecimal(totalPrice)) <= 0) { if (dto.getValOver().compareTo(new BigDecimal(totalPrice)) <= 0) {
vo.setValue(dto.getValMinus()); vo.setValue(dto.getValMinus());
vo.setFullValue(dto.getValOver());
} else { } else {
vo.setCouType(-1); vo.setCouType(-1);
vo.setValue(BigDecimal.ZERO); vo.setValue(BigDecimal.ZERO);
...@@ -383,6 +386,10 @@ public class CandyCouponServiceImpl implements ICandyCouponService { ...@@ -383,6 +386,10 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
if (dto.getUseRules().size() > 1 && dto.getCouType().equals(4)) { if (dto.getUseRules().size() > 1 && dto.getCouType().equals(4)) {
isTarget = false; isTarget = false;
} }
if(isTarget){
targetIds.add(ruleItem.getBusiId());
}
} }
if (dto.getBusiType().equals(0)) { if (dto.getBusiType().equals(0)) {
...@@ -415,6 +422,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService { ...@@ -415,6 +422,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
} }
} }
} }
vo.setTargetIds(targetIds);
return vo; return vo;
} }
......
package com.liquidnet.service.dragon.config;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RedisStreamConfig {
// @Autowired
// private RedisPayNotifyReceiver redisPayNotifyReceiver;
// @Bean
// public Subscription subscriptionAlipayNotify0(RedisConnectionFactory factory) {
// var options = StreamMessageListenerContainer
// .StreamMessageListenerContainerOptions
// .builder()
// .pollTimeout(Duration.ofMillis(1))
// .build();
// var listenerContainer = StreamMessageListenerContainer.create(factory, options);
// var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.ChannelRedisQueueEnum.ALIPAY_PAY_GROUP.getCode(), "alipay-pay-notify-0"),
// StreamOffset.create(DragonConstant.ChannelRedisQueueEnum.ALIPAY_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayNotifyReceiver);
// listenerContainer.start();
// return subscription;
// }
//
// @Bean
// public Subscription subscriptionAlipayNotify1(RedisConnectionFactory factory) {
// var options = StreamMessageListenerContainer
// .StreamMessageListenerContainerOptions
// .builder()
// .pollTimeout(Duration.ofMillis(1))
// .build();
// var listenerContainer = StreamMessageListenerContainer.create(factory, options);
// var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.ChannelRedisQueueEnum.ALIPAY_PAY_GROUP.getCode(), "alipay-pay-notify-1"),
// StreamOffset.create(DragonConstant.ChannelRedisQueueEnum.ALIPAY_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayNotifyReceiver);
// listenerContainer.start();
// return subscription;
// }
//
// @Bean
// public Subscription subscriptionWepayNotify0(RedisConnectionFactory factory) {
// var options = StreamMessageListenerContainer
// .StreamMessageListenerContainerOptions
// .builder()
// .pollTimeout(Duration.ofMillis(1))
// .build();
// var listenerContainer = StreamMessageListenerContainer.create(factory, options);
// var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.ChannelRedisQueueEnum.WECHAT_PAY_GROUP.getCode(), "wepay-pay-notify-0"),
// StreamOffset.create(DragonConstant.ChannelRedisQueueEnum.WECHAT_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayNotifyReceiver);
// listenerContainer.start();
// return subscription;
// }
//
// @Bean
// public Subscription subscriptionWepayNotify1(RedisConnectionFactory factory) {
// var options = StreamMessageListenerContainer
// .StreamMessageListenerContainerOptions
// .builder()
// .pollTimeout(Duration.ofMillis(1))
// .build();
// var listenerContainer = StreamMessageListenerContainer.create(factory, options);
// var subscription = listenerContainer.receiveAutoAck(Consumer.from(DragonConstant.ChannelRedisQueueEnum.WECHAT_PAY_GROUP.getCode(), "wepay-pay-notify-1"),
// StreamOffset.create(DragonConstant.ChannelRedisQueueEnum.WECHAT_PAY_KEY.getCode(), ReadOffset.lastConsumed()), redisPayNotifyReceiver);
// listenerContainer.start();
// return subscription;
// }
}
...@@ -302,7 +302,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -302,7 +302,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); 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");
......
...@@ -16,6 +16,7 @@ import com.liquidnet.service.goblin.dto.vo.*; ...@@ -16,6 +16,7 @@ import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinBackOrder; import com.liquidnet.service.goblin.entity.GoblinBackOrder;
import com.liquidnet.service.goblin.entity.GoblinBackOrderLog; import com.liquidnet.service.goblin.entity.GoblinBackOrderLog;
import com.liquidnet.service.goblin.entity.GoblinOrderOperationLog; import com.liquidnet.service.goblin.entity.GoblinOrderOperationLog;
import com.liquidnet.service.goblin.entity.GoblinOrderSku;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -88,7 +89,7 @@ public class GoblinOrderUtils { ...@@ -88,7 +89,7 @@ public class GoblinOrderUtils {
* @param totalPrice 订单总价 * @param totalPrice 订单总价
* @return * @return
*/ */
public HashMap<String, Object> useCoupon(String uCouponId, String content, BigDecimal totalPrice, String spuId, String uid) { public HashMap<String, Object> useCoupon(String uCouponId, String content, BigDecimal totalPrice, String spuId, String uid, List<GoblinOrderSku> goblinOrderSkuList) {
HashMap<String, Object> hashMap = CollectionUtil.mapStringObject(); HashMap<String, Object> hashMap = CollectionUtil.mapStringObject();
try { try {
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString(); MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
...@@ -109,8 +110,11 @@ public class GoblinOrderUtils { ...@@ -109,8 +110,11 @@ public class GoblinOrderUtils {
}); });
CandyUseResultVo candyUseResultVo = innerReturnVo.getData(); CandyUseResultVo candyUseResultVo = innerReturnVo.getData();
Integer type = candyUseResultVo.getCouType(); Integer type = candyUseResultVo.getCouType();
List<String> targetList = candyUseResultVo.getTargetIds();
BigDecimal fullValue = candyUseResultVo.getFullValue();
BigDecimal value = candyUseResultVo.getValue(); BigDecimal value = candyUseResultVo.getValue();
BigDecimal voucher = BigDecimal.ZERO; BigDecimal voucher = BigDecimal.ZERO;
BigDecimal targetPrice = BigDecimal.ZERO;
switch (type) { switch (type) {
case -1: case -1:
voucher = BigDecimal.valueOf(-1); voucher = BigDecimal.valueOf(-1);
...@@ -118,14 +122,35 @@ public class GoblinOrderUtils { ...@@ -118,14 +122,35 @@ public class GoblinOrderUtils {
case 1: case 1:
voucher = voucher.add(value); voucher = voucher.add(value);
break; break;
case 2: case 2://满减
voucher = voucher.add(value); for (String targetId : targetList) {
for (GoblinOrderSku skuOrderVo : goblinOrderSkuList) {
if (targetId.equals(skuOrderVo.getSpuId())) {
targetPrice = targetPrice.add(skuOrderVo.getSkuPriceActual());
}
}
}
if (fullValue.compareTo(targetPrice) >= 0) {
voucher = voucher.add(value);
} else {
backCoupon(uCouponId, uid);
hashMap.put("type", -1);
hashMap.put("voucher", 0);
return hashMap;
}
break; break;
case 3: case 3:
voucher = voucher.add(totalPrice); voucher = voucher.add(totalPrice);
break; break;
case 4: case 4://折扣
voucher = totalPrice.subtract(totalPrice.multiply(value)); for (String targetId : targetList) {
for (GoblinOrderSku skuOrderVo : goblinOrderSkuList) {
if (targetId.equals(skuOrderVo.getSpuId())) {
targetPrice = targetPrice.add(skuOrderVo.getSkuPriceActual());
}
}
}
voucher = totalPrice.subtract(targetPrice.multiply(value));
break; break;
default: default:
voucher = BigDecimal.ZERO; voucher = BigDecimal.ZERO;
......
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