Commit ea595e3b ea595e3bf7a5bb77eb2db8ddc6e2ae54a9c7f1e4 by xianghan

1.修复app账号兼容海南历史数据

1 parent f82147af
...@@ -31,6 +31,9 @@ public class UserAppIdManual implements Serializable { ...@@ -31,6 +31,9 @@ public class UserAppIdManual implements Serializable {
31 @Transient 31 @Transient
32 private String account; 32 private String account;
33 33
34 @Transient
35 private String memberCode;
36
34 // ID 37 // ID
35 @Id 38 @Id
36 @GeneratedValue(strategy = GenerationType.SEQUENCE) 39 @GeneratedValue(strategy = GenerationType.SEQUENCE)
......
...@@ -50,6 +50,11 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec ...@@ -50,6 +50,11 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec
50 Integer updateAppLastActiveTimeAndNicknameAndHeadImg(String username, String nickname, String headimgurl); 50 Integer updateAppLastActiveTimeAndNicknameAndHeadImg(String username, String nickname, String headimgurl);
51 51
52 @Modifying 52 @Modifying
53 @Query(value = "UPDATE `uc_user_app` SET `cellphone`= :#{#resources.cellphone}, `username`= :#{#resources.username},`last_active_time` = now(), `nickname` = :#{#resources.nickname}, `headimgurl` = :#{#resources.headimgurl} " +
54 " WHERE `id` = :#{#resources.id} and `status` = 1 ", nativeQuery = true)
55 Integer updateAppLastActiveTimeAndNicknameAndHeadImgById(@Param("resources") UserApp userApp);
56
57 @Modifying
53 @Query(value = "INSERT INTO `uc_user_app`(`id`, `member_id`, `username`, `password`, `type`, `status`, `nickname`, `headimgurl`, `email`, `cellphone`, `gender`, `birthday`, `last_active_time`, `delete_time`, `tags`, `description`, `create_time`, `update_time`) " + 58 @Query(value = "INSERT INTO `uc_user_app`(`id`, `member_id`, `username`, `password`, `type`, `status`, `nickname`, `headimgurl`, `email`, `cellphone`, `gender`, `birthday`, `last_active_time`, `delete_time`, `tags`, `description`, `create_time`, `update_time`) " +
54 " VALUES (:#{#resources.id}, :#{#resources.memberId}, :#{#resources.username}, :#{#resources.password}, :#{#resources.type}," + 59 " VALUES (:#{#resources.id}, :#{#resources.memberId}, :#{#resources.username}, :#{#resources.password}, :#{#resources.type}," +
55 " 1, :#{#resources.nickname}, :#{#resources.headimgurl}, :#{#resources.email}, :#{#resources.cellphone}, " + 60 " 1, :#{#resources.nickname}, :#{#resources.headimgurl}, :#{#resources.email}, :#{#resources.cellphone}, " +
......
...@@ -6,6 +6,7 @@ import com.topdraw.business.module.user.app.domain.UserAppBind; ...@@ -6,6 +6,7 @@ import com.topdraw.business.module.user.app.domain.UserAppBind;
6 import com.topdraw.business.module.user.app.service.UserAppBindService; 6 import com.topdraw.business.module.user.app.service.UserAppBindService;
7 import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; 7 import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
8 import com.topdraw.business.module.user.app.service.dto.UserAppDTO; 8 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
9 import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
9 import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; 10 import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
10 import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; 11 import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
11 import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; 12 import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
...@@ -37,6 +38,22 @@ public class UserAppController { ...@@ -37,6 +38,22 @@ public class UserAppController {
37 private UserAppBindService userAppBindService; 38 private UserAppBindService userAppBindService;
38 39
39 @Log 40 @Log
41 @PostMapping(value = "/saveAppAndBindApple4Vis")
42 @ApiOperation("兼容海南app苹果数据")
43 @AnonymousAccess
44 public ResultInfo saveAppAndBindApple4Vis(@Validated @RequestBody VisUserApple resources) {
45 log.info("兼容海南app苹果数据,参数 ==>> [saveAppAndBindApple4Vis#{}]", resources);
46 String user = resources.getUser();
47
48 if (StringUtils.isBlank(user)) {
49 log.error("兼容海南app苹果数据,参数错误,app账号不得为空,[saveAppAndBindApple4Vis#{}]", resources);
50 return ResultInfo.failure("兼容海南app苹果数据,参数错误,app账号不得为空");
51 }
52
53 return this.userAppService.saveAppAndBindApple4Vis(resources);
54 }
55
56 @Log
40 @PostMapping(value = "/saveAppAndBindWeibo4Vis") 57 @PostMapping(value = "/saveAppAndBindWeibo4Vis")
41 @ApiOperation("兼容海南app原微博数据") 58 @ApiOperation("兼容海南app原微博数据")
42 @AnonymousAccess 59 @AnonymousAccess
...@@ -46,7 +63,7 @@ public class UserAppController { ...@@ -46,7 +63,7 @@ public class UserAppController {
46 63
47 if (StringUtils.isBlank(userId)) { 64 if (StringUtils.isBlank(userId)) {
48 log.error("兼容海南app原weibo数据,参数错误,app账号不得为空,[saveAppAndBindWeibo4Vis#{}]", resources); 65 log.error("兼容海南app原weibo数据,参数错误,app账号不得为空,[saveAppAndBindWeibo4Vis#{}]", resources);
49 return ResultInfo.failure("修改app账号密码失败,参数错误,app账号不得为空"); 66 return ResultInfo.failure("兼容海南app原weibo数据,参数错误,app账号不得为空");
50 } 67 }
51 68
52 return this.userAppService.saveAppAndBindWeibo4Vis(resources); 69 return this.userAppService.saveAppAndBindWeibo4Vis(resources);
...@@ -61,7 +78,7 @@ public class UserAppController { ...@@ -61,7 +78,7 @@ public class UserAppController {
61 String openid = resources.getOpenid(); 78 String openid = resources.getOpenid();
62 if (StringUtils.isBlank(openid)) { 79 if (StringUtils.isBlank(openid)) {
63 log.error("兼容海南app原QQ数据,参数错误,app账号不得为空,[saveAppAndBindWeibo4Vis#{}]", resources); 80 log.error("兼容海南app原QQ数据,参数错误,app账号不得为空,[saveAppAndBindWeibo4Vis#{}]", resources);
64 return ResultInfo.failure("修改app账号密码失败,参数错误,无openid"); 81 return ResultInfo.failure("兼容海南app原QQ数据,参数错误,无openid");
65 } 82 }
66 83
67 return this.userAppService.saveAppAndBindQq4Vis(resources); 84 return this.userAppService.saveAppAndBindQq4Vis(resources);
...@@ -77,14 +94,14 @@ public class UserAppController { ...@@ -77,14 +94,14 @@ public class UserAppController {
77 String openid = resources.getOpenid(); 94 String openid = resources.getOpenid();
78 if (StringUtils.isBlank(openid)) { 95 if (StringUtils.isBlank(openid)) {
79 log.error("兼容海南app原微信数据,参数错误,app账号不得为空,[saveAppAndBindWeixin4Vis#{}]", resources); 96 log.error("兼容海南app原微信数据,参数错误,app账号不得为空,[saveAppAndBindWeixin4Vis#{}]", resources);
80 return ResultInfo.failure("兼容海南app原微信数据失败,参数错误,无openid"); 97 return ResultInfo.failure("兼容海南app原微信数据,参数错误,无openid");
81 } 98 }
82 99
83 String username = resources.getUsername(); 100 /*String username = resources.getUsername();
84 if (StringUtils.isBlank(username)) { 101 if (StringUtils.isBlank(username)) {
85 log.error("兼容海南app原微信数据,参数错误,app账号不得为空,[saveAppAndBindWeixin4Vis#{}]", resources); 102 log.error("兼容海南app原微信数据,参数错误,app账号不得为空,[saveAppAndBindWeixin4Vis#{}]", resources);
86 return ResultInfo.failure("兼容海南app原微信数据失败,参数错误,无username"); 103 return ResultInfo.failure("兼容海南app原微信数据失败,参数错误,无username");
87 } 104 }*/
88 105
89 return this.userAppService.saveAppAndBindWeixin4Vis(resources); 106 return this.userAppService.saveAppAndBindWeixin4Vis(resources);
90 107
...@@ -92,14 +109,37 @@ public class UserAppController { ...@@ -92,14 +109,37 @@ public class UserAppController {
92 109
93 110
94 @Log 111 @Log
112 @PostMapping(value = "/updateAppLastActiveTimeAndNicknameAndHeadImgById")
113 @ApiOperation("修改app账号最后登录时间、昵称和头像和用户名")
114 @AnonymousAccess
115 public ResultInfo updateAppLastActiveTimeAndNicknameAndHeadImgById(@Validated @RequestBody UserApp resources) {
116 log.info("修改app账号最后登录时间、昵称和头像和用户名,参数 ==>> [updatePassword#{}]", resources);
117
118 Long id = resources.getId();
119 if (Objects.isNull(id)) {
120 log.error("修改app账号最后登录时间、昵称和头像和用户名,参数错误,id不存在,[updateAppLastActiveTimeAndNicknameAndHeadImgById#{}]", resources);
121 return ResultInfo.failure("修改app账号密码失败,参数错误,app账号不得为空");
122 }
123
124 String username = resources.getUsername();
125 if (StringUtils.isBlank(username)) {
126 log.error("修改app账号最后登录时间、昵称和头像和用户名,参数错误,app账号不得为空,[updateAppLastActiveTimeAndNicknameAndHeadImgById#{}]", resources);
127 return ResultInfo.failure("修改app账号最后登录时间、昵称和头像和用户名失败,参数错误,app账号不得为空");
128 }
129
130 boolean result = this.userAppService.updateAppLastActiveTimeAndNicknameAndHeadImgById(resources);
131 return ResultInfo.success(result);
132 }
133
134 @Log
95 @PostMapping(value = "/updateAppLastActiveTimeAndNicknameAndHeadImg") 135 @PostMapping(value = "/updateAppLastActiveTimeAndNicknameAndHeadImg")
96 @ApiOperation("修改app账号最后登录时间、昵称和头像") 136 @ApiOperation("修改app账号最后登录时间、昵称和头像")
97 @AnonymousAccess 137 @AnonymousAccess
98 public ResultInfo updateAppLastActiveTimeAndNicknameAndHeadImg(@Validated @RequestBody UserApp resources) { 138 public ResultInfo updateAppLastActiveTimeAndNicknameAndHeadImg(@Validated @RequestBody UserApp resources) {
99 log.info("修改app账号密码,参数 ==>> [updatePassword#{}]", resources); 139 log.info("修改app账号密码,参数 ==>> [updateAppLastActiveTimeAndNicknameAndHeadImg#{}]", resources);
100 String username = resources.getUsername(); 140 String username = resources.getUsername();
101 if (StringUtils.isBlank(username)) { 141 if (StringUtils.isBlank(username)) {
102 log.error("修改app账号密码,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources); 142 log.error("修改app账号密码,参数错误,app账号不得为空,[updateAppLastActiveTimeAndNicknameAndHeadImg#{}]", resources);
103 return ResultInfo.failure("修改app账号密码失败,参数错误,app账号不得为空"); 143 return ResultInfo.failure("修改app账号密码失败,参数错误,app账号不得为空");
104 } 144 }
105 145
...@@ -140,7 +180,7 @@ public class UserAppController { ...@@ -140,7 +180,7 @@ public class UserAppController {
140 @ApiOperation("修改app账号最新登录时间") 180 @ApiOperation("修改app账号最新登录时间")
141 @AnonymousAccess 181 @AnonymousAccess
142 public ResultInfo updateLastActiveTime(@Validated @RequestBody UserAppBind resources) { 182 public ResultInfo updateLastActiveTime(@Validated @RequestBody UserAppBind resources) {
143 log.info("保存第三方账号 ==>> param ==>> [updateLastActiveTime#{}]", resources); 183 log.info("修改app账号最新登录时间 ==>> param ==>> [updateLastActiveTime#{}]", resources);
144 String username = resources.getUsername(); 184 String username = resources.getUsername();
145 if (StringUtils.isBlank(username)) { 185 if (StringUtils.isBlank(username)) {
146 log.error("修改app账号最新登录时间失败,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources); 186 log.error("修改app账号最新登录时间失败,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources);
......
...@@ -4,6 +4,7 @@ import com.topdraw.business.module.user.app.domain.UserApp; ...@@ -4,6 +4,7 @@ import com.topdraw.business.module.user.app.domain.UserApp;
4 import com.topdraw.business.module.user.app.domain.UserAppBind; 4 import com.topdraw.business.module.user.app.domain.UserAppBind;
5 import com.topdraw.business.module.user.app.service.dto.UserAppDTO; 5 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
6 import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; 6 import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
7 import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
7 import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; 8 import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
8 import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; 9 import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
9 import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; 10 import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
...@@ -82,6 +83,10 @@ public interface UserAppService { ...@@ -82,6 +83,10 @@ public interface UserAppService {
82 83
83 boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources); 84 boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources);
84 85
86 boolean updateAppLastActiveTimeAndNicknameAndHeadImgById(UserApp resources);
87
88 ResultInfo saveAppAndBindApple4Vis(VisUserApple resources);
89
85 ResultInfo saveAppAndBindWeibo4Vis(VisUserWeibo resources); 90 ResultInfo saveAppAndBindWeibo4Vis(VisUserWeibo resources);
86 91
87 ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources); 92 ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources);
......
1 package com.topdraw.business.module.user.app.service.impl; 1 package com.topdraw.business.module.user.app.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend;
3 import com.topdraw.business.module.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.domain.MemberBuilder; 5 import com.topdraw.business.module.member.domain.MemberBuilder;
5 import com.topdraw.business.module.member.domain.MemberTypeConstant; 6 import com.topdraw.business.module.member.domain.MemberTypeConstant;
...@@ -16,10 +17,11 @@ import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; ...@@ -16,10 +17,11 @@ import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
16 import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; 17 import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
17 import com.topdraw.business.module.vis.hainan.app.service.VisUserService; 18 import com.topdraw.business.module.vis.hainan.app.service.VisUserService;
18 import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO; 19 import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO;
20 import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
21 import com.topdraw.business.module.vis.hainan.apple.service.VisUserAppleService;
19 import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; 22 import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
20 import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; 23 import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
21 import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; 24 import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
22 import com.topdraw.business.module.vis.hainan.weixin.repository.VisUserWeixinRepository;
23 import com.topdraw.common.ResultInfo; 25 import com.topdraw.common.ResultInfo;
24 import com.topdraw.util.TimestampUtil; 26 import com.topdraw.util.TimestampUtil;
25 import com.topdraw.utils.StringUtils; 27 import com.topdraw.utils.StringUtils;
...@@ -29,6 +31,7 @@ import com.topdraw.business.module.user.app.service.UserAppService; ...@@ -29,6 +31,7 @@ import com.topdraw.business.module.user.app.service.UserAppService;
29 import com.topdraw.business.module.user.app.service.dto.UserAppDTO; 31 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
30 import com.topdraw.business.module.user.app.service.mapper.UserAppMapper; 32 import com.topdraw.business.module.user.app.service.mapper.UserAppMapper;
31 import lombok.extern.slf4j.Slf4j; 33 import lombok.extern.slf4j.Slf4j;
34 import org.springframework.aop.framework.AopContext;
32 import org.springframework.beans.BeanUtils; 35 import org.springframework.beans.BeanUtils;
33 import org.springframework.beans.factory.annotation.Autowired; 36 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.stereotype.Service; 37 import org.springframework.stereotype.Service;
...@@ -61,6 +64,8 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -61,6 +64,8 @@ public class UserAppServiceImpl implements UserAppService {
61 private VisUserService visUserService; 64 private VisUserService visUserService;
62 @Autowired 65 @Autowired
63 private UserAppBindService userAppBindService; 66 private UserAppBindService userAppBindService;
67 @Autowired
68 private VisUserAppleService visUserAppleService;
64 69
65 70
66 @Override 71 @Override
...@@ -165,6 +170,103 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -165,6 +170,103 @@ public class UserAppServiceImpl implements UserAppService {
165 } 170 }
166 171
167 @Override 172 @Override
173 @Transactional(rollbackFor = Exception.class)
174 public boolean updateAppLastActiveTimeAndNicknameAndHeadImgById(UserApp resources) {
175 Integer count = this.userAppRepository.updateAppLastActiveTimeAndNicknameAndHeadImgById(resources);
176 if (count > 0) {
177 ((UserAppServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImgById(resources);
178 return true;
179 }
180
181 return false;
182 }
183
184 @Override
185 @Transactional(rollbackFor = Exception.class)
186 public ResultInfo saveAppAndBindApple4Vis(VisUserApple resources) {
187 String username = resources.getUsername();
188 UserAppDTO userAppDTO = this.findByUsername(username);
189
190 if (Objects.nonNull(userAppDTO.getId()) && StringUtils.isNotBlank(userAppDTO.getHeadimgurl())) {
191
192 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getUser(), 6);
193 if (Objects.nonNull(userAppBindDTO.getId())) {
194
195 UserAppBind userAppBind = new UserAppBind();
196 userAppBind.setAccount(resources.getUser());
197 userAppBind.setAccountType(6);
198 userAppBind.setUserAppId(userAppDTO.getId());
199 userAppBind.setStatus(1);
200 userAppBind.setNickname(resources.getNickname());
201 userAppBind.setHeadimgurl(resources.getIcon());
202 this.userAppBindService.create(userAppBind);
203 }
204
205 return ResultInfo.success(userAppDTO);
206 }
207
208 Long visUserId = resources.getVisUserId();
209 VisUserDTO visUserDTO = this.visUserService.findById(visUserId);
210 if (Objects.nonNull(visUserDTO.getId())) {
211
212 UserAppIdManual userAppIdManual = new UserAppIdManual();
213
214 Long id = visUserDTO.getId();
215 userAppIdManual.setId(id);
216
217 userAppIdManual.setUsername(StringUtils.isBlank(username) ? resources.getUsername() : username);
218
219 String cellphone = visUserDTO.getCellphone();
220 userAppIdManual.setCellphone(StringUtils.isBlank(cellphone) ? resources.getUsername() : cellphone);
221
222 String nickname = visUserDTO.getNickname();
223 userAppIdManual.setNickname(StringUtils.isBlank(nickname) ? resources.getNickname() : nickname);
224
225 Integer gender = visUserDTO.getGender();
226 userAppIdManual.setGender(Objects.isNull(gender) ? -1 : gender);
227
228 userAppIdManual.setHeadimgurl(resources.getIcon());
229
230 String email = visUserDTO.getEmail();
231 userAppIdManual.setEmail(StringUtils.isBlank(email) ? null : email);
232
233 String tags = visUserDTO.getTags();
234 userAppIdManual.setTags(StringUtils.isBlank(tags) ? null : tags);
235
236 Timestamp createTime = visUserDTO.getCreateTime();
237 userAppIdManual.setCreateTime(Objects.isNull(createTime) ? TimestampUtil.now() : createTime);
238
239 Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getIcon(), userAppIdManual.getNickname(), 0);
240 MemberDTO memberDTO = this.memberService.create(member);
241
242 userAppIdManual.setMemberCode(memberDTO.getCode());
243 userAppIdManual.setMemberId(memberDTO.getId());
244 userAppIdManual.setType(resources.getType());
245 this.userAppRepository.saveByIdManual(userAppIdManual);
246
247 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getUser(), 6);
248 if (Objects.isNull(userAppBindDTO.getId())) {
249
250 UserAppBind userAppBind = new UserAppBind();
251 userAppBind.setAccount(resources.getUser());
252 userAppBind.setAccountType(6);
253 userAppBind.setUserAppId(visUserId);
254 userAppBind.setStatus(1);
255 userAppBind.setNickname(resources.getNickname());
256 userAppBind.setHeadimgurl(resources.getIcon());
257 this.userAppBindService.create(userAppBind);
258 }
259
260 ((UserAppServiceImpl) AopContext.currentProxy()).asyncSaveByIdManual(userAppIdManual);
261
262 return ResultInfo.success(userAppIdManual);
263 }
264
265 return ResultInfo.failure(null);
266 }
267
268 @Override
269 @Transactional(rollbackFor = Exception.class)
168 public ResultInfo saveAppAndBindWeibo4Vis(VisUserWeibo resources) { 270 public ResultInfo saveAppAndBindWeibo4Vis(VisUserWeibo resources) {
169 271
170 String username1 = resources.getUsername(); 272 String username1 = resources.getUsername();
...@@ -221,8 +323,9 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -221,8 +323,9 @@ public class UserAppServiceImpl implements UserAppService {
221 323
222 Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getIcon(), userAppIdManual.getNickname(), 0); 324 Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getIcon(), userAppIdManual.getNickname(), 0);
223 MemberDTO memberDTO = this.memberService.create(member); 325 MemberDTO memberDTO = this.memberService.create(member);
224 userAppIdManual.setMemberId(memberDTO.getId());
225 326
327 userAppIdManual.setMemberCode(memberDTO.getCode());
328 userAppIdManual.setMemberId(memberDTO.getId());
226 userAppIdManual.setType(resources.getType()); 329 userAppIdManual.setType(resources.getType());
227 330
228 this.userAppRepository.saveByIdManual(userAppIdManual); 331 this.userAppRepository.saveByIdManual(userAppIdManual);
...@@ -241,15 +344,17 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -241,15 +344,17 @@ public class UserAppServiceImpl implements UserAppService {
241 this.userAppBindService.create(userAppBind); 344 this.userAppBindService.create(userAppBind);
242 } 345 }
243 346
244 347 ((UserAppServiceImpl) AopContext.currentProxy()).asyncSaveByIdManual(userAppIdManual);
245 return ResultInfo.success(userAppIdManual); 348 return ResultInfo.success(userAppIdManual);
246 } 349 }
247 350
248 return ResultInfo.failure(null); 351 return ResultInfo.failure(null);
249 } 352 }
250 353
354
355
251 @Override 356 @Override
252 @Transactional 357 @Transactional(rollbackFor = Exception.class)
253 public ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources) { 358 public ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources) {
254 String username1 = resources.getUsername(); 359 String username1 = resources.getUsername();
255 UserAppDTO userAppDTO = this.findByUsername(username1); 360 UserAppDTO userAppDTO = this.findByUsername(username1);
...@@ -305,8 +410,9 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -305,8 +410,9 @@ public class UserAppServiceImpl implements UserAppService {
305 410
306 Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getHeadimgurl(), userAppIdManual.getNickname(), 0); 411 Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getHeadimgurl(), userAppIdManual.getNickname(), 0);
307 MemberDTO memberDTO = this.memberService.create(member); 412 MemberDTO memberDTO = this.memberService.create(member);
308 userAppIdManual.setMemberId(memberDTO.getId());
309 413
414 userAppIdManual.setMemberCode(memberDTO.getCode());
415 userAppIdManual.setMemberId(memberDTO.getId());
310 userAppIdManual.setType(resources.getType()); 416 userAppIdManual.setType(resources.getType());
311 417
312 this.userAppRepository.saveByIdManual(userAppIdManual); 418 this.userAppRepository.saveByIdManual(userAppIdManual);
...@@ -325,14 +431,17 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -325,14 +431,17 @@ public class UserAppServiceImpl implements UserAppService {
325 this.userAppBindService.create(userAppBind); 431 this.userAppBindService.create(userAppBind);
326 } 432 }
327 433
328 434 ((UserAppServiceImpl) AopContext.currentProxy()).asyncSaveByIdManual(userAppIdManual);
329 return ResultInfo.success(userAppIdManual); 435 return ResultInfo.success(userAppIdManual);
330 } 436 }
331 437
332 return ResultInfo.failure(null); 438 return ResultInfo.failure(null);
333 } 439 }
334 440
441
442
335 @Override 443 @Override
444 @Transactional(rollbackFor = Exception.class)
336 public ResultInfo saveAppAndBindQq4Vis(VisUserQq resources) { 445 public ResultInfo saveAppAndBindQq4Vis(VisUserQq resources) {
337 String username1 = resources.getUsername(); 446 String username1 = resources.getUsername();
338 UserAppDTO userAppDTO = this.findByUsername(username1); 447 UserAppDTO userAppDTO = this.findByUsername(username1);
...@@ -388,13 +497,14 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -388,13 +497,14 @@ public class UserAppServiceImpl implements UserAppService {
388 497
389 Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getIcon(), userAppIdManual.getNickname(), 0); 498 Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getIcon(), userAppIdManual.getNickname(), 0);
390 MemberDTO memberDTO = this.memberService.create(member); 499 MemberDTO memberDTO = this.memberService.create(member);
500
501 userAppIdManual.setMemberCode(memberDTO.getCode());
391 userAppIdManual.setMemberId(memberDTO.getId()); 502 userAppIdManual.setMemberId(memberDTO.getId());
392 503
393 userAppIdManual.setType(resources.getType()); 504 userAppIdManual.setType(resources.getType());
394 505
395 this.userAppRepository.saveByIdManual(userAppIdManual); 506 this.userAppRepository.saveByIdManual(userAppIdManual);
396 507
397
398 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getOpenid(), 4); 508 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getOpenid(), 4);
399 if (Objects.isNull(userAppBindDTO.getId())) { 509 if (Objects.isNull(userAppBindDTO.getId())) {
400 510
...@@ -408,6 +518,7 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -408,6 +518,7 @@ public class UserAppServiceImpl implements UserAppService {
408 this.userAppBindService.create(userAppBind); 518 this.userAppBindService.create(userAppBind);
409 } 519 }
410 520
521 ((UserAppServiceImpl) AopContext.currentProxy()).asyncSaveByIdManual(userAppIdManual);
411 522
412 return ResultInfo.success(userAppIdManual); 523 return ResultInfo.success(userAppIdManual);
413 } 524 }
...@@ -415,11 +526,16 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -415,11 +526,16 @@ public class UserAppServiceImpl implements UserAppService {
415 return ResultInfo.failure(null); 526 return ResultInfo.failure(null);
416 } 527 }
417 528
529
530
418 @Override 531 @Override
419 @Transactional(rollbackFor = Exception.class) 532 @Transactional(rollbackFor = Exception.class)
420 public boolean updatePasswordById(UserApp resources) { 533 public boolean updatePasswordById(UserApp resources) {
421 return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0; 534 return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0;
422 } 535 }
423 536
424 537 @AsyncMqSend
538 public void asyncUpdateAppLastActiveTimeAndNicknameAndHeadImgById(UserApp resources) {}
539 @AsyncMqSend
540 public void asyncSaveByIdManual(UserAppIdManual userAppIdManual) {}
425 } 541 }
......
...@@ -23,6 +23,12 @@ import java.io.Serializable; ...@@ -23,6 +23,12 @@ import java.io.Serializable;
23 @Table(name="vis_user_apple") 23 @Table(name="vis_user_apple")
24 public class VisUserApple implements Serializable { 24 public class VisUserApple implements Serializable {
25 25
26
27 @Transient
28 private String username;
29 @Transient
30 private Integer type;
31
26 // ID 32 // ID
27 @Id 33 @Id
28 @GeneratedValue(strategy = GenerationType.IDENTITY) 34 @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -219,7 +219,7 @@ public class UserOperationController { ...@@ -219,7 +219,7 @@ public class UserOperationController {
219 @ApiOperation("取消关联第三方账号") 219 @ApiOperation("取消关联第三方账号")
220 @AnonymousAccess 220 @AnonymousAccess
221 public ResultInfo cancelUserAppBind(@Validated @RequestBody UserAppBind resources) { 221 public ResultInfo cancelUserAppBind(@Validated @RequestBody UserAppBind resources) {
222 log.info("取消关联第三方账号, 参数 ==>> [updateUserApp#{}]", resources); 222 log.info("取消关联第三方账号, 参数 ==>> [cancelUserAppBind#{}]", resources);
223 223
224 String account = resources.getAccount(); 224 String account = resources.getAccount();
225 if (StringUtils.isBlank(account)) { 225 if (StringUtils.isBlank(account)) {
...@@ -234,8 +234,7 @@ public class UserOperationController { ...@@ -234,8 +234,7 @@ public class UserOperationController {
234 return ResultInfo.failure("取消关联第三方账号失败,参数错误,第三方账号类型不得为空"); 234 return ResultInfo.failure("取消关联第三方账号失败,参数错误,第三方账号类型不得为空");
235 } 235 }
236 236
237 boolean result =this.userOperationService.cancelUserAppBind(resources); 237 return this.userOperationService.cancelUserAppBind(resources);
238 return ResultInfo.success(result);
239 } 238 }
240 239
241 240
......
...@@ -187,7 +187,7 @@ public interface UserOperationService { ...@@ -187,7 +187,7 @@ public interface UserOperationService {
187 * @param resources 187 * @param resources
188 * @return 188 * @return
189 */ 189 */
190 boolean cancelUserAppBind(UserAppBind resources); 190 ResultInfo cancelUserAppBind(UserAppBind resources);
191 191
192 /** 192 /**
193 * 193 *
......
...@@ -168,14 +168,24 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -168,14 +168,24 @@ public class UserOperationServiceImpl implements UserOperationService {
168 } 168 }
169 169
170 @Override 170 @Override
171 public boolean cancelUserAppBind(UserAppBind resources) { 171 public ResultInfo cancelUserAppBind(UserAppBind resources) {
172 String account = resources.getAccount(); 172 String account = resources.getAccount();
173 Integer accountType = resources.getAccountType(); 173 Integer accountType = resources.getAccountType();
174 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType); 174 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
175 if (Objects.nonNull(userAppBindDTO.getId())) { 175 if (Objects.nonNull(userAppBindDTO.getId())) {
176 return this.userAppBindService.cancelUserAppBind(account, accountType); 176 if (Objects.nonNull(userAppBindDTO.getUserAppId())) {
177 UserAppDTO userAppDTO = this.userAppService.findById(userAppBindDTO.getUserAppId());
178 if (Objects.isNull(userAppDTO.getId())) {
179 return ResultInfo.failure("app账号不存在");
180 }
181 }
182 boolean b = this.userAppBindService.cancelUserAppBind(account, accountType);
183 if (b) {
184 return ResultInfo.success(true);
185 }
177 } 186 }
178 return false; 187
188 return ResultInfo.failure("取消绑定失败");
179 } 189 }
180 190
181 191
...@@ -189,7 +199,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -189,7 +199,7 @@ public class UserOperationServiceImpl implements UserOperationService {
189 UserAppDTO userAppDTO = this.userAppService.findByUsername(username); 199 UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
190 log.info("通过app账号查询app信息是否存在,[appBindThirdAccount#{}]", userAppDTO); 200 log.info("通过app账号查询app信息是否存在,[appBindThirdAccount#{}]", userAppDTO);
191 if (Objects.isNull(userAppDTO.getId())) { 201 if (Objects.isNull(userAppDTO.getId())) {
192 return ResultInfo.failure("绑定第三方账号失败,app账号不存在[appBindThirdAccount#{}]"); 202 return ResultInfo.failure("app账号不存在");
193 } 203 }
194 204
195 String account = resources.getAccount(); 205 String account = resources.getAccount();
...@@ -245,7 +255,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -245,7 +255,7 @@ public class UserOperationServiceImpl implements UserOperationService {
245 userAppDTO1.setHeadimgurl(headImgUrl); 255 userAppDTO1.setHeadimgurl(headImgUrl);
246 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(userAppDTO1); 256 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(userAppDTO1);
247 } 257 }
248 return ResultInfo.failure("绑定第三方账号失败,app账号不存在[appBindThirdAccount#{}]"); 258
249 } else { 259 } else {
250 resources.setUserAppId(userAppDTO.getId()); 260 resources.setUserAppId(userAppDTO.getId());
251 resources.setStatus(1); 261 resources.setStatus(1);
...@@ -256,8 +266,9 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -256,8 +266,9 @@ public class UserOperationServiceImpl implements UserOperationService {
256 BeanUtils.copyProperties(resources, userAppDTO1); 266 BeanUtils.copyProperties(resources, userAppDTO1);
257 userAppDTO1.setUsername(username); 267 userAppDTO1.setUsername(username);
258 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncCreateUserAppBindThirdAccount(userAppDTO1); 268 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncCreateUserAppBindThirdAccount(userAppDTO1);
259 return ResultInfo.success("操作成功");
260 } 269 }
270
271 return ResultInfo.success(true);
261 } 272 }
262 273
263 @Override 274 @Override
...@@ -715,6 +726,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -715,6 +726,7 @@ public class UserOperationServiceImpl implements UserOperationService {
715 726
716 // 保存关注记录 727 // 保存关注记录
717 JSONObject sourceInfo = resources.getSourceInfo(); 728 JSONObject sourceInfo = resources.getSourceInfo();
729 log.info("保存关注记录,数据 [subscribe#{}]", sourceInfo);
718 this.saveWechatSubscribeRecord(memberDTO, sourceInfo, 1); 730 this.saveWechatSubscribeRecord(memberDTO, sourceInfo, 1);
719 731
720 return true; 732 return true;
...@@ -737,37 +749,38 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -737,37 +749,38 @@ public class UserOperationServiceImpl implements UserOperationService {
737 749
738 // 内容ID,entityId:实体ID 750 // 内容ID,entityId:实体ID
739 Object entityId = sourceInfo.get("entityId"); 751 Object entityId = sourceInfo.get("entityId");
740 if (Objects.nonNull(entityId)) { 752 if (Objects.nonNull(entityId) && StringUtils.isNotBlank(entityId.toString())) {
741 wechatSubscribeRecord.setEntityId(Long.parseLong(entityId.toString())); 753 wechatSubscribeRecord.setEntityId(Long.parseLong(entityId.toString()));
742 } 754 }
743 // 内容Code, entityCode: 实体Code 755 // 内容Code, entityCode: 实体Code
744 Object entityCode = sourceInfo.get("entityCode"); 756 Object entityCode = sourceInfo.get("entityCode");
745 if (Objects.nonNull(entityCode)) { 757 if (Objects.nonNull(entityCode) && StringUtils.isNotBlank(entityCode.toString())) {
746 wechatSubscribeRecord.setEntityCode(entityCode.toString()); 758 wechatSubscribeRecord.setEntityCode(entityCode.toString());
747 } 759 }
748 // 内容类型,entityType:不填/空:首页;1:分类列表;2:商品;3:活动;4:投票对象;5:证书;6:用户上传内容;99:其他; 760 // 内容类型,entityType:不填/空:首页;1:分类列表;2:商品;3:活动;4:投票对象;5:证书;6:用户上传内容;99:其他;
749 Object entityType = sourceInfo.get("entityType"); 761 Object entityType = sourceInfo.get("entityType");
750 if (Objects.nonNull(entityType)) { 762 if (Objects.nonNull(entityType) && StringUtils.isNotBlank(entityType.toString())) {
751 wechatSubscribeRecord.setEntityType(Integer.parseInt(entityType.toString())); 763 wechatSubscribeRecord.setEntityType(Integer.parseInt(entityType.toString()));
752 } 764 }
753 // 微信场景类型,sourceType 765 // 微信场景类型,sourceType
754 Object sourceType = sourceInfo.get("sourceType"); 766 Object sourceType = sourceInfo.get("sourceType");
755 if (Objects.nonNull(sourceType)) { 767 if (Objects.nonNull(sourceType) && StringUtils.isNotBlank(sourceType.toString())) {
756 wechatSubscribeRecord.setWxScence(Integer.parseInt(sourceType.toString())); 768 wechatSubscribeRecord.setWxScence(Integer.parseInt(sourceType.toString()));
757 } 769 }
758 // 来源描述,sourceDesc:系统/运营手动维护 770 // 来源描述,sourceDesc:系统/运营手动维护
759 Object sourceDesc = sourceInfo.get("sourceDesc"); 771 Object sourceDesc = sourceInfo.get("sourceDesc");
760 if (Objects.nonNull(sourceType)) { 772 if (Objects.nonNull(sourceType) && StringUtils.isNotBlank(sourceDesc.toString())) {
761 wechatSubscribeRecord.setSourceDesc(sourceDesc.toString()); 773 wechatSubscribeRecord.setSourceDesc(sourceDesc.toString());
762 } 774 }
763 // 业务场景,0-分享 1-大屏扫码免费看 2-大屏线上活动扫码引导关注 3-小屏线上活动长按二维码引导关注 4-线下活动海报 5-线下机构/渠道引流 99-其他 775 // 业务场景,0-分享 1-大屏扫码免费看 2-大屏线上活动扫码引导关注 3-小屏线上活动长按二维码引导关注 4-线下活动海报 5-线下机构/渠道引流 99-其他
764 Object sourceScence = sourceInfo.get("sourceScence"); 776 Object sourceScence = sourceInfo.get("sourceScence");
765 if (Objects.nonNull(sourceScence)) { 777 if (Objects.nonNull(sourceScence) && StringUtils.isNotBlank(sourceScence.toString())) {
766 wechatSubscribeRecord.setSourceScence(Integer.parseInt(sourceScence.toString())); 778 wechatSubscribeRecord.setSourceScence(Integer.parseInt(sourceScence.toString()));
767 } 779 }
768 780
769 } 781 }
770 782
783 log.info("保存关注记录,落库对象 [subscribe# wechatSubscribeRecord ==>> {}]", wechatSubscribeRecord);
771 this.wechatSubscribeRecordService.create(wechatSubscribeRecord); 784 this.wechatSubscribeRecordService.create(wechatSubscribeRecord);
772 785
773 } 786 }
......