mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
update 优化分账逻辑
This commit is contained in:
@@ -816,7 +816,7 @@ public class AdapayService {
|
||||
* @param confirmAmt 确认的金额
|
||||
* @param orderCode 订单编号
|
||||
*/
|
||||
public PaymentConfirmResponse createPaymentConfirmRequest(String paymentId, AdapayMemberAccount adapayMemberAccount, BigDecimal confirmAmt, String orderCode) {
|
||||
public PaymentConfirmResponse createPaymentConfirmRequest(String paymentId, AdapayMemberAccount adapayMemberAccount, BigDecimal confirmAmt, String orderCode, String wechatAppId) {
|
||||
// 调汇付的分账接口 确认交易
|
||||
Map<String, Object> confirmParams = Maps.newHashMap();
|
||||
// Adapay生成的支付对象id
|
||||
@@ -838,7 +838,7 @@ public class AdapayService {
|
||||
confirmParams.put("div_members", Lists.newArrayList(divMember));
|
||||
Map<String, Object> paymentConfirm = null;
|
||||
try {
|
||||
paymentConfirm = PaymentConfirm.create(confirmParams);
|
||||
paymentConfirm = PaymentConfirm.create(confirmParams, wechatAppId);
|
||||
} catch (BaseAdaPayException e) {
|
||||
log.error("创建交易确认请求error", e);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import com.huifu.adapay.model.PaymentConfirm;
|
||||
import com.jsowell.adapay.common.DivMember;
|
||||
import com.jsowell.adapay.response.PaymentConfirmResponse;
|
||||
import com.jsowell.adapay.response.PaymentReverseResponse;
|
||||
import com.jsowell.adapay.service.AdapayService;
|
||||
@@ -26,7 +24,10 @@ import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.*;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.bean.BeanUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.common.util.id.SnowflakeIdWorker;
|
||||
@@ -1019,7 +1020,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
OrderSettleResult orderSettleResult;
|
||||
if (OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) {
|
||||
// 余额支付的订单
|
||||
orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount);
|
||||
orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount, appId);
|
||||
} else {
|
||||
// 在线支付,进行支付确认分账
|
||||
orderSettleResult = doPaymentConfirm(orderBasicInfo, adapayMemberAccount, appId);
|
||||
@@ -1149,7 +1150,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
* @param adapayMemberAccount
|
||||
* @return
|
||||
*/
|
||||
public OrderSettleResult doBalancePayment(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount) throws BaseAdaPayException {
|
||||
public OrderSettleResult doBalancePayment(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
|
||||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||
String orderCode = orderBasicInfo.getOrderCode();
|
||||
|
||||
@@ -1164,7 +1165,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
String paymentId = vo.getPaymentId();
|
||||
BigDecimal deductionAmount = vo.getDeductionAmount();
|
||||
// 调汇付的分账接口 确认交易
|
||||
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, deductionAmount, orderCode);
|
||||
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, deductionAmount, orderCode, wechatAppId);
|
||||
if (paymentConfirmResponse != null) {
|
||||
confirmAmt = confirmAmt.add(new BigDecimal(paymentConfirmResponse.getConfirmed_amt()));
|
||||
feeAmt = feeAmt.add(new BigDecimal(paymentConfirmResponse.getFee_amt()));
|
||||
@@ -1245,39 +1246,21 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
@Override
|
||||
public OrderSettleResult doPaymentConfirm(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
|
||||
// 查询订单的交易id
|
||||
AdapayCallbackRecord adapayCallbackRecord = adapayCallbackRecordService.selectByOrderCode(orderBasicInfo.getOrderCode());
|
||||
String orderCode = orderBasicInfo.getOrderCode();
|
||||
AdapayCallbackRecord adapayCallbackRecord = adapayCallbackRecordService.selectByOrderCode(orderCode);
|
||||
if (adapayCallbackRecord == null) {
|
||||
logger.error("根据订单号:{}, 未查询到汇付支付回调信息", orderBasicInfo.getOrderCode());
|
||||
logger.error("根据订单号:{}, 未查询到汇付支付回调信息", orderCode);
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CALLBACK_IS_NULL_ERROR);
|
||||
}
|
||||
String paymentId = adapayCallbackRecord.getPaymentId();
|
||||
|
||||
// 金额
|
||||
String settleAmount = AdapayUtil.formatAmount(orderBasicInfo.getSettleAmount());
|
||||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||
|
||||
// 调汇付的分账接口 确认交易
|
||||
Map<String, Object> confirmParams = Maps.newHashMap();
|
||||
// Adapay生成的支付对象id
|
||||
confirmParams.put("payment_id", adapayCallbackRecord.getPaymentId());
|
||||
// 请求订单号,只能为英文、数字或者下划线的一种或多种组合,保证在app_id下唯一
|
||||
confirmParams.put("order_no", "PC" + System.currentTimeMillis());
|
||||
// 确认金额,必须大于0,保留两位小数点,如0.10、100.05等。必须小于等于原支付金额-已确认金额-已撤销金额。
|
||||
confirmParams.put("confirm_amt", settleAmount);
|
||||
// 附加说明
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderCode", orderBasicInfo.getOrderCode());
|
||||
jsonObject.put("adapayMemberId", adapayMemberAccount.getAdapayMemberId());
|
||||
confirmParams.put("description", jsonObject.toJSONString());
|
||||
// 分账对象信息
|
||||
DivMember divMember = new DivMember();
|
||||
divMember.setMember_id(adapayMemberAccount.getAdapayMemberId());
|
||||
divMember.setAmount(settleAmount);
|
||||
divMember.setFee_flag(Constants.Y);
|
||||
confirmParams.put("div_members", Lists.newArrayList(divMember));
|
||||
Map<String, Object> paymentConfirm = PaymentConfirm.create(confirmParams, wechatAppId);
|
||||
logger.info("调分账接口param:{}, result:{}", JSON.toJSONString(confirmParams), JSON.toJSONString(paymentConfirm));
|
||||
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, settleAmount, orderCode, wechatAppId);
|
||||
|
||||
// 分账接口返回的信息
|
||||
PaymentConfirmResponse paymentConfirmResponse = JSONObject.parseObject(JSON.toJSONString(paymentConfirm), PaymentConfirmResponse.class);
|
||||
OrderSettleResult result = new OrderSettleResult();
|
||||
result.setConfirm_amt(paymentConfirmResponse.getConfirm_amt());
|
||||
result.setStatus(paymentConfirmResponse.getStatus());
|
||||
|
||||
Reference in New Issue
Block a user