张延森 пре 5 година
родитељ
комит
7d83f2197a
29 измењених фајлова са 888 додато и 428 уклоњено
  1. 1
    1
      pom.xml
  2. 6
    0
      src/main/java/com.huiju.welcome/config/SMSProperties.java
  3. 203
    202
      src/main/java/com.huiju.welcome/controller/CameraController.java
  4. 12
    6
      src/main/java/com.huiju.welcome/controller/TaCustomerController.java
  5. 51
    2
      src/main/java/com.huiju.welcome/controller/TaFirstUsherRecordController.java
  6. 26
    1
      src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java
  7. 15
    9
      src/main/java/com.huiju.welcome/controller/TaWechatUserController.java
  8. 2
    0
      src/main/java/com.huiju.welcome/mapper/SysUserMapper.java
  9. 1
    1
      src/main/java/com.huiju.welcome/mapper/TaCustomerMapper.java
  10. 10
    0
      src/main/java/com.huiju.welcome/model/TaCustomer.java
  11. 16
    0
      src/main/java/com.huiju.welcome/model/TaFirstUsherRecord.java
  12. 5
    0
      src/main/java/com.huiju.welcome/model/TaMainUsherRecord.java
  13. 1
    0
      src/main/java/com.huiju.welcome/model/TaPerson.java
  14. 2
    4
      src/main/java/com.huiju.welcome/service/ICameraService.java
  15. 12
    2
      src/main/java/com.huiju.welcome/service/ITaCustomerService.java
  16. 2
    2
      src/main/java/com.huiju.welcome/service/ITaFirstUsherRecordService.java
  17. 3
    1
      src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java
  18. 20
    76
      src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java
  19. 21
    1
      src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java
  20. 162
    15
      src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java
  21. 60
    23
      src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java
  22. 209
    72
      src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java
  23. 4
    0
      src/main/java/com.huiju.welcome/utils/CommConstant.java
  24. 4
    1
      src/main/java/com.huiju.welcome/utils/MiniApp.java
  25. 7
    0
      src/main/java/com.huiju.welcome/utils/SMSUtils.java
  26. 3
    3
      src/main/resources/application.yml
  27. 11
    0
      src/main/resources/mapper/SysUserMapper.xml
  28. 15
    4
      src/main/resources/mapper/TaCustomerMapper.xml
  29. 4
    2
      src/main/resources/mapper/TaVisitorAppointmentMapper.xml

+ 1
- 1
pom.xml Прегледај датотеку

@@ -10,7 +10,7 @@
10 10
 	</parent>
11 11
 	<groupId>com.huiju.welcome</groupId>
12 12
 	<artifactId>mainbiz</artifactId>
13
-	<version>v4.0.1</version>
13
+	<version>v5.2.0</version>
14 14
 	<name>mainbiz</name>
15 15
 	<description>com.huiju.welcome main service</description>
16 16
 

+ 6
- 0
src/main/java/com.huiju.welcome/config/SMSProperties.java Прегледај датотеку

