mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
订单分账逻辑
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.jsowell.adapay.operation;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 汇付相关操作需要的信息
|
||||
* Operation
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AdapayOperationInfo {
|
||||
/**
|
||||
* 分账用户 Member对象 的 id;若是商户本身时,传入0
|
||||
*/
|
||||
private String adapayMemberId;
|
||||
|
||||
// 商户唯一标识,通常使用微信小程序appId
|
||||
private String merchantKey;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.jsowell.adapay.operation;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付确认操作对象
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PaymentConfirmOperation extends AdapayOperationInfo{
|
||||
private String paymentId;
|
||||
|
||||
private BigDecimal confirmAmt;
|
||||
|
||||
private String orderCode;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.jsowell.adapay.common.DivMember;
|
||||
import com.jsowell.adapay.config.AbstractAdapayConfig;
|
||||
import com.jsowell.adapay.dto.*;
|
||||
import com.jsowell.adapay.factory.AdapayConfigFactory;
|
||||
import com.jsowell.adapay.operation.PaymentConfirmOperation;
|
||||
import com.jsowell.adapay.response.*;
|
||||
import com.jsowell.adapay.vo.*;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
@@ -785,13 +786,51 @@ public class AdapayService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建交易确认请求/创建分账请求
|
||||
* 这个方法只适用于给一个用户分账
|
||||
*/
|
||||
public PaymentConfirmResponse createPaymentConfirmRequest(PaymentConfirmOperation operation) {
|
||||
// 调汇付的分账接口 确认交易
|
||||
Map<String, Object> confirmParams = Maps.newHashMap();
|
||||
// Adapay生成的支付对象id
|
||||
confirmParams.put("payment_id", operation.getPaymentId());
|
||||
// 请求订单号,只能为英文、数字或者下划线的一种或多种组合,保证在app_id下唯一
|
||||
confirmParams.put("order_no", "PC" + System.currentTimeMillis());
|
||||
// 确认金额,必须大于0,保留两位小数点,如0.10、100.05等。必须小于等于原支付金额-已确认金额-已撤销金额。
|
||||
String amount = AdapayUtil.formatAmount(operation.getConfirmAmt());
|
||||
confirmParams.put("confirm_amt", amount);
|
||||
|
||||
// 附加说明
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderCode", operation.getOrderCode());
|
||||
jsonObject.put("adapayMemberId", operation.getAdapayMemberId());
|
||||
confirmParams.put("description", jsonObject.toJSONString());
|
||||
|
||||
// 分账对象信息 一次最多7个
|
||||
DivMember divMember = new DivMember();
|
||||
divMember.setMember_id(operation.getAdapayMemberId());
|
||||
divMember.setAmount(amount);
|
||||
divMember.setFee_flag(Constants.Y);
|
||||
confirmParams.put("div_members", Lists.newArrayList(divMember));
|
||||
|
||||
Map<String, Object> paymentConfirm = null;
|
||||
try {
|
||||
paymentConfirm = PaymentConfirm.create(confirmParams, operation.getMerchantKey());
|
||||
} catch (BaseAdaPayException e) {
|
||||
log.error("创建交易确认请求error", e);
|
||||
}
|
||||
String jsonString = JSON.toJSONString(paymentConfirm);
|
||||
log.info("调分账接口param:{}, result:{}", JSON.toJSONString(confirmParams), jsonString);
|
||||
return JSONObject.parseObject(jsonString, PaymentConfirmResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建交易确认请求/创建分账请求
|
||||
* 这个方法只适用于给一个用户分账
|
||||
*
|
||||
* @param paymentId 支付对象id
|
||||
* @param adapayMemberAccount 收到该张的汇付会员信息
|
||||
* @param adapayMemberAccount 收到该账的汇付会员信息
|
||||
* @param confirmAmt 确认的金额
|
||||
* @param orderCode 订单编号
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user