Browse Source

调整登陆接口,手机号未注册可以正常获取登陆验证码,当手机号未注册时,输入验证码后系统将自动进行注册操作。

沈静伟 4 years ago
parent
commit
1399fcb7ce

+ 15 - 9
src/dsb/com/cnd3b/common/restful/WebClientRest.java

@@ -1,5 +1,6 @@
 package com.cnd3b.common.restful;
 
+import com.cnd3b.restcontroller.publicmethod.users.Users;
 import com.cnd3b.utility.Encryption;
 import com.alibaba.fastjson.JSONException;
 import com.alibaba.fastjson.JSONObject;
@@ -60,7 +61,7 @@ public class WebClientRest {
         String[] mustkeys = {"classname", "method", "content"};
         for (String mustkey : mustkeys) {
             if (!requestcontent.containsKey(mustkey)) {
-                return new D3BReturnObject_Err().setErrMsg("json缺少KEY"+mustkey).toString();
+                return new D3BReturnObject_Err().setErrMsg("json缺少KEY" + mustkey).toString();
             }
         }
         /**
@@ -257,14 +258,13 @@ public class WebClientRest {
         if (requestcontent.containsKey("client")) {
             client = requestcontent.getString("client");
         }
-
-        DBConnect dbConnect = new DBConnect();
-        if (dbConnect.runSqlQuery("select *from tenterprise_users where fphonenumber='" + phonenumber + "'").isEmpty()) {
-            JSONObject object = new JSONObject();
-            object.put("code", 0);
-            object.put("msg", "当前手机号未注册!");
-            return object.toString();
-        }
+//        DBConnect dbConnect = new DBConnect();
+//        if (dbConnect.runSqlQuery("select * from tenterprise_users where fphonenumber='" + phonenumber + "'").isEmpty()) {
+//            JSONObject object = new JSONObject();
+//            object.put("code", 0);
+//            object.put("msg", "当前手机号未注册!");
+//            return object.toString();
+//        }
 
         String password = createPassWord();
         parameter.phonenumber_password.put(phonenumber, password);
@@ -347,6 +347,12 @@ public class WebClientRest {
         }
 
         if (resultcode == 0 || Arrays.asList(nocheckphonenumber).contains(phonenumber)) {
+            //登陆时,如果验证码验证成功,但是手机号未注册过,则自动进行注册!
+            if (connect.runSqlQuery("select * from tenterprise_users where fphonenumber='" + phonenumber + "'").isEmpty()) {
+                Users users = new Users(requestcontent);
+                users.register_usersByLogin(phonenumber);
+            }
+
             SQLFactory factory = new SQLFactory(this, "手机账号列表查询");
             factory.addParameter("fphonenumber", phonenumber);
             Rows rows = connect.runSqlQuery(factory.getSQL());

+ 30 - 1
src/dsb/com/cnd3b/restcontroller/publicmethod/users/Users.java

@@ -20,6 +20,35 @@ public class Users extends Controller {
         super(content);
     }
 
+    /**
+     * 登陆时如果没有注册则自动注册
+     *
+     * @return
+     */
+    public void register_usersByLogin(String fphonenumber) {
+        PaoSetRemote tagentsSet = null;
+        try {
+            tagentsSet = getP2ServerSystemPaoSet("tagents");
+            PaoRemote tagents = tagentsSet.addAtEnd();
+            tagents.setValue("siteid", "BWJ", 11L);//企业ID
+            tagents.setValue("createdate", getDateTime(), 11L);//录入时间
+            tagents.setValue("fphonenumber", fphonenumber, 11L);
+            tagents.setValue("fjoindate", getDateTime(), 11L);
+            tagents.setValue("ftype", "个人", 11L);
+            tagentsSet.save();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (tagentsSet != null) {
+                    tagentsSet.close();
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
     /**
      * 个人账号注册
      *
@@ -50,7 +79,7 @@ public class Users extends Controller {
             tagents.setValue("createdate", getDateTime(), 11L);//录入时间
             tagents.setValue("fphonenumber", fphonenumber, 11L);
             tagents.setValue("fjoindate", getDateTime(), 11L);
-            tagents.setValue("ftype","个人", 11L);
+            tagents.setValue("ftype", "个人", 11L);
             tagentsSet.save();
 
             WebClientRest rest = new WebClientRest();