Commit 29df11f9 by 胡敬轩

多储值卡支付 listCartGoodsCheck接口改造

parent cc28149a
......@@ -1012,11 +1012,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/
@Override
public BaseResponse getGoodsListCheck(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (StringUtils.isBlank(shoppingCartInfoRequestVo.getCardCode())) {
List<String> cardCodes = new ArrayList<>();
if(CollectionUtils.isNotEmpty(shoppingCartInfoRequestVo.getCardCodes())){
cardCodes.addAll(shoppingCartInfoRequestVo.getCardCodes());
}else if(StringUtils.isNotBlank(shoppingCartInfoRequestVo.getCardCode())){
cardCodes.add(shoppingCartInfoRequestVo.getCardCode());
}
if (CollectionUtils.isEmpty(cardCodes)) {
return ResponseUtil.error(ResponseResult.PARAMETER_MISSING);
}
//打包带走外卖
if (StringUtils.isNotBlank(shoppingCartInfoRequestVo.getCardCode()) && Objects.equals(shoppingCartInfoRequestVo.getOrderType(), 2)
if (CollectionUtils.isNotEmpty(cardCodes) && Objects.equals(shoppingCartInfoRequestVo.getOrderType(), 2)
&& StringUtils.isBlank(shoppingCartInfoRequestVo.getReceiveId())) {
return ResponseUtil.error(ResponseResult.PARAMETER_MISSING);
}
......@@ -1034,7 +1040,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
BaseListCartGoodsVO result = goodsList.getResult();
//SVC卡支付
SVCCardPay(shoppingCartInfoRequestVo.getCardCode(), shoppingCartInfoRequestVo.getReceiveId(), partnerId, storeId, result);
SVCCardPay(cardCodes, shoppingCartInfoRequestVo.getReceiveId(), partnerId, storeId, result);
return ResponseUtil.success(goodsList.getResult());
} else {
......@@ -1045,7 +1051,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = goodsList.getResult();
//SVC卡支付
SVCCardPay(shoppingCartInfoRequestVo.getCardCode(), shoppingCartInfoRequestVo.getReceiveId(), partnerId, storeId, shoppingCartGoodsResponseVo);
SVCCardPay(cardCodes, shoppingCartInfoRequestVo.getReceiveId(), partnerId, storeId, shoppingCartGoodsResponseVo);
return ResponseUtil.success(goodsList.getResult());
}
......@@ -2512,16 +2518,16 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
* 储值卡支付余额校验
* 校验订单商品金额与外卖配送费
*/
private void SVCCardPay(String cardCode, String receiveId, String partnerId, String storeId,
private void SVCCardPay(List<String> cardCodes, String receiveId, String partnerId, String storeId,
BaseListCartGoodsVO shoppingCartGoodsResponseVo) {
if (StringUtils.isBlank(cardCode)) {
if (CollectionUtils.isEmpty(cardCodes)) {
return;
}
Integer orderAmount = shoppingCartGoodsResponseVo.getTotalAmount().intValue();
String trackingNo = LogThreadLocal.getTrackingNo();
SVCCardAmountRequest request = new SVCCardAmountRequest();
request.setPartnerId(partnerId);
request.setCardCodes(Arrays.asList(cardCode));
request.setCardCodes(cardCodes);
//查询svc卡金额
BaseResponse<SVCCardAmountResponse> response = svcAppClient.batchQueryCardAmount(request);
if (response == null) {
......@@ -2530,15 +2536,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (response.getResult() == null || CollectionUtils.isEmpty(response.getResult().getCardSimpleInfos())) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR);
}
boolean check = this.checkSvcComPay(partnerId, storeId);
Integer applyType = response.getResult().getCardSimpleInfos().get(0).getApplyType();
applyType = applyType == null ? 3 : applyType;
String svcDesc = applyType == 3 ? "储值卡支付¥" : "礼品卡支付¥";
if (check) {
//混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付
Integer amount1 = response.getResult().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getResult().getCardSimpleInfos().get(0).getVamount();
Integer svcTotalAmount = amount1 + vamount;
int totalAmount = response.getResult().getCardSimpleInfos().stream().mapToInt(CardSimpleInfo::getAmount).sum();
int totalVamount = response.getResult().getCardSimpleInfos().stream().mapToInt(CardSimpleInfo::getVamount).sum();
Integer svcTotalAmount = totalAmount + totalVamount;
//获取实际配送费
Integer deliveryAmount = 0;
Integer svcPayAmount = 0;
......@@ -2558,39 +2561,22 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setSvcPayAmount(amountStr);
shoppingCartGoodsResponseVo.setSvcDiscountDesc(svcDesc + amountStr);
} else {
//获取实际配送费
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
Integer amount1 = response.getResult().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getResult().getCardSimpleInfos().get(0).getVamount();
if (orderAmount > amount1 + vamount) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_AMOUNT_DEFICIENCY);
}
BigDecimal bigDecimal = new BigDecimal(orderAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setTotalAmount(0L);
shoppingCartGoodsResponseVo.setSvcDiscountDesc(svcDesc + amountStr);
}
}
/**
* 储值卡支付余额校验
* 校验订单商品金额与外卖配送费
*/
private void SVCCardPay(String cardCode, String receiveId, String partnerId, String storeId,
private void SVCCardPay(List<String> cardCodes, String receiveId, String partnerId, String storeId,
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
if (StringUtils.isBlank(cardCode)) {
if (CollectionUtils.isEmpty(cardCodes)) {
return;
}
Integer orderAmount = shoppingCartGoodsResponseVo.getTotalAmount().intValue();
String trackingNo = LogThreadLocal.getTrackingNo();
SVCCardAmountRequest request = new SVCCardAmountRequest();
request.setPartnerId(partnerId);
request.setCardCodes(Arrays.asList(cardCode));
request.setCardCodes(cardCodes);
//查询svc卡金额
BaseResponse<SVCCardAmountResponse> response = svcAppClient.batchQueryCardAmount(request);
if (response == null) {
......@@ -2599,15 +2585,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (response.getResult() == null || CollectionUtils.isEmpty(response.getResult().getCardSimpleInfos())) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR);
}
boolean check = this.checkSvcComPay(partnerId, storeId);
Integer applyType = response.getResult().getCardSimpleInfos().get(0).getApplyType();
applyType = applyType == null ? 3 : applyType;
String svcDesc = applyType == 3 ? "储值卡支付¥" : "礼品卡支付¥";
if (check) {
//混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付
Integer amount1 = response.getResult().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getResult().getCardSimpleInfos().get(0).getVamount();
Integer svcTotalAmount = amount1 + vamount;
int totalAmount = response.getResult().getCardSimpleInfos().stream().mapToInt(CardSimpleInfo::getAmount).sum();
int totalVamount = response.getResult().getCardSimpleInfos().stream().mapToInt(CardSimpleInfo::getVamount).sum();
Integer svcTotalAmount = totalAmount + totalVamount;
//获取实际配送费
Integer deliveryAmount = 0;
Integer svcPayAmount = 0;
......@@ -2626,25 +2610,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setSvcPayAmount(amountStr);
shoppingCartGoodsResponseVo.setSvcDiscountDesc(svcDesc + amountStr);
} else {
//获取实际配送费
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
Integer amount1 = response.getResult().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getResult().getCardSimpleInfos().get(0).getVamount();
if (orderAmount > amount1 + vamount) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_AMOUNT_DEFICIENCY);
}
BigDecimal bigDecimal = new BigDecimal(orderAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setTotalAmount(0L);
shoppingCartGoodsResponseVo.setSvcDiscountDesc(svcDesc + amountStr);
}
}
/**
* 储值卡支付查询配送费
*
......
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