|
|
@@ -0,0 +1,172 @@
|
|
|
+package restcontroller.webmanage.sale.customscheme;
|
|
|
+
|
|
|
+import beans.data.BatchDeleteErr;
|
|
|
+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.Row;
|
|
|
+import common.data.Rows;
|
|
|
+import common.data.RowsMap;
|
|
|
+import common.data.SQLFactory;
|
|
|
+import org.apache.commons.io.filefilter.FalseFileFilter;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class customschemeItems extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public customschemeItems(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "方案选择列表查询", apiversion = R.ID20230105110903.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String querySelectSchemeList() throws YosException {
|
|
|
+ /*
|
|
|
+ * 过滤条件设置
|
|
|
+ */
|
|
|
+ Long sa_customschemeid = content.getLong("sa_customschemeid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select value from sa_customscheme_items where sa_customschemeid="+sa_customschemeid);
|
|
|
+ Rows selectRows = new Rows();
|
|
|
+
|
|
|
+ JSONObject jsonObject1 =new JSONObject();
|
|
|
+ JSONObject jsonObject2 =new JSONObject();
|
|
|
+ JSONObject jsonObject3 =new JSONObject();
|
|
|
+ jsonObject1.put("value", "spec");
|
|
|
+ jsonObject1.put("description", "尺寸");
|
|
|
+ jsonObject2.put("value", "material");
|
|
|
+ jsonObject2.put("description", "基材");
|
|
|
+ jsonObject3.put("value", "color");
|
|
|
+ jsonObject3.put("description", "颜色");
|
|
|
+
|
|
|
+
|
|
|
+ boolean hsacolor =false;
|
|
|
+ boolean hsamaterial =false;
|
|
|
+ boolean hsaspec =false;
|
|
|
+ if(!rows.isEmpty()){
|
|
|
+ for (Row row:rows) {
|
|
|
+ if(row.getString("value").equals("color")){
|
|
|
+ hsacolor=true;
|
|
|
+ }
|
|
|
+ if(row.getString("value").equals("material")){
|
|
|
+ hsamaterial=true;
|
|
|
+ }
|
|
|
+ if(row.getString("value").equals("spec")){
|
|
|
+ hsaspec=true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if(!hsacolor){
|
|
|
+ jsonArray.add(jsonObject3);
|
|
|
+ }
|
|
|
+ if(!hsamaterial){
|
|
|
+ jsonArray.add(jsonObject2);
|
|
|
+ }
|
|
|
+ if(!hsaspec){
|
|
|
+ jsonArray.add(jsonObject1);
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(jsonArray).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "新建或修改商品定制方案明细", apiversion = R.ID20230321155503.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {customschemeItems.class})
|
|
|
+ public String insertormodify_customschemeItems() throws YosException {
|
|
|
+ Long sa_customschemeid = content.getLong("sa_customschemeid");
|
|
|
+ JSONArray iteminfos = content.getJSONArray("iteminfos");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ Rows rowscount = dbConnect.runSqlQuery("select sa_customschemeid from sa_customscheme where sa_customschemeid=" + sa_customschemeid);
|
|
|
+ if (rowscount.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("该商品定制方案不存在").toString();
|
|
|
+ }
|
|
|
+ int i = 0;
|
|
|
+ long[] sa_customscheme_itemsid = createTableID("sa_customscheme_items", iteminfos.size());
|
|
|
+
|
|
|
+ for (Object obj : iteminfos) {
|
|
|
+ JSONObject iteminfo = (JSONObject) obj;
|
|
|
+ if (iteminfo.getLong("sa_customscheme_itemsid") <= 0 || dbConnect
|
|
|
+ .runSqlQuery("select sa_customscheme_itemsid from sa_customscheme_items where sa_customscheme_itemsid="
|
|
|
+ + iteminfo.getLong("sa_customscheme_itemsid"))
|
|
|
+ .isEmpty()) {
|
|
|
+ SQLFactory saleFactory = new SQLFactory(this, "商品定制方案明细新增");
|
|
|
+ System.out.println("1234");
|
|
|
+ saleFactory.addParameter("siteid", siteid);
|
|
|
+ saleFactory.addParameter("sa_customscheme_itemsid", sa_customscheme_itemsid[i]);
|
|
|
+ saleFactory.addParameter("sa_customschemeid", sa_customschemeid);
|
|
|
+ saleFactory.addParameter("value", iteminfo.getStringValue("value"));
|
|
|
+ saleFactory.addParameter("description", iteminfo.getStringValue("description"));
|
|
|
+ sqlList.add(saleFactory.getSQL());
|
|
|
+ i++;
|
|
|
+ } else {
|
|
|
+ SQLFactory saleFactory = new SQLFactory(this, "商品定制方案明细更新");
|
|
|
+ saleFactory.addParameter("siteid", siteid);
|
|
|
+ saleFactory.addParameter("sa_customscheme_itemsid", iteminfo.getLongValue("sa_customscheme_itemsid"));
|
|
|
+ saleFactory.addParameter("sa_customschemeid", sa_customschemeid);
|
|
|
+ saleFactory.addParameter("value", iteminfo.getStringValue("value"));
|
|
|
+ saleFactory.addParameter("description", iteminfo.getStringValue("description"));
|
|
|
+ sqlList.add(saleFactory.getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return querycustomschemeItemsList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "商品定制方案明细明细列表", apiversion = R.ID20230321155603.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String querycustomschemeItemsList() 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.value like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.description like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long sa_customschemeid = content.getLong("sa_customschemeid");
|
|
|
+// String hrid = content.getString("hrid");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "商品定制方案明细列表查询", pageSize, pageNumber, pageSorting);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter("sa_customschemeid", sa_customschemeid);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "删除明细", apiversion = R.ID20230321155703.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {customschemeItems.class})
|
|
|
+ public String deletemx() throws YosException {
|
|
|
+
|
|
|
+ JSONArray sa_customscheme_itemsids = content.getJSONArray("sa_customscheme_itemsids");
|
|
|
+ BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_customscheme_itemsids.size());
|
|
|
+ long sa_customschemeid = 0;
|
|
|
+ for (Object o : sa_customscheme_itemsids) {
|
|
|
+ long sa_customscheme_itemsid = Long.parseLong(o.toString());
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
+ SQLFactory deletesql = new SQLFactory("sql:delete from sa_customscheme_items where siteid='" + siteid
|
|
|
+ + "' and sa_customscheme_itemsid=" + sa_customscheme_itemsid);
|
|
|
+ list.add(deletesql.getSQL());
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
+ }
|
|
|
+}
|