Browse Source

订单详情的商品定制信息,没有值的隐藏不显示

eganwu 1 year ago
parent
commit
b0c4354acf
1 changed files with 41 additions and 10 deletions
  1. 41 10
      src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

+ 41 - 10
src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

@@ -14,6 +14,8 @@ import common.Controller;
 import common.DataFunction;
 import common.YosException;
 import common.data.*;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.util.StringUtil;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -433,20 +435,12 @@ public class OrderItemsHelper extends BaseClass {
                             if (!customschemeItem.getString("value").equals("spec")) {
 //                                customproperties.add(customschemeItem.getString("description") + ":" + itemRowsMap.get(itemid).get(0).getString(customschemeItem.getString("value")));
                             } else {
-                                String material = "选项:" + item.getStringValue("custommaterial");
-                                String colors = "颜色:" + item.getStringValue("customcolors");
-                                String cheek = "工艺:" + item.getStringValue("customcheek");
-                                String size = "尺寸:" + item.getStringValue("length") + "×" + item.getStringValue("width");
-                                customproperties.add(material + ";" + colors + ";" + cheek + ";" + size);
+                                customproperties.add(getcustomproperties(item));
                             }
 
                         }
                     } else {
-                        String material = "选项:" + item.getStringValue("custommaterial");
-                        String colors = "颜色:" + item.getStringValue("customcolors");
-                        String cheek = "工艺:" + item.getStringValue("customcheek");
-                        String size = "尺寸:" + item.getStringValue("length") + "×" + item.getStringValue("width");
-                        customproperties.add(material + ";" + colors + ";" + cheek + ";" + size);
+                        customproperties.add(getcustomproperties(item));
                     }
                 }
 
@@ -457,6 +451,43 @@ public class OrderItemsHelper extends BaseClass {
         return customproperties;
     }
 
+
+    public String getcustomproperties(JSONObject item) {
+        String material = item.getStringValue("custommaterial");
+        String colors = item.getStringValue("customcolors");
+        String cheek = item.getStringValue("customcheek");
+        String length = item.getStringValue("length", false, "0");
+        String width = item.getStringValue("width", false, "0");
+
+        String str = "";
+        if (!StringUtils.isBlank(material) && !material.equals("0")) {
+            str = "选项:" + material;
+        }
+        if (!StringUtils.isBlank(colors) && !colors.equals("0")) {
+            if (str.isEmpty()) {
+                str = "颜色:" + colors;
+            } else {
+                str = str + ";" + "颜色:" + colors;
+            }
+
+        }
+        if (!StringUtils.isBlank(cheek) && !cheek.equals("0")) {
+            if (str.isEmpty()) {
+                str = "工艺:" + cheek;
+            } else {
+                str = str + ";" + "工艺:" + cheek;
+            }
+
+        }
+        String size = "尺寸:" + length + "×" + width;
+        if (str.isEmpty()) {
+            str = size;
+        } else {
+            str = str + ";" + size;
+        }
+        return str;
+    }
+
     /**
      * 获取定制尺寸信息
      *