Bläddra i källkod

Merge branch 'master' of http://120.79.166.78:19005/zhongzheng-edu/saas_entrepot

yangdamao 2 år sedan
förälder
incheckning
bfe54f7aa4

+ 11 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpStatus;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -82,6 +83,8 @@ import com.zhongzheng.modules.user.vo.UserVo;
 import com.zhongzheng.modules.wx.service.IWxPayService;
 import com.zhongzheng.modules.wx.vo.WxPayVo;
 import org.apache.commons.lang3.StringUtils;
+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.Service;
@@ -107,6 +110,8 @@ import static com.squareup.okhttp.internal.Util.md5Hex;
 @Service
 public class WxPayServiceImpl implements IWxPayService {
 
+    private static Logger log = LoggerFactory.getLogger(WxPayServiceImpl.class);
+
   //  @Value("${wx.small.appid}")
     private String appid;
 
@@ -216,6 +221,9 @@ public class WxPayServiceImpl implements IWxPayService {
     @Override
     public Map<String, String> payment(String out_trade_no, String openid, String body, BigDecimal price) {
         initData();
+        log.info("支付错误1:{}", appid);
+        log.info("支付错误1:{}", mchid);
+        log.info("支付错误1:{}", key);
         WxSmallConfig config = new WxSmallConfig(appid, mchid, key);
         BigDecimal unit = new BigDecimal(100);
         price = price.multiply(unit);
@@ -233,7 +241,9 @@ public class WxPayServiceImpl implements IWxPayService {
             data.put("trade_type", "JSAPI");
             String TenantId = ServletUtils.getRequest().getHeader("TenantId");
             data.put("attach", TenantId);
+            log.info("支付参数:{}", JSON.toJSONString(data));
             Map<String, String> resp = wxpay.unifiedOrder(data);
+            log.info("支付结果:{}", JSON.toJSONString(resp));
             Map<String, String> result = new HashMap<>();
             //         result.put("provider","wxpay");
             result.put("appId", appid);
@@ -245,6 +255,7 @@ public class WxPayServiceImpl implements IWxPayService {
             return result;
         } catch (Exception e) {
             e.printStackTrace();
+            log.info("支付错误:{}", e.getMessage());
         }
 
         return null;
@@ -254,10 +265,6 @@ public class WxPayServiceImpl implements IWxPayService {
     public Map<String, String> paymentPc(String out_trade_no, String openid, String body, BigDecimal price) {
         initData();
         WxSmallConfig config = new WxSmallConfig(appid, mchid, key);
-        System.out.println(55678);
-        System.out.println(appid);
-        System.out.println(mchid);
-        System.out.println(key);
         BigDecimal unit = new BigDecimal(100);
         price = price.multiply(unit);
         try {