傅行帆 3 years ago
parent
commit
efa59fb3b9

+ 9
- 3
src/main/java/com/yunzhi/marketing/controller/TaRecommendCustomerController.java View File

@@ -33,8 +33,10 @@ import io.swagger.annotations.ApiImplicitParam;
33 33
 import io.swagger.annotations.ApiImplicitParams;
34 34
 import io.swagger.annotations.ApiOperation;
35 35
 import org.apache.commons.collections.CollectionUtils;
36
+import org.apache.ibatis.annotations.Param;
36 37
 import org.springframework.beans.factory.annotation.Autowired;
37 38
 import org.springframework.context.ApplicationContext;
39
+import org.springframework.format.annotation.DateTimeFormat;
38 40
 import org.springframework.web.bind.annotation.*;
39 41
 
40 42
 import javax.annotation.Resource;
@@ -576,7 +578,7 @@ public class TaRecommendCustomerController extends BaseController {
576 578
     public ResponseBean getCustomersIRecommended(@RequestParam int pageNumber, @RequestParam int pageSize, @PathVariable String customerId, HttpServletRequest request) {
577 579
         Integer orgId = getOrgId(request);
578 580
         try {
579
-            return ResponseBean.success(taRecommendCustomerService.getCustomersIRecommended(pageNumber, pageSize, customerId, orgId, getTaPersonBuildingListByUserId(request)));
581
+            return ResponseBean.success(taRecommendCustomerService.getCustomersIRecommended(pageNumber, pageSize, customerId, orgId, getTaPersonBuildingListByUserId(request),null,null,null));
580 582
         } catch (Exception e) {
581 583
             e.printStackTrace();
582 584
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
@@ -584,12 +586,16 @@ public class TaRecommendCustomerController extends BaseController {
584 586
     }
585 587
 
586 588
     @GetMapping("/wx/customer/recommend/mine")
587
-    public ResponseBean getWxCustomersIRecommended(@RequestParam int pageNumber, @RequestParam int pageSize, HttpServletRequest request) {
589
+    public ResponseBean getWxCustomersIRecommended(@RequestParam int pageNumber, @RequestParam int pageSize,
590
+                                                   @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate,
591
+                                                   @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime endDate,
592
+                                                   @RequestParam(value = "status", required = false) Integer status,
593
+                                                   HttpServletRequest request) {
588 594
         Integer orgId = getOrgId(request);
589 595
         String personId = getPersonId(request);
590 596
         TaPerson person = taPersonService.getById(personId);
591 597
         try {
592
-            return ResponseBean.success(taRecommendCustomerService.getCustomersIRecommended(pageNumber, pageSize, person.getPersonId(), orgId, null));
598
+            return ResponseBean.success(taRecommendCustomerService.getCustomersIRecommended(pageNumber, pageSize, person.getPersonId(), orgId, null,startDate,endDate,status));
593 599
         } catch (Exception e) {
594 600
             e.printStackTrace();
595 601
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);

+ 1
- 1
src/main/java/com/yunzhi/marketing/mapper/TaRecommendCustomerMapper.java View File

@@ -251,7 +251,7 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
251 251
 
252 252
     List<PersonIntention> getCustomerIntentions(@Param("personId") String personId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
253 253
 
254
-    IPage<TaRecommendCustomerPO> getCustomersIRecommended(IPage<TaRecommendCustomerPO> page, @Param("customerId") String customerId, @Param("status") Integer status, @Param("orgId") Integer orgId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
254
+    IPage<TaRecommendCustomerPO> getCustomersIRecommended(IPage<TaRecommendCustomerPO> page, @Param("customerId") String customerId, @Param("status") Integer status, @Param("orgId") Integer orgId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList,@Param("startDate") LocalDateTime startDate,@Param("endDate") LocalDateTime endDate);
255 255
 
256 256
     /**
257 257
      * @param page

+ 11
- 0
src/main/java/com/yunzhi/marketing/po/TaRecommendCustomerPO.java View File

@@ -2,6 +2,8 @@ package com.yunzhi.marketing.po;
2 2
 
3 3
 import lombok.Data;
4 4
 
5
+import java.time.LocalDateTime;
6
+
5 7
 @Data
6 8
 public class TaRecommendCustomerPO {
7 9
 
@@ -16,4 +18,13 @@ public class TaRecommendCustomerPO {
16 18
     private String sex;
17 19
 
18 20
     private String type;
21
+
22
+    private String buildingId;
23
+
24
+    private LocalDateTime createDate;
25
+
26
+    /**
27
+     * 过了保护期的时间
28
+     */
29
+    private LocalDateTime expirationDate;
19 30
 }

+ 2
- 1
src/main/java/com/yunzhi/marketing/service/ITaRecommendCustomerService.java View File

@@ -12,6 +12,7 @@ import com.yunzhi.marketing.excel.ReporRecommendCustomer;
12 12
 import com.yunzhi.marketing.entity.*;
13 13
 import com.yunzhi.marketing.po.TaRecommendCustomerPO;
14 14
 
15
+import java.time.LocalDateTime;
15 16
 import java.util.List;
16 17
 
17 18
 /**
@@ -54,7 +55,7 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
54 55
 
55 56
     TaRecommendCustomer getCustomerById(String customerId);
56 57
 
57
-    IPage<TaRecommendCustomerPO> getCustomersIRecommended(int pageNumber, int pageSize, String customerId, Integer orgId, List<TaPersonBuilding> taPersonBuildingList);
58
+    IPage<TaRecommendCustomerPO> getCustomersIRecommended(int pageNumber, int pageSize, String customerId, Integer orgId, List<TaPersonBuilding> taPersonBuildingList, LocalDateTime startDate,LocalDateTime endDate,Integer status);
58 59
 
59 60
     TaRecommendCustomer newByPerson(TaPerson person);
60 61
 

+ 15
- 6
src/main/java/com/yunzhi/marketing/service/impl/TaRecommendCustomerServiceImpl.java View File

@@ -1327,17 +1327,26 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
1327 1327
     }
1328 1328
 
1329 1329
     @Override
1330
-    public IPage<TaRecommendCustomerPO> getCustomersIRecommended(int pageNumber, int pageSize, String customerId, Integer orgId, List<TaPersonBuilding> taPersonBuildingList) {
1330
+    public IPage<TaRecommendCustomerPO> getCustomersIRecommended(int pageNumber, int pageSize, String customerId, Integer orgId, List<TaPersonBuilding> taPersonBuildingList, LocalDateTime startDate,LocalDateTime endDate,Integer status) {
1331 1331
 
1332 1332
 //        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
1333 1333
         // todo
1334 1334
         // 此处可能不是 person_id 而是 recommend_person
1335 1335
         IPage<TaRecommendCustomerPO> page = new Page<>(pageNumber, pageSize);
1336
-//        queryWrapper.eq("recommend_person",customerId);
1337
-////        queryWrapper.eq("building_id",building);
1338
-//        queryWrapper.eq("status", CommConstant.VERIFY_AGREE);
1339
-//        queryWrapper.eq("org_id", orgId);
1340
-        return taRecommendCustomerMapper.getCustomersIRecommended(page, customerId, CommConstant.STATUS_NORMAL, orgId, taPersonBuildingList);
1336
+        IPage<TaRecommendCustomerPO> customersIRecommended = taRecommendCustomerMapper.getCustomersIRecommended(page, customerId, status, orgId, taPersonBuildingList, startDate, endDate);
1337
+        List<TaRecommendCustomerPO> records = customersIRecommended.getRecords();
1338
+        records.forEach(e -> {
1339
+            LambdaQueryWrapper<BuildingChannel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
1340
+            lambdaQueryWrapper.eq(BuildingChannel::getBuildingId,e.getBuildingId());
1341
+            BuildingChannel buildingChannel = buildingChannelMapper.selectOne(lambdaQueryWrapper);
1342
+
1343
+            if (null != buildingChannel) {
1344
+                Integer expirationDay = buildingChannel.getExpirationDate();
1345
+                LocalDateTime expirationDate = e.getCreateDate().plusDays(expirationDay);
1346
+                e.setExpirationDate(expirationDate);
1347
+            }
1348
+        });
1349
+        return customersIRecommended;
1341 1350
     }
1342 1351
 
1343 1352
     @Override

+ 5
- 0
src/main/java/com/yunzhi/marketing/xlk/mapper/ChannelCustomerMapper.java View File

@@ -2,10 +2,14 @@ package com.yunzhi.marketing.xlk.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.yunzhi.marketing.dto.StatisticsDTO;
6
+import com.yunzhi.marketing.po.CustomerRankListVO;
5 7
 import com.yunzhi.marketing.xlk.entity.ChannelCustomer;
6 8
 import org.apache.ibatis.annotations.Mapper;
7 9
 import org.apache.ibatis.annotations.Param;
8 10
 
11
+import java.util.List;
12
+
9 13
 /**
10 14
  * <p>
11 15
  * 渠道报备客户表  Mapper 接口
@@ -26,4 +30,5 @@ public interface ChannelCustomerMapper extends BaseMapper<ChannelCustomer> {
26 30
                                           @Param("recommendPhone") String recommendPhone,
27 31
                                           @Param("status") String status,@Param("type") String type);
28 32
 
33
+    List<CustomerRankListVO> getRanklist(@Param("params") StatisticsDTO statisticsDTo);
29 34
 }

+ 20
- 3
src/main/resources/mapper/TaRecommendCustomerMapper.xml View File

@@ -870,13 +870,20 @@ FROM
870 870
         a.sex,
871 871
         "customer" AS type,
872 872
         a.building_id AS buildingId,
873
+        a.create_date,
874
+        a.building_id,
873 875
         a.realty_consultant AS consultant,
874 876
         a.STATUS AS customerStatus,
875 877
         NULL AS channelStatus,
876 878
         b.avatarurl
877 879
         from ta_recommend_customer a left join ta_person b on a.person_id = b.person_id
878 880
         where a.recommend_person = #{customerId}
879
-        and a.status &gt;= #{status}
881
+        <if test="status != null and status !=''">
882
+            and a.status = #{status}
883
+        </if>
884
+        <if test="startDate != null or endDate != null">
885
+            AND a.create_date BETWEEN #{startDate} and #{endDate}
886
+        </if>
880 887
         and a.org_id = #{orgId}
881 888
         <if test="personBuildingList != null and personBuildingList.size > 0">
882 889
             AND a.building_id in
@@ -884,6 +891,7 @@ FROM
884 891
                 #{personBuilding.buildingId}
885 892
             </foreach>
886 893
         </if>
894
+        ORDER BY create_date
887 895
         union all
888 896
         SELECT
889 897
         a.channel_customer_id AS id,
@@ -891,17 +899,25 @@ FROM
891 899
         a.phone,
892 900
         a.picture,
893 901
         a.sex,
902
+        a.building_id,
894 903
         "report" AS type,
895 904
         NULL AS buildingId,
905
+        a.create_date,
896 906
         NULL AS consultant,
897
-        NULL AS customerStatus,
907
+        "1" AS customerStatus,
898 908
         a.STATUS AS channelStatus,
899 909
         b.avatarurl
900 910
         FROM
901 911
         xlk_channel_customer a
902 912
         LEFT JOIN ta_person b ON a.person_id = b.person_id
903 913
         where a.recommend_person = #{customerId}
904
-        and a.status = #{status}
914
+        and a.status = 1
915
+        <if test="status != null and status !=''">
916
+            and a.status = #{status}
917
+        </if>
918
+        <if test="startDate != null or endDate != null">
919
+            AND a.create_date BETWEEN #{startDate} and #{endDate}
920
+        </if>
905 921
         and a.org_id = #{orgId}
906 922
         <if test="personBuildingList != null and personBuildingList.size > 0">
907 923
             AND a.building_id in
@@ -909,6 +925,7 @@ FROM
909 925
                 #{personBuilding.buildingId}
910 926
             </foreach>
911 927
         </if>
928
+        ORDER BY create_date
912 929
     </select>
913 930
 
914 931
     <select id="getCustomerListOfConsultant" resultType="com.yunzhi.marketing.entity.TaRecommendCustomer">

+ 20
- 0
src/main/resources/mapper/xlk/ChannelCustomerMapper.xml View File

@@ -44,4 +44,24 @@
44 44
             ORDER BY
45 45
                 t.create_date DESC
46 46
     </select>
47
+    <select id="getRanklist" resultType="com.yunzhi.marketing.po.CustomerRankListVO">
48
+        SELECT
49
+            COUNT(1) as number,
50
+            t.recommend_person,
51
+            p.`name`
52
+        FROM
53
+            xlk_channel_customer t
54
+        LEFT JOIN ta_person p on t.recommend_person = p.person_id
55
+        WHERE t.channel_id  = #{params.channelId}
56
+        and `status` = 2
57
+        <if test="params.startDate != null or params.endDate != null">
58
+            AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
59
+        </if>
60
+        <if test="params.startDate == null or params.endDate == null">
61
+            AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
62
+        </if>
63
+        GROUP BY t.recommend_person
64
+        ORDER BY number desc
65
+        LIMIT 3
66
+    </select>
47 67
 </mapper>