Browse Source

wxservice 适配两个公众号,全部配置改造提交

wcq 1 year ago
parent
commit
f6f1adc7c5

+ 29 - 0
README-DEPLOY.MD

@@ -0,0 +1,29 @@
+打包时切换公众号需要修改的配置
+1、请求地址:
+e码头e站通的公众号
+wxservice.ds-bay.com
+e码头公众号
+wxservice.fu-qing.com
+例如: 要打包 e码头公众号,则
+全局搜索:wxservice.ds-bay.com 全局替换为 :wxservice.fu-qing.com
+反过来一样
+
+2、clean.js  需要修改appId
+getCode方法
+qhemato:wx8735db2da152ce19   
+emato e站通:wxf9360d70bc1406ee
+
+3、application.yml 切换
+spring:
+    profiles:
+        active: qh
+active: qh   为前海e码头公众号
+
+spring:
+    profiles:
+        active: 
+active:    为空则为e站通公众号
+
+
+
+

+ 2 - 2
src/main/java/com/ematou/wxservice/mp/handler/WeChatSubscribeEventHandler.java

@@ -26,8 +26,8 @@ public class WeChatSubscribeEventHandler implements WeChatMessageHandler {
         WeChatMpXmlOutNewsMessage.Item item = new WeChatMpXmlOutNewsMessage.Item();
         item.setTitle("欢迎关注【e码头】");
         item.setDescription(">>>点击绑定手机号,立即取件!");
-        item.setPicUrl("https://wxservice.ds-bay.com/images/emtnew.png");
-        item.setUrl("https://wxservice.ds-bay.com/view/binding?openid="+weChatMessage.getFromUser());
+        item.setPicUrl("https://wxservice.fu-qing.com/images/emtnew.png");
+        item.setUrl("https://wxservice.fu-qing.com/view/binding?openid="+weChatMessage.getFromUser());
         return WeChatMpXmlOutMessage.NEWS().addArticle(item).toUser(weChatMessage.getFromUser()).fromUser(weChatMessage.getToUser()).build();
        }
 

+ 2 - 1
src/main/java/com/ematou/wxservice/mp/menu/MenuButtonManager.java

