瀏覽代碼

微信账号绑定逻辑调整

eganwu 1 年之前
父節點
當前提交
d1f13b5abe
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13 3
      src/custom/restcontroller/common/usercenter/usercenter.java

+ 13 - 3
src/custom/restcontroller/common/usercenter/usercenter.java

@@ -307,13 +307,13 @@ public class usercenter extends Controller {
      *
      * @return
      */
-    @API(title = "微信账号绑定", apiversion = R.ID20240516090402.v1.class,accesstoken = false)
+    @API(title = "微信账号绑定", apiversion = R.ID20240516090402.v1.class, accesstoken = false)
     @CACHEING_CLEAN(cms = {@cm(clazz = usercenter.class, method = {"queryUserMsg"})})
     public String WechatBinding() throws YosException {
         String wechat_code = content.getString("wechat_code");
         boolean isbinging = content.getBooleanValue("isbinging");
-        if(content.containsKey("userid")&&content.getLongValue("userid")>0){
-            userid=content.getLongValue("userid");
+        if (content.containsKey("userid") && content.getLongValue("userid") > 0) {
+            userid = content.getLongValue("userid");
         }
         if (isbinging) {
             Rows openidsRows = dbConnect.runSqlQuery("select * from sys_wechatapp_openids where userid='" + userid + "' and systemclient='" + systemclient + "'");
@@ -334,6 +334,10 @@ public class usercenter extends Controller {
         ArrayList<String> sqllist = new ArrayList<>();
         if (openid != null && !openid.equals("")) {
             if (isbinging) {
+                Rows openidsRows = dbConnect.runSqlQuery("select * from sys_wechatapp_openids where openid='" + openid + "' and systemclient='" + systemclient + "'");
+                if (openidsRows.isNotEmpty()) {
+                    return getErrReturnObject().setErrMsg("当前微信号已绑定账号!").toJSONString();
+                }
                 SQLFactory sqlFactory = new SQLFactory(this, "绑定微信openid");
                 sqlFactory.addParameter("wechatapp_openidsid", createTableID("sys_wechatapp_openids"));
                 sqlFactory.addParameter("systemclient", systemclient);
@@ -350,6 +354,12 @@ public class usercenter extends Controller {
         }
         if (unionid != null && !unionid.equals("")) {
             if (isbinging) {
+
+                Rows openidsRows = dbConnect.runSqlQuery("select * from sys_wechatapp_unionids where unionid='" + unionid + "' and systemclient='" + systemclient + "'");
+                if (openidsRows.isNotEmpty()) {
+                    return getErrReturnObject().setErrMsg("当前微信号已绑定账号!").toJSONString();
+                }
+
                 SQLFactory sqlFactory = new SQLFactory(this, "绑定微信unionid");
                 sqlFactory.addParameter("wechatapp_unionidsid", createTableID("sys_wechatapp_unionids"));
                 sqlFactory.addParameter("unionid", unionid);