Commit 3a9035d7 3a9035d7a17255bd48ec74fe1718001f1361754d by xianghan@topdraw.cn

1.添加修改会员相关人员验证条件

2.转移h5登录接口
3.微信相关事件实现逻辑
1 parent 5ffd851f
...@@ -5,6 +5,8 @@ import lombok.experimental.Accessors; ...@@ -5,6 +5,8 @@ import lombok.experimental.Accessors;
5 import cn.hutool.core.bean.BeanUtil; 5 import cn.hutool.core.bean.BeanUtil;
6 import cn.hutool.core.bean.copier.CopyOptions; 6 import cn.hutool.core.bean.copier.CopyOptions;
7 import javax.persistence.*; 7 import javax.persistence.*;
8 import javax.validation.constraints.NotNull;
9
8 import org.springframework.data.annotation.CreatedDate; 10 import org.springframework.data.annotation.CreatedDate;
9 import org.springframework.data.annotation.LastModifiedDate; 11 import org.springframework.data.annotation.LastModifiedDate;
10 import org.springframework.data.jpa.domain.support.AuditingEntityListener; 12 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
...@@ -28,6 +30,7 @@ public class MemberRelatedInfo implements Serializable { ...@@ -28,6 +30,7 @@ public class MemberRelatedInfo implements Serializable {
28 @Id 30 @Id
29 @GeneratedValue(strategy = GenerationType.IDENTITY) 31 @GeneratedValue(strategy = GenerationType.IDENTITY)
30 @Column(name = "id") 32 @Column(name = "id")
33 @NotNull(groups = {UpdateGroup.class})
31 private Long id; 34 private Long id;
32 35
33 // 会员id 36 // 会员id
......
1 package com.topdraw.business.module.member.relatedinfo.domain;
2
3 public interface UpdateGroup {
4 }
1 package com.topdraw.business.module.member.relatedinfo.rest; 1 package com.topdraw.business.module.member.relatedinfo.rest;
2 2
3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.member.relatedinfo.domain.UpdateGroup;
5 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
3 import com.topdraw.business.module.member.service.MemberService; 6 import com.topdraw.business.module.member.service.MemberService;
4 import com.topdraw.business.module.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.member.service.dto.MemberDTO;
5 import com.topdraw.common.ResultInfo; 8 import com.topdraw.common.ResultInfo;
...@@ -7,6 +10,8 @@ import com.topdraw.annotation.Log; ...@@ -7,6 +10,8 @@ import com.topdraw.annotation.Log;
7 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; 10 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
8 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService; 11 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
9 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; 12 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
13 import com.topdraw.exception.BadRequestException;
14 import lombok.extern.slf4j.Slf4j;
10 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.data.domain.Pageable; 16 import org.springframework.data.domain.Pageable;
12 import org.springframework.util.Assert; 17 import org.springframework.util.Assert;
...@@ -20,9 +25,10 @@ import java.util.Objects; ...@@ -20,9 +25,10 @@ import java.util.Objects;
20 * @author XiangHan /api/MemberRelatedInfo 25 * @author XiangHan /api/MemberRelatedInfo
21 * @date 2021-10-22 26 * @date 2021-10-22
22 */ 27 */
28 @Slf4j
23 @Api(tags = "MemberRelatedInfo管理") 29 @Api(tags = "MemberRelatedInfo管理")
24 @RestController 30 @RestController
25 @RequestMapping("/api/MemberRelatedInfo") 31 @RequestMapping("/ucEngine/api/MemberRelatedInfo")
26 @CrossOrigin 32 @CrossOrigin
27 public class MemberRelatedInfoController { 33 public class MemberRelatedInfoController {
28 34
...@@ -45,14 +51,20 @@ public class MemberRelatedInfoController { ...@@ -45,14 +51,20 @@ public class MemberRelatedInfoController {
45 return ResultInfo.success(); 51 return ResultInfo.success();
46 } 52 }
47 53
48 @Log 54 @Log("修改MemberRelatedInfo")
49 @PutMapping(value = "/update") 55 @PutMapping(value = "/update")
50 @ApiOperation("修改MemberRelatedInfo") 56 @ApiOperation("修改MemberRelatedInfo")
51 public ResultInfo update(@Validated @RequestBody MemberRelatedInfo resources) { 57 @AnonymousAccess
52 Long memberId = resources.getMemberId(); 58 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberRelatedInfo resources) {
53 String idCard = resources.getIdCard(); 59 Long id = resources.getId();
54 Assert.notNull(memberId,"memberId can't be null"); 60 MemberRelatedInfoDTO memberRelatedInfoDTO = this.MemberRelatedInfoService.findById(id);
55 Assert.notNull(idCard,"idCard can't be null"); 61 if (memberRelatedInfoDTO.getId() != null) {
62 Long memberId = memberRelatedInfoDTO.getMemberId();
63 if (Objects.isNull(memberId)) {
64 log.info("id ==>> [{}]",id);
65 throw new BadRequestException("memberId is null! please check member info");
66 }
67
56 MemberDTO memberDTO = this.memberService.findById(memberId); 68 MemberDTO memberDTO = this.memberService.findById(memberId);
57 if (Objects.nonNull(memberDTO)) { 69 if (Objects.nonNull(memberDTO)) {
58 String code = memberDTO.getCode(); 70 String code = memberDTO.getCode();
...@@ -60,6 +72,8 @@ public class MemberRelatedInfoController { ...@@ -60,6 +72,8 @@ public class MemberRelatedInfoController {
60 resources.setMemberCode(code); 72 resources.setMemberCode(code);
61 MemberRelatedInfoService.update(resources); 73 MemberRelatedInfoService.update(resources);
62 } 74 }
75 }
76
63 return ResultInfo.success(); 77 return ResultInfo.success();
64 } 78 }
65 79
......
...@@ -14,6 +14,9 @@ import java.time.LocalDateTime; ...@@ -14,6 +14,9 @@ import java.time.LocalDateTime;
14 @Data 14 @Data
15 public class MemberDTO implements Serializable { 15 public class MemberDTO implements Serializable {
16 16
17 // iptv绑定的主会员 0:否 1:是
18 private Integer iptvMajor;
19
17 // vip过期时间 20 // vip过期时间
18 private LocalDateTime vipExpireTime; 21 private LocalDateTime vipExpireTime;
19 22
......
1 package com.topdraw.business.module.user.weixin.service.dto; 1 package com.topdraw.business.module.user.weixin.service.dto;
2 2
3 import com.topdraw.annotation.Query;
3 import lombok.Data; 4 import lombok.Data;
4 5
5 /** 6 /**
...@@ -9,6 +10,7 @@ import lombok.Data; ...@@ -9,6 +10,7 @@ import lombok.Data;
9 @Data 10 @Data
10 public class UserWeixinQueryCriteria{ 11 public class UserWeixinQueryCriteria{
11 12
12 13 @Query()
14 private String unionId;
13 15
14 } 16 }
......
...@@ -38,7 +38,6 @@ import org.springframework.validation.annotation.Validated; ...@@ -38,7 +38,6 @@ import org.springframework.validation.annotation.Validated;
38 import org.springframework.web.bind.annotation.*; 38 import org.springframework.web.bind.annotation.*;
39 39
40 import java.io.IOException; 40 import java.io.IOException;
41 import java.util.HashMap;
42 import java.util.List; 41 import java.util.List;
43 import java.util.Map; 42 import java.util.Map;
44 import java.util.Objects; 43 import java.util.Objects;
...@@ -119,6 +118,7 @@ public class UserOperationController { ...@@ -119,6 +118,7 @@ public class UserOperationController {
119 @Log("大屏用户解绑") 118 @Log("大屏用户解绑")
120 @PutMapping(value = "/unbind") 119 @PutMapping(value = "/unbind")
121 @ApiOperation("大屏用户解绑") 120 @ApiOperation("大屏用户解绑")
121 @AnonymousAccess
122 public ResultInfo unbind(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) { 122 public ResultInfo unbind(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) {
123 UserTv userTv = new UserTv(); 123 UserTv userTv = new UserTv();
124 BeanUtils.copyProperties(resources,userTv); 124 BeanUtils.copyProperties(resources,userTv);
...@@ -129,6 +129,7 @@ public class UserOperationController { ...@@ -129,6 +129,7 @@ public class UserOperationController {
129 @Log("大屏更换主账号") 129 @Log("大屏更换主账号")
130 @PutMapping(value = "/changeMainAccount") 130 @PutMapping(value = "/changeMainAccount")
131 @ApiOperation("大屏更换主账号") 131 @ApiOperation("大屏更换主账号")
132 @AnonymousAccess
132 public ResultInfo changeMainAccount(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) { 133 public ResultInfo changeMainAccount(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) {
133 UserTv userTv = new UserTv(); 134 UserTv userTv = new UserTv();
134 BeanUtils.copyProperties(resources,userTv); 135 BeanUtils.copyProperties(resources,userTv);
...@@ -136,6 +137,15 @@ public class UserOperationController { ...@@ -136,6 +137,15 @@ public class UserOperationController {
136 return ResultInfo.success("update success"); 137 return ResultInfo.success("update success");
137 } 138 }
138 139
140 @Log("微信服务号(H5)登录")
141 @PostMapping("/serviceLogin")
142 @ApiOperation("微信服务号(H5)登录")
143 @AnonymousAccess
144 public ResultInfo serviceLogin(@Validated @RequestBody WeiXinUserBean resources) {
145 Object o = this.userTvOperationService.serviceLogin(resources);
146 return ResultInfo.success(o);
147 }
148
139 @Log("微信小程序登录") 149 @Log("微信小程序登录")
140 @PostMapping("/appletLogin") 150 @PostMapping("/appletLogin")
141 @ApiOperation("微信小程序登录") 151 @ApiOperation("微信小程序登录")
...@@ -187,7 +197,9 @@ public class UserOperationController { ...@@ -187,7 +197,9 @@ public class UserOperationController {
187 throw new BadRequestException("非订阅号"); 197 throw new BadRequestException("非订阅号");
188 198
189 // 用户类型 199 // 用户类型
190 JSONObject userInfo = weixinRequestUtil.getUserInfo(wxInfoMap, openId); 200 // JSONObject userInfo = weixinRequestUtil.getUserInfo(wxInfoMap, openId);
201 JSONObject userInfo = new JSONObject();
202 userInfo.put("unionid","oqDha5idQxR0WGPW2qHi-meHRtyg");
191 log.info("userInfo is : {}", userInfo.toJSONString()); 203 log.info("userInfo is : {}", userInfo.toJSONString());
192 unionId = userInfo.get("unionid").toString(); 204 unionId = userInfo.get("unionid").toString();
193 205
...@@ -212,10 +224,13 @@ public class UserOperationController { ...@@ -212,10 +224,13 @@ public class UserOperationController {
212 } else { 224 } else {
213 225
214 String eventKey = subscribeBean.getEventKey(); 226 String eventKey = subscribeBean.getEventKey();
227
228 if (StringUtils.isNotBlank(eventKey)) {
215 // 用户扫描带参二维码关注。发消息 229 // 用户扫描带参二维码关注。发消息
216 // 去除固定前缀,获取二维码参数 230 // 去除固定前缀,获取二维码参数
217 eventKey = eventKey.substring(8); 231 eventKey = eventKey.substring(8);
218 iptvUserInfo = com.alibaba.fastjson.JSONObject.parseObject(eventKey); 232 iptvUserInfo = JSONObject.parseObject(eventKey);
233 }
219 234
220 } 235 }
221 236
...@@ -224,10 +239,6 @@ public class UserOperationController { ...@@ -224,10 +239,6 @@ public class UserOperationController {
224 subscribeBean.setIptvUserInfo(iptvUserInfo); 239 subscribeBean.setIptvUserInfo(iptvUserInfo);
225 } 240 }
226 241
227
228 // 之后删除缓存信息
229 this.redisUtils.del(RedisKeyUtil.genSeSuSubscribeKey(unionId));
230
231 } 242 }
232 } 243 }
233 244
......
...@@ -12,29 +12,99 @@ import java.util.List; ...@@ -12,29 +12,99 @@ import java.util.List;
12 12
13 public interface UserOperationService { 13 public interface UserOperationService {
14 14
15 /**
16 * 保存大屏账户并创建会员
17 * @param resources
18 * @return
19 */
15 boolean createMemberByUserTv(UserTv resources); 20 boolean createMemberByUserTv(UserTv resources);
16 21
22 /**
23 * 大屏解绑
24 * @param userTv
25 */
17 void unbind(UserTv userTv); 26 void unbind(UserTv userTv);
18 27
28 /**
29 * 大屏切换主账户(会员)
30 * @param userTv
31 */
19 void changeMainAccount(UserTv userTv); 32 void changeMainAccount(UserTv userTv);
20 33
34 /**
35 * 微信小程序登录
36 * @param resources
37 * @return
38 */
21 UserWeixinDTO appletLogin(WeiXinUserBean resources); 39 UserWeixinDTO appletLogin(WeiXinUserBean resources);
22 40
41 /**
42 * 微信公众号关注
43 * @param resources
44 * @return
45 */
23 boolean subscribe(SubscribeBean resources); 46 boolean subscribe(SubscribeBean resources);
24 47
48 /**
49 * 微信公众号取关
50 * @param resources
51 * @return
52 */
25 boolean unsubscribe(SubscribeBean resources); 53 boolean unsubscribe(SubscribeBean resources);
26 54
55 /**
56 * 保存账户
57 * @param data
58 * @return
59 */
27 String saveUserInfo(String data); 60 String saveUserInfo(String data);
28 61
62 /**
63 * 获取用户授权并解析、保存用户手机号
64 * @param resources
65 * @return
66 */
29 MemberProfile saveUserWeixinPhone(WeiXinUserBean resources); 67 MemberProfile saveUserWeixinPhone(WeiXinUserBean resources);
30 68
69 /**
70 *
71 * @param content
72 * @return
73 */
31 boolean sendQrCodeMessage(String content); 74 boolean sendQrCodeMessage(String content);
32 75
76 /**
77 * 大屏删除所有收藏
78 * @param content
79 * @return
80 */
33 boolean deleteAllCollection(String content); 81 boolean deleteAllCollection(String content);
34 82
83 /**
84 * 大屏删除收藏
85 * @param content
86 * @return
87 */
35 boolean deleteCollection(String content); 88 boolean deleteCollection(String content);
36 89
90 /**
91 * 大屏收藏
92 * @param content
93 * @return
94 */
37 boolean addCollection(String content); 95 boolean addCollection(String content);
38 96
97 /**
98 * 获取大屏绑定的小屏会员列表
99 * @param platformAccount
100 * @return
101 */
39 List<MemberDTO> findBindByPlatformAccount(String platformAccount); 102 List<MemberDTO> findBindByPlatformAccount(String platformAccount);
103
104 /**
105 * 服务号(H5)登录
106 * @param resources
107 * @return
108 */
109 Object serviceLogin(WeiXinUserBean resources);
40 } 110 }
......