1.新增保存小屏账户并创建会员信息的接口
Showing
10 changed files
with
131 additions
and
31 deletions
| 1 | package com.topdraw.business.module.member.profile.rest; | 1 | package com.topdraw.business.module.member.profile.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | ||
| 3 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 4 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 4 | import com.topdraw.business.module.member.service.MemberService; | 5 | import com.topdraw.business.module.member.service.MemberService; |
| 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 6 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| ... | @@ -22,7 +23,7 @@ import java.util.Objects; | ... | @@ -22,7 +23,7 @@ import java.util.Objects; |
| 22 | */ | 23 | */ |
| 23 | @Api(tags = "MemberProfile管理") | 24 | @Api(tags = "MemberProfile管理") |
| 24 | @RestController | 25 | @RestController |
| 25 | @RequestMapping("/api/MemberProfile") | 26 | @RequestMapping("/ucEngine/api/memberProfile") |
| 26 | @CrossOrigin | 27 | @CrossOrigin |
| 27 | public class MemberProfileController { | 28 | public class MemberProfileController { |
| 28 | 29 | ||
| ... | @@ -46,6 +47,7 @@ public class MemberProfileController { | ... | @@ -46,6 +47,7 @@ public class MemberProfileController { |
| 46 | @Log | 47 | @Log |
| 47 | @PostMapping(value = "/create") | 48 | @PostMapping(value = "/create") |
| 48 | @ApiOperation("新增MemberProfile") | 49 | @ApiOperation("新增MemberProfile") |
| 50 | @AnonymousAccess | ||
| 49 | public ResultInfo create(@Validated @RequestBody MemberProfile resources) { | 51 | public ResultInfo create(@Validated @RequestBody MemberProfile resources) { |
| 50 | MemberProfileService.create(resources); | 52 | MemberProfileService.create(resources); |
| 51 | return ResultInfo.success(); | 53 | return ResultInfo.success(); |
| ... | @@ -54,6 +56,7 @@ public class MemberProfileController { | ... | @@ -54,6 +56,7 @@ public class MemberProfileController { |
| 54 | @Log | 56 | @Log |
| 55 | @PutMapping(value = "/update") | 57 | @PutMapping(value = "/update") |
| 56 | @ApiOperation("修改MemberProfile") | 58 | @ApiOperation("修改MemberProfile") |
| 59 | @AnonymousAccess | ||
| 57 | public ResultInfo update(@Validated @RequestBody MemberProfile resources) { | 60 | public ResultInfo update(@Validated @RequestBody MemberProfile resources) { |
| 58 | Long memberId = resources.getMemberId(); | 61 | Long memberId = resources.getMemberId(); |
| 59 | Assert.notNull(memberId,"memberId can't be null"); | 62 | Assert.notNull(memberId,"memberId can't be null"); | ... | ... |
| 1 | package com.topdraw.business.module.user.iptv.rest; | 1 | package com.topdraw.business.module.user.iptv.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | ||
| 3 | import com.topdraw.common.ResultInfo; | 4 | import com.topdraw.common.ResultInfo; |
| 4 | import com.topdraw.annotation.Log; | 5 | import com.topdraw.annotation.Log; |
| 5 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 6 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| ... | @@ -17,7 +18,7 @@ import io.swagger.annotations.*; | ... | @@ -17,7 +18,7 @@ import io.swagger.annotations.*; |
| 17 | */ | 18 | */ |
| 18 | @Api(tags = "UserTv管理") | 19 | @Api(tags = "UserTv管理") |
| 19 | @RestController | 20 | @RestController |
| 20 | @RequestMapping("/api/UserTv") | 21 | @RequestMapping("/ucEngine/api/userTv") |
| 21 | public class UserTvController { | 22 | public class UserTvController { |
| 22 | 23 | ||
| 23 | @Autowired | 24 | @Autowired |
| ... | @@ -36,8 +37,9 @@ public class UserTvController { | ... | @@ -36,8 +37,9 @@ public class UserTvController { |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | @Log | 39 | @Log |
| 39 | @PostMapping | 40 | @PostMapping(value = "/create") |
| 40 | @ApiOperation("新增UserTv") | 41 | @ApiOperation("新增UserTv") |
| 42 | @AnonymousAccess | ||
| 41 | public ResultInfo create(@Validated @RequestBody UserTv resources) { | 43 | public ResultInfo create(@Validated @RequestBody UserTv resources) { |
| 42 | UserTvService.create(resources); | 44 | UserTvService.create(resources); |
| 43 | return ResultInfo.success(); | 45 | return ResultInfo.success(); |
| ... | @@ -46,6 +48,7 @@ public class UserTvController { | ... | @@ -46,6 +48,7 @@ public class UserTvController { |
| 46 | @Log | 48 | @Log |
| 47 | @PutMapping | 49 | @PutMapping |
| 48 | @ApiOperation("修改UserTv") | 50 | @ApiOperation("修改UserTv") |
| 51 | @AnonymousAccess | ||
| 49 | public ResultInfo update(@Validated @RequestBody UserTv resources) { | 52 | public ResultInfo update(@Validated @RequestBody UserTv resources) { |
| 50 | UserTvService.update(resources); | 53 | UserTvService.update(resources); |
| 51 | return ResultInfo.success(); | 54 | return ResultInfo.success(); | ... | ... |
| 1 | package com.topdraw.business.module.user.weixin.rest; | 1 | package com.topdraw.business.module.user.weixin.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | ||
| 3 | import com.topdraw.common.ResultInfo; | 4 | import com.topdraw.common.ResultInfo; |
| 4 | import com.topdraw.annotation.Log; | 5 | import com.topdraw.annotation.Log; |
| 5 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 6 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| ... | @@ -17,7 +18,7 @@ import io.swagger.annotations.*; | ... | @@ -17,7 +18,7 @@ import io.swagger.annotations.*; |
| 17 | */ | 18 | */ |
| 18 | @Api(tags = "UserWeixin管理") | 19 | @Api(tags = "UserWeixin管理") |
| 19 | @RestController | 20 | @RestController |
| 20 | @RequestMapping("/api/UserWeixin") | 21 | @RequestMapping("/ucEngine/api/userWeixin") |
| 21 | public class UserWeixinController { | 22 | public class UserWeixinController { |
| 22 | 23 | ||
| 23 | @Autowired | 24 | @Autowired |
| ... | @@ -36,16 +37,18 @@ public class UserWeixinController { | ... | @@ -36,16 +37,18 @@ public class UserWeixinController { |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | @Log | 39 | @Log |
| 39 | @PostMapping | 40 | @PostMapping(value = "/create") |
| 40 | @ApiOperation("新增UserWeixin") | 41 | @ApiOperation("新增UserWeixin") |
| 42 | @AnonymousAccess | ||
| 41 | public ResultInfo create(@Validated @RequestBody UserWeixin resources) { | 43 | public ResultInfo create(@Validated @RequestBody UserWeixin resources) { |
| 42 | UserWeixinService.create(resources); | 44 | UserWeixinService.create(resources); |
| 43 | return ResultInfo.success(); | 45 | return ResultInfo.success(); |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | @Log | 48 | @Log |
| 47 | @PutMapping | 49 | @PutMapping(value = "/update") |
| 48 | @ApiOperation("修改UserWeixin") | 50 | @ApiOperation("修改UserWeixin") |
| 51 | @AnonymousAccess | ||
| 49 | public ResultInfo update(@Validated @RequestBody UserWeixin resources) { | 52 | public ResultInfo update(@Validated @RequestBody UserWeixin resources) { |
| 50 | UserWeixinService.update(resources); | 53 | UserWeixinService.update(resources); |
| 51 | return ResultInfo.success(); | 54 | return ResultInfo.success(); | ... | ... |
| ... | @@ -67,6 +67,30 @@ public class UserOperationController { | ... | @@ -67,6 +67,30 @@ public class UserOperationController { |
| 67 | return ResultInfo.success(result); | 67 | return ResultInfo.success(result); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | @Log("新增小屏账户同时创建会员信息") | ||
| 71 | @PostMapping(value = "/createWeixinUserAndCreateMember") | ||
| 72 | @ApiOperation("新增小屏账户同时创建会员信息") | ||
| 73 | @AnonymousAccess | ||
| 74 | public ResultInfo createWeixinUserAndCreateMember(@Validated @RequestBody WeiXinUserBean resources) { | ||
| 75 | |||
| 76 | log.info("Param ==> resource ==> [{}]",resources); | ||
| 77 | |||
| 78 | String appId = resources.getAppId(); | ||
| 79 | if (StringUtils.isBlank(appId)) | ||
| 80 | throw new NullPointerException("appId is null !"); | ||
| 81 | |||
| 82 | String openId = resources.getOpenId(); | ||
| 83 | if (StringUtils.isBlank(openId)) | ||
| 84 | throw new NullPointerException("openId is null !"); | ||
| 85 | |||
| 86 | String unionId = resources.getUnionId(); | ||
| 87 | if (StringUtils.isBlank(unionId)) | ||
| 88 | throw new NullPointerException("unionId is null !"); | ||
| 89 | |||
| 90 | boolean result = this.userTvOperationService.createWeixinUserAndCreateMember(resources); | ||
| 91 | return ResultInfo.success(result); | ||
| 92 | } | ||
| 93 | |||
| 70 | @Log("获取大屏绑定的小屏会员列表") | 94 | @Log("获取大屏绑定的小屏会员列表") |
| 71 | @GetMapping(value = "/findBindByPlatformAccount/{platformAccount}") | 95 | @GetMapping(value = "/findBindByPlatformAccount/{platformAccount}") |
| 72 | @AnonymousAccess | 96 | @AnonymousAccess |
| ... | @@ -319,6 +343,7 @@ public class UserOperationController { | ... | @@ -319,6 +343,7 @@ public class UserOperationController { |
| 319 | @Log("保存用户手机号信息") | 343 | @Log("保存用户手机号信息") |
| 320 | @PostMapping(value = "/saveUserWeixinPhone") | 344 | @PostMapping(value = "/saveUserWeixinPhone") |
| 321 | @ApiOperation("保存用户手机号信息") | 345 | @ApiOperation("保存用户手机号信息") |
| 346 | @AnonymousAccess | ||
| 322 | public ResultInfo saveUserWeixinPhone(@RequestBody WeiXinUserBean resources) { | 347 | public ResultInfo saveUserWeixinPhone(@RequestBody WeiXinUserBean resources) { |
| 323 | log.info("resources :[{}]",resources); | 348 | log.info("resources :[{}]",resources); |
| 324 | MemberProfile s = this.userTvOperationService.saveUserWeixinPhone(resources); | 349 | MemberProfile s = this.userTvOperationService.saveUserWeixinPhone(resources); | ... | ... |
| ... | @@ -130,4 +130,6 @@ public interface UserOperationService { | ... | @@ -130,4 +130,6 @@ public interface UserOperationService { |
| 130 | 130 | ||
| 131 | 131 | ||
| 132 | JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code); | 132 | JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code); |
| 133 | |||
| 134 | boolean createWeixinUserAndCreateMember(WeiXinUserBean resources); | ||
| 133 | } | 135 | } | ... | ... |
| ... | @@ -165,19 +165,22 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -165,19 +165,22 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
| 165 | * @return | 165 | * @return |
| 166 | */ | 166 | */ |
| 167 | private MemberProfileDTO configMemberProfile(MemberProfileDTO memberProfileDTO_0, MemberDTO memberDTO, String appid) { | 167 | private MemberProfileDTO configMemberProfile(MemberProfileDTO memberProfileDTO_0, MemberDTO memberDTO, String appid) { |
| 168 | |||
| 169 | if (Objects.isNull(memberProfileDTO_0)) return memberProfileDTO_0; | ||
| 170 | |||
| 168 | MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); | 171 | MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); |
| 169 | BeanUtils.copyProperties(memberProfileDTO_0,memberProfileDTO); | 172 | BeanUtils.copyProperties(memberProfileDTO_0,memberProfileDTO); |
| 170 | 173 | ||
| 171 | // 真实姓名 | 174 | // 真实姓名 |
| 172 | String realname = memberProfileDTO.getRealname(); | 175 | String realname = memberProfileDTO.getRealname(); |
| 173 | if (StringUtils.isNotBlank(realname)) { | 176 | if (StringUtils.isNotBlank(realname)) { |
| 174 | realname = new String(Base64.getDecoder().decode(realname.getBytes(StandardCharsets.UTF_8))); | 177 | realname = new String(Base64.getEncoder().encode(realname.getBytes(StandardCharsets.UTF_8))); |
| 175 | } | 178 | } |
| 176 | 179 | ||
| 177 | // 昵称 | 180 | // 昵称 |
| 178 | String nickname = memberDTO.getNickname(); | 181 | String nickname = memberDTO.getNickname(); |
| 179 | if (StringUtils.isNotBlank(nickname)) { | 182 | if (StringUtils.isNotBlank(nickname)) { |
| 180 | nickname = new String(Base64.getDecoder().decode(nickname.getBytes(StandardCharsets.UTF_8))); | 183 | nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8))); |
| 181 | } | 184 | } |
| 182 | 185 | ||
| 183 | // vip | 186 | // vip | ... | ... |
| ... | @@ -5,18 +5,15 @@ import cn.hutool.core.date.DateUtil; | ... | @@ -5,18 +5,15 @@ import cn.hutool.core.date.DateUtil; |
| 5 | import cn.hutool.core.util.ObjectUtil; | 5 | import cn.hutool.core.util.ObjectUtil; |
| 6 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 7 | import cn.hutool.http.HttpUtil; | 7 | import cn.hutool.http.HttpUtil; |
| 8 | import com.alibaba.druid.util.HttpClientUtils; | ||
| 9 | import com.alibaba.fastjson.JSONObject; | 8 | import com.alibaba.fastjson.JSONObject; |
| 10 | import com.topdraw.business.module.member.domain.Member; | 9 | import com.topdraw.business.module.member.domain.Member; |
| 11 | import com.topdraw.business.module.member.domain.MemberBuilder; | 10 | import com.topdraw.business.module.member.domain.MemberBuilder; |
| 12 | import com.topdraw.business.module.member.domain.MemberConstant; | ||
| 13 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 11 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 14 | import com.topdraw.business.module.member.profile.service.MemberProfileService; | 12 | import com.topdraw.business.module.member.profile.service.MemberProfileService; |
| 15 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 13 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 16 | import com.topdraw.business.module.member.service.MemberService; | 14 | import com.topdraw.business.module.member.service.MemberService; |
| 17 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 15 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 18 | import com.topdraw.business.module.member.service.dto.MemberQueryCriteria; | 16 | import com.topdraw.business.module.member.service.dto.MemberQueryCriteria; |
| 19 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; | ||
| 20 | import com.topdraw.business.module.user.iptv.domain.UserConstant; | 17 | import com.topdraw.business.module.user.iptv.domain.UserConstant; |
| 21 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 18 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 22 | import com.topdraw.business.module.user.iptv.service.UserTvService; | 19 | import com.topdraw.business.module.user.iptv.service.UserTvService; |
| ... | @@ -36,11 +33,8 @@ import com.topdraw.business.process.service.UserOperationService; | ... | @@ -36,11 +33,8 @@ import com.topdraw.business.process.service.UserOperationService; |
| 36 | import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; | 33 | import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; |
| 37 | import com.topdraw.config.LocalConstants; | 34 | import com.topdraw.config.LocalConstants; |
| 38 | import com.topdraw.config.RedisKeyUtil; | 35 | import com.topdraw.config.RedisKeyUtil; |
| 39 | import com.topdraw.config.ServiceEnvConfig; | ||
| 40 | import com.topdraw.exception.BadRequestException; | 36 | import com.topdraw.exception.BadRequestException; |
| 41 | import com.topdraw.exception.EntityNotFoundException; | 37 | import com.topdraw.exception.EntityNotFoundException; |
| 42 | import com.topdraw.module.mq.DataSyncMsg; | ||
| 43 | import com.topdraw.module.mq.EntityType; | ||
| 44 | import com.topdraw.security.AESUtil; | 38 | import com.topdraw.security.AESUtil; |
| 45 | import com.topdraw.util.IdWorker; | 39 | import com.topdraw.util.IdWorker; |
| 46 | import com.topdraw.util.TimestampUtil; | 40 | import com.topdraw.util.TimestampUtil; |
| ... | @@ -53,26 +47,18 @@ import com.topdraw.weixin.util.WeChatConstants; | ... | @@ -53,26 +47,18 @@ import com.topdraw.weixin.util.WeChatConstants; |
| 53 | import com.topdraw.weixin.util.WeiXinRequestUtil; | 47 | import com.topdraw.weixin.util.WeiXinRequestUtil; |
| 54 | import com.topdraw.weixin.util.WeixinUtil; | 48 | import com.topdraw.weixin.util.WeixinUtil; |
| 55 | import lombok.extern.slf4j.Slf4j; | 49 | import lombok.extern.slf4j.Slf4j; |
| 56 | import lombok.var; | ||
| 57 | import org.redisson.api.RedissonClient; | 50 | import org.redisson.api.RedissonClient; |
| 58 | import org.springframework.beans.BeanUtils; | 51 | import org.springframework.beans.BeanUtils; |
| 59 | import org.springframework.beans.factory.annotation.Autowired; | 52 | import org.springframework.beans.factory.annotation.Autowired; |
| 60 | import org.springframework.beans.factory.annotation.Value; | 53 | import org.springframework.beans.factory.annotation.Value; |
| 54 | import org.springframework.context.annotation.Bean; | ||
| 61 | import org.springframework.data.domain.PageRequest; | 55 | import org.springframework.data.domain.PageRequest; |
| 62 | import org.springframework.data.domain.Sort; | 56 | import org.springframework.data.domain.Sort; |
| 63 | import org.springframework.http.HttpMethod; | ||
| 64 | import org.springframework.http.ResponseEntity; | ||
| 65 | import org.springframework.stereotype.Service; | 57 | import org.springframework.stereotype.Service; |
| 66 | import org.springframework.transaction.annotation.Propagation; | 58 | import org.springframework.transaction.annotation.Propagation; |
| 67 | import org.springframework.transaction.annotation.Transactional; | 59 | import org.springframework.transaction.annotation.Transactional; |
| 68 | import org.springframework.util.Assert; | ||
| 69 | import org.springframework.util.CollectionUtils; | 60 | import org.springframework.util.CollectionUtils; |
| 70 | import org.springframework.web.client.RestTemplate; | ||
| 71 | 61 | ||
| 72 | import javax.annotation.Resource; | ||
| 73 | import java.io.IOException; | ||
| 74 | import java.sql.Timestamp; | ||
| 75 | import java.time.LocalDateTime; | ||
| 76 | import java.util.*; | 62 | import java.util.*; |
| 77 | import java.util.concurrent.TimeUnit; | 63 | import java.util.concurrent.TimeUnit; |
| 78 | import java.util.stream.Collectors; | 64 | import java.util.stream.Collectors; |
| ... | @@ -485,6 +471,19 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -485,6 +471,19 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 485 | } | 471 | } |
| 486 | 472 | ||
| 487 | /** | 473 | /** |
| 474 | * | ||
| 475 | * @param userWeixinDTO | ||
| 476 | * @param vip | ||
| 477 | * @return | ||
| 478 | */ | ||
| 479 | private Long doCreateMember(UserWeixinDTO userWeixinDTO,Integer vip) { | ||
| 480 | UserWeixin userWeixin = new UserWeixin(); | ||
| 481 | BeanUtils.copyProperties(userWeixinDTO,userWeixin); | ||
| 482 | Long memberId = this.doCreateMember(userWeixin, vip); | ||
| 483 | return memberId; | ||
| 484 | } | ||
| 485 | |||
| 486 | /** | ||
| 488 | * 创建会员 | 487 | * 创建会员 |
| 489 | * @description 同一用户只有一个会员,通过unionId查询任意账户是否关联了会员,如果关联了就不用再创建 | 488 | * @description 同一用户只有一个会员,通过unionId查询任意账户是否关联了会员,如果关联了就不用再创建 |
| 490 | * @param userWeixin | 489 | * @param userWeixin |
| ... | @@ -527,6 +526,16 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -527,6 +526,16 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 527 | return memberId; | 526 | return memberId; |
| 528 | } | 527 | } |
| 529 | 528 | ||
| 529 | private UserWeixinDTO doCreateUserWeiXin(UserWeixinDTO userWeixin,Long memberId) { | ||
| 530 | if (Objects.isNull(memberId)) | ||
| 531 | throw new NullPointerException("memberId is null !"); | ||
| 532 | |||
| 533 | UserWeixin userWeixin1 = new UserWeixin(); | ||
| 534 | BeanUtils.copyProperties(userWeixin,userWeixin1); | ||
| 535 | UserWeixinDTO userWeixinDTO = this.doCreateUserWeiXin(userWeixin1, memberId); | ||
| 536 | return userWeixinDTO; | ||
| 537 | } | ||
| 538 | |||
| 530 | /** | 539 | /** |
| 531 | * 保存微信账户信息 | 540 | * 保存微信账户信息 |
| 532 | * @param userWeixin | 541 | * @param userWeixin |
| ... | @@ -658,21 +667,29 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -658,21 +667,29 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 658 | 667 | ||
| 659 | } | 668 | } |
| 660 | 669 | ||
| 661 | if (StringUtils.isNotBlank(userInfo)) { | 670 | String phoneNumber = ""; |
| 671 | if (StringUtils.isNotBlank(encryptedData)) { | ||
| 662 | 672 | ||
| 663 | JSONObject userInfoJo = JSONObject.parseObject(userInfo); | 673 | JSONObject userInfoJo = JSONObject.parseObject(userInfo); |
| 664 | if (Objects.nonNull(userInfoJo)) { | 674 | if (Objects.nonNull(userInfoJo)) { |
| 665 | encryptedData = userInfoJo.getString("encryptedData"); | 675 | encryptedData = userInfoJo.getString("encryptedData"); |
| 666 | iv = userInfoJo.getString("iv"); | 676 | iv = userInfoJo.getString("iv"); |
| 667 | String sessionkey = jsonObject.getString("session_key"); | 677 | String sessionkey = jsonObject.getString("session_key"); |
| 668 | String userInfoWeixin = AESUtil.decryptJsUserInfo(encryptedData, iv, sessionkey); | 678 | JSONObject userInfoPhone = AESUtil.decryptJsUserPhone(encryptedData, iv, sessionkey); |
| 669 | log.info("userInfo:" + userInfo); | 679 | if (ObjectUtil.isNull(userInfoPhone)) { |
| 670 | userInfoWxJo = JSONObject.parseObject(userInfoWeixin); | 680 | throw new BadRequestException("decrypt phone error..."); |
| 681 | } | ||
| 682 | |||
| 683 | phoneNumber = userInfoPhone.getString("phoneNumber"); | ||
| 684 | if (StringUtils.isBlank(phoneNumber)) { | ||
| 685 | throw new BadRequestException("phoneNumber is null..."); | ||
| 686 | } | ||
| 687 | |||
| 671 | } | 688 | } |
| 672 | } | 689 | } |
| 673 | 690 | ||
| 674 | DefaultWeiXinBeanDefinition weiXinBeanDefinition = | 691 | DefaultWeiXinBeanDefinition weiXinBeanDefinition = |
| 675 | new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo); | 692 | new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo,phoneNumber); |
| 676 | 693 | ||
| 677 | return weiXinBeanDefinition; | 694 | return weiXinBeanDefinition; |
| 678 | } | 695 | } |
| ... | @@ -1360,6 +1377,44 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1360,6 +1377,44 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1360 | return jsonObject; | 1377 | return jsonObject; |
| 1361 | } | 1378 | } |
| 1362 | 1379 | ||
| 1380 | @Override | ||
| 1381 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 1382 | public boolean createWeixinUserAndCreateMember(WeiXinUserBean resources) { | ||
| 1383 | |||
| 1384 | String appId = resources.getAppId(); | ||
| 1385 | String openId = resources.getOpenId(); | ||
| 1386 | String unionId = resources.getUnionId(); | ||
| 1387 | |||
| 1388 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | ||
| 1389 | if (Objects.nonNull(userWeixinDTO)) | ||
| 1390 | throw new BadRequestException("账户已存在"); | ||
| 1391 | |||
| 1392 | // 当前用户的任意微信app | ||
| 1393 | UserWeixinDTO userWeixinDTO1 = this.findFirstByUnionId(unionId); | ||
| 1394 | |||
| 1395 | Long memberId = null; | ||
| 1396 | Integer vip = 0; | ||
| 1397 | if (Objects.nonNull(userWeixinDTO1.getId()) && Objects.nonNull(userWeixinDTO1.getMemberId())) { | ||
| 1398 | |||
| 1399 | memberId = userWeixinDTO1.getMemberId(); | ||
| 1400 | |||
| 1401 | } else { | ||
| 1402 | userWeixinDTO1 = new UserWeixinDTO(); | ||
| 1403 | BeanUtils.copyProperties(resources,userWeixinDTO1); | ||
| 1404 | // 创建会员 | ||
| 1405 | memberId = this.doCreateMember(userWeixinDTO1,0); | ||
| 1406 | } | ||
| 1407 | |||
| 1408 | // 保存微信账户 | ||
| 1409 | this.doCreateUserWeiXin(userWeixinDTO1,memberId); | ||
| 1410 | |||
| 1411 | return true; | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | private UserWeixinDTO findFirstByUnionId(String unionId) { | ||
| 1415 | return this.userWeixinService.findFirstByUnionId(unionId); | ||
| 1416 | } | ||
| 1417 | |||
| 1363 | /** | 1418 | /** |
| 1364 | * 通过id检索大屏信息 | 1419 | * 通过id检索大屏信息 |
| 1365 | * @param userIptvId | 1420 | * @param userIptvId | ... | ... |
| ... | @@ -132,7 +132,7 @@ public class WeiXinAppletUserParser implements WeiXinUserParser { | ... | @@ -132,7 +132,7 @@ public class WeiXinAppletUserParser implements WeiXinUserParser { |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | DefaultWeiXinBeanDefinition weiXinBeanDefinition = | 134 | DefaultWeiXinBeanDefinition weiXinBeanDefinition = |
| 135 | new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo); | 135 | new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo,null); |
| 136 | return weiXinBeanDefinition; | 136 | return weiXinBeanDefinition; |
| 137 | } | 137 | } |
| 138 | 138 | ... | ... |
| ... | @@ -46,7 +46,7 @@ public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition { | ... | @@ -46,7 +46,7 @@ public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition { |
| 46 | public DefaultWeiXinBeanDefinition() { | 46 | public DefaultWeiXinBeanDefinition() { |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | public DefaultWeiXinBeanDefinition(String appId, String code,String unionId,String openId, JSONObject userInfoWxJo) { | 49 | public DefaultWeiXinBeanDefinition(String appId, String code,String unionId,String openId, JSONObject userInfoWxJo,String phone) { |
| 50 | 50 | ||
| 51 | this.userInfo = userInfoWxJo; | 51 | this.userInfo = userInfoWxJo; |
| 52 | if (userInfo != null) { | 52 | if (userInfo != null) { |
| ... | @@ -91,6 +91,7 @@ public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition { | ... | @@ -91,6 +91,7 @@ public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition { |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | this.unionId = unionId; | 93 | this.unionId = unionId; |
| 94 | this.phoneNumber = phone; | ||
| 94 | this.openId = openId; | 95 | this.openId = openId; |
| 95 | this.appid = appId; | 96 | this.appid = appId; |
| 96 | this.code = code; | 97 | this.code = code; | ... | ... |
| ... | @@ -9,15 +9,18 @@ import org.slf4j.LoggerFactory; | ... | @@ -9,15 +9,18 @@ import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.boot.test.context.SpringBootTest; | 9 | import org.springframework.boot.test.context.SpringBootTest; |
| 10 | import org.springframework.test.context.junit4.SpringRunner; | 10 | import org.springframework.test.context.junit4.SpringRunner; |
| 11 | 11 | ||
| 12 | import java.sql.Timestamp; | ||
| 13 | |||
| 12 | @SpringBootTest(classes= MemberServiceApplication.class) | 14 | @SpringBootTest(classes= MemberServiceApplication.class) |
| 13 | @RunWith(SpringRunner.class) | 15 | @RunWith(SpringRunner.class) |
| 14 | public class BaseTest { | 16 | public class BaseTest { |
| 15 | 17 | ||
| 16 | public Logger LOG = LoggerFactory.getLogger(BaseTest.class); | 18 | public Logger LOG = LoggerFactory.getLogger(BaseTest.class); |
| 19 | |||
| 17 | private static String replaceUrl(String body, String ftpPath) { | 20 | private static String replaceUrl(String body, String ftpPath) { |
| 18 | boolean contains = body.contains("<source src="); | 21 | boolean contains = body.contains("<source src="); |
| 19 | if (contains) { | 22 | if (contains) { |
| 20 | body = body.replaceAll( "(<source src=(.*?)/>)","<source src="+"\""+ftpPath+"\"/>"); | 23 | body = body.replaceAll("(<source src=(.*?)/>)", "<source src=" + "\"" + ftpPath + "\"/>"); |
| 21 | } | 24 | } |
| 22 | return body; | 25 | return body; |
| 23 | } | 26 | } |
| ... | @@ -27,4 +30,6 @@ public class BaseTest { | ... | @@ -27,4 +30,6 @@ public class BaseTest { |
| 27 | DataSyncMsg.TaskTemplateParam taskTemplateParam = JSONObject.parseObject(param, DataSyncMsg.TaskTemplateParam.class); | 30 | DataSyncMsg.TaskTemplateParam taskTemplateParam = JSONObject.parseObject(param, DataSyncMsg.TaskTemplateParam.class); |
| 28 | System.out.println(taskTemplateParam); | 31 | System.out.println(taskTemplateParam); |
| 29 | } | 32 | } |
| 33 | |||
| 34 | |||
| 30 | } | 35 | } | ... | ... |
-
Please register or sign in to post a comment