Ver código fonte

修改客户信息

liujiankang 7 anos atrás
pai
commit
9b0400da39

+ 8 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/customer/CustomerBasicService.java

@@ -98,6 +98,14 @@ public interface CustomerBasicService {
                                       BillingInfo billingInfo, TicketOpeningInfo ticketOpeningInfo) throws Exception;
 
     /**
+     * 修改客户基本信息
+     *
+     * @param customerBasicInfo
+     * @return
+     */
+    public void updateCustomerBasicInfo(CustomerBasicInfo customerBasicInfo,List<DockedContactInfo> dockedContactInfoList, List<ChannelSaleInfo> channelSaleInfoList,
+                                      BillingInfo billingInfo, TicketOpeningInfo ticketOpeningInfo) throws Exception;
+    /**
      * 查询所有省份
      * @param provinceId
      * @return

+ 40 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/customer/CustomerBasicServiceImpl.java

@@ -100,6 +100,46 @@ public class CustomerBasicServiceImpl implements CustomerBasicService{
     @Transactional
     public void saveCustomerBasicInfo(CustomerBasicInfo customerBasicInfo,List<DockedContactInfo> dockedContactInfoList, List<ChannelSaleInfo> channelSaleInfoList,
                                       BillingInfo billingInfo, TicketOpeningInfo ticketOpeningInfo) throws Exception{
+        logger.info("saveCustomerBasicInfo start...");
+        int customerId = -1;
+        int channelDivisionId = -1;
+        try {
+            customerBasicMapper.saveCustomerBasicInfo(customerBasicInfo);
+            customerId = customerBasicInfo.getCustomerId();
+            if(customerId != -1){
+                if(dockedContactInfoList != null && dockedContactInfoList.size()>1){
+                    dockedContactInfoList.remove(0);
+                    for (DockedContactInfo dockedContactInfo: dockedContactInfoList) {
+                        dockedContactInfo.setCustomerId(customerId);
+                        customerBasicMapper.saveDockedContactInfo(dockedContactInfo);
+                    }
+                }
+                if(channelSaleInfoList != null && channelSaleInfoList.size()>1){
+                    channelSaleInfoList.remove(0);
+                    for (ChannelSaleInfo channelSaleInfo: channelSaleInfoList) {
+                        channelSaleInfo.setCustomerId(customerId);
+                        customerBasicMapper.saveChannelDivisionInfo(channelSaleInfo);
+                        //channelSaleInfo.setChannelDivisionId(channelDivisionId);
+                        customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                    }
+                }
+                billingInfo.setCustomerId(customerId);
+                ticketOpeningInfo.setCustomerId(customerId);
+                customerBasicMapper.saveBillingInfo(billingInfo);
+                customerBasicMapper.saveTicketOpeningInfo(ticketOpeningInfo);
+            }
+            logger.info("saveCustomerBasicInfo end...");
+        }catch (Exception e){
+            logger.error("添加客户信息失败"+e.getMessage());
+            throw new RuntimeException("添加客户信息失败");
+        }
+
+    }
+
+    @Override
+    @Transactional
+    public void updateCustomerBasicInfo(CustomerBasicInfo customerBasicInfo,List<DockedContactInfo> dockedContactInfoList, List<ChannelSaleInfo> channelSaleInfoList,
+                                      BillingInfo billingInfo, TicketOpeningInfo ticketOpeningInfo) throws Exception{
         int customerId = -1;
         int channelDivisionId = -1;
         try {
@@ -151,7 +191,6 @@ public class CustomerBasicServiceImpl implements CustomerBasicService{
         }
 
     }
-
     public List<Province> queryProvinceList(String provinceId){
         return (List<Province>)customerBasicMapper.queryProvinceList(provinceId);
     }

+ 1 - 1
watero-rst-web/src/main/java/com/iamberry/rst/controllers/customer/CustomerBasicController.java

@@ -382,7 +382,7 @@ public class CustomerBasicController {
         }
         logger.info("-----------------修改客户信息开始----------------------");
             try {
-                customerBasicService.saveCustomerBasicInfo(customerBasicInfo,dockedContactInfoList,channelSaleInfoList,billingInfo,ticketOpeningInfo);
+                customerBasicService.updateCustomerBasicInfo(customerBasicInfo,dockedContactInfoList,channelSaleInfoList,billingInfo,ticketOpeningInfo);
                 isSaveSuccess = true;
             } catch (RuntimeException e) {
             isSaveSuccess = false;

+ 1 - 1
watero-rst-web/src/main/webapp/WEB-INF/views/customer/customer_basic_list.ftl

@@ -44,7 +44,7 @@
                         </#if>
                     </select>
                     <select class="my-select" name="cooperativeState">
-                        <option value ="1">合作状态</option>
+                        <option value ="">合作状态</option>
                     <#if cooperativeState??>
                         <option value ="1" <#if cooperativeState == 1>selected</#if>>意向合作</option>
                         <option value ="2" <#if cooperativeState == 2>selected</#if>>已经合作</option>

+ 239 - 40
watero-rst-web/src/main/webapp/WEB-INF/views/customer/update_customer_info.ftl

@@ -167,7 +167,7 @@
                         </tr>
                         </#list>
                     <#else>
-                    <tr><td colspan="5" class="td-manage text-c" >暂时没有联系人信息,请添加!</td></tr>
+                    <tr><td colspan="5" id="contactTbodyId"  class="td-manage text-c" >暂时没有联系人信息,请添加!</td></tr>
                     </#if>
                     </tbody>
                 </table>
@@ -255,7 +255,7 @@
                         </tr>
                         </#list>
                     <#else>
-                    <tr><td colspan="7" class="td-manage text-c" >暂时没有客户销售渠道信息,请添加!</td></tr>
+                    <tr><td colspan="7" class="td-manage text-c" id="channelTbodyId" >暂时没有客户销售渠道信息,请添加!</td></tr>
                     </#if>
                     </tbody>
                 </table>
@@ -471,6 +471,10 @@
         $("[name='promotingProducts']").change(function (){
             initSupplyPrice($(this).val());
         })
+        /*监听产品价格选择*/
+        $("[name='supplyPrice']").change(function (){
+            changeSupplyPrice($(this).val());
+        })
     })
 
     /*业务逻辑js控制 start*/
