Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

魏熙美 5 lat temu
rodzic
commit
f7564a4a4d

+ 50
- 0
src/main/java/com/huiju/estateagents/controller/TaRecommendCustomerController.java Wyświetl plik

@@ -132,6 +132,56 @@ public class TaRecommendCustomerController extends BaseController {
132 132
             return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
133 133
         }
134 134
     }
135
+    @GetMapping("/admin/customer/recommend/recommender")
136
+    public ResponseBean getRecCustomerList (@RequestParam(value ="name",required = false) String name,
137
+                                         @RequestParam(value ="tel",required = false) String tel,
138
+                                         @RequestParam(value ="buildingId",required = false) String buildingId,
139
+                                         @RequestParam(value ="recommendName",required = false) String recommendName,
140
+                                         @RequestParam(value ="recommendTel",required = false) String recommendTel,
141
+                                         @RequestParam(value ="pageNumber",defaultValue = "1") Integer pageNumber,
142
+                                         @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
143
+                                         @RequestParam(value ="entryType",required = false) String entryType,
144
+                                         @RequestParam(value ="verifyStatus",required = false) String verifyStatus,
145
+                                         @RequestParam(value = "sex",required = false)Integer sex){
146
+        try{
147
+            return ResponseBean.success(taRecommendCustomerService.getRecCustomerList(pageNumber,pageSize,buildingId,name,tel,recommendName,recommendTel,entryType,verifyStatus,sex));
148
+        }catch (Exception e){
149
+            e.printStackTrace();
150
+            return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
151
+        }
152
+    }
153
+    @GetMapping("/admin/customer/recommend/report")
154
+    public ResponseBean getRepCustomerList (@RequestParam(value ="name",required = false) String name,
155
+                                         @RequestParam(value ="tel",required = false) String tel,
156
+                                         @RequestParam(value ="buildingId",required = false) String buildingId,
157
+                                         @RequestParam(value ="consultName",required = false) String consultName,
158
+                                         @RequestParam(value ="consultTel",required = false) String consultTel,
159
+                                         @RequestParam(value ="pageNumber",defaultValue = "1") Integer pageNumber,
160
+                                         @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
161
+                                         @RequestParam(value ="entryType",required = false) String entryType,
162
+                                         @RequestParam(value ="verifyStatus",required = false) String verifyStatus,
163
+                                         @RequestParam(value = "sex",required = false)Integer sex){
164
+        try{
165
+            return ResponseBean.success(taRecommendCustomerService.getRepCustomerList(pageNumber,pageSize,buildingId,name,tel,consultName,consultTel,entryType,verifyStatus,sex));
166
+        }catch (Exception e){
167
+            e.printStackTrace();
168
+            return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
169
+        }
170
+    }
171
+
172
+    @GetMapping("/admin/customer/agents")
173
+    public ResponseBean getIndependentAgents (@RequestParam(value ="name",required = false) String name,
174
+                                            @RequestParam(value ="tel",required = false) String tel,
175
+                                            @RequestParam(value ="pageNumber",defaultValue = "1") Integer pageNumber,
176
+                                            @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
177
+        try{
178
+            return ResponseBean.success(taRecommendCustomerService.getIndependentAgents(pageNumber,pageSize,name,tel));
179
+        }catch (Exception e){
180
+            e.printStackTrace();
181
+            return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
182
+        }
183
+    }
184
+
135 185
 
136 186
     @GetMapping("/admin/customer/recommend/{customerId}")
137 187
     public ResponseBean getCustomersIRecommended (@RequestParam int pageNumber, @RequestParam int pageSize, @PathVariable String customerId){

+ 4
- 2
src/main/java/com/huiju/estateagents/mapper/TaRecommendCustomerMapper.java Wyświetl plik

@@ -1,6 +1,7 @@
1 1
 package com.huiju.estateagents.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.huiju.estateagents.entity.TaPerson;
4 5
 import com.huiju.estateagents.entity.TaRecommendCustomer;
5 6
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6 7
 import org.apache.ibatis.annotations.Mapper;
@@ -26,6 +27,7 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
26 27
     TaRecommendCustomer getCustomerById(@Param("customerId")String customerId);
27 28
 
28 29
     IPage<TaRecommendCustomer> getCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex);
29
-
30
-
30
+    IPage<TaRecommendCustomer> getRecCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex);
31
+    IPage<TaRecommendCustomer> getRepCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex);
32
+    IPage<TaPerson> getIndependentAgents(IPage<TaPerson>page, @Param("name") String name, @Param("tel") String tel);
31 33
 }

+ 9
- 0
src/main/java/com/huiju/estateagents/service/ITaRecommendCustomerService.java Wyświetl plik

@@ -24,10 +24,19 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
24 24
 
