Browse Source

客户标签绑定

zangguocen 3 years ago
parent
commit
3e81e2be21

+ 9 - 4
yijia-label/src/main/java/com/yijia/label/controller/CustomerLabelController.java

@@ -1,5 +1,6 @@
 package com.yijia.label.controller;
 
+import java.util.Date;
 import java.util.List;
 
 import com.yijia.common.core.domain.model.LoginUser;
@@ -28,7 +29,7 @@ import com.yijia.common.core.page.TableDataInfo;
 
 /**
  * 用户标签Controller
- * 
+ *
  * @author yijia
  * @date 2021-06-15
  */
@@ -79,14 +80,16 @@ public class CustomerLabelController extends BaseController
     @GetMapping(value = "/selectCustomerLabelInfo")
     public AjaxResult selectCustomerLabelInfo(CustomerLabel customerLabel)
     {
+        System.out.println("==================="+new Date());
         LoginUser currentUser = SecurityUtils.getLoginUser();
         customerLabel.setStationId(currentUser.getUser().getDeptId());
         customerLabel.setDelFlag("0");
         ResponeCustomerLabel responeCustomerLabel =new ResponeCustomerLabel();
         List<CustomerLabel> notlist = customerLabelService.selectNotCustomerLabelInfo(customerLabel);
-        List<String> list = customerLabelService.selectPhoneList(customerLabel);
+        List<CustomerLabel> list = customerLabelService.selectPhoneList(customerLabel);
         responeCustomerLabel.setNotCustomerLabelList(notlist);
-        responeCustomerLabel.setPhoneList(list);
+       // responeCustomerLabel.setPhoneList(list);
+        System.out.println("=================================="+new Date());
         return AjaxResult.success(responeCustomerLabel);
     }
 
