ソースを参照

修改客户信息

liujiankang 7 年 前
コミット
df7ac591ce

+ 1 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/customer/DockedContactInfo.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
+ * 对接联系人信息
  * Created by Administrator on 2018/4/19.
  */
 public class DockedContactInfo implements Serializable {

+ 38 - 26
watero-rst-service/src/main/java/com/iamberry/rst/service/customer/CustomerBasicServiceImpl.java

@@ -71,97 +71,109 @@ public class CustomerBasicServiceImpl implements CustomerBasicService{
 
     private Logger logger = LoggerFactory.getLogger(CustomerBasicServiceImpl.class);
 
-    @Autowired
-    private CustomerBasicMapper customerBasicInfoSaveMapper;
-
-
     @Override
     public CustomerBasicInfo queryCustomerBasicInfoByCustomerId(int queryCustomerId) {
-        return customerBasicInfoSaveMapper.queryCustomerBasicInfoByCustomerId(queryCustomerId);
+        return customerBasicMapper.queryCustomerBasicInfoByCustomerId(queryCustomerId);
     }
 
     @Override
     public List<DockedContactInfo> queryDockedContactInfoListByCustomerId(int queryCustomerId) {
-        return customerBasicInfoSaveMapper.queryDockedContactInfoListByCustomerId(queryCustomerId);
+        return customerBasicMapper.queryDockedContactInfoListByCustomerId(queryCustomerId);
     }
 
     @Override
     public List<ChannelSaleInfo> queryChannelSaleInfoListByCustomerId(int queryCustomerId) {
-        return customerBasicInfoSaveMapper.queryChannelSaleInfoListByCustomerId(queryCustomerId);
+        return customerBasicMapper.queryChannelSaleInfoListByCustomerId(queryCustomerId);
     }
 
     @Override
     public BillingInfo queryBillingInfoByCustomerId(int queryCustomerId) {
-        return customerBasicInfoSaveMapper.queryBillingInfoByCustomerId(queryCustomerId);
+        return customerBasicMapper.queryBillingInfoByCustomerId(queryCustomerId);
     }
 
     @Override
     public TicketOpeningInfo queryTicketOpeningInfoByCustomerId(int queryCustomerId) {
-        return customerBasicInfoSaveMapper.queryTicketOpeningInfoByCustomerId(queryCustomerId);
+        return customerBasicMapper.queryTicketOpeningInfoByCustomerId(queryCustomerId);
     }
 
     @Override
     @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 {
-            customerBasicInfoSaveMapper.saveCustomerBasicInfo(customerBasicInfo);
+            customerBasicMapper.updateCustomerBasic(customerBasicInfo);
             customerId = customerBasicInfo.getCustomerId();
+
+            //删除旧联系人数据和渠道销售信息
+            customerBasicMapper.deleteContactInfo(customerId);
+            List<ChannelSaleInfo> listChannelSale = customerBasicMapper.queryChannelSaleInfoListByCustomerId(customerId);
+            if(listChannelSale.size() > 0){
+                for(ChannelSaleInfo channelSaleInfo : listChannelSale){
+                    customerBasicMapper.deleteDivisionInfo(channelSaleInfo.getChannelDivisionId());
+                }
+            }
+
             if(customerId != -1){
                 if(dockedContactInfoList != null && dockedContactInfoList.size()>1){
                     dockedContactInfoList.remove(0);
                     for (DockedContactInfo dockedContactInfo: dockedContactInfoList) {
                         dockedContactInfo.setCustomerId(customerId);
-                        customerBasicInfoSaveMapper.saveDockedContactInfo(dockedContactInfo);
+                        customerBasicMapper.saveDockedContactInfo(dockedContactInfo);
                     }
                 }
                 if(channelSaleInfoList != null && channelSaleInfoList.size()>1){
                     channelSaleInfoList.remove(0);
                     for (ChannelSaleInfo channelSaleInfo: channelSaleInfoList) {
                         channelSaleInfo.setCustomerId(customerId);
-                        customerBasicInfoSaveMapper.saveChannelDivisionInfo(channelSaleInfo);
-                        //channelSaleInfo.setChannelDivisionId(channelDivisionId);
-                        customerBasicInfoSaveMapper.saveChannelSaleInfo(channelSaleInfo);
+                        customerBasicMapper.saveChannelDivisionInfo(channelSaleInfo);
+                        customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
                     }
                 }
                 billingInfo.setCustomerId(customerId);
                 ticketOpeningInfo.setCustomerId(customerId);
-                customerBasicInfoSaveMapper.saveBillingInfo(billingInfo);
-                customerBasicInfoSaveMapper.saveTicketOpeningInfo(ticketOpeningInfo);
+                if(billingInfo.getBillingId()!=null){
+                    customerBasicMapper.updateBillingInfo(billingInfo);
+                }else{
+                    customerBasicMapper.saveBillingInfo(billingInfo);
+                }
+                if(ticketOpeningInfo.getTicketOpeningId()!=null){
+                    customerBasicMapper.updateOpeningInfo(ticketOpeningInfo);
+                }else{
+                    customerBasicMapper.saveTicketOpeningInfo(ticketOpeningInfo);
+                }
+
             }
-            logger.info("saveCustomerBasicInfo end...");
         }catch (Exception e){
-            logger.error("添加客户信息失败"+e.getMessage());
-            throw new RuntimeException("添加客户信息失败");
+            logger.error("修改客户信息失败"+e.getMessage());
+            throw new RuntimeException("修改客户信息失败");
         }
 
     }
 
     public List<Province> queryProvinceList(String provinceId){
-        return (List<Province>)customerBasicInfoSaveMapper.queryProvinceList(provinceId);
+        return (List<Province>)customerBasicMapper.queryProvinceList(provinceId);
     }
 
     public List<City> queryCityList(String provinceId){
-        return (List<City>)customerBasicInfoSaveMapper.queryCityList(provinceId);
+        return (List<City>)customerBasicMapper.queryCityList(provinceId);
     }
 
     public List<ChannelDivisionInfo> queryChannelCategoryList(String channelCategoryId){
-        return (List<ChannelDivisionInfo>)customerBasicInfoSaveMapper.queryChannelCategoryList(channelCategoryId);
+        return (List<ChannelDivisionInfo>)customerBasicMapper.queryChannelCategoryList(channelCategoryId);
     }
 
     public List<ChannelDivisionInfo> queryChannelTypeList(String channelCategoryId){
-        return (List<ChannelDivisionInfo>)customerBasicInfoSaveMapper.queryChannelTypeList(channelCategoryId);
+        return (List<ChannelDivisionInfo>)customerBasicMapper.queryChannelTypeList(channelCategoryId);
     }
 
     public List<Product> queryPromotingProductsList(String promotingProductsInfo){
-        return (List<Product>)customerBasicInfoSaveMapper.queryPromotingProductsList(promotingProductsInfo);
+        return (List<Product>)customerBasicMapper.queryPromotingProductsList(promotingProductsInfo);
     }
 
     public List<ProductColor> querySupplyPriceList(String promotingProductsId){
-        return (List<ProductColor>)customerBasicInfoSaveMapper.querySupplyPriceList(promotingProductsId);
+        return (List<ProductColor>)customerBasicMapper.querySupplyPriceList(promotingProductsId);
     }
     /*@Override
     public void saveDockedContactInfo(DockedContactInfo dockedContactInfo) {

+ 19 - 22
watero-rst-service/src/main/java/com/iamberry/rst/service/customer/mapper/CustomerBasicMapper.xml

@@ -527,34 +527,31 @@
         UPDATE tb_rst_customer_basic_info
         <set >
             <if test="customerName != null and customerName !='' " >
-                customer_name = #{customerName}
+                customer_name = #{customerName},
             </if>
             <if test="customerIndustry != null and customerIndustry !='' " >
-                customer_industry = #{customerIndustry}
+                customer_industry = #{customerIndustry},
             </if>
             <if test="customerType != null and customerType !='' " >
-                customer_type = #{customerType}
+                customer_type = #{customerType},
             </if>
             <if test="cooperativeState != null and cooperativeState !='' " >
-                cooperative_state = #{cooperativeState}
+                cooperative_state = #{cooperativeState},
             </if>
             <if test="customerProvinceCode != null and customerProvinceCode !='' " >
-                customer_province_code = #{customerProvinceCode}
+                customer_province_code = #{customerProvinceCode},
             </if>
             <if test="customerCityCode != null and customerCityCode !='' " >
-                customer_city_code = #{customerCityCode}
+                customer_city_code = #{customerCityCode},
             </if>
             <if test="customerAddress != null and customerAddress !='' " >
-                customer_address = #{customerAddress}
+                customer_address = #{customerAddress},
             </if>
             <if test="customerStatus != null and customerStatus !='' " >
-                customer_status = #{customerStatus}
+                customer_status = #{customerStatus},
             </if>
             <if test="updateDate != null and updateDate !='' " >
-                update_date = #{updateDate}
-            </if>
-            <if test="idUpdateBy != null and idUpdateBy !='' " >
-                id_update_by = #{idUpdateBy}
+                update_date = #{updateDate},
             </if>
             <if test="customerRemarks != null and customerRemarks !='' " >
                 customer_remarks = #{customerRemarks}
@@ -567,16 +564,16 @@
         UPDATE tb_rst_billing_info
         <set >
             <if test="accountOpeningBranch != null and accountOpeningBranch !='' " >
-                account_opening_branch = #{accountOpeningBranch}
+                account_opening_branch = #{accountOpeningBranch},
             </if>
             <if test="accountName != null and accountName !='' " >
-                account_name = #{accountName}
+                account_name = #{accountName},
             </if>
             <if test="accountNum != null and accountNum !='' " >
-                account_num = #{accountNum}
+                account_num = #{accountNum},
             </if>
             <if test="receivablesName != null and receivablesName !='' " >
-                receivables_name = #{receivablesName}
+                receivables_name = #{receivablesName},
             </if>
             <if test="receivablesPhone != null and receivablesPhone !='' " >
                 receivables_phone = #{receivablesPhone}
@@ -589,22 +586,22 @@
         UPDATE tb_rst_ticket_opening_info
         <set >
             <if test="ticketType != null and ticketType !='' " >
-                ticket_type = #{ticketType}
+                ticket_type = #{ticketType},
             </if>
             <if test="accountOpeningBranch != null and accountOpeningBranch !='' " >
-                account_opening_branch = #{accountOpeningBranch}
+                account_opening_branch = #{accountOpeningBranch},
             </if>
             <if test="ticketOpeningAccount != null and ticketOpeningAccount !='' " >
-                ticket_opening_account = #{ticketOpeningAccount}
+                ticket_opening_account = #{ticketOpeningAccount},
             </if>
             <if test="enterpriseName != null and enterpriseName !='' " >
-                enterprise_name = #{enterpriseName}
+                enterprise_name = #{enterpriseName},
             </if>
             <if test="taxpayerIdentificationNum != null and taxpayerIdentificationNum !='' " >
-                taxpayer_identification_num = #{taxpayerIdentificationNum}
+                taxpayer_identification_num = #{taxpayerIdentificationNum},
             </if>
             <if test="ticketOpeningPhone != null and ticketOpeningPhone !='' " >
-                ticket_opening_phone = #{ticketOpeningPhone}
+                ticket_opening_phone = #{ticketOpeningPhone},
             </if>
             <if test="enterpriseAddress != null and enterpriseAddress !='' " >
                 enterprise_address = #{enterpriseAddress}

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

@@ -230,42 +230,6 @@ public class CustomerBasicController {
         channelSaleInfo.setCustomerId(Integer.valueOf(customerId));
         //List<ChannelDivisionInfo> listChannelDivisionInfo = customerBasicService.listChannelDivisionInfo(Integer.valueOf(customerId));
         List<ChannelSaleInfo> listChannelSaleInfo = customerBasicService.listChannelSaleInfo(channelSaleInfo);
-        //渠道销售信息封装
-       /* List<ChannelDivisionInfo> listChannelDivisionInfo = new ArrayList<ChannelDivisionInfo>();
-        for (int i=0;i<listChannelSaleInfo.size();i++){
-            boolean isContinue = true;
-            if(listChannelDivisionInfo.size() > 0){
-                for(ChannelDivisionInfo channelDivisionInfo : listChannelDivisionInfo){
-                    List<ChannelSaleInfo> listChannel = channelDivisionInfo.getListChannelSaleInfo();
-                    for (ChannelSaleInfo Info : listChannel){
-                        if(Info.getChannelDivisionId().intValue() == listChannelSaleInfo.get(i).getChannelDivisionId().intValue()
-                                && Info.getChannelName().equals(listChannelSaleInfo.get(i).getChannelName())){
-                            isContinue = false;
-                        }
-                    }
-
-                }
-            }
-            if(!isContinue){
-                continue;//数据已保存不需要再循环
-            }
-            ChannelDivisionInfo channelDivisionInfo = new ChannelDivisionInfo();
-            channelDivisionInfo.setChannelCategory(listChannelSaleInfo.get(i).getChannelCategory());
-            channelDivisionInfo.setChannelType(listChannelSaleInfo.get(i).getChannelType());
-            channelDivisionInfo.setChannelName(listChannelSaleInfo.get(i).getChannelName());
-                List<ChannelSaleInfo> listChannelSale = new ArrayList<ChannelSaleInfo>();
-            for (int j=0;j<listChannelSaleInfo.size();j++){
-                if(listChannelSaleInfo.get(i).getChannelDivisionId().intValue() == listChannelSaleInfo.get(j).getChannelDivisionId().intValue()
-                  && listChannelSaleInfo.get(i).getChannelName().equals(listChannelSaleInfo.get(j).getChannelName())){
-                    listChannelSale.add(listChannelSaleInfo.get(j));
-                }
-                if(j == listChannelSaleInfo.size()-1){
-                    channelDivisionInfo.setListChannelSaleInfo(listChannelSale);
-                }
-
-            }
-            listChannelDivisionInfo.add(channelDivisionInfo);
-        }*/
         mv.addObject("customerBasicInfo",customerBasicInfo);
         mv.addObject("listDockedContactInfo",listDockedContactInfo);
         mv.addObject("billingInfo",billingInfo);
@@ -342,8 +306,8 @@ public class CustomerBasicController {
      *
      * @return
      */
-    @RequiresPermissions("customerBasic:save:customerInfo")
-    @RequestMapping(value = "/update_customer_info")
+    @RequiresPermissions("customerBasic:update:customerInfo")
+    @RequestMapping(value = "/_update_customer_info")
     public ModelAndView updateCustomerInfo(HttpServletRequest request) throws Exception{
         ModelAndView mv = new ModelAndView("customerInfoAdmin/update_customer_info");
         String customerId = request.getParameter("customerId");
@@ -383,6 +347,57 @@ public class CustomerBasicController {
     }
 
     /**
+     * 修改客户信息
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @ResponseBody
+    @RequiresPermissions("customerBasic:update:customerBasic")
+    @RequestMapping("/update_customer_info")
+    public ResponseJson updateCustomerBasicInfo(HttpServletRequest request,String customerInfoJson,String dockedContactInfoListJson,
+                                              String channelSaleInfoListJson,String billingInfoJson,String ticketOpeningInfoJson) throws Exception {
+        Integer adminId = AdminUtils.getLoginAdminId();
+        JSONArray jsonArray;
+        List<DockedContactInfo> dockedContactInfoList;
+        List<ChannelSaleInfo> channelSaleInfoList;
+        jsonArray = JSONArray.fromObject(dockedContactInfoListJson);
+        dockedContactInfoList = (List) JSONArray.toCollection(jsonArray, DockedContactInfo.class);
+
+        jsonArray = JSONArray.fromObject(channelSaleInfoListJson);
+        channelSaleInfoList = (List) JSONArray.toCollection(jsonArray, ChannelSaleInfo.class);
+        JSONObject customerJsonObject =  JSONObject.fromObject(customerInfoJson);
+        CustomerBasicInfo customerBasicInfo = (CustomerBasicInfo) customerJsonObject.toBean(customerJsonObject,CustomerBasicInfo.class);
+        customerBasicInfo.setIdCreateBy(adminId);
+
+        JSONObject billingInfoJsonObject =  JSONObject.fromObject(billingInfoJson);
+        BillingInfo billingInfo = (BillingInfo) billingInfoJsonObject.toBean(billingInfoJsonObject,BillingInfo.class);
+
+        JSONObject ticketOpeningInfoJsonObject =  JSONObject.fromObject(ticketOpeningInfoJson);
+        TicketOpeningInfo ticketOpeningInfo = (TicketOpeningInfo) ticketOpeningInfoJsonObject.toBean(ticketOpeningInfoJsonObject,TicketOpeningInfo.class);
+        ResponseJson rjx = this.isValiData(customerBasicInfo);
+        Boolean isSaveSuccess = false;//是否保存成功标识
+        if(rjx.getResultCode() == 500){
+            return rjx;
+        }
+        logger.info("-----------------修改客户信息开始----------------------");
+            try {
+                customerBasicService.saveCustomerBasicInfo(customerBasicInfo,dockedContactInfoList,channelSaleInfoList,billingInfo,ticketOpeningInfo);
+                isSaveSuccess = true;
+            } catch (RuntimeException e) {
+            isSaveSuccess = false;
+            return new ResponseJson(500, e.getMessage(), 500);
+        }
+        logger.info("-----------------修改客户信息结束----------------------");
+        if (!isSaveSuccess) {
+            return new ResponseJson(500, "修改客户信息失败!", 500);
+        }else{
+            return new ResponseJson(200, "修改客户信息成功!", 200);
+        }
+    }
+
+
+    /**
      * 查询所有省份
      *
      * @return

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

@@ -62,6 +62,8 @@
     <#--<form action="${path}/admin/customerBasic/save_customer_info" method="post" class="form form-horizontal" id="form-customerInfoAdmin-add"  onkeydown="if(event.keyCode==13)return false;">-->
         <input type="hidden" id="saveCustomerInfo" name="saveCustomerInfo" value="">
         <input type="hidden" id="customerId" name="customerId" value="${customerBasicInfo.customerId!''}">
+        <input type="hidden" id="billingId" name="billingId" value="<#if billingInfo??>${billingInfo.billingId!''}</#if>">
+        <input type="hidden" id="ticketOpeningId" name="ticketOpeningId" value="<#if billingInfo??>${ticketOpeningInfo.ticketOpeningId!''}</#if>">
         <#--客户基本信息 start-->
         <div class="row cl">
             <label class="form-label col-2">
@@ -429,7 +431,7 @@
         <div  class="class="row cl"">
             <!-- Unnamed ()  style="visibility: visible;"-->
             <div id="u30" class="my-btn-search" style="cursor:pointer; float: center;height: 35px;margin-right: 30px;margin-bottom: 10px;">
-                <p><span onclick="addCustomerBasicInfo()">添加客户信息</span></p>
+                <p><span onclick="updateCustomerBasicInfo()">确认修改</span></p>
             </div>
         </div>
         <input type="hidden" id="provinceCode" value="${customerBasicInfo.customerProvinceCode!''}">
@@ -728,11 +730,12 @@
         }
         return false;
     }
-    /*添加客户信息*/
-    function addCustomerBasicInfo() {
+    /*修改客户信息*/
+    function updateCustomerBasicInfo() {
         var customerBasicInfoSaveForm = {};
         //客户基本信息
         var customerBasicInfo = {};
+        customerBasicInfo.customerId = $("[name='customerId']").val();
         customerBasicInfo.customerType = $("[name='customerType']").val();
         customerBasicInfo.cooperativeState = $("[name='cooperativeState']").val();
         customerBasicInfo.customerName = $("[name='customerName']").val();
@@ -769,6 +772,7 @@
         //alert("channelSaleInfoList:"+channelSaleInfoList.length);
         //付款/退款信息
         var billingInfo = {};
+        billingInfo.billingId = $("[name='billingId']").val();
         billingInfo.accountOpeningBranch = $("[name='accountOpeningBranch']").val();
         billingInfo.accountName = $("[name='accountName']").val();
         billingInfo.accountNum = $("[name='accountNum']").val();
@@ -776,6 +780,7 @@
         billingInfo.receivablesPhone = $("[name='receivablesPhone']").val();
         //开票信息
         var ticketOpeningInfo = {};
+        ticketOpeningInfo.ticketOpeningId = $("[name='ticketOpeningId']").val();
         ticketOpeningInfo.ticketType = $("[name='ticketType']").val();
         ticketOpeningInfo.accountOpeningBranch = $("[name='accountOpeningBranch']").val();
         ticketOpeningInfo.ticketOpeningAccount = $("[name='ticketOpeningAccount']").val();
@@ -784,7 +789,6 @@
         ticketOpeningInfo.ticketOpeningPhone = $("[name='ticketOpeningPhone']").val();
         ticketOpeningInfo.enterpriseAddress = $("[name='enterpriseAddress']").val();
         //发送保存请求
-        alert("request ...Start...");
         customerBasicInfoSaveForm.customerBasicInfo = customerBasicInfo;
         customerBasicInfoSaveForm.dockedContactInfoList = dockedContactInfoList;
         customerBasicInfoSaveForm.channelSaleInfoList = channelSaleInfoList;
@@ -809,7 +813,7 @@
                 billingInfoJson : billingInfoJson,
                 ticketOpeningInfoJson:ticketOpeningInfoJson
             },
-            url: "${path}/admin/customerBasic/save_customer_info",
+            url: "${path}/admin/customerBasic/update_customer_info",
             async: true,
             success: function(data){
                 if (data.returnCode == 200) {