1.优化
Showing
19 changed files
with
249 additions
and
223 deletions
... | @@ -26,7 +26,7 @@ public class MemberAddress extends AsyncMqModule implements Serializable { | ... | @@ -26,7 +26,7 @@ public class MemberAddress extends AsyncMqModule implements Serializable { |
26 | 26 | ||
27 | /** 主键 */ | 27 | /** 主键 */ |
28 | @Id | 28 | @Id |
29 | @GeneratedValue(strategy = GenerationType.SEQUENCE) | 29 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
30 | @Column(name = "id") | 30 | @Column(name = "id") |
31 | private Long id; | 31 | private Long id; |
32 | 32 | ... | ... |
... | @@ -10,4 +10,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ... | @@ -10,4 +10,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
10 | */ | 10 | */ |
11 | public interface MemberAddressRepository extends JpaRepository<MemberAddress, Long>, JpaSpecificationExecutor<MemberAddress> { | 11 | public interface MemberAddressRepository extends JpaRepository<MemberAddress, Long>, JpaSpecificationExecutor<MemberAddress> { |
12 | 12 | ||
13 | |||
14 | MemberAddress findByMemberIdAndSequence(Long memberId, Integer sequence); | ||
13 | } | 15 | } | ... | ... |
... | @@ -33,4 +33,12 @@ public interface MemberAddressService { | ... | @@ -33,4 +33,12 @@ public interface MemberAddressService { |
33 | * @param resources | 33 | * @param resources |
34 | */ | 34 | */ |
35 | void delete(Long resources); | 35 | void delete(Long resources); |
36 | |||
37 | /** | ||
38 | * | ||
39 | * @param memberId | ||
40 | * @param sequence | ||
41 | * @return | ||
42 | */ | ||
43 | MemberAddressDTO findByMemberIdAndSequence(Long memberId, Integer sequence); | ||
36 | } | 44 | } | ... | ... |
... | @@ -13,6 +13,9 @@ import java.time.LocalDateTime; | ... | @@ -13,6 +13,9 @@ import java.time.LocalDateTime; |
13 | @Data | 13 | @Data |
14 | public class MemberAddressDTO implements Serializable { | 14 | public class MemberAddressDTO implements Serializable { |
15 | 15 | ||
16 | /** 会员code */ | ||
17 | private String memberCode; | ||
18 | |||
16 | /** 主键 */ | 19 | /** 主键 */ |
17 | private Long id; | 20 | private Long id; |
18 | 21 | ... | ... |
... | @@ -46,9 +46,7 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -46,9 +46,7 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
46 | @Transactional(rollbackFor = Exception.class) | 46 | @Transactional(rollbackFor = Exception.class) |
47 | public MemberAddressDTO create(MemberAddress resources) { | 47 | public MemberAddressDTO create(MemberAddress resources) { |
48 | log.info("MemberAddressServiceImpl ==>> create ==>> param ==>> [{}]",resources); | 48 | log.info("MemberAddressServiceImpl ==>> create ==>> param ==>> [{}]",resources); |
49 | MemberDTO memberDTO = this.checkMember(resources); | 49 | MemberAddress memberAddress = this.memberAddressRepository.save(resources); |
50 | MemberAddress _memberAddress = MemberAddressBuilder.build(resources, memberDTO.getId(), memberDTO.getCode()); | ||
51 | MemberAddress memberAddress = this.memberAddressRepository.save(_memberAddress); | ||
52 | 50 | ||
53 | log.info("MemberAddressServiceImpl ==>> create ==>> result ==>> [{}]",resources); | 51 | log.info("MemberAddressServiceImpl ==>> create ==>> result ==>> [{}]",resources); |
54 | MemberAddressDTO memberAddressDTO = new MemberAddressDTO(); | 52 | MemberAddressDTO memberAddressDTO = new MemberAddressDTO(); |
... | @@ -63,9 +61,6 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -63,9 +61,6 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
63 | log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources); | 61 | log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources); |
64 | Assert.notNull(resources.getId(),"id can't be null"); | 62 | Assert.notNull(resources.getId(),"id can't be null"); |
65 | try { | 63 | try { |
66 | MemberDTO memberDTO = this.checkMember(resources); | ||
67 | resources.setMemberCode(memberDTO.getCode()); | ||
68 | |||
69 | MemberAddress _memberAddress = this.memberAddressRepository.findById(resources.getId()).orElseGet(MemberAddress::new); | 64 | MemberAddress _memberAddress = this.memberAddressRepository.findById(resources.getId()).orElseGet(MemberAddress::new); |
70 | ValidationUtil.isNull( _memberAddress.getId(),"MemberAddress","id",resources.getId()); | 65 | ValidationUtil.isNull( _memberAddress.getId(),"MemberAddress","id",resources.getId()); |
71 | _memberAddress.copy(resources); | 66 | _memberAddress.copy(resources); |
... | @@ -92,6 +87,12 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -92,6 +87,12 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
92 | this.memberAddressRepository.delete(MemberAddress); | 87 | this.memberAddressRepository.delete(MemberAddress); |
93 | } | 88 | } |
94 | 89 | ||
90 | @Override | ||
91 | public MemberAddressDTO findByMemberIdAndSequence(Long memberId, Integer sequence) { | ||
92 | MemberAddress memberAddress = this.memberAddressRepository.findByMemberIdAndSequence(memberId, sequence); | ||
93 | return this.memberAddressMapper.toDto(memberAddress); | ||
94 | } | ||
95 | |||
95 | /** | 96 | /** |
96 | * 检查会员 | 97 | * 检查会员 |
97 | * @param memberAddress | 98 | * @param memberAddress | ... | ... |
... | @@ -35,7 +35,7 @@ public class Member implements Serializable { | ... | @@ -35,7 +35,7 @@ public class Member implements Serializable { |
35 | 35 | ||
36 | /** 主键 */ | 36 | /** 主键 */ |
37 | @Id | 37 | @Id |
38 | @GeneratedValue(strategy = GenerationType.AUTO) | 38 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
39 | @Column(name = "id") | 39 | @Column(name = "id") |
40 | @NotNull(message = "id can't be null!!",groups = {UpdateGroup.class}) | 40 | @NotNull(message = "id can't be null!!",groups = {UpdateGroup.class}) |
41 | private Long id; | 41 | private Long id; | ... | ... |
... | @@ -13,6 +13,9 @@ import java.sql.Timestamp; | ... | @@ -13,6 +13,9 @@ import java.sql.Timestamp; |
13 | @Data | 13 | @Data |
14 | public class MemberProfileDTO implements Serializable { | 14 | public class MemberProfileDTO implements Serializable { |
15 | 15 | ||
16 | /** 会员code */ | ||
17 | private String memberCode; | ||
18 | |||
16 | /** 主键 */ | 19 | /** 主键 */ |
17 | private Long id; | 20 | private Long id; |
18 | 21 | ... | ... |
... | @@ -108,17 +108,18 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -108,17 +108,18 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
108 | 108 | ||
109 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | 109 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); |
110 | // 检查会员是否存在 | 110 | // 检查会员是否存在 |
111 | this.checkMember(resources); | 111 | MemberDTO memberDTO = this.checkMember(resources); |
112 | // 真实姓名(加密) | 112 | // 真实姓名(加密) |
113 | String realName = resources.getRealname(); | 113 | String realName = resources.getRealname(); |
114 | if (StringUtils.isNotBlank(realName)) { | 114 | if (StringUtils.isNotBlank(realName)) { |
115 | resources.setRealname(Base64Util.encode(realName)); | 115 | resources.setRealname(Base64Util.encode(realName)); |
116 | } | 116 | } |
117 | 117 | ||
118 | MemberProfile memberProfile = new MemberProfile(); | 118 | MemberProfileDTO _memberProfileDTO = this.findByMemberId(memberDTO.getId()); |
119 | BeanUtils.copyProperties(resources,memberProfile); | 119 | resources.setMemberId(_memberProfileDTO.getMemberId()); |
120 | MemberProfile _memberProfile = this.memberProfileRepository.save(memberProfile); | 120 | resources.setId(_memberProfileDTO.getId()); |
121 | 121 | resources.setCreateTime(_memberProfileDTO.getCreateTime()); | |
122 | MemberProfile _memberProfile = this.memberProfileRepository.save(resources); | ||
122 | 123 | ||
123 | MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); | 124 | MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); |
124 | BeanUtils.copyProperties(_memberProfile,memberProfileDTO); | 125 | BeanUtils.copyProperties(_memberProfile,memberProfileDTO); | ... | ... |
... | @@ -29,7 +29,7 @@ public class MemberRelatedInfo extends AsyncMqModule implements Serializable { | ... | @@ -29,7 +29,7 @@ public class MemberRelatedInfo extends AsyncMqModule implements Serializable { |
29 | 29 | ||
30 | /** ID */ | 30 | /** ID */ |
31 | @Id | 31 | @Id |
32 | @GeneratedValue(strategy = GenerationType.SEQUENCE) | 32 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
33 | @Column(name = "id") | 33 | @Column(name = "id") |
34 | @NotNull(message = "id can't be null" , groups = {UpdateGroup.class}) | 34 | @NotNull(message = "id can't be null" , groups = {UpdateGroup.class}) |
35 | private Long id; | 35 | private Long id; | ... | ... |
... | @@ -101,15 +101,15 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -101,15 +101,15 @@ public class MemberServiceImpl implements MemberService { |
101 | public MemberDTO create(Member resources) { | 101 | public MemberDTO create(Member resources) { |
102 | 102 | ||
103 | Member member = MemberBuilder.build(resources); | 103 | Member member = MemberBuilder.build(resources); |
104 | Long memberId = this.save(member); | 104 | Member _member = this.save(member); |
105 | 105 | ||
106 | if (Objects.nonNull(memberId)) { | 106 | if (Objects.nonNull(_member.getId())) { |
107 | MemberProfile memberProfile = MemberProfileBuilder.build(member); | 107 | MemberProfile memberProfile = MemberProfileBuilder.build(_member); |
108 | // 保存会员属性 | 108 | // 保存会员属性 |
109 | this.memberProfileService.create(memberProfile); | 109 | this.memberProfileService.create(memberProfile); |
110 | } | 110 | } |
111 | 111 | ||
112 | return this.memberMapper.toDto(member); | 112 | return this.memberMapper.toDto(_member); |
113 | 113 | ||
114 | } | 114 | } |
115 | 115 | ||
... | @@ -130,14 +130,12 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -130,14 +130,12 @@ public class MemberServiceImpl implements MemberService { |
130 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); | 130 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); |
131 | try { | 131 | try { |
132 | MemberDTO memberDTO = this.checkMember(resources); | 132 | MemberDTO memberDTO = this.checkMember(resources); |
133 | resources.setId(memberDTO.getId()); | ||
134 | resources.setCode(memberDTO.getCode()); | ||
135 | resources.setCreateTime(memberDTO.getCreateTime()); | ||
136 | Member _member = this.save(resources); | ||
137 | return this.memberMapper.toDto(_member); | ||
133 | 138 | ||
134 | Member member = new Member(); | ||
135 | BeanUtils.copyProperties(memberDTO,member); | ||
136 | member.copy(resources); | ||
137 | |||
138 | this.save(member); | ||
139 | |||
140 | return this.memberMapper.toDto(member); | ||
141 | } catch (Exception e) { | 139 | } catch (Exception e) { |
142 | e.printStackTrace(); | 140 | e.printStackTrace(); |
143 | throw e; | 141 | throw e; |
... | @@ -145,24 +143,22 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -145,24 +143,22 @@ public class MemberServiceImpl implements MemberService { |
145 | 143 | ||
146 | } | 144 | } |
147 | 145 | ||
148 | public Long save(Member member){ | 146 | public Member save(Member member){ |
149 | this.memberRepository.save(member); | 147 | return this.memberRepository.save(member); |
150 | return member.getId(); | ||
151 | } | 148 | } |
152 | 149 | ||
153 | @Override | 150 | @Override |
154 | @Transactional(rollbackFor = Exception.class) | 151 | @Transactional(rollbackFor = Exception.class) |
155 | public MemberDTO doUpdateMemberPoints(Member resources) { | 152 | public MemberDTO doUpdateMemberPoints(Member resources) { |
156 | try { | 153 | try { |
157 | //this.redisUtils.doLock("member::update::code" + resources.getCode()); | ||
158 | 154 | ||
159 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); | 155 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); |
160 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | 156 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); |
161 | member.copy(resources); | 157 | member.copy(resources); |
162 | 158 | ||
163 | this.save(member); | 159 | Member _member = this.save(member); |
164 | 160 | ||
165 | return this.memberMapper.toDto(member); | 161 | return this.memberMapper.toDto(_member); |
166 | 162 | ||
167 | } catch (Exception e) { | 163 | } catch (Exception e) { |
168 | e.printStackTrace(); | 164 | e.printStackTrace(); | ... | ... |
... | @@ -27,7 +27,7 @@ public class MemberVipHistory extends AsyncMqModule implements Serializable { | ... | @@ -27,7 +27,7 @@ public class MemberVipHistory extends AsyncMqModule implements Serializable { |
27 | 27 | ||
28 | // 主键 | 28 | // 主键 |
29 | @Id | 29 | @Id |
30 | @GeneratedValue(strategy = GenerationType.SEQUENCE) | 30 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
31 | @Column(name = "id") | 31 | @Column(name = "id") |
32 | private Long id; | 32 | private Long id; |
33 | 33 | ... | ... |
... | @@ -37,7 +37,7 @@ public class UserTv extends AsyncMqModule implements Serializable { | ... | @@ -37,7 +37,7 @@ public class UserTv extends AsyncMqModule implements Serializable { |
37 | 37 | ||
38 | /** ID */ | 38 | /** ID */ |
39 | @Id | 39 | @Id |
40 | @GeneratedValue(strategy = GenerationType.AUTO) | 40 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
41 | @Column(name = "id") | 41 | @Column(name = "id") |
42 | private Long id; | 42 | private Long id; |
43 | 43 | ... | ... |
1 | package com.topdraw.business.process.service.dto; | ||
2 | |||
3 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | ||
4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
5 | import lombok.AllArgsConstructor; | ||
6 | import lombok.Data; | ||
7 | import lombok.NoArgsConstructor; | ||
8 | |||
9 | import java.io.Serializable; | ||
10 | |||
11 | /** | ||
12 | * @author : | ||
13 | * @description: | ||
14 | * @function : | ||
15 | * @date :Created in 2022/3/23 9:48 | ||
16 | * @version: : | ||
17 | * @modified By: | ||
18 | * @since : modified in 2022/3/23 9:48 | ||
19 | */ | ||
20 | |||
21 | @Data | ||
22 | @AllArgsConstructor | ||
23 | @NoArgsConstructor | ||
24 | public class MemberProfileAndMemberDTO implements Serializable { | ||
25 | |||
26 | private MemberProfileDTO memberProfileDTO; | ||
27 | private MemberDTO memberDTO; | ||
28 | } |
... | @@ -14,12 +14,15 @@ import com.topdraw.business.process.service.UserOperationService; | ... | @@ -14,12 +14,15 @@ import com.topdraw.business.process.service.UserOperationService; |
14 | import com.topdraw.business.process.service.dto.MemberAndUserTvDTO; | 14 | import com.topdraw.business.process.service.dto.MemberAndUserTvDTO; |
15 | import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO; | 15 | import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO; |
16 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
17 | import org.apache.commons.lang3.StringUtils; | ||
17 | import org.springframework.beans.BeanUtils; | 18 | import org.springframework.beans.BeanUtils; |
18 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
20 | import org.springframework.transaction.annotation.Propagation; | 21 | import org.springframework.transaction.annotation.Propagation; |
21 | import org.springframework.transaction.annotation.Transactional; | 22 | import org.springframework.transaction.annotation.Transactional; |
22 | 23 | ||
24 | import java.util.Objects; | ||
25 | |||
23 | @Service | 26 | @Service |
24 | @Slf4j | 27 | @Slf4j |
25 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 28 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
... | @@ -32,45 +35,122 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -32,45 +35,122 @@ public class UserOperationServiceImpl implements UserOperationService { |
32 | @Autowired | 35 | @Autowired |
33 | private UserWeixinService userWeixinService; | 36 | private UserWeixinService userWeixinService; |
34 | 37 | ||
35 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 38 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) |
36 | public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) { | 39 | public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) { |
37 | this.saveMember(memberAndWeixinUserDTO.getMemberDTO()); | 40 | UserWeixinDTO userWeixinDTO = memberAndWeixinUserDTO.getUserWeixinDTO(); |
38 | this.saveWeixin(memberAndWeixinUserDTO.getUserWeixinDTO()); | 41 | String openid = userWeixinDTO.getOpenid(); |
39 | } | 42 | String unionid = userWeixinDTO.getUnionid(); |
43 | String appid = userWeixinDTO.getAppid(); | ||
44 | |||
45 | UserWeixinDTO _userWeixinDTO = this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionid, appid, openid); | ||
46 | if (Objects.isNull(_userWeixinDTO.getId())) { | ||
47 | // 检查会员是否存在 | ||
48 | UserWeixinDTO _userWeixinDTO1 = this.userWeixinService.findFirstByUnionId(unionid); | ||
49 | if (Objects.nonNull(_userWeixinDTO1.getId())) { | ||
50 | // 会员已存在 | ||
51 | Long memberId = _userWeixinDTO1.getMemberId(); | ||
52 | userWeixinDTO.setMemberId(memberId); | ||
53 | this.createWeixin(userWeixinDTO); | ||
54 | |||
55 | } else { | ||
56 | |||
57 | MemberDTO memberDTO = memberAndWeixinUserDTO.getMemberDTO(); | ||
58 | MemberDTO _memberDTO = this.createMember(memberDTO); | ||
59 | userWeixinDTO.setMemberId(_memberDTO.getId()); | ||
60 | this.createWeixin(userWeixinDTO); | ||
61 | |||
62 | } | ||
63 | |||
64 | } | ||
40 | 65 | ||
41 | private void saveMember(MemberDTO memberDTO){ | ||
42 | Member member = new Member(); | ||
43 | BeanUtils.copyProperties(memberDTO, member); | ||
44 | this.memberService.create(member); | ||
45 | } | 66 | } |
46 | 67 | ||
47 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 68 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) |
48 | public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTvDTO) { | 69 | public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTvDTO) { |
49 | this.saveMember(memberAndUserTvDTO.getMemberDTO()); | 70 | UserTvDTO userTvDTO = memberAndUserTvDTO.getUserTvDTO(); |
50 | this.saveUserTv(memberAndUserTvDTO.getUserTvDTO()); | 71 | String platformAccount = userTvDTO.getPlatformAccount(); |
72 | UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
73 | if (Objects.isNull(_userTvDTO)) { | ||
74 | // 创建大屏会员 | ||
75 | MemberDTO memberDTO = this.createMember(memberAndUserTvDTO.getMemberDTO()); | ||
76 | userTvDTO.setMemberId(memberDTO.getId()); | ||
77 | // 创建大屏账号 | ||
78 | this.createUserTv(userTvDTO); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) | ||
83 | public void asyncWeixin(UserWeixinDTO userWeixinDTO) { | ||
84 | String openid = userWeixinDTO.getOpenid(); | ||
85 | String unionid = userWeixinDTO.getUnionid(); | ||
86 | String appid = userWeixinDTO.getAppid(); | ||
87 | UserWeixinDTO _userWeixinDTO = this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionid, appid, openid); | ||
88 | if (Objects.nonNull(_userWeixinDTO)) { | ||
89 | userWeixinDTO.setId(_userWeixinDTO.getId()); | ||
90 | this.updateWeixin(userWeixinDTO); | ||
91 | } | ||
92 | |||
93 | } | ||
94 | |||
95 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) | ||
96 | public void asyncUserTv(UserTvDTO userTvDTO) { | ||
97 | String platformAccount = userTvDTO.getPlatformAccount(); | ||
98 | UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
99 | if (Objects.nonNull(_userTvDTO)) { | ||
100 | Long id = _userTvDTO.getId(); | ||
101 | userTvDTO.setId(id); | ||
102 | this.updateUserTv(userTvDTO); | ||
103 | } | ||
104 | |||
51 | } | 105 | } |
52 | 106 | ||
53 | public void asyncWeixin(UserWeixinDTO weixinDTO) { | 107 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) |
54 | this.saveWeixin(weixinDTO); | 108 | public void asyncMember(MemberDTO memberDTO) { |
109 | String code = memberDTO.getCode(); | ||
110 | if (StringUtils.isNotBlank(code)) { | ||
111 | MemberDTO _memberDTO = this.memberService.findByCode(code); | ||
112 | if (Objects.nonNull(_memberDTO)) { | ||
113 | Long id = _memberDTO.getId(); | ||
114 | memberDTO.setId(id); | ||
115 | this.updateMember(memberDTO); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | |||
121 | private MemberDTO createMember(MemberDTO memberDTO){ | ||
122 | Member member = new Member(); | ||
123 | BeanUtils.copyProperties(memberDTO, member); | ||
124 | return this.memberService.create(member); | ||
125 | } | ||
126 | |||
127 | private MemberDTO updateMember(MemberDTO memberDTO){ | ||
128 | Member member = new Member(); | ||
129 | BeanUtils.copyProperties(memberDTO, member); | ||
130 | return this.memberService.update(member); | ||
55 | } | 131 | } |
56 | 132 | ||
57 | private void saveWeixin(UserWeixinDTO weixinDTO){ | 133 | private void createWeixin(UserWeixinDTO weixinDTO){ |
58 | UserWeixin userWeixin = new UserWeixin(); | 134 | UserWeixin userWeixin = new UserWeixin(); |
59 | BeanUtils.copyProperties(weixinDTO, userWeixin); | 135 | BeanUtils.copyProperties(weixinDTO, userWeixin); |
60 | this.userWeixinService.create(userWeixin); | 136 | this.userWeixinService.create(userWeixin); |
61 | } | 137 | } |
62 | 138 | ||
63 | public void asyncUserTv(UserTvDTO userTvDTO) { | 139 | private void updateWeixin(UserWeixinDTO weixinDTO){ |
64 | this.saveUserTv(userTvDTO); | 140 | UserWeixin userWeixin = new UserWeixin(); |
141 | BeanUtils.copyProperties(weixinDTO, userWeixin); | ||
142 | this.userWeixinService.update(userWeixin); | ||
65 | } | 143 | } |
66 | 144 | ||
67 | private void saveUserTv(UserTvDTO userTvDTO){ | 145 | private void createUserTv(UserTvDTO userTvDTO){ |
68 | UserTv userTv = new UserTv(); | 146 | UserTv userTv = new UserTv(); |
69 | BeanUtils.copyProperties(userTvDTO, userTv); | 147 | BeanUtils.copyProperties(userTvDTO, userTv); |
70 | this.userTvService.create(userTv); | 148 | this.userTvService.create(userTv); |
71 | } | 149 | } |
72 | 150 | ||
73 | public void asyncMember(MemberDTO memberDTO) { | 151 | private void updateUserTv(UserTvDTO userTvDTO){ |
74 | this.saveMember(memberDTO); | 152 | UserTv userTv = new UserTv(); |
153 | BeanUtils.copyProperties(userTvDTO, userTv); | ||
154 | this.userTvService.update(userTv); | ||
75 | } | 155 | } |
76 | } | 156 | } | ... | ... |
... | @@ -3,13 +3,18 @@ package com.topdraw.business.process.service.impl.member; | ... | @@ -3,13 +3,18 @@ package com.topdraw.business.process.service.impl.member; |
3 | import com.topdraw.business.module.member.address.domain.MemberAddress; | 3 | import com.topdraw.business.module.member.address.domain.MemberAddress; |
4 | import com.topdraw.business.module.member.address.service.MemberAddressService; | 4 | import com.topdraw.business.module.member.address.service.MemberAddressService; |
5 | import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; | 5 | import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; |
6 | import com.topdraw.business.module.member.service.MemberService; | ||
7 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
6 | import com.topdraw.business.process.service.member.MemberAddressOperationService; | 8 | import com.topdraw.business.process.service.member.MemberAddressOperationService; |
7 | import lombok.extern.slf4j.Slf4j; | 9 | import lombok.extern.slf4j.Slf4j; |
10 | import org.springframework.beans.BeanUtils; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
10 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
11 | import org.springframework.transaction.annotation.Transactional; | 14 | import org.springframework.transaction.annotation.Transactional; |
12 | 15 | ||
16 | import java.util.Objects; | ||
17 | |||
13 | /** | 18 | /** |
14 | * @author XiangHan | 19 | * @author XiangHan |
15 | * @date 2021-10-22 | 20 | * @date 2021-10-22 |
... | @@ -21,31 +26,48 @@ public class MemberAddressOperationServiceImpl implements MemberAddressOperation | ... | @@ -21,31 +26,48 @@ public class MemberAddressOperationServiceImpl implements MemberAddressOperation |
21 | 26 | ||
22 | @Autowired | 27 | @Autowired |
23 | private MemberAddressService memberAddressService; | 28 | private MemberAddressService memberAddressService; |
24 | 29 | @Autowired | |
25 | @Override | 30 | private MemberService memberService; |
26 | public MemberAddressDTO findById(Long id) { | ||
27 | return this.memberAddressService.findById(id); | ||
28 | } | ||
29 | 31 | ||
30 | @Override | 32 | public void asyncDeleteMemberAddress(MemberAddressDTO memberAddressDTO){ |
31 | @Transactional(rollbackFor = Exception.class) | 33 | String memberCode = memberAddressDTO.getMemberCode(); |
32 | public MemberAddressDTO create(MemberAddress resources) { | 34 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); |
33 | log.info("MemberAddressOperationServiceImpl ==>> create ==>> param ==>> [{}]",resources); | 35 | MemberAddressDTO _memberAddressDTO = |
34 | return this.memberAddressService.create(resources); | 36 | this.memberAddressService.findByMemberIdAndSequence(memberDTO.getId(), memberAddressDTO.getSequence()); |
37 | if (Objects.nonNull(_memberAddressDTO)) { | ||
38 | this.memberAddressService.delete(_memberAddressDTO.getId()); | ||
39 | } | ||
35 | } | 40 | } |
36 | 41 | ||
37 | @Override | 42 | public void asyncMemberAddress(MemberAddressDTO memberAddressDTO){ |
38 | @Transactional(rollbackFor = Exception.class) | 43 | MemberDTO memberDTO = this.memberService.findByCode(memberAddressDTO.getMemberCode()); |
39 | public MemberAddressDTO update(MemberAddress resources) { | 44 | |
40 | log.info("MemberAddressOperationServiceImpl ==>> update ==>> param ==>> [{}]",resources); | 45 | MemberAddressDTO _memberAddressDTO = this.memberAddressService.findByMemberIdAndSequence(memberDTO.getId(), |
46 | memberAddressDTO.getSequence()); | ||
47 | if (Objects.nonNull(_memberAddressDTO)) { | ||
41 | 48 | ||
42 | return this.memberAddressService.update(resources); | 49 | memberAddressDTO.setId(_memberAddressDTO.getId()); |
50 | memberAddressDTO.setMemberId(memberDTO.getId()); | ||
51 | this.updateMemberAddress(memberAddressDTO); | ||
52 | |||
53 | } else { | ||
54 | |||
55 | memberAddressDTO.setId(null); | ||
56 | memberAddressDTO.setMemberId(memberDTO.getId()); | ||
57 | this.createMemberAddress(memberAddressDTO); | ||
58 | |||
59 | } | ||
43 | } | 60 | } |
44 | 61 | ||
45 | @Override | 62 | public void createMemberAddress(MemberAddressDTO memberAddressDTO){ |
46 | @Transactional(rollbackFor = Exception.class) | 63 | MemberAddress memberAddress = new MemberAddress(); |
47 | public void delete(Long id) { | 64 | BeanUtils.copyProperties(memberAddressDTO, memberAddress); |
48 | this.memberAddressService.delete(id); | 65 | this.memberAddressService.create(memberAddress); |
49 | } | 66 | } |
50 | 67 | ||
68 | public void updateMemberAddress(MemberAddressDTO memberAddressDTO){ | ||
69 | MemberAddress memberAddress = new MemberAddress(); | ||
70 | BeanUtils.copyProperties(memberAddressDTO, memberAddress); | ||
71 | this.memberAddressService.update(memberAddress); | ||
72 | } | ||
51 | } | 73 | } | ... | ... |
... | @@ -2,23 +2,17 @@ package com.topdraw.business.process.service.impl.member; | ... | @@ -2,23 +2,17 @@ package com.topdraw.business.process.service.impl.member; |
2 | 2 | ||
3 | import cn.hutool.core.util.ObjectUtil; | 3 | import cn.hutool.core.util.ObjectUtil; |
4 | import com.topdraw.business.module.member.domain.Member; | 4 | import com.topdraw.business.module.member.domain.Member; |
5 | import com.topdraw.business.module.member.profile.service.MemberProfileService; | ||
5 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 6 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
6 | import com.topdraw.business.module.member.service.MemberService; | 7 | import com.topdraw.business.module.member.service.MemberService; |
7 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 8 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
8 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; | 9 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; |
9 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; | 10 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; |
10 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | ||
11 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; | 11 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; |
12 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 12 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
13 | import com.topdraw.business.process.domian.weixin.BuyVipBean; | ||
14 | import com.topdraw.business.process.service.member.MemberOperationService; | 13 | import com.topdraw.business.process.service.member.MemberOperationService; |
15 | import com.topdraw.business.process.service.member.MemberProfileOperationService; | ||
16 | import com.topdraw.exception.EntityNotFoundException; | ||
17 | import org.springframework.beans.BeanUtils; | 14 | import org.springframework.beans.BeanUtils; |
18 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.cache.annotation.CacheConfig; | ||
20 | import org.springframework.cache.annotation.CachePut; | ||
21 | import org.springframework.cache.annotation.Cacheable; | ||
22 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 16 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
23 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
24 | import org.springframework.util.Assert; | 18 | import org.springframework.util.Assert; |
... | @@ -28,13 +22,13 @@ import java.time.ZoneOffset; | ... | @@ -28,13 +22,13 @@ import java.time.ZoneOffset; |
28 | import java.util.Objects; | 22 | import java.util.Objects; |
29 | 23 | ||
30 | @Service | 24 | @Service |
31 | @CacheConfig(cacheNames = "member") | 25 | //@CacheConfig(cacheNames = "member") |
32 | public class MemberOperationServiceImpl implements MemberOperationService { | 26 | public class MemberOperationServiceImpl implements MemberOperationService { |
33 | 27 | ||
34 | @Autowired | 28 | @Autowired |
35 | private MemberService memberService; | 29 | private MemberService memberService; |
36 | @Autowired | 30 | @Autowired |
37 | private MemberProfileOperationService memberProfileOperationService; | 31 | private MemberProfileService memberProfileService; |
38 | @Autowired | 32 | @Autowired |
39 | private MemberVipHistoryService memberVipHistoryService; | 33 | private MemberVipHistoryService memberVipHistoryService; |
40 | @Autowired | 34 | @Autowired |
... | @@ -58,7 +52,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -58,7 +52,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
58 | this.memberVipHistoryService.create(memberVipHistory); | 52 | this.memberVipHistoryService.create(memberVipHistory); |
59 | } | 53 | } |
60 | 54 | ||
61 | @CachePut(key = "#resources.id") | 55 | // @CachePut(key = "#resources.id") |
62 | @Override | 56 | @Override |
63 | public MemberDTO update(Member resources) { | 57 | public MemberDTO update(Member resources) { |
64 | MemberDTO memberDTO = this.memberService.update(resources); | 58 | MemberDTO memberDTO = this.memberService.update(resources); |
... | @@ -216,6 +210,6 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -216,6 +210,6 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
216 | * @return | 210 | * @return |
217 | */ | 211 | */ |
218 | private MemberProfileDTO findMemberProfileByMemberId(Long memberId) { | 212 | private MemberProfileDTO findMemberProfileByMemberId(Long memberId) { |
219 | return this.memberProfileOperationService.findByMemberId(memberId); | 213 | return this.memberProfileService.findByMemberId(memberId); |
220 | } | 214 | } |
221 | } | 215 | } | ... | ... |
... | @@ -4,9 +4,12 @@ import com.topdraw.business.module.member.domain.Member; | ... | @@ -4,9 +4,12 @@ import com.topdraw.business.module.member.domain.Member; |
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.service.MemberProfileService; | 5 | import com.topdraw.business.module.member.profile.service.MemberProfileService; |
6 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 6 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
7 | import com.topdraw.business.module.member.service.MemberService; | ||
7 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 8 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
9 | import com.topdraw.business.process.service.dto.MemberProfileAndMemberDTO; | ||
8 | import com.topdraw.business.process.service.member.MemberOperationService; | 10 | import com.topdraw.business.process.service.member.MemberOperationService; |
9 | import com.topdraw.business.process.service.member.MemberProfileOperationService; | 11 | import com.topdraw.business.process.service.member.MemberProfileOperationService; |
12 | import org.springframework.beans.BeanUtils; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
12 | import org.springframework.util.StringUtils; | 15 | import org.springframework.util.StringUtils; |
... | @@ -27,62 +30,40 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation | ... | @@ -27,62 +30,40 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation |
27 | private MemberProfileService memberProfileService; | 30 | private MemberProfileService memberProfileService; |
28 | @Autowired | 31 | @Autowired |
29 | private MemberOperationService memberOperationService; | 32 | private MemberOperationService memberOperationService; |
33 | @Autowired | ||
34 | private MemberService memberService; | ||
30 | 35 | ||
31 | @Override | 36 | public MemberProfileDTO asyncMemberProfile(MemberProfileDTO memberProfileDTO){ |
32 | public MemberProfileDTO findById(Long id) { | 37 | String memberCode = memberProfileDTO.getMemberCode(); |
33 | return this.memberProfileService.findById(id); | 38 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); |
34 | } | 39 | Long memberId = memberDTO.getId(); |
35 | 40 | MemberProfileDTO _memberProfileDTO = this.memberProfileService.findByMemberId(memberId); | |
36 | @Override | 41 | memberProfileDTO.setId(_memberProfileDTO.getId()); |
37 | public MemberProfile create(MemberProfile resources) { | 42 | memberProfileDTO.setMemberId(memberId); |
38 | return this.memberProfileService.create(resources); | 43 | return this.updateMemberProfile(memberProfileDTO); |
39 | } | ||
40 | |||
41 | @Override | ||
42 | public MemberProfile createDefault(MemberProfile resources) { | ||
43 | return this.memberProfileService.createDefault(resources); | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public MemberProfile createDefault(Member resources) { | ||
48 | return this.memberProfileService.createDefault(resources); | ||
49 | } | 44 | } |
50 | 45 | ||
51 | @Override | 46 | private MemberProfileDTO updateMemberProfile(MemberProfileDTO memberProfileDTO) { |
52 | public MemberProfile createDefaultByMemberId(Long resources) { | 47 | MemberProfile memberProfile = new MemberProfile(); |
53 | return this.memberProfileService.createDefaultByMemberId(resources); | 48 | BeanUtils.copyProperties(memberProfileDTO, memberProfile); |
49 | return this.memberProfileService.update(memberProfile); | ||
54 | } | 50 | } |
55 | 51 | ||
56 | @Override | ||
57 | public MemberProfileDTO update(MemberProfile resources) { | ||
58 | return this.memberProfileService.update(resources); | ||
59 | } | ||
60 | 52 | ||
61 | @Override | 53 | public void asyncMemberProfileAndMember(MemberProfileAndMemberDTO resources) { |
62 | public void delete(Long id) { | 54 | MemberProfileDTO memberProfileDTO = resources.getMemberProfileDTO(); |
63 | this.memberProfileService.delete(id); | 55 | MemberProfileDTO _memberProfileDTO = this.asyncMemberProfile(memberProfileDTO); |
64 | } | ||
65 | 56 | ||
66 | @Override | 57 | MemberDTO memberDTO = resources.getMemberDTO(); |
67 | public MemberProfileDTO findByMemberId(Long memberId) { | 58 | memberDTO.setId(_memberProfileDTO.getMemberId()); |
68 | return this.memberProfileService.findByMemberId(memberId); | 59 | memberDTO.setNickname(_memberProfileDTO.getRealname()); |
69 | } | 60 | memberDTO.setGender(_memberProfileDTO.getGender()); |
61 | memberDTO.setBirthday(_memberProfileDTO.getBirthday()); | ||
62 | memberDTO.setAvatarUrl(_memberProfileDTO.getAvatarUrl()); | ||
70 | 63 | ||
71 | @Override | 64 | Member member = new Member(); |
72 | public MemberProfileDTO findByMemberCode(String memberCode) { | 65 | BeanUtils.copyProperties(memberDTO,member); |
73 | return this.memberProfileService.findByMemberCode(memberCode); | 66 | this.memberService.update(member); |
74 | } | 67 | } |
75 | 68 | ||
76 | @Override | ||
77 | public MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources) { | ||
78 | String memberCode = resources.getMemberCode(); | ||
79 | MemberDTO memberDTO = null; | ||
80 | if (StringUtils.isEmpty(memberCode)) { | ||
81 | Long memberId = resources.getMemberId(); | ||
82 | memberDTO = this.memberOperationService.findById(memberId); | ||
83 | resources.setMemberCode(memberDTO.getCode()); | ||
84 | } | ||
85 | |||
86 | return this.memberProfileService.updateMemberProfileAndMember(resources, memberDTO); | ||
87 | } | ||
88 | } | 69 | } | ... | ... |
... | @@ -5,29 +5,6 @@ import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; | ... | @@ -5,29 +5,6 @@ import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; |
5 | 5 | ||
6 | public interface MemberAddressOperationService { | 6 | public interface MemberAddressOperationService { |
7 | 7 | ||
8 | /** | ||
9 | * 根据ID查询 | ||
10 | * @param resources ID | ||
11 | * @return MemberAddressDTO | ||
12 | */ | ||
13 | MemberAddressDTO findById(Long resources); | ||
14 | 8 | ||
15 | /** | ||
16 | * 保存会员地址 | ||
17 | * @param resources | ||
18 | */ | ||
19 | MemberAddressDTO create(MemberAddress resources); | ||
20 | |||
21 | /** | ||
22 | * 修改会员地址 | ||
23 | * @param resources | ||
24 | */ | ||
25 | MemberAddressDTO update(MemberAddress resources); | ||
26 | |||
27 | /** | ||
28 | * 通过id删除 | ||
29 | * @param resources | ||
30 | */ | ||
31 | void delete(Long resources); | ||
32 | 9 | ||
33 | } | 10 | } | ... | ... |
1 | package com.topdraw.business.process.service.member; | 1 | package com.topdraw.business.process.service.member; |
2 | 2 | ||
3 | 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.service.dto.MemberProfileDTO; | ||
6 | 3 | ||
7 | public interface MemberProfileOperationService { | 4 | public interface MemberProfileOperationService { |
8 | 5 | ||
9 | /** | ||
10 | * 根据ID查询 | ||
11 | * @param id ID | ||
12 | * @return MemberProfileDTO | ||
13 | */ | ||
14 | MemberProfileDTO findById(Long id); | ||
15 | |||
16 | /** | ||
17 | * 保存 | ||
18 | * @param resources 会员基本信息 | ||
19 | * @return | ||
20 | */ | ||
21 | MemberProfile create(MemberProfile resources); | ||
22 | |||
23 | /** | ||
24 | * 默认属性 | ||
25 | * @param resources | ||
26 | * @return | ||
27 | */ | ||
28 | MemberProfile createDefault(MemberProfile resources); | ||
29 | |||
30 | /** | ||
31 | * 通过会员创建默认属性 | ||
32 | * @param resources | ||
33 | * @return | ||
34 | */ | ||
35 | MemberProfile createDefault(Member resources); | ||
36 | |||
37 | /** | ||
38 | * 通过会员id创建默认属性 | ||
39 | * @param resources | ||
40 | * @return | ||
41 | */ | ||
42 | MemberProfile createDefaultByMemberId(Long resources); | ||
43 | |||
44 | /** | ||
45 | * 修改 | ||
46 | * @param resources | ||
47 | */ | ||
48 | MemberProfileDTO update(MemberProfile resources); | ||
49 | |||
50 | /** | ||
51 | * 删除 | ||
52 | * @param id | ||
53 | */ | ||
54 | void delete(Long id); | ||
55 | |||
56 | /** | ||
57 | * 通过会员id查询 | ||
58 | * @param memberId | ||
59 | * @return | ||
60 | */ | ||
61 | MemberProfileDTO findByMemberId(Long memberId); | ||
62 | |||
63 | /** | ||
64 | * 通过会员code查询 | ||
65 | * @param memberCode | ||
66 | * @return | ||
67 | */ | ||
68 | MemberProfileDTO findByMemberCode(String memberCode); | ||
69 | |||
70 | /** | ||
71 | * 修改会员属性并同步会员信息 | ||
72 | * @param resources | ||
73 | */ | ||
74 | MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources); | ||
75 | |||
76 | } | 6 | } | ... | ... |
-
Please register or sign in to post a comment