Преглед изворни кода

Merge branch 'v4' of http://git.ycjcjy.com/welcome/service-welcome3 into v4

张延森 пре 6 година
родитељ
комит
54722be5ca

+ 23
- 2
src/main/java/com.huiju.welcome/controller/TaCustomerController.java Прегледај датотеку

@@ -12,6 +12,7 @@ import com.huiju.welcome.service.*;
12 12
 import com.huiju.welcome.utils.DateUtils;
13 13
 import com.huiju.welcome.utils.JWTUtils;
14 14
 import com.huiju.welcome.utils.StatusUtils;
15
+import com.huiju.welcome.utils.StringUtils;
15 16
 import org.apache.http.HttpStatus;
16 17
 import org.slf4j.Logger;
17 18
 import org.slf4j.LoggerFactory;
@@ -57,6 +58,9 @@ public class TaCustomerController extends BaseController {
57 58
     @Autowired
58 59
     ISysUserService iSysUserService;
59 60
 
61
+    @Autowired
62
+    ITaCarService iTaCarService;
63
+
60 64
     /**
61 65
      * 保存对象
62 66
      * @param taCustomer 实体对象
@@ -77,6 +81,12 @@ public class TaCustomerController extends BaseController {
77 81
         taCustomer.setConsultantId(user.getUserId());
78 82
         taCustomer.setRealtyConsultant(user.getUsername());
79 83
 
84
+        if (!StringUtils.isEmpty(taCustomer.getPlateNumber())) {
85
+            TaCar taCar = iTaCarService.getById(taCustomer.getPlateNumber());
86
+            taCustomer.setCarColor(taCar.getColor());
87
+            taCustomer.setCarModel(taCar.getCarModel());
88
+        }
89
+
80 90
         ResponseBean responseBean = new ResponseBean();
81 91
         try {
82 92
             // 会员保存之前, 先保存人员
@@ -113,7 +123,9 @@ public class TaCustomerController extends BaseController {
113 123
             iTaCustomerMapService.saveBatch(customerMapList);
114 124
 
115 125
             // 新增会员来访信息
116
-            iTaMainUsherRecordService.newRecordByConsultant(taCustomer, follows);
126
+            if (!StringUtils.isEmpty(taCustomer.getAvatar())) {
127
+                iTaMainUsherRecordService.newRecordByConsultant(taCustomer, follows);
128
+            }
117 129
 
118 130
             taCustomer.setStatus(StatusUtils.Normal);
119 131
             taCustomer.setCreateDate(LocalDateTime.now());
@@ -168,6 +180,12 @@ public class TaCustomerController extends BaseController {
168 180
         TaCustomer taCustomer = JSONObject.parseObject(paramStr, TaCustomer.class);
169 181
         JSONArray follows = params.getJSONArray("follows");
170 182
 
183
+        if (!StringUtils.isEmpty(taCustomer.getPlateNumber()) && StringUtils.isEmpty(taCustomer.getCarModel())) {
184
+            TaCar taCar = iTaCarService.getById(taCustomer.getPlateNumber());
185
+            taCustomer.setCarColor(taCar.getColor());
186
+            taCustomer.setCarModel(taCar.getCarModel());
187
+        }
188
+
171 189
         ResponseBean responseBean = new ResponseBean();
172 190
         try {
173 191
 
@@ -200,7 +218,9 @@ public class TaCustomerController extends BaseController {
200 218
 //                taCustomer.setRemark(originRemark);
201 219
 //            }
202 220
 
203
-            iTaMainUsherRecordService.updateByCustomer(taCustomer, follows, JWTUtils.getSubject(request));
221
+            if (!StringUtils.isEmpty(taCustomer.getAvatar())) {
222
+                iTaMainUsherRecordService.updateByCustomer(taCustomer, follows, JWTUtils.getSubject(request));
223
+            }
204 224
 
205 225
             //taCustomer.setRemark(null);
206 226
             if (iTaCustomerService.updateById(taCustomer)){
@@ -241,6 +261,7 @@ public class TaCustomerController extends BaseController {
241 261
 
242 262
             responseBean.addSuccess(cust);
243 263
         }catch (Exception e){
264
+            e.printStackTrace();
244 265
             logger.error("taCustomerGetByID -=- {}",e.toString());
245 266
             responseBean.addError(e.getMessage());
246 267
         }

+ 6
- 2
src/main/java/com.huiju.welcome/controller/TaGoodsOrdersController.java Прегледај датотеку

@@ -49,6 +49,8 @@ public class TaGoodsOrdersController extends BaseController {
49 49
     public ITaMainUsherRecordService iTaMainUsherRecordService;
50 50
     @Autowired
51 51
     public ITaCustomerService iTaCustomerService;
52
+    @Autowired
53
+    public ITaWechatUserService iTaWechatUserService;
52 54
 
53 55
 
54 56
     /**
@@ -61,7 +63,9 @@ public class TaGoodsOrdersController extends BaseController {
61 63
         ResponseBean responseBean = new ResponseBean();
62 64
         try {
63 65
             String userId = JWTUtils.getSubject(request);
64
-            SysUser sysUser = iSysUserService.getById(userId);
66
+            TaWechatUser user = iTaWechatUserService.getById(userId);
67
+
68
+            SysUser sysUser = iSysUserService.getById(user.getPersonId());
65 69
             taGoodsOrders.setUserId(sysUser.getUserId());
66 70
             taGoodsOrders.setUserName(sysUser.getUsername());
67 71
             taGoodsOrders.setUserType(sysUser.getUserIdentity());
@@ -74,7 +78,7 @@ public class TaGoodsOrdersController extends BaseController {
74 78
                 //
75 79
                 TaCustomer cust = iTaCustomerService.getById(taGoodsOrders.getCustomerId());
76 80
                 if (cust != null) {
77
-                    boolean ok = iTaMainUsherRecordService.newRecordByConsultant(cust, null);
81
+                    boolean ok = iTaMainUsherRecordService.newRecordByConsultant(cust, new JSONArray());
78 82
 
79 83
                     if (!ok) {
80 84
                         return ResponseBean.error("更新客户到访失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);

+ 1
- 1
src/main/java/com.huiju.welcome/controller/TaWechatUserController.java Прегледај датотеку

@@ -94,7 +94,7 @@ public class TaWechatUserController extends BaseController {
94 94
             map.put("identity", "");
95 95
         } else if (null != taWechatUser.getPersonId()) {
96 96
             SysUser sysUser = iSysUserService.getById(taWechatUser.getPersonId());
97
-            if (StatusUtils.Normal == sysUser.getStatus()) {
97
+            if (null != sysUser && StatusUtils.Normal == sysUser.getStatus()) {
98 98
                 map.put("identity", sysUser.getUserIdentity());
99 99
             }
100 100
         }

+ 2
- 0
src/main/java/com.huiju.welcome/model/TaCustomer.java Прегледај датотеку

@@ -64,6 +64,8 @@ public class TaCustomer implements Serializable {
64 64
 
65 65
     private String realtyConsultant;
66 66
 
67
+    private String carColor;
68
+
67 69
     @TableField(exist = false)
68 70
     private List<TaPerson> group;
69 71
 

+ 2
- 0
src/main/java/com.huiju.welcome/model/TaFirstUsherRecord.java Прегледај датотеку

@@ -59,4 +59,6 @@ public class TaFirstUsherRecord implements Serializable {
59 59
     private String driverImage;
60 60
 
61 61
     private String licenseImage;
62
+
63
+    private String phone;
62 64
 }

+ 3
- 0
src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java Прегледај датотеку

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.service.IService;
6 6
 import com.huiju.welcome.common.base.ResponseBean;
7 7
 import com.huiju.welcome.model.TaCustomer;
8
+import com.huiju.welcome.model.TaFirstUsherRecord;
8 9
 import com.huiju.welcome.model.TaMainUsherRecord;
9 10
 import com.huiju.welcome.model.TaPerson;
10 11
 
@@ -48,4 +49,6 @@ public interface ITaMainUsherRecordService extends IService<TaMainUsherRecord> {
48 49
     TaMainUsherRecord getTodayRecord(Integer customerId);
49 50
     
50 51
     boolean updateMainUsherRecord(TaMainUsherRecord taMainUsherRecord, Integer customerId, String subject);
52
+
53
+    TaMainUsherRecord newRecordByFirstUsher(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer);
51 54
 }

+ 1
- 1
src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java Прегледај датотеку

@@ -115,7 +115,7 @@ public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCar
115 115
             if (null != personId && personId > 0) {
116 116
                 // 是否内部人员
117 117
                 TaPerson taPerson = iTaPersonService.getByIdOrReal(personId);
118
-                if (null != taPerson.getTypeId() && taPerson.getTypeId() == CommConstant.TYPE_INNER_PERSON) {
118
+                if (null != taPerson && null != taPerson.getTypeId() && taPerson.getTypeId() == CommConstant.TYPE_INNER_PERSON) {
119 119
                     taCarRecordMapper.insert(taCarRecord);
120 120
                     iTaCarService.newCarByDevice(taCarRecord);
121 121
                     return true;

+ 22
- 3
src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java Прегледај датотеку

@@ -50,6 +50,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
50 50
     @Autowired
51 51
     ITaMainUsherRecordService iTaMainUsherRecordService;
52 52
 
53
+    @Autowired
54
+    ITaFirstUsherRecordService iTaFirstUsherRecordService;
55
+
53 56
     @Autowired
54 57
     ITaVisitorAppointmentService iTaVisitorAppointmentService;
55 58
 
@@ -240,8 +243,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
240 243
 
241 244
     @Override
242 245
     public Map<String, Object> getHistoryRecBy(Map<String, Object> filters) {
246
+        String phone = filters.get("phone").toString();
243 247
         Map<String, Object> result = new HashMap<String, Object>(){{
244
-            put("phone", filters.get("phone").toString());
248
+            put("phone", phone);
245 249
         }};
246 250
 
247 251
         List<TaVisitorAppointment> appointments = iTaVisitorAppointmentService.getAppointmentsBy(filters);
@@ -255,7 +259,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
255 259
             result.put("customerId", "");
256 260
         }
257 261
 
258
-        List<TaCustomer> custs = taCustomerMapper.getSomeCustMayBe(null, filters.get("phone").toString());
262
+        List<TaCustomer> custs = taCustomerMapper.getSomeCustMayBe(null, phone);
259 263
         if (null != custs && custs.size() > 0) {
260 264
             result.put("source", "customer");
261 265
             result.put("name", custs.get(0).getCustomerName());
@@ -267,7 +271,22 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
267 271
             result.put("customerId", custs.get(0).getCustomerId());
268 272
         }
269 273
 
270
-        return result;
274
+        // 如果车牌不存在, 查询车辆来访记录
275
+        // 只使用最近的一次记录
276
+        if (null == result.get("plateNumber")) {
277
+            QueryWrapper<TaFirstUsherRecord> queryWrapper = new QueryWrapper<>();
278
+            queryWrapper.eq("phone", phone);
279
+            queryWrapper.ge("status", StatusUtils.Ready);
280
+            queryWrapper.orderByDesc("visite_date");
281
+            queryWrapper.last("limit 1");
282
+
283
+            TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.getOne(queryWrapper);
284
+            if (null != taFirstUsherRecord && null != taFirstUsherRecord.getPlateNumber()) {
285
+                result.put("plateNumber", taFirstUsherRecord.getPlateNumber());
286
+            }
287
+        }
288
+
289
+      return result;
271 290
     }
272 291
 
273 292
     @Override

+ 29
- 4
src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java Прегледај датотеку

@@ -121,20 +121,37 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
121 121
         }
122 122
 
123 123
         // 查找客户
124
-        TaCustomer taCustomer = iTaCustomerService.getByPhoneOrPlate(null, taFirstUsherRecord.getPlateNumber());
124
+        TaCustomer taCustomer = iTaCustomerService.getByPhoneOrPlate(taFirstUsherRecord.getPhone(), taFirstUsherRecord.getPlateNumber());
125 125
         if (null == taCustomer) return true;
126 126
 
127 127
         // 更新车型
128 128
         if (null != taFirstUsherRecord.getCarModel()) {
129 129
             taCustomer.setCarModel(taFirstUsherRecord.getCarModel());
130
-            iTaCustomerService.updateById(taCustomer);
130
+            taCustomer.setCarColor(taFirstUsherRecord.getColor());
131 131
         }
132 132
 
133
+        // 更新车牌
134
+        if (StringUtils.isEmpty(taCustomer.getPlateNumber())) {
135
+            taCustomer.setPlateNumber(taFirstUsherRecord.getPlateNumber());
136
+        }
137
+
138
+        iTaCustomerService.updateById(taCustomer);
139
+
133 140
         // 更新到访记录
134 141
         TaMainUsherRecord taMainUsherRecord = iTaMainUsherRecordService.getTodayRecord(taCustomer.getCustomerId());
142
+        if (null == taMainUsherRecord) {
143
+            iTaMainUsherRecordService.newRecordByFirstUsher(taFirstUsherRecord, taCustomer);
144
+        } else {
145
+
146
+            if (null != taFirstUsherRecord.getCarModel()) {
147
+                taMainUsherRecord.setCarModel(taFirstUsherRecord.getCarModel());
148
+                taMainUsherRecord.setColor(taFirstUsherRecord.getColor());
149
+            }
150
+
151
+            if (StringUtils.isEmpty(taMainUsherRecord.getPlateNumber())) {
152
+                taMainUsherRecord.setPlateNumber(taFirstUsherRecord.getPlateNumber());
153
+            }
135 154
 
136
-        if (null != taMainUsherRecord && null != taFirstUsherRecord.getCarModel()) {
137
-            taMainUsherRecord.setCarModel(taFirstUsherRecord.getCarModel());
138 155
             iTaMainUsherRecordService.updateById(taMainUsherRecord);
139 156
         }
140 157
 
@@ -173,6 +190,14 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
173 190
 
174 191
     private void notifyConsultant(TaFirstUsherRecord taFirstUsherRecord) {
175 192
         String plateNumber = taFirstUsherRecord.getPlateNumber();
193
+//        String phone = taFirstUsherRecord.getPhone();
194
+
195
+//        TaCustomer taCustomer = iTaCustomerService.getByPhoneOrPlate(phone, plateNumber);
196
+//        if (null != taCustomer) {
197
+//            try {
198
+//                iTaCustomerService.notifyConsultant(taCustomer);
199
+//            } catch (Exception e) {}
200
+//        }
176 201
 
177 202
         // 依据车牌判断是否老客户来访
178 203
         if (!StringUtils.isEmpty(plateNumber)) {

+ 32
- 2
src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java Прегледај датотеку

@@ -109,7 +109,7 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
109 109
 
110 110
     @Override
111 111
     public boolean newRecordByConsultant(TaCustomer taCustomer, JSONArray follows) {
112
-        if (StringUtils.isEmpty(taCustomer.getRemark()) && (null == follows || follows.size() == 0)) {
112
+        if (StringUtils.isEmpty(taCustomer.getRemark()) && null == follows) {
113 113
             return false;
114 114
         }
115 115
 
@@ -147,6 +147,8 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
147 147
         taMainUsherRecord.setChannel(taCustomer.getChannel());
148 148
         taMainUsherRecord.setPurpose(taCustomer.getPurpose());
149 149
         taMainUsherRecord.setPlateNumber(taCustomer.getPlateNumber());
150
+        taMainUsherRecord.setCarModel(taCustomer.getCarModel());
151
+        taMainUsherRecord.setColor(taCustomer.getCarColor());
150 152
         taMainUsherRecord.setVisiteDate(LocalDateTime.now());
151 153
         taMainUsherRecord.setRemark(taCustomer.getRemark());
152 154
 
@@ -496,7 +498,35 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
496 498
     
497 499
         return true;
498 500
     }
499
-    
501
+
502
+    @Override
503
+    public TaMainUsherRecord newRecordByFirstUsher(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer) {
504
+        TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
505
+        taMainUsherRecord.setColor(taFirstUsherRecord.getColor());
506
+        taMainUsherRecord.setPlateNumber(taFirstUsherRecord.getPlateNumber());
507
+        taMainUsherRecord.setStatus(StatusUtils.Normal);
508
+        taMainUsherRecord.setAvatar(taFirstUsherRecord.getDriverImage());
509
+        taMainUsherRecord.setPhone(taFirstUsherRecord.getPhone());
510
+        taMainUsherRecord.setVisiteDate(taFirstUsherRecord.getVisiteDate());
511
+        taMainUsherRecord.setCarModel(taFirstUsherRecord.getCarModel());
512
+        taMainUsherRecord.setChannel(taFirstUsherRecord.getChannel());
513
+        taMainUsherRecord.setPurpose(taFirstUsherRecord.getPurpose());
514
+        taMainUsherRecord.setCarImage(taFirstUsherRecord.getCarImage());
515
+
516
+        if (null != taCustomer) {
517
+            taMainUsherRecord.setPersonId(taCustomer.getCustomerId());
518
+            taMainUsherRecord.setCustomerId(taCustomer.getCustomerId());
519
+            taMainUsherRecord.setConsultantId(taCustomer.getConsultantId());
520
+            taMainUsherRecord.setPersonName(taCustomer.getCustomerName());
521
+            taMainUsherRecord.setRealtyConsultant(taCustomer.getRealtyConsultant());
522
+            taMainUsherRecord.setSex(taCustomer.getSex());
523
+            taMainUsherRecord.setPhone(taCustomer.getPhone());
524
+        }
525
+
526
+        taMainUsherRecordMapper.insert(taMainUsherRecord);
527
+        return taMainUsherRecord;
528
+    }
529
+
500 530
     private TaMainUsherRecord newRecordByPerson(TaPerson taPerson) {
501 531
         TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
502 532
         taMainUsherRecord.setPersonName(taPerson.getName());

+ 26
- 1
src/main/java/com.huiju.welcome/service/impl/TaPersonServiceImpl.java Прегледај датотеку

@@ -70,6 +70,9 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
70 70
     @Autowired
71 71
     private ITaVisitingWordsService visitingWordsService;
72 72
 
73
+    @Autowired
74
+    private ITaCustomerService iTaCustomerService;
75
+
73 76
     @Autowired
74 77
     private XFYun xfYun;
75 78
     
@@ -368,7 +371,29 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
368 371
         String words = taPerson.getWords();
369 372
         Integer sex = "2".equals(taPerson.getSex()) ? 2 : 1;
370 373
         String personName = taPerson.getName();
371
-        if (null == personName) personName = "";
374
+
375
+        // 是否有映射客户
376
+        TaCustomer taCustomer = iTaCustomerService.getSameByPerson(taPerson.getRealId());
377
+        if (null != taCustomer) {
378
+            if (null != taCustomer.getSex()) {
379
+                sex = taCustomer.getSex();
380
+            }
381
+
382
+            personName = taCustomer.getCustomerName();
383
+        }
384
+        if (null == personName || "".equals(personName)) {
385
+            personName = "";
386
+        } else {
387
+            // 客户名称只取姓
388
+            personName = personName.substring(0, 1);
389
+            if (1 == sex) {
390
+                personName += "先生";
391
+            } else {
392
+                personName += "女士";
393
+            }
394
+        }
395
+
396
+        taPerson.setName(personName);
372 397
 
373 398
         // 检查是不是有定制语音
374 399
         QueryWrapper<TaCustomWords> wrapper = new QueryWrapper<>();

+ 1
- 1
src/main/java/com.huiju.welcome/utils/CommConstant.java Прегледај датотеку

@@ -6,7 +6,7 @@ public class CommConstant {
6 6
     public final static String IDENTITY_MAINUSHER = "main-usher";
7 7
     public final static String IDENTITY_BARUSHER = "bar-usher";
8 8
 
9
-    public final static String PAGE_MY_CUSTOMER = "pages/client/myclient/myclient";
9
+    public final static String PAGE_MY_CUSTOMER = "pages/client/clientdetail/clientdetail";
10 10
 
11 11
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
12 12
 

+ 4
- 5
src/main/resources/mapper/TaCustomerMapper.xml Прегледај датотеку

@@ -21,11 +21,10 @@
21 21
     <select id="customerPage" resultType="com.huiju.welcome.model.TaCustomer">
22 22
         select
23 23
         *,
24
-        tct.to_user_name as agentUserName,
25
-        tct.to_user_id as agentUserId,
26
-        tct.transfer_id as transferId
24
+        consultant_id as agentUserId,
25
+        realty_consultant as agentUserName,
26
+        "" as transferId
27 27
         from ta_customer tac
28
-        left join ta_customer_transfer tct on tac.customer_id = tct.customer_id
29 28
         <where>
30 29
             <if test="customerName !=null and customerName != ''">
31 30
                 and tac.customer_name LIKE CONCAT('%',#{customerName},'%')
@@ -39,7 +38,7 @@
39 38
                 and   tac.plate_number LIKE CONCAT('%',#{platNumber},'%')
40 39
             </if>
41 40
             <if test="agentUserId != null">
42
-                and tct.to_user_id = #{agentUserId}
41
+                and tac.consultant_id = #{agentUserId}
43 42
             </if>
44 43
         </where>
45 44
         order by create_date desc