Your Name 5 лет назад
Родитель
Сommit
ec549602cc
22 измененных файлов: 518 добавлений и 370 удалений
  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. 2
    2
      src/main/java/com.huiju.welcome/controller/TaCustomerController.java
  5. 1
    0
      src/main/java/com.huiju.welcome/controller/TaFirstUsherRecordController.java
  6. 13
    1
      src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java
  7. 2
    0
      src/main/java/com.huiju.welcome/mapper/SysUserMapper.java
  8. 1
    1
      src/main/java/com.huiju.welcome/mapper/TaCustomerMapper.java
  9. 4
    0
      src/main/java/com.huiju.welcome/model/TaCustomer.java
  10. 2
    0
      src/main/java/com.huiju.welcome/model/TaMainUsherRecord.java
  11. 1
    1
      src/main/java/com.huiju.welcome/service/ITaCustomerService.java
  12. 3
    1
      src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java
  13. 1
    1
      src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java
  14. 4
    2
      src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java
  15. 35
    12
      src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java
  16. 12
    1
      src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java
  17. 182
    133
      src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java
  18. 2
    1
      src/main/java/com.huiju.welcome/utils/MiniApp.java
  19. 7
    0
      src/main/java/com.huiju.welcome/utils/SMSUtils.java
  20. 10
    7
      src/main/resources/application.yml
  21. 11
    0
      src/main/resources/mapper/SysUserMapper.xml
  22. 15
    4
      src/main/resources/mapper/TaCustomerMapper.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
+}

+ 2
- 2
src/main/java/com.huiju.welcome/controller/TaCustomerController.java Просмотреть файл

