|
@@ -1,5 +1,7 @@
|
|
|
package shop.alien.store.util.ali;
|
|
package shop.alien.store.util.ali;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alipay.api.AlipayApiException;
|
|
import com.alipay.api.AlipayApiException;
|
|
|
import com.alipay.api.AlipayClient;
|
|
import com.alipay.api.AlipayClient;
|
|
@@ -19,10 +21,12 @@ import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.LifeUser;
|
|
import shop.alien.entity.store.LifeUser;
|
|
|
import shop.alien.entity.store.StoreAliPayErrorLog;
|
|
import shop.alien.entity.store.StoreAliPayErrorLog;
|
|
|
import shop.alien.entity.store.StoreAliPayLog;
|
|
import shop.alien.entity.store.StoreAliPayLog;
|
|
|
|
|
+import shop.alien.entity.store.StoreAliPayRefundLog;
|
|
|
import shop.alien.entity.store.StoreUser;
|
|
import shop.alien.entity.store.StoreUser;
|
|
|
import shop.alien.store.service.LifeUserService;
|
|
import shop.alien.store.service.LifeUserService;
|
|
|
import shop.alien.store.service.StoreAliPayErrorLogService;
|
|
import shop.alien.store.service.StoreAliPayErrorLogService;
|
|
|
import shop.alien.store.service.StoreAliPayLogService;
|
|
import shop.alien.store.service.StoreAliPayLogService;
|
|
|
|
|
+import shop.alien.store.service.StoreAliPayRefundLogService;
|
|
|
import shop.alien.store.service.StoreUserService;
|
|
import shop.alien.store.service.StoreUserService;
|
|
|
import shop.alien.store.util.ali.ocr.OcrStrategy;
|
|
import shop.alien.store.util.ali.ocr.OcrStrategy;
|
|
|
import shop.alien.store.util.ali.ocr.OcrStrategyFactory;
|
|
import shop.alien.store.util.ali.ocr.OcrStrategyFactory;
|
|
@@ -31,6 +35,7 @@ import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
|
import shop.alien.util.common.UrlEncode;
|
|
import shop.alien.util.common.UrlEncode;
|
|
|
import shop.alien.util.system.OSUtil;
|
|
import shop.alien.util.system.OSUtil;
|
|
|
|
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Base64;
|
|
import java.util.Base64;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -54,7 +59,8 @@ public class AliApi {
|
|
|
private final LifeUserService lifeUserService;
|
|
private final LifeUserService lifeUserService;
|
|
|
|
|
|
|
|
private final StoreAliPayErrorLogService storeAliPayErrorLogService;
|
|
private final StoreAliPayErrorLogService storeAliPayErrorLogService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private final StoreAliPayRefundLogService storeAliPayRefundLogService;
|
|
|
|
|
|
|
|
private final OcrStrategyFactory ocrStrategyFactory;
|
|
private final OcrStrategyFactory ocrStrategyFactory;
|
|
|
|
|
|
|
@@ -203,6 +209,54 @@ public class AliApi {
|
|
|
String refundReslut = "";
|
|
String refundReslut = "";
|
|
|
if (response.isSuccess()) {
|
|
if (response.isSuccess()) {
|
|
|
refundReslut = "调用成功";
|
|
refundReslut = "调用成功";
|
|
|
|
|
+ // 保存退款信息进入到退款记录表
|
|
|
|
|
+ JSONObject responseBody = JSONObject.parseObject(response.getBody());
|
|
|
|
|
+ JSONObject refundResponse = responseBody.getJSONObject("alipay_trade_refund_response");
|
|
|
|
|
+
|
|
|
|
|
+ StoreAliPayRefundLog refundLog = new StoreAliPayRefundLog();
|
|
|
|
|
+ // 响应基本信息
|
|
|
|
|
+ refundLog.setResponseCode(refundResponse.getString("code"));
|
|
|
|
|
+ refundLog.setResponseMsg(refundResponse.getString("msg"));
|
|
|
|
|
+ // 买家信息
|
|
|
|
|
+ refundLog.setBuyerLogonId(refundResponse.getString("buyer_logon_id"));
|
|
|
|
|
+ refundLog.setBuyerOpenId(refundResponse.getString("buyer_open_id"));
|
|
|
|
|
+ // 资金变动信息
|
|
|
|
|
+ refundLog.setFundChange(refundResponse.getString("fund_change"));
|
|
|
|
|
+ // 订单信息
|
|
|
|
|
+ refundLog.setOutTradeNo(refundResponse.getString("out_trade_no"));
|
|
|
|
|
+ refundLog.setTradeNo(refundResponse.getString("trade_no"));
|
|
|
|
|
+ // 退款金额信息
|
|
|
|
|
+ refundLog.setRefundFee(refundResponse.getString("refund_fee"));
|
|
|
|
|
+ refundLog.setSendBackFee(refundResponse.getString("send_back_fee"));
|
|
|
|
|
+ // 退款渠道明细(转换为JSON字符串)
|
|
|
|
|
+ if (refundResponse.containsKey("refund_detail_item_list")) {
|
|
|
|
|
+ JSONArray refundDetailList = refundResponse.getJSONArray("refund_detail_item_list");
|
|
|
|
|
+ if (refundDetailList != null) {
|
|
|
|
|
+ refundLog.setRefundDetailItemList(JSON.toJSONString(refundDetailList));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 退款时间(字符串转Date)
|
|
|
|
|
+ String gmtRefundPayStr = refundResponse.getString("gmt_refund_pay");
|
|
|
|
|
+ if (StringUtils.isNotBlank(gmtRefundPayStr)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ refundLog.setGmtRefundPay(sdf.parse(gmtRefundPayStr));
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
|
+ log.warn("解析退款时间失败: {}", gmtRefundPayStr, e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 退款原因和部分退款编号(从请求参数中获取)
|
|
|
|
|
+ refundLog.setRefundReason(refundReason);
|
|
|
|
|
+ refundLog.setOutRequestNo(partialRefundCode);
|
|
|
|
|
+ // 证书和签名信息
|
|
|
|
|
+ refundLog.setAlipayCertSn(responseBody.getString("alipay_cert_sn"));
|
|
|
|
|
+ refundLog.setSign(responseBody.getString("sign"));
|
|
|
|
|
+ // 标准字段
|
|
|
|
|
+ refundLog.setDeleteFlag(0);
|
|
|
|
|
+ refundLog.setCreatedTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ storeAliPayRefundLogService.save(refundLog);
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
log.warn("AliPayConfig.processRefund ERROR Msg={}", response.getBody());
|
|
log.warn("AliPayConfig.processRefund ERROR Msg={}", response.getBody());
|
|
|
JSONObject jsonObject = JSONObject.parseObject(response.getBody()).getJSONObject("alipay_trade_refund_response");
|
|
JSONObject jsonObject = JSONObject.parseObject(response.getBody()).getJSONObject("alipay_trade_refund_response");
|
|
@@ -373,6 +427,7 @@ public class AliApi {
|
|
|
}else{
|
|
}else{
|
|
|
payeeInfo.setIdentity(phone);
|
|
payeeInfo.setIdentity(phone);
|
|
|
}
|
|
}
|
|
|
|
|
+ payeeInfo.setName(name);
|
|
|
model.setPayeeInfo(payeeInfo);
|
|
model.setPayeeInfo(payeeInfo);
|
|
|
// 设置业务备注
|
|
// 设置业务备注
|
|
|
model.setRemark("爱丽恩提现业务");
|
|
model.setRemark("爱丽恩提现业务");
|