新增 根据分账id撤销已分帐订单

This commit is contained in:
Lemon
2025-04-28 09:41:47 +08:00
parent 3489b7899f
commit 297c251274
6 changed files with 90 additions and 0 deletions

View File

@@ -313,4 +313,25 @@ public class OrderBasicInfoController extends BaseController {
return response;
}
/**
* 根据分账id撤销已分帐
* @param paymentConfirmId
* @return
*/
@GetMapping("/confirmReverseByPaymentConfirmId/{paymentConfirmId}")
public RestApiResponse<?> confirmReverseByPaymentConfirmId(@PathVariable("paymentConfirmId") String paymentConfirmId) {
RestApiResponse<?> response = null;
try {
String result = orderSplitRecordService.confirmReverseByPaymentConfirmId(paymentConfirmId);
response = new RestApiResponse<>(result);
}catch (BusinessException businessException) {
response = new RestApiResponse<>(businessException.getCode(), businessException.getMessage());
} catch (Exception e) {
logger.error("根据分账id撤销已分帐 error, ", e);
response = new RestApiResponse<>(e);
}
logger.info("根据分账id撤销已分帐 param:{}, result:{}", paymentConfirmId, response);
return response;
}
}

View File

@@ -68,6 +68,9 @@ public class Constants {
public static final String JSOWELL = "举视";
// 希晓运营商的merchantId
public static final String XIXIAO_MERCHANT_ID_PRD = "35";
public static final String DEFAULT = "default"; // 默认
/**
@@ -75,6 +78,8 @@ public class Constants {
*/
public static final String DEFAULT_APP_ID = "wxbb3e0d474569481d"; // 默认微信小程序appId
public static final String XIXIAO_APP_ID = "wx20abc5210391649c"; // 希晓微信小程序appId
public static final byte[] updateServerPort = new byte[]{port};
// FTP用户名

View File

@@ -59,4 +59,6 @@ public interface OrderSplitRecordMapper {
* @return
*/
List<SplitConfigStationVO> queryStationAggregateData(@Param("dto") SplitConfigStationDTO dto);
List<OrderSplitRecord> selectInfoByPaymentConfirmId(String paymentConfirmId);
}

View File

@@ -1,5 +1,6 @@
package com.jsowell.pile.service;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.jsowell.adapay.dto.PaymentConfirmParam;
import com.jsowell.adapay.dto.SplitData;
import com.jsowell.adapay.response.PaymentConfirmResponse;
@@ -92,5 +93,11 @@ public interface OrderSplitRecordService {
* @return
*/
List<SplitRecordInfoVO> queryOrderSplitDetail(String orderCode);
/**
* 根据分账id撤销已分帐
* @param paymentConfirmId
*/
String confirmReverseByPaymentConfirmId(String paymentConfirmId) throws BaseAdaPayException;
}

View File

@@ -1,21 +1,27 @@
package com.jsowell.pile.service.impl;
import com.alibaba.fastjson2.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.huifu.adapay.model.AdapayCommon;
import com.jsowell.adapay.dto.PaymentConfirmParam;
import com.jsowell.adapay.dto.SplitData;
import com.jsowell.adapay.response.PaymentConfirmResponse;
import com.jsowell.adapay.service.AdapayService;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.model.LoginUser;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.common.enums.DelFlagEnum;
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.SecurityUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
import com.jsowell.pile.domain.AdapayMemberAccount;
import com.jsowell.pile.domain.OrderSplitRecord;
import com.jsowell.pile.domain.PileMerchantInfo;
@@ -498,6 +504,48 @@ public class OrderSplitRecordServiceImpl implements OrderSplitRecordService {
return resultList;
}
/**
* 根据分账id撤销已分帐
* @param paymentConfirmId
*/
@Override
public String confirmReverseByPaymentConfirmId(String paymentConfirmId) throws BaseAdaPayException {
// 根据确认id查出订单信息
List<OrderSplitRecord> recordList = orderSplitRecordMapper.selectInfoByPaymentConfirmId(paymentConfirmId);
if (CollectionUtils.isEmpty(recordList)) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
}
OrderSplitRecord orderSplitRecord = recordList.get(0);
String merchantId = orderSplitRecord.getMerchantId();
String orderCode = orderSplitRecord.getOrderCode();
String wxappId = Constants.DEFAULT_APP_ID;
// 通过确认id查询会查出多条分账记录需要先判断订单所属的运营商是举视还是希晓
if (StringUtils.equals(merchantId, Constants.XIXIAO_MERCHANT_ID_PRD)) {
wxappId = Constants.XIXIAO_APP_ID;
}
// 确认请求参数
String newOrderCode = orderCode + "_" + DateUtils.dateTimeNow();
Map<String, Object> confirmReverseParams = Maps.newHashMap();
confirmReverseParams.put("adapay_func_code", "payments.confirm.reverse");
confirmReverseParams.put("payment_confirm_id", paymentConfirmId);
confirmReverseParams.put("reason", "后管支付管理页面撤销已分帐");
confirmReverseParams.put("order_no", newOrderCode);
// 调用汇付接口
Map<String, Object> confirmReverseResult = AdapayCommon.requestAdapay(confirmReverseParams, wxappId);
// 获取返回参数中的status
String status = String.valueOf(confirmReverseResult.get("status"));
if (StringUtils.equals("succeeded", status)) {
// 成功撤销,将之前该订单下的所有分账信息状态改为已撤销
recordList.forEach(
x -> x.setStatus("revoked")
);
// 批量修改
orderSplitRecordMapper.updateBatchSelective(recordList);
}
return status;
}
/**
* 根据汇付会员id查询分账汇总数据
* @param dto

View File

@@ -882,4 +882,11 @@
</if>
</select>
<select id="selectInfoByPaymentConfirmId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from order_split_record
where del_flag = '0'
and payment_confirm_id = #{paymentConfirmId,jdbcType=VARCHAR}
</select>
</mapper>