|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alipay.api.AlipayApiException;
|
|
|
+import com.alipay.api.AlipayClient;
|
|
|
import com.alipay.api.FileItem;
|
|
|
import com.alipay.api.domain.*;
|
|
|
import com.alipay.api.request.*;
|
|
|
@@ -387,7 +388,12 @@ public class FacetofaceService {
|
|
|
* 生成当面付收款二维码 — 调用 alipay.trade.precreate
|
|
|
*/
|
|
|
public F2fTradeVO precreateTrade(F2fTradePrecreateDTO dto) {
|
|
|
+ log.info("[收款] 开始生成收款码: enterprise_id={}, amount={}", dto.getEnterpriseId(), dto.getTotalAmount());
|
|
|
+
|
|
|
FacetofaceOrderEntity order = getSuccessOrder(dto.getEnterpriseId());
|
|
|
+ log.info("[收款] 找到成功订单: order_id={}, merchant_pid={}, auth_token_len={}",
|
|
|
+ order.getId(), order.getMerchantPid(),
|
|
|
+ order.getAppAuthToken() != null ? order.getAppAuthToken().length() : 0);
|
|
|
|
|
|
String outTradeNo = "F2F" + System.currentTimeMillis() + String.format("%04d", (int) (Math.random() * 10000));
|
|
|
try {
|
|
|
@@ -398,17 +404,28 @@ public class FacetofaceService {
|
|
|
|
|
|
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
|
|
|
request.setBizModel(model);
|
|
|
- request.setNotifyUrl(alipayClientFactory.getPaymentConfig().getNotifyUrl());
|
|
|
+ String notifyUrl = alipayClientFactory.getPaymentConfig().getNotifyUrl();
|
|
|
+ request.setNotifyUrl(notifyUrl);
|
|
|
request.putOtherTextParam("app_auth_token", order.getAppAuthToken());
|
|
|
|
|
|
- AlipayTradePrecreateResponse response = alipayClientFactory.getClient(dto.getEnterpriseId(), ServiceProviderBizType.FACETOFACE_NOTIFY.getValue()).execute(request);
|
|
|
+ log.info("[收款] precreate 请求参数: out_trade_no={}, total_amount={}, subject={}, notify_url={}, app_auth_token={}...",
|
|
|
+ outTradeNo, dto.getTotalAmount(), model.getSubject(), notifyUrl,
|
|
|
+ order.getAppAuthToken() != null ? order.getAppAuthToken().substring(0, Math.min(10, order.getAppAuthToken().length())) : "null");
|
|
|
+
|
|
|
+ AlipayClient client = alipayClientFactory.getClient(dto.getEnterpriseId(), ServiceProviderBizType.FACETOFACE_NOTIFY.getValue());
|
|
|
+ log.info("[收款] AlipayClient: {}", client != null ? "OK" : "NULL");
|
|
|
+
|
|
|
+ AlipayTradePrecreateResponse response = client.execute(request);
|
|
|
+
|
|
|
+ log.info("[收款] precreate 响应: code={}, msg={}, sub_code={}, sub_msg={}",
|
|
|
+ response.getCode(), response.getMsg(), response.getSubCode(), response.getSubMsg());
|
|
|
|
|
|
if (!response.isSuccess()) {
|
|
|
throw new BusinessException(400, "生成收款码失败: " +
|
|
|
(response.getSubMsg() != null ? response.getSubMsg() : response.getMsg()));
|
|
|
}
|
|
|
|
|
|
- log.info("当面付收款码生成成功: out_trade_no={}, qr_code={}", outTradeNo, response.getQrCode());
|
|
|
+ log.info("[收款] 收款码生成成功: out_trade_no={}, qr_code={}", outTradeNo, response.getQrCode());
|
|
|
|
|
|
F2fTradeVO vo = new F2fTradeVO();
|
|
|
vo.setOutTradeNo(outTradeNo);
|
|
|
@@ -416,6 +433,7 @@ public class FacetofaceService {
|
|
|
return vo;
|
|
|
|
|
|
} catch (AlipayApiException ex) {
|
|
|
+ log.error("[收款] AlipayApiException: {}", ex.getMessage(), ex);
|
|
|
throw new BusinessException(400, "生成收款码失败: " + ex.getMessage());
|
|
|
}
|
|
|
}
|