Browse Source

订单修改

wangxiaoming 5 years ago
parent
commit
80baa6de99

+ 19 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductColor.java

@@ -57,6 +57,9 @@ public class ProductColor implements Serializable {
 
     private Integer isUpdate;        //是否修改过   1:修改过   2:未曾修改
 
+    private String colorIds;       //颜色id
+    private String[] colorIdStr;       //颜色id
+
     public String getProductName() {
         return productName;
     }
@@ -225,6 +228,22 @@ public class ProductColor implements Serializable {
         this.isUpdate = isUpdate;
     }
 
+    public String getColorIds() {
+        return colorIds;
+    }
+
+    public void setColorIds(String colorIds) {
+        this.colorIds = colorIds;
+    }
+
+    public String[] getColorIdStr() {
+        return colorIdStr;
+    }
+
+    public void setColorIdStr(String[] colorIdStr) {
+        this.colorIdStr = colorIdStr;
+    }
+
     @Override
     public String toString() {
         return "ProductColor{" +

+ 6 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productMapper.xml

@@ -67,6 +67,12 @@
             <if test="typeCompany != null and typeCompany != ''">
                 AND pt.type_company  = #{typeCompany}
             </if >
+            <if test="colorIdStr != null and colorIdStr != ''">
+                AND c.color_id IN
+                <foreach collection="colorIdStr" item="node" index="index" separator="," open="(" close=")">
+                    #{node}
+                </foreach >
+            </if>
         </where>
     </select>
 

+ 69 - 76
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminSalesOrderController.java

@@ -4,6 +4,9 @@ import com.iamberry.rst.core.cm.CompanyInfo;
 import com.iamberry.rst.core.cm.SalesOrder;
 import com.iamberry.rst.core.cm.SalesOrderItem;
 import com.iamberry.rst.core.cm.StoreInfo;
+import com.iamberry.rst.core.dm.DealerChannel;
+import com.iamberry.rst.core.dm.DealerProduct;
+import com.iamberry.rst.core.dm.DealerProductStore;
 import com.iamberry.rst.core.order.*;
 import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.core.sys.Admin;
@@ -12,6 +15,7 @@ import com.iamberry.rst.faces.cm.CompanyInfoService;
 import com.iamberry.rst.faces.cm.SalesOrderService;
 import com.iamberry.rst.faces.cm.StoreInfoService;
 import com.iamberry.rst.faces.dm.DealerChannelService;
+import com.iamberry.rst.faces.dm.DealerProductService;
 import com.iamberry.rst.faces.order.EfastOrderService;
 import com.iamberry.rst.faces.order.LogisticsInfoService;
 import com.iamberry.rst.faces.order.OrderBatchService;
@@ -76,6 +80,8 @@ public class AdminSalesOrderController {
     private OrderWarehouseService orderWarehouseService;
     @Autowired
     private DealerChannelService dealerChannelService;
+    @Autowired
+    private DealerProductService dealerProductService;
     /**
      * 分页查询订单列表信息
      * @param request
@@ -1941,87 +1947,74 @@ public class AdminSalesOrderController {
 
     @ResponseBody
     @RequestMapping("/get_product")
-    public ResponseJson getProduct(HttpServletRequest request, ProductColor productColor,Integer storeId) throws Exception {
+    public ResponseJson getProduct(HttpServletRequest request, ProductColor productColor,Integer storeId,Integer salesOrderStatus) throws Exception {
         ResponseJson rj =  new ResponseJson(200, "SUCCESS", 200);
+
+        if(productColor.getColorIds()!=null && !"".equals(productColor.getColorIds())){
+            String[] colorIdStr = productColor.getColorIds().split("_");
+            productColor.setColorIdStr(colorIdStr);
+        }
         productColor.setColorStatus(1);
         List<ProductColor> productColorList = productService.listproductAndColor(productColor);
 
-//        DealerChannel dealerChannel = new DealerChannel();
-//        boolean flag = true;
-//        if(storeId != null){
-//            dealerChannel.setStoreId(storeId);
-//            List<DealerChannel>  dealerChannelList = dealerChannelService.getDealerChannelList(dealerChannel);
-//            if(dealerChannelList!= null && dealerChannelList.size() > 0){
-//                dealerChannel = dealerChannelList.get(0);
-//            }else{
-//                order.setReturnStatus("error");
-//                order.setReturnMsg("订单导入失败-查询店铺对应客户信息失败,店铺ID:"+order.getStoreId()+"。");
-//                order.setPlatformOrderId("1");
-//                flag = false;
-//            }
-//
-//            if(flag){
-//                if(1 == dealerChannel.getDealerSelfOperated()){
-//                    //是否自营 1:自营 2:非自营
-//                    String colorDiscount = "-1";
-//                    colorDiscount = getValue(temp.getCell(discountColumnIndex)).trim();
-//                    if(colorDiscount != null && !"".equals(colorDiscount)){
-//                        colorDiscount = colorDiscount.replaceAll("\\r|\\r|\\n","");
-//                    }
-//                    if(colorDiscount == null || "".equals(colorDiscount)){
-//                        order.setReturnStatus("error");
-//                        order.setReturnMsg("价格不正确"+"。");
-//                        order.setPlatformOrderId("1");
-//                    }else{
-//                        // 计算单个价格
-//                        Double colorDiscountDou = Double.valueOf(colorDiscount);
-//                        colorDiscountDou = colorDiscountDou*100/orderNumByInt;
-//                        order.setOrderProductDiscount(colorDiscountDou.intValue());
-//                        order.setOrderProductPrice(colorDiscountDou.intValue());
-//                        //赋值小结
-//                        Double orderTotal = Double.valueOf(colorDiscount);
-//                        orderTotal = orderTotal*100;
-//                        order.setOrderTotal(orderTotal.intValue());
-//                    }
-//                }else{
-//                    //2:非自营
-//                    DealerProduct dealerProduct = new DealerProduct();
-//                    dealerProduct.setDealerId(dealerChannel.getDealerId());
-//                    dealerProduct.setColorBar(OrderProductBarCodeValue);
-//                    List<DealerProduct> dealerProductList = dealerProductService.getDealerProductAndStoreList(dealerProduct);
-//                    if(dealerProductList != null && dealerProductList.size() > 0){
-//                        for (DealerProduct dp:dealerProductList) {
-//                            if(1 == dp.getDealProdStoreArea()){
-//                                // 1:全部店铺
-//                                order.setOrderProductDiscount(dp.getDealProdPrice());
-//                                order.setOrderProductPrice(dp.getDealProdPrice());
-//                                order.setOrderTotal(dp.getDealProdPrice()*orderNumByInt);
-//                            }else{
-//                                // 2:部分店铺
-//                                for (DealerProductStore dps:dp.getDealerProductStoreList()) {
-//                                    if(order.getStoreId().equals(dps.getStoreId())){
-//                                        order.setOrderProductDiscount(dp.getDealProdPrice());
-//                                        order.setOrderProductPrice(dp.getDealProdPrice());
-//                                        order.setOrderTotal(dp.getDealProdPrice()*orderNumByInt);
-//                                    }
-//                                }
-//                            }
-//                        }
-//                    }else{
-//                        order.setReturnStatus("error");
-//                        order.setReturnMsg("订单导入-未能从该客户中获取到对应产品的信息,客户名称:"+dealerChannel.getDealerName()+",产品SKU:"+ OrderProductBarCodeValue+"。");
-//                        order.setPlatformOrderId("1");
-//                    }
-//                }
-//            }
-//
-//        }
-//
-//        for (:
-//             ) {
-//
-//        }
+        //是否自营 1:自营 2:非自营
+        Integer dealerSelfOperated=0;
+        if(salesOrderStatus == 1){
+            DealerChannel dealerChannel = new DealerChannel();
+            boolean flag = true;
+            if(storeId != null){
+
+                StoreInfo storeInfo = storeInfoService.getStoreInfoById(storeId);
+
+                dealerChannel.setStoreId(storeId);
+                List<DealerChannel>  dealerChannelList = dealerChannelService.getDealerChannelList(dealerChannel);
+                if(dealerChannelList!= null && dealerChannelList.size() > 0){
+                    dealerChannel = dealerChannelList.get(0);
+                }else{
+                    rj = ResponseJson.getFAILURE();
+                    rj.setResultMsg("查询店铺对应客户信息失败,店铺名称:"+storeInfo.getStoreName());
+                    return rj;
+                }
+
+                dealerSelfOperated = dealerChannel.getDealerSelfOperated();
+
+                if(2 == dealerChannel.getDealerSelfOperated()){
+                    //2:非自营
+                    for (ProductColor pc:productColorList) {
+                        DealerProduct dealerProduct = new DealerProduct();
+                        dealerProduct.setDealerId(dealerChannel.getDealerId());
+                        dealerProduct.setColorBar(pc.getColorBar());
+                        List<DealerProduct> dealerProductList = dealerProductService.getDealerProductAndStoreList(dealerProduct);
+                        if(dealerProductList != null && dealerProductList.size() > 0){
+                            for (DealerProduct dp:dealerProductList) {
+                                if(1 == dp.getDealProdStoreArea()){
+                                    // 1:全部店铺
+                                    pc.setColorDiscount(dp.getDealProdPrice());
+                                    pc.setColorPrice(dp.getDealProdPrice());
+                                }else{
+                                    // 2:部分店铺
+                                    for (DealerProductStore dps:dp.getDealerProductStoreList()) {
+                                        if(storeId.equals(dps.getStoreId())){
+                                            pc.setColorDiscount(dp.getDealProdPrice());
+                                            pc.setColorPrice(dp.getDealProdPrice());
+                                        }
+                                    }
+                                }
+                            }
+                        }else{
+                            rj = ResponseJson.getFAILURE();
+                            rj.setResultMsg("未能从该客户中获取到对应产品的信息,客户名称:"+dealerChannel.getDealerName()+";产品名称:"+ pc.getProductName() +"("+ pc.getColorName() +")。");
+                        }
+                    }
+                }
+            }else{
+                rj = ResponseJson.getFAILURE();
+                rj.setResultMsg("查询店铺对应客户信息失败,店铺ID为空。");
+                return rj;
+            }
+        }
         rj.addResponseKeyValue("productColorList",productColorList);
+        rj.addResponseKeyValue("dealerSelfOperated",dealerSelfOperated);
         return rj;
     }
 }

+ 18 - 6
watero-rst-web/src/main/webapp/WEB-INF/views/order/salesOrder/add_order.ftl

@@ -106,7 +106,7 @@
             <div class="row cl">
                 <label class="form-label col-1 col-sm-1">批次编号:</label>
                 <div class="formControls col-2 col-sm-2" style="">
-                    <input type="text" class="input-text" value="" placeholder="填写批次编号,新增可不填。" id="salesBatchId" name="salesBatchId">
+                    <input type="text" class="input-text trim_input" value="" placeholder="填写批次编号,新增可不填。" id="salesBatchId" name="salesBatchId">
                 </div>
             </div>
 
@@ -119,10 +119,10 @@
 				    </span>
                     </div>
                     <#--<div class="formControls col-2 col-sm-2">
-                    <span class="select-box">
-                        <select  class="select init_store"  name="salesStoreId" id="">
-                        </select>
-                    </span>
+                        <span class="select-box">
+                            <select  class="select init_store"  name="salesStoreId" id="">
+                            </select>
+                        </span>
                     </div>-->
                     <div class="formControls col-2 col-sm-2">
                         <input id="store_1" name="maktMaktx" class="input-text" list="datalist_1" value="" placeholder="输入店铺关键字或双击" datatype="*1-20"  />
@@ -206,7 +206,7 @@
                 </div>
             </div>
 
-            <div class="row cl" id="" style="">
+            <div class="row cl" id="product_color" style="">
                 <label class="form-label col-1 col-sm-1">产品信息:</label>
                 <div class="formControls col-10 col-sm-10">
                     <input type="button" style="color: #32a3d8;border: 1px solid #32a3d8;" class="btn add-order-button" onclick="add_product()" value="添加产品" >
@@ -228,6 +228,12 @@
                     </table>
                     <input type="hidden" id="orderItemString" name="orderItemString" value="" >
                 </div>
+                <br>
+            </div>
+
+            <div class="row cl" >
+                <label class="form-label col-1 col-sm-1"></label>
+                <div id="product_color_error" style="color: red;"></div>
             </div>
 
             <div class="row cl" id="" style="">
@@ -335,8 +341,14 @@
         }
     });
 
+    /*是否为修改*/
+    const isUpdate = false;
+
     /*如果修改信息时匹配地址出现失败,由此标识提醒一次,添加订单不需要次标识*/
     var isNameCorrect = true;
+
+    //所选店铺是否自营 1:自营 2:非自营
+    var dealerSelfOperated;
 </script>
 
 

+ 14 - 7
watero-rst-web/src/main/webapp/WEB-INF/views/order/salesOrder/update_order.ftl

@@ -137,10 +137,10 @@
 				    </span>
                     </div>
                     <div class="formControls col-2 col-sm-2">
-                    <span class="select-box">
-                        <select  class="select init_store"  name="salesStoreId" id="" ulcId="${order.salesStoreId!""}" >
-                        </select>
-                    </span>
+                        <span class="select-box">
+                            <select  class="select init_store"  name="salesStoreId" id="" ulcId="${order.salesStoreId!""}" >
+                            </select>
+                        </span>
                     </div>
                 </div>
 
@@ -217,7 +217,7 @@
                 </div>
             </div>
 
-            <div class="row cl" id="" style="">
+            <div class="row cl" id="product_color" style="">
                 <label class="form-label col-1 col-sm-1">商品信息:</label>
                 <div class="formControls col-10 col-sm-10">
                     <input type="button" class="btn btn-primary add-order-button" onclick="add_product()" value="添加商品" >
@@ -279,7 +279,10 @@
                 </div>
             </div>
 
-
+            <div class="row cl" >
+                <label class="form-label col-1 col-sm-1"></label>
+                <div id="product_color_error" style="color: red;"></div>
+            </div>
 
             <div class="row cl" id="" style="">
                 <label class="form-label col-1 col-sm-1" style="display: none">总金额:</label>
@@ -355,10 +358,14 @@
 
     var sc = initSalesChannel($(".sales_channel"));
 
+    /*是否为修改*/
+    const isUpdate = true;
+
     /*如果修改信息时匹配地址出现失败,由此标识提醒一次*/
     var isNameCorrect = false;
 
-
+    //所选店铺是否自营 1:自营 2:非自营
+    var dealerSelfOperated = 0;
 </script>
 </body>
 </html>

+ 82 - 8
watero-rst-web/src/main/webapp/common/js/salesOrder/salesOrder.js

@@ -2,15 +2,15 @@
 var allCustomerId = "";
 
 
+
 /**
  * 打开商品列表
  */
 function add_product() {
-    var storeId = $("#datalist_1").val();
+    var storeId = getStoreId();
     var salesOrderStatus = $("#salesOrderStatus").val();
     if(salesOrderStatus == 1 && !isEmpty(storeId)){
         vailErrorMsg_3($("#salesCompanyId"),"请选择店铺!");
-        return false;
     }
     layer_show("商品列表",url_path + "/admin/salesOrder/to_add_product","1000","500");
 }
@@ -72,6 +72,17 @@ $(function(){
                 }
             }
 
+            //检测颜色与店铺之间关系
+            if(!storeProductColor()){
+                vailErrorMsg_3($("#product_color"),"店铺与商品信息不匹配!");
+                return false;
+            }
+
+            //计算价格
+            if(dealerSelfOperated == 2){
+                calculatePrice();
+            }
+
             var addressProvince = $("#addressProvince").find("option:selected").text();
             var addressCity = $("#addressCity").find("option:selected").text();
             var addressCountry = $("#addressCountry").find("option:selected").text();
@@ -129,6 +140,61 @@ $(function(){
 });
 
 
+//检测颜色与店铺之间关系
+function  storeProductColor() {
+    var colorIds = '';
+    $("#add_product").find("tr").each(function(){
+        colorIds += $(this).find(".color_id").val() +'_';
+    });
+
+    var storeId = getStoreId();
+    var salesOrderStatus = $("#salesOrderStatus").val();
+    if(salesOrderStatus == 1 && !isEmpty(storeId)){
+        vailErrorMsg_3($("#salesCompanyId"),"请选择店铺!");
+        return false;
+    }
+
+    var flag = false;
+
+    $.ajax({
+        type: "POST",
+        data: {
+            colorIds : colorIds,
+            storeId : storeId,
+            salesOrderStatus : salesOrderStatus
+        },
+        url: url_path +"/admin/salesOrder/get_product",
+        async:false,
+        success: function(data){
+            if (data.returnCode == 200 && data.returnMsg.productColorList.length > 0 ) {
+                //所选店铺是否自营 1:自营 2:非自营
+                dealerSelfOperated = data.returnMsg.dealerSelfOperated;
+                flag = true;
+            }else{
+                $("#product_color_error").html(data.resultMsg);
+                flag = false;
+            }
+        }
+    });
+    return flag;
+}
+
+function getStoreId() {
+    var storeId;
+    if(isUpdate){
+        storeId = $(".init_store").val();
+    }else{
+        var $options=$("#datalist_1").children();
+        for(var i=0;i<$options.length;i++){
+            if($options.eq(i).val().trim()==$("#store_1").val().trim()){
+                storeId = $options.eq(i).attr("data-id");
+            }
+        }
+    }
+    return storeId;
+}
+
+
 /**
  * 客诉回调
  * @param colorIds
@@ -230,8 +296,8 @@ function setSelectProduct(colorIds){
     $("#all_add_product").show();
 
     var colorIdArray = colorIds.split("_");
-    for(var i=0;i<colorIdArray.length;i++){
-        var colorId = colorIdArray[i];
+    for(var j=0;j<colorIdArray.length;j++){
+        var colorId = colorIdArray[j];
         if(colorId == ""){
             break;
         }
@@ -247,23 +313,30 @@ function setSelectProduct(colorIds){
             continue;
         }
 
-        var storeId = $("#datalist_1").val();
+        var storeId = getStoreId();
         var salesOrderStatus = $("#salesOrderStatus").val();
         if(salesOrderStatus == 1 && !isEmpty(storeId)){
             vailErrorMsg_3($("#salesCompanyId"),"请选择店铺!");
-            return false;
         }
 
         $.ajax({
             type: "POST",
             data: {
                 colorId : colorId,
-                storeId : storeId
+                storeId : storeId,
+                salesOrderStatus : salesOrderStatus
             },
             url: url_path +"/admin/salesOrder/get_product",
+            async:false,
             success: function(data){
                 var html = "";
                 if (data.returnCode == 200 && data.returnMsg.productColorList.length > 0 ) {
+                    //所选店铺是否自营 1:自营 2:非自营
+                    dealerSelfOperated = data.returnMsg.dealerSelfOperated;
+                    // var priceHide = '';
+                    // if(data.returnMsg.dealerSelfOperated == 2){
+                    //     priceHide = 'readonly="readonly"';
+                    // }
                     for(var i=0;i<data.returnMsg.productColorList.length;i++){
                         var productColor = data.returnMsg.productColorList[i];
                         var discount = accDiv(productColor.colorDiscount,100);
@@ -280,7 +353,8 @@ function setSelectProduct(colorIds){
                             ' </tr>';
                     }
                 }else{
-                    html = '<tr class="text-c"><td colspan="12">没有搜索到商品,请重试!</td></tr>';
+                    $("#product_color_error").html(data.resultMsg);
+                    return false;
                 }
                 $("#add_product").append(html);
                 /*计算价格*/