|
@@ -9,16 +9,15 @@ import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
import common.annotation.cm;
|
|
|
-import common.data.Row;
|
|
|
-import common.data.Rows;
|
|
|
-import common.data.RowsMap;
|
|
|
-import common.data.SQLFactory;
|
|
|
+import common.data.*;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
+import static restcontroller.webmanage.sale.enterprise.enterprise.validatePhoneNumber;
|
|
|
+
|
|
|
@API(title = "管理端-账号管理")
|
|
|
public class users extends Controller {
|
|
|
public users(JSONObject content) throws YosException {
|
|
@@ -146,6 +145,10 @@ public class users extends Controller {
|
|
|
String accountno = accountprefix + content.getStringValue("accountno");
|
|
|
JSONArray roleids = content.getJSONArray("roleids");
|
|
|
|
|
|
+ boolean isValidPhoneNumber = validatePhoneNumber(changephonenumber);
|
|
|
+ if (!isValidPhoneNumber) {
|
|
|
+ return getErrReturnObject().setErrMsg("请输入正确的手机号").toString();
|
|
|
+ }
|
|
|
|
|
|
if (dbConnect.runSqlQuery("select *from sys_users where phonenumber='" + changephonenumber + "' and userid!='" + changeuserid + "'").isNotEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("存在重复的手机号信息").toString();
|
|
@@ -168,11 +171,26 @@ public class users extends Controller {
|
|
|
usertype = row.get(0).getInteger("usertype");
|
|
|
}
|
|
|
}
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+ //经销商
|
|
|
+ sys_enterpriseid = content.getLongValue("sys_enterpriseid");
|
|
|
+ if (usertype == 21 || usertype == 22) {
|
|
|
+ if (sys_enterpriseid <= 0) {
|
|
|
+ return getErrReturnObject().setErrMsg("请选择经销商").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (usertype == 21 && changeuserid == 0) {
|
|
|
+ if (dbConnect.runSqlQuery("select * from sys_enterprise_hr where sys_enterpriseid='" + sys_enterpriseid + "' and isleader=1 and siteid='" + siteid + "'").isNotEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("创建失败,已存在负责人账号").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
Rows defaultrole = dbConnect.runSqlQuery("select roleid from sys_role where siteid='" + siteid + "' and usertype='" + usertype + "' and issystem=1");
|
|
|
roleidslist.addAll(defaultrole.toArrayList("roleid", new ArrayList<>()));
|
|
|
|
|
|
- ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+
|
|
|
if (changeuserid <= 0 || dbConnect.runSqlQuery("select userid from sys_users where userid=" + changeuserid).isEmpty()) {
|
|
|
CreateUserFactory createUserFactory;
|
|
|
if (accountno.isEmpty()) {
|
|
@@ -185,7 +203,8 @@ public class users extends Controller {
|
|
|
}
|
|
|
|
|
|
sqllist.addAll(createUserFactory.getSQL());
|
|
|
- content.put("userid", createUserFactory.getUserid());
|
|
|
+ changeuserid=createUserFactory.getUserid();
|
|
|
+ content.put("userid", changeuserid);
|
|
|
} else {
|
|
|
if (accountno.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("账号不能为空").toString();
|
|
@@ -217,6 +236,33 @@ public class users extends Controller {
|
|
|
sqllist.add(deleterole.getSQL());
|
|
|
}
|
|
|
String[] oldroleids = dbConnect.runSqlQuery("select roleid from sys_userrole where siteid='" + siteid + "' and userid='" + changeuserid + "' order by roleid").toArray("roleid");
|
|
|
+
|
|
|
+ if (usertype == 21 || usertype == 22) {
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sys_enterprise_hr where siteid='" + siteid + "' and sys_enterpriseid=" + sys_enterpriseid + " and userid=" + changeuserid );
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_hr");
|
|
|
+ insertSQL.setValue("siteid", siteid);
|
|
|
+ insertSQL.setValue("sys_enterprise_hrid", createTableID("sys_enterprise_hr"));
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ insertSQL.setValue("userid", changeuserid);
|
|
|
+ insertSQL.setValue("phonenumber", changephonenumber);
|
|
|
+ insertSQL.setValue("isleader", usertype == 21 ? 1 : 0);
|
|
|
+ insertSQL.setValue("position", usertype == 21 ? "负责人" : "");
|
|
|
+ insertSQL.setValue("name", changename);
|
|
|
+ insertSQL.setValue("remarks", "");
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ } else {
|
|
|
+ Long sys_enterprise_hrid = rows.get(0).getLong("sys_enterprise_hrid");
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise_hr");
|
|
|
+ updateSQL.setUniqueid(sys_enterprise_hrid).setSiteid(siteid);
|
|
|
+ updateSQL.setValue("phonenumber", changephonenumber);
|
|
|
+ updateSQL.setValue("name", changename);
|
|
|
+ updateSQL.setValue("remarks", "");
|
|
|
+ sqllist.add(updateSQL.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
dbConnect.runSqlUpdate(sqllist);
|
|
|
if (userid != changeuserid) {
|
|
|
String[] newroleids = dbConnect.runSqlQuery("select roleid from sys_userrole where siteid='" + siteid + "' and userid='" + changeuserid + "' order by roleid").toArray("roleid");
|