Przeglądaj źródła

获取验证码及登陆接口新增client请求来源字段

沈静伟 4 lat temu
rodzic
commit
8aef2462d6

+ 7 - 0
src/dsb/com/cnd3b/common/parameter/parameter.java

@@ -28,6 +28,13 @@ public class parameter {
      * 登录-手机号、验证码
      */
     public static HashMap<String, String> phonenumber_password = new HashMap<>(16);
+
+    /**
+     * 登陆-验证码,来源
+     */
+    public static HashMap<String, String> password_client = new HashMap<>(16);
+
+
     /**
      * 登录-验证码、有效期
      */

+ 4 - 7
src/dsb/com/cnd3b/common/restful/SQL/手机账号列表查询.sql → src/dsb/com/cnd3b/common/restful/SQL/客户端手机账号列表查询.sql

@@ -12,12 +12,10 @@ select t1.tenterprise_userid
        t1.fissysadministrator,
        t5.fappmodel,
        case
-           when t6.tpayinfoid IS null and ((t1.fusertype = '经销商' and t5.fagentamount > 0) or
-                                           (t1.fusertype = '企业' and t5.FENTERPRISEUSERAMOUNT > 0)) then 1
+           when t6.tpayinfoid IS null and t5.fagentamount > 0 then 1
            else 0 end                                                                as fisneedpay,
        case
-           when t6.tpayinfoid IS null and t1.fusertype = '经销商' then t5.fagentamount
-           when t6.tpayinfoid IS null and t1.fusertype = '企业' then t5.FENTERPRISEUSERAMOUNT
+           when t6.tpayinfoid IS null then t5.fagentamount
            else 0 end                                                                as fpayamount,
        t5.fagentoldamount,
        t2.floginmode,
@@ -27,7 +25,6 @@ from tenterprise_users t1
          inner join tenterprise t2 on t1.siteid = t2.siteid
          left join tagents t3 on t1.siteid = t3.siteid and t1.tagentsid = t3.tagentsid
          inner join tappmodelauth t5 on t1.siteid = t5.siteid and t5.fisdefault = 1
-         left join tpayinfo t6 on t1.siteid = t6.siteid and ((t1.fusertype = '经销商' and t1.tagentsid = t6.tagentsid) or
-                                                             (t1.fusertype = '企业' and t1.tenterprise_userid = t6.tenterprise_userid)) and
+         left join tpayinfo t6 on t1.siteid = t6.siteid and t1.tagentsid = t6.tagentsid and
                                   t6.fbegdate <= GETDATE() and t6.fenddate >= GETDATE()
-where t1.fphonenumber =$fphonenumber$ and t2.floginmode in (1, 3) and t1.fisused=1
+where t1.fphonenumber =$fphonenumber$ and t2.floginmode in (1, 3) and t1.fisused=1 and t1.fusertype = '经销商'

+ 24 - 0
src/dsb/com/cnd3b/common/restful/SQL/管理端手机账号列表查询.sql

@@ -0,0 +1,24 @@
+select t1.tenterprise_userid                                                         as userid,
+       t1.fphonenumber,
+       t1.siteid,
+       t1.tagentsid,
+       t3.fagentname,
+       t3.fagentnum,
+       t3.fagentname,
+       t1.fusertype,
+       t1.frole,
+       t1.fname,
+       t1.fisadministrator,
+       t1.fissysadministrator,
+       t5.fappmodel,
+       0                                                                as fisneedpay,
+       0                                                                as fpayamount,
+       t5.fagentoldamount,
+       t2.floginmode,
+       t2.tenterpriseid,
+       t3.ftype as fagenttype
+from tenterprise_users t1
+         inner join tenterprise t2 on t1.siteid = t2.siteid
+         left join tagents t3 on t1.siteid = t3.siteid and t1.tagentsid = t3.tagentsid
+         inner join tappmodelauth t5 on t1.siteid = t5.siteid and t5.fisdefault = 1
+where t1.fphonenumber =$fphonenumber$ and t2.floginmode in (1, 3) and t1.fisused=1 and t1.fusertype = 'ÆóÒµ'

+ 23 - 11
src/dsb/com/cnd3b/common/restful/WebClientRest.java

@@ -256,7 +256,7 @@ public class WebClientRest {
             }
         }
         String phonenumber = requestcontent.getString("phonenumber");
