Commit 078d2d28 by 王世昌

Merge branch 'bugfix-小料三方商品id修复-wsc' into qa

parents 3496e5a8 a69ed155
......@@ -13,6 +13,9 @@
package cn.freemud.enums;
import java.util.Arrays;
import java.util.List;
/**
* 应该是下面这个type对应
* @see com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType
......@@ -39,6 +42,18 @@ public enum OrderAccountType {
private String desc;
/**
* 需要 核销的 券 归类
* 代金券
* 商品券
* 运费全
* 折扣券
*/
public static List<Integer> verificationCoupon = Arrays.asList(OrderAccountType.COUPON.getCode(),
OrderAccountType.PRODUCT_COUPON.getCode(),
OrderAccountType.FREIGHT_COUPON.getCode(),
OrderAccountType.DISCOUNT_COUPON.getCode());
OrderAccountType(Integer code, String desc) {
this.code = code;
this.desc = desc;
......
......@@ -70,6 +70,7 @@ public enum ResponseResult {
STORE_WILL_COLSE("43020", "门店即将打烊,不能下单",""),
STORE_DDELIVERY_METHOD("43021", "获取门店外卖配送方式异常",""),
STORE_QUERYEXPECTARRIVETIME("43022", "获取门店计算预计送达时间失败",""),
STORE_DATE_ERROR("43023", "门店数据错误",""),
/**
* 购物车状态码
......
......@@ -40,10 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service("platformCouponRelationService")
......@@ -64,7 +61,7 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
private static final String ORDER_RESOURCE_PUSH_LOG_ROUTING_KEY = "order-resource-push-log-routing-key";
@Value("${baffleOpen.verification.coupon:false}")
private Boolean baffleOpen=false;
private Boolean baffleOpen = false;
@Override
public BaseResponse verificationCoupon(List<QueryOrdersResponseDto.DataBean.OrderBean.AccountBean> accountList, QueryOrdersResponseDto.DataBean.OrderBean orderBean, CouponReqType couponReqType) {
......@@ -72,7 +69,9 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
if (CollectionUtils.isEmpty(accountList)) {
return ResponseUtil.success();
}
if (accountList.size() > 1) {
// 需要判断 accountList 里面 是都 同时包含 配送券+ other券
boolean isDoubleCoupon = checkAccountList(accountList);
if (isDoubleCoupon) {
Integer code = OrderAccountType.FREIGHT_COUPON.getCode();
// 运费券 塞进 核销接口里面, 这里真的是贼恶心 逻辑不敢动
QueryOrdersResponseDto.DataBean.OrderBean.AccountBean freightCouponAccountBean = accountList.stream().filter(accountBean -> code.equals(accountBean.getType())).findFirst().orElse(null);
......@@ -91,6 +90,28 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
}
/**
* 要校验一遍是否 使用了 需要核销的券 代金券 商品券 运费全 折扣券 需要核销
*
* @param accountList 这里会传递 多张券 和其他的计算 类型
* @return
*/
private boolean checkAccountList(List<QueryOrdersResponseDto.DataBean.OrderBean.AccountBean> accountList) {
// 里面只有一个值 直接使用老逻辑 不管是 什么券
if (accountList.size() == 1) {
return false;
}
// 拿出 所有的使用券信息 代金券 商品券 运费全 折扣券 需要核销
int count = 0;
for (QueryOrdersResponseDto.DataBean.OrderBean.AccountBean accountBean : accountList) {
if (OrderAccountType.verificationCoupon.contains(accountBean.getType())){
count ++;
}
}
// 说明使用了 2张以上的优惠券 需要核销
return count > 1;
}
/**
* 原有逻辑没变动的基础上 加上 配送券信息对象
*
* @param couponCodeVerificationTransDto 配送券信息对象 如果为null 就是原来的逻辑
......@@ -180,12 +201,12 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
lastException = ex;
ErrorLog.printErrorLog("verification_error", "/api", couponCodeVerificationDto, ex);
}
if (lastException != null){
if (lastException != null) {
sendMessage(orderBean, LogThreadLocal.getTrackingNo(), couponCodeVerificationDto, lastException);
}else if (!ok || Objects.equals(baffleOpen,true)){
} else if (!ok || Objects.equals(baffleOpen, true)) {
sendMessage(orderBean, LogThreadLocal.getTrackingNo(), couponCodeVerificationDto, ok ? "模拟券核销失败" : couponCodeResponseDto);
}
if (!ok){
if (!ok) {
emailAlertService.sendEmailAlert("核销券码失败", String.format("request:%s \r\nresponse:%s", JSONObject.toJSONString(couponCodeVerificationDto), JSONObject.toJSONString(lastException == null ? couponCodeResponseDto : lastException)));
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
}
......
......@@ -205,6 +205,10 @@ public class CheckOrder {
if (storeResponseDto.getActiveFlag() == null || storeResponseDto.getActiveFlag() != 1) {
throw new ServiceException(ResponseResult.STORE_ITEM_STOP_BUSINESS);
}
//特殊情况
if ("".equals(storeResponseDto.getBusinessType())) {
throw new ServiceException(ResponseResult.STORE_DATE_ERROR);
}
createOrderVo.setStoreName(storeResponseDto.getStoreName());
createOrderVo.setStoreAddress(storeResponseDto.getAddress());
createOrderVo.setThirdShopId(storeResponseDto.getThirdPartCode());
......
......@@ -109,11 +109,12 @@ public class CalculationCommonService {
// 需要算上配送券的优惠金额
Integer discountAmount = 0;
if (CollectionUtils.isNotEmpty(discountResult.getDiscounts())) {
// 过滤出配送券金额
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount discount = discountResult.getDiscounts().stream().filter(c -> c.getType() != null && c.getType().compareTo(ActivityTypeEnum.TYPE_34.getCode()) == 0).findFirst().orElse(null);
if (discount != null) {
discountAmount = discount.getDiscount();
}
// 过滤出配送券金额 和 满减配送费活动金额
double sum = discountResult.getDiscounts().stream()
.filter(c -> c.getType() != null && (c.getType().compareTo(ActivityTypeEnum.TYPE_34.getCode()) == 0 || c.getType().compareTo(ActivityTypeEnum.TYPE_14.getCode()) == 0))
.mapToDouble(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount::getDiscount)
.sum();
discountAmount = Double.valueOf(sum).intValue();
}
shoppingCartGoodsResponseVo.setTotalDiscountAmount(discountResult.getTotalDiscountAmount() + discountAmount);
}
......@@ -466,7 +467,7 @@ public class CalculationCommonService {
goods.setSpuForeignName(mg.getSpuForeignName());
goods.setSalePrice(mg.getFinalPrice());
goods.setQty(mg.getQty());
goods.setCustomerCode(cartGoods.getCustomerCode());
goods.setCustomerCode(mg.getCustomerCode());
goods.setOriginalPrice(mg.getOriginalPrice());
//提前当前行促销
BlockRow blockRow = smallRow.get(goods.getSpuId());
......
......@@ -85,7 +85,8 @@ public class CouponSharingService {
// 当couponCode不为空时,需计算优惠价格 3代金 31折扣 32商品 33换购券
long couponDiscount = 0;
if (couponPromotionVO != null && StringUtils.isNotEmpty(couponPromotionVO.getCouponCode())
if (couponPromotionVO != null && (StringUtils.isNotEmpty(couponPromotionVO.getCouponCode()) || CollectionUtils.isNotEmpty(couponPromotionVO.getCouponCodes()))
&& calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())) {
//List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.CouponResults> couponResultsList = calculationDiscountResult.getCouponDiscounts();
// 需要加上 配送券的 配送券 type = 34
......
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