1.修改部分接口名称
2.修改部分接口保存逻辑
Showing
11 changed files
with
140 additions
and
81 deletions
| 1 | package com.topdraw.business.module.member.profile.domain; | ||
| 2 | |||
| 3 | import com.topdraw.utils.StringUtils; | ||
| 4 | |||
| 5 | import java.sql.Timestamp; | ||
| 6 | import java.util.Objects; | ||
| 7 | |||
| 8 | public class MemberProfileBuild { | ||
| 9 | |||
| 10 | public static MemberProfile build(Long memberId , String realname , Integer gender, Timestamp birthday){ | ||
| 11 | MemberProfile memberProfile = build(memberId,realname,gender,"","","","","","", | ||
| 12 | "","","",birthday); | ||
| 13 | return memberProfile; | ||
| 14 | } | ||
| 15 | |||
| 16 | public static MemberProfile build(){ | ||
| 17 | MemberProfile memberProfile = build(null,"",null,"","","","","","", | ||
| 18 | "","","",null); | ||
| 19 | return memberProfile; | ||
| 20 | } | ||
| 21 | |||
| 22 | public static MemberProfile build(Long memberId, String realName, Integer sex, | ||
| 23 | String contry, String district, String city, String idCard, String province, | ||
| 24 | String email, String description, String phone, String constellation, | ||
| 25 | Timestamp timestamp) { | ||
| 26 | |||
| 27 | if (memberId == null) | ||
| 28 | throw new NullPointerException("memberId is null"); | ||
| 29 | |||
| 30 | MemberProfile memberProfile = new MemberProfile(); | ||
| 31 | memberProfile.setMemberId(memberId); | ||
| 32 | memberProfile.setRealname(stringIsNull(realName)); | ||
| 33 | memberProfile.setGender(sex == null ? 0 : sex); | ||
| 34 | memberProfile.setCountry(stringIsNull(contry)); | ||
| 35 | memberProfile.setDistrict(stringIsNull(district)); | ||
| 36 | memberProfile.setCity(stringIsNull(city)); | ||
| 37 | memberProfile.setIdCard(stringIsNull(idCard)); | ||
| 38 | memberProfile.setProvince(stringIsNull(province)); | ||
| 39 | memberProfile.setEmail(stringIsNull(email)); | ||
| 40 | memberProfile.setDescription(stringIsNull(description)); | ||
| 41 | memberProfile.setPhone(stringIsNull(phone)); | ||
| 42 | memberProfile.setConstellation(stringIsNull(constellation)); | ||
| 43 | memberProfile.setBirthday(timestamp); | ||
| 44 | |||
| 45 | return memberProfile; | ||
| 46 | } | ||
| 47 | |||
| 48 | private static String stringIsNull(String s){ | ||
| 49 | return StringUtils.isBlank(s)?"":s; | ||
| 50 | } | ||
| 51 | |||
| 52 | private static Object objectIsNull(Object s){ | ||
| 53 | return Objects.nonNull(s)?null:s; | ||
| 54 | } | ||
| 55 | |||
| 56 | } |
| ... | @@ -37,6 +37,8 @@ public interface MemberProfileService { | ... | @@ -37,6 +37,8 @@ public interface MemberProfileService { |
| 37 | 37 | ||
| 38 | MemberProfile create(MemberProfile resources); | 38 | MemberProfile create(MemberProfile resources); |
| 39 | 39 | ||
| 40 | MemberProfile createDefault(MemberProfile resources); | ||
| 41 | |||
| 40 | void update(MemberProfile resources); | 42 | void update(MemberProfile resources); |
| 41 | 43 | ||
| 42 | void delete(Long id); | 44 | void delete(Long id); | ... | ... |
| ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.profile.service.impl; | ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.profile.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | 3 | import com.topdraw.aspect.AsyncMqSend; |
| 4 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 4 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 5 | import com.topdraw.business.module.member.profile.domain.MemberProfileBuild; | ||
| 5 | import com.topdraw.utils.ValidationUtil; | 6 | import com.topdraw.utils.ValidationUtil; |
| 6 | import com.topdraw.business.module.member.profile.repository.MemberProfileRepository; | 7 | import com.topdraw.business.module.member.profile.repository.MemberProfileRepository; |
| 7 | import com.topdraw.business.module.member.profile.service.MemberProfileService; | 8 | import com.topdraw.business.module.member.profile.service.MemberProfileService; |
| ... | @@ -65,6 +66,16 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -65,6 +66,16 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | @Override | 68 | @Override |
| 69 | public MemberProfile createDefault(MemberProfile resources) { | ||
| 70 | Long memberId = resources.getMemberId(); | ||
| 71 | String realname = resources.getRealname(); | ||
| 72 | Integer gender = resources.getGender(); | ||
| 73 | MemberProfile memberProfile = MemberProfileBuild.build(); | ||
| 74 | MemberProfile memberProfile1 = this.MemberProfileRepository.save(memberProfile); | ||
| 75 | return memberProfile1; | ||
| 76 | } | ||
| 77 | |||
| 78 | @Override | ||
| 68 | @Transactional(rollbackFor = Exception.class) | 79 | @Transactional(rollbackFor = Exception.class) |
| 69 | @AsyncMqSend() | 80 | @AsyncMqSend() |
| 70 | public void update(MemberProfile resources) { | 81 | public void update(MemberProfile resources) { | ... | ... |
| 1 | package com.topdraw.business.module.member.rest; | 1 | package com.topdraw.business.module.member.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | ||
| 3 | import com.topdraw.annotation.Log; | 4 | import com.topdraw.annotation.Log; |
| 4 | import com.topdraw.business.module.member.domain.Member; | 5 | import com.topdraw.business.module.member.domain.Member; |
| 5 | import com.topdraw.business.module.member.service.MemberService; | 6 | import com.topdraw.business.module.member.service.MemberService; |
| ... | @@ -25,7 +26,7 @@ import java.util.Objects; | ... | @@ -25,7 +26,7 @@ import java.util.Objects; |
| 25 | */ | 26 | */ |
| 26 | @Api(tags = "Member管理") | 27 | @Api(tags = "Member管理") |
| 27 | @RestController | 28 | @RestController |
| 28 | @RequestMapping("/api/member") | 29 | @RequestMapping("/ucEngine/api/member") |
| 29 | @CrossOrigin | 30 | @CrossOrigin |
| 30 | public class MemberController { | 31 | public class MemberController { |
| 31 | 32 | ||
| ... | @@ -72,6 +73,7 @@ public class MemberController { | ... | @@ -72,6 +73,7 @@ public class MemberController { |
| 72 | @Log | 73 | @Log |
| 73 | @PutMapping(value = "/update") | 74 | @PutMapping(value = "/update") |
| 74 | @ApiOperation("修改Member") | 75 | @ApiOperation("修改Member") |
| 76 | @AnonymousAccess | ||
| 75 | public ResultInfo update(@Validated @RequestBody Member resources) { | 77 | public ResultInfo update(@Validated @RequestBody Member resources) { |
| 76 | Long memberId = resources.getId(); | 78 | Long memberId = resources.getId(); |
| 77 | Assert.notNull(memberId,"memberId can't be null"); | 79 | Assert.notNull(memberId,"memberId can't be null"); |
| ... | @@ -80,10 +82,6 @@ public class MemberController { | ... | @@ -80,10 +82,6 @@ public class MemberController { |
| 80 | String code = memberDTO.getCode(); | 82 | String code = memberDTO.getCode(); |
| 81 | Assert.notNull(code, "code can't be null"); | 83 | Assert.notNull(code, "code can't be null"); |
| 82 | resources.setCode(code); | 84 | resources.setCode(code); |
| 83 | String nickname = resources.getNickname(); | ||
| 84 | if (!StringUtils.isEmpty(nickname)) { | ||
| 85 | resources.setNickname(Base64Util.encode(nickname)); | ||
| 86 | } | ||
| 87 | memberService.update(resources); | 85 | memberService.update(resources); |
| 88 | } | 86 | } |
| 89 | return ResultInfo.success(); | 87 | return ResultInfo.success(); | ... | ... |
| ... | @@ -105,11 +105,10 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -105,11 +105,10 @@ public class MemberServiceImpl implements MemberService { |
| 105 | member.setDueCouponAmount(defaultValue); | 105 | member.setDueCouponAmount(defaultValue); |
| 106 | member.setBlackStatus(0L); | 106 | member.setBlackStatus(0L); |
| 107 | String nickname = member.getNickname(); | 107 | String nickname = member.getNickname(); |
| 108 | if (StringUtils.isEmpty(nickname)) { | 108 | if (StringUtils.isNotEmpty(nickname)) { |
| 109 | nickname = "未设置"; | 109 | String base64Nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8))); |
| 110 | member.setNickname(base64Nickname); | ||
| 110 | } | 111 | } |
| 111 | String base64Nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8))); | ||
| 112 | member.setNickname(base64Nickname); | ||
| 113 | return member; | 112 | return member; |
| 114 | } | 113 | } |
| 115 | 114 | ... | ... |
| ... | @@ -56,6 +56,16 @@ public class UserWeixinController { | ... | @@ -56,6 +56,16 @@ public class UserWeixinController { |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | @Log | 58 | @Log |
| 59 | @PutMapping(value = "/updateWeixinMemberProfile") | ||
| 60 | @ApiOperation("修改UserWeixin") | ||
| 61 | @AnonymousAccess | ||
| 62 | public ResultInfo updateWeixinMemberProfile(@Validated @RequestBody UserWeixin resources) { | ||
| 63 | UserWeixinService.update(resources); | ||
| 64 | return ResultInfo.success(); | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | @Log | ||
| 59 | @DeleteMapping(value = "/{id}") | 69 | @DeleteMapping(value = "/{id}") |
| 60 | @ApiOperation("删除UserWeixin") | 70 | @ApiOperation("删除UserWeixin") |
| 61 | public ResultInfo delete(@PathVariable Long id) { | 71 | public ResultInfo delete(@PathVariable Long id) { | ... | ... |
| ... | @@ -94,11 +94,13 @@ public class UserWeixinDTO implements Serializable { | ... | @@ -94,11 +94,13 @@ public class UserWeixinDTO implements Serializable { |
| 94 | // 授权时间 | 94 | // 授权时间 |
| 95 | private Timestamp authTime; | 95 | private Timestamp authTime; |
| 96 | 96 | ||
| 97 | private Integer sex; | 97 | private Integer gender; |
| 98 | 98 | ||
| 99 | private String country; | 99 | private String country; |
| 100 | 100 | ||
| 101 | private String province; | 101 | private String province; |
| 102 | 102 | ||
| 103 | private String city; | 103 | private String city; |
| 104 | |||
| 105 | private Integer sex; | ||
| 104 | } | 106 | } | ... | ... |
| ... | @@ -13,13 +13,13 @@ public class WeiXinUserBean { | ... | @@ -13,13 +13,13 @@ public class WeiXinUserBean { |
| 13 | 13 | ||
| 14 | private Long id; | 14 | private Long id; |
| 15 | 15 | ||
| 16 | private String unionId; | 16 | private String unionid; |
| 17 | 17 | ||
| 18 | /** */ | 18 | /** */ |
| 19 | private String openId; | 19 | private String openid; |
| 20 | 20 | ||
| 21 | /** */ | 21 | /** */ |
| 22 | private String appId; | 22 | private String appid; |
| 23 | 23 | ||
| 24 | /** 加密后的appId,参数 */ | 24 | /** 加密后的appId,参数 */ |
| 25 | private String wxAppid; | 25 | private String wxAppid; | ... | ... |
| ... | @@ -8,6 +8,7 @@ import com.topdraw.annotation.Log; | ... | @@ -8,6 +8,7 @@ import com.topdraw.annotation.Log; |
| 8 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 8 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 9 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 9 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 10 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 10 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 11 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | ||
| 11 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; | 12 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; |
| 12 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 13 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
| 13 | import com.topdraw.business.process.domian.TempIptvUser; | 14 | import com.topdraw.business.process.domian.TempIptvUser; |
| ... | @@ -71,23 +72,24 @@ public class UserOperationController { | ... | @@ -71,23 +72,24 @@ public class UserOperationController { |
| 71 | @PostMapping(value = "/createWeixinUserAndCreateMember") | 72 | @PostMapping(value = "/createWeixinUserAndCreateMember") |
| 72 | @ApiOperation("新增小屏账户同时创建会员信息") | 73 | @ApiOperation("新增小屏账户同时创建会员信息") |
| 73 | @AnonymousAccess | 74 | @AnonymousAccess |
| 74 | public ResultInfo createWeixinUserAndCreateMember(@Validated @RequestBody WeiXinUserBean resources) { | 75 | public ResultInfo createWeixinUserAndCreateMember(@Validated @RequestBody UserWeixin resources) { |
| 75 | 76 | ||
| 76 | log.info("Param ==> resource ==> [{}]",resources); | 77 | log.info("Param ==> resource ==> [{}]",resources); |
| 77 | 78 | ||
| 78 | String appId = resources.getAppId(); | 79 | String appId = resources.getAppid(); |
| 79 | if (StringUtils.isBlank(appId)) | 80 | if (StringUtils.isBlank(appId)) |
| 80 | throw new NullPointerException("appId is null !"); | 81 | throw new NullPointerException("appId is null !"); |
| 81 | 82 | ||
| 82 | String openId = resources.getOpenId(); | 83 | String openId = resources.getOpenid(); |
| 83 | if (StringUtils.isBlank(openId)) | 84 | if (StringUtils.isBlank(openId)) |
| 84 | throw new NullPointerException("openId is null !"); | 85 | throw new NullPointerException("openId is null !"); |
| 85 | 86 | ||
| 86 | String unionId = resources.getUnionId(); | 87 | String unionId = resources.getUnionid(); |
| 87 | if (StringUtils.isBlank(unionId)) | 88 | if (StringUtils.isBlank(unionId)) |
| 88 | throw new NullPointerException("unionId is null !"); | 89 | throw new NullPointerException("unionId is null !"); |
| 89 | 90 | ||
| 90 | boolean result = this.userTvOperationService.createWeixinUserAndCreateMember(resources); | 91 | UserWeixinDTO result = this.userTvOperationService.createWeixinUserAndCreateMember(resources); |
| 92 | |||
| 91 | return ResultInfo.success(result); | 93 | return ResultInfo.success(result); |
| 92 | } | 94 | } |
| 93 | 95 | ||
| ... | @@ -187,7 +189,7 @@ public class UserOperationController { | ... | @@ -187,7 +189,7 @@ public class UserOperationController { |
| 187 | @ApiOperation("微信小程序绑定大屏") | 189 | @ApiOperation("微信小程序绑定大屏") |
| 188 | @AnonymousAccess | 190 | @AnonymousAccess |
| 189 | public ResultInfo appletBind(@Validated @RequestBody BindBean resources) { | 191 | public ResultInfo appletBind(@Validated @RequestBody BindBean resources) { |
| 190 | String unionId = resources.getUnionId(); | 192 | String unionId = resources.getUnionid(); |
| 191 | if (StringUtils.isBlank(unionId)) | 193 | if (StringUtils.isBlank(unionId)) |
| 192 | Assert.state(StrUtil.isNotBlank(unionId), "跨屏绑定,请先进行授权"); | 194 | Assert.state(StrUtil.isNotBlank(unionId), "跨屏绑定,请先进行授权"); |
| 193 | 195 | ||
| ... | @@ -223,13 +225,13 @@ public class UserOperationController { | ... | @@ -223,13 +225,13 @@ public class UserOperationController { |
| 223 | private void parseSubscribe(SubscribeBean subscribeBean) throws IOException { | 225 | private void parseSubscribe(SubscribeBean subscribeBean) throws IOException { |
| 224 | if (Objects.nonNull(subscribeBean)) { | 226 | if (Objects.nonNull(subscribeBean)) { |
| 225 | 227 | ||
| 226 | String appId = subscribeBean.getAppId(); | 228 | String appId = subscribeBean.getAppid(); |
| 227 | // appId不得为空 | 229 | // appId不得为空 |
| 228 | if (StringUtils.isBlank(appId)) | 230 | if (StringUtils.isBlank(appId)) |
| 229 | throw new BadRequestException("appId 不存在!"); | 231 | throw new BadRequestException("appId 不存在!"); |
| 230 | 232 | ||
| 231 | // openId | 233 | // openId |
| 232 | String openId = subscribeBean.getOpenId(); | 234 | String openId = subscribeBean.getOpenid(); |
| 233 | if (StringUtils.isBlank(openId)) | 235 | if (StringUtils.isBlank(openId)) |
| 234 | throw new BadRequestException("openId 不存在!"); | 236 | throw new BadRequestException("openId 不存在!"); |
| 235 | 237 | ||
| ... | @@ -260,7 +262,7 @@ public class UserOperationController { | ... | @@ -260,7 +262,7 @@ public class UserOperationController { |
| 260 | if (StringUtils.isBlank(unionId)) | 262 | if (StringUtils.isBlank(unionId)) |
| 261 | throw new BadRequestException("unionId 不存在!"); | 263 | throw new BadRequestException("unionId 不存在!"); |
| 262 | 264 | ||
| 263 | subscribeBean.setUnionId(unionId); | 265 | subscribeBean.setUnionid(unionId); |
| 264 | 266 | ||
| 265 | // 大屏账户信息 | 267 | // 大屏账户信息 |
| 266 | JSONObject iptvUserInfo = null; | 268 | JSONObject iptvUserInfo = null; |
| ... | @@ -302,14 +304,6 @@ public class UserOperationController { | ... | @@ -302,14 +304,6 @@ public class UserOperationController { |
| 302 | return ResultInfo.success(result); | 304 | return ResultInfo.success(result); |
| 303 | } | 305 | } |
| 304 | 306 | ||
| 305 | @GetMapping(value = "/checkBind") | ||
| 306 | @ApiOperation("校验是否绑定") | ||
| 307 | public IResultInfo checkBind(BindBean bindBean) { | ||
| 308 | Assert.notNull(bindBean.getId(), "id can not be null"); | ||
| 309 | Map<String, Object> map = this.userTvOperationService.checkBind(bindBean); | ||
| 310 | return ResultInfo.success(map); | ||
| 311 | } | ||
| 312 | |||
| 313 | /** | 307 | /** |
| 314 | * @param data | 308 | * @param data |
| 315 | * @description 通过大屏关注的订阅号,因为订阅号不支持带参二维码, | 309 | * @description 通过大屏关注的订阅号,因为订阅号不支持带参二维码, | ... | ... |
| ... | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; | ... | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; |
| 4 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 4 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 6 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 6 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 7 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | ||
| 7 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 8 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
| 8 | import com.topdraw.business.process.domian.weixin.BindBean; | 9 | import com.topdraw.business.process.domian.weixin.BindBean; |
| 9 | import com.topdraw.business.process.domian.weixin.BuyVipBean; | 10 | import com.topdraw.business.process.domian.weixin.BuyVipBean; |
| ... | @@ -121,15 +122,8 @@ public interface UserOperationService { | ... | @@ -121,15 +122,8 @@ public interface UserOperationService { |
| 121 | */ | 122 | */ |
| 122 | boolean appletBind(BindBean resources); | 123 | boolean appletBind(BindBean resources); |
| 123 | 124 | ||
| 124 | /** | ||
| 125 | * | ||
| 126 | * @param bindBean | ||
| 127 | * @return | ||
| 128 | */ | ||
| 129 | Map<String, Object> checkBind(BindBean bindBean); | ||
| 130 | |||
| 131 | 125 | ||
| 132 | JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code); | 126 | JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code); |
| 133 | 127 | ||
| 134 | boolean createWeixinUserAndCreateMember(WeiXinUserBean resources); | 128 | UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources); |
| 135 | } | 129 | } | ... | ... |
| ... | @@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject; | ... | @@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject; |
| 9 | import com.topdraw.business.module.member.domain.Member; | 9 | import com.topdraw.business.module.member.domain.Member; |
| 10 | import com.topdraw.business.module.member.domain.MemberBuilder; | 10 | import com.topdraw.business.module.member.domain.MemberBuilder; |
| 11 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 11 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 12 | import com.topdraw.business.module.member.profile.domain.MemberProfileBuild; | ||
| 12 | import com.topdraw.business.module.member.profile.service.MemberProfileService; | 13 | import com.topdraw.business.module.member.profile.service.MemberProfileService; |
| 13 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 14 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 14 | import com.topdraw.business.module.member.service.MemberService; | 15 | import com.topdraw.business.module.member.service.MemberService; |
| ... | @@ -142,9 +143,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -142,9 +143,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 142 | */ | 143 | */ |
| 143 | @Override | 144 | @Override |
| 144 | public boolean subscribe(SubscribeBean resources) { | 145 | public boolean subscribe(SubscribeBean resources) { |
| 145 | String unionId = resources.getUnionId(); | 146 | String unionId = resources.getUnionid(); |
| 146 | String appId = resources.getAppId(); | 147 | String appId = resources.getAppid(); |
| 147 | String openId = resources.getOpenId(); | 148 | String openId = resources.getOpenid(); |
| 148 | 149 | ||
| 149 | // 小屏账户 | 150 | // 小屏账户 |
| 150 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | 151 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); |
| ... | @@ -268,8 +269,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -268,8 +269,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 268 | @Override | 269 | @Override |
| 269 | public boolean unsubscribe(SubscribeBean resources) { | 270 | public boolean unsubscribe(SubscribeBean resources) { |
| 270 | 271 | ||
| 271 | String appId = resources.getAppId(); | 272 | String appId = resources.getAppid(); |
| 272 | String openId = resources.getOpenId(); | 273 | String openId = resources.getOpenid(); |
| 273 | 274 | ||
| 274 | // 修改关注状态 0:未关注 | 275 | // 修改关注状态 0:未关注 |
| 275 | UserWeixinDTO userWeixinDTO = this.doUpdateUserWeiXinStatus(appId, openId, UNSUBSCRIBE_STATUS); | 276 | UserWeixinDTO userWeixinDTO = this.doUpdateUserWeiXinStatus(appId, openId, UNSUBSCRIBE_STATUS); |
| ... | @@ -1242,9 +1243,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1242,9 +1243,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1242 | 1243 | ||
| 1243 | @Override | 1244 | @Override |
| 1244 | public Object serviceLogin(WeiXinUserBean resources) { | 1245 | public Object serviceLogin(WeiXinUserBean resources) { |
| 1245 | String unionId = resources.getUnionId(); | 1246 | String unionId = resources.getUnionid(); |
| 1246 | String appId = resources.getAppId(); | 1247 | String appId = resources.getAppid(); |
| 1247 | String openId = resources.getOpenId(); | 1248 | String openId = resources.getOpenid(); |
| 1248 | 1249 | ||
| 1249 | // 小屏账户 | 1250 | // 小屏账户 |
| 1250 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | 1251 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); |
| ... | @@ -1331,32 +1332,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1331,32 +1332,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1331 | } | 1332 | } |
| 1332 | 1333 | ||
| 1333 | @Override | 1334 | @Override |
| 1334 | public Map<String, Object> checkBind(BindBean bindBean) { | ||
| 1335 | Map<String, Object> map = new HashMap<>(); | ||
| 1336 | Long id = bindBean.getId(); | ||
| 1337 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id); | ||
| 1338 | if (Objects.nonNull(userWeixinDTO.getId())) { | ||
| 1339 | Long memberId = userWeixinDTO.getMemberId(); | ||
| 1340 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
| 1341 | |||
| 1342 | if (Objects.isNull(memberDTO.getId())) { | ||
| 1343 | log.error("param => UserTv id ==> [{}]", id); | ||
| 1344 | throw new EntityNotFoundException(MemberDTO.class, "id", "小程序账户对应的会员不存在"); | ||
| 1345 | } | ||
| 1346 | |||
| 1347 | Long userIptvId = memberDTO.getUserIptvId(); | ||
| 1348 | if (Objects.nonNull(userIptvId)) { | ||
| 1349 | map.put("isBind", 1); | ||
| 1350 | map.put("platformUserId", userIptvId); | ||
| 1351 | return map; | ||
| 1352 | } else { | ||
| 1353 | map.put("isBind", 0); | ||
| 1354 | } | ||
| 1355 | } | ||
| 1356 | return map; | ||
| 1357 | } | ||
| 1358 | |||
| 1359 | @Override | ||
| 1360 | public JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code) { | 1335 | public JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code) { |
| 1361 | // 链接微信服务器 | 1336 | // 链接微信服务器 |
| 1362 | String url = WeChatConstants.CODE2SESSION.replace("APPID", appId) | 1337 | String url = WeChatConstants.CODE2SESSION.replace("APPID", appId) |
| ... | @@ -1379,15 +1354,16 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1379,15 +1354,16 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1379 | 1354 | ||
| 1380 | @Override | 1355 | @Override |
| 1381 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 1356 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
| 1382 | public boolean createWeixinUserAndCreateMember(WeiXinUserBean resources) { | 1357 | public UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources) { |
| 1383 | 1358 | ||
| 1384 | String appId = resources.getAppId(); | 1359 | String appId = resources.getAppid(); |
| 1385 | String openId = resources.getOpenId(); | 1360 | String openId = resources.getOpenid(); |
| 1386 | String unionId = resources.getUnionId(); | 1361 | String unionId = resources.getUnionid(); |
| 1387 | 1362 | ||
| 1363 | // 检查账户是否存在 | ||
| 1388 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | 1364 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); |
| 1389 | if (Objects.nonNull(userWeixinDTO)) | 1365 | if (Objects.nonNull(userWeixinDTO.getId())) |
| 1390 | throw new BadRequestException("账户已存在"); | 1366 | return userWeixinDTO; |
| 1391 | 1367 | ||
| 1392 | // 当前用户的任意微信app | 1368 | // 当前用户的任意微信app |
| 1393 | UserWeixinDTO userWeixinDTO1 = this.findFirstByUnionId(unionId); | 1369 | UserWeixinDTO userWeixinDTO1 = this.findFirstByUnionId(unionId); |
| ... | @@ -1399,16 +1375,33 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1399,16 +1375,33 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1399 | memberId = userWeixinDTO1.getMemberId(); | 1375 | memberId = userWeixinDTO1.getMemberId(); |
| 1400 | 1376 | ||
| 1401 | } else { | 1377 | } else { |
| 1378 | |||
| 1402 | userWeixinDTO1 = new UserWeixinDTO(); | 1379 | userWeixinDTO1 = new UserWeixinDTO(); |
| 1403 | BeanUtils.copyProperties(resources,userWeixinDTO1); | 1380 | BeanUtils.copyProperties(resources,userWeixinDTO1); |
| 1404 | // 创建会员 | 1381 | // 创建会员 |
| 1405 | memberId = this.doCreateMember(userWeixinDTO1,0); | 1382 | memberId = this.doCreateMember(userWeixinDTO1,vip); |
| 1383 | |||
| 1406 | } | 1384 | } |
| 1407 | 1385 | ||
| 1408 | // 保存微信账户 | 1386 | // 保存微信账户 |
| 1409 | this.doCreateUserWeiXin(userWeixinDTO1,memberId); | 1387 | userWeixinDTO1 = this.doCreateUserWeiXin(userWeixinDTO1,memberId); |
| 1410 | 1388 | ||
| 1411 | return true; | 1389 | // 创建会员属性信息 |
| 1390 | this.createMemberProfile(userWeixinDTO1); | ||
| 1391 | |||
| 1392 | return userWeixinDTO1; | ||
| 1393 | } | ||
| 1394 | |||
| 1395 | /** | ||
| 1396 | * | ||
| 1397 | * @param userWeixinDTO1 | ||
| 1398 | */ | ||
| 1399 | private void createMemberProfile(UserWeixinDTO userWeixinDTO1) { | ||
| 1400 | Long memberId = userWeixinDTO1.getMemberId(); | ||
| 1401 | String nickname = userWeixinDTO1.getNickname(); | ||
| 1402 | Integer sex = userWeixinDTO1.getGender(); | ||
| 1403 | MemberProfile memberProfile = MemberProfileBuild.build(memberId, nickname, sex, null); | ||
| 1404 | this.memberProfileService.create(memberProfile); | ||
| 1412 | } | 1405 | } |
| 1413 | 1406 | ||
| 1414 | private UserWeixinDTO findFirstByUnionId(String unionId) { | 1407 | private UserWeixinDTO findFirstByUnionId(String unionId) { | ... | ... |
-
Please register or sign in to post a comment