eganwu пре 1 година
родитељ
комит
d5b86174ef

+ 15 - 0
src/custom/restcontroller/R.java

@@ -6374,6 +6374,21 @@ public class R {
         }
     }
 
+    public static class ID20240514131202 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240514131302 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240514131402 {
+        public static class v1 {
+        }
+    }
+
 }
 
 

+ 118 - 0
src/custom/restcontroller/webmanage/saletool/award/AwardItems.java

@@ -0,0 +1,118 @@
+package restcontroller.webmanage.saletool.award;
+
+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 restcontroller.webmanage.saletool.fad.FadHelper;
+
+public class AwardItems extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public AwardItems(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "奖品项新增或编辑", apiversion = R.ID20240514131202.v1.class)
+    public String insertOrUpdate() throws YosException {
+
+        Long sa_awardid = content.getLongValue("sa_awardid");
+        Long sa_awarditemsid = content.getLongValue("sa_awarditemsid");
+
+        if (sa_awarditemsid <= 0) {
+            sa_awarditemsid = createTableID("sa_awarditems");
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_awarditems");
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(sa_awarditemsid);
+            insertSQL.setValue("sequence", content.getLongValue("sequence"));
+            insertSQL.setValue("name", content.getStringValue("name"));
+            insertSQL.setValue("price", content.getBigDecimalValue("price"));
+            insertSQL.setValue("percentage", content.getBigDecimalValue("percentage"));
+            insertSQL.setValue("type", content.getStringValue("type"));
+            insertSQL.setValue("realcount", content.getLongValue("totalcount"));
+            insertSQL.setValue("outcount", content.getLongValue("outcount"));
+            insertSQL.setValue("totalcount", content.getLongValue("totalcount"));
+            insertSQL.setValue("sa_awardid", sa_awardid);
+            insertSQL.insert();
+
+        } else {
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_awarditems");
+            updateSQL.setSiteid(siteid);
+            updateSQL.setUniqueid(sa_awarditemsid);
+            updateSQL.setValue("sequence", content.getLongValue("sequence"));
+            updateSQL.setValue("name", content.getStringValue("name"));
+            updateSQL.setValue("price", content.getBigDecimalValue("price"));
+            updateSQL.setValue("percentage", content.getBigDecimalValue("percentage"));
+            updateSQL.setValue("type", content.getStringValue("type"));
+            updateSQL.setValue("outcount", content.getLongValue("outcount"));
+            updateSQL.setValue("totalcount", content.getLongValue("totalcount"));
+            updateSQL.setValue("sa_awardid", sa_awardid);
+            updateSQL.update();
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "奖品项删除", apiversion = R.ID20240514131302.v1.class)
+    public String delete() throws YosException {
+
+        JSONArray sa_awarditemsids = content.getJSONArray("sa_awarditemsids");
+        if (sa_awarditemsids.size() == 0) {
+            return getErrReturnObject().setErrMsg("请选择要删除的数据").toString();
+        }
+
+
+        DeleteSQL sqlFactory = SQLFactory.createDeleteSQL(this, "sa_awarditems");
+        sqlFactory.setSiteid(siteid);
+        sqlFactory.setWhere("sa_awarditemsid", sa_awarditemsids.toArray());
+        sqlFactory.delete();
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "奖品项新增或编辑", apiversion = R.ID20240514131402.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(")");
+            }
+
+            if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
+                where.append(" and (");
+                where.append("t1.type ='").append(whereObject.getString("type")).append("' ");
+                where.append(")");
+            }
+
+        }
+
+        Long sa_awardid = content.getLongValue("sa_awardid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_awarditems")
+                .setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("sa_awardid", sa_awardid);
+        querySQL.setWhere(where.toString());
+        querySQL.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+}