1.优化
Showing
12 changed files
with
138 additions
and
42 deletions
... | @@ -6,10 +6,11 @@ import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; | ... | @@ -6,10 +6,11 @@ import com.topdraw.business.module.contact.vis.service.dto.ActivityAddressDTO; |
6 | import com.topdraw.common.ResultInfo; | 6 | import com.topdraw.common.ResultInfo; |
7 | import com.topdraw.business.module.contact.vis.domain.ActivityAddress; | 7 | import com.topdraw.business.module.contact.vis.domain.ActivityAddress; |
8 | import com.topdraw.business.module.contact.vis.service.ActivityAddressService; | 8 | import com.topdraw.business.module.contact.vis.service.ActivityAddressService; |
9 | import com.topdraw.exception.BadRequestException; | ||
9 | import lombok.extern.slf4j.Slf4j; | 10 | import lombok.extern.slf4j.Slf4j; |
11 | import org.apache.commons.lang3.StringUtils; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.util.Assert; | 13 | import org.springframework.util.Assert; |
12 | import org.springframework.util.StringUtils; | ||
13 | import org.springframework.validation.annotation.Validated; | 14 | import org.springframework.validation.annotation.Validated; |
14 | import org.springframework.web.bind.annotation.*; | 15 | import org.springframework.web.bind.annotation.*; |
15 | import io.swagger.annotations.*; | 16 | import io.swagger.annotations.*; |
... | @@ -33,17 +34,22 @@ public class ActivityAddressController { | ... | @@ -33,17 +34,22 @@ public class ActivityAddressController { |
33 | @GetMapping(value = "/findByPlatformAccountAndActivityId") | 34 | @GetMapping(value = "/findByPlatformAccountAndActivityId") |
34 | @ApiOperation("查询指定活动事件的中奖人联系方式") | 35 | @ApiOperation("查询指定活动事件的中奖人联系方式") |
35 | @AnonymousAccess | 36 | @AnonymousAccess |
36 | public ResultInfo findByPlatformAccountAndActivityId(@Validated @RequestBody ActivityAddress resources) { | 37 | public ResultInfo findByPlatformAccountAndActivityId(@RequestParam(value = "platformAccount") String platformAccount, |
37 | log.info("activityAddress ==>> findByPlatformAccountAndActivityId ==>> resources ==>> {}", resources); | 38 | @RequestParam(value = "activityId") Long activityId) { |
38 | String platformAccount = resources.getPlatformAccount(); | 39 | log.info("activityAddress ==>> findByPlatformAccountAndActivityId ==>> platformAccount ==>> {}", platformAccount); |
39 | if (!StringUtils.hasText(platformAccount)) { | 40 | log.info("activityAddress ==>> findByPlatformAccountAndActivityId ==>> activityId ==>> {}", activityId); |
40 | Assert.notNull(platformAccount, "platformAccount is null"); | 41 | if (StringUtils.isBlank(platformAccount)) { |
42 | throw new BadRequestException("platformAccount is nul"); | ||
41 | } | 43 | } |
42 | Long activityId = resources.getActivityId(); | 44 | |
43 | if (Objects.isNull(activityId)) { | 45 | if (Objects.isNull(activityId)) { |
44 | Assert.notNull(activityId, "activityId is null"); | 46 | throw new BadRequestException("activityId is nul"); |
45 | } | 47 | } |
46 | ActivityAddressDTO activityAddressDTO = this.activityAddressService.findByPlatformAccountAndActivityId(resources); | 48 | |
49 | ActivityAddress activityAddress = new ActivityAddress(); | ||
50 | activityAddress.setPlatformAccount(platformAccount); | ||
51 | activityAddress.setActivityId(activityId); | ||
52 | ActivityAddressDTO activityAddressDTO = this.activityAddressService.findByPlatformAccountAndActivityId(activityAddress); | ||
47 | return ResultInfo.success(activityAddressDTO); | 53 | return ResultInfo.success(activityAddressDTO); |
48 | } | 54 | } |
49 | 55 | ||
... | @@ -63,32 +69,32 @@ public class ActivityAddressController { | ... | @@ -63,32 +69,32 @@ public class ActivityAddressController { |
63 | public ResultInfo createOrUpdateActivityAddress(@Validated @RequestBody ActivityAddress resources) { | 69 | public ResultInfo createOrUpdateActivityAddress(@Validated @RequestBody ActivityAddress resources) { |
64 | log.info("activityAddress ==>> createOrUpdateActivityAddress ==>> params ==>> {}", resources); | 70 | log.info("activityAddress ==>> createOrUpdateActivityAddress ==>> params ==>> {}", resources); |
65 | String platformAccount = resources.getPlatformAccount(); | 71 | String platformAccount = resources.getPlatformAccount(); |
66 | if (!StringUtils.hasText(platformAccount)) { | 72 | if (StringUtils.isBlank(platformAccount)) { |
67 | Assert.notNull(platformAccount, "platformAccount is null"); | 73 | throw new BadRequestException("platformAccount is null"); |
68 | } | 74 | } |
69 | Long appId = resources.getAppId(); | 75 | Long appId = resources.getAppId(); |
70 | if (Objects.isNull(appId)) { | 76 | if (Objects.isNull(appId)) { |
71 | Assert.notNull(appId, "appId is null"); | 77 | throw new BadRequestException("appId is null"); |
72 | } | 78 | } |
73 | Long activityId = resources.getActivityId(); | 79 | Long activityId = resources.getActivityId(); |
74 | if (Objects.isNull(activityId)) { | 80 | if (Objects.isNull(activityId)) { |
75 | Assert.notNull(activityId, "activityId is null"); | 81 | throw new BadRequestException("activityId is null"); |
76 | } | 82 | } |
77 | Long userId = resources.getUserId(); | 83 | Long userId = resources.getUserId(); |
78 | if (Objects.isNull(userId)) { | 84 | if (Objects.isNull(userId)) { |
79 | Assert.notNull(userId, "visUserId is null"); | 85 | throw new BadRequestException("visUserId is null"); |
80 | } | 86 | } |
81 | String name = resources.getName(); | 87 | String name = resources.getName(); |
82 | if (!StringUtils.hasText(name)) { | 88 | if (StringUtils.isBlank(name)) { |
83 | Assert.notNull(name, "name is null"); | 89 | throw new BadRequestException("name is null"); |
84 | } | 90 | } |
85 | String cellphone = resources.getCellphone(); | 91 | String cellphone = resources.getCellphone(); |
86 | if (!StringUtils.hasText(cellphone)) { | 92 | if (StringUtils.isBlank(cellphone)) { |
87 | Assert.notNull(cellphone, "cellphone is null"); | 93 | throw new BadRequestException("cellphone is null"); |
88 | } | 94 | } |
89 | String address = resources.getAddress(); | 95 | String address = resources.getAddress(); |
90 | if (!StringUtils.hasText(address)) { | 96 | if (StringUtils.isBlank(address)) { |
91 | Assert.notNull(address, "address is null"); | 97 | throw new BadRequestException( "address is null"); |
92 | } | 98 | } |
93 | ActivityAddressDTO activityAddressDTO = this.activityAddressService.createOrUpdateActivityAddress(resources); | 99 | ActivityAddressDTO activityAddressDTO = this.activityAddressService.createOrUpdateActivityAddress(resources); |
94 | return ResultInfo.success(activityAddressDTO); | 100 | return ResultInfo.success(activityAddressDTO); | ... | ... |
1 | package com.topdraw.business.module.member.profile.domain; | 1 | package com.topdraw.business.module.member.profile.domain; |
2 | 2 | ||
3 | import com.topdraw.business.module.common.validated.CreateGroup; | ||
3 | import com.topdraw.business.module.common.validated.UpdateGroup; | 4 | import com.topdraw.business.module.common.validated.UpdateGroup; |
4 | import lombok.Data; | 5 | import lombok.Data; |
5 | import lombok.experimental.Accessors; | 6 | import lombok.experimental.Accessors; |
... | @@ -44,6 +45,7 @@ public class MemberProfile implements Serializable { | ... | @@ -44,6 +45,7 @@ public class MemberProfile implements Serializable { |
44 | 45 | ||
45 | /** 会员id */ | 46 | /** 会员id */ |
46 | @Column(name = "member_id", nullable = false) | 47 | @Column(name = "member_id", nullable = false) |
48 | @NotNull(message = "memberId not be null!!" , groups = {CreateGroup.class}) | ||
47 | private Long memberId; | 49 | private Long memberId; |
48 | 50 | ||
49 | /** 姓名 */ | 51 | /** 姓名 */ | ... | ... |
... | @@ -5,6 +5,8 @@ import com.topdraw.exception.GlobeExceptionMsg; | ... | @@ -5,6 +5,8 @@ import com.topdraw.exception.GlobeExceptionMsg; |
5 | import org.apache.commons.lang3.StringUtils; | 5 | import org.apache.commons.lang3.StringUtils; |
6 | import org.springframework.util.Assert; | 6 | import org.springframework.util.Assert; |
7 | 7 | ||
8 | import java.util.Objects; | ||
9 | |||
8 | public class MemberProfileBuilder { | 10 | public class MemberProfileBuilder { |
9 | 11 | ||
10 | public static MemberProfile build(Member member){ | 12 | public static MemberProfile build(Member member){ |
... | @@ -67,13 +69,13 @@ public class MemberProfileBuilder { | ... | @@ -67,13 +69,13 @@ public class MemberProfileBuilder { |
67 | memberProfile.setCountry(stringIsNull(resources.getCountry())); | 69 | memberProfile.setCountry(stringIsNull(resources.getCountry())); |
68 | memberProfile.setDistrict(stringIsNull(resources.getDistrict())); | 70 | memberProfile.setDistrict(stringIsNull(resources.getDistrict())); |
69 | memberProfile.setCity(stringIsNull(resources.getCity())); | 71 | memberProfile.setCity(stringIsNull(resources.getCity())); |
70 | memberProfile.setIdCard(StringUtils.isBlank(resources.getIdCard())?"000000000000000000":resources.getIdCard()); | 72 | memberProfile.setIdCard(StringUtils.isBlank(resources.getIdCard()) ? "000000000000000000":resources.getIdCard()); |
71 | memberProfile.setProvince(stringIsNull(resources.getProvince())); | 73 | memberProfile.setProvince(stringIsNull(resources.getProvince())); |
72 | memberProfile.setEmail(stringIsNull(resources.getEmail())); | 74 | memberProfile.setEmail(stringIsNull(resources.getEmail())); |
73 | memberProfile.setDescription(stringIsNull(resources.getDescription())); | 75 | memberProfile.setDescription(stringIsNull(resources.getDescription())); |
74 | memberProfile.setPhone(stringIsNull(resources.getPhone())); | 76 | memberProfile.setPhone(stringIsNull(resources.getPhone())); |
75 | memberProfile.setConstellation(stringIsNull(resources.getConstellation())); | 77 | memberProfile.setConstellation(stringIsNull(resources.getConstellation())); |
76 | memberProfile.setBirthday(stringIsNull(resources.getBirthday())); | 78 | memberProfile.setBirthday(Objects.isNull(resources.getBirthday()) ? "1900-01-01" : resources.getBirthday()); |
77 | return memberProfile; | 79 | return memberProfile; |
78 | } | 80 | } |
79 | } | 81 | } | ... | ... |
... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.profile.rest; | ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.profile.rest; |
2 | 2 | ||
3 | import com.topdraw.annotation.AnonymousAccess; | 3 | import com.topdraw.annotation.AnonymousAccess; |
4 | import com.topdraw.aop.log.Log; | 4 | import com.topdraw.aop.log.Log; |
5 | import com.topdraw.business.module.common.validated.CreateGroup; | ||
5 | import com.topdraw.business.module.common.validated.UpdateGroup; | 6 | import com.topdraw.business.module.common.validated.UpdateGroup; |
6 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 7 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
7 | import com.topdraw.business.process.service.member.MemberProfileOperationService; | 8 | import com.topdraw.business.process.service.member.MemberProfileOperationService; |
... | @@ -53,4 +54,19 @@ public class MemberProfileController { | ... | @@ -53,4 +54,19 @@ public class MemberProfileController { |
53 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); | 54 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); |
54 | return ResultInfo.success(memberProfileDTO); | 55 | return ResultInfo.success(memberProfileDTO); |
55 | } | 56 | } |
57 | |||
58 | |||
59 | @Log("新增会员属性") | ||
60 | @RequestMapping(value = "/create") | ||
61 | @ApiOperation("新增会员属性") | ||
62 | @AnonymousAccess | ||
63 | @Deprecated | ||
64 | public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberProfile resources) { | ||
65 | |||
66 | log.info("memberProfile ==>> update ==>> resources ===>> [{}]",resources); | ||
67 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.createMemberProfileAndSyncMember(resources); | ||
68 | log.info("memberProfile ==>> update ==>> result ===>> [{}]",memberProfileDTO); | ||
69 | |||
70 | return ResultInfo.success(memberProfileDTO); | ||
71 | } | ||
56 | } | 72 | } | ... | ... |
... | @@ -23,28 +23,28 @@ public interface MemberProfileService { | ... | @@ -23,28 +23,28 @@ public interface MemberProfileService { |
23 | * @param resources 会员基本信息 | 23 | * @param resources 会员基本信息 |
24 | * @return | 24 | * @return |
25 | */ | 25 | */ |
26 | MemberProfile create(MemberProfile resources); | 26 | MemberProfileDTO create(MemberProfile resources); |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * 默认属性 | 29 | * 默认属性 |
30 | * @param resources | 30 | * @param resources |
31 | * @return | 31 | * @return |
32 | */ | 32 | */ |
33 | MemberProfile createDefault(MemberProfile resources); | 33 | MemberProfileDTO createDefault(MemberProfile resources); |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * 通过会员创建默认属性 | 36 | * 通过会员创建默认属性 |
37 | * @param resources | 37 | * @param resources |
38 | * @return | 38 | * @return |
39 | */ | 39 | */ |
40 | MemberProfile createDefault(Member resources); | 40 | MemberProfileDTO createDefault(Member resources); |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * 通过会员id创建默认属性 | 43 | * 通过会员id创建默认属性 |
44 | * @param resources | 44 | * @param resources |
45 | * @return | 45 | * @return |
46 | */ | 46 | */ |
47 | MemberProfile createDefaultByMemberId(Long resources); | 47 | MemberProfileDTO createDefaultByMemberId(Long resources); |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * 修改 | 50 | * 修改 | ... | ... |
... | @@ -53,7 +53,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -53,7 +53,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
53 | public MemberProfileDTO findByMemberId(Long memberId) { | 53 | public MemberProfileDTO findByMemberId(Long memberId) { |
54 | log.info("MemberProfileDTO ==>> findByMemberId ==>> resources ===>> [{}]",memberId); | 54 | log.info("MemberProfileDTO ==>> findByMemberId ==>> resources ===>> [{}]",memberId); |
55 | MemberProfile memberProfile = this.memberProfileRepository.findByMemberId(memberId).orElseGet(MemberProfile::new); | 55 | MemberProfile memberProfile = this.memberProfileRepository.findByMemberId(memberId).orElseGet(MemberProfile::new); |
56 | ValidationUtil.isNull(memberProfile.getId(),"MemberProfile","memberId",memberId); | 56 | // ValidationUtil.isNull(memberProfile.getId(),"MemberProfile","memberId",memberId); |
57 | return this.memberProfileMapper.toDto(memberProfile); | 57 | return this.memberProfileMapper.toDto(memberProfile); |
58 | } | 58 | } |
59 | 59 | ||
... | @@ -67,33 +67,35 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -67,33 +67,35 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
67 | 67 | ||
68 | @Override | 68 | @Override |
69 | @Transactional(rollbackFor = Exception.class) | 69 | @Transactional(rollbackFor = Exception.class) |
70 | public MemberProfile create(MemberProfile resources) { | 70 | public MemberProfileDTO create(MemberProfile resources) { |
71 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | 71 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); |
72 | 72 | ||
73 | // 检查会员 | 73 | // 检查会员 |
74 | this.checkMember(resources); | 74 | this.checkMember(resources); |
75 | 75 | ||
76 | this.memberProfileRepository.save(resources); | 76 | MemberProfile _memberProfile = this.memberProfileRepository.save(resources); |
77 | 77 | ||
78 | return resources; | 78 | MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); |
79 | BeanUtils.copyProperties(_memberProfile,memberProfileDTO); | ||
80 | return memberProfileDTO; | ||
79 | } | 81 | } |
80 | 82 | ||
81 | @Override | 83 | @Override |
82 | @Transactional(rollbackFor = Exception.class) | 84 | @Transactional(rollbackFor = Exception.class) |
83 | public MemberProfile createDefault(MemberProfile resources) { | 85 | public MemberProfileDTO createDefault(MemberProfile resources) { |
84 | MemberProfile memberProfile = MemberProfileBuilder.build(resources); | 86 | MemberProfile memberProfile = MemberProfileBuilder.build(resources); |
85 | return this.create(memberProfile); | 87 | return this.create(memberProfile); |
86 | } | 88 | } |
87 | 89 | ||
88 | @Override | 90 | @Override |
89 | @Transactional(rollbackFor = Exception.class) | 91 | @Transactional(rollbackFor = Exception.class) |
90 | public MemberProfile createDefault(Member resources) { | 92 | public MemberProfileDTO createDefault(Member resources) { |
91 | MemberProfile memberProfile = MemberProfileBuilder.build(resources); | 93 | MemberProfile memberProfile = MemberProfileBuilder.build(resources); |
92 | return this.create(memberProfile); | 94 | return this.create(memberProfile); |
93 | } | 95 | } |
94 | 96 | ||
95 | @Override | 97 | @Override |
96 | public MemberProfile createDefaultByMemberId(Long resources) { | 98 | public MemberProfileDTO createDefaultByMemberId(Long resources) { |
97 | MemberProfile memberProfile = MemberProfileBuilder.build(resources); | 99 | MemberProfile memberProfile = MemberProfileBuilder.build(resources); |
98 | return this.create(memberProfile); | 100 | return this.create(memberProfile); |
99 | } | 101 | } | ... | ... |
... | @@ -55,8 +55,6 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -55,8 +55,6 @@ public class MemberServiceImpl implements MemberService { |
55 | @Override | 55 | @Override |
56 | public MemberDTO findById(Long id) { | 56 | public MemberDTO findById(Long id) { |
57 | Member member = this.memberRepository.findById(id).orElseGet(Member::new); | 57 | Member member = this.memberRepository.findById(id).orElseGet(Member::new); |
58 | // ValidationUtil.isNull(member.getId(),"Member","id",id); | ||
59 | |||
60 | return this.memberMapper.toDto(member); | 58 | return this.memberMapper.toDto(member); |
61 | 59 | ||
62 | } | 60 | } | ... | ... |
1 | package com.topdraw.business.process.domian.member; | 1 | package com.topdraw.business.process.domian.member; |
2 | 2 | ||
3 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
4 | import lombok.Data; | 3 | import lombok.Data; |
5 | 4 | ||
6 | import java.sql.Timestamp; | 5 | import java.sql.Timestamp; |
7 | import java.time.LocalDateTime; | ||
8 | 6 | ||
9 | /** | 7 | /** |
10 | * @author : | 8 | * @author : |
... | @@ -25,4 +23,6 @@ public class MemberOperationBean { | ... | @@ -25,4 +23,6 @@ public class MemberOperationBean { |
25 | // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") | 23 | // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
26 | private Timestamp vipExpireTime; | 24 | private Timestamp vipExpireTime; |
27 | 25 | ||
26 | |||
27 | |||
28 | } | 28 | } | ... | ... |
... | @@ -4,11 +4,13 @@ import com.topdraw.annotation.AnonymousAccess; | ... | @@ -4,11 +4,13 @@ import com.topdraw.annotation.AnonymousAccess; |
4 | import com.topdraw.aop.log.Log; | 4 | import com.topdraw.aop.log.Log; |
5 | import com.topdraw.business.module.common.validated.UpdateGroup; | 5 | import com.topdraw.business.module.common.validated.UpdateGroup; |
6 | import com.topdraw.business.module.member.domain.Member; | 6 | import com.topdraw.business.module.member.domain.Member; |
7 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | ||
7 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 8 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
8 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 9 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
9 | import com.topdraw.business.process.domian.member.MemberOperationBean; | 10 | import com.topdraw.business.process.domian.member.MemberOperationBean; |
10 | import com.topdraw.business.process.domian.weixin.BuyVipBean; | 11 | import com.topdraw.business.process.domian.weixin.BuyVipBean; |
11 | import com.topdraw.business.process.service.member.MemberOperationService; | 12 | import com.topdraw.business.process.service.member.MemberOperationService; |
13 | import com.topdraw.business.process.service.member.MemberProfileOperationService; | ||
12 | import com.topdraw.common.IResultInfo; | 14 | import com.topdraw.common.IResultInfo; |
13 | import com.topdraw.common.ResultInfo; | 15 | import com.topdraw.common.ResultInfo; |
14 | import com.topdraw.exception.BadRequestException; | 16 | import com.topdraw.exception.BadRequestException; |
... | @@ -34,6 +36,7 @@ public class MemberOperationController { | ... | @@ -34,6 +36,7 @@ public class MemberOperationController { |
34 | @Autowired | 36 | @Autowired |
35 | private MemberOperationService memberOperationService; | 37 | private MemberOperationService memberOperationService; |
36 | 38 | ||
39 | |||
37 | @Log("手动修改vip") | 40 | @Log("手动修改vip") |
38 | @RequestMapping(value = "/updateVipByMemberId") | 41 | @RequestMapping(value = "/updateVipByMemberId") |
39 | @ApiOperation("手动修改vip") | 42 | @ApiOperation("手动修改vip") | ... | ... |
... | @@ -173,7 +173,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -173,7 +173,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
173 | Integer sex = resources.getSex(); | 173 | Integer sex = resources.getSex(); |
174 | 174 | ||
175 | // 检查小屏账户是否存在 | 175 | // 检查小屏账户是否存在 |
176 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | 176 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId, appId, openId); |
177 | if (Objects.nonNull(userWeixinDTO.getId())) { | 177 | if (Objects.nonNull(userWeixinDTO.getId())) { |
178 | log.error("createWeixinUserAndMember ==>> result ==>> [{}]", userWeixinDTO); | 178 | log.error("createWeixinUserAndMember ==>> result ==>> [{}]", userWeixinDTO); |
179 | throw new BadRequestException(GlobeExceptionMsg.OPERATION_FORBID + "==>> " + GlobeExceptionMsg.ENTITY_ALREADY_EXISTS); | 179 | throw new BadRequestException(GlobeExceptionMsg.OPERATION_FORBID + "==>> " + GlobeExceptionMsg.ENTITY_ALREADY_EXISTS); |
... | @@ -183,22 +183,25 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -183,22 +183,25 @@ public class UserOperationServiceImpl implements UserOperationService { |
183 | UserWeixinDTO _userWeixinDTO = this.findFirstByUnionId(unionId); | 183 | UserWeixinDTO _userWeixinDTO = this.findFirstByUnionId(unionId); |
184 | if (Objects.nonNull(_userWeixinDTO.getId())) { | 184 | if (Objects.nonNull(_userWeixinDTO.getId())) { |
185 | 185 | ||
186 | Assert.notNull(_userWeixinDTO.getMemberId(),GlobeExceptionMsg.MEMBER_ID_IS_NULL); | 186 | Assert.notNull(_userWeixinDTO.getMemberId(), GlobeExceptionMsg.MEMBER_ID_IS_NULL); |
187 | 187 | ||
188 | // 小屏会员 | 188 | // 小屏会员 |
189 | MemberDTO memberDTO = this.findMemberById(_userWeixinDTO.getMemberId()); | 189 | MemberDTO memberDTO = this.findMemberById(_userWeixinDTO.getMemberId()); |
190 | if (Objects.nonNull(memberDTO)) { | 190 | if (Objects.nonNull(memberDTO)) { |
191 | |||
191 | resources.setMemberId(_userWeixinDTO.getMemberId()); | 192 | resources.setMemberId(_userWeixinDTO.getMemberId()); |
192 | UserWeixin userWeixin = UserWeixinBuilder.build(resources); | 193 | UserWeixin userWeixin = UserWeixinBuilder.build(resources); |
193 | UserWeixinDTO weixinDTO = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); | 194 | UserWeixinDTO weixinDTO = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); |
194 | weixinDTO.setMemberCode(memberDTO.getCode()); | 195 | weixinDTO.setMemberCode(memberDTO.getCode()); |
196 | |||
195 | // 同步至iptv | 197 | // 同步至iptv |
196 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncWeixin(weixinDTO); | 198 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncWeixin(weixinDTO); |
197 | 199 | ||
198 | return weixinDTO; | 200 | return weixinDTO; |
201 | |||
199 | } | 202 | } |
200 | 203 | ||
201 | throw new EntityNotFoundException(MemberDTO.class,"code",GlobeExceptionMsg.MEMBER_CODE_IS_NULL); | 204 | throw new EntityNotFoundException(MemberDTO.class, "code", GlobeExceptionMsg.MEMBER_CODE_IS_NULL); |
202 | 205 | ||
203 | } else { | 206 | } else { |
204 | 207 | ||
... | @@ -206,6 +209,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -206,6 +209,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
206 | Member _member = | 209 | Member _member = |
207 | MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_WEIXIN, | 210 | MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_WEIXIN, |
208 | headimgurl, nickname, 0, sex); | 211 | headimgurl, nickname, 0, sex); |
212 | |||
209 | MemberDTO memberDTO = this.createMember(_member); | 213 | MemberDTO memberDTO = this.createMember(_member); |
210 | 214 | ||
211 | if (Objects.nonNull(memberDTO)) { | 215 | if (Objects.nonNull(memberDTO)) { |
... | @@ -213,12 +217,13 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -213,12 +217,13 @@ public class UserOperationServiceImpl implements UserOperationService { |
213 | UserWeixinDTO _userWeixinDTO1 = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); | 217 | UserWeixinDTO _userWeixinDTO1 = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); |
214 | 218 | ||
215 | // 同步至iptv | 219 | // 同步至iptv |
216 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMemberAndUserWeixin4Iptv(new MemberAndWeixinUserDTO(memberDTO, _userWeixinDTO1)); | 220 | ((UserOperationServiceImpl)AopContext.currentProxy()). |
221 | asyncMemberAndUserWeixin4Iptv(new MemberAndWeixinUserDTO(memberDTO, _userWeixinDTO1)); | ||
217 | 222 | ||
218 | return _userWeixinDTO1; | 223 | return _userWeixinDTO1; |
219 | } | 224 | } |
220 | 225 | ||
221 | throw new EntityNotFoundException(MemberDTO.class,"code",GlobeExceptionMsg.MEMBER_CODE_IS_NULL); | 226 | throw new EntityNotFoundException(MemberDTO.class, "code", GlobeExceptionMsg.MEMBER_CODE_IS_NULL); |
222 | 227 | ||
223 | } | 228 | } |
224 | 229 | ... | ... |
1 | package com.topdraw.business.process.service.impl.member; | 1 | package com.topdraw.business.process.service.impl.member; |
2 | 2 | ||
3 | import com.topdraw.aspect.AsyncMqSend; | 3 | import com.topdraw.aspect.AsyncMqSend; |
4 | import com.topdraw.business.module.member.domain.Member; | ||
4 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 5 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
5 | import com.topdraw.business.module.member.profile.service.MemberProfileService; | 6 | import com.topdraw.business.module.member.profile.service.MemberProfileService; |
6 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 7 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
... | @@ -8,12 +9,16 @@ import com.topdraw.business.module.member.service.MemberService; | ... | @@ -8,12 +9,16 @@ import com.topdraw.business.module.member.service.MemberService; |
8 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 9 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
9 | import com.topdraw.business.process.service.dto.MemberProfileAndMemberDTO; | 10 | import com.topdraw.business.process.service.dto.MemberProfileAndMemberDTO; |
10 | import com.topdraw.business.process.service.member.MemberProfileOperationService; | 11 | import com.topdraw.business.process.service.member.MemberProfileOperationService; |
12 | import com.topdraw.exception.EntityExistException; | ||
13 | import com.topdraw.exception.EntityNotFoundException; | ||
11 | import org.apache.commons.lang3.StringUtils; | 14 | import org.apache.commons.lang3.StringUtils; |
12 | import org.springframework.aop.framework.AopContext; | 15 | import org.springframework.aop.framework.AopContext; |
16 | import org.springframework.beans.BeanUtils; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
15 | 19 | ||
16 | import javax.validation.constraints.NotNull; | 20 | import javax.validation.constraints.NotNull; |
21 | import java.util.Objects; | ||
17 | 22 | ||
18 | 23 | ||
19 | /** | 24 | /** |
... | @@ -37,6 +42,8 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation | ... | @@ -37,6 +42,8 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation |
37 | public void asyncMemberProfile(MemberProfileDTO memberProfileDTO){} | 42 | public void asyncMemberProfile(MemberProfileDTO memberProfileDTO){} |
38 | @AsyncMqSend | 43 | @AsyncMqSend |
39 | public void asyncMemberProfileAndMember(MemberProfileAndMemberDTO memberProfileAndMemberDTO){} | 44 | public void asyncMemberProfileAndMember(MemberProfileAndMemberDTO memberProfileAndMemberDTO){} |
45 | @AsyncMqSend | ||
46 | public void asyncCreateMemberProfile(MemberProfileDTO memberProfileDTO) {} | ||
40 | 47 | ||
41 | @Override | 48 | @Override |
42 | public MemberProfileDTO update(MemberProfile resources) { | 49 | public MemberProfileDTO update(MemberProfile resources) { |
... | @@ -65,4 +72,52 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation | ... | @@ -65,4 +72,52 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation |
65 | 72 | ||
66 | return memberProfileDTO; | 73 | return memberProfileDTO; |
67 | } | 74 | } |
75 | |||
76 | @Override | ||
77 | public MemberProfileDTO createMemberProfileAndSyncMember(MemberProfile resources) { | ||
78 | MemberDTO memberDTO = this.memberService.findById(resources.getMemberId()); | ||
79 | if (Objects.isNull(memberDTO.getId())) | ||
80 | throw new EntityNotFoundException(MemberDTO.class, "code", memberDTO.getCode()); | ||
81 | |||
82 | MemberProfileDTO _memberProfileDTO = this.memberProfileService.findByMemberId(resources.getMemberId()); | ||
83 | |||
84 | if (Objects.isNull(_memberProfileDTO.getId())) { | ||
85 | |||
86 | MemberProfileDTO memberProfileDTO = this.memberProfileService.createDefault(resources); | ||
87 | memberProfileDTO.setMemberCode(memberDTO.getCode()); | ||
88 | |||
89 | this.createMemberProfileAndSyncMember(memberProfileDTO, memberDTO); | ||
90 | |||
91 | ((MemberProfileOperationServiceImpl) AopContext.currentProxy()).asyncCreateMemberProfile(memberProfileDTO); | ||
92 | |||
93 | } else { | ||
94 | |||
95 | throw new EntityExistException(MemberProfileDTO.class, "id", _memberProfileDTO.getId().toString()); | ||
96 | |||
97 | } | ||
98 | |||
99 | return null; | ||
100 | } | ||
101 | |||
102 | private void createMemberProfile(MemberProfileDTO memberProfileDTO) { | ||
103 | MemberProfile memberProfile = new MemberProfile(); | ||
104 | BeanUtils.copyProperties(memberProfileDTO, memberProfile); | ||
105 | this.memberProfileService.createDefault(memberProfile); | ||
106 | } | ||
107 | |||
108 | private void createMemberProfileAndSyncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) { | ||
109 | this.createMemberProfile(memberProfileDTO); | ||
110 | this.syncMember(memberProfileDTO, memberDTO); | ||
111 | } | ||
112 | |||
113 | private void syncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) { | ||
114 | memberDTO.setAvatarUrl(memberProfileDTO.getAvatarUrl()); | ||
115 | memberDTO.setNickname(memberProfileDTO.getRealname()); | ||
116 | memberDTO.setGender(memberProfileDTO.getGender()); | ||
117 | Member member = new Member(); | ||
118 | BeanUtils.copyProperties(memberDTO, member); | ||
119 | this.memberService.update(member); | ||
120 | } | ||
121 | |||
122 | |||
68 | } | 123 | } | ... | ... |
... | @@ -17,4 +17,11 @@ public interface MemberProfileOperationService { | ... | @@ -17,4 +17,11 @@ public interface MemberProfileOperationService { |
17 | */ | 17 | */ |
18 | MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources); | 18 | MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources); |
19 | 19 | ||
20 | /** | ||
21 | * | ||
22 | * @param resources | ||
23 | * @return | ||
24 | */ | ||
25 | MemberProfileDTO createMemberProfileAndSyncMember(MemberProfile resources); | ||
26 | |||
20 | } | 27 | } | ... | ... |
-
Please register or sign in to post a comment