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

Commit 9dc07321 authored by 胡佳晨's avatar 胡佳晨

修复 拒绝退款 用户订单详情报错

用券逻辑修改
parent f2e25ed3
......@@ -112,6 +112,7 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService {
return ResponseDto.failure(ErrorMapping.get("20003"));
}
GoblinAppOrderDetailsVo vo = GoblinAppOrderDetailsVo.getNew();
vo.setStoreOrderVo(orderVo);
List<GoblinOrderSkuVo> skuVos = ObjectUtil.getGoblinOrderSkuVoArrayList();
for (String orderSkuId : orderVo.getOrderSkuVoIds()) {
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(orderSkuId);
......
......@@ -316,16 +316,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
//商铺券
BigDecimal storeVoucherPrice = BigDecimal.ZERO;
if (storeVoucherCode != null && !storeVoucherCode.equals("")) {
String spuIds = "";
for (GoblinOrderSkuParam item : storeParam.getGoblinOrderSkuParamArrayList()) {
String pre = GoblinStatusConst.MarketPreStatus.getPre(item.getSpuId());
if (pre != null) {
spuIds = spuIds.concat(item.getSpuId().split(pre)[0] + ",");
} else {
spuIds = spuIds.concat(item.getSpuId() + ",");
}
}
GoblinUseResultVo storeCouponVo = orderUtils.useStoreCoupon(storeVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid);
GoblinUseResultVo storeCouponVo = orderUtils.useStoreCoupon(storeVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, goblinOrderSkuList, uid);
String typeVoucher;
if (storeCouponVo != null) {
storeVoucherPrice = storeCouponVo.getValue();
......
......@@ -16,6 +16,8 @@ import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinBackOrder;
import com.liquidnet.service.goblin.entity.GoblinBackOrderLog;
import com.liquidnet.service.goblin.entity.GoblinOrderOperationLog;
import com.liquidnet.service.goblin.entity.GoblinOrderSku;
import com.liquidnet.service.goblin.param.CouponCanUse2Param;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -188,7 +190,7 @@ public class GoblinOrderUtils {
}
}
public GoblinUseResultVo useStoreCoupon(String ucouponId, String content, BigDecimal totalPrice, String spuId, String uid) {
public GoblinUseResultVo useStoreCoupon(String ucouponId, String content, BigDecimal totalPrice, List<GoblinOrderSku> goblinOrderSkuList, String uid) {
try {
List<GoblinUserCouponVo> voList = redisUtils.getUserCouponVos(uid);
GoblinUseResultVo returnVo = GoblinUseResultVo.getNew();
......@@ -222,35 +224,40 @@ public class GoblinOrderUtils {
break;
} else {
List<String> spuIds = redisUtils.getStoreCouponSpuIds(vo.getStoreCouponId());
if (spuId == null) {
continue;
if (spuIds == null) {
break;
}
//判断是否在可用商品内
List<String> spuList = Arrays.asList(spuId.split(","));
BigDecimal contentPrice = BigDecimal.ZERO;
for (String item : spuIds) {
if (spuList.contains(item)) {
if (vo.getType().equals("1")) {//代金券
returnVo.setValue(vo.getValFace());
returnVo.setCouType(vo.getType());
} else if (vo.getType().equals("2")) {//折扣
BigDecimal tempPrice = totalPrice.multiply(vo.getDiscount()).setScale(2, BigDecimal.ROUND_HALF_UP);
if (tempPrice.compareTo(vo.getDeduction()) > 0) {
tempPrice = vo.getDeduction();
}
returnVo.setValue(tempPrice);
returnVo.setCouType(vo.getType());
} else if (vo.getType().equals("3") && vo.getTriggers().compareTo(totalPrice) <= 0) {//满减
returnVo.setValue(vo.getValMinus());
returnVo.setCouType(vo.getType());
for (GoblinOrderSku param : goblinOrderSkuList) {
if (param.getSpuId().equals(item)) {
contentPrice = contentPrice.add(param.getSkuPriceActual());
}
vo.setState(5);
vo.setUsedFor(content);
goblinMongoUtils.changeCouponVos(vo.getUcouponId(), vo);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_COUPON.getKey(),
SqlMapping.get("goblin_user_coupon.updateState", vo.getState(), vo.getUsedFor(), LocalDateTime.now(), vo.getUcouponId()));
}
break;
}
if (vo.getTriggers().compareTo(contentPrice) <= 0) {
if (vo.getType().equals("1")) {//代金券
returnVo.setValue(vo.getValFace());
returnVo.setCouType(vo.getType());
} else if (vo.getType().equals("2")) {//折扣
BigDecimal tempPrice = totalPrice.multiply(vo.getDiscount()).setScale(2, BigDecimal.ROUND_HALF_UP);
if (tempPrice.compareTo(vo.getDeduction()) > 0) {
tempPrice = vo.getDeduction();
}
returnVo.setValue(tempPrice);
returnVo.setCouType(vo.getType());
} else if (vo.getType().equals("3") && vo.getTriggers().compareTo(totalPrice) <= 0) {//满减
returnVo.setValue(vo.getValMinus());
returnVo.setCouType(vo.getType());
}
vo.setState(5);
vo.setUsedFor(content);
goblinMongoUtils.changeCouponVos(vo.getUcouponId(), vo);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_COUPON.getKey(),
SqlMapping.get("goblin_user_coupon.updateState", vo.getState(), vo.getUsedFor(), LocalDateTime.now(), vo.getUcouponId()));
}
}
}
break;
......
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