|
|
@@ -0,0 +1,240 @@
|
|
|
+package restcontroller.webmanage.saletool.feedback;
|
|
|
+
|
|
|
+import beans.attachment.Attachment;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.mysql.cj.x.protobuf.MysqlxCrud;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 意见反馈
|
|
|
+ */
|
|
|
+
|
|
|
+public class FeedBack extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public FeedBack(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "意见反馈新增或编辑", apiversion = R.ID20240517102502.v1.class)
|
|
|
+ public String insertOrUpdate() throws YosException {
|
|
|
+ Long sa_feedbackid = content.getLongValue("sa_feedbackid");
|
|
|
+
|
|
|
+ if (sa_feedbackid <= 0) {
|
|
|
+ sa_feedbackid = createTableID("sa_feedback");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_feedback");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(sa_feedbackid);
|
|
|
+ insertSQL.setValue("type", content.getStringValue("type"));
|
|
|
+ insertSQL.setValue("depname", getDepartment(userid).getString("depname"));
|
|
|
+ insertSQL.setValue("phonenumber", getUser(userid).getString("phonenumber"));
|
|
|
+ insertSQL.setValue("remarks", content.getStringValue("remarks"));
|
|
|
+ insertSQL.setValue("name", username);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ insertSQL.setValue("areaname", userInfo.getAreaName(this));
|
|
|
+ insertSQL.insert();
|
|
|
+ content.put("sa_feedbackid", sa_feedbackid);
|
|
|
+ } else {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_feedback");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_feedbackid);
|
|
|
+ updateSQL.setValue("type", content.getStringValue("type"));
|
|
|
+ updateSQL.setValue("depname", getDepartment(userid).getString("depname"));
|
|
|
+ updateSQL.setValue("phonenumber", getUser(userid).getString("phonenumber"));
|
|
|
+ updateSQL.setValue("remarks", content.getStringValue("remarks"));
|
|
|
+ updateSQL.setValue("name", username);
|
|
|
+ updateSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ updateSQL.setValue("areaname", userInfo.getAreaName(this));
|
|
|
+ updateSQL.update();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return detail();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "意见反馈详情", apiversion = R.ID20240517102602.v1.class)
|
|
|
+ public String detail() throws YosException {
|
|
|
+ Long sa_feedbackid = content.getLongValue("sa_feedbackid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_feedback").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setUniqueid(sa_feedbackid);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getSucReturnObject().setData(new Row()).toString();
|
|
|
+ }
|
|
|
+ Row row = rows.get(0);
|
|
|
+ row.put("attinfos", Attachment.get(this, "sa_feedback", sa_feedbackid));
|
|
|
+ row.put("depareaname", row.getString("depname") + row.getString("areaname"));
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "意见反馈删除", apiversion = R.ID20240517102702.v1.class)
|
|
|
+ public String delete() throws YosException {
|
|
|
+ JSONArray sa_feedbackids = content.getJSONArray("sa_feedbackids");
|
|
|
+ if (sa_feedbackids.size() == 0) {
|
|
|
+ return getErrReturnObject().setErrMsg("请选择要删除的数据").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ DeleteSQL sqlFactory = SQLFactory.createDeleteSQL(this, "sa_feedback");
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setWhere("sa_feedbackid", sa_feedbackids.toArray());
|
|
|
+ sqlFactory.delete();
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "意见反馈列表", apiversion = R.ID20240517102802.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.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.type ='").append(whereObject.getString("type")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (pageSorting.equals("''")) {
|
|
|
+ pageSorting = "t1.createdate desc";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_feedback")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ RowsMap readRowsMap = FeedBackHelper.getReadRows(this, rows.toArrayList("sa_feedbackid", new ArrayList<>()));
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("depareaname", row.getString("depname") + row.getString("areaname"));
|
|
|
+ Long replycount = row.getLong("replycount");
|
|
|
+ Long userreplycount = 0L;
|
|
|
+
|
|
|
+ Rows readRows = readRowsMap.getOrDefault(row.getString("sa_feedbackid"), new Rows());
|
|
|
+ if (readRows.isNotEmpty()) {
|
|
|
+ userreplycount = readRows.get(0).getLong("count");
|
|
|
+ }
|
|
|
+ if (replycount != userreplycount) {
|
|
|
+ row.put("isnew", 1);
|
|
|
+ } else {
|
|
|
+ row.put("isnew", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "我的意见反馈列表", apiversion = R.ID20240517102902.v1.class)
|
|
|
+ public String mylist() 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(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.type ='").append(whereObject.getString("type")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (pageSorting.equals("''")) {
|
|
|
+ pageSorting = "t1.createdate desc";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_feedback")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("createuserid", userid);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ RowsMap readRowsMap = FeedBackHelper.getReadRows(this, rows.toArrayList("sa_feedbackid", new ArrayList<>()));
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long replycount = row.getLong("replycount");
|
|
|
+ Long userreplycount = 0L;
|
|
|
+
|
|
|
+ Rows readRows = readRowsMap.getOrDefault(row.getString("sa_feedbackid"), new Rows());
|
|
|
+ if (readRows.isNotEmpty()) {
|
|
|
+ userreplycount = readRows.get(0).getLong("count");
|
|
|
+ }
|
|
|
+ if (replycount != userreplycount) {
|
|
|
+ row.put("isnew", 1);
|
|
|
+ } else {
|
|
|
+ row.put("isnew", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "小程序意见反馈回复列表", apiversion = R.ID20240517103002.v1.class)
|
|
|
+ public String replylist() throws YosException {
|
|
|
+ String ownertable = "sa_feedback";
|
|
|
+ Long sa_feedbackid = content.getLongValue("sa_feedbackid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_datacomment").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("ownertable", ownertable);
|
|
|
+ querySQL.setWhere("ownerid", sa_feedbackid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy("t1.createdate desc");
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("headpic", getHeadPic(row.getLong("userid")));
|
|
|
+ if (userid != row.getLong("userid")) {
|
|
|
+ row.put("name", "官方");
|
|
|
+ row.put("headpic", userInfo.getSiteLogo(this));
|
|
|
+ }
|
|
|
+
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datacomment_read");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(createTableID("sys_datacomment_read"));
|
|
|
+ insertSQL.setValue("userid", userid);
|
|
|
+ insertSQL.setValue("sys_datacommentid", row.getString("sys_datacommentid"));
|
|
|
+ insertSQL.setWhere("not exists(select 1 from sys_datacomment_read where userid=" + userid + " and sys_datacommentid=" + row.getString("sys_datacommentid") + " )");
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|