25 25
     ResponseBean recommendCust(String paramStr, String openid);
26 26
 
27
+    ResponseBean reportCust(String paramStr, String openid);
28
+
27 29
     IPage<TaRecommendCustomer> getUnSignedCustomerList(int pageNumber, int pageSize, String building,String personId);
28 30
 
29 31
     IPage<TaRecommendCustomer> getCustomerList(int pageNumber, int pageSize, String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex);
30 32
 
33
+    IPage<TaRecommendCustomer> getRecCustomerList(int pageNumber, int pageSize, String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex);
34
+
35
+    IPage<TaRecommendCustomer> getRepCustomerList(int pageNumber, int pageSize, String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex);
36
+
37
+    IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize,String name,String tel);
38
+
39
+
31 40
     TaRecommendCustomer getCustomerDetail(String customerId);
32 41
 
33 42
     TaRecommendCustomer getCustomerById(String customerId);

+ 97
- 4
src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java Wyświetl plik

@@ -183,8 +183,6 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
183 183
         taRecommendCustomer.setEntryType(CommConstant.ENTRY_INPUT);
184 184
         taRecommendCustomer.setVerifyStatus(CommConstant.VERIFY_READY);
185 185
 
186
-        // 报备日期是今天
187
-        taRecommendCustomer.setReportDate(LocalDateTime.now());
188 186
 
189 187
         String status = params.getString("status");
190 188
         if (null == status) status = "1";
@@ -195,10 +193,10 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
195 193
         QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
196 194
         queryWrapper.eq("name", taRecommendCustomer.getName());
197 195
         queryWrapper.eq("phone", taRecommendCustomer.getPhone());
198
-        queryWrapper.ge("report_date", LocalDateTime.now().minusDays(10));
196
+        queryWrapper.eq("building_id",taRecommendCustomer.getBuildingId());
199 197
         List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
200 198
         if (null != result && result.size() > 0) {
201
-            return ResponseBean.error("当前客户尚在保护期, 不能再次推荐", ResponseBean.ERROR_ILLEGAL_PARAMS);
199
+            return ResponseBean.error("当前客户已被推荐, 不能再次推荐", ResponseBean.ERROR_ILLEGAL_PARAMS);
202 200
         }
203 201
 
204 202
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
@@ -206,6 +204,83 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
206 204
             return ResponseBean.error("推荐客户失败", ResponseBean.ERROR_UNAVAILABLE);
207 205
         }
208 206
 
