|
@@ -17,6 +17,7 @@ import com.ylx.common.enums.BusinessType;
|
|
|
import com.ylx.common.utils.MessageUtils;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
import com.ylx.common.utils.file.FileUploadUtils;
|
|
|
+import com.ylx.common.utils.file.FileUtils;
|
|
|
import com.ylx.framework.config.ServerConfig;
|
|
|
import com.ylx.framework.manager.AsyncManager;
|
|
|
import com.ylx.framework.manager.factory.AsyncFactory;
|
|
@@ -24,6 +25,7 @@ import com.ylx.framework.web.service.WxTokenService;
|
|
|
import com.ylx.massage.domain.CouponReceive;
|
|
|
import com.ylx.massage.domain.TJs;
|
|
|
import com.ylx.massage.domain.TWxUser;
|
|
|
+import com.ylx.massage.domain.TbFile;
|
|
|
import com.ylx.massage.service.CouponReceiveService;
|
|
|
import com.ylx.massage.service.TJsService;
|
|
|
import com.ylx.massage.service.TWxUserService;
|
|
@@ -44,10 +46,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.File;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.InputStreamReader;
|
|
|
+import java.io.*;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+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;
|
|
@@ -254,14 +258,21 @@ public class WeChatController extends BaseController {
|
|
|
fromUserName = new TWxUser();
|
|
|
}
|
|
|
fromUserName.setcOpenid(encryptMap.get("FromUserName"));
|
|
|
- fromUserName.setcUpUser(StringUtilsMassage.afterString(encryptMap.get("EventKey"), "qrscene_"));
|
|
|
+ //fromUserName.setcUpUser(StringUtilsMassage.afterString(encryptMap.get("EventKey"), "qrscene_"));
|
|
|
+ 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);
|
|
|
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");
|
|
|
+ returnMap.put("Content", "欢迎来到大菠萝city"+"\n" +
|
|
|
+ "\n" +
|
|
|
+ "大菠萝city是一家快速上门服务预约平台,提供正规 绿色 快捷上门服务,提供按摩、推拿、养生、SPA等服务,专业针对居家、差旅、酒店等顾客提供便捷健康养生服务");
|
|
|
String encryptMsg = weChatUtil.mapToXml(returnMap).toString();
|
|
|
return encryptMsg;
|
|
|
}
|
|
@@ -379,7 +390,7 @@ public class WeChatController extends BaseController {
|
|
|
return weChatUtil.getTicket(token, openId);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("获取JS公众号二维码")
|
|
|
+ @ApiOperation("获取JS公众号二维码ticket")
|
|
|
@RequestMapping(value = "getJSwxQrCode", method = RequestMethod.GET)
|
|
|
public void getJSwxQrCode(@RequestParam String jsId) {
|
|
|
//获取access_token
|
|
@@ -393,11 +404,39 @@ public class WeChatController extends BaseController {
|
|
|
//获取二维码图片
|
|
|
//File file = QrCodeUtil.generate(qrCodeUrl, config, FileUtil.file(RuoYiConfig.getUploadPath() + "/code.png"));
|
|
|
TJs tjs = new TJs();
|
|
|
+ tjs.setId(jsId);
|
|
|
tjs.setTicket(jsTicket.get("ticket").toString());
|
|
|
jsService.updateById(tjs);
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @ApiOperation("兑换JS公众号二维码")
|
|
|
+ @RequestMapping(value = "getJSwxQrCodeDh", method = RequestMethod.GET)
|
|
|
+ public String getJSwxQrCode1(@RequestParam String ticket) throws UnsupportedEncodingException {
|
|
|
+
|
|
|
+ String qrCodeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="
|
|
|
+ + URLEncoder.encode(ticket, "UTF-8");
|
|
|
+ String filePath = RuoYiConfig.getUploadPath() + "ewm.png";
|
|
|
+ log.info("二维码地址:{}", filePath);
|
|
|
+
|
|
|
+ try (InputStream in = new URL(qrCodeUrl).openStream();
|
|
|
+ OutputStream out = Files.newOutputStream(Paths.get(filePath))) {
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int bytesRead;
|
|
|
+ while ((bytesRead = in.read(buffer)) != -1) {
|
|
|
+ out.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("二维码地址:{}", filePath);
|
|
|
+ int lastSlashIndex = filePath.lastIndexOf("/");
|
|
|
+ String fileName = filePath.substring(lastSlashIndex + 1);
|
|
|
+ return Constants.RESOURCE_PREFIX + "/" + fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation("获取公众号网页二维码")
|
|
|
@GetMapping("/getweQrCode")
|
|
|
public AjaxResult weiXinLogin1(String openId) {
|