mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
创建余额支付请求
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.adapay.dto.BalancePaymentRequestDTO;
|
||||
import com.jsowell.adapay.service.AdapayMemberService;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
@@ -38,6 +40,9 @@ public class TempController extends BaseController {
|
||||
@Autowired
|
||||
private IAdapayMemberAccountService adapayMemberAccountService;
|
||||
|
||||
@Autowired
|
||||
private AdapayMemberService adapayMemberService;
|
||||
|
||||
/**
|
||||
* 临时刷数据接口
|
||||
* http://localhost:8080/temp/tempUpdateVirtualAmount
|
||||
@@ -210,4 +215,25 @@ public class TempController extends BaseController {
|
||||
logger.info("运营商分账手动接口result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试余额支付接口
|
||||
* http://localhost:8080/temp/testCreateBalancePayment
|
||||
*/
|
||||
@PostMapping("/testCreateBalancePayment")
|
||||
public RestApiResponse<?> testCreateBalancePayment(@RequestBody BalancePaymentRequestDTO dto) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
adapayMemberService.createBalancePaymentRequest(dto.getOutMemberId(), dto.getInMemberId(), dto.getTransAmt());
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("测试余额支付接口warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("测试余额支付接口error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_WEIXIN_REFUND_ERROR);
|
||||
}
|
||||
logger.info("测试余额支付接口result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jsowell.adapay.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class BalancePaymentRequestDTO {
|
||||
// 出账用户的member_id, 若为商户本身时,请传入0
|
||||
private String outMemberId;
|
||||
|
||||
// 入账用户的member_id, 若为商户本身时,请传入0
|
||||
private String inMemberId;
|
||||
|
||||
// 交易金额, 必须大于0,保留两位小数点,如0.10、100.05等
|
||||
private String transAmt;
|
||||
}
|
||||
@@ -453,6 +453,12 @@ public class AdapayMemberService {
|
||||
log.info("取现接口返回参数" + JSON.toJSONString(settleCount));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新汇付会员信息
|
||||
* @param dto
|
||||
* @return
|
||||
* @throws BaseAdaPayException
|
||||
*/
|
||||
public Map<String, Object> updateAdapayMember(SettleAccountDTO dto) throws BaseAdaPayException {
|
||||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId());
|
||||
if (adapayMemberAccount == null) {
|
||||
@@ -487,4 +493,24 @@ public class AdapayMemberService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建余额支付请求
|
||||
* @param outMemberId 出账用户的member_id, 若为商户本身时,请传入0
|
||||
* @param inMemberId 入账用户的member_id, 若为商户本身时,请传入0
|
||||
* @param transAmt 交易金额, 必须大于0,保留两位小数点,如0.10、100.05等
|
||||
*/
|
||||
public void createBalancePaymentRequest(String outMemberId, String inMemberId, String transAmt) throws BaseAdaPayException {
|
||||
Map<String, Object> balanceParam = Maps.newHashMap();
|
||||
balanceParam.put("app_id", ADAPAY_APP_ID);
|
||||
balanceParam.put("adapay_func_code", "settle_accounts.balancePay");
|
||||
balanceParam.put("order_no", IdUtils.fastSimpleUUID());
|
||||
balanceParam.put("out_member_id", outMemberId);
|
||||
balanceParam.put("in_member_id", "0");
|
||||
balanceParam.put("trans_amt", AdapayUtil.formatAmount(transAmt));
|
||||
balanceParam.put("goods_title", "测试余额支付");
|
||||
balanceParam.put("goods_desc", "该商品信息用于测试余额支付");
|
||||
Map<String, Object> paymentResult = AdapayCommon.requestAdapay(balanceParam);
|
||||
log.info("创建余额支付param:{}, result:{}", JSON.toJSONString(balanceParam), JSON.toJSONString(paymentResult));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user