devrelease_toaliyun_real
| @@ -51,5 +51,7 @@ public class WxPayAccount extends BaseEntity { | |||||
| return notifyUrl + "/subsidyPay"; | return notifyUrl + "/subsidyPay"; | ||||
| } | } | ||||
| public boolean checkShare() { return share > 0; } | |||||
| } | } | ||||
| @@ -239,16 +239,18 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| } | } | ||||
| // 9. 分账 | |||||
| try { | |||||
| shareForCardPay(record.getTenantId(), record.getCardId(), record.getOrderId(), record.getId()); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| if(ErrorCode.PROFIT_SHARING_NUM_UP_LIMIT.getCode() == e.getErrorCode()) { | |||||
| // 分账已到20次限制,后面只记录,无法分账 | |||||
| logger.error("分账已到20次限制,后面只记录,无法分账"); | |||||
| } else { | |||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||||
| if (payAccount.checkShare()) { | |||||
| // 9. 分账 | |||||
| try { | |||||
| shareForCardPay(record.getTenantId(), record.getCardId(), record.getOrderId(), record.getId()); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| if (ErrorCode.PROFIT_SHARING_NUM_UP_LIMIT.getCode() == e.getErrorCode()) { | |||||
| // 分账已到20次限制,后面只记录,无法分账 | |||||
| logger.error("分账已到20次限制,后面只记录,无法分账"); | |||||
| } else { | |||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -705,6 +705,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| cardInfo.setRemainingAmount(coupon.getPrice()); | cardInfo.setRemainingAmount(coupon.getPrice()); | ||||
| if (!coupon.checkIsFree()) { | if (!coupon.checkIsFree()) { | ||||
| // 有价卡 | |||||
| try { | try { | ||||
| WxPayOrder payOrderQ = new WxPayOrder(); | WxPayOrder payOrderQ = new WxPayOrder(); | ||||
| payOrderQ.setTenantId(user.getTenantId()); | payOrderQ.setTenantId(user.getTenantId()); | ||||
| @@ -714,16 +715,36 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("payOrder not found:" + e.getMessage()); | logger.error("payOrder not found:" + e.getMessage()); | ||||
| } | } | ||||
| cardInfo.setTransactionId(payOrder.getTransactionId()); | |||||
| if (payOrder.getShareAmount() != null) { | if (payOrder.getShareAmount() != null) { | ||||
| // 开启分账 | |||||
| fee = payOrder.getPayAmount() - payOrder.getShareAmount(); | fee = payOrder.getPayAmount() - payOrder.getShareAmount(); | ||||
| cardInfo.setShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRemainingShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRateAmount(payOrder.getRateAmount()); | |||||
| } else { | } else { | ||||
| fee = payOrder.getPayAmount(); | |||||
| // 未开启分账 | |||||
| WxPayAccount payAccount = null; | |||||
| WxPayAccount payAccountQ = new WxPayAccount(); | |||||
| payAccountQ.setTenantId(cardInfo.getTenantId()); | |||||
| try { | |||||
| payAccount = wxPayAccountMapper.selectOne(payAccountQ); | |||||
| 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); | |||||
| } | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("获取payAccount error: " + cardInfo.getTenantId()); | |||||
| } | |||||
| } | } | ||||
| cardInfo.setTransactionId(payOrder.getTransactionId()); | |||||
| cardInfo.setShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRemainingShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRateAmount(payOrder.getRateAmount()); | |||||
| } else { | } else { | ||||
| // 免费卡 | |||||
| cardInfo.setShareFeeAmount(0); | cardInfo.setShareFeeAmount(0); | ||||
| cardInfo.setRemainingShareFeeAmount(0); | cardInfo.setRemainingShareFeeAmount(0); | ||||
| cardInfo.setRateAmount(0); | cardInfo.setRateAmount(0); | ||||
| @@ -168,7 +168,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | ||||
| } | } | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | ||||
| if (payAccount.getShare().intValue() > 0) { | |||||
| if (payAccount.checkShare()) { | |||||
| isShare = EnumPayShare.YES; | isShare = EnumPayShare.YES; | ||||
| } | } | ||||
| @@ -226,8 +226,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| record.setPayVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | record.setPayVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | ||||
| record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | ||||
| record.setShare(isShare.getCode()); | record.setShare(isShare.getCode()); | ||||
| record.setShareAmount(0); // 不分账时,默认设为0 | |||||
| record.setRateAmount(0); // 不分账时,默认设为0 | |||||
| if (isShare == EnumPayShare.YES) { | if (isShare == EnumPayShare.YES) { | ||||
| // 分账金额 | // 分账金额 | ||||
| int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate(), false); | int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate(), false); | ||||
| @@ -432,7 +430,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | ||||
| } | } | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | ||||
| if (payAccount.getShare().intValue() > 0) { | |||||
| if (payAccount.checkShare()) { | |||||
| isShare = EnumPayShare.YES; | isShare = EnumPayShare.YES; | ||||
| } | } | ||||
| @@ -91,7 +91,7 @@ public class WxSubsidyServiceImpl implements WxSubsidyService { | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(user.getTenantId()); | WxAppinfo appInfo = wxAppinfoService.getCAppInfo(user.getTenantId()); | ||||
| // 2. 获取payAccount | // 2. 获取payAccount | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | ||||
| if (payAccount.getShare().intValue() > 0) { | |||||
| if (payAccount.checkShare()) { | |||||
| isShare = EnumPayShare.YES; | isShare = EnumPayShare.YES; | ||||
| } | } | ||||
| // 3. 补贴订单 | // 3. 补贴订单 | ||||