Forráskód Böngészése

优化:获取公众号用户unionid。

lym 4 éve
szülő
commit
f6c035464f

+ 6 - 0
src/main/java/com/hw/form/WechatInfoForm.java

@@ -15,6 +15,12 @@ public class WechatInfoForm {
     @ApiModelProperty(value = "旧公众号openid",example = "旧公众号openid")
     private String oldOpenid;
 
+    @ApiModelProperty(value = "旧公众号unionid",example = "旧公众号unionid")
+    private String oldUnionid;
+
+    @ApiModelProperty(value = "新公众号appid",example = "新公众号appid")
+    private String newAppid;
+
     @ApiModelProperty(value = "新公众号openid",example = "新公众号openid")
     private String newOpenid;
 

+ 14 - 2
src/main/resources/application-dev.properties

@@ -41,9 +41,21 @@ spring.redis.jedis.pool.max-wait=-1
 spring.redis.timeout=5000
 
 #原公众号appId
-wx.ma.appId=wxbe90cc7c5233dd84
+#wx.ma.appId=wxbe90cc7c5233dd84
+#小程序
+#wx.ma.appId=wx2844cc0f6ea2fff9
+#发改委公众号
+#wx.ma.appId=wxa993a695e678d087
+#环境厅公众号
+#wx.ma.appId=wx2d869242710685d4
+#基金会
+wx.ma.appId=wx66b5e3b94dd2d990
 #原公众号secret
-wx.ma.secret=ec4a18ce1a7bcf17cf592c3d57cec68a
+#wx.ma.secret=ec4a18ce1a7bcf17cf592c3d57cec68a
+#wx.ma.secret=4af8ce08fca18a51176ab3be52484398
+#wx.ma.secret=b8ade54835fd7c631229e2aa2f24bffe
+#wx.ma.secret=d0ee924ccc75ad4e6fa51797988a163a
+wx.ma.secret=568055c0f78c0d97f17d695abb8231a0
 
 #新公众号appId
 newwx.ma.appId=wxbe90cc7c5233dd84

+ 14 - 1
src/main/resources/mappers/WechatInfoMapper.xml

@@ -146,7 +146,20 @@
   <!-- 批量修改 lym -->
   <update id="batchUpdate" parameterType="com.hw.form.WechatInfoForm">
     <foreach collection="list" item="item" separator=";">
-      UPDATE t_wechat_info SET new_openid = #{item.newOpenid},modified_time = NOW() WHERE old_appid = #{item.oldAppid} and old_openid = #{item.oldOpenid}
+      UPDATE t_wechat_info
+         <set>
+          <if test="item.newOpenid != null and item.newOpenid != ''">
+            new_openid = #{item.newOpenid},
+          </if>
+          <if test="item.oldUnionid != null and item.oldUnionid != ''">
+            old_unionid = #{item.oldUnionid},
+          </if>
+           <if test="item.newAppid != null and item.newAppid != ''">
+             new_appid = #{item.newAppid},
+           </if>
+           modified_time = NOW()
+         </set>
+            WHERE old_appid = #{item.oldAppid} and old_openid = #{item.oldOpenid}
     </foreach>
   </update>
 </mapper>

+ 10 - 8
src/main/resources/sql/创建表和默认数据.sql

@@ -1,11 +1,13 @@
 #创建表
-CREATE TABLE `t_wechat_info` (
-       `guid` char(32) CHARACTER SET utf8mb4 NOT NULL DEFAULT '1' COMMENT '序列',
-       `old_appid` varchar(50) DEFAULT NULL COMMENT '旧公众号appid',
-       `old_openid` varchar(50) DEFAULT NULL COMMENT '旧微信openid',
-       `new_openid` varchar(50) DEFAULT NULL COMMENT '新微信openid',
-       `create_time` datetime DEFAULT NULL COMMENT '创建时间',
-       `modified_time` datetime DEFAULT NULL COMMENT '修改时间',
-       PRIMARY KEY (`guid`)
+CREATE TABLE `t_wechat_info_1` (
+   `guid` char(32) CHARACTER SET utf8mb4 NOT NULL DEFAULT '1' COMMENT '序列',
+   `old_appid` varchar(50) DEFAULT NULL COMMENT '旧公众号appid',
+   `old_openid` varchar(50) DEFAULT NULL COMMENT '旧微信openid',
+   `old_unionid` varchar(50) DEFAULT NULL COMMENT '旧公众号unionid',
+   `new_appid` varchar(50) DEFAULT NULL COMMENT '新公众号appid',
+   `new_openid` varchar(50) DEFAULT NULL COMMENT '新微信openid',
+   `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+   `modified_time` datetime DEFAULT NULL COMMENT '修改时间',
+   PRIMARY KEY (`guid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='新旧公众号openid信息';