mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 创建提现请求 提取方法
This commit is contained in:
@@ -4,8 +4,6 @@ import com.alibaba.fastjson2.JSONObject;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
import com.huifu.adapay.model.CorpMember;
|
|
||||||
import com.huifu.adapay.model.Member;
|
|
||||||
import com.huifu.adapay.model.PaymentReverse;
|
import com.huifu.adapay.model.PaymentReverse;
|
||||||
import com.huifu.adapay.model.Refund;
|
import com.huifu.adapay.model.Refund;
|
||||||
import com.jsowell.JsowellApplication;
|
import com.jsowell.JsowellApplication;
|
||||||
@@ -31,7 +29,6 @@ import com.jsowell.pile.domain.AdapayMemberAccount;
|
|||||||
import com.jsowell.pile.domain.OrderUnsplitRecord;
|
import com.jsowell.pile.domain.OrderUnsplitRecord;
|
||||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||||
import com.jsowell.pile.service.OrderUnsplitRecordService;
|
import com.jsowell.pile.service.OrderUnsplitRecordService;
|
||||||
import com.jsowell.pile.service.PileMerchantInfoService;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -47,7 +44,10 @@ import java.io.BufferedReader;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +62,7 @@ public class PaymentTestController {
|
|||||||
|
|
||||||
String wechatAppId2 = "wx20abc5210391649c"; // 嘉佳充电
|
String wechatAppId2 = "wx20abc5210391649c"; // 嘉佳充电
|
||||||
|
|
||||||
String adapayAppId = "app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa";
|
String adapayAppId = "app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa"; // 固定参数, 汇付配置的万车充小程序appId
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
@@ -76,8 +76,86 @@ public class PaymentTestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderBasicInfoService orderBasicInfoService;
|
private OrderBasicInfoService orderBasicInfoService;
|
||||||
|
|
||||||
@Autowired
|
/**
|
||||||
private PileMerchantInfoService pileMerchantInfoService;
|
* 查询分账信息
|
||||||
|
* @throws BaseAdaPayException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void queryCreateConfirmReverse() throws BaseAdaPayException {
|
||||||
|
List<String> paymentIdList = getPaymentIdList(); // 查询分账信息
|
||||||
|
|
||||||
|
List<String> unSplitList = Lists.newArrayList(); // 未分帐
|
||||||
|
List<String> splitList = Lists.newArrayList(); // 已分帐
|
||||||
|
|
||||||
|
BigDecimal total = BigDecimal.ZERO; // 总分账金额
|
||||||
|
BigDecimal totalWithdrawalAmt = BigDecimal.ZERO; // 实际到账金额汇总
|
||||||
|
BigDecimal totalFeeAmt = BigDecimal.ZERO; // 手续费金额汇总
|
||||||
|
|
||||||
|
List<String> selfList = Lists.newArrayList();
|
||||||
|
|
||||||
|
Map<String, BigDecimal> map = Maps.newHashMap();
|
||||||
|
for (String paymentId : paymentIdList) {
|
||||||
|
if (StringUtils.isBlank(paymentId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 查询支付确认id
|
||||||
|
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
||||||
|
dto.setPaymentId(paymentId);
|
||||||
|
dto.setWechatAppId(wechatAppId1);
|
||||||
|
// 查询分账信息
|
||||||
|
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
||||||
|
if (response != null) {
|
||||||
|
List<PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
||||||
|
if (CollectionUtils.isEmpty(confirms)) {
|
||||||
|
unSplitList.add(paymentId);
|
||||||
|
} else {
|
||||||
|
splitList.add(paymentId);
|
||||||
|
for (PaymentConfirmInfo confirm : confirms) {
|
||||||
|
if (adapayService.queryConfirmReverseStatus(confirm)) {
|
||||||
|
System.out.println("支付确认id:" + confirm.getId() + "撤销了。。。");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
||||||
|
String adapayMemberId = jsonObject.getString("adapayMemberId");
|
||||||
|
if (StringUtils.isBlank(adapayMemberId)) {
|
||||||
|
adapayMemberId = jsonObject.getString("adapayMemberIds");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal confirmAmt = new BigDecimal(confirm.getConfirmAmt()); // 本次确认金额
|
||||||
|
BigDecimal confirmedAmt = new BigDecimal(confirm.getConfirmedAmt()); // 已确认金额
|
||||||
|
BigDecimal feeAmt = new BigDecimal(confirm.getFeeAmt()); // 手续费
|
||||||
|
|
||||||
|
// 汇总已确认金额
|
||||||
|
total = total.add(confirmedAmt);
|
||||||
|
|
||||||
|
// 汇总手续费金额
|
||||||
|
totalFeeAmt = totalFeeAmt.add(feeAmt);
|
||||||
|
|
||||||
|
// 汇总可提现金额
|
||||||
|
totalWithdrawalAmt = totalWithdrawalAmt.add(confirmAmt).subtract(feeAmt);
|
||||||
|
|
||||||
|
// confirm
|
||||||
|
List<DivMember> divMembers = confirm.getDivMembers();
|
||||||
|
System.out.println("confirm:" + JSON.toJSONString(divMembers));
|
||||||
|
for (DivMember divMember : divMembers) {
|
||||||
|
// 放map
|
||||||
|
map.merge(divMember.getMemberId(), new BigDecimal(divMember.getAmount()), BigDecimal::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.equals(adapayMemberId, "0")) {
|
||||||
|
selfList.add(paymentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unSplitList.add(paymentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("=================未分账:" + JSON.toJSONString(unSplitList) + ", 数量:" + unSplitList.size());
|
||||||
|
System.out.println("=================已分账:" + JSON.toJSONString(map) + ", 总分账:" + total + ", 数量:" + splitList.size());
|
||||||
|
System.out.println("===============金额明细:" + "总到账金额:" + totalWithdrawalAmt + ", 总手续费:" + totalFeeAmt);
|
||||||
|
System.out.println("===================自己:" + JSON.toJSONString(selfList) + ", 数量:" + selfList.size());
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getPaymentIdList() {
|
public List<String> getPaymentIdList() {
|
||||||
List<String> resultList = Lists.newArrayList();
|
List<String> resultList = Lists.newArrayList();
|
||||||
@@ -131,6 +209,26 @@ public class PaymentTestController {
|
|||||||
return paramMap;
|
return paramMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提现方法
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void withdraw() {
|
||||||
|
String merchantId = "349";
|
||||||
|
String orderNo = "drawcash_" + merchantId + "_" + System.currentTimeMillis();
|
||||||
|
BigDecimal cashAmt = new BigDecimal("560.17");
|
||||||
|
String adapayMemberId = "ACM88073310";
|
||||||
|
// String adapayAppId = "app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa"; // 固定参数, 汇付配置的万车充小程序appId
|
||||||
|
String settleAccountId = "0744607938214272";
|
||||||
|
String wechatAppId = wechatAppId1;
|
||||||
|
try {
|
||||||
|
adapayService.createDrawcashRequest(orderNo, cashAmt, adapayMemberId, adapayAppId, settleAccountId, wechatAppId);
|
||||||
|
} catch (BaseAdaPayException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
List<String> orderCodeList = Lists.newArrayList();
|
List<String> orderCodeList = Lists.newArrayList();
|
||||||
orderCodeList.add("C44107428110");
|
orderCodeList.add("C44107428110");
|
||||||
@@ -362,90 +460,9 @@ public class PaymentTestController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询分账信息
|
|
||||||
* @throws BaseAdaPayException
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void queryCreateConfirmReverse() throws BaseAdaPayException {
|
|
||||||
List<String> paymentIdList = getPaymentIdList(); // 查询分账信息
|
|
||||||
|
|
||||||
List<String> unSplitList = Lists.newArrayList(); // 未分帐
|
|
||||||
List<String> splitList = Lists.newArrayList(); // 已分帐
|
|
||||||
|
|
||||||
BigDecimal total = BigDecimal.ZERO; // 总分账金额
|
|
||||||
BigDecimal totalWithdrawalAmt = BigDecimal.ZERO; // 实际到账金额汇总
|
|
||||||
BigDecimal totalFeeAmt = BigDecimal.ZERO; // 手续费金额汇总
|
|
||||||
|
|
||||||
List<String> selfList = Lists.newArrayList();
|
|
||||||
|
|
||||||
Map<String, BigDecimal> map = Maps.newHashMap();
|
|
||||||
for (String paymentId : paymentIdList) {
|
|
||||||
if (StringUtils.isBlank(paymentId)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 查询支付确认id
|
|
||||||
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
|
||||||
dto.setPaymentId(paymentId);
|
|
||||||
dto.setWechatAppId(wechatAppId1);
|
|
||||||
// 查询分账信息
|
|
||||||
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
|
||||||
if (response != null) {
|
|
||||||
List<PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
|
||||||
if (CollectionUtils.isEmpty(confirms)) {
|
|
||||||
unSplitList.add(paymentId);
|
|
||||||
} else {
|
|
||||||
splitList.add(paymentId);
|
|
||||||
for (PaymentConfirmInfo confirm : confirms) {
|
|
||||||
if (adapayService.queryConfirmReverseStatus(confirm)) {
|
|
||||||
System.out.println("支付确认id:" + confirm.getId() + "撤销了。。。");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
|
||||||
String adapayMemberId = jsonObject.getString("adapayMemberId");
|
|
||||||
if (StringUtils.isBlank(adapayMemberId)) {
|
|
||||||
adapayMemberId = jsonObject.getString("adapayMemberIds");
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal confirmAmt = new BigDecimal(confirm.getConfirmAmt()); // 本次确认金额
|
|
||||||
BigDecimal confirmedAmt = new BigDecimal(confirm.getConfirmedAmt()); // 已确认金额
|
|
||||||
BigDecimal feeAmt = new BigDecimal(confirm.getFeeAmt()); // 手续费
|
|
||||||
|
|
||||||
// 汇总已确认金额
|
|
||||||
total = total.add(confirmedAmt);
|
|
||||||
|
|
||||||
// 汇总手续费金额
|
|
||||||
totalFeeAmt = totalFeeAmt.add(feeAmt);
|
|
||||||
|
|
||||||
// 汇总可提现金额
|
|
||||||
totalWithdrawalAmt = totalWithdrawalAmt.add(confirmAmt).subtract(feeAmt);
|
|
||||||
|
|
||||||
// confirm
|
|
||||||
List<DivMember> divMembers = confirm.getDivMembers();
|
|
||||||
System.out.println("confirm:" + JSON.toJSONString(divMembers));
|
|
||||||
for (DivMember divMember : divMembers) {
|
|
||||||
// 放map
|
|
||||||
map.merge(divMember.getMemberId(), new BigDecimal(divMember.getAmount()), BigDecimal::add);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.equals(adapayMemberId, "0")) {
|
|
||||||
selfList.add(paymentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unSplitList.add(paymentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("=================未分账:" + JSON.toJSONString(unSplitList) + ", 数量:" + unSplitList.size());
|
|
||||||
System.out.println("=================已分账:" + JSON.toJSONString(map) + ", 总分账:" + total + ", 数量:" + splitList.size());
|
|
||||||
System.out.println("===============金额明细:" + "总到账金额:" + totalWithdrawalAmt + ", 总手续费:" + totalFeeAmt);
|
|
||||||
System.out.println("===================自己:" + JSON.toJSONString(selfList) + ", 数量:" + selfList.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量支付确认撤销
|
* 批量支付确认撤销
|
||||||
|
*
|
||||||
* @throws BaseAdaPayException
|
* @throws BaseAdaPayException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -830,17 +830,17 @@ public class AdapayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 发送提现申请
|
// 发送提现申请
|
||||||
Map<String, Object> settleCountParams = Maps.newHashMap();
|
// Map<String, Object> settleCountParams = Maps.newHashMap();
|
||||||
String orderNo = "drawcash_" + dto.getMerchantId() + "_" + System.currentTimeMillis();
|
String orderNo = "drawcash_" + dto.getMerchantId() + "_" + System.currentTimeMillis();
|
||||||
settleCountParams.put("order_no", orderNo);
|
// settleCountParams.put("order_no", orderNo);
|
||||||
settleCountParams.put("cash_amt", AdapayUtil.formatAmount(cashAmt));
|
// settleCountParams.put("cash_amt", AdapayUtil.formatAmount(cashAmt));
|
||||||
settleCountParams.put("member_id", adapayAccountBalanceVO.getAdapayMemberId());
|
// settleCountParams.put("member_id", adapayAccountBalanceVO.getAdapayMemberId());
|
||||||
settleCountParams.put("app_id", config.getAdapayAppId());
|
// settleCountParams.put("app_id", config.getAdapayAppId());
|
||||||
settleCountParams.put("settle_account_id", adapayAccountBalanceVO.getSettleAccountId());
|
// settleCountParams.put("settle_account_id", adapayAccountBalanceVO.getSettleAccountId());
|
||||||
settleCountParams.put("cash_type", "T1");
|
// settleCountParams.put("cash_type", "T1");
|
||||||
settleCountParams.put("notify_url", ADAPAY_CALLBACK_URL);
|
// settleCountParams.put("notify_url", ADAPAY_CALLBACK_URL);
|
||||||
Map<String, Object> settleCount = Drawcash.create(settleCountParams, config.getWechatAppId());
|
Map<String, Object> settleCount = createDrawcashRequest(orderNo, cashAmt, adapayAccountBalanceVO.getAdapayMemberId(), config.getAdapayAppId(), adapayAccountBalanceVO.getSettleAccountId(), config.getWechatAppId());
|
||||||
log.info("申请取现接口,请求参数:{}, 返回参数:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount));
|
// log.info("申请取现接口,请求参数:{}, 返回参数:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount));
|
||||||
|
|
||||||
if (settleCount == null) {
|
if (settleCount == null) {
|
||||||
throw new BusinessException("", "申请取现接口发生异常");
|
throw new BusinessException("", "申请取现接口发生异常");
|
||||||
@@ -878,6 +878,24 @@ public class AdapayService {
|
|||||||
clearingBillInfoService.updateStatus(clearingBillIds, billStatus, id);
|
clearingBillInfoService.updateStatus(clearingBillIds, billStatus, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建提现请求
|
||||||
|
*/
|
||||||
|
public Map<String, Object> createDrawcashRequest(String orderNo, BigDecimal cashAmt, String adapayMemberId, String adapayAppId, String settleAccountId, String wechatAppId) throws BaseAdaPayException {
|
||||||
|
Map<String, Object> settleCountParams = Maps.newHashMap();
|
||||||
|
settleCountParams.put("order_no", orderNo);
|
||||||
|
settleCountParams.put("cash_amt", AdapayUtil.formatAmount(cashAmt));
|
||||||
|
settleCountParams.put("member_id", adapayMemberId);
|
||||||
|
settleCountParams.put("app_id", adapayAppId);
|
||||||
|
settleCountParams.put("settle_account_id", settleAccountId);
|
||||||
|
settleCountParams.put("cash_type", "T1");
|
||||||
|
settleCountParams.put("notify_url", ADAPAY_CALLBACK_URL);
|
||||||
|
Map<String, Object> settleCount = Drawcash.create(settleCountParams, wechatAppId);
|
||||||
|
log.info("申请取现接口,请求参数:{}, 返回参数:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount));
|
||||||
|
return settleCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询取现对象
|
* 查询取现对象
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user