Browse Source

调整获取微信手机号逻辑

eganwu 1 year ago
parent
commit
a96d8634fb

+ 4 - 0
src/custom/restcontroller/saletool/sharematerial/sharematerial.java

@@ -305,7 +305,11 @@ public class sharematerial extends Controller {
         String code = content.getString("code");
         WechatMiniProgram miniProgram = new WechatMiniProgram(systemclient);
         JSONObject jsonObject = miniProgram.getWechatUserPhonenumber(code);
+        if (jsonObject.containsKey("errcode") && jsonObject.getInteger("errcode") != 0) {
+            return getErrReturnObject().setErrMsg(jsonObject.toJSONString()).toString();
+        }
         return getSucReturnObject().setData(jsonObject).toString();
+
     }
 
 

+ 8 - 3
src/custom/utility/wechat/miniprogram/WechatMiniProgram.java

@@ -12,9 +12,9 @@ import utility.wechat.wechatpay.WechatPay;
 import java.util.Calendar;
 
 public class WechatMiniProgram extends BaseClass {
-    private String appid="";
+    private String appid = "";
     private String secret;
-    private String mch_id="";
+    private String mch_id = "";
     private String mch_key;
     private String systemclient;
 
@@ -52,6 +52,7 @@ public class WechatMiniProgram extends BaseClass {
     public String getMch_key() {
         return mch_key;
     }
+
     public String getAppId() {
         return appid;
     }
@@ -100,6 +101,10 @@ public class WechatMiniProgram extends BaseClass {
             phone_infoObject.remove("watermark");
             return phone_infoObject;
         }
+        if (resultObject.containsKey("errcode") && resultObject.getInteger("errcode") == 40001) {
+            access_token_timelimit = 0L;
+            access_token = getAccessToken();
+        }
         return resultObject;
     }
 
@@ -110,7 +115,7 @@ public class WechatMiniProgram extends BaseClass {
      * @param custip      客户端IP地址
      * @return
      */
-    public String createPayOrder(String systemclient,String orderno, String trade_type, String wechat_code, String custip,  String title,int order_amount) throws YosException {
+    public String createPayOrder(String systemclient, String orderno, String trade_type, String wechat_code, String custip, String title, int order_amount) throws YosException {
         WechatPay wechatPay = new WechatPay(systemclient);
         return wechatPay.createPayOrder(orderno, trade_type, getWechatUserID(wechat_code).getOpenid(), custip, title, order_amount);
     }