@@ -98,6 +101,7 @@ public class CustomerLabelController extends BaseController
     @GetMapping(value = "/selectNotCustomerLabelInfo")
     public TableDataInfo selectNotCustomerLabelInfo(CustomerLabel customerLabel)
     {
+        startPage();
         LoginUser currentUser = SecurityUtils.getLoginUser();
         customerLabel.setStationId(currentUser.getUser().getDeptId());
         customerLabel.setDelFlag("0");
@@ -113,10 +117,11 @@ public class CustomerLabelController extends BaseController
     @GetMapping(value = "/selectPhoneList")
     public TableDataInfo selectPhoneList(CustomerLabel customerLabel)
     {
+        startPage();
         LoginUser currentUser = SecurityUtils.getLoginUser();
         customerLabel.setDelFlag("0");
         customerLabel.setStationId(currentUser.getUser().getDeptId());
-        List<String> list = customerLabelService.selectPhoneList(customerLabel);
+        List<CustomerLabel> list = customerLabelService.selectPhoneList(customerLabel);
         return getDataTable(list);
     }
 

+ 15 - 8
yijia-label/src/main/java/com/yijia/label/mapper/CustomerLabelMapper.java

@@ -5,15 +5,15 @@ import com.yijia.label.domain.CustomerLabel;
 
 /**
  * 用户标签Mapper接口
- * 
+ *
  * @author yijia
  * @date 2021-06-15
  */
-public interface CustomerLabelMapper 
+public interface CustomerLabelMapper
 {
     /**
      * 查询用户标签
-     * 
+     *
      * @param id 用户标签ID
      * @return 用户标签
      */
@@ -21,7 +21,7 @@ public interface CustomerLabelMapper
 
     /**
      * 查询用户标签列表
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 用户标签集合
      */
@@ -29,7 +29,7 @@ public interface CustomerLabelMapper
 
     /**
      * 新增用户标签
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface CustomerLabelMapper
 
     /**
      * 修改用户标签
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface CustomerLabelMapper
 
     /**
      * 删除用户标签
-     * 
+     *
      * @param id 用户标签ID
      * @return 结果
      */
@@ -53,7 +53,7 @@ public interface CustomerLabelMapper
 
     /**
      * 批量删除用户标签
-     * 
+     *
      * @param ids 需要删除的数据ID
      * @return 结果
      */
@@ -67,4 +67,11 @@ public interface CustomerLabelMapper
      * @return
      */
     public CustomerLabel selectCustomerLabelInfo(CustomerLabel labelInfo);
+
+    /**
+     * 查询标签用户
+     * @param
+     * @return
+     */
+    public  List<CustomerLabel> selectPhonelist(CustomerLabel customerLabel);
 }

+ 9 - 9
yijia-label/src/main/java/com/yijia/label/service/ICustomerLabelService.java

@@ -5,15 +5,15 @@ import com.yijia.label.domain.CustomerLabel;
 
 /**
  * 用户标签Service接口
- * 
+ *
  * @author yijia
  * @date 2021-06-15
  */
-public interface ICustomerLabelService 
+public interface ICustomerLabelService
 {
     /**
      * 查询用户标签
-     * 
+     *
      * @param id 用户标签ID
      * @return 用户标签
      */
@@ -21,7 +21,7 @@ public interface ICustomerLabelService
 
     /**
      * 查询用户标签列表
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 用户标签集合
      */
@@ -29,7 +29,7 @@ public interface ICustomerLabelService
 
     /**
      * 新增用户标签
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface ICustomerLabelService
 
     /**
      * 修改用户标签
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface ICustomerLabelService
 
     /**
      * 批量删除用户标签
-     * 
+     *
      * @param ids 需要删除的用户标签ID
      * @return 结果
      */
@@ -53,7 +53,7 @@ public interface ICustomerLabelService
 
     /**
      * 删除用户标签信息
-     * 
+     *
      * @param id 用户标签ID
      * @return 结果
      */
@@ -77,5 +77,5 @@ public interface ICustomerLabelService
      * @param customerLabel
      * @return
      */
-    public List<String> selectPhoneList(CustomerLabel customerLabel);
+    public List<CustomerLabel> selectPhoneList(CustomerLabel customerLabel);
 }

+ 11 - 17
yijia-label/src/main/java/com/yijia/label/service/impl/CustomerLabelServiceImpl.java

@@ -11,19 +11,19 @@ import com.yijia.label.service.ICustomerLabelService;
 
 /**
  * 用户标签Service业务层处理
- * 
+ *
  * @author yijia
  * @date 2021-06-15
  */
 @Service
-public class CustomerLabelServiceImpl implements ICustomerLabelService 
+public class CustomerLabelServiceImpl implements ICustomerLabelService
 {
     @Autowired
     private CustomerLabelMapper customerLabelMapper;
 
     /**
      * 查询用户标签
-     * 
+     *
      * @param id 用户标签ID
      * @return 用户标签
      */
@@ -35,7 +35,7 @@ public class CustomerLabelServiceImpl implements ICustomerLabelService
 
     /**
      * 查询用户标签列表
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 用户标签
      */
@@ -47,7 +47,7 @@ public class CustomerLabelServiceImpl implements ICustomerLabelService
 
     /**
      * 新增用户标签
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 结果
      */
@@ -60,7 +60,7 @@ public class CustomerLabelServiceImpl implements ICustomerLabelService
 
     /**
      * 修改用户标签
-     * 
+     *
      * @param customerLabel 用户标签
      * @return 结果
      */
@@ -73,7 +73,7 @@ public class CustomerLabelServiceImpl implements ICustomerLabelService
 
     /**
      * 批量删除用户标签
-     * 
+     *
      * @param ids 需要删除的用户标签ID
      * @return 结果
      */
@@ -85,7 +85,7 @@ public class CustomerLabelServiceImpl implements ICustomerLabelService
 
     /**
      * 删除用户标签信息
-     * 
+     *
      * @param id 用户标签ID
      * @return 结果
      */
@@ -129,14 +129,8 @@ public class CustomerLabelServiceImpl implements ICustomerLabelService
      * @return
      */
     @Override
-    public List<String> selectPhoneList(CustomerLabel customerLabel) {
-        List<CustomerLabel> list= customerLabelMapper.selectCustomerLabelList(customerLabel);
-        List<String> stringList =new ArrayList<>();
-        if(list!=null && list.size()>0){
-            for(CustomerLabel label:list){
-                stringList.add(label.getPhone());
-            }
-        }
-        return stringList;
+    public List<CustomerLabel> selectPhoneList(CustomerLabel customerLabel) {
+        List<CustomerLabel> list= customerLabelMapper.selectPhonelist(customerLabel);
+        return list;
     }
 }

+ 29 - 11
yijia-label/src/main/resources/mapper/label/CustomerLabelMapper.xml

@@ -29,22 +29,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="delFlag != null "> and del_flag = #{delFlag}</if>
         </where>
     </select>
-
     <select id="selectNotCustomerLabelInfo" parameterType="CustomerLabel" resultMap="CustomerLabelResult">
-        SELECT DISTINCT(phone_number) as phone,customer_name
-        from customer_manage m
-        join app_user_info a on a.mobile_phone =m.phone_number
+        SELECT	* FROM(
+        SELECT DISTINCT ( m.phone_number ) AS phone,customer_name,pay_date
+        FROM customer_manage m
+        LEFT JOIN app_user_info a ON m.mina_user_id = a.user_id
+        LEFT JOIN ( SELECT max( pay_date ) AS pay_date, po.consumer_id FROM pay_order po
+        <where>
+            <if test="stationId != null "> and po.station_id = #{stationId}</if>
+        </where>
+          GROUP BY consumer_id ) c ON c.consumer_id = a.user_id
         <where>
             <if test="stationId != null "> and m.station_id = #{stationId}</if>
             <if test="phone != null  and phone != ''"> and m.phone_number like concat('%', #{phone}, '%')</if>
+            <if test="customerName != null  and customerName != ''"> and m.customer_name like concat('%', #{customerName}, '%')</if>
         </where>
-        and phone_number  not in
-        ( select phone from customer_label b
+        AND m.phone_number NOT IN ( SELECT phone FROM customer_label b
         <where>
             <if test="stationId != null "> and b.station_id = #{stationId}</if>
-            <if test="labelId != null "> and label_id != #{labelId}</if>
             <if test="delFlag != null "> and del_flag = #{delFlag}</if>
-        </where>  )
+            <if test="phone != null  and phone != ''"> and b.phone like concat('%', #{phone}, '%')</if>
+        </where>
+         )) po
+        ORDER BY  po.pay_date DESC
+    </select>
+    <select id="selectPhonelist" parameterType="CustomerLabel" resultMap="CustomerLabelResult">
+        SELECT DISTINCT phone,label_id,c.station_id,m.customer_name from  customer_label	c
+        left join  customer_manage m on c.phone = m.phone_number and c.station_id = m.station_id
+        <where>
+            <if test="stationId != null "> and c.station_id = #{stationId}</if>
+            <if test="labelId != null "> and label_id = #{labelId}</if>
+            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
+            <if test="phone != null  and phone != ''"> and c.phone like concat('%', #{phone}, '%')</if>
+            <if test="customerName != null  and customerName != ''"> and m.customer_name like concat('%', #{customerName}, '%')</if>
+        </where>
     </select>
     <select id="selectCustomerLabelById" parameterType="Integer" resultMap="CustomerLabelResult">
         <include refid="selectCustomerLabelVo"/>
@@ -106,10 +124,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteCustomerLabelByIds" parameterType="String">
-        delete from customer_label where id in 
+        delete from customer_label where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-    
-</mapper>
+
+</mapper>