@@ -582,32 +586,32 @@
     /*根据渠道类别初始化渠道类型*/
     function initChannelType(channelCategory){
         var channelTypeListInfo = null;
-       /* if(channelCategory == null || channelCategory == ""){
-            var html = '<option value="">请选择渠道类别</option>';
-            $("[name='channelCategory']").html(html);
-        }else{*/
-            $.ajax({
-                type: "POST",
-                data: {
-                    channelCategoryId : channelCategory
-                },
-                url: "${path}/admin/customerBasic/query_channelTypeList",
-                async: true,
-                success: function(data){
-                    var html = '<option value="">请选择渠道类型</option>';
-                    if (data.returnCode == 200) {
-                        for(var i=0;i<data.returnMsg.channelTypeList.length;i++){
-                            channelTypeListInfo = data.returnMsg.channelTypeList[i];
-                            html += '<option value="'+ channelTypeListInfo.channelName +'">'+ channelTypeListInfo.channelType +'</option>';
-                        }
-                    }else{
-                        html = '';
+        /* if(channelCategory == null || channelCategory == ""){
+             var html = '<option value="">请选择渠道类别</option>';
+             $("[name='channelCategory']").html(html);
+         }else{*/
+        $.ajax({
+            type: "POST",
+            data: {
+                channelCategoryId : channelCategory
+            },
+            url: "${path}/admin/customerBasic/query_channelTypeList",
+            async: true,
+            success: function(data){
+                var html = '<option value="">请选择渠道类型</option>';
+                if (data.returnCode == 200) {
+                    for(var i=0;i<data.returnMsg.channelTypeList.length;i++){
+                        channelTypeListInfo = data.returnMsg.channelTypeList[i];
+                        html += '<option value="'+ channelTypeListInfo.channelName +'">'+ channelTypeListInfo.channelType +'</option>';
                     }
-                    $("[name='channelType']").html(html);
-                },
-                error: function(XmlHttpRequest, textStatus, errorThrown){
+                }else{
+                    html = '';
                 }
-            });
+                $("[name='channelType']").html(html);
+            },
+            error: function(XmlHttpRequest, textStatus, errorThrown){
+            }
+        });
         //}
     }
 
@@ -647,7 +651,7 @@
         //var supplyPriceInfo = null;
         if(promotingProductsId == null || promotingProductsId == ""){
             var html = '<option value="">请选择销售产品</option>';
-            $("[name='promotingProducts']").html(html);
+            //$("[name='promotingProducts']").html(html);
         }else{
             $.ajax({
                 type: "POST",
@@ -657,16 +661,17 @@
                 url: "${path}/admin/customerBasic/query_supplyPriceList",
                 async: true,
                 success: function(data){
-                    var html = '<option value="">请选择产品价格</option>';
+                    var html = '<option value="">手动输入产品价格</option>';
                     if (data.returnCode == 200) {
                         for(var i=0;i<data.returnMsg.supplyPriceList.length;i++){
                             var supplyPriceInfo = data.returnMsg.supplyPriceList[i];
-                            html += '<option value="'+ supplyPriceInfo.colorId +'">'+ supplyPriceInfo.colorPrice +'</option>';
+                            html += '<option value="'+ supplyPriceInfo.colorPrice +'">'+ supplyPriceInfo.colorPrice +'</option>';
                         }
                     }else{
                         html = '';
                     }
                     $("[name='supplyPrice']").html(html);
+                    $("#writeSupplyPrice").show();
                 },
                 error: function(XmlHttpRequest, textStatus, errorThrown){
                 }
@@ -674,13 +679,40 @@
         }
     }
 
+    /*监听产品价格选项*/
+    function changeSupplyPrice(supplyPrice){
+        if(supplyPrice == ""){
+            $("#writeSupplyPrice").show();
+        }else{
+            $("#writeSupplyPrice").hide();
+        }
+    }
+
     /*保存对接联系人信息到列表*/
     function toAddDockedContactInfo() {
         //var dockedContactInfoList =  new Array();
+        //document.getElementById("contactListId").innerHTML = "";
+        //$("#contactListId").innerHTML = "";
         var contactName = document.getElementById("contactName").value;
         var contactPhone = document.getElementById("contactPhone").value;
         var contactType = document.getElementById("contactType").value;
         var contactEmail = document.getElementById("contactEmail").value;
+        if(contactName == "" || contactName == null ){
+            layer.msg("联系人姓名不能为空");
+            return;
+        }
+        if(contactPhone == "" || contactPhone == null ){
+            layer.msg("电话不能为空");
+            return;
+        }
+        if(contactType == "" || contactType == null ){
+            layer.msg("职位/身份不能为空");
+            return;
+        }
+        if(contactEmail == "" || contactEmail == null ){
+            layer.msg("联系邮箱不能为空");
+            return;
+        }
         //var operation = "删除";
         var operation = "<a href='javascript:;' onclick='deleteContact(this)'>删除</a>";
         //"<a href='javascript:;' onclick='del(this)'>删除</a>";
@@ -697,19 +729,58 @@
             cell = row.insertCell();
             cell.innerHTML=operation;
         }
+        $("#contactTbodyId").hide();
         return false;
     }
     /*保存客户销售信息到列表*/
     function toAddChannelSaleInfo() {
-        //var channelSaleInfoList =  new Array();
         var channelCategory = document.getElementById("channelCategory").value;
+        if(channelCategory == "1"){
+            channelCategory = "电商";
+        }else if(channelCategory == "2"){
+            channelCategory = "特殊渠道";
+        }else if(channelCategory == "3"){
+            channelCategory = "线下";
+        }else if(channelCategory == "4"){
+            channelCategory = "海外";
+        }
         var channelType = document.getElementById("channelType").value;
         var channelName = document.getElementById("channelName").value;
         var promotingProducts = document.getElementById("promotingProducts").value;
+        var myselect=document.getElementById("promotingProducts");
+        var promotingProductsText = myselect.options[myselect.selectedIndex].text;
         var supplyPrice = document.getElementById("supplyPrice").value;
         var accountPeriod = document.getElementById("accountPeriod").value;
-        //var operation = "删除";
-         var operation = "<a href='javascript:;' onclick='deleteChannelSale(this)'>删除</a>";
+        if(accountPeriod == "1"){
+            accountPeriod = "先款";
+        }else if(accountPeriod == "2"){
+            accountPeriod = "月结";
+        }else if(accountPeriod == "3"){
+            accountPeriod = "两个月";
+        }
+        if(channelCategory == "" || channelCategory == null ){
+            layer.msg("渠道类别不能为空");
+            return;
+        }
+        if(channelType == "" || channelType == null ){
+            layer.msg("渠道类型不能为空");
+            return;
+        }
+        if(channelName == "" || channelName == null ){
+            layer.msg("渠道平台/名称不能为空");
+            return;
+        }
+        if(promotingProducts == "" || promotingProducts == null ){
+            layer.msg("销售产品不能为空");
+            return;
+        }
+        if(supplyPrice == "" || supplyPrice == null ){
+            layer.msg("供货价格不能为空");
+            return;
+        }
+        var promotingProductsHtml = '<input type="hidden" value="'+promotingProducts+'">';
+
+        var operation = "<a href='javascript:;' onclick='deleteChannelSale(this)' name='deleteChannelSale'>删除</a>";
         row = document.getElementById("saleTable").insertRow();
         if(row!=null){
             cell=row.insertCell();
@@ -719,7 +790,7 @@
             cell = row.insertCell();
             cell.innerHTML=channelName;
             cell = row.insertCell();
-            cell.innerHTML=promotingProducts;
+            cell.innerHTML=promotingProductsHtml+promotingProductsText;
             cell = row.insertCell();
             cell.innerHTML=supplyPrice;
             cell = row.insertCell();
@@ -727,6 +798,7 @@
             cell = row.insertCell();
             cell.innerHTML=operation;
         }
+        $("#channelTbodyId").hide();
         return false;
     }
     /*修改客户信息*/
@@ -743,6 +815,22 @@
         customerBasicInfo.customerCityCode = $("[name='customerCityCode']").val();
         customerBasicInfo.customerAddress = $("[name='customerAddress']").val();
         customerBasicInfo.customerRemarks = $("[name='customerRemarks']").val();
+        if(customerBasicInfo.customerName == "" || customerBasicInfo.customerName == null ){
+            layer.msg("客户名称不能为空");
+            return;
+        }
+        if(customerBasicInfo.customerIndustry == "" || customerBasicInfo.customerIndustry == null ){
+            layer.msg("客户行业不能为空");
+            return;
+        }
+        if(customerBasicInfo.customerProvinceCode == "" || customerBasicInfo.customerProvinceCode == null ){
+            layer.msg("客户省份不能为空");
+            return;
+        }
+        if(customerBasicInfo.customerCityCode == "" || customerBasicInfo.customerCityCode == null ){
+            layer.msg("客户城市不能为空");
+            return;
+        }
         //对接联系人信息
         var dockedContactInfoList =  new Array();
         $("#contactListId").find("tr").each(function (){
@@ -752,20 +840,41 @@
             dockedContactInfo.contactType = $("[name='contactType']").val();
             dockedContactInfo.contactEmail = $("[name='contactEmail']").val();
             dockedContactInfoList.push(dockedContactInfo);
-        })
+        });
+        if(dockedContactInfoList.length<2){
+            layer.msg("对接联系人信息不能为空");
+            return;
+        }
         var dockedContactInfoListJson = $("#dockedContactInfoJson").val(JSON.stringify(dockedContactInfoList));
         //客户销售渠道信息
         var channelSaleInfoList =  new Array();
         $("#channelSaleListId").find("tr").each(function (){
             var channelSaleInfo = {};
             channelSaleInfo.channelCategory = $("[name='channelCategory']").val();
+            if(channelSaleInfo.channelCategory == "电商"){
+                channelSaleInfo.channelCategory = "1";
+            }else if(channelSaleInfo.channelCategory == "特殊渠道"){
+                channelSaleInfo.channelCategory = "2";
+            }else if(channelSaleInfo.channelCategory == "线下"){
+                channelSaleInfo.channelCategory = "3";
+            }else if(channelSaleInfo.channelCategory == "海外"){
+                channelSaleInfo.channelCategory = "4";
+            }
             channelSaleInfo.channelType = $("[name='channelType']").val();
             channelSaleInfo.channelName = $("[name='channelName']").val();
             channelSaleInfo.promotingProducts = $("[name='promotingProducts']").val();
+            alert($("[name='promotingProducts']").val()+"--1");
             channelSaleInfo.supplyPrice = $("[name='supplyPrice']").val();
             channelSaleInfo.accountPeriod = $("[name='accountPeriod']").val();
+            if(channelSaleInfo.accountPeriod == "先款"){
+                channelSaleInfo.accountPeriod = "1";
+            }else if(channelSaleInfo.accountPeriod == "月结"){
+                channelSaleInfo.accountPeriod = "2";
+            }else if(channelSaleInfo.accountPeriod == "两个月"){
+                channelSaleInfo.accountPeriod = "3";
+            }
             channelSaleInfoList.push(channelSaleInfo);
-        })
+        });
         var channelSaleInfoListJson = $("#channelSaleInfoJson").val(JSON.stringify(channelSaleInfoList));
         //alert("dockedContactInfoList:"+dockedContactInfoList.length);
         //alert("channelSaleInfoList:"+channelSaleInfoList.length);
