1.兼容历史数据无unionid和memberId的情况
Showing
1 changed file
with
87 additions
and
0 deletions
| 1 | package com.topdraw.test.business.process.rest; | ||
| 2 | |||
| 3 | import com.alibaba.fastjson.JSON; | ||
| 4 | import com.topdraw.BaseTest; | ||
| 5 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | ||
| 6 | import com.topdraw.business.process.domian.TempCoupon; | ||
| 7 | import com.topdraw.business.process.domian.weixin.SubscribeBeanEvent; | ||
| 8 | import com.topdraw.business.process.rest.CouponOperationController; | ||
| 9 | import com.topdraw.business.process.rest.UserOperationController; | ||
| 10 | import com.topdraw.common.ResultInfo; | ||
| 11 | import com.topdraw.util.TimestampUtil; | ||
| 12 | import org.junit.Test; | ||
| 13 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | |||
| 15 | import java.io.IOException; | ||
| 16 | import java.time.LocalDateTime; | ||
| 17 | import java.util.ArrayList; | ||
| 18 | import java.util.List; | ||
| 19 | |||
| 20 | public class UserOperationControllerTest extends BaseTest { | ||
| 21 | |||
| 22 | @Autowired | ||
| 23 | UserOperationController userOperationController; | ||
| 24 | |||
| 25 | @Test | ||
| 26 | public void subscribe(){ | ||
| 27 | SubscribeBeanEvent subscribeBeanEvent = new SubscribeBeanEvent(); | ||
| 28 | try { | ||
| 29 | String s = "{\n" + | ||
| 30 | " \"unionid\": \"oqDha5lxMuXYMGgT6gyLIFL7VumM\",\n" + | ||
| 31 | " \"dyAppid\": \"wx5d88c7fe99f89f32\",\n" + | ||
| 32 | " \"nickname\": \"%E5%90%89%E8%B4%9D\",\n" + | ||
| 33 | " \"headimgurl\": \"https%3A%2F%2Fthirdwx.qlogo.cn%2Fmmopen%2Fvi_32%2FDYAIOgq83erGuDK9HlicY2iasIB5VHXTNWtuqfIZxIpzicQKWg9ogSRKRO1DeYtWicDHMMibpibHOEZRfp1Fvd4EQgrg%2F132\",\n" + | ||
| 34 | " \"IPTVappid\": \"kids3\",\n" + | ||
| 35 | " \"platformAccount\": \"topdraw\"\n" + | ||
| 36 | "}"; | ||
| 37 | userOperationController.saveUserInfo(s); | ||
| 38 | |||
| 39 | String a = "{\"appId\":\"wx5d88c7fe99f89f32\",\"eventKey\":\"\",\"headimgurl\":\"https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erGuDK9HlicY2iasIB5VHXTNWtuqfIZxIpzicQKWg9ogSRKRO1DeYtWicDHMMibpibHOEZRfp1Fvd4EQgrg/132\",\"openId\":\"oeHBC6JjlbNGFQ172uKICRDYDuGs\",\"unionid\":\"oqDha5lxMuXYMGgT6gyLIFL7VumM\"}" | ||
| 40 | ; | ||
| 41 | subscribeBeanEvent.setContent(a); | ||
| 42 | userOperationController.subscribe(subscribeBeanEvent); | ||
| 43 | |||
| 44 | } catch (IOException e) { | ||
| 45 | e.printStackTrace(); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | @Test | ||
| 50 | public void createWeixinUserAndCreateMember(){ | ||
| 51 | |||
| 52 | /*{"accessToken":"","appid":"wxfaa765183a332521","authTime":1648479958000, | ||
| 53 | "createTime":1648479958000,"description":"", | ||
| 54 | "headimgurl":"upload/icon/2022-04-20/a642c2cc-0e71-460b-a373-cbb9df6873f2.jpg", | ||
| 55 | "id":127942,"nickname":"5ZCJ6LSd","openid":"oxgff4goR2v2747JBYOhTRN38Z-o", | ||
| 56 | "privilege":"","refreshToken":"","sex":0,"sourceDesc":"","sourceEntity":"", | ||
| 57 | "sourceId":"","sourceType":"","sourceUser":0,"syncStatus":0, | ||
| 58 | "unionid":"oqDha5lxMuXYMGgT6gyLIFL7VumM","updateTime":1650450992000}*/ | ||
| 59 | |||
| 60 | UserWeixin userWeixin = new UserWeixin(); | ||
| 61 | userWeixin.setAccessToken(""); | ||
| 62 | userWeixin.setAppid("wxfaa765183a332521"); | ||
| 63 | userWeixin.setAuthTime(TimestampUtil.now()); | ||
| 64 | userWeixin.setHeadimgurl("upload/icon/2022-04-20/a642c2cc-0e71-460b-a373-cbb9df6873f2.jpg"); | ||
| 65 | userWeixin.setId(127942L); | ||
| 66 | // userWeixin.setNickname("5ZCJ6LSd"); | ||
| 67 | userWeixin.setNickname(null); | ||
| 68 | userWeixin.setOpenid("oxgff4goR2v2747JBYOhTRN38Z-o"); | ||
| 69 | // userWeixin.setOpenid("1"); | ||
| 70 | userWeixin.setPrivilege(""); | ||
| 71 | userWeixin.setRefreshToken(""); | ||
| 72 | userWeixin.setSex(null); | ||
| 73 | // userWeixin.setSex(0); | ||
| 74 | userWeixin.setSourceDesc(""); | ||
| 75 | userWeixin.setSourceEntity(""); | ||
| 76 | userWeixin.setSourceId(""); | ||
| 77 | userWeixin.setSourceType(""); | ||
| 78 | userWeixin.setSourceUser(0L); | ||
| 79 | userWeixin.setSyncStatus(0); | ||
| 80 | userWeixin.setUnionid("oqDha5lxMuXYMGgT6gyLIFL7VumM"); | ||
| 81 | ResultInfo resultInfo = this.userOperationController.createWeixinUserAndCreateMember(userWeixin); | ||
| 82 | LOG.info("===>>>"+resultInfo); | ||
| 83 | } | ||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | } |
-
Please register or sign in to post a comment