|
@@ -0,0 +1,440 @@
|
|
|
+package restcontroller.webmanage.saletool.store;
|
|
|
+
|
|
|
+import beans.attachment.Attachment;
|
|
|
+import beans.time.Time;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 门店小程序
|
|
|
+ */
|
|
|
+public class Store extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public Store(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sa_store = "sa_store";
|
|
|
+ Controller controller = this;
|
|
|
+
|
|
|
+ @API(title = "门店列表", apiversion = R.ID20240410095602.v1.class)
|
|
|
+ public String list() throws YosException {
|
|
|
+
|
|
|
+
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.storename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("storetype") && !"".equals(whereObject.getString("storetype"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.storetype='").append(whereObject.getString("storetype")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.status='").append(whereObject.getString("status")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (content.containsKey("sys_enterpriseid") && content.getLongValue("sys_enterpriseid") != 0) {
|
|
|
+ sys_enterpriseid = content.getLongValue("sys_enterpriseid");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QuerySQL listQuery = SQLFactory.createQuerySQL(controller, sa_store)
|
|
|
+ .setTableAlias("t1");
|
|
|
+ listQuery.addJoinTable(JOINTYPE.left, "sys_enterprise_hr", "t2", "t2.sys_enterprise_hrid=t1.leader_hrid and t2.siteid=t1.siteid"
|
|
|
+ , "name", "phonenumber");
|
|
|
+ listQuery.addJoinTable(JOINTYPE.left, "sys_users", "t3", "t3.userid=t2.userid "
|
|
|
+ , "accountno");
|
|
|
+ listQuery.addJoinTable(JOINTYPE.left, "sys_enterprise", "t4", "t4.sys_enterpriseid=t1.sys_enterpriseid and t4.siteid=t1.siteid"
|
|
|
+ , "enterprisename");
|
|
|
+ listQuery.setWhere("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ listQuery.setWhere(where.toString());
|
|
|
+ listQuery.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = listQuery.query();
|
|
|
+
|
|
|
+ RowsMap attinfoRows = Attachment.get(controller, sa_store, rows.toArrayList("sa_storeid", new ArrayList<>()));
|
|
|
+ for (Row row : rows) {
|
|
|
+
|
|
|
+ row.put("attinfos", attinfoRows.getOrDefault(row.getString("sa_storeid"), new Rows()));
|
|
|
+ row.put("detailaddress", row.getString("province") + row.getString("city") + row.getString("county") + row.getString("address"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店新增或编辑", apiversion = R.ID20240410095302.v1.class)
|
|
|
+ public String insertOrUpdate() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ if (sa_storeid <= 0) {
|
|
|
+ sa_storeid = createTableID(sa_store);
|
|
|
+ InsertSQL sqlFactory = SQLFactory.createInsertSQL(controller, sa_store);
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setUniqueid(sa_storeid);
|
|
|
+ sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.setValue("storename", content.getStringValue("storename"));
|
|
|
+ sqlFactory.setValue("sale_phonenmber", content.getStringValue("sale_phonenmber"));
|
|
|
+ sqlFactory.setValue("area", content.getStringValue("area"));
|
|
|
+ sqlFactory.setValue("leader_hrid", content.getLongValue("leader_hrid"));
|
|
|
+ sqlFactory.setValue("storetype", content.getStringValue("storetype"));
|
|
|
+ sqlFactory.setValue("markettype", content.getStringValue("markettype"));
|
|
|
+ sqlFactory.setValue("service_phonenmber", content.getStringValue("service_phonenmber"));
|
|
|
+ sqlFactory.setValue("latitude", content.getStringValue("latitude"));
|
|
|
+ sqlFactory.setValue("longitude", content.getStringValue("longitude"));
|
|
|
+ sqlFactory.setValue("province", content.getStringValue("province"));
|
|
|
+ sqlFactory.setValue("city", content.getStringValue("city"));
|
|
|
+ sqlFactory.setValue("county", content.getStringValue("county"));
|
|
|
+ sqlFactory.setValue("address", content.getStringValue("address"));
|
|
|
+ sqlFactory.setValue("storeno", content.getStringValue("storeno"));
|
|
|
+ sqlFactory.setValue("status", "新建");
|
|
|
+ sqlFactory.insert();
|
|
|
+
|
|
|
+ content.put("sa_storeid", sa_storeid);
|
|
|
+ }
|
|
|
+ if (sa_storeid > 0) {
|
|
|
+ UpdateSQL sqlFactory = SQLFactory.createUpdateSQL(controller, sa_store);
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setUniqueid(sa_storeid);
|
|
|
+ sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.setValue("storename", content.getStringValue("storename"));
|
|
|
+ sqlFactory.setValue("sale_phonenmber", content.getStringValue("sale_phonenmber"));
|
|
|
+ sqlFactory.setValue("area", content.getStringValue("area"));
|
|
|
+ sqlFactory.setValue("leader_hrid", content.getLongValue("leader_hrid"));
|
|
|
+ sqlFactory.setValue("storetype", content.getStringValue("storetype"));
|
|
|
+ sqlFactory.setValue("markettype", content.getStringValue("markettype"));
|
|
|
+ sqlFactory.setValue("service_phonenmber", content.getStringValue("service_phonenmber"));
|
|
|
+ sqlFactory.setValue("latitude", content.getStringValue("latitude"));
|
|
|
+ sqlFactory.setValue("longitude", content.getStringValue("longitude"));
|
|
|
+ sqlFactory.setValue("province", content.getStringValue("province"));
|
|
|
+ sqlFactory.setValue("city", content.getStringValue("city"));
|
|
|
+ sqlFactory.setValue("county", content.getStringValue("county"));
|
|
|
+ sqlFactory.setValue("address", content.getStringValue("address"));
|
|
|
+ sqlFactory.setValue("storeno", content.getStringValue("storeno"));
|
|
|
+ sqlFactory.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(controller, "sa_store_hr");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(createTableID("sa_store_hr"));
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ insertSQL.setValue("sa_storeid", sa_storeid);
|
|
|
+ insertSQL.setValue("sys_enterprise_hrid", content.getLongValue("leader_hrid"));
|
|
|
+ insertSQL.setWhere("not exists(select 1 from sa_store_hr where sys_enterprise_hrid=" + content.getLongValue("leader_hrid") + " and sa_storeid=" + sa_storeid + " and siteid='" + siteid + "')");
|
|
|
+ insertSQL.insert();
|
|
|
+ return detail();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店详情", apiversion = R.ID20240410095402.v1.class)
|
|
|
+ public String detail() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ QuerySQL detailQuery = SQLFactory.createQuerySQL(controller, sa_store).setTableAlias("t1");
|
|
|
+ detailQuery.addJoinTable(JOINTYPE.left, "sys_enterprise_hr", "t2", "t2.sys_enterprise_hrid=t1.leader_hrid and t2.siteid=t1.siteid"
|
|
|
+ , "name");
|
|
|
+ detailQuery.addJoinTable(JOINTYPE.left, "sys_users", "t3", "t3.userid=t2.userid "
|
|
|
+ , "accountno");
|
|
|
+ detailQuery.addJoinTable(JOINTYPE.left, "sys_enterprise", "t4", "t4.sys_enterpriseid=t1.sys_enterpriseid and t4.siteid=t1.siteid"
|
|
|
+ , "enterprisename");
|
|
|
+ detailQuery.addQueryFields("phonenumber", "ifnull(t2.phonenumber,t3.phonenumber)");
|
|
|
+ detailQuery.setUniqueid(sa_storeid);
|
|
|
+ Rows rows = detailQuery.query();
|
|
|
+
|
|
|
+ Row detailRow = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+
|
|
|
+ detailRow.putIfAbsent("checkdate", "");
|
|
|
+ detailRow.putIfAbsent("submitdate", "");
|
|
|
+
|
|
|
+ Rows attinfoRows = Attachment.get(controller, sa_store, sa_storeid);
|
|
|
+ detailRow.put("attinfos", attinfoRows);
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(detailRow).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店删除", apiversion = R.ID20240410095502.v1.class)
|
|
|
+ public String delete() throws YosException {
|
|
|
+
|
|
|
+ JSONArray sa_storeids = content.getJSONArray("sa_storeids");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(controller, sa_store);
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sa_storeid", sa_storeids);
|
|
|
+ querySQL.setWhere("status!='新建'");
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前状态不可删除").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(controller, sa_store);
|
|
|
+ deleteSQL.setSiteid(siteid);
|
|
|
+ deleteSQL.setWhere("sa_storeid", sa_storeids);
|
|
|
+ deleteSQL.delete();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店提交", apiversion = R.ID20240410110302.v1.class)
|
|
|
+ public String submit() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT status from sa_store WHERE sa_storeid=" + sa_storeid + " and siteid='" + siteid + "' ");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("数据不存在").toString();
|
|
|
+ }
|
|
|
+ if (!rows.get(0).getString("status").equals("新建")) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前状态不允许提交").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, sa_store);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_storeid);
|
|
|
+ updateSQL.setValue("status", "提交");
|
|
|
+ updateSQL.setValue("submitby", username);
|
|
|
+ updateSQL.setValue("submitdate", Time.getDateTime_Str());
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店撤回", apiversion = R.ID20240410110802.v1.class)
|
|
|
+ public String unsubmit() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT status from sa_store WHERE sa_storeid=" + sa_storeid + " and siteid='" + siteid + "' ");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("数据不存在").toString();
|
|
|
+ }
|
|
|
+ if (!rows.get(0).getString("status").equals("提交")) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前状态不允许撤回").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, sa_store);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_storeid);
|
|
|
+ updateSQL.setValue("status", "新建");
|
|
|
+ updateSQL.setValue("submitby", "null");
|
|
|
+ updateSQL.setValue("submitdate", "null");
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店退回", apiversion = R.ID20240410135402.v1.class)
|
|
|
+ public String returnBack() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT status from sa_store WHERE sa_storeid=" + sa_storeid + " and siteid='" + siteid + "' ");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("数据不存在").toString();
|
|
|
+ }
|
|
|
+ if (!rows.get(0).getString("status").equals("提交")) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前状态不允许退回").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, sa_store);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_storeid);
|
|
|
+ updateSQL.setValue("status", "新建");
|
|
|
+ updateSQL.setValue("submitby", "null");
|
|
|
+ updateSQL.setValue("submitdate", "null");
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店审核", apiversion = R.ID20240410141002.v1.class)
|
|
|
+ public String check() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT status from sa_store WHERE sa_storeid=" + sa_storeid + " and siteid='" + siteid + "' ");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("数据不存在").toString();
|
|
|
+ }
|
|
|
+ if (!rows.get(0).getString("status").equals("提交")) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前状态不允许审核").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, sa_store);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_storeid);
|
|
|
+ updateSQL.setValue("status", "审核");
|
|
|
+ updateSQL.setValue("checkby", username);
|
|
|
+ updateSQL.setValue("checkdate", Time.getDateTime_Str());
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店反审核", apiversion = R.ID20240410141402.v1.class)
|
|
|
+ public String uncheck() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT status from sa_store WHERE sa_storeid=" + sa_storeid + " and siteid='" + siteid + "' ");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("数据不存在").toString();
|
|
|
+ }
|
|
|
+ if (!rows.get(0).getString("status").equals("审核")) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前状态不允许反审核").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, sa_store);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_storeid);
|
|
|
+ updateSQL.setValue("status", "新建");
|
|
|
+ updateSQL.setValue("checkby", "null");
|
|
|
+ updateSQL.setValue("checkdate", "null");
|
|
|
+ updateSQL.setValue("submitby", "null");
|
|
|
+ updateSQL.setValue("submitdate", "null");
|
|
|
+ updateSQL.update();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "选择负责人(添加门店人员)", apiversion = R.ID20240410142002.v1.class)
|
|
|
+ public String chooseLeader() throws YosException {
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sys_enterprise_hr"
|
|
|
+ , "sys_enterprise_hrid", "name", "position", "phonenumber", "isleader", "userid")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ querySQL.setWhere(" not exists(select 1 from sa_store where leader_hrid=t1.sys_enterprise_hrid and sa_storeid=" + sa_storeid + " and siteid='" + siteid + "')");
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ //查询角色
|
|
|
+ RowsMap roleRowsMap = StoreHelper.getRoleRowsMap(controller, rows.toArray("userid"));
|
|
|
+ //查询门店
|
|
|
+ RowsMap storeRowsMap = StoreHelper.getStoreRowsMap(controller, rows.toArray("sys_enterprise_hrid"));
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("headpic", getHeadPic(row.getLong("userid")));
|
|
|
+ Rows roleRows = roleRowsMap.getOrDefault(row.getString("userid"), new Rows());
|
|
|
+ row.put("rolenames", String.join(",", roleRows.toArrayList("rolename")));
|
|
|
+
|
|
|
+ Rows storeRows = storeRowsMap.getOrDefault(row.getString("sys_enterprise_hrid"), new Rows());
|
|
|
+ row.put("storenames", String.join(",", storeRows.toArrayList("storename")));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "门店人员", apiversion = R.ID20240410150702.v1.class)
|
|
|
+ public String storeHrs() throws YosException {
|
|
|
+
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sys_enterprise_hr"
|
|
|
+ , "sys_enterprise_hrid", "name", "position", "phonenumber", "isleader", "userid","createby","createdate","changeby","changedate")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sa_store_hr", "t2", "t2.sys_enterprise_hrid=t1.sys_enterprise_hrid and t2.siteid=t1.siteid"
|
|
|
+ , "sa_store_hrid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_users", "t3", "t3.userid=t1.userid "
|
|
|
+ , "accountno");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ querySQL.setWhere("t2.sa_storeid", sa_storeid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ //查询角色
|
|
|
+ RowsMap roleRowsMap = StoreHelper.getRoleRowsMap(controller, rows.toArray("userid"));
|
|
|
+ //查询门店
|
|
|
+ RowsMap storeRowsMap = StoreHelper.getStoreRowsMap(controller, rows.toArray("sys_enterprise_hrid"));
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("headpic", getHeadPic(row.getLong("userid")));
|
|
|
+ Rows roleRows = roleRowsMap.getOrDefault(row.getString("userid"), new Rows());
|
|
|
+ row.put("rolenames", String.join(",", roleRows.toArrayList("rolename")));
|
|
|
+
|
|
|
+ Rows storeRows = storeRowsMap.getOrDefault(row.getString("sys_enterprise_hrid"), new Rows());
|
|
|
+ row.put("storenames", String.join(",", storeRows.toArrayList("storename")));
|
|
|
+
|
|
|
+ row.putIfAbsent("createdate","");
|
|
|
+ row.putIfAbsent("changedate","");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "添加门店人员", apiversion = R.ID20240410153502.v1.class)
|
|
|
+ public String addstoreHrs() throws YosException {
|
|
|
+ Long sa_storeid = content.getLongValue("sa_storeid");
|
|
|
+ JSONArray sys_enterprise_hrids = content.getJSONArray("sys_enterprise_hrids");
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ for (Object object : sys_enterprise_hrids) {
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(controller, "sa_store_hr");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(createTableID("sa_store_hr"));
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ insertSQL.setValue("sa_storeid", sa_storeid);
|
|
|
+ insertSQL.setValue("sys_enterprise_hrid", object);
|
|
|
+ insertSQL.setWhere("not exists(select 1 from sa_store_hr where sys_enterprise_hrid=" + object + " and sa_storeid=" + sa_storeid + " and siteid='" + siteid + "')");
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "删除门店人员", apiversion = R.ID20240410153602.v1.class)
|
|
|
+ public String deleteStoreHrs() throws YosException {
|
|
|
+
|
|
|
+ JSONArray sa_store_hrids = content.getJSONArray("sa_store_hrids");
|
|
|
+
|
|
|
+ DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(controller, "sa_store_hr");
|
|
|
+ deleteSQL.setSiteid(siteid);
|
|
|
+ deleteSQL.setWhere("sa_store_hrid", sa_store_hrids);
|
|
|
+ deleteSQL.delete();
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|