@@ -777,6 +886,25 @@
         billingInfo.accountNum = $("[name='accountNum']").val();
         billingInfo.receivablesName = $("[name='receivablesName']").val();
         billingInfo.receivablesPhone = $("[name='receivablesPhone']").val();
+        if(billingInfo.accountOpeningBranch == "" || billingInfo.accountOpeningBranch == null ){
+            layer.msg("开户支行不能为空");
+            return;
+        }
+        if(billingInfo.accountName == "" || billingInfo.accountName == null ){
+            layer.msg("账号名称不能为空");
+            return;
+        }
+        if(billingInfo.accountNum == "" || billingInfo.accountNum == null ){
+            layer.msg("账号不能为空");
+            return;
+        }
+        if(billingInfo.receivablesName == "" || billingInfo.receivablesName == null ){
+            layer.msg("收款人姓名不能为空");
+            return;
+        }if(billingInfo.receivablesPhone == "" || billingInfo.receivablesPhone == null ){
+            layer.msg("收款人手机不能为空");
+            return;
+        }
         //开票信息
         var ticketOpeningInfo = {};
         ticketOpeningInfo.ticketOpeningId = $("[name='ticketOpeningId']").val();
@@ -787,6 +915,40 @@
         ticketOpeningInfo.taxpayerIdentificationNum = $("[name='taxpayerIdentificationNum']").val();
         ticketOpeningInfo.ticketOpeningPhone = $("[name='ticketOpeningPhone']").val();
         ticketOpeningInfo.enterpriseAddress = $("[name='enterpriseAddress']").val();
