|
|
@@ -0,0 +1,195 @@
|
|
|
+package restcontroller.webmanage.sale.aftersalesmag;
|
|
|
+
|
|
|
+import beans.data.BatchDeleteErr;
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.annotation.CACHEING;
|
|
|
+import common.annotation.CACHEING_CLEAN;
|
|
|
+import common.data.*;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+@API(title = "返修处理意见")
|
|
|
+public class aftersalesmagdisposition extends Controller {
|
|
|
+ public aftersalesmagdisposition(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "新增更新返修处理意见", apiversion = R.ID2025062713362503.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {aftersalesmagdisposition.class})
|
|
|
+ public String insertormodify_aftersalesmagdisposition() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ // 表名
|
|
|
+ String tableName = "sa_aftersalesmag_disposition";
|
|
|
+ Long sa_aftersalesmag_dispositionid = content.getLong("sa_aftersalesmag_dispositionid");
|
|
|
+ boolean scrapstock =content.getBooleanValue("scrapstock");
|
|
|
+ boolean isrefund = content.getBooleanValue("isrefund");
|
|
|
+ boolean ismaintain = content.getBooleanValue("ismaintain");
|
|
|
+ boolean inishedstock = content.getBooleanValue("inishedstock");
|
|
|
+ String disposition = content.getStringValue("disposition");
|
|
|
+ if (sa_aftersalesmag_dispositionid <= 0 || dbConnect.runSqlQuery(
|
|
|
+ "select sa_aftersalesmag_dispositionid from sa_aftersalesmag_disposition where sa_aftersalesmag_dispositionid=" + sa_aftersalesmag_dispositionid)
|
|
|
+ .isEmpty()) {
|
|
|
+ sa_aftersalesmag_dispositionid = createTableID(tableName);
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, tableName);
|
|
|
+ insertSQL.setUniqueid(sa_aftersalesmag_dispositionid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("scrapstock", scrapstock);
|
|
|
+ insertSQL.setValue("isrefund", isrefund);
|
|
|
+ insertSQL.setValue("ismaintain",ismaintain);
|
|
|
+ insertSQL.setValue("inishedstock", inishedstock);
|
|
|
+ insertSQL.setValue("disposition", disposition);
|
|
|
+ insertSQL.setValue("isused", false);
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_aftersalesmag_disposition", sa_aftersalesmag_dispositionid, "新增", "返修处理意见新增成功").getSQL());
|
|
|
+ } else {
|
|
|
+ Rows rows = dbConnect.runSqlQuery(
|
|
|
+ "SELECT isused from sa_aftersalesmag_disposition WHERE sa_aftersalesmag_dispositionid = "
|
|
|
+ + sa_aftersalesmag_dispositionid);
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ if (!rows.get(0).getBoolean("isused")) {
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, tableName);
|
|
|
+ updateSQL.setUniqueid(sa_aftersalesmag_dispositionid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("scrapstock", scrapstock);
|
|
|
+ updateSQL.setValue("isrefund", isrefund);
|
|
|
+ updateSQL.setValue("ismaintain",ismaintain);
|
|
|
+ updateSQL.setValue("inishedstock", inishedstock);
|
|
|
+ updateSQL.setValue("disposition", disposition);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_aftersalesmag_disposition", sa_aftersalesmag_dispositionid, "更新", "返修处理意见更新成功")
|
|
|
+ .getSQL());
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("非启用状态下无法编辑").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("该返修处理意见不存在").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ content.put("sa_aftersalesmag_dispositionid", sa_aftersalesmag_dispositionid);
|
|
|
+
|
|
|
+ return queryaftersalesmagdispositionMain();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "返修意见详情", apiversion = R.ID2025062713454303.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryaftersalesmagdispositionMain() throws YosException {
|
|
|
+ Long sa_aftersalesmag_dispositionid = content.getLong("sa_aftersalesmag_dispositionid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_aftersalesmag_disposition", "*");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setWhere("t1.sa_aftersalesmag_dispositionid",sa_aftersalesmag_dispositionid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "查询返修意见列表", apiversion = R.ID2025062713474903.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryaftersalesmagdispositionList() 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.disposition like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("isused") && !"".equals(whereObject.getString("isused"))) {
|
|
|
+ where.append(" and t1.isused ='").append(whereObject.getString("isused")).append("' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_aftersalesmag_disposition", "*");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "删除", apiversion = R.ID2025062713500603.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {aftersalesmagdisposition.class})
|
|
|
+ public String delete() throws YosException {
|
|
|
+ JSONArray sa_aftersalesmag_dispositionids = content.getJSONArray("sa_aftersalesmag_dispositionids");
|
|
|
+ BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_aftersalesmag_dispositionids.size());
|
|
|
+ for (Object o : sa_aftersalesmag_dispositionids) {
|
|
|
+ long sa_aftersalesmag_dispositionid = Long.parseLong(o.toString());
|
|
|
+ Rows RowsStatus = dbConnect
|
|
|
+ .runSqlQuery("select sa_aftersalesmag_dispositionid,isused from sa_aftersalesmag_disposition where siteid='" + siteid
|
|
|
+ + "' and sa_aftersalesmag_dispositionid='" + sa_aftersalesmag_dispositionid + "'");
|
|
|
+
|
|
|
+ if (RowsStatus.isNotEmpty()) {
|
|
|
+ if (RowsStatus.get(0).getBoolean("isused")) {
|
|
|
+ batchDeleteErr.addErr(sa_aftersalesmag_dispositionid, "启用状态的返修意见无法删除");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate("delete from sa_aftersalesmag_disposition where siteid='" + siteid + "' and sa_aftersalesmag_dispositionid="
|
|
|
+ + sa_aftersalesmag_dispositionid);
|
|
|
+ }
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "是否启用", apiversion = R.ID2025062713544603.v1.class)
|
|
|
+ @CACHEING_CLEAN( apiClass = {aftersalesmagdisposition.class})
|
|
|
+ public String isused() throws YosException {
|
|
|
+ Long sa_aftersalesmag_dispositionid = content.getLong("sa_aftersalesmag_dispositionid");
|
|
|
+ boolean isused = content.getBooleanValue("isused");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t1.sa_aftersalesmag_dispositionid,t1.isused,t1.disposition from sa_aftersalesmag_disposition t1 where t1.sa_aftersalesmag_dispositionid ='"
|
|
|
+ + sa_aftersalesmag_dispositionid + "' and t1.siteid='" + siteid + "'");
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (isused) {
|
|
|
+ if (row.getBoolean("isused")) {
|
|
|
+ return getErrReturnObject().setErrMsg("【"+row.getString("disposition")+"】返退意见为启用状态,无法再次启用")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!row.getBoolean("isused")) {
|
|
|
+ return getErrReturnObject().setErrMsg("【"+row.getString("disposition")+"】返退意见为非启用状态,无法停用")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_aftersalesmag_disposition");
|
|
|
+ updateSQL.setUniqueid(sa_aftersalesmag_dispositionid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("isused", isused);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ if (isused) {
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_aftersalesmag_disposition", sa_aftersalesmag_dispositionid, "启用", "返退意见启用成功").getSQL());
|
|
|
+ } else {
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_aftersalesmag_disposition", sa_aftersalesmag_dispositionid, "停用", "返退意见停用成功").getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|