|
|
@@ -6,6 +6,7 @@ import beans.enterprise.Enterprise;
|
|
|
import beans.itemclass.ItemClass;
|
|
|
import beans.itemgroup.Itemgroup;
|
|
|
import beans.itemprice.ItemPrice;
|
|
|
+import beans.parameter.Parameter;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -14,10 +15,7 @@ import common.Controller;
|
|
|
import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
-import common.data.Row;
|
|
|
-import common.data.Rows;
|
|
|
-import common.data.RowsMap;
|
|
|
-import common.data.SQLFactory;
|
|
|
+import common.data.*;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
|
@@ -56,208 +54,121 @@ public class itemgroup extends Controller {
|
|
|
@API(title = "查询", apiversion = R.ID20220926142203.v1.class)
|
|
|
@CACHEING
|
|
|
public String queryItemgroup() throws YosException {
|
|
|
- Long istool = content.getLongValue("istool");
|
|
|
- //Rows itemclassRows = Enterprise.getItemSaleClasses(this, sys_enterpriseid, true, istool);
|
|
|
if (content.containsKey("sys_enterpriseid")) {
|
|
|
sys_enterpriseid = content.getLongValue("sys_enterpriseid");
|
|
|
}
|
|
|
- /*
|
|
|
- * * 过滤条件设置
|
|
|
- */
|
|
|
- String where = " 1=1 ";
|
|
|
- String where1 = "";
|
|
|
- String itemclasssql = "select itemclassid from plm_itemclass where siteid='" + siteid + "'";
|
|
|
- if (sys_enterpriseid > 0) {
|
|
|
- Row enterpriseRow = Enterprise.getEnterprise(this, sys_enterpriseid);
|
|
|
- if (!enterpriseRow.isEmpty()) {
|
|
|
- //企业营销类别
|
|
|
- boolean saleclassauth = enterpriseRow.getBoolean("saleclassauth");
|
|
|
- if (saleclassauth) {
|
|
|
- itemclasssql = "select itemclassid from plm_itemclass where siteid='" + siteid + "' and itemclassid in ( SELECT itemclassid from sys_enterprise_saleclass WHERE sys_enterpriseid = " + sys_enterpriseid + " and siteid='" + siteid + "')";
|
|
|
- }
|
|
|
- //企业领域
|
|
|
- Rows tradefieldrows = dbConnect.runSqlQuery("SELECT tradefield from sys_enterprise_tradefield WHERE sys_enterpriseid =" + sys_enterpriseid + " and siteid ='" + siteid + "'");
|
|
|
- if (!tradefieldrows.isEmpty()) {
|
|
|
- for (Row row : tradefieldrows) {
|
|
|
- where1 = where1 + " (t1.tradefield like'%" + row.getString("tradefield") + "%') or ";
|
|
|
- }
|
|
|
- } else {
|
|
|
- where1 = where1 + " 1=2 ";
|
|
|
- }
|
|
|
- } else {
|
|
|
- where1 = " 1=2 ";
|
|
|
- }
|
|
|
|
|
|
- } else {
|
|
|
- where1 = " 1=1 ";
|
|
|
- }
|
|
|
- if (where1.contains("or")) {
|
|
|
- where1 = where1.substring(0, where1.lastIndexOf("or"));
|
|
|
+ int pricegrade = 1;
|
|
|
+ try {
|
|
|
+ pricegrade =Integer.parseInt( Parameter.get(siteid, "defaultlevelprice"));//价格等级
|
|
|
+ } catch (Exception ignored) {
|
|
|
}
|
|
|
- Rows itemclassRows = dbConnect.runSqlQuery(itemclasssql);
|
|
|
-
|
|
|
- ArrayList<Long> itemclassList = new ArrayList<Long>();
|
|
|
- for (Row row : itemclassRows) {
|
|
|
- //System.out.println(row.getLong("itemclassid"));
|
|
|
- itemclassList.add(row.getLong("itemclassid"));
|
|
|
- itemclassList.addAll(ItemClass.getSubItemClassIds(this, row.getLong("itemclassid")));
|
|
|
+ boolean saleclassauth = false;//是否需要经营授权
|
|
|
+ if (sys_enterpriseid > 0) {
|
|
|
+ Row enterpriseRow = Enterprise.getEnterprise(this, sys_enterpriseid);
|
|
|
+ saleclassauth = enterpriseRow.isEmpty() ? saleclassauth : enterpriseRow.getBoolean("saleclassauth");
|
|
|
+ Enterprise.EnterpriseGrade enterpriseGrade = Enterprise.getEnterpriseGrade(this, sys_enterpriseid);
|
|
|
+ pricegrade = enterpriseGrade == null ? pricegrade : enterpriseGrade.getPricegrade();
|
|
|
}
|
|
|
+ pricegrade = pricegrade <= 0 ? 1 : pricegrade;
|
|
|
|
|
|
- SQLFactory factorygroupid = new SQLFactory(this, "查询授权范围内的商品组商品");
|
|
|
- factorygroupid.addParameter("siteid", siteid);
|
|
|
|
|
|
- if (content.containsKey("where")) {
|
|
|
- JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ String where = " 1=1 ";
|
|
|
+ JSONObject content_where =new JSONObject();
|
|
|
+ if(this.content.containsKey("where")){
|
|
|
+ content_where=this.content.getJSONObject("where");}
|
|
|
|
|
|
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
- where = where + " and (t1.groupname like'%" + whereObject.getString("condition")
|
|
|
- + "%' or t1.groupnum like'%" + whereObject.getString("condition")
|
|
|
- + "%' or exists(select 1 from sa_itemgroupmx s1 left join plm_item s2 on s1.itemid=s2.itemid and s1.siteid=s2.siteid where (s2.itemname like '%"
|
|
|
- + whereObject.getString("condition") + "%' or s2.itemno like '%" + whereObject.getString("condition")
|
|
|
- + "%' or s2.standards like '%" + whereObject.getString("condition")
|
|
|
- + "%' or s2.spec like '%" + whereObject.getString("condition")
|
|
|
- + "%' or s2.byname like '%" + whereObject.getString("condition")
|
|
|
- + "%' or s2.model like '%" + whereObject.getString("condition")
|
|
|
- + "%') and s1.sa_itemgroupid=t1.sa_itemgroupid) ) ";
|
|
|
-
|
|
|
- pageSorting="t1.groupname like'%" + whereObject.getString("condition")+"%' desc,exists(select 1 from sa_itemgroupmx s1 " +
|
|
|
- " LEFT JOIN plm_item s2 ON s1.itemid = s2.itemid AND s1.siteid = s2.siteid where s2.itemname like'%"+whereObject.getString("condition")+"%') desc,exists(select 1 from sa_itemgroupmx s1 " +
|
|
|
- " LEFT JOIN plm_item s2 ON s1.itemid = s2.itemid AND s1.siteid = s2.siteid where s2.itemno like'%"+whereObject.getString("condition")+"%') desc,t1.groupnum like'%" + whereObject.getString("condition")+"%' desc";
|
|
|
|
|
|
- }
|
|
|
- if (whereObject.containsKey("tradefield") && !"".equals(whereObject.getString("tradefield"))) {
|
|
|
- where = where + " and (t1.tradefield like'%" + whereObject.getString("tradefield") + "%') ";
|
|
|
- }
|
|
|
-// else {
|
|
|
-// if (sys_enterpriseid > 0) {
|
|
|
-// where = where + " and (t1.tradefield in (SELECT tradefield from sys_enterprise_tradefield WHERE sys_enterpriseid = " + sys_enterpriseid + " and siteid='" + siteid + "') ) ";
|
|
|
-// }
|
|
|
-// }
|
|
|
- if (whereObject.containsKey("standards") && !"".equals(whereObject.getString("standards"))) {
|
|
|
- where = where
|
|
|
- + " and exists(select 1 from sa_itemgroupmx s1 left join plm_item s2 on s1.itemid=s2.itemid and s1.siteid=s2.siteid where s2.standards='"
|
|
|
- + whereObject.getString("standards") + "' and s1.sa_itemgroupid=t1.sa_itemgroupid) ";
|
|
|
- }
|
|
|
- if (whereObject.containsKey("itemclassid") && !"".equals(whereObject.getString("itemclassid"))) {
|
|
|
-
|
|
|
- ArrayList<Long> list = ItemClass.getSubItemClassIds(this, whereObject.getLong("itemclassid"));
|
|
|
- list.add(whereObject.getLong("itemclassid"));
|
|
|
- ArrayList<Long> listNew = new ArrayList<>();
|
|
|
- listNew.add((long) 0);
|
|
|
- for (long itemclassid : list) {
|
|
|
- if (itemclassList.contains(itemclassid)) {
|
|
|
- listNew.add(itemclassid);
|
|
|
- }
|
|
|
+ if (!content_where.getStringValue("tradefield").isEmpty()) {
|
|
|
+ where = where + " and (t1.tradefield ='" + content_where.getString("tradefield") + "') ";
|
|
|
+ }
|
|
|
+ if (!content_where.getStringValue("standards").isEmpty()) {
|
|
|
+ where = where + " and exists(select 1 from sa_itemgroupmx s1 left join plm_item s2 on s1.itemid=s2.itemid and s1.siteid=s2.siteid where s2.standards='"
|
|
|
+ + content_where.getString("standards") + "' and s1.sa_itemgroupid=t1.sa_itemgroupid) ";
|
|
|
+ }
|
|
|
+ StringBuilder itemclassids_where=new StringBuilder();
|
|
|
+ if (!content_where.getStringValue("itemclassid").isEmpty()) {
|
|
|
+ ArrayList<Long> itemclassid = ItemClass.getSubItemClassIds(this, content_where.getLong("itemclassid"));
|
|
|
+ itemclassid.add(content_where.getLong("itemclassid"));
|
|
|
+ for(long id:itemclassid){
|
|
|
+ if(!itemclassids_where.toString().isEmpty()){
|
|
|
+ itemclassids_where.append(",");
|
|
|
}
|
|
|
-
|
|
|
- factorygroupid.addParameter_in("itemclassid", listNew);
|
|
|
-
|
|
|
- } else {
|
|
|
- factorygroupid.addParameter_in("itemclassid",
|
|
|
- itemclassList);
|
|
|
+ itemclassids_where.append(id);
|
|
|
}
|
|
|
- } else {
|
|
|
- factorygroupid.addParameter_in("itemclassid",
|
|
|
- itemclassList);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //品牌过滤
|
|
|
JSONArray brandids = content.getJSONArray("brandids");
|
|
|
if (brandids.isEmpty()) {
|
|
|
- Rows rows;
|
|
|
if (sys_enterpriseid > 0) {
|
|
|
- rows = Enterprise.getBrands(this, sys_enterpriseid);
|
|
|
- } else {
|
|
|
- rows = dbConnect.runSqlQuery("select sa_brandid from sa_brand where siteid='" + siteid + "'");
|
|
|
- }
|
|
|
- if (!rows.isEmpty()) {
|
|
|
- for (Row row : rows) {
|
|
|
- brandids.add(row.getLong("sa_brandid"));
|
|
|
- }
|
|
|
+ brandids = Enterprise.getBrands(this, sys_enterpriseid).toJsonArray("sa_brandid");
|
|
|
} else {
|
|
|
- brandids.add(0);
|
|
|
+ brandids = dbConnect.runSqlQuery("select sa_brandid from sa_brand where siteid='" + siteid + "'").toJsonArray("sa_brandid");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- factorygroupid.addParameter("siteid", siteid);
|
|
|
- Enterprise.EnterpriseGrade enterpriseGrade = Enterprise.getEnterpriseGrade(this, sys_enterpriseid);
|
|
|
- if (enterpriseGrade != null) {
|
|
|
- factorygroupid.addParameter("pricegrade", enterpriseGrade.getPricegrade());
|
|
|
- }else {
|
|
|
- Rows siteParameterRows =dbConnect.runSqlQuery("select defaultlevelprice from sys_site_parameter where siteid='"+siteid+"'");
|
|
|
- if(!siteParameterRows.isEmpty()){
|
|
|
- if(StringUtils.isBlank(siteParameterRows.get(0).getString("defaultlevelprice"))){
|
|
|
- factorygroupid.addParameter("pricegrade", "1");
|
|
|
- }else{
|
|
|
- factorygroupid.addParameter("pricegrade", siteParameterRows.get(0).getString("defaultlevelprice"));
|
|
|
- }
|
|
|
- }else{
|
|
|
- factorygroupid.addParameter("pricegrade", "1");
|
|
|
- }
|
|
|
- }
|
|
|
- Rows rowsgroupids = dbConnect.runSqlQuery(factorygroupid.getSQL());
|
|
|
- RowsMap itemgroupRowMap = rowsgroupids.toRowsMap("sa_itemgroupid");
|
|
|
/*
|
|
|
* SQL查询参数设置并查询
|
|
|
*/
|
|
|
- SQLFactory factory = new SQLFactory(this, "商品组列表查询", pageSize, pageNumber, pageSorting);
|
|
|
- factory.addParameter("siteid", siteid);
|
|
|
- factory.addParameter_in("sa_brandid", brandids.toArray());
|
|
|
- factory.addParameter_in("sa_itemgroupids", rowsgroupids.toArrayList("sa_itemgroupid", new ArrayList<Long>()));
|
|
|
- factory.addParameter_SQL("where", where);
|
|
|
- factory.addParameter_SQL("where1", where1);
|
|
|
- String sql = factory.getSQL();
|
|
|
- //System.out.println(sql);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
- ArrayList<Long> itemgroupids = rows.toArrayList("sa_itemgroupid", new ArrayList<Long>());
|
|
|
- RowsMap itemgroupScemeRowsMap = Itemgroup.getItemgroupScemeid(this, itemgroupids);
|
|
|
+ QuerySQL itemGroupQuery = SQLFactory.createQuerySQL(this, "sa_itemgroup", "sa_itemgroupid", "sa_brandid", "ispriorityshow",
|
|
|
+ "istopping", "changeby", "createby", "changedate", "createdate", "groupnum", "itemno", "groupname", "tradefield", "isonsale");
|
|
|
+ itemGroupQuery.setTableAlias("t1");
|
|
|
+ itemGroupQuery.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.itemno = t2.itemno AND t1.siteid = t2.siteid", "itemid");
|
|
|
+ itemGroupQuery.addJoinTable(JOINTYPE.left, "sa_brand", "t3", "t3.sa_brandid = t1.sa_brandid AND t3.siteid = t1.siteid", "brandname");
|
|
|
+ itemGroupQuery.addJoinTable(JOINTYPE.left, "plm_unit", "t6", "t6.unitid = t2.unitid AND t6.siteid = t2.siteid", "unitname");
|
|
|
+ if (saleclassauth) {
|
|
|
+ //如果企业有营销授权,则查询授权商品组
|
|
|
+ itemGroupQuery.addJoinTable(JOINTYPE.inner, "sys_enterprise_itemgroupauth_view", "t7", "t7.sa_itemgroupid = t1.sa_itemgroupid and t7.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
+ }
|
|
|
|
|
|
- for (Row row2 : rows) {
|
|
|
- long sa_itemgroupid = row2.getLong("sa_itemgroupid");
|
|
|
- ArrayList<String> list = DataTag.queryTag(this, "sa_itemgroup", sa_itemgroupid, false);
|
|
|
- row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
|
|
|
-// HashMap<Long, ItemPrice> ItemPriceList = ItemPrice.getItemGroupPrice(this, sys_enterpriseid,
|
|
|
-// row2.getLong("sa_itemgroupid"));
|
|
|
-// BigDecimal max = new BigDecimal(0);
|
|
|
-// BigDecimal min = ((ItemPrice) ItemPriceList.values().toArray()[0]).getPrice();
|
|
|
-// for (ItemPrice itemPrice : ItemPriceList.values()) {
|
|
|
-// BigDecimal itemprice = itemPrice.getPrice();
|
|
|
-// if (itemprice.compareTo(max) >0) {
|
|
|
-// max = itemprice;
|
|
|
-// }
|
|
|
-// if (itemprice.compareTo(min) <0) {
|
|
|
-// min = itemprice;
|
|
|
-// }
|
|
|
-// }
|
|
|
- Rows rows1 = itemgroupRowMap.get(String.valueOf(sa_itemgroupid));
|
|
|
- if (rows1.isEmpty()) {
|
|
|
- row2.put("maxprice", 0);
|
|
|
- row2.put("minprice", 0);
|
|
|
- } else {
|
|
|
- row2.put("maxprice", rows1.get(0).getBigDecimal("maxprice"));
|
|
|
- row2.put("minprice", rows1.get(0).getBigDecimal("minprice"));
|
|
|
- }
|
|
|
+ itemGroupQuery.setSiteid(siteid);
|
|
|
+ itemGroupQuery.setCondition("t1.groupname", "t1.groupnum", "t2.model");
|
|
|
+ itemGroupQuery.setWhere("t1.isonsale=1");
|
|
|
+ itemGroupQuery.setWhere("t2.ismodule", content.getLongValue("ismodule"));
|
|
|
+ itemGroupQuery.setWhere("t1.sa_brandid", brandids.toArray());
|
|
|
+ itemGroupQuery.setWhere(where);
|
|
|
+ if (!content_where.getStringValue("condition").isEmpty()) {
|
|
|
+ itemGroupQuery.setOrderBy("t1.groupname like'%" + content_where.getString("condition") + "%' desc");
|
|
|
+ }
|
|
|
+ if(!itemclassids_where.toString().isEmpty()){
|
|
|
+ itemGroupQuery.setWhere("exists(" +
|
|
|
+ "select * from sa_itemgroupmx t10 " +
|
|
|
+ "inner join sa_itemsaleclass t11 on t10.itemid=t11.itemid " +
|
|
|
+ "where t10.sa_itemgroupid=t1.sa_itemgroupid and t11.itemclassid in("+itemclassids_where+"))");
|
|
|
+ }
|
|
|
+ itemGroupQuery.setPage(pageSize, pageNumber);
|
|
|
+ Rows itemGroupRows = itemGroupQuery.query();
|
|
|
+
|
|
|
+ //商品组价格查询
|
|
|
+ QuerySQL itempriceQuery = SQLFactory.createQuerySQL(this, "sa_itemgroupmx", "sa_itemgroupid").setTableAlias("t1");
|
|
|
+ itempriceQuery.addJoinTable(JOINTYPE.inner, "sa_itemprice", "t2", "t1.itemid=t2.itemid");
|
|
|
+ itempriceQuery.addQueryFields("maxprice", "max(t2.price)");
|
|
|
+ itempriceQuery.addQueryFields("minprice", "min(t2.price)");
|
|
|
+ itempriceQuery.setWhere("t1.sa_itemgroupid", itemGroupRows.toArrayList("sa_itemgroupid"));
|
|
|
+ itempriceQuery.setWhere("t2.pricegrade", pricegrade);
|
|
|
+ if(!itemclassids_where.toString().isEmpty()){
|
|
|
+ itemGroupQuery.setWhere("exists(" +
|
|
|
+ "select * from sa_itemsaleclass t11 " +
|
|
|
+ "where t1.itemid=t11.itemid and t11.itemclassid in("+itemclassids_where+"))");
|
|
|
+ }
|
|
|
|
|
|
+ itempriceQuery.addGroupBy("t1.sa_itemgroupid");
|
|
|
+ RowsMap itemGroupPriceRowsMap = itempriceQuery.query().toRowsMap("sa_itemgroupid");
|
|
|
|
|
|
- Long id = sa_itemgroupid;
|
|
|
- if (itemgroupScemeRowsMap.get(id.toString()).isNotEmpty()) {
|
|
|
- if (itemgroupScemeRowsMap.get(id.toString()).get(0).getLong("sa_customschemeid") > 0) {
|
|
|
- row2.put("isscheme", true);
|
|
|
- } else {
|
|
|
- row2.put("isscheme", false);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- row2.put("isscheme", false);
|
|
|
- }
|
|
|
- }
|
|
|
+ ArrayList<Long> itemgroupids = itemGroupRows.toArrayList("sa_itemgroupid", new ArrayList<>());
|
|
|
+ RowsMap itemgroupScemeRowsMap = Itemgroup.getItemgroupScemeid(this, itemgroupids);
|
|
|
|
|
|
- ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
|
|
|
- /**
|
|
|
+ ArrayList<Long> itemgroupDefaultItems = itemGroupRows.toArrayList("itemid", new ArrayList<>());//商品组默认商品ID
|
|
|
+ /*
|
|
|
* 查询商品明细
|
|
|
*/
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "查询商品列表");
|
|
|
- sqlFactory.addParameter_in("itemids", ids);
|
|
|
+ sqlFactory.addParameter_in("itemids", itemgroupDefaultItems);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
Rows itemrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
@@ -270,50 +181,75 @@ public class itemgroup extends Controller {
|
|
|
row.put("gradeprice", itemPrice.getMarketprice());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
RowsMap itemRowsMap = itemrows.toRowsMap("itemid");
|
|
|
|
|
|
//默认商品图片
|
|
|
Rows defaultImageRows = Item.getItemdefaultImage(this);
|
|
|
// 封面cover
|
|
|
- RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
|
|
|
+ RowsMap defaultItemCoverRowsMap = getAttachmentUrl("plm_item", itemgroupDefaultItems, "cover");
|
|
|
// 附件
|
|
|
- RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
|
|
|
+ RowsMap defaultItemAttRowsMap = getAttachmentUrl("plm_item", itemgroupDefaultItems);
|
|
|
// 附件
|
|
|
- RowsMap itemgroupRowsMap = getAttachmentUrl("sa_itemgroup", itemgroupids);
|
|
|
+ RowsMap itemgroupAttRowsMap = getAttachmentUrl("sa_itemgroup", itemgroupids);
|
|
|
|
|
|
|
|
|
- Rows rowsitemclass = dbConnect.runSqlQuery(
|
|
|
- " select t7.itemclassname,t6.itemid,t8.brandname,t7.itemclassfullname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
|
|
|
- + siteid + "'");
|
|
|
- RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
|
|
|
- for (Row row : rows) {
|
|
|
- Rows itemRows = itemRowsMap.get(row.getString("itemid"));
|
|
|
- row.put("item", itemRows);
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_itemsaleclass", "itemid", "classtype").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "plm_itemclass", "t2", "t1.itemclassid = t2.itemclassid AND t1.siteid = t2.siteid", "itemclassname", "itemclassfullname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sa_brand", "t3", "t2.sa_brandid = t3.sa_brandid AND t2.siteid = t3.siteid", "brandname");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("itemid", itemGroupRows.toArrayList("itemid"));
|
|
|
+ RowsMap itemclassRowsMap = querySQL.query().toRowsMap("itemid");
|
|
|
|
|
|
- Rows coverRows = coverRowsMap.get(row.getString("itemid"));
|
|
|
- if (coverRows.isEmpty()) {
|
|
|
- if (!defaultImageRows.isEmpty()) {
|
|
|
- row.put("cover", defaultImageRows.get(0).getString("url"));
|
|
|
- } else {
|
|
|
- row.put("cover", "");
|
|
|
- }
|
|
|
+ for (Row itemGroupRow : itemGroupRows) {
|
|
|
+ long sa_itemgroupid = itemGroupRow.getLong("sa_itemgroupid");
|
|
|
+
|
|
|
+ //设置标签
|
|
|
+ itemGroupRow.put("tag1", DataTag.queryTag(this, "sa_itemgroup", sa_itemgroupid, false));
|
|
|
+
|
|
|
+ //设置商品组价格
|
|
|
+ Rows itemGroupPriceRows = itemGroupPriceRowsMap.get(String.valueOf(sa_itemgroupid));
|
|
|
+ if (itemGroupPriceRows.isEmpty()) {
|
|
|
+ itemGroupRow.put("maxprice", 0);
|
|
|
+ itemGroupRow.put("minprice", 0);
|
|
|
} else {
|
|
|
- row.put("cover", coverRows.get(0).getString("url"));
|
|
|
+ itemGroupRow.put("maxprice", itemGroupPriceRows.get(0).getBigDecimal("maxprice"));
|
|
|
+ itemGroupRow.put("minprice", itemGroupPriceRows.get(0).getBigDecimal("minprice"));
|
|
|
}
|
|
|
|
|
|
- if ((itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows())).isNotEmpty()) {
|
|
|
- row.put("attinfos", itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows()));
|
|
|
+ //设置方案
|
|
|
+ if (itemgroupScemeRowsMap.containsKey(String.valueOf(sa_itemgroupid)) && itemgroupScemeRowsMap.get(String.valueOf(sa_itemgroupid)).get(0).getLong("sa_customschemeid") > 0) {
|
|
|
+ itemGroupRow.put("isscheme", true);
|
|
|
} else {
|
|
|
- if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
|
|
|
- row.put("attinfos", defaultImageRows);
|
|
|
- } else {
|
|
|
- row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
- }
|
|
|
+ itemGroupRow.put("isscheme", false);
|
|
|
}
|
|
|
- row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
|
|
|
+
|
|
|
+ //设置默认商品详情
|
|
|
+ itemGroupRow.put("item", itemRowsMap.get(itemGroupRow.getString("itemid")));
|
|
|
+
|
|
|
+ //设置默认商品图片
|
|
|
+ Rows coverRows = defaultItemCoverRowsMap.get(itemGroupRow.getString("itemid"));
|
|
|
+ if (coverRows.isNotEmpty()) {
|
|
|
+ itemGroupRow.put("cover", coverRows.get(0).getString("url"));
|
|
|
+ } else if (defaultImageRows.isNotEmpty()) {
|
|
|
+ itemGroupRow.put("cover", defaultImageRows.get(0).getString("url"));
|
|
|
+ } else {
|
|
|
+ itemGroupRow.put("cover", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((itemgroupAttRowsMap.getOrDefault(itemGroupRow.getString("sa_itemgroupid"), new Rows())).isNotEmpty()) {
|
|
|
+ itemGroupRow.put("attinfos", itemgroupAttRowsMap.get(itemGroupRow.getString("sa_itemgroupid")));
|
|
|
+ } else if ((defaultItemAttRowsMap.getOrDefault(itemGroupRow.getString("itemid"), new Rows())).isNotEmpty()) {
|
|
|
+ itemGroupRow.put("attinfos", defaultItemAttRowsMap.get(itemGroupRow.getString("itemid")));
|
|
|
+ } else {
|
|
|
+ itemGroupRow.put("attinfos", defaultImageRows);
|
|
|
+ }
|
|
|
+
|
|
|
+ itemGroupRow.put("itemclass", itemclassRowsMap.get(itemGroupRow.getString("itemid")));
|
|
|
}
|
|
|
|
|
|
- return getSucReturnObject().setData(rows).toString();
|
|
|
+ return getSucReturnObject().setData(itemGroupRows).toString();
|
|
|
|
|
|
}
|
|
|
|