|
@@ -1,5 +1,6 @@
|
|
|
package com.ylx.web.controller.massage;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
import cn.hutool.extra.qrcode.QrConfig;
|
|
@@ -40,6 +41,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -52,10 +54,7 @@ import java.net.URL;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static com.ylx.massage.utils.OtherUtil.verification;
|
|
@@ -251,7 +250,9 @@ public class WeChatController extends BaseController {
|
|
|
private String getString(Map<String, String> encryptMap) throws Exception {
|
|
|
// 返回消息时ToUserName的值与FromUserName的互换
|
|
|
Map<String, String> returnMap = new HashMap<>();
|
|
|
-
|
|
|
+ String content ="欢迎来到大菠萝city"+"\n" +
|
|
|
+ "\n" +
|
|
|
+ "大菠萝city是一家快速上门服务预约平台,提供正规 绿色 快捷上门服务,提供按摩、推拿、养生、SPA等服务,专业针对居家、差旅、酒店等顾客提供便捷健康养生服务";
|
|
|
//添加新用户
|
|
|
TWxUser fromUserName = wxUserService.getByOpenId(encryptMap.get("FromUserName"));
|
|
|
if (fromUserName == null) {
|
|
@@ -262,17 +263,24 @@ public class WeChatController extends BaseController {
|
|
|
fromUserName.setRole(1);
|
|
|
wxUserService.saveOrUpdate(fromUserName);
|
|
|
//绑定技师
|
|
|
- TJs tJs = new TJs();
|
|
|
- tJs.setId(StringUtilsMassage.afterString(encryptMap.get("EventKey"), "qrscene_"));
|
|
|
- tJs.setcOpenId(encryptMap.get("FromUserName"));
|
|
|
- jsService.updateById(tJs);
|
|
|
+ TJs byId = jsService.getById(StringUtilsMassage.afterString(encryptMap.get("EventKey"), "qrscene_"));
|
|
|
+ List<TJs> byOpenid = jsService.list(new LambdaQueryWrapper<TJs>().eq(TJs::getcOpenId, encryptMap.get("FromUserName")));
|
|
|
+ if (CollectionUtil.isNotEmpty(byOpenid)) {
|
|
|
+ content = "你已有绑定的账号如需换绑请先解绑";
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(byId.getcOpenId())) {
|
|
|
+ content = "该账号已被绑定,请选择其他账号";
|
|
|
+ } else if (CollectionUtil.isEmpty(byOpenid)) {
|
|
|
+ TJs tJs = new TJs();
|
|
|
+ tJs.setId(StringUtilsMassage.afterString(encryptMap.get("EventKey"), "qrscene_"));
|
|
|
+ tJs.setcOpenId(encryptMap.get("FromUserName"));
|
|
|
+ jsService.updateById(tJs);
|
|
|
+ }
|
|
|
returnMap.put("ToUserName", encryptMap.get("FromUserName"));
|
|
|
returnMap.put("FromUserName", encryptMap.get("ToUserName"));
|
|
|
returnMap.put("CreateTime", new Date().getTime() + "");
|
|
|
returnMap.put("MsgType", "text");
|
|
|
- returnMap.put("Content", "欢迎来到大菠萝city"+"\n" +
|
|
|
- "\n" +
|
|
|
- "大菠萝city是一家快速上门服务预约平台,提供正规 绿色 快捷上门服务,提供按摩、推拿、养生、SPA等服务,专业针对居家、差旅、酒店等顾客提供便捷健康养生服务");
|
|
|
+ returnMap.put("Content", content);
|
|
|
String encryptMsg = weChatUtil.mapToXml(returnMap).toString();
|
|
|
return encryptMsg;
|
|
|
}
|
|
@@ -412,11 +420,12 @@ public class WeChatController extends BaseController {
|
|
|
|
|
|
@ApiOperation("兑换JS公众号二维码")
|
|
|
@RequestMapping(value = "getJSwxQrCodeDh", method = RequestMethod.GET)
|
|
|
- public String getJSwxQrCode1(@RequestParam String ticket) throws UnsupportedEncodingException {
|
|
|
+ public String getJSwxQrCode1(@RequestParam String ticket,@RequestParam String id) throws UnsupportedEncodingException {
|
|
|
+
|
|
|
|
|
|
String qrCodeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="
|
|
|
+ URLEncoder.encode(ticket, "UTF-8");
|
|
|
- String filePath = RuoYiConfig.getUploadPath() + "ewm.png";
|
|
|
+ String filePath = RuoYiConfig.getUploadEwmPath() + id +".png";
|
|
|
log.info("二维码地址:{}", filePath);
|
|
|
|
|
|
try (InputStream in = new URL(qrCodeUrl).openStream();
|
|
@@ -432,7 +441,7 @@ public class WeChatController extends BaseController {
|
|
|
log.info("二维码地址:{}", filePath);
|
|
|
int lastSlashIndex = filePath.lastIndexOf("/");
|
|
|
String fileName = filePath.substring(lastSlashIndex + 1);
|
|
|
- return Constants.RESOURCE_PREFIX + "/" + fileName;
|
|
|
+ return Constants.RESOURCE_PREFIX + "/ewm/" + fileName;
|
|
|
}
|
|
|
|
|
|
|