zhijiezhao 3 anni fa
parent
commit
d2142c1e59

+ 3 - 1
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -180,9 +180,11 @@ public interface ProductDao extends CrudDao<Product> {
 
     List<Integer> getProductIdByBrandId(String brandId);
 
-    List<Shop> findSepcialShopList();
+    List<CmShop> findSepcialShopList();
 
     void updateMainImage(Product product);
 
     String getSplitCodeByProductId(Integer productID);
+
+    List<CmSplitCode> findSplitCodesByShopId(Integer shopID);
 }

+ 12 - 1
src/main/java/com/caimei/modules/product/entity/CmShop.java

@@ -3,6 +3,7 @@ package com.caimei.modules.product.entity;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * shop
@@ -12,7 +13,10 @@ import java.math.BigDecimal;
 
 public class CmShop implements Serializable {
     private Integer shopID;
-
+    /**
+     * 虚拟字段,页面使用
+     */
+    private List<CmSplitCode> splitCodes;
     /**
      * 对应的userId
      */
@@ -361,6 +365,13 @@ public class CmShop implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    public List<CmSplitCode> getSplitCodes() {
+        return splitCodes;
+    }
+
+    public void setSplitCodes(List<CmSplitCode> splitCodes) {
+        this.splitCodes = splitCodes;
+    }
 
     public Integer getShopID() {
         return shopID;

+ 42 - 0
src/main/java/com/caimei/modules/product/entity/CmSplitCode.java

@@ -0,0 +1,42 @@
+package com.caimei.modules.product.entity;
+
+import java.io.Serializable;
+
+public class CmSplitCode implements Serializable {
+    private Integer shopId;
+    private String splitCode;
+    private String codeName;
+    private String email;
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public String getSplitCode() {
+        return splitCode;
+    }
+
+    public void setSplitCode(String splitCode) {
+        this.splitCode = splitCode;
+    }
+
+    public String getCodeName() {
+        return codeName;
+    }
+
+    public void setCodeName(String codeName) {
+        this.codeName = codeName;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+}

+ 6 - 1
src/main/java/com/caimei/modules/product/service/ProductService.java

@@ -7,6 +7,7 @@ import com.caimei.modules.common.utils.UploadUtils;
 import com.caimei.modules.product.dao.*;
 import com.caimei.modules.product.entity.*;
 import com.caimei.modules.sys.utils.UploadImageUtils;
+import com.caimei.modules.user.entity.SplitCode;
 import com.caimei.po.ProductImage;
 import com.caimei.po.ProductLadderPrice;
 import com.caimei.po.Shop;
@@ -552,7 +553,11 @@ public class ProductService extends CrudService<ProductDao, Product> {
         return productDao.findProductDescribe(productID);
     }
 
-    public List<Shop> findSepcialShopList() {
+    public List<CmShop> findSepcialShopList() {
         return productDao.findSepcialShopList();
     }
+
+    public List<CmSplitCode> getCodes(Integer shopId) {
+        return productDao.findSplitCodesByShopId(shopId);
+    }
 }

+ 9 - 2
src/main/java/com/caimei/modules/product/web/ProductNewController.java

@@ -251,7 +251,7 @@ public class ProductNewController extends BaseController {
     @RequestMapping(value = "productAdd")
     public String addProduct(Product product, Model model) {
         List<CmBrand> brandList = productService.findBrandList();
-        List<Shop> shopList = productService.findSepcialShopList();
+        List<CmShop> shopList = productService.findSepcialShopList();
         //解析商品搜索关键字(搜索关键词目前最多只能5个)
         String searchKey = product.getSearchKey();
         List<String> searchKeyList = new ArrayList<String>(5);
@@ -284,6 +284,12 @@ public class ProductNewController extends BaseController {
         return "modules/product-new/cmNewProductForm";
     }
 
+    @RequestMapping(value = "getCodes")
+    @ResponseBody
+    public List<CmSplitCode> getCodes(Integer shopId) {
+        return productService.getCodes(shopId);
+    }
+
     @RequiresPermissions("product:product:view")
     @RequestMapping(value = "productEdit")
     public String editProduct(Product product, Model model) {
@@ -312,10 +318,11 @@ public class ProductNewController extends BaseController {
             product.setBigTypeID(0);
             product.setSmallTypeID(0);
             product.setTinyTypeID(0);
+            product.setShopType(2);
         }
         product.setCommodityType(StringUtils.isEmpty(product.getCommodityType()) ? "0" : product.getCommodityType());
         List<CmBrand> brandList = productService.findBrandList();
-        List<Shop> shopList = productService.findSepcialShopList();
+        List<CmShop> shopList = productService.findSepcialShopList();
         Map<String, Object> classify = productService.findClassify();
         List<Province> provinceList = areaService.loadProvince();
         List<CmProductCombination> combinationList = cmProductCombinationService.findProductCombinationList();

+ 9 - 2
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -1888,10 +1888,17 @@
 	<select id="findProductDescribe" resultType="java.lang.String">
 		select productDescribe from product where productID = #{productID}
 	</select>
-	<select id="findSepcialShopList" resultType="com.caimei.po.Shop">
-		select name,shopId from shop where shopType=2
+	<select id="findSepcialShopList" resultType="com.caimei.modules.product.entity.CmShop">
+		select name,shopID
+		from shop
+		where shopType=2
 	</select>
     <select id="getSplitCodeByProductId" resultType="java.lang.String">
 		select splitCode from product where productID = #{productID}
 	</select>
+	<select id="findSplitCodesByShopId" resultType="com.caimei.modules.product.entity.CmSplitCode">
+		select shopId,commercialCode as splitCode,codeDetail as codeName,email
+		from cm_shop_splitcode
+		where shopId = #{shopID}
+	</select>
 </mapper>

+ 40 - 7
src/main/webapp/WEB-INF/views/modules/product-new/productEdit.jsp

@@ -149,7 +149,12 @@
 <body>
 <ul class="nav nav-tabs">
     <li><a href="${ctx}/product/new/list">商品信息列表</a></li>
-    <li class="active"><a href="${ctx}/product/new/productEdit?id=${product.id}">商品信息编辑</a></li>
+    <c:if test="${not empty product.id}">
+        <li class="active"><a href="${ctx}/product/new/productEdit?id=${product.id}">商品信息编辑</a></li>
+    </c:if>
+    <c:if test="${empty product.id}">
+        <li class="active"><a href="${ctx}/product/new/productEdit?id=${product.id}">发布特殊供应商商品</a></li>
+    </c:if>
 </ul>
 <form:form id="inputForm" modelAttribute="product"
            action="${ctx}/product/new/productSave?searchShopID=${product.searchShopID}&searchShopName=${product.searchShopName}&searchBigTypeID=${product.searchBigTypeID}&searchSmallTypeID=${product.searchSmallTypeID}&searchTinyTypeID=${product.searchTinyTypeID}&searchValidFlag=${product.searchValidFlag}&searchActStatus=${product.searchActStatus}&searchProductType=${product.searchProductType}&searchBrandID=${product.searchBrandID}&searchPreferredFlag=${product.searchPreferredFlag}&searchProductCategory=${product.searchProductCategory}&editFlag=${product.editFlag}&shopType=${product.shopType}"
@@ -234,11 +239,13 @@
         </tr>
         <c:if test="${product.shopType == 2}">
         <tr>
-                <th><span style="color: red">*</span>供应商:</th>
+            <th><span style="color: red">*</span>供应商:</th>
             <td colspan="3">
-                <form:select path="shopID" class="input-small required">
+                <form:select path="shopID" class="input-small required" onchange="getCodes(this.value)">
                     <form:option value="" label="请选择"/>
-                    <form:options items="${shopList}" itemLabel="name" itemValue="shopID" htmlEscape="false"/>
+                    <c:forEach items="${shopList}" var="shop" varStatus="index">
+                            <form:option value="${shop.shopID}" label="${shop.name}"/>
+                    </c:forEach>
                 </form:select>
             </td>
         </tr>
@@ -499,13 +506,19 @@
         <tr>
             <th>线上分账账号:</th>
             <td colspan="3">
-                <form:select path="splitCode" class="select-ele input-medium required">
+                <c:if test="${not empty product.productID}">
+                <form:select path="splitCode" class="select-ele input-medium">
                     <form:option value="" label="请选择"/>
                     <c:forEach items="${splitCodeList}" var="splitCodeList" varStatus="index">
-                        <form:option value="${splitCodeList.splitCode}" label="${splitCodeList.splitCode} ${splitCodeList.codeRemark}"/>
+                        <form:option value="${splitCodeList.splitCode}" label="${splitCodeList.codeRemark}"/>
                     </c:forEach>
                 </form:select>
-<%--                <form:input path="splitCode" type="text" id="splitCode" maxlength="15"/>--%>
+                </c:if>
+                <c:if test="${empty product.productID}">
+                    <form:select path="splitCode" class="select-ele input-medium" id="getCode">
+                        <form:option value="" label="请选择"/>
+                    </form:select>
+                </c:if>
             </td>
         </tr>
         <tr id="taxPointDiv">
@@ -894,6 +907,26 @@
     <%--    });--%>
     <%--});--%>
 
+    function getCodes(data){
+
+        var opts = "<option value=''>请选择</option>";
+        $.ajax({
+            type: "POST",
+            url: "${ctx}/product/new/getCodes",
+            data: {"shopId": data},
+            success: function (res) {
+                console.log("data------------------->"+res)
+                for (let i = 0; i < res.length; i++) {
+                    opts += "<option value='" + res[i].splitCode + "'>" + res[i].codeName + "</option>";
+                }
+                console.log(opts);
+                $("#getCode").html('').append(opts);
+                },
+            error: function (res) {
+            }
+        });
+    }
+
     //图片初始化
     if(${product.shopType == 2}){
     $(function () {

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/user/newCmShopForm.jsp

@@ -792,11 +792,11 @@
                         <div id="paramsItem" class="paramsItem">
                             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<form:input
                                 path="splitCodes[${varIndex.index}].splitCode" id="paramsName"
-                                maxlength="8" placeholder="请输入分帐商户号" class="input-small"/>
+                                maxlength="15" placeholder="请输入分帐商户号" class="input-small"/>
                             <form:input path="splitCodes[${varIndex.index}].email" id="email"
-                                        maxlength="10" placeholder="请输入对应邮箱号" class="input-small"/>
+                                        maxlength="15" placeholder="请输入对应邮箱号" class="input-small"/>
                             <form:input path="splitCodes[${varIndex.index}].codeRemark" id="paramsContent"
-                                        maxlength="10" placeholder="请输入账户备注"
+                                        maxlength="15" placeholder="请输入账户备注"
                                         class="input-small"/>
                             <span type="button" style="cursor: pointer;color: #0B61A4"
                                   onclick="deleteParams(this)">删除</span>