-        String client = "";
+        String client = "";//登陆来源,web_manage、web_customer、wechat_customer
         if (requestcontent.containsKey("client")) {
             client = requestcontent.getString("client");
         }
@@ -270,6 +270,7 @@ public class WebClientRest {
 
         String password = createPassWord();
         parameter.phonenumber_password.put(phonenumber, password);
+        parameter.password_client.put(password, client);
         Calendar calendar = Calendar.getInstance();
         calendar.add(Calendar.MINUTE, 5);
         parameter.phonenumber_date.put(phonenumber, calendar.getTime());
@@ -333,6 +334,12 @@ public class WebClientRest {
         String phonenumber = requestcontent.getString("phonenumber");
         String password = requestcontent.getString("password");
 
+        String login_client_ = "";//登陆来源,web_manage、web_customer、wechat_customer
+        if (requestcontent.containsKey("client")) {
+            login_client_ = requestcontent.getString("client");
+        }
+
+        String password_client_ = "";//登陆来源,web_manage、web_customer、wechat_customer
         int resultcode;
         DBConnect connect = new DBConnect();
         if (!parameter.phonenumber_password.containsKey(phonenumber)) {
@@ -344,21 +351,27 @@ public class WebClientRest {
             String syspassword = parameter.phonenumber_password.get(phonenumber);
             if (password.equals(new Encryption().Encode_MD5(syspassword))) {
                 resultcode = 0;//验证码正确
+                password_client_ = parameter.password_client.get(syspassword);
+                if (!login_client_.equals(password_client_)) {
+                    resultcode = 4;
+                }
             } else {
                 resultcode = 3;//验证码错误
             }
         }
-
+        boolean isweb_manage = login_client_.equals("web_manage");//是否管理端登陆
         int isnewregister = 0;
         if (resultcode == 0 || Arrays.asList(nocheckphonenumber).contains(phonenumber)) {
-            //登陆时,如果验证码验证成功,但是手机号未注册过,则自动进行注册!
-            if (connect.runSqlQuery("select * from tenterprise_users where fisused=1 and fphonenumber='" + phonenumber + "'").isEmpty()) {
-                Users users = new Users(requestcontent);
-                users.register_usersByLogin(phonenumber);
-                isnewregister = 1;
+            if (!isweb_manage) {
+                //登陆时,如果验证码验证成功,但是手机号未注册过,则自动进行注册!
+                if (connect.runSqlQuery("select * from tenterprise_users where fisused=1 and fphonenumber='" + phonenumber + "'").isEmpty()) {
+                    Users users = new Users(requestcontent);
+                    users.register_usersByLogin(phonenumber);
+                    isnewregister = 1;
+                }
             }
-
-            SQLFactory factory = new SQLFactory(this, "手机账号列表查询");
+            //web管理端登陆
+            SQLFactory factory = new SQLFactory(this, isweb_manage ? "管理端手机账号列表查询" : "客户端手机账号列表查询");
             factory.addParameter("fphonenumber", phonenumber);
             Rows rows = connect.runSqlQuery(factory.getSQL());
 
@@ -380,7 +393,6 @@ public class WebClientRest {
                  */
                 connect.runSqlUpdate(tokensaveList);
             }
-
             JSONObject object = new JSONObject();
             object.put("code", 1);
             object.put("msg", "成功");
@@ -399,7 +411,7 @@ public class WebClientRest {
                 msg = "请先获取所填手机号验证码!";
             } else if (resultcode == 2) {
                 msg = "验证码已失效,请重新获取!";
-            } else if (resultcode == 3) {
+            } else if (resultcode == 3 || resultcode == 4) {
                 msg = "无效的验证码!";
             }
             JSONObject object = new JSONObject();