+        if(ticketOpeningInfo.ticketType == "1" ){
+            if(ticketOpeningInfo.accountOpeningBranch == "" || ticketOpeningInfo.accountOpeningBranch == null ){
+                layer.msg("开户支行不能为空");
+                return;
+            }
+            if(ticketOpeningInfo.ticketOpeningAccount == "" || ticketOpeningInfo.ticketOpeningAccount == null ){
+                layer.msg("开票账户不能为空");
+                return;
+            }
+            if(ticketOpeningInfo.enterpriseName == "" || ticketOpeningInfo.enterpriseName == null ){
+                layer.msg("企业名称不能为空");
+                return;
+            }
+            if(ticketOpeningInfo.taxpayerIdentificationNum == "" || ticketOpeningInfo.taxpayerIdentificationNum == null ){
+                layer.msg("纳税人识别号不能为空");
+                return;
+            }
+            if(ticketOpeningInfo.ticketOpeningPhone == "" || ticketOpeningInfo.ticketOpeningPhone == null ){
+                layer.msg("开票电话不能为空");
+                return;
+            }if(ticketOpeningInfo.enterpriseAddress == "" || ticketOpeningInfo.enterpriseAddress == null ){
+                layer.msg("企业地址不能为空");
+                return;
+            }
+        }else{
+            if(ticketOpeningInfo.enterpriseName == "" || ticketOpeningInfo.enterpriseName == null ){
+                layer.msg("企业名称不能为空");
+                return;
+            }
+            if(ticketOpeningInfo.taxpayerIdentificationNum == "" || ticketOpeningInfo.taxpayerIdentificationNum == null ){
+                layer.msg("纳税人识别号不能为空");
+                return;
+            }
+        }
         //发送保存请求
         customerBasicInfoSaveForm.customerBasicInfo = customerBasicInfo;
         customerBasicInfoSaveForm.dockedContactInfoList = dockedContactInfoList;