@@ -11,6 +11,7 @@ public class SMSProperties {
11 11
     String method;
12 12
     String contentType;
13 13
     Captcha captcha;
14
+    Visitor visitor;
14 15
 
15 16
     @Data
16 17
     public static class Template {
@@ -26,4 +27,9 @@ public class SMSProperties {
26 27
         Integer size;
27 28
         String sign;
28 29
     }
30
+
31
+    @Data
32
+    public static class Visitor {
33
+        String code;
34
+    }
29 35
 }

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

@@ -1,202 +1,203 @@
1
-package com.huiju.welcome.controller;
2
-
3
-import com.alibaba.fastjson.JSONObject;
4
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
6
-import com.huiju.welcome.common.Action;
7
-import com.huiju.welcome.common.WebSocketServer;
8
-import com.huiju.welcome.common.base.ResponseBean;
9
-import com.huiju.welcome.model.*;
10
-import com.huiju.welcome.service.*;
11
-import com.huiju.welcome.utils.AliFaceUtils;
12
-import com.huiju.welcome.utils.AliOSSUtils;
13
-import com.huiju.welcome.utils.StatusUtils;
14
-import com.huiju.welcome.utils.XFYun;
15
-import io.swagger.annotations.ApiOperation;
16
-import org.slf4j.Logger;
17
-import org.slf4j.LoggerFactory;
18
-import org.apache.http.HttpStatus;
19
-import org.springframework.beans.factory.annotation.Autowired;
20
-import org.springframework.beans.factory.annotation.Value;
21
-import org.springframework.transaction.annotation.Transactional;
22
-import org.springframework.web.bind.annotation.*;
23
-import org.springframework.web.multipart.MultipartFile;
24
-import org.springframework.web.multipart.MultipartHttpServletRequest;
25
-
26
-import javax.annotation.PostConstruct;
27
-import javax.servlet.http.HttpServletRequest;
28
-import javax.websocket.server.PathParam;
29
-import java.io.File;
30
-import java.io.FileOutputStream;
31
-import java.io.IOException;
32
-import java.nio.ByteBuffer;
33
-import java.nio.channels.FileChannel;
34
-import java.time.Duration;
35
-import java.time.LocalDateTime;
36
-import java.util.HashMap;
37
-import java.util.List;
38
-import java.util.Map;
39
-
40
-/**
41
- * @author FXF
42
- * @date 2019-03-13
43
- */
44
-@RestController
45
-@RequestMapping("/")
46
-@Transactional(rollbackFor = Exception.class)
47
-public class CameraController {
48
-	private Logger log = LoggerFactory.getLogger(XFYun.class);
49
-
50
-	@Autowired
51
-	ITaDeviceService taDeviceService;
52
-	
53
-	@Autowired
54
-	private ISysParamService iSysParamService;
55
-
56
-	@Autowired
57
-	private ITaCarRecordService iTaCarRecordService;
58
-
59
-	@Autowired
60
-	private ICameraService cameraService;
61
-
62
-	@Autowired
63
-	private AliFaceUtils aliFaceUtils;
64
-
65
-	@GetMapping("/ping")
66
-	public String ping() {
67
-		return "pong";
68
-	}
69
-
70
-	@ApiOperation(value = "人脸对比结果上传", notes = "人脸对比结果上传")
71
-	@PostMapping(value = "/camera/{deviceId}/person")
72
-	public ResponseBean person(
73
-			@PathVariable String deviceId,
74
-			MultipartFile snapshot,
75
-			TaSnapshotPerson taSnapshotPerson,
76
-			HttpServletRequest request) {
77
-		ResponseBean responseBean = new ResponseBean();
78
-
79
-		if (null == deviceId || null == taSnapshotPerson) {
80
-			responseBean.addError(HttpStatus.SC_BAD_REQUEST, "设备ID 或者 抓拍参数传入方式不正确");
81
-			return responseBean;
82
-		}
83
-
84
-		if (!deviceId.equals(taSnapshotPerson.getDeviceId())) {
85
-			responseBean.addError(HttpStatus.SC_BAD_REQUEST, "设备ID 或者 抓拍参数传入不正确");
86
-			return responseBean;
87
-		}
88
-
89
-		taSnapshotPerson.setAvatar(getMultipartFile(snapshot));
90
-
91
-		// 抓拍时间为当前时间
92
-		taSnapshotPerson.setCreateDate(LocalDateTime.now());
93
-
94
-		cameraService.newPersonByDevice(taSnapshotPerson);
95
-		return responseBean;
96
-	}
97
-
98
-	@PostMapping("/camera/{deviceId}/face")
99
-	public ResponseBean face(
100
-			@PathVariable("deviceId") String deviceId,
101
-			@RequestParam(value = "avatar", required = false) MultipartFile avatar,
102
-			@RequestParam(value = "score", defaultValue = "0") Integer score
103
-	) {
104
-		if (avatar.isEmpty()) {
105
-			return ResponseBean.error("没有找到人脸信息", HttpStatus.SC_BAD_REQUEST);
106
-		}
107
-
108
-		// 上传阿里云OSS
109
-		String avatarURL = getMultipartFile(avatar);
110
-
111
-		// 人像质量最低值, 低于这个值的认为人脸抓拍失败, 取值范围 1 - 100
112
-		Float faceMinScore = iSysParamService.getFaceMinScore();
113
-		if (score < faceMinScore) {
114
-			log.error("人脸质量过低, 放弃本次抓拍人脸 {}", avatarURL);
115
-			return ResponseBean.success("");
116
-		}
117
-
118
-		TaSnapshotPerson taSnapshotPerson = new TaSnapshotPerson();
119
-
120
-		// 人脸比对检索
121
-		JSONObject result = null;
122
-		try {
123
-			result = aliFaceUtils.searchFace(avatarURL);
124
-		} catch (Exception e) {
125
-			log.error("比对人脸失败: {}", e.getMessage());
126
-			e.printStackTrace();
127
-			return ResponseBean.error("比对人脸失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
128
-		}
129
-
130
-		if (null != result) {
131
-			Float rate = result.getFloat("rate");
132
-			if (null == rate) {
133
-				log.error("比对人脸异常, 比对阈值结果为空");
134
-				rate = 0.0f;
135
-			} else {
136
-				rate *= 100;
137
-			}
138
-			Integer matchPerson = result.getInteger("personId");
139
-
140
-			taSnapshotPerson.setSimilarity(rate);
141
-			taSnapshotPerson.setMatchPerson(matchPerson);
142
-		} else {
143
-			taSnapshotPerson.setSimilarity(0f);
144
-		}
145
-
146
-		taSnapshotPerson.setCreateDate(LocalDateTime.now());
147
-		taSnapshotPerson.setStatus(StatusUtils.Normal);
148
-		taSnapshotPerson.setAvatar(avatarURL);
149
-		taSnapshotPerson.setDeviceId(deviceId);
150
-		taSnapshotPerson.setScore(score);
151
-
152
-		cameraService.newPersonByDevice(taSnapshotPerson);
153
-		return ResponseBean.success("");
154
-	}
155
-
156
-	@PostMapping(value = "/camera/{deviceId}/car")
157
-	public ResponseBean car(
158
-			@PathVariable("deviceId") String deviceId,
159
-			@RequestParam("sceneImage") MultipartFile carImage,
160
-			@RequestParam("licenseImage") MultipartFile licenseImage,
161
-			@RequestParam(value = "driverImage", required = false) MultipartFile driverImage,
162
-			@RequestParam(value = "copilotImage", required = false) MultipartFile copilotImage,
163
-			@RequestParam("plateNumber") String plateNumber,
164
-			@RequestParam("color") String color,
165
-			@RequestParam("carModel") String carModel
166
-			) {
167
-
168
-		TaCarRecord taCarRecord = new TaCarRecord();
169
-		taCarRecord.setPlateNumber(plateNumber);
170
-		taCarRecord.setColor(color);
171
-		taCarRecord.setCarModel(carModel);
172
-		taCarRecord.setCreateDate(LocalDateTime.now());
173
-
174
-		if (null != carImage && !carImage.isEmpty()) {
175
-			taCarRecord.setCarImage(getMultipartFile(carImage));
176
-		}
177
-		if (null != licenseImage && !licenseImage.isEmpty()) {
178
-			taCarRecord.setLicenseImage(getMultipartFile(licenseImage));
179
-		}
180
-		if (null != driverImage && !driverImage.isEmpty()) {
181
-			taCarRecord.setDriverImage(getMultipartFile(driverImage));
182
-		}
183
-		if (null != copilotImage && !copilotImage.isEmpty()) {
184
-			taCarRecord.setCopilotImage(getMultipartFile(copilotImage));
185
-		}
186
-
187
-		iTaCarRecordService.newRecordByDevice(taCarRecord);
188
-
189
-		return ResponseBean.success("");
190
-	}
191
-
192
-	// 获取上传单文件
193
-	private String getMultipartFile(MultipartFile f) {
194
-		try {
195
-			return AliOSSUtils.putObject(f);
196
-		} catch (IOException e) {
197
-			e.printStackTrace();
198
-			log.error("上传人脸至阿里云失败: " + e.getMessage());
199
-			return null;
200
-		}
201
-	}
202
-}
1
+package com.huiju.welcome.controller;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
6
+import com.huiju.welcome.common.Action;
7
+import com.huiju.welcome.common.WebSocketServer;
8
+import com.huiju.welcome.common.base.ResponseBean;
9
+import com.huiju.welcome.model.*;
10
+import com.huiju.welcome.service.*;
11
+import com.huiju.welcome.utils.AliFaceUtils;
12
+import com.huiju.welcome.utils.AliOSSUtils;
13
+import com.huiju.welcome.utils.StatusUtils;
14
+import com.huiju.welcome.utils.XFYun;
15
+import io.swagger.annotations.ApiOperation;
16
+import org.slf4j.Logger;
17
+import org.slf4j.LoggerFactory;
18
+import org.apache.http.HttpStatus;
19
+import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.beans.factory.annotation.Value;
21
+import org.springframework.transaction.annotation.Transactional;
22
+import org.springframework.web.bind.annotation.*;
23
+import org.springframework.web.multipart.MultipartFile;
24
+import org.springframework.web.multipart.MultipartHttpServletRequest;
25
+
26
+import javax.annotation.PostConstruct;
27
+import javax.servlet.http.HttpServletRequest;
28
+import javax.websocket.server.PathParam;
29
+import java.io.File;
30
+import java.io.FileOutputStream;
31
+import java.io.IOException;
32
+import java.nio.ByteBuffer;
33
+import java.nio.channels.FileChannel;
34
+import java.time.Duration;
35
+import java.time.LocalDateTime;
36
+import java.util.HashMap;
37
+import java.util.List;
38
+import java.util.Map;
39
+
40
+/**
41
+ * @author FXF
42
+ * @date 2019-03-13
43
+ */
44
+@RestController
45
+@RequestMapping("/")
46
+@Transactional(rollbackFor = Exception.class)
47
+public class CameraController {
48
+	private Logger log = LoggerFactory.getLogger(XFYun.class);
49
+
50
+	@Autowired
51
+	ITaDeviceService taDeviceService;
52
+	
53
+	@Autowired
54
+	private ISysParamService iSysParamService;
55
+
56
+	@Autowired
57
+	private ITaCarRecordService iTaCarRecordService;
58
+
59
+	@Autowired
60
+	private ICameraService cameraService;
61
+
62
+	@Autowired
63
+	private AliFaceUtils aliFaceUtils;
64
+
65
+	@GetMapping("/ping")
66
+	public String ping() {
67
+		return "pong";
68
+	}
69
+
70
+	@ApiOperation(value = "人脸对比结果上传", notes = "人脸对比结果上传")
71
+	@PostMapping(value = "/camera/{deviceId}/person")
72
+	public ResponseBean person(
73
+			@PathVariable String deviceId,
74
+			MultipartFile snapshot,
75
+			TaSnapshotPerson taSnapshotPerson,
76
+			HttpServletRequest request) {
77
+		ResponseBean responseBean = new ResponseBean();
78
+
79
+		if (null == deviceId || null == taSnapshotPerson) {
80
+			responseBean.addError(HttpStatus.SC_BAD_REQUEST, "设备ID 或者 抓拍参数传入方式不正确");
81
+			return responseBean;
82
+		}
83
+
84
+		if (!deviceId.equals(taSnapshotPerson.getDeviceId())) {
85
+			responseBean.addError(HttpStatus.SC_BAD_REQUEST, "设备ID 或者 抓拍参数传入不正确");
86
+			return responseBean;
87
+		}
88
+
89
+		taSnapshotPerson.setAvatar(getMultipartFile(snapshot));
90
+
91
+		// 抓拍时间为当前时间
92
+		taSnapshotPerson.setCreateDate(LocalDateTime.now());
93
+
94
+		cameraService.newPersonByDevice(taSnapshotPerson);
95
+		return responseBean;
96
+	}
97
+
98
+	@PostMapping("/camera/{deviceId}/face")
99
+	public ResponseBean face(
100
+			@PathVariable("deviceId") String deviceId,
101
+			@RequestParam(value = "avatar", required = false) MultipartFile avatar,
102
+			@RequestParam(value = "score", defaultValue = "0") Integer score
103
+	) {
104
+		if (avatar.isEmpty()) {
105
+			return ResponseBean.error("没有找到人脸信息", HttpStatus.SC_BAD_REQUEST);
106
+		}
107
+
108
+		// 上传阿里云OSS
109
+		String avatarURL = getMultipartFile(avatar);
110
+
111
+		// 人像质量最低值, 低于这个值的认为人脸抓拍失败, 取值范围 1 - 100
112
+		Float faceMinScore = iSysParamService.getFaceMinScore();
113
+		if (score < faceMinScore) {
114
+			log.error("人脸质量过低, 放弃本次抓拍人脸 {}", avatarURL);
115
+			return ResponseBean.success("");
116
+		}
117
+
118
+		TaSnapshotPerson taSnapshotPerson = new TaSnapshotPerson();
119
+
120
+		// 人脸比对检索
121
+		JSONObject result = null;
122
+		try {
123
+			result = aliFaceUtils.searchFace(avatarURL);
124
+		} catch (Exception e) {
125
+			log.error("比对人脸失败: {}", e.getMessage());
126
+			e.printStackTrace();
127
+			return ResponseBean.error("比对人脸失败", HttpStatus.SC_INTERNAL_SERVER_ERROR);
128
+		}
129
+
130
+		if (null != result) {
131
+			Float rate = result.getFloat("rate");
132
+			if (null == rate) {
133
+				log.error("比对人脸异常, 比对阈值结果为空");
134
+				rate = 0.0f;
135
+			}
136
+//			else {
137
+//				rate *= 100;
138
+//			}
139
+			Integer matchPerson = result.getInteger("personId");
140
+
141
+			taSnapshotPerson.setSimilarity(rate);
142
+			taSnapshotPerson.setMatchPerson(matchPerson);
143
+		} else {
144
+			taSnapshotPerson.setSimilarity(0f);
145
+		}
146
+
147
+		taSnapshotPerson.setCreateDate(LocalDateTime.now());
148
+		taSnapshotPerson.setStatus(StatusUtils.Normal);
149
+		taSnapshotPerson.setAvatar(avatarURL);
150
+		taSnapshotPerson.setDeviceId(deviceId);
151
+		taSnapshotPerson.setScore(score);
152
+
153
+		cameraService.newPersonByDevice(taSnapshotPerson);
154
+		return ResponseBean.success("");
155
+	}
156
+
157
+	@PostMapping(value = "/camera/{deviceId}/car")
158
+	public ResponseBean car(
159
+			@PathVariable("deviceId") String deviceId,
160
+			@RequestParam("sceneImage") MultipartFile carImage,
161
+			@RequestParam("licenseImage") MultipartFile licenseImage,
162
+			@RequestParam(value = "driverImage", required = false) MultipartFile driverImage,
163
+			@RequestParam(value = "copilotImage", required = false) MultipartFile copilotImage,
164
+			@RequestParam("plateNumber") String plateNumber,
165
+			@RequestParam("color") String color,
166
+			@RequestParam("carModel") String carModel
167
+			) {
168
+
169
+		TaCarRecord taCarRecord = new TaCarRecord();
170
+		taCarRecord.setPlateNumber(plateNumber);
171
+		taCarRecord.setColor(color);
172
+		taCarRecord.setCarModel(carModel);
173
+		taCarRecord.setCreateDate(LocalDateTime.now());
174
+
175
+		if (null != carImage && !carImage.isEmpty()) {
176
+			taCarRecord.setCarImage(getMultipartFile(carImage));
177
+		}
178
+		if (null != licenseImage && !licenseImage.isEmpty()) {
179
+			taCarRecord.setLicenseImage(getMultipartFile(licenseImage));
180
+		}
181
+		if (null != driverImage && !driverImage.isEmpty()) {
182
+			taCarRecord.setDriverImage(getMultipartFile(driverImage));
183
+		}
184
+		if (null != copilotImage && !copilotImage.isEmpty()) {
185
+			taCarRecord.setCopilotImage(getMultipartFile(copilotImage));
186
+		}
187
+
188
+		iTaCarRecordService.newRecordByDevice(taCarRecord);
189
+
190
+		return ResponseBean.success("");
191
+	}
192
+
193
+	// 获取上传单文件
194
+	private String getMultipartFile(MultipartFile f) {
195
+		try {
196
+			return AliOSSUtils.putObject(f);
197
+		} catch (IOException e) {
198
+			e.printStackTrace();
199
+			log.error("上传人脸至阿里云失败: " + e.getMessage());
200
+			return null;
201
+		}
202
+	}
203
+}

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

@@ -259,7 +259,13 @@ public class TaCustomerController extends BaseController {
259 259
 
260 260
             List<TaPerson> group = iTaCustomerService.getGroup(cust.getCustomerId());
261 261
             cust.setGroup(group);
262
-
262
+            //插入车牌信息
263
+            QueryWrapper<TaCar> queryWrapper = new QueryWrapper<>();
264
+            queryWrapper.eq("plate_number",cust.getPlateNumber());
265
+            TaCar taCar = iTaCarService.getOne(queryWrapper);
266
+            if (null != taCar){
267
+                cust.setCarImage(taCar.getCarImage());
268
+            }
263 269
             responseBean.addSuccess(cust);
264 270
         }catch (Exception e){
265 271
             e.printStackTrace();
@@ -287,7 +293,7 @@ public class TaCustomerController extends BaseController {
287 293
         @RequestParam(defaultValue = "1") int pageNumber,
288 294
         @RequestParam(defaultValue = "10") int pageSize,
289 295
         @RequestParam(defaultValue = "false") boolean mine,
290
-        @RequestParam(defaultValue = "") String nameOrPhone,
296
+        @RequestParam(defaultValue = "", name = "nameOrPhone") String nameOrPhoneOrReceiver,
291 297
         @RequestParam(defaultValue = "" ) Integer consultant,
292 298
         HttpServletRequest request
293 299
     ){
@@ -302,7 +308,7 @@ public class TaCustomerController extends BaseController {
302 308
                 consultantId = consultant;
303 309
             }
304 310
 
305
-            IPage<TaCustomer> result = iTaCustomerService.getCustomerListOfFront(pageNumber, pageSize, consultantId, nameOrPhone);
311
+            IPage<TaCustomer> result = iTaCustomerService.getCustomerListOfFront(pageNumber, pageSize, consultantId, nameOrPhoneOrReceiver);
306 312
             List<TaCustomer> custs = result.getRecords();
307 313
 
308 314
             if (null != custs && custs.size() > 0) {
@@ -327,7 +333,7 @@ public class TaCustomerController extends BaseController {
327 333
      * @return
328 334
      */
329 335
     @RequestMapping(value="/miniapp/customer/visitor/{state}",method= RequestMethod.GET)
330
-    public ResponseBean visitorCustomerList(@RequestParam(defaultValue = "1") int pageNumber,
336
+    public ResponseBean visitorCustomerList(@RequestParam(defaultValue = "1") int pageNum,
331 337
                                             @RequestParam(defaultValue = "10") int pageSize,
332 338
                                             @PathVariable String state,
333 339
                                             HttpServletRequest request){
@@ -341,10 +347,10 @@ public class TaCustomerController extends BaseController {
341 347
             }
342 348
             //已归属和未归属人员列表 分页
343 349
             if (state.equals(CommConstant.CUSTOMER_ATTRIBUTION)) {
344
-                IPage<TaCustomer> result = iTaCustomerService.getAttributionList(pageNumber, pageSize);
350
+                IPage<TaCustomer> result = iTaCustomerService.getAttributionList(pageNum, pageSize);
345 351
                 responseBean.addSuccess(result);
346 352
             }else if (state.equals(CommConstant.CUSTOMER_UNATTRIBUTION)){
347
-                IPage<TaCustomer> result = iTaCustomerService.getUnattributionList(pageNumber, pageSize);
353
+                IPage<TaCustomer> result = iTaCustomerService.getUnattributionList(pageNum, pageSize);
348 354
                 responseBean.addSuccess(result);
349 355
             }
350 356
             

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

@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.huiju.welcome.common.base.BaseController;
7 7
 import com.huiju.welcome.common.base.ResponseBean;
8
+import com.huiju.welcome.model.TaCustomer;
8 9
 import com.huiju.welcome.model.TaFirstUsherRecord;
10
+import com.huiju.welcome.service.ITaCustomerService;
9 11
 import com.huiju.welcome.service.ITaFirstUsherRecordService;
10 12
 import com.huiju.welcome.utils.DateUtils;
11 13
 import com.huiju.welcome.utils.StatusUtils;
@@ -14,6 +16,10 @@ import org.slf4j.LoggerFactory;
14 16
 import org.springframework.beans.factory.annotation.Autowired;
15 17
 import org.springframework.web.bind.annotation.*;
16 18
 
19
+import java.time.LocalDateTime;
20
+import java.time.format.DateTimeFormatter;
21
+import java.util.List;
22
+
17 23
 
18 24
 /**
19 25
  * <p>
@@ -32,6 +38,8 @@ public class TaFirstUsherRecordController extends BaseController {
32 38
     @Autowired
33 39
     public ITaFirstUsherRecordService iTaFirstUsherRecordService;
34 40
 
41
+    @Autowired
42
+    private ITaCustomerService taCustomerService;
35 43
 
36 44
     /**
37 45
      * 保存对象
@@ -51,6 +59,7 @@ public class TaFirstUsherRecordController extends BaseController {
51 59
                 responseBean.addError("fail");
52 60
             }
53 61
         }catch (Exception e){
62
+            e.printStackTrace();
54 63
             logger.error("taFirstUsherRecordAdd -=- {}",e.toString());
55 64
             responseBean.addError(e.getMessage());
56 65
         }
@@ -120,7 +129,30 @@ public class TaFirstUsherRecordController extends BaseController {
120 129
         }
121 130
         return responseBean;
122 131
     }
123
-
132
+    
133
+    /**
134
+     * 根据id查询对象
135
+     * @param id  实体ID
136
+     */
137
+    @RequestMapping(value="/miniapp/firstUsherRecord/{id}",method= RequestMethod.GET)
138
+    public ResponseBean miniappGet(@PathVariable Integer id){
139
+        ResponseBean responseBean = new ResponseBean();
140
+        try {
141
+            TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.getById(id);
142
+            TaCustomer taCustomer = taCustomerService.getCutomerByPhoneAndPlatenumber(taFirstUsherRecord.getPhone(),taFirstUsherRecord.getPlateNumber());
143
+            if (null != taCustomer){
144
+                taFirstUsherRecord.setCustomerName(taCustomer.getCustomerName());
145
+                taFirstUsherRecord.setAvatar(taCustomer.getAvatar());
146
+                taFirstUsherRecord.setCustomerId(taCustomer.getCustomerId());
147
+            }
148
+            responseBean.addSuccess(taFirstUsherRecord);
149
+        }catch (Exception e){
150
+            logger.error("taFirstUsherRecordGetByID -=- {}",e.toString());
151
+            responseBean.addError(e.getMessage());
152
+        }
153
+        return responseBean;
154
+    }
155
+    
124 156
     /**
125 157
      * 根据id查询对象
126 158
      */
@@ -147,8 +179,25 @@ public class TaFirstUsherRecordController extends BaseController {
147 179
             queryWrapper.lt(!done, "status", StatusUtils.BizDone);
148 180
         }
149 181
         queryWrapper.orderByDesc("rec_id");
150
-
182
+    
183
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
184
+        
151 185
         IPage<TaFirstUsherRecord> result = iTaFirstUsherRecordService.page(pg, queryWrapper);
186
+        List<TaFirstUsherRecord> taFirstUsherRecordList = result.getRecords();
187
+        taFirstUsherRecordList.stream().forEach(e -> {
188
+            TaCustomer taCustomer = taCustomerService.getByPhoneOrPlate(e.getPhone(),e.getPlateNumber());
189
+            if (null != taCustomer){
190
+                if (formatter.format(taCustomer.getCreateDate()).equals(formatter.format(LocalDateTime.now()))){
191
+                    e.setNewCustomer(true);
192
+                }else {
193
+                    e.setNewCustomer(false);
194
+                }
195
+            }else {
196
+                e.setNewCustomer(true);
197
+            }
198
+        });
199
+    
200
+        result.setRecords(taFirstUsherRecordList);
152 201
 
153 202
 //            if (onlyNew) {
154 203
 //               iTaFirstUsherRecordService.updateNormal(result.getRecords());

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

@@ -53,6 +53,9 @@ public class TaMainUsherRecordController extends BaseController {
53 53
 
54 54
     @Autowired
55 55
     private ITaPersonService iTaPersonService;
56
+    
57
+    @Autowired
58
+    private ITaCustomerService taCustomerService;
56 59
 
57 60
     @Autowired
58 61
     private ITaCustomerService iTaCustomerService;
@@ -102,7 +105,7 @@ public class TaMainUsherRecordController extends BaseController {
102 105
     public ResponseBean update(@RequestBody TaMainUsherRecord taMainUsherRecord, @PathVariable Integer id){
103 106
         ResponseBean responseBean = new ResponseBean();
104 107
         try {
105
-            iTaMainUsherRecordService.updateByMiniapp(taMainUsherRecord);
108
+            iTaMainUsherRecordService.updateByMiniapp(taMainUsherRecord, null);
106 109
         }catch (Exception e){
107 110
             logger.error("taMainUsherRecordUpdate -=- {}",e.toString());
108 111
             responseBean.addError(e.getMessage());
@@ -152,6 +155,17 @@ public class TaMainUsherRecordController extends BaseController {
152 155
         return ResponseBean.success("");
153 156
     }
154 157
 
158
+    @RequestMapping(value="/miniapp/today/mainUsherRecord",method= RequestMethod.GET)
159
+    public ResponseBean getTodayList() {
160
+        QueryWrapper<TaMainUsherRecord> queryWrapper = new QueryWrapper<>();
161
+        queryWrapper.ge("visite_date", DateUtils.morning());
162
+        queryWrapper.isNotNull("customer_id");
163
+        queryWrapper.orderByDesc("visite_date");
164
+
165
+        List<TaMainUsherRecord> result = iTaMainUsherRecordService.list(queryWrapper);
166
+        return ResponseBean.success(result);
167
+    }
168
+
155 169
     /**
156 170
      * 分页查询
157 171
      */
@@ -171,6 +185,7 @@ public class TaMainUsherRecordController extends BaseController {
171 185
         queryWrapper.ge(today, "visite_date", DateUtils.morning());
172 186
         queryWrapper.gt("rec_id", fromRec);
173 187
         queryWrapper.eq(null != customer && !"".equals(customer), "customer_id", customer);
188
+        queryWrapper.orderByDesc("visite_date");
174 189
 
175 190
         if (onlyNew) {
176 191
             queryWrapper.eq("status", StatusUtils.Ready);
@@ -197,6 +212,16 @@ public class TaMainUsherRecordController extends BaseController {
197 212
                 query.orderByDesc("visite_date");
198 213
                 query.last("limit 1");
199 214
                 rec.setLastRecord(iTaMainUsherRecordService.getOne(query));
215
+                TaCustomer taCustomer = taCustomerService.getByPhoneOrPlate(rec.getPhone(),rec.getPlateNumber());
216
+                if (null != taCustomer){
217
+                    if (DateUtils.sameDay(taCustomer.getCreateDate(), LocalDateTime.now())){
218
+                        rec.setNewCustomer(true);
219
+                    }else {
220
+                        rec.setNewCustomer(false);
221
+                    }
222
+                }else {
223
+                    rec.setNewCustomer(true);
224
+                }
200 225
             }
201 226
 
202 227
 //                if (onlyNew) {

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

@@ -56,16 +56,22 @@ public class TaWechatUserController extends BaseController {
56 56
     private SMSUtils smsUtils;
57 57
 
58 58
     @GetMapping("/login")
59
-    public ResponseBean login(@RequestParam String code) {
60
-        ResponseBean resp = miniApp.getOpenid(code);
61
-        if (resp.getCode() != 200) {
62
-            return resp;
59
+    public ResponseBean login(@RequestParam(value = "code",required = false) String code,@RequestParam(value = "openid",required = false) String openid) {
60
+        String sessionKey = "";
61
+        String unionId = "";
62
+        if (!StringUtils.isEmpty(code)){
63
+            ResponseBean resp = miniApp.getOpenid(code);
64
+            if (resp.getCode() != 200) {
65
+                return resp;
66
+            }
67
+    
68
+            JSONObject data = (JSONObject) resp.getData();
69
+            openid = data.getString("openid");
70
+            logger.info("登录人的openi的是:{}",openid);
71
+            sessionKey = data.getString("session_key");
72
+            unionId = data.getString("unionid");
63 73
         }
64
-
65
-        JSONObject data = (JSONObject) resp.getData();
66
-        String openid = data.getString("openid");
67
-        String sessionKey = data.getString("session_key");
68
-        String unionId = data.getString("unionid");
74
+        
69 75
         String appid = miniApp.getAppid();
70 76
 
71 77
         Map<String, Object> map = new HashMap<>();

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

@@ -27,4 +27,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
27 27
     void fireUser(@Param("userId") Integer userId);
28 28
 	
29 29
 	List<SysUser> selectConsultManagerList(@Param("identityConsultantManager") String identityConsultantManager);
30
+
31
+    String getPhoneByOpenid(@Param("openid") String openid);
30 32
 }

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

@@ -26,7 +26,7 @@ public interface TaCustomerMapper extends BaseMapper<TaCustomer> {
26 26
 
27 27
     List<TaCustomer> getSomeCustMayBe(@Param("plateNumber") String plateNumber, @Param("phone") String phone);
28 28
 
29
-    IPage<TaCustomer> getCustomerListOfFront(IPage<TaCustomer> page,@Param("consultantId") Integer consultantId,@Param("nameOrPhone") String nameOrPhone);
29
+    IPage<TaCustomer> getCustomerListOfFront(IPage<TaCustomer> page,@Param("consultantId") Integer consultantId,@Param("nameOrPhoneOrReceiver") String nameOrPhoneOrReceiver);
30 30
     
31 31
     IPage<TaCustomer> getAttributionList(IPage<TaCustomer> page);
32 32
     

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

@@ -213,4 +213,14 @@ public class TaCustomer implements Serializable {
213 213
      */
214 214
     @TableField(exist = false)
215 215
     private LocalDateTime visiteDate;
216
+    
217
+    /**
218
+     * 车辆图片
219
+     */
220
+    @TableField(exist = false)
221
+    private String carImage;
222
+
223
+    private String customerType;
224
+
225
+    private String receiver;
216 226
 }

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

@@ -61,4 +61,20 @@ public class TaFirstUsherRecord implements Serializable {
61 61
     private String licenseImage;
62 62
 
63 63
     private String phone;
64
+    
65
+    private Integer consultantId;
66
+    
67
+    private String realtyConsultant;
68
+    
69
+    @TableField(exist = false)
70
+    private String customerName;
71
+    
72
+    @TableField(exist = false)
73
+    private String avatar;
74
+    
75
+    @TableField(exist = false)
76
+    private Integer customerId;
77
+    
78
+    @TableField(exist = false)
79
+    private boolean newCustomer;
64 80
 }

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

@@ -76,4 +76,9 @@ public class TaMainUsherRecord implements Serializable {
76 76
 
77 77
     @TableField(exist = false)
78 78
     TaMainUsherRecord lastRecord;
79
+    
80
+    @TableField(exist = false)
81
+    private boolean newCustomer;
82
+
83
+    private String receiver;
79 84
 }

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

@@ -1,6 +1,7 @@
1 1
 package com.huiju.welcome.model;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
5 6
 import lombok.Data;
6 7
 import lombok.EqualsAndHashCode;

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

@@ -2,6 +2,8 @@ package com.huiju.welcome.service;
2 2
 
3 3
 import com.huiju.welcome.model.TaCustomer;
4 4
 import com.huiju.welcome.model.TaDevice;
5
+import com.huiju.welcome.model.TaFirstUsherRecord;
6
+import com.huiju.welcome.model.TaMainUsherRecord;
5 7
 import com.huiju.welcome.model.TaPerson;
6 8
 import com.huiju.welcome.model.TaSnapshotPerson;
7 9
 
@@ -9,8 +11,4 @@ public interface ICameraService {
9 11
     String dispatchPerson(TaPerson taPerson, TaDevice ...devices);
10 12
 
11 13
     boolean newPersonByDevice(TaSnapshotPerson taSnapshotPerson);
12
-    
13
-    void sendMessageToBar(TaCustomer taCustomer,Integer personNum);
14
-    
15
-    void sendMessageToConsultManager(TaCustomer taCustomer);
16 14
 }

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

@@ -45,11 +45,21 @@ public interface ITaCustomerService extends IService<TaCustomer> {
45 45
 
46 46
     TaCustomer getWithLastVisit(Integer id);
47 47
 
48
-    IPage<TaCustomer> getCustomerListOfFront(int pageNumber, int pageSize, Integer consultantId, String nameOrPhone);
49
-
50 48
     List<CustomerExcel> getCustomersEqualCustomerPage(String customerName, String phone, String platNumber, Integer agentUserId);
49
+
50
+    IPage<TaCustomer> getCustomerListOfFront(int pageNumber, int pageSize, Integer consultantId, String nameOrPhoneOrReceiver);
51 51
 	
52 52
 	IPage<TaCustomer> getAttributionList(int pageNumber, int pageSize);
53 53
     
54 54
     IPage<TaCustomer> getUnattributionList(int pageNumber, int pageSize);
55
+    
56
+    void notifyFirstUsherConsultantManager(TaFirstUsherRecord taFirstUsherRecord,TaCustomer taCustomer);
57
+    
58
+    TaCustomer getCutomerByPhoneAndPlatenumber(String phone, String plateNumber);
59
+    
60
+    void sendMessageToBar(TaCustomer taCustomer,Integer personNum);
61
+    
62
+    void sendMessageToConsultManager(TaCustomer taCustomer);
63
+    
64
+    void sendMessageAll(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer, TaMainUsherRecord taMainUsherRecord);
55 65
 }

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

@@ -3,10 +3,10 @@ package com.huiju.welcome.service;
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5 5
 import com.huiju.welcome.model.TaCarRecord;
6
+import com.huiju.welcome.model.TaCustomer;
6 7
 import com.huiju.welcome.model.TaFirstUsherRecord;
7 8
 
8 9
 import java.util.List;
9
-import java.util.Date;
10 10
 
11 11
 /**
12 12
  * <p>
@@ -25,7 +25,7 @@ public interface ITaFirstUsherRecordService extends IService<TaFirstUsherRecord>
25 25
 
26 26
     boolean updateNormal(List<TaFirstUsherRecord> records);
27 27
 
28
-    TaFirstUsherRecord newRecordByDevice(TaCarRecord taCarRecord);
28
+    TaFirstUsherRecord newRecordByDevice(TaCarRecord taCarRecord, TaCustomer taCustomer);
29 29
 
30 30
     void notifyMiniapp(TaFirstUsherRecord taFirstUsherRecord);
31 31
 

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

@@ -38,7 +38,7 @@ public interface ITaMainUsherRecordService extends IService<TaMainUsherRecord> {
38 38
 
39 39
     boolean newRecordByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception;
40 40
 
41
-    boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception;
41
+    boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord, TaCustomer taCustomer) throws Exception;
42 42
 
43 43
     boolean deleteRecord(Integer id);
44 44
 
@@ -51,4 +51,6 @@ public interface ITaMainUsherRecordService extends IService<TaMainUsherRecord> {
51 51
     boolean updateMainUsherRecord(TaMainUsherRecord taMainUsherRecord, Integer customerId, String subject);
52 52
 
53 53
     TaMainUsherRecord newRecordByFirstUsher(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer);
54
+
55
+    TaMainUsherRecord mergeAndDelete(TaMainUsherRecord source, TaMainUsherRecord target);
54 56
 }

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

@@ -12,6 +12,8 @@ import com.huiju.welcome.model.SysUser;
12 12
 import com.huiju.welcome.model.TaCustomer;
13 13
 import com.huiju.welcome.model.TaCustomerMap;
14 14
 import com.huiju.welcome.model.TaDevice;
15
+import com.huiju.welcome.model.TaFirstUsherRecord;
16
+import com.huiju.welcome.model.TaMainUsherRecord;
15 17
 import com.huiju.welcome.model.TaPerson;
16 18
 import com.huiju.welcome.model.TaSnapshotPerson;
17 19
 import com.huiju.welcome.service.*;
@@ -60,9 +62,6 @@ public class CameraServiceImpl implements ICameraService {
60 62
     @Autowired
61 63
     ITaCustomerService iTaCustomerService;
62 64
     
63
-    @Value("${unface.device}")
64
-    private String unfaceDevice;
65
-    
66 65
     @Autowired
67 66
     private TaCustomerMapMapper taCustomerMapMapper;
68 67
     
@@ -199,26 +198,28 @@ public class CameraServiceImpl implements ICameraService {
199 198
         }
200 199
 
201 200
         //二号岗设备推送
202
-        if(taSnapshotPerson.getDeviceId().equals(unfaceDevice)){
201
+        TaDevice taDevice = taDeviceService.getById(taSnapshotPerson.getDeviceId());
202
+        if(!taDevice.getAfr().equals(CommConstant.DEVICE_AFR_UNFACE)){
203 203
             sendMessageToConsult(taPerson);
204
+            
205
+    
206
+            // 预写到访日志
207
+            visitingLogService.newLogByDevice(taSnapshotPerson, taPerson);
208
+    
209
+            // 判断是否客户来访
210
+            try {
211
+                iTaCustomerService.judgeNewCust(taPerson);
212
+            } catch (Exception e) {
213
+                log.error(e.getMessage());
214
+            }
204 215
         }else{
205 216
             // 推送消息
206 217
             taPersonService.send2Front(taPerson);
207 218
         }
208
-
219
+    
209 220
         // 保存抓拍日志
210 221
         taSnapshotPersonService.save(taSnapshotPerson);
211
-
212
-        // 预写到访日志
213
-        visitingLogService.newLogByDevice(taSnapshotPerson, taPerson);
214
-
215
-        // 判断是否客户来访
216
-        try {
217
-            iTaCustomerService.judgeNewCust(taPerson);
218
-        } catch (Exception e) {
219
-            log.error(e.getMessage());
220
-        }
221
-
222
+        
222 223
         return true;
223 224
     }
224 225
     
@@ -234,67 +235,10 @@ public class CameraServiceImpl implements ICameraService {
234 235
                 try {
235 236
                     //推送置业顾问
236 237
                     iTaCustomerService.notifyConsultant(taCustomer);
237
-                    //推送置业经理
238
-                    sendMessageToConsultManager(taCustomer);
239
-                    //推送吧台
240
-                    sendMessageToBar(taCustomer,null);
241
-                } catch (Exception e) {
242
-                    e.printStackTrace();
243
-                }
238
+                } catch (Exception e) {}
239
+                //推送置业经理
240
+                iTaCustomerService.sendMessageToConsultManager(taCustomer);
244 241
             }
245
-        }else {
246
-            //推送人脸到二号岗
247
-            sendMessageToMainusher(taPerson);
248 242
         }
249 243
     }
250
-    
251
-    /**
252
-     * 推送人脸数据到二号岗
253
-     * @param taPerson
254
-     */
255
-    private void sendMessageToMainusher(TaPerson taPerson) {
256
-        try {
257
-            WebSocketServer.sendInfo(JSONObject.toJSONString(taPerson), CommConstant.WECHAT_CLIENT_MAINUSHER, null);
258
-        } catch (Exception e) {}
259
-    }
260
-    
261
-    /**
262
-     * 推送消息去吧台
263
-     * @param taCustomer
264
-     */
265
-    @Override
266
-    public void sendMessageToBar(TaCustomer taCustomer,Integer personNum) {
267
-        Map<String,Object> map = new HashMap<>();
268
-        map.put("customerId",taCustomer.getCustomerId());
269
-        map.put("customerName",taCustomer.getCustomerName());
270
-        map.put("consultantName",taCustomer.getRealtyConsultant());
271
-        map.put("avatar",taCustomer.getAvatar());
272
-        map.put("visitorNum",personNum);
273
-        map.put("visitorTime",LocalDateTime.now());
274
-        map.put("type",CommConstant.IDENTITY_BARUSHER);
275
-        try {
276
-            WebSocketServer.sendInfo(JSONObject.toJSONString(map), CommConstant.WECHAT_CLIENT_MINIAPP, null);
277
-        } catch (Exception e) {}
278
-    }
279
-    
280
-    @Override
281
-    public void sendMessageToConsultManager(TaCustomer taCustomer) {
282
-        //获取所有的置业经理信息并推送消息
283
-        List<SysUser> sysUserList = sysUserMapper.selectConsultManagerList(CommConstant.IDENTITY_CONSULTANT_MANAGER);
284
-        sysUserList.stream().forEach(e -> {
285
-            String tpl = miniApp.getTpls().getVisitor();
286
-            String page = CommConstant.PAGE_MY_CUSTOMER + "?id=" + taCustomer.getCustomerId();
287
-            String openid = e.getOpenid();
288
-            if (null == openid) {
289
-                return;
290
-            }
291
-            List<Object> data = new ArrayList<Object>(){{
292
-                add(taCustomer.getCustomerName());
293
-                add(taCustomer.getPhone());
294
-                add("您有客户来访, 请及时接待!");
295
-            }};
296
-    
297
-            miniApp.sendTPLMessage(tpl, openid, page, data);
298
-        });
299
-    }
300 244
 }

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

@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
17 17
 
18 18
 import java.time.LocalDate;
19 19
 import java.time.LocalDateTime;
20
+import java.time.format.DateTimeFormatter;
20 21
 import java.util.Date;
21 22
 import java.util.List;
22 23
 
@@ -199,7 +200,16 @@ public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCar
199 200
         iTaCarService.newCarByDevice(taCarRecord);
200 201
 
201 202
         // 生成保安迎宾记录, 并通知小程序
202
-        TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.newRecordByDevice(taCarRecord);
203
+        TaFirstUsherRecord taFirstUsherRecord = iTaFirstUsherRecordService.newRecordByDevice(taCarRecord,taCustomer);
204
+        if (null != taCustomer){
205
+            if (DateUtils.sameDay(taCustomer.getCreateDate(),LocalDateTime.now())){
206
+                taFirstUsherRecord.setNewCustomer(true);
207
+            }else {
208
+                taFirstUsherRecord.setNewCustomer(false);
209
+            }
210
+        }else {
211
+            taFirstUsherRecord.setNewCustomer(true);
212
+        }
203 213
         iTaFirstUsherRecordService.notifyCar(taFirstUsherRecord);
204 214
 
205 215
         // 如果客户有固定置业, 推送消息给置业
@@ -210,6 +220,16 @@ public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCar
210 220
                 log.error("发送消息给置业失败: {}", e.getMessage());
211 221
             }
212 222
         }
223
+        
224
+        //自动关联成功
225
+        if (null != taCustomer){
226
+            iTaCustomerService.sendMessageToConsultManager(taCustomer);
227
+            // 发送吧台 - 人数未知就是 0
228
+            iTaCustomerService.sendMessageToBar(taCustomer, 0);
229
+        }
230
+        
231
+        //推送websocket消息。车辆垃圾数据太多,不推送消息
232
+//        iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
213 233
 
214 234
         return true;
215 235
     }

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

@@ -1,23 +1,23 @@
1 1
 package com.huiju.welcome.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5 6
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import com.huiju.welcome.common.WebSocketServer;
8 10
 import com.huiju.welcome.mapper.*;
9 11
 import com.huiju.welcome.model.*;
10 12
 import com.huiju.welcome.service.*;
11
-import com.huiju.welcome.utils.CommConstant;
12
-import com.huiju.welcome.utils.MiniApp;
13
-import com.huiju.welcome.utils.StatusUtils;
14
-import com.huiju.welcome.utils.StringUtils;
13
+import com.huiju.welcome.utils.*;
15 14
 import org.slf4j.Logger;
16 15
 import org.slf4j.LoggerFactory;
17 16
 import org.springframework.beans.factory.annotation.Autowired;
18 17
 import org.springframework.stereotype.Service;
19 18
 
20 19
 import java.time.LocalDateTime;
20
+import java.time.format.DateTimeFormatter;
21 21
 import java.util.ArrayList;
22 22
 import java.util.HashMap;
23 23
 import java.util.List;
@@ -77,6 +77,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
77 77
     @Autowired
78 78
     ICameraService cameraService;
79 79
 
80
+    @Autowired
81
+    SMSUtils smsUtils;
82
+
80 83
     @Override
81 84
     public List<TaPerson> getGroup(Integer customerId) {
82 85
         return taCustomerMapMapper.getGroup(customerId);
@@ -147,7 +150,13 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
147 150
         taCustomer.setCarModel(taCarRecord.getCarModel());
148 151
         taCustomer.setPlateNumber(taCarRecord.getPlateNumber());
149 152
         taCustomer.setConsultantId(consultantId);
150
-
153
+        if (null != consultantId){
154
+            SysUser usr = sysUserMapper.selectById(consultantId);
155
+            if (null != usr){
156
+                taCustomer.setRealtyConsultant(usr.getUsername());
157
+            }
158
+        }
159
+        
151 160
         TaPerson taPerson = iTaPersonService.newPersonByFront(taCustomer);
152 161
         taCustomer.setCustomerId(taPerson.getRealId());
153 162
 
@@ -176,9 +185,69 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
176 185
             add("您有客户来访, 请及时接待!");
177 186
         }};
178 187
 
179
-        miniApp.sendTPLMessage(tpl, openid, page, data);
188
+        if (miniApp.sendTPLMessage(tpl, openid, page, data).getCode() == -1) {
189
+            // 没有 formid 发短信
190
+            String phone = sysUserMapper.getPhoneByOpenid(openid);
191
+            if (null != phone) {
192
+                smsUtils.sendVisitor(phone, null == taCustomer ? "": StringUtils.ifNull(taCustomer.getCustomerName(), ""));
193
+            }
194
+        }
180 195
     }
181
-
196
+    
197
+    /**
198
+     * 推送车辆信息给置业经理
199
+     * @param taFirstUsherRecord
200
+     * @param taCustomer
201
+     * @throws Exception
202
+     */
203
+    @Override
204
+    public void notifyFirstUsherConsultantManager(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer) {
205
+        List<SysUser> sysUserList = sysUserMapper.selectConsultManagerList(CommConstant.IDENTITY_CONSULTANT_MANAGER);
206
+        String message ="";
207
+        if (null != taCustomer){
208
+            if (null == taCustomer.getConsultantId()){
209
+                message = "请安排置业接待。";
210
+            }else{
211
+                SysUser sysUser = sysUserMapper.selectById(taCustomer.getConsultantId());
212
+                message = "置业"+sysUser.getUsername()+"客户,请安排接待";
213
+            }
214
+        }else {
215
+            message = "客户已到达, 请及时关注。";
216
+        }
217
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
218
+        
219
+        String visitData = formatter.format(taFirstUsherRecord.getVisiteDate());
220
+        List<Object> data = new ArrayList<Object>();
221
+        data.add(visitData);
222
+        data.add(taFirstUsherRecord.getPlateNumber()+" "+ taFirstUsherRecord.getColor() + " " + taFirstUsherRecord.getCarModel());
223
+        data.add(message);
224
+        sysUserList.stream().forEach(e -> {
225
+            String tpl = miniApp.getTpls().getFirstUsher();
226
+            String page = CommConstant.PAGE_MY_FIRSTUSHER + "?id=" + taFirstUsherRecord.getRecId();
227
+            String openid = e.getOpenid();
228
+            if (null == openid) {
229
+                return;
230
+            }
231
+//            miniApp.sendTPLMessage(tpl, openid, page, data);
232
+            if (miniApp.sendTPLMessage(tpl, openid, page, data).getCode() == -1) {
233
+                // 没有 formid 发短信
234
+                String phone = sysUserMapper.getPhoneByOpenid(openid);
235
+                if (null != phone) {
236
+                    smsUtils.sendVisitor(phone, null == taCustomer ? "": StringUtils.ifNull(taCustomer.getCustomerName(), ""));
237
+                }
238
+            }
239
+        });
240
+    }
241
+    
242
+    @Override
243
+    public TaCustomer getCutomerByPhoneAndPlatenumber(String phone, String plateNumber) {
244
+        List<TaCustomer> list = taCustomerMapper.getSomeCustMayBe(plateNumber,phone);
245
+        if (list.size() > 0){
246
+            return list.get(0);
247
+        }
248
+        return null;
249
+    }
250
+    
182 251
     @Override
183 252
     public boolean updateConsultant(TaCustomer taCustomer, Integer consultantId) {
184 253
         SysUser usr = sysUserMapper.selectById(consultantId);
@@ -222,8 +291,10 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
222 291
             taMainUsherRecord.setCustomerId(cust.getCustomerId());
223 292
         } else {
224 293
             cust = taCustomerMapper.selectById(custId);
294
+            cust.setReceiver(taMainUsherRecord.getReceiver());
295
+            taCustomerMapper.updateById(cust);
225 296
         }
226
-        
297
+
227 298
         TaCustomerMap taCustomerMap = taCustomerMapMapper.getCustomerOf(personId);
228 299
         if (null == taCustomerMap) {
229 300
             TaCustomerMap custMap = new TaCustomerMap();
@@ -242,10 +313,10 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
242 313
         }
243 314
     
244 315
         if (notify){
245
-            //通知吧台来人了
246
-            cameraService.sendMessageToBar(cust,taMainUsherRecord.getPersonNum());
316
+            //通知前端
317
+            sendMessageAll(null,cust,taMainUsherRecord);
247 318
             //推送置业经理
248
-            cameraService.sendMessageToConsultManager(cust);
319
+            sendMessageToConsultManager(cust);
249 320
         }
250 321
         
251 322
         return cust;
@@ -283,9 +354,13 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
283 354
         }
284 355
         if (notify){
285 356
             //通知吧台来人了
286
-            cameraService.sendMessageToBar(cust,taFirstUsherRecord.getPersonNum());
357
+            sendMessageAll(taFirstUsherRecord,cust,null);
358
+
359
+            //通知吧台人数等信息
360
+            sendMessageToBar(cust,taFirstUsherRecord.getPersonNum());
361
+
287 362
             //推送置业经理
288
-            cameraService.sendMessageToConsultManager(cust);
363
+            sendMessageToConsultManager(cust);
289 364
         }
290 365
         
291 366
         return cust;
@@ -302,6 +377,8 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
302 377
         taCustomer.setPurpose(taFirstUsherRecord.getPurpose());
303 378
         taCustomer.setStatus(StatusUtils.Normal);
304 379
         taCustomer.setCreateDate(LocalDateTime.now());
380
+        taCustomer.setConsultantId(taFirstUsherRecord.getConsultantId());
381
+        taCustomer.setRealtyConsultant(taFirstUsherRecord.getRealtyConsultant());
305 382
     
306 383
         return taCustomer;
307 384
     }
@@ -319,6 +396,8 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
319 396
             result.put("appointment", 1);
320 397
             result.put("name", appointments.get(0).getPersonName());
321 398
             result.put("consultantId", appointments.get(0).getCreateUser());
399
+            SysUser user= sysUserMapper.selectById(appointments.get(0).getCreateUser());
400
+            result.put("consultantName", user.getUsername());
322 401
             result.put("sex", appointments.get(0).getSex());
323 402
             result.put("plateNumber", appointments.get(0).getPlatNumber());
324 403
             result.put("customerId", "");
@@ -450,9 +529,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
450 529
     }
451 530
 
452 531
     @Override
453
-    public IPage<TaCustomer> getCustomerListOfFront(int pageNumber, int pageSize, Integer consultantId, String nameOrPhone) {
532
+    public IPage<TaCustomer> getCustomerListOfFront(int pageNumber, int pageSize, Integer consultantId, String nameOrPhoneOrReceiver) {
454 533
         IPage<TaCustomer> page = new Page<>(pageNumber, pageSize);
455
-        return taCustomerMapper.getCustomerListOfFront(page, consultantId, nameOrPhone);
534
+        return taCustomerMapper.getCustomerListOfFront(page, consultantId, nameOrPhoneOrReceiver);
456 535
     }
457 536
 
458 537
     @Override
@@ -570,6 +649,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
570 649
         taCustomer.setRealtyConsultant(taMainUsherRecord.getRealtyConsultant());
571 650
         taCustomer.setStatus(StatusUtils.Normal);
572 651
         taCustomer.setCreateDate(LocalDateTime.now());
652
+        taCustomer.setReceiver(taMainUsherRecord.getReceiver());
573 653
 
574 654
         return taCustomer;
575 655
     }
@@ -584,5 +664,72 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
584 664
 
585 665
         return taCustomerMapper.insert(taCustomer) > 0;
586 666
     }
667
+    
668
+    
669
+    
670
+    /**
671
+     * 推送消息去吧台
672
+     * @param taCustomer
673
+     */
674
+    @Override
675
+    public void sendMessageToBar(TaCustomer taCustomer,Integer personNum) {
676
+        Map<String,Object> map = new HashMap<>();
677
+        map.put("customerId",taCustomer.getCustomerId());
678
+        map.put("customerName",taCustomer.getCustomerName());
679
+        map.put("consultantName",taCustomer.getRealtyConsultant());
680
+        map.put("avatar",taCustomer.getAvatar());
681
+        map.put("visitorNum",personNum);
682
+        map.put("visitorTime",LocalDateTime.now());
683
+        map.put("type",CommConstant.IDENTITY_BARUSHER);
684
+        try {
685
+            WebSocketServer.sendInfo(JSONObject.toJSONString(map), CommConstant.WECHAT_CLIENT_MINIAPP, null);
686
+        } catch (Exception e) {}
687
+    }
688
+    
689
+    @Override
690
+    public void sendMessageToConsultManager(TaCustomer taCustomer) {
691
+        //获取所有的置业经理信息并推送消息
692
+        List<SysUser> sysUserList = sysUserMapper.selectConsultManagerList(CommConstant.IDENTITY_CONSULTANT_MANAGER);
693
+        sysUserList.stream().forEach(e -> {
694
+            String tpl = miniApp.getTpls().getVisitor();
695
+            String page = CommConstant.PAGE_MY_CUSTOMER + "?id=" + taCustomer.getCustomerId();
696
+            String openid = e.getOpenid();
697
+            if (null == openid) {
698
+                return;
699
+            }
700
+            List<Object> data = new ArrayList<Object>(){{
701
+                add(taCustomer.getCustomerName());
702
+                add(taCustomer.getPhone());
703
+                add("您有客户来访, 请及时接待!");
704
+            }};
705
+            
706
+//            miniApp.sendTPLMessage(tpl, openid, page, data);
707
+            if (miniApp.sendTPLMessage(tpl, openid, page, data).getCode() == -1) {
708
+                // 没有 formid 发短信
709
+                String phone = sysUserMapper.getPhoneByOpenid(openid);
710
+                if (null != phone) {
711
+                    smsUtils.sendVisitor(phone, null == taCustomer ? "": StringUtils.ifNull(taCustomer.getCustomerName(), ""));
712
+                }
713
+            }
714
+        });
715
+    }
716
+    
717
+    @Override
718
+    public void sendMessageAll(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer, TaMainUsherRecord taMainUsherRecord) {
719
+        Map<String,Object> map = new HashMap<>();
720
+        map.put("type",CommConstant.IDENTITY_ALL_USHER);
721
+        if (null != taFirstUsherRecord){
722
+            map.put("taFirstUsherRecord",taFirstUsherRecord);
723
+        }
724
+        if (null != taCustomer){
725
+            map.put("taCustomer",taCustomer);
726
+        }
727
+        if (null != taMainUsherRecord){
728
+            map.put("taMainUsherRecord",taMainUsherRecord);
729
+        }
730
+        try {
731
+            WebSocketServer.sendInfo(JSONObject.toJSONString(map), CommConstant.WECHAT_CLIENT_MINIAPP, null);
732
+        } catch (Exception e) {}
733
+    }
587 734
 
588 735
 }

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

@@ -67,7 +67,7 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
67 67
     }
68 68
 
69 69
     @Override
70
-    public TaFirstUsherRecord newRecordByDevice(TaCarRecord taCarRecord) {
70
+    public TaFirstUsherRecord newRecordByDevice(TaCarRecord taCarRecord, TaCustomer taCustomer) {
71 71
         TaFirstUsherRecord taFirstUsherRecord = new TaFirstUsherRecord();
72 72
         taFirstUsherRecord.setStatus(StatusUtils.Ready);
73 73
         taFirstUsherRecord.setCarImage(taCarRecord.getCarImage());
@@ -80,7 +80,13 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
80 80
         taFirstUsherRecord.setPersonNum(taCarRecord.getPersonNum());
81 81
         taFirstUsherRecord.setDriverImage(taCarRecord.getDriverImage());
82 82
         taFirstUsherRecord.setLicenseImage(taCarRecord.getLicenseImage());
83
-
83
+        if (null != taCustomer){
84
+            taFirstUsherRecord.setConsultantId(taCustomer.getConsultantId());
85
+            taFirstUsherRecord.setRealtyConsultant(taCustomer.getRealtyConsultant());
86
+            taFirstUsherRecord.setPhone(taCustomer.getPhone());
87
+            taFirstUsherRecord.setPersonName(taCustomer.getCustomerName());
88
+        }
89
+        
84 90
         taFirstUsherRecordMapper.insert(taFirstUsherRecord);
85 91
 
86 92
         return taFirstUsherRecord;
@@ -126,7 +132,16 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
126 132
     private boolean updateOtherInfo(TaFirstUsherRecord taFirstUsherRecord) {
127 133
         // 更新车辆信息
128 134
         TaCar taCar = iTaCarService.getById(taFirstUsherRecord.getPlateNumber());
129
-        if (null != taFirstUsherRecord.getCarModel()) {
135
+        if (null == taCar) {
136
+            taCar = new TaCar();
137
+            taCar.setPlateNumber(taFirstUsherRecord.getPlateNumber());
138
+            taCar.setColor(taFirstUsherRecord.getColor());
139
+            taCar.setCarModel(taFirstUsherRecord.getCarModel());
140
+            taCar.setCarImage(taFirstUsherRecord.getCarImage());
141
+            taCar.setStatus(StatusUtils.Normal);
142
+            taCar.setTypeId(CommConstant.TYPE_CAR_NORMAL);
143
+            iTaCarService.save(taCar);
144
+        } else if (null != taFirstUsherRecord.getCarModel()) {
130 145
             taCar.setCarModel(taFirstUsherRecord.getCarModel());
131 146
             taCar.setColor(taFirstUsherRecord.getColor());
132 147
             iTaCarService.updateById(taCar);
@@ -173,6 +188,10 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
173 188
             if (StringUtils.isEmpty(taMainUsherRecord.getPlateNumber())) {
174 189
                 taMainUsherRecord.setPlateNumber(taFirstUsherRecord.getPlateNumber());
175 190
             }
191
+            
192
+            if(null != taMainUsherRecord.getPersonNum()){
193
+                taMainUsherRecord.setPersonNum(taFirstUsherRecord.getPersonNum());
194
+            }
176 195
 
177 196
             iTaMainUsherRecordService.updateById(taMainUsherRecord);
178 197
         }
@@ -212,29 +231,47 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
212 231
 
213 232
     private void notifyConsultant(TaFirstUsherRecord taFirstUsherRecord) {
214 233
         String plateNumber = taFirstUsherRecord.getPlateNumber();
215
-//        String phone = taFirstUsherRecord.getPhone();
216
-
217
-//        TaCustomer taCustomer = iTaCustomerService.getByPhoneOrPlate(phone, plateNumber);
218
-//        if (null != taCustomer) {
219
-//            try {
220
-//                iTaCustomerService.notifyConsultant(taCustomer);
221
-//            } catch (Exception e) {}
222
-//        }
234
+        String phone = taFirstUsherRecord.getPhone();
223 235
 
224
-        // 依据车牌判断是否老客户来访
225
-        if (!StringUtils.isEmpty(plateNumber)) {
226
-            List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(plateNumber);
227
-
228
-            // 一个车牌对应多个客户, 先随机找一条数据
229
-            if (null != taCustomerList && taCustomerList.size() > 0) {
230
-                TaCustomer taCustomer = taCustomerList.get(0);
231
-                try {
236
+        TaCustomer taCustomer = iTaCustomerService.getByPhoneOrPlate(phone, plateNumber);
237
+        if (null != taCustomer) {
238
+            try {
239
+                if (null != taCustomer.getConsultantId()){
232 240
                     iTaCustomerService.notifyConsultant(taCustomer);
233
-                    //通知吧台来人了
234
-                    cameraService.sendMessageToBar(taCustomer,taFirstUsherRecord.getPersonNum());
235
-                } catch (Exception e) {}
236
-            }
241
+                }
242
+                //通知前端
243
+                iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
244
+                //通知置业经理车辆信息
245
+                iTaCustomerService.notifyConsultant(taCustomer);
246
+                // 通知吧台
247
+                iTaCustomerService.sendMessageToBar(taCustomer, taFirstUsherRecord.getPersonNum());
248
+            } catch (Exception e) {}
249
+        }else if(StringUtils.isEmpty(taFirstUsherRecord.getPhone())){
250
+            //有手机号的情况下会新建customer,推送后置
251
+            //通知置业经理车辆信息
252
+            iTaCustomerService.notifyFirstUsherConsultantManager(taFirstUsherRecord,taCustomer);
253
+            //通知前端
254
+            iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
237 255
         }
256
+        
257
+        // 依据车牌判断是否老客户来访
258
+        //if (!StringUtils.isEmpty(plateNumber)) {
259
+        //    List<TaCustomer> taCustomerList = iTaCustomerService.getSomeCustMayBe(plateNumber);
260
+        //
261
+        //    // 一个车牌对应多个客户, 先随机找一条数据
262
+        //    if (null != taCustomerList && taCustomerList.size() > 0) {
263
+        //        TaCustomer taCustomer = taCustomerList.get(0);
264
+        //        try {
265
+        //            if (null != taCustomer.getConsultantId()){
266
+        //                iTaCustomerService.notifyConsultant(taCustomer);
267
+        //            }
268
+        //            //通知吧台来人了
269
+        //            cameraService.sendMessageToBar(taCustomer,taFirstUsherRecord.getPersonNum());
270
+        //            //推送置业经理
271
+        //            cameraService.sendMessageToConsultManager(taCustomer);
272
+        //        } catch (Exception e) {}
273
+        //    }
274
+        //}
238 275
     }
239 276
 
240 277
     @Override

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

@@ -15,6 +15,7 @@ import com.huiju.welcome.model.*;
15 15
 import com.huiju.welcome.common.base.ResponseBean;
16 16
 import com.huiju.welcome.model.TaCustomer;
17 17
 import com.huiju.welcome.model.TaMainUsherRecord;
18
+import com.huiju.welcome.service.ICameraService;
18 19
 import com.huiju.welcome.service.ITaCustomerService;
19 20
 import com.huiju.welcome.service.ITaMainUsherRecordService;
20 21
 import com.huiju.welcome.service.ITaPersonService;
@@ -38,6 +39,7 @@ import java.util.List;
38 39
 @Slf4j
39 40
 @Service
40 41
 public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordMapper, TaMainUsherRecord> implements ITaMainUsherRecordService {
42
+
41 43
     @Autowired
42 44
     private TaMainUsherRecordMapper taMainUsherRecordMapper;
43 45
 
@@ -67,6 +69,12 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
67 69
 
68 70
     @Autowired
69 71
     MiniApp miniApp;
72
+    
73
+    @Autowired
74
+    ICameraService cameraService;
75
+
76
+    @Autowired
77
+    SMSUtils smsUtils;
70 78
 
71 79
     @Override
72 80
     public boolean updateNormal(List<TaMainUsherRecord> records) {
@@ -201,7 +209,14 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
201 209
                 add("您有新客户来访, 请及时接待!");
202 210
             }};
203 211
 
204
-            miniApp.sendTPLMessage(tplId, openid, page, data);
212
+//            miniApp.sendTPLMessage(tplId, openid, page, data);
213
+            if (miniApp.sendTPLMessage(tplId, openid, page, data).getCode() == -1) {
214
+                // 没有 formid 发短信
215
+                String tel = sysUserMapper.getPhoneByOpenid(openid);
216
+                if (null != tel) {
217
+                    smsUtils.sendVisitor(tel, StringUtils.ifNull(visitorName, ""));
218
+                }
219
+            }
205 220
         } else {
206 221
             // 否则, 给原置业发消息, 给接待置业发消息
207 222
 
@@ -217,9 +232,14 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
217 232
                 add(phone);
218 233
                 add("您有新客户来访, 已被安排给 " + usr1.getUsername() + " 接待!");
219 234
             }};
220
-            miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
221
-
222
-
235
+//            miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
236
+            if (miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1).getCode() == -1) {
237
+                // 没有 formid 发短信
238
+                String tel = sysUserMapper.getPhoneByOpenid(rcOpenid);
239
+                if (null != tel) {
240
+                    smsUtils.sendVisitor(tel, StringUtils.ifNull(visitorName, ""));
241
+                }
242
+            }
223 243
 
224 244
             // 代理置业
225 245
             SysUser usr2 = sysUserMapper.selectById(realConsultant);
@@ -228,7 +248,14 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
228 248
                 add(phone);
229 249
                 add(usr2.getUsername() + " 有新客户来访, 请协助接待一下!");
230 250
             }};
231
-            miniApp.sendTPLMessage(tplId, openid, page, dt2);
251
+//            miniApp.sendTPLMessage(tplId, openid, page, dt2);
252
+            if (miniApp.sendTPLMessage(tplId, openid, page, dt2).getCode() == -1) {
253
+                // 没有 formid 发短信
254
+                String tel = sysUserMapper.getPhoneByOpenid(openid);
255
+                if (null != tel) {
256
+                    smsUtils.sendVisitor(tel, StringUtils.ifNull(visitorName, ""));
257
+                }
258
+            }
232 259
         }
233 260
     }
234 261
 
@@ -243,97 +270,98 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
243 270
 
244 271
     @Override
245 272
     public boolean newRecordByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception {
246
-        Integer consultantId = taMainUsherRecord.getConsultantId();
247
-        if (null == consultantId || consultantId < 1) {
248
-            throw new Exception("置业顾问不能为空");
249
-        }
273
+//        Integer consultantId = taMainUsherRecord.getConsultantId();
274
+        //if (null == consultantId || consultantId < 1) {
275
+        //    throw new Exception("置业顾问不能为空");
276
+        //}
250 277
 
251 278
         if (StringUtils.isEmpty(taMainUsherRecord.getPhone())) {
252 279
             throw new Exception("客户电话不能为空");
253 280
         }
254 281
 
282
+        TaCustomer taCustomer = getOrNewCustomerBy(taMainUsherRecord);
255 283
         taMainUsherRecord.setStatus(StatusUtils.Normal);
284
+        taMainUsherRecord.setVisiteDate(LocalDateTime.now());
285
+        taMainUsherRecord.setCustomerId(taCustomer.getCustomerId());
256 286
 
257
-        // 新增客户
258
-        iTaCustomerService.newCustByMainUsher(taMainUsherRecord, true);
287
+        TaMainUsherRecord taMainUsherRecordToday = getTodayRecord(taCustomer.getCustomerId());
259 288
 
260
-        return taMainUsherRecordMapper.insert(taMainUsherRecord) > 0;
261
-    }
289
+        if (null == taMainUsherRecordToday) {
290
+            int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
291
+            if (row < 1) {
292
+                log.error("新增跟进记录失败");
293
+                return false;
294
+            }
295
+            return updateByMiniapp(taMainUsherRecord, taCustomer);
296
+        }else {
297
+//            taMainUsherRecordToday = newRecordByCust(taCustomer, sysUserMapper.selectById(taCustomer.getConsultantId()));
298
+            if (!StringUtils.isEmpty(taMainUsherRecord.getPhone())){
299
+                taMainUsherRecordToday.setPhone(taMainUsherRecord.getPhone());
300
+            }
262 301
 
263
-    @Override
264
-    public boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception {
265
-        Integer consultantId = taMainUsherRecord.getConsultantId();
266
-        if (null == consultantId || consultantId < 1) {
267
-            throw new Exception("置业顾问不能为空");
302
+            if (!StringUtils.isEmpty(taMainUsherRecord.getPersonName())){
303
+                taMainUsherRecordToday.setPersonName(taMainUsherRecord.getPersonName());
304
+            }
305
+            if (!StringUtils.isEmpty(taMainUsherRecord.getPurpose())){
306
+                taMainUsherRecordToday.setPurpose(taMainUsherRecord.getPurpose());
307
+            }
308
+            if (!taMainUsherRecord.getAppointment()){
309
+                taMainUsherRecordToday.setAppointment(taMainUsherRecord.getAppointment());
310
+                taMainUsherRecordToday.setAppointmentId(taMainUsherRecord.getAppointmentId());
311
+            }
312
+            if (null != taMainUsherRecord.getPersonNum()){
313
+                taMainUsherRecordToday.setPersonNum(taMainUsherRecord.getPersonNum());
314
+            }
315
+            if (!StringUtils.isEmpty(taMainUsherRecord.getCarModel())){
316
+                taMainUsherRecordToday.setCarModel(taMainUsherRecord.getCarModel());
317
+            }
318
+            if (!StringUtils.isEmpty(taMainUsherRecord.getPlateNumber())){
319
+                taMainUsherRecordToday.setPlateNumber(taMainUsherRecord.getPlateNumber());
320
+            }
321
+            if (!StringUtils.isEmpty(taMainUsherRecord.getColor())){
322
+                taMainUsherRecordToday.setColor(taMainUsherRecord.getColor());
323
+            }
324
+            if (!StringUtils.isEmpty(taMainUsherRecord.getAvatar())){
325
+                taMainUsherRecordToday.setAvatar(taMainUsherRecord.getAvatar());
326
+            }
327
+
328
+            // todo 可能有问题
329
+            taMainUsherRecordToday.setReceiver(taMainUsherRecord.getReceiver());
330
+
331
+            return updateByMiniapp(taMainUsherRecordToday, taCustomer);
268 332
         }
333
+    }
269 334
 
335
+    @Override
336
+    public boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord, TaCustomer taCustomer) throws Exception {
270 337
         if (StringUtils.isEmpty(taMainUsherRecord.getPhone())) {
271 338
             throw new Exception("客户电话不能为空");
272 339
         }
273 340
 
274
-        taMainUsherRecord.setStatus(StatusUtils.Normal);
275
-
276
-        // 是否更新了置业
277
-        TaCustomer taCustomer = null;
278
-        if (null != taMainUsherRecord.getCustomerId()) {
279
-            taCustomer = iTaCustomerService.getById(taMainUsherRecord.getCustomerId());
280
-        } else if (null != taMainUsherRecord.getPhone() || null != taMainUsherRecord.getPlateNumber()) {
281
-            // 尝试使用手机号去查找
282
-            taCustomer = iTaCustomerService.getByPhoneOrPlate(taMainUsherRecord.getPhone(), taMainUsherRecord.getPlateNumber());
283
-        } else if (null != taMainUsherRecord.getAvatar()) {
284
-            // 依据人脸查询
285
-            JSONObject result = aliFaceUtils.searchFace(taMainUsherRecord.getAvatar());
286
-            if (null != result) {
287
-                Integer personId = Integer.valueOf(result.getString("personId"));
288
-                taCustomer = iTaCustomerService.getSameByPerson(personId);
289
-            }
341
+        if (null == taCustomer) {
342
+            taCustomer = getOrNewCustomerBy(taMainUsherRecord);
290 343
         }
291 344
 
292
-        if (null == taCustomer && null == taMainUsherRecord.getCustomerId()) {
293
-            taCustomer = iTaCustomerService.newCustByMainUsher(taMainUsherRecord, false);
345
+        taMainUsherRecord.setStatus(StatusUtils.Normal);
346
+        taMainUsherRecord.setVisiteDate(LocalDateTime.now());
347
+        taMainUsherRecord.setCustomerId(taCustomer.getCustomerId());
348
+        int row = 0;
349
+        if (null == taMainUsherRecord.getRecId()) {
350
+            row = taMainUsherRecordMapper.insert(taMainUsherRecord);
351
+        } else {
352
+            row = taMainUsherRecordMapper.updateById(taMainUsherRecord);
294 353
         }
295 354
 
355
+        Integer consultantId = taMainUsherRecord.getConsultantId();
296 356
         Integer originConsultant = taCustomer.getConsultantId();
297 357
 
298
-        // 是否需要更新客户信息
299
-        // 只更新空内容
300
-        if (StringUtils.isEmpty(taCustomer.getCustomerName()) || StringUtils.isEmpty(taCustomer.getPhone())) {
301
-            if (StringUtils.isEmpty(taCustomer.getCustomerName())) {
302
-                taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
303
-            }
304
-
305
-            if (StringUtils.isEmpty(taCustomer.getPhone())) {
306
-                taCustomer.setPhone(taMainUsherRecord.getPhone());
307
-            }
308
-
309
-            if (null == taCustomer.getSex()) {
310
-                taCustomer.setSex(taMainUsherRecord.getSex());
311
-            }
312
-
313
-            if (StringUtils.isEmpty(taCustomer.getAvatar())) {
314
-                taCustomer.setAvatar(taMainUsherRecord.getAvatar());
315
-            }
316
-
317
-            if (StringUtils.isEmpty(taCustomer.getPlateNumber())) {
318
-                taCustomer.setPlateNumber(taMainUsherRecord.getPlateNumber());
319
-            }
320
-
321
-            if (StringUtils.isEmpty(taCustomer.getCarModel())) {
322
-                taCustomer.setCarModel(taMainUsherRecord.getCarModel());
323
-            }
324
-
325
-            iTaCustomerService.updateById(taCustomer);
326
-        }
327
-
328
-        int row = taMainUsherRecordMapper.updateById(taMainUsherRecord);
329
-
330 358
         // 更新人员信息
331 359
         iTaPersonService.updateByMainUsher(taMainUsherRecord);
332 360
 
333 361
         // 如果原来置业为空
334 362
         if (null == originConsultant || originConsultant < 1) {
335 363
             iTaCustomerService.updateConsultant(taCustomer, consultantId);
336
-        } else if (!consultantId.equals(originConsultant)) {
364
+        } else if (null != consultantId && !consultantId.equals(originConsultant)) {
337 365
             // 如果临时替换跟踪置业
338 366
             // 那么需要给原始置业, 以及临时置业各自发一条消息
339 367
             String page = CommConstant.PAGE_MY_CUSTOMER + "?id=" + String.valueOf(taCustomer.getCustomerId());
@@ -359,7 +387,13 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
359 387
             dt1.add(taCustomer.getPhone());
360 388
             dt1.add("您有新客户来访, 已被安排给 " + proxyUser.getUsername() + " 接待!");
361 389
 
362
-            miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
390
+//            miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
391
+            if (miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1).getCode() == -1) {                // 没有 formid 发短信
392
+                String phone = sysUserMapper.getPhoneByOpenid(rcOpenid);
393
+                if (null != phone) {
394
+                    smsUtils.sendVisitor(phone, StringUtils.ifNull(taCustomer.getCustomerName(), ""));
395
+                }
396
+            }
363 397
 
364 398
             // 通知临时置业
365 399
             List<Object> dt2 = new ArrayList<Object>();
@@ -367,12 +401,83 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
367 401
             dt2.add(taCustomer.getPhone());
368 402
             dt2.add(rcUser.getUsername() + " 有新客户来访, 请协助接待一下!");
369 403
 
370
-            miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2);
404
+//            miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2);
405
+            if (miniApp.sendTPLMessage(tplId, proxyOpenid, page, dt2).getCode() == -1) {                // 没有 formid 发短信
406
+                String phone = sysUserMapper.getPhoneByOpenid(proxyOpenid);
407
+                if (null != phone) {
408
+                    smsUtils.sendVisitor(phone, StringUtils.ifNull(taCustomer.getCustomerName(), ""));
409
+                }
410
+            }
371 411
         }
372
-
412
+    
413
+        //通知前端
414
+        iTaCustomerService.sendMessageAll(null,taCustomer,taMainUsherRecord);
415
+        //推送置业经理
416
+        iTaCustomerService.sendMessageToConsultManager(taCustomer);
417
+        //推送吧台
418
+        iTaCustomerService.sendMessageToBar(taCustomer,taMainUsherRecord.getPersonNum());
373 419
         return row > 0;
374 420
     }
375 421
 
422
+    private TaCustomer getOrNewCustomerBy(TaMainUsherRecord taMainUsherRecord) throws Exception {
423
+        // 是否更新了置业
424
+        TaCustomer taCustomer = null;
425
+        if (null != taMainUsherRecord.getCustomerId()) {
426
+            taCustomer = iTaCustomerService.getById(taMainUsherRecord.getCustomerId());
427
+        } else if (null != taMainUsherRecord.getPhone() || null != taMainUsherRecord.getPlateNumber()) {
428
+            // 尝试使用手机号去查找
429
+            taCustomer = iTaCustomerService.getByPhoneOrPlate(taMainUsherRecord.getPhone(), taMainUsherRecord.getPlateNumber());
430
+        } else if (null != taMainUsherRecord.getPersonId()) {
431
+            // 依据人员ID 查询
432
+            TaPerson taPerson = iTaPersonService.getById(taMainUsherRecord.getPersonId());
433
+            taCustomer = taCustomerMapper.getCustomerOf(taPerson.getPersonId(), taPerson.getRealId());
434
+        }
435
+
436
+        if (null != taMainUsherRecord.getAvatar() && null == taCustomer) {
437
+            // 依据人脸查询
438
+            JSONObject result = aliFaceUtils.searchFace(taMainUsherRecord.getAvatar());
439
+            if (null != result) {
440
+                Integer personId = Integer.valueOf(result.getString("personId"));
441
+                taCustomer = iTaCustomerService.getSameByPerson(personId);
442
+            }
443
+        }
444
+
445
+        if (null == taCustomer) {
446
+            taCustomer = iTaCustomerService.newCustByMainUsher(taMainUsherRecord, true);
447
+        } else {
448
+            // 是否需要更新客户信息
449
+            // 只更新空内容
450
+            taCustomer.setReceiver(taMainUsherRecord.getReceiver());
451
+            if (StringUtils.isEmpty(taCustomer.getCustomerName())) {
452
+                taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
453
+            }
454
+
455
+            if (StringUtils.isEmpty(taCustomer.getPhone())) {
456
+                taCustomer.setPhone(taMainUsherRecord.getPhone());
457
+            }
458
+
459
+            if (null == taCustomer.getSex()) {
460
+                taCustomer.setSex(taMainUsherRecord.getSex());
461
+            }
462
+
463
+            if (StringUtils.isEmpty(taCustomer.getAvatar())) {
464
+                taCustomer.setAvatar(taMainUsherRecord.getAvatar());
465
+            }
466
+
467
+            if (StringUtils.isEmpty(taCustomer.getPlateNumber())) {
468
+                taCustomer.setPlateNumber(taMainUsherRecord.getPlateNumber());
469
+            }
470
+
471
+            if (StringUtils.isEmpty(taCustomer.getCarModel())) {
472
+                taCustomer.setCarModel(taMainUsherRecord.getCarModel());
473
+            }
474
+
475
+            iTaCustomerService.updateById(taCustomer);
476
+        }
477
+
478
+        return taCustomer;
479
+    }
480
+
376 481
     @Override
377 482
     public boolean deleteRecord(Integer id) {
378 483
         UpdateWrapper<TaMainUsherRecord> updateWrapper = new UpdateWrapper<>();
@@ -395,6 +500,15 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
395 500
         taMainUsherRecord.setStatus(StatusUtils.Ready);
396 501
         taMainUsherRecord.setPersonId(taPerson.getRealId());
397 502
         int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
503
+        if (null != taCustomer){
504
+            if (DateUtils.sameDay(taCustomer.getCreateDate(),LocalDateTime.now())){
505
+                taMainUsherRecord.setNewCustomer(true);
506
+            }else {
507
+                taMainUsherRecord.setNewCustomer(false);
508
+            }
509
+        }else {
510
+            taMainUsherRecord.setNewCustomer(true);
511
+        }
398 512
 
399 513
         try {
400 514
             Action act = Action.create(Action.TYPE_NEW_MAIN_USHER, JSONObject.toJSONString(taMainUsherRecord, SerializerFeature.WriteMapNullValue));
@@ -512,6 +626,7 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
512 626
         taMainUsherRecord.setChannel(taFirstUsherRecord.getChannel());
513 627
         taMainUsherRecord.setPurpose(taFirstUsherRecord.getPurpose());
514 628
         taMainUsherRecord.setCarImage(taFirstUsherRecord.getCarImage());
629
+        taMainUsherRecord.setPersonNum(taFirstUsherRecord.getPersonNum());
515 630
 
516 631
         if (null != taCustomer) {
517 632
             taMainUsherRecord.setPersonId(taCustomer.getCustomerId());
@@ -527,6 +642,28 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
527 642
         return taMainUsherRecord;
528 643
     }
529 644
 
645
+    /**
646
+     * 合并 source 到 target, 并且删除 source
647
+     * @param source
648
+     * @param target
649
+     * @return
650
+     */
651
+    @Override
652
+    public TaMainUsherRecord mergeAndDelete(TaMainUsherRecord source, TaMainUsherRecord target) {
653
+        if (null == source) return target;
654
+        if (null == target) return source;
655
+
656
+        // 合并为空的字段
657
+        target.setPersonId(ifIntNvl(target.getPersonId(), source.getPersonId()));
658
+        target.setPersonName(StringUtils.ifNull(target.getPersonName(), source.getPersonName()));
659
+
660
+        return null;
661
+    }
662
+
663
+    private Integer ifIntNvl(Integer a, Integer b) {
664
+        return null == a ? b : a;
665
+    }
666
+
530 667
     private TaMainUsherRecord newRecordByPerson(TaPerson taPerson) {
531 668
         TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
532 669
         taMainUsherRecord.setPersonName(taPerson.getName());

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

@@ -6,8 +6,10 @@ 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
     public final static String IDENTITY_CONSULTANT_MANAGER = "consultant_manager";
9
+    public final static String IDENTITY_ALL_USHER = "all-usher";
9 10
 
10 11
     public final static String PAGE_MY_CUSTOMER = "pages/client/clientdetail/clientdetail";
12
+    public final static String PAGE_MY_FIRSTUSHER = "pages/client/visitorDetail/visitorDetail";
11 13
 
12 14
     public final static String WECHAT_CLIENT_MINIAPP = "miniapp";
13 15
     public final static String WECHAT_CLIENT_CAR = "car";
@@ -17,6 +19,8 @@ public class CommConstant {
17 19
     public final static Integer TYPE_NEW_PERSON = 1;
18 20
     public final static Integer TYPE_VIP_PERSON = 2;
19 21
     public final static Integer TYPE_INNER_PERSON = 3;
22
+    
23
+    public final static String DEVICE_AFR_UNFACE = "0";
20 24
 
21 25
     public final static String TYPE_CAR_NORMAL = "normal";
22 26
     public final static String TYPE_CAR_INNER = "inner";

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

@@ -65,7 +65,8 @@ public class MiniApp {
65 65
 
66 66
         String formId = iTaMiniFormidsService.getFormidBy(toUser, true);
67 67
         if (null == formId) {
68
-            return ResponseBean.error("发送模板消息失败, 没有可用的 formid ", HttpStatus.SC_INTERNAL_SERVER_ERROR);
68
+            return ResponseBean.error("没有可用的 formid", -1);
69
+//            return ResponseBean.error("发送模板消息失败, 没有可用的 formid ", HttpStatus.SC_INTERNAL_SERVER_ERROR);
69 70
         }
70 71
 
71 72
         String api = String.format("/api/%s/tpl/%s/form/%s/to/%s", appid, tplId, formId, toUser);
@@ -101,5 +102,7 @@ public class MiniApp {
101 102
     @Data
102 103
     public static class Tpl {
103 104
         private String visitor;
105
+        
106
+        private String firstUsher;
104 107
     }
105 108
 }

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

@@ -79,6 +79,13 @@ public class SMSUtils {
79 79
         return true;
80 80
     }
81 81
 
82
+    public boolean sendVisitor(String tel, String name) {
83
+        log.info("发送手机 {} 客户名称 {}", tel, name);
84
+
85
+        String[] params = { name };
86
+        return sendMessage(smsProperties.getVisitor().getCode(), tel, params);
87
+    }
88
+
82 89
     private String genCaptcha(int length) {
83 90
         List<String> nums = new ArrayList<>();
84 91
         for (int i = 0; i < length; i ++) {

+ 3
- 3
src/main/resources/application.yml Прегледај датотеку

@@ -50,6 +50,7 @@ miniapp:
50 50
   secret: 03fcb0228ada1dd27ba45fb5a64c6f52
51 51
   tpls:
52 52
     visitor: m5fR2X1D-iWUurRe-pQQU8VgcxSSZ5eAVoquMixphFw
53
+    firstUsher: DlpqippBqmqkWWLDxsxB7iIbhlD7px4TCnP2KcK7DY8
53 54
 
54 55
 # ali-cloud
55 56
 ali:
@@ -96,6 +97,5 @@ sms:
96 97
     # 短信签名
97 98
     sign: AI智慧案场
98 99
 
99
-# 二号岗设备不具备人脸比对功能
100
-unface:
101
-  device: 216
100
+  visitor:
101
+    code: "0501"

+ 11
- 0
src/main/resources/mapper/SysUserMapper.xml Прегледај датотеку

@@ -32,4 +32,15 @@
32 32
             AND s.user_identity = #{identityConsultantManager}
33 33
             AND s.STATUS = 1
34 34
     </select>
35
+
36
+    <select id="getPhoneByOpenid" resultType="String">
37
+      SELECT
38
+        t.phone
39
+      FROM
40
+        sys_user t
41
+        JOIN ta_wechat_user s ON s.person_id = t.user_id
42
+      WHERE
43
+        s.openid = #{openid}
44
+        LIMIT 1
45
+    </select>
35 46
 </mapper>

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

@@ -83,18 +83,29 @@
83 83
 
84 84
     <select id="getCustomerListOfFront" resultType="com.huiju.welcome.model.TaCustomer">
85 85
         SELECT
86
-            *
86
+            t.*,
87
+            s.visite_date
87 88
         FROM
88 89
             ta_customer t
90
+        LEFT JOIN (
91
+            SELECT
92
+                a.customer_id,
93
+                max( b.visite_date ) as visite_date
94
+            FROM
95
+              ta_customer a
96
+            LEFT JOIN ta_main_usher_record b USING ( customer_id )
97
+            GROUP BY
98
+              a.customer_id
99
+            ) s USING ( customer_id )
89 100
         WHERE t.status &gt; 0
90 101
             <if test="consultantId !=null">
91 102
               AND t.consultant_id = #{consultantId}
92 103
             </if>
93
-            <if test="nameOrPhone !=null and nameOrPhone != ''">
94
-              AND ( t.customer_name LIKE CONCAT('%',#{nameOrPhone},'%') OR t.phone LIKE CONCAT('%',#{nameOrPhone},'%') )
104
+            <if test="nameOrPhoneOrReceiver !=null and nameOrPhoneOrReceiver != ''">
105
+              AND ( t.customer_name LIKE CONCAT('%',#{nameOrPhoneOrReceiver},'%') OR t.phone LIKE CONCAT('%',#{nameOrPhoneOrReceiver},'%') OR t.receiver LIKE CONCAT('%',#{nameOrPhoneOrReceiver},'%'))
95 106
             </if>
96 107
         ORDER BY
97
-            t.create_date DESC
108
+          IFNULL( s.visite_date, t.create_date ) DESC
98 109
     </select>
99 110
 
100 111
     <select id="getAttributionList" resultType="com.huiju.welcome.model.TaCustomer">

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

@@ -49,12 +49,14 @@
49 49
 
50 50
     <select id="getTodayAppointmentList" resultType="com.huiju.welcome.model.TaVisitorAppointment">
51 51
         SELECT
52
-            *
52
+            t.*,
53
+            s.username
53 54
         FROM
54 55
             ta_visitor_appointment t
56
+            LEFT JOIN sys_user s ON t.create_user = s.user_id
55 57
         WHERE
56 58
             t.STATUS > 0
57
-            AND ( DATE_FORMAT( visit_date, '%Y-%m-%d' ) = DATE_FORMAT( now( ), '%Y-%m-%d' ) OR visit_date IS NULL )
59
+            AND ( DATE_FORMAT( t.visit_date, '%Y-%m-%d' ) = DATE_FORMAT( now( ), '%Y-%m-%d' ) OR t.visit_date IS NULL )
58 60
         ORDER BY
59 61
             t.create_date DESC
60 62
     </select>