|
|
@@ -1,16 +1,15 @@
|
|
|
package restcontroller.sale.team;
|
|
|
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
import beans.user.User;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import common.Controller;
|
|
|
import common.YosException;
|
|
|
-import common.annotation.API;
|
|
|
-import common.annotation.CACHEING;
|
|
|
-import common.annotation.CACHEING_CLEAN;
|
|
|
-import common.annotation.cm;
|
|
|
+import common.annotation.*;
|
|
|
import common.data.*;
|
|
|
import common.data.db.SQLList;
|
|
|
+import common.password.UserPassword;
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
@@ -47,8 +46,7 @@ public class team extends Controller {
|
|
|
// sqlFactory.addParameter_SQL("where", where);
|
|
|
// Rows hrrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise_hr", "sys_enterprise_hrid", "name",
|
|
|
- "position", "isleader", "phonenumber", "remarks", "email", "userid", "authmodel", "isagent");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise_hr", "sys_enterprise_hrid", "name", "position", "isleader", "phonenumber", "remarks", "email", "userid", "authmodel", "isagent");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.inner, "sys_users", "t2", "t1.userid = t2.userid and t2.status!='DELETED'", "accountno");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_usertrialperiod", "t4", "t4.userid=t1.userid and t4.siteid=t1.siteid");
|
|
|
@@ -121,7 +119,9 @@ public class team extends Controller {
|
|
|
String position = content.getString("position");
|
|
|
String remarks = content.getString("remarks");
|
|
|
Long roleid = content.getLong("roleid");
|
|
|
-
|
|
|
+ String password = content.getString("password");//md5加密
|
|
|
+ boolean userdatalimit = content.getBoolean("userdatalimit");//仅可查询本人客户、客户订单
|
|
|
+ boolean storedatalimit = content.getBoolean("storedatalimit");//仅可处理门店数据
|
|
|
// int usertype = 22;//经销商子账号用户类型
|
|
|
ArrayList<Long> newroleidList = new ArrayList<>();
|
|
|
newroleidList.add(roleid);
|
|
|
@@ -142,7 +142,12 @@ public class team extends Controller {
|
|
|
// newroleidList.addAll(defaultrole.toArrayList("roleid", new ArrayList<>()));
|
|
|
Rows sys_enterprise_hrRows = dbConnect.runSqlQuery("select userid from sys_enterprise_hr where siteid='" + siteid + "'and sys_enterpriseid='" + sys_enterpriseid + "' and sys_enterprise_hrid=" + sys_enterprise_hrid);
|
|
|
if (sys_enterprise_hrid <= 0 || sys_enterprise_hrRows.isEmpty()) {
|
|
|
- User.createUser(this, sys_enterpriseid, name, phonenumber, false, position, 21, ArrayUtils.toPrimitive(newroleidList.toArray(new Long[]{})), "");
|
|
|
+ long id = User.createUser(this, sys_enterpriseid, name, phonenumber, false, position, 21, ArrayUtils.toPrimitive(newroleidList.toArray(new Long[]{})), "");
|
|
|
+ UpdateSQL sysEnterpriseHr = SQLFactory.createUpdateSQL(this, "sys_enterprise_hr");
|
|
|
+ sysEnterpriseHr.setValue("userdatalimit", userdatalimit);
|
|
|
+ sysEnterpriseHr.setValue("storedatalimit", storedatalimit);
|
|
|
+ sysEnterpriseHr.setValue("password", UserPassword.create(password));
|
|
|
+ sysEnterpriseHr.setSiteid(siteid).setWhere("sys_enterpriseid", sys_enterpriseid).setWhere("userid", id);
|
|
|
} else {
|
|
|
SQLList sqllist = new SQLList();
|
|
|
SQLFactory modifyusersql = new SQLFactory(this, "团队成员修改");
|
|
|
@@ -155,6 +160,8 @@ public class team extends Controller {
|
|
|
modifyusersql.addParameter("position", position);
|
|
|
modifyusersql.addParameter("remarks", remarks);
|
|
|
modifyusersql.addParameter("changeuserid", userid);
|
|
|
+ modifyusersql.addParameter("userdatalimit", userdatalimit ? 1 : 0);
|
|
|
+ modifyusersql.addParameter("storedatalimit", storedatalimit ? 1 : 0);
|
|
|
sqllist.add(modifyusersql.getSQL());
|
|
|
|
|
|
/*
|
|
|
@@ -207,6 +214,31 @@ public class team extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 团队人员账号密码设置
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @API(title = "团队人员账号密码设置", apiversion = R.ID2026052015501001.v1.class, params = {
|
|
|
+ @Param(paramname = "password", remarks = "密码", isrequired = true, fieldtype = FieldType.Varchar),
|
|
|
+ @Param(paramname = "sys_enterprise_hrid", remarks = "团队人员id", isrequired = true, fieldtype = FieldType.Varchar)}
|
|
|
+ )
|
|
|
+ public String setPassword() throws YosException {
|
|
|
+ String password = content.getString("password");//md5加密
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise_hr");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ querySQL.setWhere("sys_enterprise_hrid", content.getLong("sys_enterprise_hrid"));
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("团队人员不存在").toString();
|
|
|
+ }
|
|
|
+ UserPassword.create(rows.get(0).getLong("userid"), password);
|
|
|
+ DataContrlLog.createLog(this, "sys_users", userid, "密码重置", "密码重置成功").insert();
|
|
|
+ loguserout(userid);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
@API(title = "删除团队成员", apiversion = R.ID20221107094804.v1.class)
|
|
|
@CACHEING_CLEAN(cms = {@cm(clazz = team.class, method = {"query_teamList"})})
|
|
|
public String deleteHr() throws YosException {
|