|
|
|
@@ -546,6 +546,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); |
|
|
|
} |
|
|
|
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); |
|
|
|
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); |
|
|
|
EnumPayShare paySHareEnum = EnumPayShare.getEnum(payAccount.getShare()); |
|
|
|
if (paySHareEnum != null) { |
|
|
|
isShare = paySHareEnum; |
|
|
|
@@ -579,20 +580,29 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
record.setShare(isShare.getCode()); |
|
|
|
record.setComposeOrder(EnumComposeOrder.SINGLE.getCode()); |
|
|
|
|
|
|
|
if (isShare == EnumPayShare.YES) { |
|
|
|
// 分账金额 |
|
|
|
int iChargeFee = OrderHelper.getMallCharge(record.getPayAmount(), payAccount); |
|
|
|
Integer share_amount = record.getPayAmount() - iChargeFee; |
|
|
|
record.setShareAmount(share_amount); |
|
|
|
if(payAccount.getRealRate() != null) { |
|
|
|
int iRealChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRealRate(), true); |
|
|
|
record.setRateAmount(iRealChargeFee); |
|
|
|
} |
|
|
|
if (share_amount <= 0) { |
|
|
|
isShare = EnumPayShare.NO; |
|
|
|
record.setShare(isShare.getCode()); |
|
|
|
Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); |
|
|
|
Long merchant_id = null; |
|
|
|
String merchant_uid = ""; |
|
|
|
if(EnumPayMchType.DIRECT.equals(record.getMchType())){//直连模式记录收款商户 |
|
|
|
merchant_id = user.getMerchantId(); |
|
|
|
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType()); |
|
|
|
// merchant_uid = wxCouponChannelService.getCouponOneMerchantUid(payWay,merchant_id,o.getTenantId()); |
|
|
|
// if(null == merchant_id || StringUtils.isBlank(merchant_uid)){ |
|
|
|
if(receiver == null){ |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); |
|
|
|
} |
|
|
|
merchant_uid = receiver.getReceiverAccount(); |
|
|
|
} |
|
|
|
int rate = payShareServie.getOfficialCommission(order,payAccount);//抖音分佣率 |
|
|
|
logger.info("抖音分佣率"+rate); |
|
|
|
PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(order.getPayment(),rate, payAccount); |
|
|
|
logger.info("佣金明细"+ JSON.toJSONString(oShareAmount)); |
|
|
|
int share_amount = oShareAmount.getShareAmount(); |
|
|
|
int rate_amount = oShareAmount.getRateAmount(); |
|
|
|
childShares.put(String.valueOf(order.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_id,merchant_uid,order.getId())); |
|
|
|
record.setShareAmount(share_amount); |
|
|
|
record.setRateAmount(rate_amount); |
|
|
|
record.setChildOrderShare(JSON.toJSONString(childShares)); |
|
|
|
|
|
|
|
int sqlRow = wxPayOrderMapper.insert(record); |
|
|
|
if (sqlRow != 1) { |
|
|
|
@@ -601,19 +611,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
} else { |
|
|
|
record = list.get(0); |
|
|
|
if (null == record.getShare()) { |
|
|
|
if (isShare == EnumPayShare.YES) { |
|
|
|
int iChargeFee = OrderHelper.getMallCharge(record.getPayAmount(), payAccount); |
|
|
|
Integer share_amount = record.getPayAmount() - iChargeFee; |
|
|
|
if (share_amount <= 0) { |
|
|
|
isShare = EnumPayShare.NO; |
|
|
|
} |
|
|
|
} |
|
|
|
record.setShare(isShare.getCode()); |
|
|
|
}else { |
|
|
|
isShare = EnumPayShare.getEnum(record.getShare()); |
|
|
|
} |
|
|
|
payOrderNo = String.valueOf(record.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
logger.debug("wxPayRecord md5 before:"+record.toString()); |
|
|
|
|