1.添加小程序绑定事件
Showing
5 changed files
with
70 additions
and
15 deletions
... | @@ -22,13 +22,13 @@ import io.swagger.annotations.*; | ... | @@ -22,13 +22,13 @@ import io.swagger.annotations.*; |
22 | import java.util.Objects; | 22 | import java.util.Objects; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * @author XiangHan /api/MemberRelatedInfo | 25 | * @author XiangHan |
26 | * @date 2021-10-22 | 26 | * @date 2021-10-22 |
27 | */ | 27 | */ |
28 | @Slf4j | 28 | @Slf4j |
29 | @Api(tags = "MemberRelatedInfo管理") | 29 | @Api(tags = "MemberRelatedInfo管理") |
30 | @RestController | 30 | @RestController |
31 | @RequestMapping("/ucEngine/api/MemberRelatedInfo") | 31 | @RequestMapping("/ucEngine/api/memberRelatedInfoController") |
32 | @CrossOrigin | 32 | @CrossOrigin |
33 | public class MemberRelatedInfoController { | 33 | public class MemberRelatedInfoController { |
34 | 34 | ... | ... |
... | @@ -15,17 +15,17 @@ import org.springframework.web.bind.annotation.*; | ... | @@ -15,17 +15,17 @@ import org.springframework.web.bind.annotation.*; |
15 | 15 | ||
16 | @Api("会员处理") | 16 | @Api("会员处理") |
17 | @RestController | 17 | @RestController |
18 | @RequestMapping(value = "/ucEngine/api/memberOperation") | 18 | @RequestMapping(value = "/ucEngine/api/memberOperationController") |
19 | public class MemberOperationController { | 19 | public class MemberOperationController { |
20 | 20 | ||
21 | @Autowired | 21 | @Autowired |
22 | private MemberOperationService memberOperationService; | 22 | private MemberOperationService memberOperationService; |
23 | 23 | ||
24 | @Log("获取会员加密信息并且检查vip状态") | 24 | @Log("获取会员加密信息并且检查vip状态") |
25 | @GetMapping("/getMemberProfileAndCheckVip/{memberId}/{appid}") | 25 | @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") |
26 | @ApiOperation("获取会员加密信息并且检查vip状态") | 26 | @ApiOperation("获取会员加密信息并且检查vip状态") |
27 | public IResultInfo getMemberProfileAndCheckVip(@PathVariable Long memberId, @PathVariable String appid) { | 27 | public IResultInfo getMemberProfileAndCheckVip(@PathVariable(value = "appId") String appId, @PathVariable(value = "memberId") Long memberId) { |
28 | MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appid); | 28 | MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId); |
29 | return ResultInfo.success(memberProfileDTO); | 29 | return ResultInfo.success(memberProfileDTO); |
30 | } | 30 | } |
31 | 31 | ... | ... |
1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
2 | 2 | ||
3 | import cn.hutool.core.util.ObjectUtil; | 3 | import cn.hutool.core.util.ObjectUtil; |
4 | import cn.hutool.core.util.StrUtil; | ||
5 | import com.alibaba.druid.support.json.JSONUtils; | ||
6 | import com.alibaba.fastjson.JSON; | ||
7 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
8 | import com.topdraw.annotation.AnonymousAccess; | 5 | import com.topdraw.annotation.AnonymousAccess; |
9 | import com.topdraw.annotation.Log; | 6 | import com.topdraw.annotation.Log; |
10 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 7 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
11 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 8 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
12 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 9 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
13 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | ||
14 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | ||
15 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 10 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
16 | import com.topdraw.business.process.domian.TempIptvUser; | 11 | import com.topdraw.business.process.domian.TempIptvUser; |
17 | import com.topdraw.business.process.domian.UnbindGroup; | 12 | import com.topdraw.business.process.domian.UnbindGroup; |
... | @@ -22,7 +17,6 @@ import com.topdraw.business.process.service.UserOperationService; | ... | @@ -22,7 +17,6 @@ import com.topdraw.business.process.service.UserOperationService; |
22 | import com.topdraw.common.ResultInfo; | 17 | import com.topdraw.common.ResultInfo; |
23 | import com.topdraw.config.RedisKeyUtil; | 18 | import com.topdraw.config.RedisKeyUtil; |
24 | import com.topdraw.exception.BadRequestException; | 19 | import com.topdraw.exception.BadRequestException; |
25 | import com.topdraw.module.mq.DataSyncMsg; | ||
26 | import com.topdraw.util.JSONUtil; | 20 | import com.topdraw.util.JSONUtil; |
27 | import com.topdraw.utils.RedisUtils; | 21 | import com.topdraw.utils.RedisUtils; |
28 | import com.topdraw.utils.StringUtils; | 22 | import com.topdraw.utils.StringUtils; |
... | @@ -51,8 +45,6 @@ public class UserOperationController { | ... | @@ -51,8 +45,6 @@ public class UserOperationController { |
51 | @Autowired | 45 | @Autowired |
52 | private UserOperationService userTvOperationService; | 46 | private UserOperationService userTvOperationService; |
53 | @Autowired | 47 | @Autowired |
54 | private WeiXinRequestUtil weixinRequestUtil; | ||
55 | @Autowired | ||
56 | private RedisUtils redisUtils; | 48 | private RedisUtils redisUtils; |
57 | 49 | ||
58 | @Log("获取大屏绑定的小屏会员列表") | 50 | @Log("获取大屏绑定的小屏会员列表") |
... | @@ -155,6 +147,15 @@ public class UserOperationController { | ... | @@ -155,6 +147,15 @@ public class UserOperationController { |
155 | return ResultInfo.success(result); | 147 | return ResultInfo.success(result); |
156 | } | 148 | } |
157 | 149 | ||
150 | @Log("微信小程序绑定大屏") | ||
151 | @PostMapping("/appletBind") | ||
152 | @ApiOperation("微信小程序绑定大屏") | ||
153 | @AnonymousAccess | ||
154 | public ResultInfo appletBind(@Validated @RequestBody WeiXinUserBean resources) { | ||
155 | UserWeixinDTO result = this.userTvOperationService.appletBind(resources); | ||
156 | return ResultInfo.success(result); | ||
157 | } | ||
158 | |||
158 | @Log("微信公众号关注") | 159 | @Log("微信公众号关注") |
159 | @PostMapping("/subscribe") | 160 | @PostMapping("/subscribe") |
160 | @ApiOperation("微信公众号关注") | 161 | @ApiOperation("微信公众号关注") | ... | ... |
... | @@ -107,4 +107,11 @@ public interface UserOperationService { | ... | @@ -107,4 +107,11 @@ public interface UserOperationService { |
107 | * @return | 107 | * @return |
108 | */ | 108 | */ |
109 | Object serviceLogin(WeiXinUserBean resources); | 109 | Object serviceLogin(WeiXinUserBean resources); |
110 | |||
111 | /** | ||
112 | * 小程序绑定大屏 | ||
113 | * @param resources | ||
114 | * @return | ||
115 | */ | ||
116 | UserWeixinDTO appletBind(WeiXinUserBean resources); | ||
110 | } | 117 | } | ... | ... |
... | @@ -475,7 +475,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -475,7 +475,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
475 | // 保存或者修改,微信账户信息 | 475 | // 保存或者修改,微信账户信息 |
476 | UserWeixinDTO userWeixinDTO = this.doCreateUserWeiXin(userWeixin, memberId); | 476 | UserWeixinDTO userWeixinDTO = this.doCreateUserWeiXin(userWeixin, memberId); |
477 | 477 | ||
478 | return userWeixinDTO; | 478 | // 为了保证返回的同一用户 |
479 | UserWeixinDTO userWeixinDTO_0 = this.getFirstId(userWeixinDTO); | ||
480 | return userWeixinDTO_0; | ||
479 | } | 481 | } |
480 | 482 | ||
481 | /** | 483 | /** |
... | @@ -1188,6 +1190,51 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1188,6 +1190,51 @@ public class UserOperationServiceImpl implements UserOperationService { |
1188 | return userWeixinDTO_0; | 1190 | return userWeixinDTO_0; |
1189 | } | 1191 | } |
1190 | 1192 | ||
1193 | @Override | ||
1194 | public UserWeixinDTO appletBind(WeiXinUserBean resources) { | ||
1195 | /*Optional<UserWeixin> userWeixinOptional = userWeixinRepository.findById(criteria.getId()); | ||
1196 | if (!userWeixinOptional.isPresent()) { | ||
1197 | throw new EntityNotFoundException(UserWeixin.class, "id", criteria.getId().toString()); | ||
1198 | } | ||
1199 | UserWeixin userWeixin = userWeixinOptional.get(); | ||
1200 | Member weixinMember = userWeixin.getMember(); | ||
1201 | String unionid = criteria.getUnionid(); | ||
1202 | |||
1203 | Long personId = null; | ||
1204 | |||
1205 | // 前端先校验绑定状态,若已绑定会予以提示,进一步操作,可能会产生换绑 | ||
1206 | // 小屏账号关联person,且已进行了授权 | ||
1207 | if (ObjectUtil.isNull(weixinMember) && StrUtil.isNotBlank(unionid)) { | ||
1208 | //第一次绑定 | ||
1209 | // 微信用户unionid为空,或者与传到unionid一致,否则报错 | ||
1210 | Assert.state(StrUtil.isBlank(userWeixin.getUnionid()) || ObjectUtil.equals(userWeixin.getUnionid(), unionid), "用户信息有误,请重新授权"); | ||
1211 | |||
1212 | userWeixin.setUnionid(unionid); | ||
1213 | Member member = getOrGenerateMobileMember(userWeixin, null); | ||
1214 | personId = member.getId(); | ||
1215 | } else if (ObjectUtil.isNotNull(weixinMember)) { | ||
1216 | personId = weixinMember.getId(); | ||
1217 | personCode = weixinMember.getCode(); | ||
1218 | } | ||
1219 | |||
1220 | TvUserQueryCriteria tvUserQueryCriteria = new TvUserQueryCriteria(); | ||
1221 | tvUserQueryCriteria.setPlatformAccount(criteria.getPlatformUserId()); | ||
1222 | List<TvUserDTO> tvUsers = tvUserService.queryAll(tvUserQueryCriteria); | ||
1223 | // 理论上,大屏账号在创建/修改时,会同步到此侧,查不到可能是传值有误,或还未同步过来 | ||
1224 | Assert.notEmpty(tvUsers, "大屏账号不存在,请检查或稍后重试"); | ||
1225 | TvUser tvUser = tvUserMapper.toEntity(tvUsers.get(0)); | ||
1226 | |||
1227 | // 更新关联的大屏账号 | ||
1228 | // personService.updateBindTvUser(personCode, tvUser.getId()); | ||
1229 | weixinMember.setUserIptvId(tvUser.getId()); | ||
1230 | weixinMember.setBindIptvTime(new Timestamp(System.currentTimeMillis())); | ||
1231 | weixinMember.setBindIptvPlatformType(1); | ||
1232 | memberService.update(weixinMember); | ||
1233 | userWeixin.setMemberId(personId); | ||
1234 | update(userWeixin);*/ | ||
1235 | return null; | ||
1236 | } | ||
1237 | |||
1191 | /** | 1238 | /** |
1192 | * 同一用户有多个微信APP的情况下展示同一个账户信息 | 1239 | * 同一用户有多个微信APP的情况下展示同一个账户信息 |
1193 | * 原则:那个先创建就用那个id | 1240 | * 原则:那个先创建就用那个id | ... | ... |
-
Please register or sign in to post a comment