207
+//        // 找到销售经理,并推送消息
208
+//        TaPerson saleMan = taPersonMapper.getSalesExecutive();
209
+//        if (null != saleMan && !StringUtils.isEmpty(saleMan.getMiniOpenid())) {
210
+//            // 发送消息
211
+//            iMiniAppService.sendNewCustomerMessage(saleMan.getMiniOpenid(), CommConstant.MINIAPP_INDEX, taRecommendCustomer.getName(), taRecommendCustomer.getPhone(), "", taPerson.getName());
212
+//        }
213
+
214
+        return ResponseBean.success(taRecommendCustomer);
215
+    }
216
+
217
+
218
+
219
+    @Override
220
+    public ResponseBean reportCust(String paramStr, String openid) {
221
+        JSONObject params = JSONObject.parseObject(paramStr);
222
+        if (null == params) {
223
+            return ResponseBean.error("解析参数失败", ResponseBean.ERROR_ILLEGAL_PARAMS);
224
+        }
225
+        List<TaPerson> taPersons = getPersonsByOpenId(openid);
226
+        if (null == taPersons || taPersons.size() != 1) {
227
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
228
+        }
229
+        TaPerson taPerson = taPersons.get(0);
230
+
231
+        String checkResult = checkCustomerParams(params);
232
+        if (null != checkResult) {
233
+            return ResponseBean.error(checkResult, ResponseBean.ERROR_MISSING_PARAMS);
234
+        }
235
+
236
+        TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
237
+
238
+        taRecommendCustomer.setName(params.getString("name"));
239
+        taRecommendCustomer.setPicture(params.getString("picture"));
240
+        taRecommendCustomer.setPhone(params.getString("phone"));
241
+        taRecommendCustomer.setSex(params.getInteger("sex"));
242
+        taRecommendCustomer.setDescribe(params.getString("describe"));
243
+        taRecommendCustomer.setRealtyConsultant(params.getString("RealtyConsultant"));
244
+        taRecommendCustomer.setBuildingId(params.getString("buildingId"));
245
+        taRecommendCustomer.setReportRecommendStatus(CommConstant.REPORTED);
246
+        taRecommendCustomer.setCreateDate(LocalDateTime.now());
247
+
248
+        // 时间格式 yyyy-MM-dd
249
+        String at = params.getString("appointmentTime");
250
+        if (!StringUtils.isEmpty(at)) {
251
+            taRecommendCustomer.setAppointmentTime(DateUtils.day2LocalDateime(at));
252
+        }
253
+
254
+//        taRecommendCustomer.setAppointmentTime((String) params.get("appointmentTime"));
255
+        taRecommendCustomer.setVisiteNum(params.getInteger("visiteNum"));
256
+        taRecommendCustomer.setIntention(params.getString("intention"));
257
+        taRecommendCustomer.setRealtyManageType(params.getString("realtyManageType"));
258
+        taRecommendCustomer.setDemandType(params.getString("demandType"));
259
+        taRecommendCustomer.setPriceRange(params.getString("priceRange"));
260
+        taRecommendCustomer.setEntryType(CommConstant.ENTRY_INPUT);
261
+        taRecommendCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
262
+
263
+
264
+        String status = params.getString("status");
265
+        if (null == status) status = "1";
266
+        taRecommendCustomer.setStatus(status);
267
+        taRecommendCustomer.setRecommendPerson(taPerson.getPersonId());
268
+
269
+        // 报备有 10 天有效期
270
+        QueryWrapper<TaRecommendCustomer> queryWrapper = new QueryWrapper<>();
271
+        queryWrapper.eq("name", taRecommendCustomer.getName());
272
+        queryWrapper.eq("phone", taRecommendCustomer.getPhone());
273
+        queryWrapper.eq("building_id",taRecommendCustomer.getBuildingId());
274
+        List<TaRecommendCustomer> result = taRecommendCustomerMapper.selectList(queryWrapper);
275
+        if (null != result && result.size() > 0) {
276
+            return ResponseBean.error("当前客户已被报备, 不能再次报备", ResponseBean.ERROR_ILLEGAL_PARAMS);
277
+        }
278
+
279
+        int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
280
+        if (row < 1) {
281
+            return ResponseBean.error("报备客户失败", ResponseBean.ERROR_UNAVAILABLE);
282
+        }
283
+
209 284
         // 找到销售经理,并推送消息
210 285
         TaPerson saleMan = taPersonMapper.getSalesExecutive();
211 286
         if (null != saleMan && !StringUtils.isEmpty(saleMan.getMiniOpenid())) {
@@ -256,6 +331,24 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
256 331
         return taRecommendCustomerMapper.getCustomerList(page,building,name,tel,consultName,consultTel,entryType,verifyStatus,sex);
257 332
     }
258 333
 
334
+    @Override
335
+    public IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize,String name,String tel){
336
+        IPage<TaPerson>page = new Page<>(pageNumber,pageSize);
337
+        return taRecommendCustomerMapper.getIndependentAgents(page,name,tel);
338
+    }
339
+
340
+    @Override
341
+    public IPage<TaRecommendCustomer> getRecCustomerList(int pageNumber, int pageSize,String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex){
342
+        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
343
+        return taRecommendCustomerMapper.getCustomerList(page,building,name,tel,consultName,consultTel,entryType,verifyStatus,sex);
344
+    }
345
+
346
+    @Override
347
+    public IPage<TaRecommendCustomer> getRepCustomerList(int pageNumber, int pageSize,String building,String name,String tel,String consultName,String consultTel,String entryType,String verifyStatus,Integer sex){
348
+        IPage<TaRecommendCustomer>page = new Page<>(pageNumber,pageSize);
349
+        return taRecommendCustomerMapper.getCustomerList(page,building,name,tel,consultName,consultTel,entryType,verifyStatus,sex);
350
+    }
351
+
259 352
     @Override
