chunping 2 роки тому
батько
коміт
48beb0518f

+ 5 - 5
mp-admin/src/main/java/com/qs/mp/web/controller/api/callback/AlipayCallBackController.java

@@ -78,7 +78,7 @@ public class AlipayCallBackController {
       flag = AlipaySignature.rsaCheckV1 (params, aliPublicKey, "GBK","RSA2");
       if (!flag) {
         LogUtil.error(logger,"验签失败");
-        responseWrite(response,"error");
+        responseWrite(response,"fail");
         return;
       }
     } catch (AlipayApiException e) {
@@ -97,17 +97,17 @@ public class AlipayCallBackController {
         .eq(PayOrder::getOrderNo, tradeNo));
     if (null == order) {
       logger.error("支付订单不存在,bizId:" + bizId + ",tradeNo:" + tradeNo);
-      responseWrite(response,"error");
+      responseWrite(response,"fail");
       return;
     }
     if(order.getTransactionAmount() != totalAmount){
       logger.error("回调金额与订单金额不一致");
-      responseWrite(response,"error");
+      responseWrite(response,"fail");
       return;
     }
     if (!"TRADE_SUCCESS".equals(tradeStatus)) {
       logger.error("非支付成功消息,忽略");
-      responseWrite(response,"error");
+      responseWrite(response,"fail");
       return;
     }
     PayOrder payOrder =  new PayOrder();
@@ -133,7 +133,7 @@ public class AlipayCallBackController {
       responseWrite(response,"success");
     } catch (Exception e){
       LogUtil.error(logger, e, "支付回调消息更新失败 orderId:" + order.getOrderId());
-      responseWrite(response,"error");
+      responseWrite(response,"fail");
     }
   }
 

+ 9 - 19
mp-service/src/main/java/com/qs/mp/pay/service/impl/WalletServiceImpl.java

@@ -38,6 +38,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 
 import java.util.Objects;
@@ -47,7 +48,7 @@ import java.util.Objects;
  * @create 2021 2021/9/4 1:59 下午
  * @describe
  */
-@Service
+@Component
 public class WalletServiceImpl implements IWalletService {
 
   protected final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
@@ -103,34 +104,22 @@ public class WalletServiceImpl implements IWalletService {
   private static final String PAY_RESOURCE_TYPE = "1017"; //2:微信小程序
 
   // 支付宝直连
-
-  private static String aliAppId;
   @Value("${ali-miniApp.appId}")
-  public void setAliAppId(String aliAppId) {
-    aliAppId = aliAppId;
-  }
+  private static String aliAppId;
 
-  private static String aliPublicKey;
   @Value("${ali-miniApp.public-key}")
-  public void setAliPublicKey(String aliPublicKey) {
-    aliPublicKey = aliPublicKey;
-  }
+  private static String aliPublicKey;
 
-  private static String aliPrivateKey;
   @Value("${ali-miniApp.private-key}")
-  public static void setAliPrivateKey(String aliPrivateKey) {
-    aliPrivateKey = aliPrivateKey;
-  }
+  private static String aliPrivateKey;
 
-  private static String aliServerUrl;
   @Value("${ali-miniApp.serverUrl}")
-  public static void setAliServerUrl(String aliServerUrl) {
-    aliServerUrl = aliServerUrl;
-  }
+  private String aliServerUrl;
 
   @Value("${alipay.callbackUrl}")
   private String alipayCallbackUrl;  //支付宝直连回调地址
-  private static AlipayClient alipayClient = null;
+
+  private AlipayClient alipayClient = null;
 
 
   @Override
@@ -162,6 +151,7 @@ public class WalletServiceImpl implements IWalletService {
       if(e.getCause() instanceof java.security.spec.InvalidKeySpecException){
         logger.error("商户私钥格式不正确,请确认application.properties文件中是否配置正确");
       }
+      logger.error("创建支付宝交易异常。request:" + JSON.toJSONString(alipayRequest), e);
       throw new ServiceException("订单创建失败");
     }