@@ -293,7 +293,7 @@ public class TaCustomerController extends BaseController {
293 293
         @RequestParam(defaultValue = "1") int pageNumber,
294 294
         @RequestParam(defaultValue = "10") int pageSize,
295 295
         @RequestParam(defaultValue = "false") boolean mine,
296
-        @RequestParam(defaultValue = "") String nameOrPhone,
296
+        @RequestParam(defaultValue = "", name = "nameOrPhone") String nameOrPhoneOrReceiver,
297 297
         @RequestParam(defaultValue = "" ) Integer consultant,
298 298
         HttpServletRequest request
299 299
     ){
@@ -308,7 +308,7 @@ public class TaCustomerController extends BaseController {
308 308
                 consultantId = consultant;
309 309
             }
310 310
 
311
-            IPage<TaCustomer> result = iTaCustomerService.getCustomerListOfFront(pageNumber, pageSize, consultantId, nameOrPhone);
311
+            IPage<TaCustomer> result = iTaCustomerService.getCustomerListOfFront(pageNumber, pageSize, consultantId, nameOrPhoneOrReceiver);
312 312
             List<TaCustomer> custs = result.getRecords();
313 313
 
314 314
             if (null != custs && custs.size() > 0) {

+ 1
- 0
src/main/java/com.huiju.welcome/controller/TaFirstUsherRecordController.java Просмотреть файл

@@ -59,6 +59,7 @@ public class TaFirstUsherRecordController extends BaseController {
59 59
                 responseBean.addError("fail");
60 60
             }
61 61
         }catch (Exception e){
62
+            e.printStackTrace();
62 63
             logger.error("taFirstUsherRecordAdd -=- {}",e.toString());
63 64
             responseBean.addError(e.getMessage());
64 65
         }

+ 13
- 1
src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java Просмотреть файл

@@ -98,7 +98,7 @@ public class TaMainUsherRecordController extends BaseController {
98 98
     public ResponseBean update(@RequestBody TaMainUsherRecord taMainUsherRecord, @PathVariable Integer id){
99 99
         ResponseBean responseBean = new ResponseBean();
100 100
         try {
101
-            iTaMainUsherRecordService.updateByMiniapp(taMainUsherRecord);
101
+            iTaMainUsherRecordService.updateByMiniapp(taMainUsherRecord, null);
102 102
         }catch (Exception e){
103 103
             logger.error("taMainUsherRecordUpdate -=- {}",e.toString());
104 104
             responseBean.addError(e.getMessage());
@@ -148,6 +148,17 @@ public class TaMainUsherRecordController extends BaseController {
148 148
         return ResponseBean.success("");
149 149
     }
150 150
 
151
+    @RequestMapping(value="/miniapp/today/mainUsherRecord",method= RequestMethod.GET)
152
+    public ResponseBean getTodayList() {
153
+        QueryWrapper<TaMainUsherRecord> queryWrapper = new QueryWrapper<>();
154
+        queryWrapper.ge("visite_date", DateUtils.morning());
155
+        queryWrapper.isNotNull("customer_id");
156
+        queryWrapper.orderByDesc("visite_date");
157
+
158
+        List<TaMainUsherRecord> result = iTaMainUsherRecordService.list(queryWrapper);
159
+        return ResponseBean.success(result);
160
+    }
161
+
151 162
     /**
152 163
      * 分页查询
153 164
      */
@@ -167,6 +178,7 @@ public class TaMainUsherRecordController extends BaseController {
167 178
         queryWrapper.ge(today, "visite_date", DateUtils.morning());
168 179
         queryWrapper.gt("rec_id", fromRec);
169 180
         queryWrapper.eq(null != customer && !"".equals(customer), "customer_id", customer);
181
+        queryWrapper.orderByDesc("visite_date");
170 182
 
171 183
         if (onlyNew) {
172 184
             queryWrapper.eq("status", StatusUtils.Ready);

+ 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 Просмотреть файл

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

+ 4
- 0
src/main/java/com.huiju.welcome/model/TaCustomer.java Просмотреть файл

@@ -219,4 +219,8 @@ public class TaCustomer implements Serializable {
219 219
      */
220 220
     @TableField(exist = false)
221 221
     private String carImage;
222
+
223
+    private String customerType;
224
+
225
+    private String receiver;
222 226
 }

+ 2
- 0
src/main/java/com.huiju.welcome/model/TaMainUsherRecord.java Просмотреть файл

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

+ 1
- 1
src/main/java/com.huiju.welcome/service/ITaCustomerService.java Просмотреть файл

@@ -45,7 +45,7 @@ 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);
48
+    IPage<TaCustomer> getCustomerListOfFront(int pageNumber, int pageSize, Integer consultantId, String nameOrPhoneOrReceiver);
49 49
 	
50 50
 	IPage<TaCustomer> getAttributionList(int pageNumber, int pageSize);
51 51
     

+ 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
 }

+ 1
- 1
src/main/java/com.huiju.welcome/service/impl/CameraServiceImpl.java Просмотреть файл

@@ -199,7 +199,7 @@ public class CameraServiceImpl implements ICameraService {
199 199
 
200 200
         //二号岗设备推送
201 201
         TaDevice taDevice = taDeviceService.getById(taSnapshotPerson.getDeviceId());
202
-        if(taDevice.getAfr().equals(CommConstant.DEVICE_AFR_UNFACE)){
202
+        if(!taDevice.getAfr().equals(CommConstant.DEVICE_AFR_UNFACE)){
203 203
             sendMessageToConsult(taPerson);
204 204
             
205 205
     

+ 4
- 2
src/main/java/com.huiju.welcome/service/impl/TaCarRecordServiceImpl.java Просмотреть файл

@@ -224,10 +224,12 @@ public class TaCarRecordServiceImpl extends ServiceImpl<TaCarRecordMapper, TaCar
224 224
         //自动关联成功
225 225
         if (null != taCustomer){
226 226
             iTaCustomerService.sendMessageToConsultManager(taCustomer);
227
+            // 发送吧台 - 人数未知就是 0
228
+            iTaCustomerService.sendMessageToBar(taCustomer, 0);
227 229
         }
228 230
         
229
-        //推送websocket消息。统一推送。
230
-        iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
231
+        //推送websocket消息。车辆垃圾数据太多,不推送消息
232
+//        iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
231 233
 
232 234
         return true;
233 235
     }

+ 35
- 12
src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java Просмотреть файл

@@ -10,10 +10,7 @@ import com.huiju.welcome.common.WebSocketServer;
10 10
 import com.huiju.welcome.mapper.*;
11 11
 import com.huiju.welcome.model.*;
12 12
 import com.huiju.welcome.service.*;
13
-import com.huiju.welcome.utils.CommConstant;
14
-import com.huiju.welcome.utils.MiniApp;
15
-import com.huiju.welcome.utils.StatusUtils;
16
-import com.huiju.welcome.utils.StringUtils;
13
+import com.huiju.welcome.utils.*;
17 14
 import org.slf4j.Logger;
18 15
 import org.slf4j.LoggerFactory;
19 16
 import org.springframework.beans.factory.annotation.Autowired;
@@ -80,6 +77,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
80 77
     @Autowired
81 78
     ICameraService cameraService;
82 79
 
80
+    @Autowired
81
+    SMSUtils smsUtils;
82
+
83 83
     @Override
84 84
     public List<TaPerson> getGroup(Integer customerId) {
85 85
         return taCustomerMapMapper.getGroup(customerId);
@@ -185,7 +185,13 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
185 185
             add("您有客户来访, 请及时接待!");
186 186
         }};
187 187
 
188
-        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
+        }
189 195
     }
190 196
     
191 197
     /**
@@ -222,7 +228,14 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
222 228
             if (null == openid) {
223 229
                 return;
224 230
             }
225
-            miniApp.sendTPLMessage(tpl, openid, page, data);
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
+            }
226 239
         });
227 240
     }
228 241
     
@@ -278,8 +291,10 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
278 291
             taMainUsherRecord.setCustomerId(cust.getCustomerId());
279 292
         } else {
280 293
             cust = taCustomerMapper.selectById(custId);
294
+            cust.setReceiver(taMainUsherRecord.getReceiver());
295
+            taCustomerMapper.updateById(cust);
281 296
         }
282
-        
297
+
283 298
         TaCustomerMap taCustomerMap = taCustomerMapMapper.getCustomerOf(personId);
284 299
         if (null == taCustomerMap) {
285 300
             TaCustomerMap custMap = new TaCustomerMap();
@@ -340,10 +355,10 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
340 355
         if (notify){
341 356
             //通知吧台来人了
342 357
             sendMessageAll(taFirstUsherRecord,cust,null);
343
-            
358
+
344 359
             //通知吧台人数等信息
345 360
             sendMessageToBar(cust,taFirstUsherRecord.getPersonNum());
346
-            
361
+
347 362
             //推送置业经理
348 363
             sendMessageToConsultManager(cust);
349 364
         }
@@ -514,9 +529,9 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
514 529
     }
515 530
 
516 531
     @Override
517
-    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) {
518 533
         IPage<TaCustomer> page = new Page<>(pageNumber, pageSize);
519
-        return taCustomerMapper.getCustomerListOfFront(page, consultantId, nameOrPhone);
534
+        return taCustomerMapper.getCustomerListOfFront(page, consultantId, nameOrPhoneOrReceiver);
520 535
     }
521 536
     
522 537
     @Override
@@ -575,6 +590,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
575 590
         taCustomer.setRealtyConsultant(taMainUsherRecord.getRealtyConsultant());
576 591
         taCustomer.setStatus(StatusUtils.Normal);
577 592
         taCustomer.setCreateDate(LocalDateTime.now());
593
+        taCustomer.setReceiver(taMainUsherRecord.getReceiver());
578 594
 
579 595
         return taCustomer;
580 596
     }
@@ -628,7 +644,14 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
628 644
                 add("您有客户来访, 请及时接待!");
629 645
             }};
630 646
             
631
-            miniApp.sendTPLMessage(tpl, openid, page, data);
647
+//            miniApp.sendTPLMessage(tpl, openid, page, data);
648
+            if (miniApp.sendTPLMessage(tpl, openid, page, data).getCode() == -1) {
649
+                // 没有 formid 发短信
650
+                String phone = sysUserMapper.getPhoneByOpenid(openid);
651
+                if (null != phone) {
652
+                    smsUtils.sendVisitor(phone, null == taCustomer ? "": StringUtils.ifNull(taCustomer.getCustomerName(), ""));
653
+                }
654
+            }
632 655
         });
633 656
     }
634 657
     

+ 12
- 1
src/main/java/com.huiju.welcome/service/impl/TaFirstUsherRecordServiceImpl.java Просмотреть файл

@@ -132,7 +132,16 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
132 132
     private boolean updateOtherInfo(TaFirstUsherRecord taFirstUsherRecord) {
133 133
         // 更新车辆信息
134 134
         TaCar taCar = iTaCarService.getById(taFirstUsherRecord.getPlateNumber());
135
-        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()) {
136 145
             taCar.setCarModel(taFirstUsherRecord.getCarModel());
137 146
             taCar.setColor(taFirstUsherRecord.getColor());
138 147
             iTaCarService.updateById(taCar);
@@ -234,6 +243,8 @@ public class TaFirstUsherRecordServiceImpl extends ServiceImpl<TaFirstUsherRecor
234 243
                 iTaCustomerService.sendMessageAll(taFirstUsherRecord,taCustomer,null);
235 244
                 //通知置业经理车辆信息
236 245
                 iTaCustomerService.notifyConsultant(taCustomer);
246
+                // 通知吧台
247
+                iTaCustomerService.sendMessageToBar(taCustomer, taFirstUsherRecord.getPersonNum());
237 248
             } catch (Exception e) {}
238 249
         }else if(StringUtils.isEmpty(taFirstUsherRecord.getPhone())){
239 250
             //有手机号的情况下会新建customer,推送后置

+ 182
- 133
src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java Просмотреть файл

@@ -39,6 +39,7 @@ import java.util.List;
39 39
 @Slf4j
40 40
 @Service
41 41
 public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordMapper, TaMainUsherRecord> implements ITaMainUsherRecordService {
42
+
42 43
     @Autowired
43 44
     private TaMainUsherRecordMapper taMainUsherRecordMapper;
44 45
 
@@ -72,6 +73,9 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
72 73
     @Autowired
73 74
     ICameraService cameraService;
74 75
 
76
+    @Autowired
77
+    SMSUtils smsUtils;
78
+
75 79
     @Override
76 80
     public boolean updateNormal(List<TaMainUsherRecord> records) {
77 81
         if (records == null || records.size() == 0) return true;
@@ -205,7 +209,14 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
205 209
                 add("您有新客户来访, 请及时接待!");
206 210
             }};
207 211
 
208
-            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
+            }
209 220
         } else {
210 221
             // 否则, 给原置业发消息, 给接待置业发消息
211 222
 
@@ -221,9 +232,14 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
221 232
                 add(phone);
222 233
                 add("您有新客户来访, 已被安排给 " + usr1.getUsername() + " 接待!");
223 234
             }};
224
-            miniApp.sendTPLMessage(tplId, rcOpenid, page, dt1);
225
-
226
-
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
+            }
227 243
 
228 244
             // 代理置业
229 245
             SysUser usr2 = sysUserMapper.selectById(realConsultant);
@@ -232,7 +248,14 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
232 248
                 add(phone);
233 249
                 add(usr2.getUsername() + " 有新客户来访, 请协助接待一下!");
234 250
             }};
235
-            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
+            }
236 259
         }
237 260
     }
238 261
 
@@ -247,7 +270,7 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
247 270
 
248 271
     @Override
249 272
     public boolean newRecordByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception {
250
-        Integer consultantId = taMainUsherRecord.getConsultantId();
273
+//        Integer consultantId = taMainUsherRecord.getConsultantId();
251 274
         //if (null == consultantId || consultantId < 1) {
252 275
         //    throw new Exception("置业顾问不能为空");
253 276
         //}
@@ -256,149 +279,82 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
256 279
             throw new Exception("客户电话不能为空");
257 280
         }
258 281
 
282
+        TaCustomer taCustomer = getOrNewCustomerBy(taMainUsherRecord);
259 283
         taMainUsherRecord.setStatus(StatusUtils.Normal);
260
-    
261
-        // 是否更新了置业
262
-        TaCustomer taCustomer = null;
263
-        if (null != taMainUsherRecord.getCustomerId()) {
264
-            taCustomer = iTaCustomerService.getById(taMainUsherRecord.getCustomerId());
265
-        } else if (null != taMainUsherRecord.getPhone() || null != taMainUsherRecord.getPlateNumber()) {
266
-            // 尝试使用手机号去查找
267
-            taCustomer = iTaCustomerService.getByPhoneOrPlate(taMainUsherRecord.getPhone(), taMainUsherRecord.getPlateNumber());
268
-        } else if (null != taMainUsherRecord.getAvatar()) {
269
-            // 依据人脸查询
270
-            JSONObject result = aliFaceUtils.searchFace(taMainUsherRecord.getAvatar());
271
-            if (null != result) {
272
-                Integer personId = Integer.valueOf(result.getString("personId"));
273
-                taCustomer = iTaCustomerService.getSameByPerson(personId);
284
+        taMainUsherRecord.setVisiteDate(LocalDateTime.now());
285
+        taMainUsherRecord.setCustomerId(taCustomer.getCustomerId());
286
+
287
+        TaMainUsherRecord taMainUsherRecordToday = getTodayRecord(taCustomer.getCustomerId());
288
+
289
+        if (null == taMainUsherRecordToday) {
290
+            int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
291
+            if (row < 1) {
292
+                log.error("新增跟进记录失败");
293
+                return false;
274 294
             }
275
-        }
276
-        
277
-        if (null == taCustomer){
278
-            // 新增客户
279
-            TaCustomer taCustomerNew = iTaCustomerService.newCustByMainUsher(taMainUsherRecord, true);
280
-    
281
-            taMainUsherRecord.setVisiteDate(LocalDateTime.now());
282
-            taMainUsherRecord.setCustomerId(taCustomerNew.getCustomerId());
283
-            return taMainUsherRecordMapper.insert(taMainUsherRecord) > 0;
295
+            return updateByMiniapp(taMainUsherRecord, taCustomer);
284 296
         }else {
285
-    
286
-            TaMainUsherRecord taMainUsherRecordToday = getTodayRecord(taCustomer.getCustomerId());
287
-            
288
-            if (null == taMainUsherRecordToday) {
289
-                int row = taMainUsherRecordMapper.insert(taMainUsherRecord);
290
-                if (row < 1) {
291
-                    log.error("新增跟进记录失败");
292
-                    return false;
293
-                }
294
-                return updateByMiniapp(taMainUsherRecord);
295
-            }else {
296
-                taMainUsherRecordToday = newRecordByCust(taCustomer, sysUserMapper.selectById(taCustomer.getConsultantId()));
297
-    
298
-                if (!StringUtils.isEmpty(taMainUsherRecord.getPhone())){
299
-                    taMainUsherRecordToday.setPhone(taMainUsherRecord.getPhone());
300
-                }
301
-    
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
-                return updateByMiniapp(taMainUsherRecordToday);
297
+//            taMainUsherRecordToday = newRecordByCust(taCustomer, sysUserMapper.selectById(taCustomer.getConsultantId()));
298
+            if (!StringUtils.isEmpty(taMainUsherRecord.getPhone())){
299
+                taMainUsherRecordToday.setPhone(taMainUsherRecord.getPhone());
300
+            }
301
+
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());
328 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);
329 332
         }
330
-        
331
-        
332 333
     }
333 334
 
334 335
     @Override
335
-    public boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord) throws Exception {
336
-        Integer consultantId = taMainUsherRecord.getConsultantId();
337
-        //if (null == consultantId || consultantId < 1) {
338
-        //    throw new Exception("置业顾问不能为空");
339
-        //}
340
-
336
+    public boolean updateByMiniapp(TaMainUsherRecord taMainUsherRecord, TaCustomer taCustomer) throws Exception {
341 337
         if (StringUtils.isEmpty(taMainUsherRecord.getPhone())) {
342 338
             throw new Exception("客户电话不能为空");
343 339
         }
344 340
 
345
-        taMainUsherRecord.setStatus(StatusUtils.Normal);
346
-
347
-        // 是否更新了置业
348
-        TaCustomer taCustomer = null;
349
-        if (null != taMainUsherRecord.getCustomerId()) {
350
-            taCustomer = iTaCustomerService.getById(taMainUsherRecord.getCustomerId());
351
-        } else if (null != taMainUsherRecord.getPhone() || null != taMainUsherRecord.getPlateNumber()) {
352
-            // 尝试使用手机号去查找
353
-            taCustomer = iTaCustomerService.getByPhoneOrPlate(taMainUsherRecord.getPhone(), taMainUsherRecord.getPlateNumber());
354
-        } else if (null != taMainUsherRecord.getAvatar()) {
355
-            // 依据人脸查询
356
-            JSONObject result = aliFaceUtils.searchFace(taMainUsherRecord.getAvatar());
357
-            if (null != result) {
358
-                Integer personId = Integer.valueOf(result.getString("personId"));
359
-                taCustomer = iTaCustomerService.getSameByPerson(personId);
360
-            }
341
+        if (null == taCustomer) {
342
+            taCustomer = getOrNewCustomerBy(taMainUsherRecord);
361 343
         }
362 344
 
363
-        if (null == taCustomer && null == taMainUsherRecord.getCustomerId()) {
364
-            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);
365 353
         }
366 354
 
355
+        Integer consultantId = taMainUsherRecord.getConsultantId();
367 356
         Integer originConsultant = taCustomer.getConsultantId();
368 357
 
369
-        // 是否需要更新客户信息
370
-        // 只更新空内容
371
-        if (StringUtils.isEmpty(taCustomer.getCustomerName()) || StringUtils.isEmpty(taCustomer.getPhone()) || StringUtils.isEmpty(taCustomer.getAvatar())
372
-             || StringUtils.isEmpty(taCustomer.getPlateNumber() )) {
373
-            if (StringUtils.isEmpty(taCustomer.getCustomerName())) {
374
-                taCustomer.setCustomerName(taMainUsherRecord.getPersonName());
375
-            }
376
-
377
-            if (StringUtils.isEmpty(taCustomer.getPhone())) {
378
-                taCustomer.setPhone(taMainUsherRecord.getPhone());
379
-            }
380
-
381
-            if (null == taCustomer.getSex()) {
382
-                taCustomer.setSex(taMainUsherRecord.getSex());
383
-            }
384
-
385
-            if (StringUtils.isEmpty(taCustomer.getAvatar())) {
386
-                taCustomer.setAvatar(taMainUsherRecord.getAvatar());
387
-            }
388
-
389
-            if (StringUtils.isEmpty(taCustomer.getPlateNumber())) {
390
-                taCustomer.setPlateNumber(taMainUsherRecord.getPlateNumber());
391
-            }
392
-
393
-            if (StringUtils.isEmpty(taCustomer.getCarModel())) {
394
-                taCustomer.setCarModel(taMainUsherRecord.getCarModel());
395
-            }
396
-
397
-            iTaCustomerService.updateById(taCustomer);
398
-        }
399
-
400
-        int row = taMainUsherRecordMapper.updateById(taMainUsherRecord);
401
-
402 358
         // 更新人员信息
403 359
         iTaPersonService.updateByMainUsher(taMainUsherRecord);
404 360
 
@@ -431,7 +387,13 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
431 387
             dt1.add(taCustomer.getPhone());
432 388
             dt1.add("您有新客户来访, 已被安排给 " + proxyUser.getUsername() + " 接待!");
433 389
 
434
-            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
+            }
435 397
 
436 398
             // 通知临时置业
437 399
             List<Object> dt2 = new ArrayList<Object>();
@@ -439,7 +401,13 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
439 401
             dt2.add(taCustomer.getPhone());
440 402
             dt2.add(rcUser.getUsername() + " 有新客户来访, 请协助接待一下!");
441 403
 
442
-            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
+            }
443 411
         }
444 412
     
445 413
         //通知前端
@@ -451,6 +419,65 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
451 419
         return row > 0;
452 420
     }
453 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
+
454 481
     @Override
455 482
     public boolean deleteRecord(Integer id) {
456 483
         UpdateWrapper<TaMainUsherRecord> updateWrapper = new UpdateWrapper<>();
@@ -615,6 +642,28 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
615 642
         return taMainUsherRecord;
616 643
     }
617 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
+
618 667
     private TaMainUsherRecord newRecordByPerson(TaPerson taPerson) {
619 668
         TaMainUsherRecord taMainUsherRecord = new TaMainUsherRecord();
620 669
         taMainUsherRecord.setPersonName(taPerson.getName());

+ 2
- 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);

+ 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 ++) {

+ 10
- 7
src/main/resources/application.yml Просмотреть файл

@@ -1,12 +1,12 @@
1 1
 spring:
2 2
   datasource:
3 3
     driver-class-name: com.mysql.cj.jdbc.Driver
4
-#    url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/welcome3?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
5
-#    username: welcome
6
-#    password: s190QU2#z%hdU%^FPkY9qjls
7
-    url: jdbc:mysql://47.101.36.130:3306/welcome3?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
8
-    username: root
9
-    password: Wt4q*/9}i00q@0a4jM{z6O#h129@F/
4
+    url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/welcome3?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
5
+    username: welcome
6
+    password: s190QU2#z%hdU%^FPkY9qjls
7
+#    url: jdbc:mysql://47.101.36.130:3306/welcome3?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
8
+#    username: root
9
+#    password: Wt4q*/9}i00q@0a4jM{z6O#h129@F/
10 10
   servlet:
11 11
     multipart:
12 12
       max-file-size: 1024MB
@@ -95,4 +95,7 @@ sms:
95 95
     # 验证码长度
96 96
     size: 4
97 97
     # 短信签名
98
-    sign: AI智慧案场
98
+    sign: AI智慧案场
99
+
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 Просмотреть файл

@@ -60,18 +60,29 @@
60 60
 
61 61
     <select id="getCustomerListOfFront" resultType="com.huiju.welcome.model.TaCustomer">
62 62
         SELECT
63
-            *
63
+            t.*,
64
+            s.visite_date
64 65
         FROM
65 66
             ta_customer t
67
+        LEFT JOIN (
68
+            SELECT
69
+                a.customer_id,
70
+                max( b.visite_date ) as visite_date
71
+            FROM
72
+              ta_customer a
73
+            LEFT JOIN ta_main_usher_record b USING ( customer_id )
74
+            GROUP BY
75
+              a.customer_id
76
+            ) s USING ( customer_id )
66 77
         WHERE t.status &gt; 0
67 78
             <if test="consultantId !=null">
68 79
               AND t.consultant_id = #{consultantId}
69 80
             </if>
70
-            <if test="nameOrPhone !=null and nameOrPhone != ''">
71
-              AND ( t.customer_name LIKE CONCAT('%',#{nameOrPhone},'%') OR t.phone LIKE CONCAT('%',#{nameOrPhone},'%') )
81
+            <if test="nameOrPhoneOrReceiver !=null and nameOrPhoneOrReceiver != ''">
82
+              AND ( t.customer_name LIKE CONCAT('%',#{nameOrPhoneOrReceiver},'%') OR t.phone LIKE CONCAT('%',#{nameOrPhoneOrReceiver},'%') OR t.receiver LIKE CONCAT('%',#{nameOrPhoneOrReceiver},'%'))
72 83
             </if>
73 84
         ORDER BY
74
-            t.create_date DESC
85
+          IFNULL( s.visite_date, t.create_date ) DESC
75 86
     </select>
76 87
 
77 88
     <select id="getAttributionList" resultType="com.huiju.welcome.model.TaCustomer">