update 汇付会员

This commit is contained in:
2023-06-09 14:44:32 +08:00
parent 87d4f8a9f0
commit e1bc44bbc3
6 changed files with 53 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
package com.jsowell.service;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -274,9 +275,10 @@ public class OrderService {
}
// 封装对象
String amount = AdapayUtil.formatAmount(dto.getPayAmount()); // 用户支付金额
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
createAdaPaymentParam.setOrder_no(orderInfo.getOrderCode());
createAdaPaymentParam.setPay_amt(AdapayUtil.formatAmount(dto.getPayAmount()));
createAdaPaymentParam.setPay_amt(amount);
createAdaPaymentParam.setApp_id(ADAPAY_APP_ID); // todo 后面移动到配置文件中
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求
createAdaPaymentParam.setGoods_title("充电费用");
@@ -288,12 +290,26 @@ public class OrderService {
//异步通知地址url为http/https路径服务器POST回调URL 上请勿附带参数
createAdaPaymentParam.setNotify_url(ADAPAY_CALLBACK_URL);
createAdaPaymentParam.setExpend(JSONObject.toJSONString( ImmutableMap.of("open_id", openId)));
// 分账对象信息
String adapayMemberId = pileStationInfoService.selectAdapayMemberId(orderInfo.getStationId());
if (StringUtils.isNotBlank(adapayMemberId)) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("member_id", adapayMemberId);
jsonObject.put("amount", amount);
jsonObject.put("fee_flag", Constants.Y);
// 分账对象信息列表最多仅支持7个分账方json 数组形式
JSONArray jsonArray = new JSONArray();
jsonArray.add(jsonObject);
createAdaPaymentParam.setDiv_members(jsonArray.toString());
}
try {
log.info("创建汇付支付参数:{}", JSONObject.toJSONString(createAdaPaymentParam));
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam));
if (response != null && !response.isEmpty()) {
JSONObject jsonObject = JSONObject.parseObject(response.get("expend").toString());
JSONObject pay_info = jsonObject.getJSONObject("pay_info");
JSONObject expend = JSONObject.parseObject(response.get("expend").toString());
JSONObject pay_info = expend.getJSONObject("pay_info");
Map<String, Object> resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference<Map<String, Object>>() {
});
if (resultMap != null) {

View File

@@ -56,4 +56,12 @@ public class AdapayMemberController extends BaseController {
}
return result;
}
/**
* 查询汇付结算账户
*/
@PostMapping("/selectSettleAccount")
public AjaxResult selectSettleAccount(@RequestBody AdapayMemberInfoDTO dto) {
return null;
}
}