mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update 汇付会员
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user