|
@@ -33,59 +33,45 @@ public class FadGoods extends Controller {
|
|
|
public String insertOrUpdate() throws YosException {
|
|
|
Long sa_fadid = content.getLongValue("sa_fadid");
|
|
|
int isonsale = content.getIntValue("isonsale");
|
|
|
-
|
|
|
String tag = content.getStringValue("tag");
|
|
|
+ Long parentid = 0L;
|
|
|
|
|
|
- if (sa_fadid <= 0) {
|
|
|
+ ArrayList<String> listSQL = new ArrayList<>();
|
|
|
+ Rows fadRows = dbConnect.runSqlQuery("SELECT * from sa_fad WHERE sa_fadid=" + sa_fadid + " and siteid='" + siteid + "'");
|
|
|
+ if (sa_fadid <= 0 || fadRows.isEmpty()) {
|
|
|
sa_fadid = createTableID(sa_fad);
|
|
|
- InsertSQL sqlFactory = SQLFactory.createInsertSQL(this, sa_fad);
|
|
|
- sqlFactory.setSiteid(siteid);
|
|
|
- sqlFactory.setUniqueid(sa_fadid);
|
|
|
- sqlFactory.setValue("itemid", content.getLongValue("itemid"));
|
|
|
- sqlFactory.setValue("itemno", content.getStringValue("itemno"));
|
|
|
- sqlFactory.setValue("name", content.getStringValue("name"));
|
|
|
- sqlFactory.setValue("subtitle", content.getStringValue("subtitle"));
|
|
|
- sqlFactory.setValue("model", content.getStringValue("model"));
|
|
|
- sqlFactory.setValue("class", content.getJSONArray("class"));
|
|
|
- sqlFactory.setValue("pricetype", content.getStringValue("pricetype"));
|
|
|
- sqlFactory.setValue("price", content.getBigDecimalValue("price"));
|
|
|
- sqlFactory.setValue("price_deposit", content.getBigDecimalValue("price_deposit"));
|
|
|
- sqlFactory.setValue("price_store", content.getBigDecimalValue("price_store"));
|
|
|
- sqlFactory.setValue("price_rebate", content.getBigDecimalValue("price_rebate"));
|
|
|
- sqlFactory.setValue("unitname", content.getStringValue("unitname"));
|
|
|
- sqlFactory.setValue("isnew", content.getBooleanValue("isnew"));
|
|
|
- sqlFactory.setValue("sequence", content.getLongValue("sequence"));
|
|
|
- sqlFactory.setValue("content", content.getStringValue("contentstr", true));
|
|
|
- sqlFactory.setValue("classid", 2);
|
|
|
- sqlFactory.setValue("parentid", content.getLongValue("parentid"));
|
|
|
- sqlFactory.setValue("canadjust", content.getLongValue("canadjust"));
|
|
|
- sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
-
|
|
|
- sqlFactory.insert();
|
|
|
+ InsertSQL sqlFactory = FadHelper.getFadInsertSQL(this, sa_fadid, parentid);
|
|
|
+ listSQL.add(sqlFactory.getSQL());
|
|
|
content.put("sa_fadid", sa_fadid);
|
|
|
} else {
|
|
|
- UpdateSQL sqlFactory = SQLFactory.createUpdateSQL(this, sa_fad);
|
|
|
- sqlFactory.setUniqueid(sa_fadid);
|
|
|
- sqlFactory.setSiteid(siteid);
|
|
|
- sqlFactory.setValue("itemid", content.getLongValue("itemid"));
|
|
|
- sqlFactory.setValue("itemno", content.getStringValue("itemno"));
|
|
|
- sqlFactory.setValue("name", content.getStringValue("name"));
|
|
|
- sqlFactory.setValue("subtitle", content.getStringValue("subtitle"));
|
|
|
- sqlFactory.setValue("model", content.getStringValue("model"));
|
|
|
- sqlFactory.setValue("class", content.getJSONArray("class"));
|
|
|
- sqlFactory.setValue("pricetype", content.getStringValue("pricetype"));
|
|
|
- sqlFactory.setValue("price", content.getBigDecimalValue("price"));
|
|
|
- sqlFactory.setValue("price_deposit", content.getBigDecimalValue("price_deposit"));
|
|
|
- sqlFactory.setValue("price_store", content.getBigDecimalValue("price_store"));
|
|
|
- sqlFactory.setValue("price_rebate", content.getBigDecimalValue("price_rebate"));
|
|
|
- sqlFactory.setValue("unitname", content.getStringValue("unitname"));
|
|
|
- sqlFactory.setValue("isnew", content.getBooleanValue("isnew"));
|
|
|
- sqlFactory.setValue("sequence", content.getLongValue("sequence"));
|
|
|
- sqlFactory.setValue("content", content.getStringValue("contentstr", true));
|
|
|
- sqlFactory.setValue("parentid", content.getLongValue("parentid"));
|
|
|
- sqlFactory.setValue("canadjust", content.getLongValue("canadjust"));
|
|
|
- sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
- sqlFactory.update();
|
|
|
+
|
|
|
+ boolean canadjust = fadRows.get(0).getBoolean("canadjust");
|
|
|
+ long temp_sys_enterpriseid = fadRows.get(0).getLong("sys_enterpriseid");
|
|
|
+ //允许经销商调整,数据是总部的,修改方为总部
|
|
|
+ if (canadjust && temp_sys_enterpriseid == 0 && sys_enterpriseid == 0) {
|
|
|
+ UpdateSQL sqlFactory = FadHelper.getFadUpdateSQL(this, sa_fadid);
|
|
|
+ listSQL.add(sqlFactory.getSQL());
|
|
|
+ //更新parentid为sa_fadid的数据
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT sa_fadid from sa_fad WHERE parentid=" + sa_fadid + " and siteid='" + siteid + "'");
|
|
|
+ for (Row row : rows) {
|
|
|
+ sqlFactory = FadHelper.getFadUpdateSQL(this, row.getLong("sa_fadid"));
|
|
|
+ listSQL.add(sqlFactory.getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //允许经销商调整,数据是总部的,修改方为经销商
|
|
|
+ else if (canadjust && temp_sys_enterpriseid == 0 && sys_enterpriseid > 0) {
|
|
|
+ parentid = sa_fadid;
|
|
|
+ sa_fadid = createTableID(sa_fad);
|
|
|
+ InsertSQL sqlFactory = FadHelper.getFadInsertSQL(this, sa_fadid, parentid);
|
|
|
+ listSQL.add(sqlFactory.getSQL());
|
|
|
+ content.put("sa_fadid", sa_fadid);
|
|
|
+ } else {
|
|
|
+ UpdateSQL sqlFactory = FadHelper.getFadUpdateSQL(this, sa_fadid);
|
|
|
+ listSQL.add(sqlFactory.getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//上下架
|
|
@@ -95,7 +81,8 @@ public class FadGoods extends Controller {
|
|
|
updateSQL.setValue("isonsale", isonsale);
|
|
|
updateSQL.setValue("onsaledate", isonsale == 1 ? Time.getDateTime_Str() : "null");
|
|
|
updateSQL.setValue("onsaleby", isonsale == 1 ? username : "null");
|
|
|
- updateSQL.update();
|
|
|
+ listSQL.add(updateSQL.getSQL());
|
|
|
+ dbConnect.runSqlUpdate(listSQL);
|
|
|
|
|
|
DataTag.deleteTag(this, "sa_fad", sa_fadid);
|
|
|
DataTag.createSystemTag(this, "sa_fad", sa_fadid, tag);
|
|
@@ -158,8 +145,8 @@ public class FadGoods extends Controller {
|
|
|
detailRow.put("attinfos_pic", attachmentRows);
|
|
|
detailRow.putIfAbsent("onsaledate", "");
|
|
|
ArrayList<String> tags = DataTag.queryTag(this, "sa_fad", detailRow.getLong("sa_fadid"), true);
|
|
|
- detailRow.putIfAbsent("tag", StringUtils.join(tags,","));
|
|
|
- detailRow.putIfAbsent("classnames", StringUtils.join(detailRow.getJSONArray("class"),","));
|
|
|
+ detailRow.putIfAbsent("tag", StringUtils.join(tags, ","));
|
|
|
+ detailRow.putIfAbsent("classnames", StringUtils.join(detailRow.getJSONArray("class"), ","));
|
|
|
|
|
|
|
|
|
return getSucReturnObject().setData(detailRow).toString();
|
|
@@ -195,7 +182,7 @@ public class FadGoods extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "单品列表", apiversion = R.ID20240428154002.v1.class)
|
|
|
+ @API(title = "商品列表", apiversion = R.ID20240428154002.v1.class)
|
|
|
public String list() throws YosException {
|
|
|
/*
|
|
|
过滤条件设置
|
|
@@ -255,10 +242,10 @@ public class FadGoods extends Controller {
|
|
|
|
|
|
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, sa_fad,
|
|
|
- "sa_fadid", "name", "isonsale", "model", "pricetype","sequence", "createby", "createdate", "onsaledate","class")
|
|
|
+ "sa_fadid", "name", "isonsale", "canadjust", "model", "pricetype", "sequence", "createby", "createdate", "onsaledate", "class")
|
|
|
.setTableAlias("t1");
|
|
|
|
|
|
- querySQL.addJoinTable(JOINTYPE.left,"sys_datatag","t2","t2.ownertable='sa_fad' and t2.ownerid=t1.sa_fadid and t2.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_datatag", "t2", "t2.ownertable='sa_fad' and t2.ownerid=t1.sa_fadid and t2.siteid=t1.siteid");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("classid", 2);
|
|
|
querySQL.setWhere(where.toString());
|
|
@@ -277,8 +264,8 @@ public class FadGoods extends Controller {
|
|
|
row.putIfAbsent("onsaledate", "");
|
|
|
|
|
|
ArrayList<String> tags = DataTag.queryTag(this, "sa_fad", row.getLong("sa_fadid"), true);
|
|
|
- row.putIfAbsent("tag", StringUtils.join(tags,","));
|
|
|
- row.putIfAbsent("classnames", StringUtils.join(row.getJSONArray("class"),","));
|
|
|
+ row.putIfAbsent("tag", StringUtils.join(tags, ","));
|
|
|
+ row.putIfAbsent("classnames", StringUtils.join(row.getJSONArray("class"), ","));
|
|
|
}
|
|
|
|
|
|
|