This commit is contained in:
2023-09-26 15:41:05 +08:00
parent c41d8e00d0
commit 530e1d11d7
7 changed files with 132 additions and 221 deletions

View File

@@ -1021,7 +1021,7 @@ public class OrderService {
.payMode(OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())
.payAmount(amount)
.acquirer(AcquirerEnum.ADAPAY.getValue())
.deductionRecord(JSON.toJSONString(Lists.newArrayList(paymentInfo)))
.deductionRecord(JSON.toJSONString(paymentInfo))
.createBy(null)
.delFlag(DelFlagEnum.NORMAL.getValue())
.build();

View File

@@ -10,6 +10,7 @@ import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
import com.jsowell.adapay.response.QueryPaymentConfirmDetailResponse;
import com.jsowell.adapay.service.AdapayService;
import com.jsowell.adapay.vo.OrderSettleResult;
import com.jsowell.adapay.vo.PaymentInfo;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.ykc.*;
import com.jsowell.common.exception.BusinessException;
@@ -367,6 +368,13 @@ public class TempService {
}
}
/**
* 查询余额订单 分账信息
* @param orderCode
* @param memberId
* @param wechatAppId
* @return
*/
private BigDecimal queryBalanceOrderSettleInfo(String orderCode, String memberId, String wechatAppId) {
BigDecimal resultAmt = BigDecimal.ZERO;
// 查询会员余额支付记录
@@ -394,6 +402,11 @@ public class TempService {
return resultAmt;
}
/**
* 查询未分账订单
* @param dto
* @return
*/
public Map<String, Object> queryUndividedOrder(SettleOrderReportDTO dto) {
Map<String, Object> resultMap = Maps.newHashMap();
@@ -451,7 +464,13 @@ public class TempService {
}
public void doBalancePaymentTemp(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String appId) {
/**
* 余额支付分账
* @param orderBasicInfo
* @param adapayMemberAccount
* @param wechatAppId
*/
public void doBalancePaymentTemp(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount, String wechatAppId) throws BaseAdaPayException {
String orderCode = orderBasicInfo.getOrderCode();
// 查询订单支付记录
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
@@ -461,15 +480,38 @@ public class TempService {
OrderPayRecord record = orderPayRecordList.get(0);
String deductionRecord = record.getDeductionRecord();
AbstractOrderLogic orderLogic = new DelayMerchantOrderLogic();
List<JSONObject> jsonObjects = orderLogic.parseDeductionRecord(deductionRecord);
List<PaymentInfo> paymentInfos = orderLogic.parseDeductionRecord(deductionRecord);
// 通过paymentId查询 分账记录
for (PaymentInfo paymentInfo : paymentInfos) {
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
String paymentId = paymentInfo.getPaymentId();
dto.setPaymentId(paymentId);
dto.setWechatAppId(wechatAppId);
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
if (response == null) {
continue;
}
List<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> confirms = response.getPaymentConfirms();
if (CollectionUtils.isNotEmpty(confirms)) {
for (QueryPaymentConfirmDetailResponse.PaymentConfirmInfo confirm : confirms) {
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
// 找到orderCode的分账记录
// 校验是不是分给正确的商户
// 撤销原分账
// 重新分账
// 找到orderCode的分账记录
if (StringUtils.equals(jsonObject.getString("orderCode"), orderCode)) {
// 分账金额
BigDecimal confirmAmt = new BigDecimal(confirm.getConfirmAmt());
// 校验是不是分给正确的商户
String adapayMemberId = jsonObject.getString("adapayMemberId");
if (!StringUtils.equals(adapayMemberId, adapayMemberAccount.getAdapayMemberId())) {
// 撤销原分账
adapayService.createConfirmReverse(confirm.getId(), wechatAppId);
// 重新分账
adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, confirmAmt, orderCode, wechatAppId);
}
}
}
}
}
}
}