Sfoglia il codice sorgente

修改支付逻辑

hgw 3 anni fa
parent
commit
8fd86dd046

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantOrderRecordServiceImpl.java

@@ -347,7 +347,7 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
         if (StringUtils.equals(orderRecord.getPaymentChannel(), PaymentChannelEnum.ADAPAY.getCode())) {
             Map<String, Object> payment;
             try {
-                Integer tenantId = -1;
+                Integer tenantId = orderRecord.getTenantId();
                 HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(tenantId);
                 if (hfMerchantConfig == null) {
                     throw new BizException("机构[{}]汇付商户信息找不到", tenantId);

+ 10 - 11
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java

@@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.util.DigestUtils;
 
 public class Payment {
-	
+
 	private final static Logger LOGGER = LoggerFactory.getLogger(Payment.class);
     /**
      * 执行一个支付交易
@@ -23,13 +23,13 @@ public class Payment {
      */
     public static Map<String, Object> executePayment(String appId, String merchantKey, Map<String, Object> paymentParams) throws Exception {
         paymentParams.put("app_id", appId);
-        
+
         LOGGER.info("汇付[创建支付对象] Req:{}", paymentParams);
 
         //调用sdk方法,创建支付,得到支付对象
         Map<String, Object> payment = new HashMap<>();
         payment = com.huifu.adapay.model.Payment.create(paymentParams, merchantKey);
-        
+
         LOGGER.info("汇付[创建支付对象] Resp:{}", payment);
 
         String errorCode = (String) payment.get("error_code");
@@ -67,25 +67,24 @@ public class Payment {
      * @throws Exception 异常
      */
     public static Map<String, Object> queryPayment(String paymentId, String merchantKey) throws Exception {
-        System.out.println("=======query payment begin=======");
+        LOGGER.info("=======query payment begin=======");
         //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id7
         //调用sdk方法,查询支付交易,得到支付对象
         Map<String, Object> payment = new HashMap<>();
         try {
-            System.out.println("支付查询请求参数:" + JSON.toJSONString(paymentId));
+            LOGGER.info("queryPayment >>> 支付查询请求参数:{}", paymentId);
             payment = com.huifu.adapay.model.Payment.query(paymentId, merchantKey);
         } catch (ThirdpartyException e) {
-            e.printStackTrace();
+            LOGGER.error("queryPayment >>> 支付查询异常", e.getCause());
         }
-
-        System.out.println("支付查询返回参数:" + JSON.toJSONString(payment));
+        LOGGER.info("queryPayment >>> 支付查询返回参数:{}", JSON.toJSONString(payment));
 
         String error_code = (String) payment.get("error_code");
         if (null != error_code) {
             String error_msg = (String) payment.get("error_msg");
-            System.out.println("error_code:" + error_code + "............." + error_msg);
+            LOGGER.error("queryPayment >>>  error_code:" + error_code + "............." + error_msg);
         }
-        System.out.println("=======query payment end=======");
+        LOGGER.info("queryPayment >>> =======query payment end=======");
         return payment;
     }
 
@@ -121,7 +120,7 @@ public class Payment {
     }
 
     public static Map<String, Object> getPayMap(HfMerchantConfig hfMerchantConfig, BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
-    	
+
         Map<String, Object> paymentParams = new LinkedHashMap<>();
         paymentParams.put("appId", hfMerchantConfig.getAppId());
         paymentParams.put("amount", amount.setScale(2, BigDecimal.ROUND_HALF_UP));