260 353
     public TaRecommendCustomer getCustomerById(String customerId){
261 354
         return taRecommendCustomerMapper.getCustomerById(customerId);

+ 114
- 14
src/main/resources/mapper/TaRecommendCustomerMapper.xml Wyświetl plik

@@ -31,20 +31,18 @@ FROM
31 31
 	GROUP BY a.customer_id
32 32
     </select>
33 33
 
34
-    <select id="getCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
34
+    <select id="getRecCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
35 35
         SELECT
36
-	a.*,
37
-	a.customer_id as customerId,
38
-	b.name as consultantName,
39
-    b.tel as consultTel,
40
-    c.nickname as recommendName,
41
-    c.tel as recommendTel
42
-FROM
43
-	ta_recommend_customer a
44
-	LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
45
-    LEFT JOIN ta_person c on a.recommend_person = c.person_id
36
+        a.*,
37
+        a.customer_id as customerId,
38
+        c.phone as recommendTel,
39
+        c.nickname as recommendName
40
+        FROM
41
+        ta_recommend_customer a
42
+        LEFT JOIN ta_person c on a.recommend_person = c.person_id
46 43
 	<where>
47 44
         a.status > 0
45
+        and a.report_recommend_status = 2
48 46
         <if test="building != null and building !=''">
49 47
             and a.building_id = #{building}
50 48
         </if>
@@ -55,10 +53,10 @@ FROM
55 53
             and a.phone = #{tel}
56 54
         </if>
57 55
         <if test="consultName != null and consultName !=''">
58
-            and b.name like CONCAT('%',#{consultName}, '%')
56
+            and c.nickname like CONCAT('%',#{consultName}, '%')
59 57
         </if>
60 58
         <if test="consultTel != null and consultTel !=''">
61
-            and b.tel = #{consultTel}
59
+            and c.phone = #{consultTel}
62 60
         </if>
63 61
         <if test="entryType != null and entryType !=''">
64 62
             and a.entry_type = #{entryType}
@@ -69,8 +67,110 @@ FROM
69 67
         <if test="sex != null and sex !=''">
70 68
             and a.sex = #{sex}
71 69
         </if>
72
-
73 70
     </where>
71
+        order by a.create_date desc
72
+    </select>
73
+
74
+    <select id="getIndependentAgents" resultType="com.huiju.estateagents.entity.TaPerson">
75
+        SELECT
76
+	*
77
+FROM
78
+	ta_person
79
+<where>
80
+    person_type = 'estate agent'
81
+    and status >0
82
+    <if test="name != null and name !=''">
83
+        and a.nickname = #{name}
84
+    </if>
85
+    <if test="tel != null and tel!=''">
86
+        and a.phone = #{tel}
87
+    </if>
88
+
89
+</where>
90
+
91
+ORDER BY
92
+	create_date DESC
93
+    </select>
94
+
95
+    <select id="getRepCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
96
+        SELECT
97
+        a.*,
98
+        a.customer_id AS customerId,
99
+        b.NAME AS consultantName,
100
+        b.tel AS consultTel
101
+        FROM
102
+        ta_recommend_customer a
103
+        LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
104
+        <where>
105
+            a.status > 0
106
+            and a.report_recommend_status = 1
107
+            <if test="building != null and building !=''">
108
+                and a.building_id = #{building}
109
+            </if>
110
+            <if test="name != null and name !=''">
111
+                and a.name = #{name}
112
+            </if>
113
+            <if test="tel != null and tel!=''">
114
+                and a.phone = #{tel}
115
+            </if>
116
+            <if test="consultName != null and consultName !=''">
117
+                and b.name like CONCAT('%',#{consultName}, '%')
118
+            </if>
119
+            <if test="consultTel != null and consultTel !=''">
120
+                and b.tel = #{consultTel}
121
+            </if>
122
+            <if test="entryType != null and entryType !=''">
123
+                and a.entry_type = #{entryType}
124
+            </if>
125
+            <if test="verifyStatus != null and verifyStatus !=''">
126
+                and a.verify_status = #{verifyStatus}
127
+            </if>
128
+            <if test="sex != null and sex !=''">
129
+                and a.sex = #{sex}
130
+            </if>
131
+        </where>
132
+        order by a.create_date desc
133
+    </select>
134
+    <select id="getCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
135
+        SELECT
136
+        a.*,
137
+        a.customer_id as customerId,
138
+        b.name as consultantName,
139
+        b.tel as consultTel,
140
+        c.nickname as recommendName,
141
+        c.tel as recommendTel
142
+        FROM
143
+        ta_recommend_customer a
144
+        LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
145
+        LEFT JOIN ta_person c on a.recommend_person = c.person_id
146
+        <where>
147
+            a.status > 0
148
+            <if test="building != null and building !=''">
149
+                and a.building_id = #{building}
150
+            </if>
151
+            <if test="name != null and name !=''">
152
+                and a.name = #{name}
153
+            </if>
154
+            <if test="tel != null and tel!=''">
155
+                and a.phone = #{tel}
156
+            </if>
157
+            <if test="consultName != null and consultName !=''">
158
+                and b.name like CONCAT('%',#{consultName}, '%')
159
+            </if>
160
+            <if test="consultTel != null and consultTel !=''">
161
+                and b.tel = #{consultTel}
162
+            </if>
163
+            <if test="entryType != null and entryType !=''">
164
+                and a.entry_type = #{entryType}
165
+            </if>
166
+            <if test="verifyStatus != null and verifyStatus !=''">
167
+                and a.verify_status = #{verifyStatus}
168
+            </if>
169
+            <if test="sex != null and sex !=''">
170
+                and a.sex = #{sex}
171
+            </if>
172
+        </where>
173
+        order by a.create_date desc
74 174
     </select>
75 175
     <select id="getCustomerById" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
76 176
          SELECT