Bläddra i källkod

添加客户基本信息

dujinyan 7 år sedan
förälder
incheckning
08277bcabd

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

@@ -11,6 +11,7 @@ import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.faces.customer.CustomerBasicService;
 import com.iamberry.rst.service.customer.mapper.CustomerBasicMapper;
 import com.iamberry.rst.util.PageUtil;
+import com.iamberry.wechat.tools.payUtil.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -102,7 +103,7 @@ public class CustomerBasicServiceImpl implements CustomerBasicService{
                                       BillingInfo billingInfo, TicketOpeningInfo ticketOpeningInfo) throws Exception{
         logger.info("saveCustomerBasicInfo start...");
         int customerId = -1;
-        int channelDivisionId = -1;
+        String channelDivisionId = "";
         try {
             customerBasicMapper.saveCustomerBasicInfo(customerBasicInfo);
             customerId = customerBasicInfo.getCustomerId();
@@ -118,9 +119,20 @@ public class CustomerBasicServiceImpl implements CustomerBasicService{
                     channelSaleInfoList.remove(0);
                     for (ChannelSaleInfo channelSaleInfo: channelSaleInfoList) {
                         channelSaleInfo.setCustomerId(customerId);
-                        customerBasicMapper.saveChannelDivisionInfo(channelSaleInfo);
-                        //channelSaleInfo.setChannelDivisionId(channelDivisionId);
-                        customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                        String channelName = channelSaleInfo.getChannelName();
+                        channelDivisionId = customerBasicMapper.queryIsExsitChannelNameChannelName(channelSaleInfo);
+                        if(StringUtil.isNotEmpty(channelDivisionId)){
+                            if(Integer.valueOf(channelDivisionId)>0){
+                                channelSaleInfo.setChannelDivisionId(Integer.valueOf(channelDivisionId));
+                                customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                            }else{
+                                customerBasicMapper.saveChannelDivisionInfo(channelSaleInfo);
+                                customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                            }
+                        }else{
+                            customerBasicMapper.saveChannelDivisionInfo(channelSaleInfo);
+                            customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                        }
                     }
                 }
                 billingInfo.setCustomerId(customerId);
@@ -141,7 +153,7 @@ public class CustomerBasicServiceImpl implements CustomerBasicService{
     public void updateCustomerBasicInfo(CustomerBasicInfo customerBasicInfo,List<DockedContactInfo> dockedContactInfoList, List<ChannelSaleInfo> channelSaleInfoList,
                                       BillingInfo billingInfo, TicketOpeningInfo ticketOpeningInfo) throws Exception{
         int customerId = -1;
-        Integer channelDivisionId = -1;
+        String channelDivisionId = "";
         try {
             customerBasicMapper.updateCustomerBasic(customerBasicInfo);
             customerId = customerBasicInfo.getCustomerId();
@@ -168,10 +180,15 @@ public class CustomerBasicServiceImpl implements CustomerBasicService{
                     channelSaleInfoList.remove(0);
                     for (ChannelSaleInfo channelSaleInfo: channelSaleInfoList) {
                         channelSaleInfo.setCustomerId(customerId);
-                        channelDivisionId = customerBasicMapper.queryIsExsitChannelNameChannelName(channelSaleInfo.getChannelName());
-                        if(channelDivisionId > 0){
-                            channelSaleInfo.setChannelDivisionId(channelDivisionId);
-                            customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                        channelDivisionId = customerBasicMapper.queryIsExsitChannelNameChannelName(channelSaleInfo);
+                        if(StringUtil.isNotEmpty(channelDivisionId)){
+                            if(Integer.valueOf(channelDivisionId)>0){
+                                channelSaleInfo.setChannelDivisionId(Integer.valueOf(channelDivisionId));
+                                customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                            }else{
+                                customerBasicMapper.saveChannelDivisionInfo(channelSaleInfo);
+                                customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);
+                            }
                         }else{
                             customerBasicMapper.saveChannelDivisionInfo(channelSaleInfo);
                             customerBasicMapper.saveChannelSaleInfo(channelSaleInfo);

+ 2 - 2
watero-rst-service/src/main/java/com/iamberry/rst/service/customer/mapper/CustomerBasicMapper.java

@@ -195,8 +195,8 @@ public interface CustomerBasicMapper {
 
     /**
      * 判断是否存在渠道名称
-     * @param channelName
+     * @param channelSaleInfo
      * @return
      */
-    int queryIsExsitChannelNameChannelName(String channelName);
+    String queryIsExsitChannelNameChannelName(ChannelSaleInfo channelSaleInfo);
 }

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

@@ -414,13 +414,17 @@
     </select>
     <!-- 根据客户id查询客户销售渠道备案信息 -->
     <!--查询渠道名称是否存在-->
-    <select id="queryIsExsitChannelNameChannelName" parameterType="String" resultType="Integer">
+    <select id="queryIsExsitChannelNameChannelName" parameterType="ChannelSaleInfo" resultType="java.lang.String">
         SELECT
         IFNULL(max(t.channel_division_id),0)
         FROM
         tb_rst_channel_division_info t
         WHERE
-        t.channel_name = #{name}
+        t.channel_name = #{channelName}
+        AND
+        t.channel_category = #{channelCategory}
+        AND
+        t.channel_type = #{channelType}
     </select>
     <select id="queryChannelSaleInfoListByCustomerId" parameterType="Integer" resultMap="channelSaleInfoResult">
         SELECT
@@ -501,7 +505,7 @@
         WHEN t.channel_category = 1 THEN '电商'
         WHEN t.channel_category = 2 THEN '特殊渠道'
         WHEN t.channel_category = 3 THEN '线下'
-        ELSE '海外'
+        WHEN t.channel_category = 4 THEN '海外'
         END AS 'channel_categoryId'
         FROM
         tb_rst_channel_division_info t