汇付支付 执行退款

This commit is contained in:
2023-05-27 16:01:27 +08:00
parent 35413920d3
commit 6cba1f84c5
9 changed files with 83 additions and 7 deletions

View File

@@ -23,6 +23,7 @@ import com.jsowell.common.util.AdapayUtil;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
import com.jsowell.common.util.id.SnowflakeIdWorker;
import com.jsowell.pile.domain.MemberBasicInfo;
import com.jsowell.pile.domain.MemberInvoiceTitle;
import com.jsowell.pile.domain.MemberPlateNumberRelation;
@@ -455,7 +456,7 @@ public class MemberService {
public Map<String, Object> rechargeBalanceWithAdapay(WeixinPayDTO dto) throws Exception {
// 封装对象
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
createAdaPaymentParam.setOrder_no(IdUtils.fastSimpleUUID());
createAdaPaymentParam.setOrder_no(SnowflakeIdWorker.getSnowflakeId());
createAdaPaymentParam.setPay_amt(AdapayUtil.formatAmount(dto.getAmount()));
createAdaPaymentParam.setApp_id(ADAPAY_APP_ID); // 移动到配置文件中
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求

View File

@@ -758,7 +758,7 @@ public class OrderService {
orderBasicInfoService.weChatRefund(dto);
}
public void adapayRefund(WeChatRefundDTO dto) {
public void adapayRefund(WeChatRefundDTO dto) throws BaseAdaPayException {
log.info("汇付退款 param:{}", JSON.toJSONString(dto));
// 退款有两种情况 1-订单结算退款 2-用户余额退款
String refundType = dto.getRefundType();
@@ -1213,7 +1213,6 @@ public class OrderService {
}
}
// 入库
OrderInvoiceRecord orderInvoiceRecord = new OrderInvoiceRecord();
orderInvoiceRecord.setStatus("0");

View File

@@ -5,6 +5,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.huifu.adapay.model.Refund;
import com.jsowell.JsowellApplication;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
@@ -143,6 +145,27 @@ public class SpringBootTestController {
@Autowired
private AdapayCallbackRecordService adapayCallbackRecordService;
@Test
public void testAdapayRefund() {
// 创建汇付退款对象 在完成初始化设置情况下,调用方法,获取 Refund对象
try {
String id = "002212023052711245310508373206577954816";
String refundAmount = "0.01";
Map<String, Object> refundParams = Maps.newHashMap();
refundParams.put("refund_amt", AdapayUtil.formatAmount(refundAmount));
refundParams.put("refund_order_no", SnowflakeIdWorker.getSnowflakeId());
Map<String, Object> response = Refund.create(id, refundParams);
System.out.println(JSON.toJSONString(response));
// if (response != null && !response.isEmpty()) {
// JSONObject jsonObject = JSONObject.parseObject(response.get("expend").toString());
// JSONObject pay_info = jsonObject.getJSONObject("pay_info");
// Map<String, Object> resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference<Map<String, Object>>() {});
// }
} catch (Exception e) {
System.out.println(e);
}
}
@Test
public void testSaveCallback() throws JsonProcessingException {
String data = "{\"app_id\":\"app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa\",\"created_time\":\"20230527100758\",\"description\":\"{\\\"type\\\":\\\"balance\\\",\\\"memberId\\\":\\\"29336349\\\"}\",\"end_time\":\"20230527100810\",\"expend\":{\"bank_type\":\"OTHERS\",\"open_id\":\"o8jhot6PJF93EPhNISsXi28dKdS8\",\"sub_open_id\":\"o4REX5MprZfTaLnVNxfdOY-wnwGI\"},\"fee_amt\":\"0.00\",\"id\":\"002212023052710075810508353847861903360\",\"order_no\":\"4c457bd474334d5eaf82f4795265b6ad\",\"out_trans_id\":\"4200001864202305270647556621\",\"party_order_id\":\"02212305273647819807712\",\"pay_amt\":\"0.01\",\"pay_channel\":\"wx_lite\",\"real_amt\":\"0.01\",\"share_eq\":\"Y\",\"status\":\"succeeded\",\"wx_user_id\":\"\"}";