@@ -805,8 +967,6 @@
             type: "POST",
             data: {
                 customerInfoJson:customerInfoJson,
-                /*dockedContactInfoListJson:dockedContactInfoListJson,
-                channelSaleInfoListJson:dockedContactInfoListJson,*/
                 dockedContactInfoList:dockedContactInfoList,
                 channelSaleInfoList:channelSaleInfoList,
                 billingInfoJson : billingInfoJson,
@@ -817,15 +977,16 @@
             success: function(data){
                 if (data.returnCode == 200) {
                     saveStates = "保存成功";
-                    alert(saveStates);
+                    layer.msg(saveStates,{icon: 1,time:1000});
+                    window.location.href= "${path}/admin/customerBasic/listCustomerBasic";
                 }else{
                     saveStates = "保存失败";
-                    alert(saveStates);
+                    layer.msg(saveStates,{icon: 5,time:1000});
                 }
             },
             error: function(XmlHttpRequest, textStatus, errorThrown){
                 saveStates = "保存失败";
-                alert(saveStates);
+                layer.msg(saveStates,{icon: 5,time:1000});
             }
         });
     }
@@ -834,11 +995,49 @@
     function deleteContact(x){
         $(x).parent().parent().remove();
         // tr.parentNode.removeChild(tr);
+        initContactInfoListBody();
     }
     // 删除客户销售渠道信息函数
     function deleteChannelSale(x){
         var tr = x.parentNode.parentNode;
         tr.parentNode.removeChild(tr);
+        initChannelSaleInfoListBody();
+    }
+
+    //监听对接联系人
+    function initContactInfoListBody() {
+        var dockedContactInfoList =  new Array();
+        $("#contactListId").find("tr").each(function (){
+            var dockedContactInfo = {};
+            dockedContactInfo.contactName = $("[name='contactName']").val();
+            dockedContactInfo.contactPhone = $("[name='contactPhone']").val();
+            dockedContactInfo.contactType = $("[name='contactType']").val();
+            dockedContactInfo.contactEmail = $("[name='contactEmail']").val();
+            dockedContactInfoList.push(dockedContactInfo);
+        })
+        if(dockedContactInfoList.length<2){
+            $("#contactTbodyId").show();
+            //document.getElementById("contactListId").innerHTML = "<tr><td colspan=\"5\" class=\"td-manage text-c\" >暂时没有联系人信息,请添加!</td></tr>";
+        }
+    }
+
+    //监听销售渠道
+    function initChannelSaleInfoListBody() {
+        var channelSaleInfoList =  new Array();
+        $("#channelSaleListId").find("tr").each(function (){
+            var channelSaleInfo = {};
+            channelSaleInfo.channelCategory = $("[name='channelCategory']").val();
+            channelSaleInfo.channelType = $("[name='channelType']").val();
+            channelSaleInfo.channelName = $("[name='channelName']").val();
+            channelSaleInfo.promotingProducts = $("[name='promotingProducts']").val();
+            channelSaleInfo.supplyPrice = $("[name='supplyPrice']").val();
+            channelSaleInfo.accountPeriod = $("[name='accountPeriod']").val();
+            channelSaleInfoList.push(channelSaleInfo);
+        })
+        if(channelSaleInfoList.length<2){
+            $("#channelTbodyId").show();
+            //document.getElementById("channelSaleListId").innerHTML = "<tr><td colspan=\"7\" class=\"td-manage text-c\" >暂时没有客户销售渠道信息,请添加!</td></tr>";
+        }
     }
     /*业务逻辑js控制 end*/
 </script>