@@ -79,8 +79,9 @@ public class MenuButtonManager {
             ClickButton scanPush = new ClickButton("扫码取件", WeChatConstant.EventType.SCANCODE_PUSH.toLowerCase(), WeChatConstant.CustomEventKey.SCANCODE_PUSH_BUTTON);
             //ClickButton myHistoryBtn = new ClickButton("取件历史", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.MY_HISTORY_RECORD);
             //ViewButton addressEntryBtn = new ViewButton("收货地址管理", WeChatConstant.EventType.VIEW.toLowerCase(), "http://kmall-test.ds-bay.com:8080/qrcode/verification.html");
+            MiniProgramButton miniProgramButton = new MiniProgramButton("小程序",WeChatConstant.EventType.MINIPROGRAM.toLowerCase(),"http://mp.weixin.qq.com","wx1f09731935da5dd7","/pages/index/index");
             MenuButton takeParcelMenuButton = new MenuButton("取件服务");
-            takeParcelMenuButton.setSub_button(Arrays.asList(scanPush)); // myCodeBtn  我的取件码菜单屏蔽
+            takeParcelMenuButton.setSub_button(Arrays.asList(scanPush,miniProgramButton)); // myCodeBtn  我的取件码菜单屏蔽
 
             ViewButton companyState = new ViewButton("公司状态", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=3&sn=da0db13971baf7a27bf639f2f7eaebbe&scene=18#wechat_redirect");
             ViewButton companyInfo = new ViewButton("公司简介", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/s?__biz=MzIwMTI2MTg1MA==&mid=503159833&idx=1&sn=fbddc8c56f960d7912cee60c959c42e8&chksm=0ef9aa6c398e237a862143c4f4c7314c0159a77e87ad4fd39a89d22181bcb05aedc9a816c8b2&scene=18#wechat_redirect");

+ 4 - 1
src/main/java/com/ematou/wxservice/service/UserInfoService.java

@@ -15,6 +15,7 @@ import org.omg.IOP.Encoding;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -42,6 +43,8 @@ public class UserInfoService {
 
     @Autowired
     WeChatApiRestTemplate weChatApiRestTemplate;
+    @Value("${wx.general.appId}")
+    private String appId;
 
     public UserInfo get(String openId, String phoneNumber){
 
@@ -131,7 +134,7 @@ public class UserInfoService {
 
     public ScannVO getScanningture() {
         ScannVO scannVO = new ScannVO();
-        scannVO.setAppId("wxf9360d70bc1406ee");
+        scannVO.setAppId(appId);
         return scannVO;
     }
 

+ 3 - 1
src/main/java/com/ematou/wxservice/service/WeChatService.java

@@ -47,6 +47,8 @@ public class WeChatService {
     WeChatMessageService weChatMessageService;
     @Value("${wechat}")
     String wechat;
+    @Value("${wx.general.appId}")
+    private String appId;
     /**
      * 获取普通AccessToken
      * @return AccessToken
@@ -219,7 +221,7 @@ public class WeChatService {
         String nonceStr = df.format(new Random().nextInt(100000000));
         String sign = SignUtil.jsApiSign(ticket, url, timestamp, nonceStr);
         Map<String, Object> result = new HashMap<>();
-        result.put("appId", "wxf9360d70bc1406ee");
+        result.put("appId", appId);
         result.put("timestamp", timestamp);
         result.put("nonceStr", nonceStr);
         result.put("signature", sign);

+ 42 - 0
src/main/resources/application-qh.yml

@@ -0,0 +1,42 @@
+server:
+  port: 3030
+
+wx:
+  general:
+    appId: wx8735db2da152ce19
+    appSecret: 016edeba9d3f0508c95476ceec5f65e4
+spring:
+  profiles:
+    active: qh
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+#    username: tuser
+#    password: Qq!123
+#    url: jdbc:mysql://120.76.84.45:3306/wx_base?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+    username: wx_service
+    password: p9ryaBSuA6
+    url: jdbc:mysql://out-rm-wz92efl25x02n44xego.mysql.rds.aliyuncs.com:3306/wx_service?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+  thymeleaf:
+    cache: false
+    prefix: classpath:/templates/
+    suffix: .html
+    check-template-location: true
+    encoding: UTF-8
+    mode: HTML
+    servlet:
+      content-type: text/html
+mybatis:
+  mapper-locations: classpath:mybatis/*.xml
+  configuration:
+    map-underscore-to-camel-case: true
+logging:
+  config: classpath:logback.xml
+sms:
+  # 单条短信请求url
+  singleUrl: https://sms.yunpian.com/v2/sms/single_send.json
+  # 短信模板
+  smsContent: 【前海电商】欢迎绑定%s公众号,您的手机验证码是%s。本条信息无需回复
+#e码头e站通公众号
+#wechat: emato
+#前海e码头公众号
+wechat: qhemato

+ 2 - 0
src/main/resources/application.yml

@@ -6,6 +6,8 @@ wx:
     appId: wxf9360d70bc1406ee
     appSecret: 78413a82d0332ecbf7fdf475d0a8b08e
 spring:
+  profiles:
+    active: qh
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
 #    username: tuser

+ 1 - 1
src/main/resources/logback.xml

@@ -2,7 +2,7 @@
 
 <configuration scan="false" scanPeriod="60 seconds" debug="false">
 
-    <property name="LOG_HOME" value="logs/"/>
+    <property name="LOG_HOME" value="/data/project/logs/wxservice/"/>
     <!-- 定义日志的根目录 -->
     <property name="TRACE_DIR" value="trace" />
     <property name="DEBUG_DIR" value="debug" />

+ 1 - 0
src/main/resources/static/MP_verify_uMbFthC1PdFZ4HZO.txt

@@ -0,0 +1 @@
+uMbFthC1PdFZ4HZO

+ 7 - 4
src/main/resources/static/js/clean.js

@@ -68,7 +68,7 @@ function sendMessage1() {
     $("#btnSendCode1").attr("disabled", "true");
     $("#btnSendCode1").val(+curCount1 + "秒再获取");
 
-    $.get("https://wxservice.ds-bay.com/user/send?phoneNumber=" + phone + "&openId=" + sessionStorage.getItem("openid"), function (res) {
+    $.get("https://wxservice.fu-qing.com/user/send?phoneNumber=" + phone + "&openId=" + sessionStorage.getItem("openid"), function (res) {
     })
 
     InterValObj1 = window.setInterval(SetRemainTime1, 1000);
@@ -95,7 +95,7 @@ submitForm = function () {
     if (flag) {
         var openid = getUrlParam("openid");
         $.ajax({
-            url: "https://wxservice.ds-bay.com/binding",
+            url: "https://wxservice.fu-qing.com/binding",
             data: JSON.stringify({phone: $("#phone1").val(), code: $("#code1").val(), openId: openid}),
             type: "POST",
             contentType: 'application/json',
@@ -148,7 +148,10 @@ getCode = function () {
     }
     var code = getUrlParam('code') // 截取路径中的code,如果没有就去微信授权,如果已经获取到了就直接传code给后台获取openId
     var local = window.location.href;
-    var APPID = 'wxf9360d70bc1406ee';
+    // qhemato:wx8735db2da152ce19
+    var APPID = 'wx8735db2da152ce19';
+    // emato  e站通:  wxf9360d70bc1406ee
+    // var APPID = 'wxf9360d70bc1406ee';
     if (code == null || code === '') {
         window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + APPID + '&redirect_uri=' + encodeURIComponent(local) + '&response_type=code&scope=snsapi_base&state=#wechat_redirect'
     } else {
@@ -160,7 +163,7 @@ getOpenId = function (code) {
     $.ajax({
         type: 'GET',
         dataType: 'text',
-        url: 'https://wxservice.ds-bay.com/oauth2?code=' + code,
+        url: 'https://wxservice.fu-qing.com/oauth2?code=' + code,
         success: function (res) {
             if (res.status == -1) {
                 // 提示没有关注公众号 没有关注公众号跳转到关注公众号页面

+ 4 - 4
src/main/resources/templates/binding.html

@@ -7,9 +7,9 @@
         <meta content="yes" name="apple-mobile-web-app-capable"/>
         <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
         <meta content="telephone=no" name="format-detection"/>
-        <link href="https://wxservice.ds-bay.com/css/style.css" rel="stylesheet" type="text/css"/>
-        <script type="text/javascript" src="https://wxservice.ds-bay.com/js/jquery.min.js"></script>
-        <script type="text/javascript" src="https://wxservice.ds-bay.com/js/clean.js"></script>
+        <link href="https://wxservice.fu-qing.com/css/style.css" rel="stylesheet" type="text/css"/>
+        <script type="text/javascript" src="https://wxservice.fu-qing.com/js/jquery.min.js"></script>
+        <script type="text/javascript" src="https://wxservice.fu-qing.com/js/clean.js"></script>
     </head>
     <body>
 
@@ -42,7 +42,7 @@
                 <div class="aui-code-box">
                     <h2>绑定手机</h2>
                     <p>登录及找回密码的途径</p>
-                    <form id="submit_form" ><!--action="https://wxservice.ds-bay.com/binding" method="post"-->
+                    <form id="submit_form" ><!--action="https://wxservice.fu-qing.com/binding" method="post"-->
                         <p class="aui-code-line">
                             <em>+86</em>
                             <input type="text" class="aui-code-line-input" name="phone1" value="" id="phone1" autocomplete="off" placeholder="请输入已绑定的手机号" style="padding-left:28px;"/>

+ 1 - 1
src/main/resources/templates/qrcode.html

@@ -15,7 +15,7 @@
     const purl = location.href;
     const data = {"url": purl};
     $.ajax({
-        url: "https://wxservice.ds-bay.com/jsSign",
+        url: "https://wxservice.fu-qing.com/jsSign",
         data: JSON.stringify(data),
         type: "POST",
         contentType: 'application/json',

+ 3 - 3
src/main/resources/templates/return.html

@@ -7,8 +7,8 @@
         <meta content="yes" name="apple-mobile-web-app-capable"/>
         <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
         <meta content="telephone=no" name="format-detection"/>
-        <link href="https://wxservice.ds-bay.com/css/style_return.css" rel="stylesheet" type="text/css"/>
-        <script type="text/javascript" src="https://wxservice.ds-bay.com/js/jquery.min.js"></script>
+        <link href="https://wxservice.fu-qing.com/css/style_return.css" rel="stylesheet" type="text/css"/>
+        <script type="text/javascript" src="https://wxservice.fu-qing.com/js/jquery.min.js"></script>
     </head>
     <body>
 
@@ -39,7 +39,7 @@
             <section class="aui-scrollView">
                 <div class="aui-back-box">
                     <div class="aui-back-pitch">
-                        <img src="https://wxservice.ds-bay.com/images/icon-pitch.png" alt="">
+                        <img src="https://wxservice.fu-qing.com/images/icon-pitch.png" alt="">
                     </div>
                     <div class="aui-back-title">
                         <h2>绑定成功</h2>