|
|
@@ -19,11 +19,14 @@ import common.data.Rows;
|
|
|
import common.data.RowsMap;
|
|
|
import common.data.SQLFactory;
|
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.LinkedHashSet;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
@API(title = "商品组")
|
|
|
public class itemgroup extends Controller {
|
|
|
@@ -342,14 +345,77 @@ public class itemgroup extends Controller {
|
|
|
@API(title = "商品组列表", apiversion = R.ID20221223165503.v1.class)
|
|
|
@CACHEING
|
|
|
public String querymx() throws YosException {
|
|
|
-
|
|
|
+ Set colorList = new LinkedHashSet();
|
|
|
+ Set specList = new LinkedHashSet();
|
|
|
+ Set materialList = new LinkedHashSet();
|
|
|
+ int count=0;
|
|
|
+ String color=content.getStringValue("color");
|
|
|
+ String spec=content.getStringValue("spec");
|
|
|
+ String material=content.getStringValue("material");
|
|
|
+ if(StringUtils.isBlank(color)){
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(spec)){
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(material)){
|
|
|
+ count++;
|
|
|
+ }
|
|
|
/**
|
|
|
* SQL商品组明细查询参数设置并查询
|
|
|
*/
|
|
|
+ Rows rows = null;
|
|
|
SQLFactory factory = new SQLFactory(this, "商品组明细查询");
|
|
|
factory.addParameter("sa_itemgroupid", content.getString("sa_itemgroupid"));
|
|
|
factory.addParameter("siteid", siteid);
|
|
|
- Rows rows = dbConnect.runSqlQuery(factory.getSQL());
|
|
|
+
|
|
|
+ if(count==3){
|
|
|
+ factory.addParameter_SQL("where", "1=1");
|
|
|
+ rows = dbConnect.runSqlQuery(factory.getSQL());
|
|
|
+ }else if(count==2){
|
|
|
+ if(StringUtils.isNotBlank(color)){
|
|
|
+ factory.addParameter_SQL("where", "1=1 and t2.color='"+color+"'");
|
|
|
+ }else if(StringUtils.isNotBlank(spec)){
|
|
|
+ factory.addParameter_SQL("where", "1=1 and t2.spec='"+spec+"'");
|
|
|
+ }else if(StringUtils.isNotBlank(material)){
|
|
|
+ factory.addParameter_SQL("where", "1=1 and t3.material='"+material+"'");
|
|
|
+ }
|
|
|
+ rows = dbConnect.runSqlQuery(factory.getSQL());
|
|
|
+
|
|
|
+ }else if(count==1){
|
|
|
+ if(StringUtils.isBlank(color)){
|
|
|
+ factory.addParameter_SQL("where", "1=1 and t2.spec='"+spec+"' and t3.material='"+material+"'");
|
|
|
+ }else if(StringUtils.isBlank(spec)){
|
|
|
+ factory.addParameter_SQL("where", "1=1 and t2.spec='"+color+"' and t3.material='"+material+"'");
|
|
|
+ }else if(StringUtils.isBlank(material)){
|
|
|
+ factory.addParameter_SQL("where", "1=1 and t2.spec='"+spec+"' and t2.color='"+color+"'");
|
|
|
+ }
|
|
|
+ rows = dbConnect.runSqlQuery(factory.getSQL());
|
|
|
+ }
|
|
|
+ if(!rows.isEmpty()){
|
|
|
+ for (Row row : rows) {
|
|
|
+ if(StringUtils.isNotBlank(row.getString("color"))){
|
|
|
+ colorList.add(row.getString("color"));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(row.getString("spec"))){
|
|
|
+ specList.add(row.getString("spec"));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(row.getString("material"))){
|
|
|
+ materialList.add(row.getString("material"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(StringUtils.isNotBlank(content.getString("color"))){
|
|
|
+ colorList.add(content.getString("color"));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(content.getString("spec"))){
|
|
|
+ specList.add(content.getString("spec"));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(content.getString("material"))){
|
|
|
+ materialList.add(content.getString("material"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询商品明细
|
|
|
@@ -402,6 +468,9 @@ public class itemgroup extends Controller {
|
|
|
row.put("brand", brandRowsMap.get(row.getString("itemid")));
|
|
|
}
|
|
|
JSONObject oject = new JSONObject();
|
|
|
+ oject.put("colorRows", colorList);
|
|
|
+ oject.put("specRows", specList);
|
|
|
+ oject.put("materialRows", materialList);
|
|
|
oject.put("rows", rows);
|
|
|
oject.put("item", itemrows);
|
|
|
return getSucReturnObject().setData(oject).toString();
|