|
|
|
@@ -610,7 +610,7 @@ public class WxOrderServiceImpl implements WxOrderService { |
|
|
|
|
|
|
|
long redisStock = redisLock.getCouponStock(Long.parseLong(couponIdStr)); |
|
|
|
if (redisStock<=0) { |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券库存已为零!"); |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券库存已为零!:"+couponIdStr); |
|
|
|
} |
|
|
|
// 检查 优惠券 库存 |
|
|
|
if (coupon.getRemainInventory() <= 0) { |
|
|
|
@@ -1067,13 +1067,6 @@ public class WxOrderServiceImpl implements WxOrderService { |
|
|
|
|
|
|
|
/// 储值卡信息添加 |
|
|
|
if (isCard) { |
|
|
|
//判断该transctionId是否已经存在,如果存在,则不添加 |
|
|
|
WxCardInfo cardInfoq = new WxCardInfo(); |
|
|
|
cardInfoq.setTransactionId(payOrder.getTransactionId()); |
|
|
|
List<WxCardInfo> cardInfoList = wxCardInfoMapper.findList(cardInfoq); |
|
|
|
if (null != cardInfoList && cardInfoList.size() > 0) { |
|
|
|
//do nothing |
|
|
|
}else { |
|
|
|
Integer fee = 0; |
|
|
|
WxCardInfo cardInfo = new WxCardInfo(); |
|
|
|
cardInfo.setId(couponOrder.getId()); |
|
|
|
@@ -1083,27 +1076,35 @@ public class WxOrderServiceImpl implements WxOrderService { |
|
|
|
cardInfo.setSaleAmount(coupon.getSalePrice()); |
|
|
|
cardInfo.setRemainingAmount(coupon.getPrice()); |
|
|
|
if (!coupon.checkIsFree()) { |
|
|
|
// 有价卡 |
|
|
|
cardInfo.setTransactionId(payOrder.getTransactionId()); |
|
|
|
if (payOrder.getShareAmount() != null) { |
|
|
|
// 开启分账 |
|
|
|
fee = payOrder.getPayAmount() - payOrder.getShareAmount(); |
|
|
|
cardInfo.setShareFeeAmount(payOrder.getShareAmount()); |
|
|
|
cardInfo.setRemainingShareFeeAmount(payOrder.getShareAmount()); |
|
|
|
cardInfo.setRateAmount(payOrder.getRateAmount()); |
|
|
|
} else { |
|
|
|
// 未开启分账 |
|
|
|
fee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRate(), false); |
|
|
|
Integer shareAmount = payOrder.getPayAmount() - fee; |
|
|
|
cardInfo.setShareFeeAmount(shareAmount); |
|
|
|
cardInfo.setRemainingShareFeeAmount(shareAmount); |
|
|
|
if (payAccount.getRealRate() != null) { |
|
|
|
int iRealChargeFee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRealRate(), true); |
|
|
|
if (fee > iRealChargeFee) { |
|
|
|
cardInfo.setRateAmount(fee - iRealChargeFee); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//判断该transctionId是否已经存在,如果存在,则不添加 |
|
|
|
WxCardInfo cardInfoq = new WxCardInfo(); |
|
|
|
cardInfoq.setTransactionId(payOrder.getTransactionId()); |
|
|
|
List<WxCardInfo> cardInfoList = wxCardInfoMapper.findList(cardInfoq); |
|
|
|
if (null != cardInfoList && cardInfoList.size() > 0) { |
|
|
|
//do nothing |
|
|
|
}else { |
|
|
|
// 有价卡 |
|
|
|
cardInfo.setTransactionId(payOrder.getTransactionId()); |
|
|
|
if (payOrder.getShareAmount() != null) { |
|
|
|
// 开启分账 |
|
|
|
fee = payOrder.getPayAmount() - payOrder.getShareAmount(); |
|
|
|
cardInfo.setShareFeeAmount(payOrder.getShareAmount()); |
|
|
|
cardInfo.setRemainingShareFeeAmount(payOrder.getShareAmount()); |
|
|
|
cardInfo.setRateAmount(payOrder.getRateAmount()); |
|
|
|
} else { |
|
|
|
// 未开启分账 |
|
|
|
fee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRate(), false); |
|
|
|
Integer shareAmount = payOrder.getPayAmount() - fee; |
|
|
|
cardInfo.setShareFeeAmount(shareAmount); |
|
|
|
cardInfo.setRemainingShareFeeAmount(shareAmount); |
|
|
|
if (payAccount.getRealRate() != null) { |
|
|
|
int iRealChargeFee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRealRate(), true); |
|
|
|
if (fee > iRealChargeFee) { |
|
|
|
cardInfo.setRateAmount(fee - iRealChargeFee); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 免费卡 |
|
|
|
cardInfo.setShareFeeAmount(0); |
|
|
|
@@ -1130,7 +1131,6 @@ public class WxOrderServiceImpl implements WxOrderService { |
|
|
|
} |
|
|
|
wxCardInfoMapper.insert(cardInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
return couponOrder; |
|
|
|
} |
|
|
|
|
|
|
|
|