Commit 54482871 by 缪晖

拼单混合支付提交

parent 383c6979
...@@ -127,6 +127,21 @@ public class ShoppingCartCollageResponseVo extends ShoppingCartGoodsBaseResponse ...@@ -127,6 +127,21 @@ public class ShoppingCartCollageResponseVo extends ShoppingCartGoodsBaseResponse
private Integer deliveryFeeZeroReason; private Integer deliveryFeeZeroReason;
/** /**
* 代金券
*/
private String couponCode;
/**
* 运费券
*/
private String freightCouponCode;
/**
* svc卡支付金额
*/
private String svcPayAmount;
/**
* 购物车版本号 * 购物车版本号
*/ */
private Integer carVer; private Integer carVer;
......
...@@ -17,6 +17,7 @@ import cn.freemud.interceptor.ServiceException; ...@@ -17,6 +17,7 @@ import cn.freemud.interceptor.ServiceException;
import cn.freemud.redis.RedisCache; import cn.freemud.redis.RedisCache;
import cn.freemud.service.*; import cn.freemud.service.*;
import cn.freemud.service.thirdparty.ActivityClient; import cn.freemud.service.thirdparty.ActivityClient;
import cn.freemud.service.thirdparty.SvcComPayClient;
import cn.freemud.utils.PropertyConvertUtil; import cn.freemud.utils.PropertyConvertUtil;
import cn.freemud.utils.RedisLock; import cn.freemud.utils.RedisLock;
import cn.freemud.utils.ResponseUtil; import cn.freemud.utils.ResponseUtil;
...@@ -103,6 +104,9 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp ...@@ -103,6 +104,9 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
@Autowired @Autowired
private PaymentNewService paymentNewService; private PaymentNewService paymentNewService;
@Autowired
private SvcComPayClient svcComPayClient;
@Override @Override
public BaseResponse addGoodsByCard(AddGoodsByWeixinCardRequestVo request) { public BaseResponse addGoodsByCard(AddGoodsByWeixinCardRequestVo request) {
...@@ -1261,20 +1265,73 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp ...@@ -1261,20 +1265,73 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
if (response.getData() == null || response.getData().getData() == null || response.getData().getData().getCardSimpleInfos().size() > 1) { if (response.getData() == null || response.getData().getData() == null || response.getData().getData().getCardSimpleInfos().size() > 1) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR); throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR);
} }
//获取实际配送费 boolean check = this.checkSvcComPay(partnerId, storeId);
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) { if (check) {
// Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId); //混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付
Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue(); Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
orderAmount += deliveryAmount; Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount();
} Integer svcTotalAmount = amount1+vamount;
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount(); //获取实际配送费
Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount(); Integer deliveryAmount = 0;
if (orderAmount > amount1 + vamount) { Integer svcPayAmount = 0;
throw new ServiceException(ResponseResult.USER_SVC_CARD_AMOUNT_DEFICIENCY); if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
} //Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
BigDecimal bigDecimal = new BigDecimal(orderAmount); deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString(); orderAmount += deliveryAmount;
shoppingCartGoodsResponseVo.setTotalAmount(0L); }
shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr); if (svcTotalAmount>0 && svcTotalAmount>orderAmount) {
svcPayAmount = orderAmount;
shoppingCartGoodsResponseVo.setTotalAmount(0L);
}
else if (svcTotalAmount>0 && svcTotalAmount<=orderAmount) {
svcPayAmount = svcTotalAmount;
shoppingCartGoodsResponseVo.setTotalAmount((orderAmount.longValue()-svcPayAmount.longValue()));
}
BigDecimal bigDecimal = new BigDecimal(svcPayAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setSvcPayAmount(amountStr);
shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
}
else {
//获取实际配送费
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getData().getData().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("储值卡支付¥" + amountStr);
}
}
/**
* 获取混合支付是否开启
* @param partnerId
* @return
*/
private boolean checkSvcComPay(String partnerId,String storeId) {
SvcComPayRequestDto requestDto = new SvcComPayRequestDto();
requestDto.setPartnerId(partnerId);
requestDto.setStoreId(storeId);
SvcComPayResponseDto query = null;
for (int i=0;i<3;i++) {
query = svcComPayClient.query(requestDto);
if (query!=null) break;
}
if (query==null || !ResponseResult.SUCCESS.getCode().equals(query.getCode())) {
return false;
}
if (query.getResult()!=null && query.getResult().getValue()) {
return true;
}
else {
return false;
}
} }
} }
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