mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-04 22:18:02 +08:00
update 汇付支付回调
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
package com.jsowell.service;
|
package com.jsowell.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
import com.huifu.adapay.model.Payment;
|
import com.huifu.adapay.model.Payment;
|
||||||
import com.jsowell.adapay.common.CreateAdaPaymentParam;
|
import com.jsowell.adapay.common.CreateAdaPaymentParam;
|
||||||
@@ -437,6 +439,12 @@ public class MemberService {
|
|||||||
return orderService.weixinPayV3(dto);
|
return orderService.weixinPayV3(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用汇付支付充值余额
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public Map<String, Object> rechargeBalanceWithAdapay(WeixinPayDTO dto) throws Exception {
|
public Map<String, Object> rechargeBalanceWithAdapay(WeixinPayDTO dto) throws Exception {
|
||||||
// 封装对象
|
// 封装对象
|
||||||
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
|
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
|
||||||
@@ -444,12 +452,16 @@ public class MemberService {
|
|||||||
createAdaPaymentParam.setPay_amt(AdapayUtil.formatAmount(dto.getAmount()));
|
createAdaPaymentParam.setPay_amt(AdapayUtil.formatAmount(dto.getAmount()));
|
||||||
createAdaPaymentParam.setApp_id("app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa"); // todo 后面移动到配置文件中
|
createAdaPaymentParam.setApp_id("app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa"); // todo 后面移动到配置文件中
|
||||||
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求
|
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求
|
||||||
createAdaPaymentParam.setGoods_title("充电费用1");
|
createAdaPaymentParam.setGoods_title("余额");
|
||||||
createAdaPaymentParam.setGoods_desc("充电费用2");
|
createAdaPaymentParam.setGoods_desc("会员充值余额");
|
||||||
createAdaPaymentParam.setDescription("充电费用3");
|
// createAdaPaymentParam.setDescription("充电费用3");
|
||||||
createAdaPaymentParam.setExpend(JSONObject.toJSONString( ImmutableMap.of("open_id", dto.getOpenId())));
|
createAdaPaymentParam.setExpend(JSONObject.toJSONString( ImmutableMap.of("open_id", dto.getOpenId())));
|
||||||
//异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
|
//异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
|
||||||
createAdaPaymentParam.setNotify_url("https://api.jsowellcloud.com/uniapp/pay/adapayCallback");
|
createAdaPaymentParam.setNotify_url("https://api.jsowellcloud.com/uniapp/pay/adapayCallback");
|
||||||
|
Map<String, String> map = Maps.newHashMap();
|
||||||
|
map.put("type", ScenarioEnum.BALANCE.getValue());
|
||||||
|
map.put("memberId", dto.getMemberId());
|
||||||
|
createAdaPaymentParam.setDescription(JSON.toJSONString(map));
|
||||||
try {
|
try {
|
||||||
log.info("创建汇付支付参数:{}", JSONObject.toJSONString(createAdaPaymentParam));
|
log.info("创建汇付支付参数:{}", JSONObject.toJSONString(createAdaPaymentParam));
|
||||||
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam));
|
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.service;
|
package com.jsowell.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@@ -1248,8 +1249,54 @@ public class OrderService {
|
|||||||
AdapayCallbackRecord adapayCallbackRecord = mapper.readValue(data, AdapayCallbackRecord.class);
|
AdapayCallbackRecord adapayCallbackRecord = mapper.readValue(data, AdapayCallbackRecord.class);
|
||||||
adapayCallbackRecordService.saveAdapayCallbackRecord(adapayCallbackRecord);
|
adapayCallbackRecordService.saveAdapayCallbackRecord(adapayCallbackRecord);
|
||||||
|
|
||||||
// 修改订单为已支付
|
JSONObject descJson = JSON.parseObject(adapayCallbackRecord.getDescription());
|
||||||
|
String type = descJson.getString("type");
|
||||||
|
String memberId = descJson.getString("memberId");
|
||||||
|
String orderCode = descJson.getString("orderCode");
|
||||||
|
BigDecimal amount = adapayCallbackRecord.getPayAmt();
|
||||||
|
if (StringUtils.equals(type, ScenarioEnum.ORDER.getValue())) { // 1-订单支付
|
||||||
|
// 支付订单成功
|
||||||
|
// orderCode = (String) map.get("orderCode");
|
||||||
|
PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder()
|
||||||
|
.orderCode(orderCode)
|
||||||
|
.payAmount(amount)
|
||||||
|
.payMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
||||||
|
.build();
|
||||||
|
// 订单支付成功 支付回调
|
||||||
|
payOrderSuccessCallback(callbackDTO);
|
||||||
|
|
||||||
|
// 记录订单支付流水
|
||||||
|
OrderPayRecord orderPayRecord = OrderPayRecord.builder()
|
||||||
|
.orderCode(orderCode)
|
||||||
|
.payMode(OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())
|
||||||
|
.payAmount(amount)
|
||||||
|
.createBy(null)
|
||||||
|
.build();
|
||||||
|
orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord));
|
||||||
|
} else if (StringUtils.equals(type, ScenarioEnum.BALANCE.getValue())) { // 2-充值余额
|
||||||
|
// 充值余额成功
|
||||||
|
// memberId = (String) map.get("memberId");
|
||||||
|
UpdateMemberBalanceDTO dto = new UpdateMemberBalanceDTO();
|
||||||
|
dto.setMemberId(memberId);
|
||||||
|
dto.setType(MemberWalletEnum.TYPE_IN.getValue());
|
||||||
|
dto.setSubType(MemberWalletEnum.SUBTYPE_TOP_UP.getValue());
|
||||||
|
dto.setUpdatePrincipalBalance(amount);
|
||||||
|
memberBasicInfoService.updateMemberBalance(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信支付订单 记录会员交易流水
|
||||||
|
MemberTransactionRecord record = MemberTransactionRecord.builder()
|
||||||
|
.orderCode(orderCode)
|
||||||
|
.scenarioType(type)
|
||||||
|
.memberId(memberId)
|
||||||
|
.actionType(ActionTypeEnum.FORWARD.getValue())
|
||||||
|
.payMode(PayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
||||||
|
.paymentInstitutions(PaymentInstitutionsEnum.ADAPAY.getValue())
|
||||||
|
.amount(amount) // 单位元
|
||||||
|
.outTradeNo(adapayCallbackRecord.getPartyOrderId())
|
||||||
|
.transactionId(adapayCallbackRecord.getOutTransId())
|
||||||
|
.build();
|
||||||
|
memberTransactionRecordService.insertSelective(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user