|
|
@@ -12,6 +12,7 @@ import common.annotation.CACHEING_CLEAN;
|
|
|
import common.annotation.cm;
|
|
|
import common.data.*;
|
|
|
import restcontroller.R;
|
|
|
+import restcontroller.sale.serviceorder.serviceorder;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
@@ -295,6 +296,73 @@ public class users extends Controller {
|
|
|
return query_userMain();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "通过手机号查询美大终端客户id", apiversion = R.ID2025082114391803.v1.class)
|
|
|
+ public String querycustomer() throws YosException {
|
|
|
+ String phonenumber = content.getString("phonenumber");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_customers where sa_agentsid!=0 and siteid='"+siteid+"' and phonenumber='"+phonenumber+"'");
|
|
|
+ Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "创建美大终端客户", apiversion = R.ID2025082114174203.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiversions = {users.class})
|
|
|
+ public String inser_user() throws YosException {
|
|
|
+ long userid = 0;//新增时传0
|
|
|
+ String name = content.getString("name");
|
|
|
+ String phonenumber = content.getString("phonenumber");
|
|
|
+ String remarks = content.getString("remarks");
|
|
|
+ String accountno = "美大用户"+phonenumber.substring(phonenumber.length() - 4);
|
|
|
+
|
|
|
+ boolean isValidPhoneNumber = validatePhoneNumber(phonenumber);
|
|
|
+ if (!isValidPhoneNumber) {
|
|
|
+ return getErrReturnObject().setErrMsg("请输入正确的手机号").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_customers where sa_agentsid!=0 and siteid='"+siteid+"' and phonenumber='"+phonenumber+"'");
|
|
|
+ if(rows.isEmpty()){
|
|
|
+ return getSucReturnObject().setData(false).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (dbConnect.runSqlQuery("select *from sys_users where phonenumber='" + phonenumber + "' and userid!='" + userid + "'").isNotEmpty()) {
|
|
|
+ return getSucReturnObject().setData(true).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<Long> roleidslist = new ArrayList<>();
|
|
|
+ /*
|
|
|
+ 根据用户类型查找新账号默认角色
|
|
|
+ */
|
|
|
+ int usertype = 99;
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ 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<>()));
|
|
|
+
|
|
|
+ CreateUserFactory createUserFactory;
|
|
|
+ if (accountno.isEmpty()) {
|
|
|
+ createUserFactory = new CreateUserFactory(this, name, phonenumber, usertype, roleidslist.toArray(new Long[]{}), remarks);
|
|
|
+ } else {
|
|
|
+ String accountprefix = Parameter.getString(siteid, "accountprefix");
|
|
|
+ accountno = accountprefix + accountno;
|
|
|
+ if (dbConnect.runSqlQuery("SELECT 1 from sys_users WHERE accountno ='" + accountno + "' ").isNotEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前账号【" + accountno + "】已存在").toString();
|
|
|
+ }
|
|
|
+ createUserFactory = new CreateUserFactory(this, accountno, name, phonenumber, usertype, roleidslist.toArray(new Long[]{}), remarks);
|
|
|
+ }
|
|
|
+
|
|
|
+ sqllist.addAll(createUserFactory.getSQL());
|
|
|
+ userid = createUserFactory.getUserid();
|
|
|
+ content.put("userid", userid);
|
|
|
+ sqllist.add(DataContrlLog.createLog(this,"sys_users",userid,"新增","新增用户成功").getSQL());
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(true).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@API(title = "登陆账号变更")
|
|
|
@CACHEING_CLEAN(cms = {@cm(clazz = users.class, method = {"query_userList", "query_userMain"})})
|
|
|
public String changeAccountno() throws YosException {
|