Commit 2477a356 2477a356f80f414fd24d6964db06b2ab99de06fe by xianghan

1.优化部分程序,清理警告信息

1 parent f916b030
Showing 18 changed files with 361 additions and 611 deletions
1 package com.topdraw.business.module.member.viphistory.rest;
2
3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
4 import com.topdraw.business.process.service.member.MemberOperationService;
5 import com.topdraw.common.ResultInfo;
6 import io.swagger.annotations.Api;
7 import io.swagger.annotations.ApiOperation;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.validation.annotation.Validated;
10 import org.springframework.web.bind.annotation.*;
11
12 /**
13 * @author luerlong
14 * @date 2021-12-10
15 */
16 @Api(tags = "会员vip历史管理")
17 @RestController
18 @RequestMapping("/uce/memberVipHistory")
19 public class MemberVipHistoryController {
20
21 @Autowired
22 private MemberOperationService memberOperationService;
23
24 @PostMapping
25 @ApiOperation("新增MemberVipHistory")
26 public ResultInfo create(@Validated @RequestBody MemberVipHistory resources) {
27 this.memberOperationService.createVipHistory(resources);
28 return ResultInfo.success();
29 }
30
31 }
...@@ -24,7 +24,7 @@ public interface MemberVipHistoryService { ...@@ -24,7 +24,7 @@ public interface MemberVipHistoryService {
24 * 24 *
25 * @param resources 25 * @param resources
26 */ 26 */
27 void create(MemberVipHistory resources); 27 MemberVipHistoryDTO create(MemberVipHistory resources);
28 28
29 /** 29 /**
30 * 30 *
......
...@@ -52,15 +52,14 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService { ...@@ -52,15 +52,14 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
52 52
53 @Override 53 @Override
54 @Transactional(rollbackFor = Exception.class) 54 @Transactional(rollbackFor = Exception.class)
55 @AsyncMqSend 55 public MemberVipHistoryDTO create(MemberVipHistory resources) {
56 public void create(MemberVipHistory resources) {
57 log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources); 56 log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources);
58 MemberDTO memberDTO = this.checkMember(resources); 57 MemberDTO memberDTO = this.checkMember(resources);
59 58
60 MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(resources); 59 MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(resources);
61 MemberVipHistory vipHistory = this.memberVipHistoryRepository.save(memberVipHistory); 60 MemberVipHistory vipHistory = this.memberVipHistoryRepository.save(memberVipHistory);
62 vipHistory.setMemberCode(memberDTO.getCode()); 61 vipHistory.setMemberCode(memberDTO.getCode());
63 62 return this.memberVipHistoryMapper.toDto(vipHistory);
64 } 63 }
65 64
66 @Override 65 @Override
......
1 package com.topdraw.business.module.rights.constant;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/18 16:06
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/18 16:06
11 */
12 public interface RightTypeConstants {
13
14 // 优惠券
15 int DISCOUNT_COUPON = 1;
16 // 观影券
17 int VIEW_COUPON= 2;
18 // 参加活动
19 int JOIN_ACTIVITY = 3;
20 // 积分商品
21 int POINTS_GOODS = 4;
22 // IPTV产品包
23 int IPTV_PRODUCT = 5;
24 // IPTV观影权益
25 int IPTV_VIEW = 6;
26
27 }
1 package com.topdraw.business.module.task.template.constant;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/18 14:30
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/18 14:30
11 */
12 public interface TaskEventType {
13 //类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置;
14 // 8:播放记录;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他
15 int LOGIN = 1;
16 int VIEW = 2;
17 int ACTIVITY = 3;
18 int ORDER = 4;
19 int MEMBER_PRIORITY = 5;
20 int SIGN = 6;
21 int COMPLETE_INFO = 7;
22 int PLAY = 8;
23 int BINDING = 10;
24 int POINTS_TRANS = 11;
25 int POINTS_EXCHANGE_GOODS = 30;
26 int SYSTEM_OPERATE = 98;
27 int OHHER = 99;
28
29 }
...@@ -2,25 +2,20 @@ package com.topdraw.business.process.rest; ...@@ -2,25 +2,20 @@ package com.topdraw.business.process.rest;
2 2
3 import com.topdraw.annotation.AnonymousAccess; 3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.common.validated.UpdateGroup; 4 import com.topdraw.business.module.common.validated.UpdateGroup;
5 import com.topdraw.business.module.member.domain.Member;
6 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; 5 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
7 import com.topdraw.business.module.member.service.dto.MemberDTO; 6 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.business.process.domian.member.MemberOperationBean; 7 import com.topdraw.business.process.domian.member.MemberOperationBean;
9 import com.topdraw.business.process.domian.weixin.BuyVipBean;
10 import com.topdraw.business.process.service.member.MemberOperationService; 8 import com.topdraw.business.process.service.member.MemberOperationService;
11 import com.topdraw.common.IResultInfo; 9 import com.topdraw.common.IResultInfo;
12 import com.topdraw.common.ResultInfo; 10 import com.topdraw.common.ResultInfo;
13 import com.topdraw.exception.BadRequestException;
14 import io.swagger.annotations.Api; 11 import io.swagger.annotations.Api;
15 import io.swagger.annotations.ApiOperation; 12 import io.swagger.annotations.ApiOperation;
16 import lombok.extern.slf4j.Slf4j; 13 import lombok.extern.slf4j.Slf4j;
17 import org.apache.commons.lang3.StringUtils; 14 import org.apache.commons.lang3.StringUtils;
18 import org.springframework.beans.BeanUtils;
19 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.validation.annotation.Validated; 16 import org.springframework.validation.annotation.Validated;
21 import org.springframework.web.bind.annotation.*; 17 import org.springframework.web.bind.annotation.*;
22 18
23 import java.sql.Timestamp;
24 import java.util.Objects; 19 import java.util.Objects;
25 20
26 @Api("会员处理") 21 @Api("会员处理")
...@@ -38,21 +33,11 @@ public class MemberOperationController { ...@@ -38,21 +33,11 @@ public class MemberOperationController {
38 @AnonymousAccess 33 @AnonymousAccess
39 public ResultInfo updateVipByMemberId(@Validated(value = {UpdateGroup.class}) @RequestBody MemberOperationBean resources) { 34 public ResultInfo updateVipByMemberId(@Validated(value = {UpdateGroup.class}) @RequestBody MemberOperationBean resources) {
40 log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); 35 log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources);
41 Integer vip = resources.getVip();
42 Timestamp vipExpireTime = resources.getVipExpireTime();
43 Long memberId = resources.getMemberId(); 36 Long memberId = resources.getMemberId();
44 MemberDTO memberDTO = this.memberOperationService.findById(memberId); 37 MemberDTO memberDTO = this.memberOperationService.findById(memberId);
38 resources.setMemberCode(memberDTO.getCode());
45 39
46 Member member = new Member(); 40 return this.updateVipByMemberCode(resources);
47 BeanUtils.copyProperties(memberDTO, member);
48 if (Objects.nonNull(vip)) {
49 member.setVip(vip);
50 }
51 if (Objects.nonNull(vipExpireTime)) {
52 member.setVipExpireTime(vipExpireTime);
53 }
54 this.memberOperationService.doUpdateMemberVipAndVipExpireTime(member);
55 return ResultInfo.success();
56 } 41 }
57 42
58 @RequestMapping(value = "/updateVipByMemberCode") 43 @RequestMapping(value = "/updateVipByMemberCode")
...@@ -71,28 +56,9 @@ public class MemberOperationController { ...@@ -71,28 +56,9 @@ public class MemberOperationController {
71 log.error("参数错误,vip为空或者小于0 , vip ==>> {}", vip); 56 log.error("参数错误,vip为空或者小于0 , vip ==>> {}", vip);
72 return ResultInfo.failure("参数错误,vip为空或者小于0"); 57 return ResultInfo.failure("参数错误,vip为空或者小于0");
73 } 58 }
74 Timestamp vipExpireTime = resources.getVipExpireTime();
75
76
77 Member member = new Member();
78 member.setCode(memberCode);
79 member.setVip(vip);
80 member.setVipExpireTime(vipExpireTime);
81
82 MemberDTO memberDTO = this.memberOperationService.doUpdateMemberVipAndVipExpireTime(member);
83 this.createVipHistory(memberDTO.getId(), memberDTO.getCode(), vip, vipExpireTime);
84
85 return ResultInfo.success();
86 }
87 59
88 60 MemberDTO memberDTO = this.memberOperationService.doUpdateVipByMemberCode(resources);
89 private void createVipHistory(Long memberId, String code, Integer vip , Timestamp vipExpireTime){ 61 return ResultInfo.success(memberDTO);
90 BuyVipBean buyVipBean = new BuyVipBean();
91 buyVipBean.setMemberId(memberId);
92 buyVipBean.setMemberCode(code);
93 buyVipBean.setVip(vip);
94 buyVipBean.setVipExpireTime(vipExpireTime);
95 this.memberOperationService.buyVipByMemberId(buyVipBean);
96 } 62 }
97 63
98 64
...@@ -104,27 +70,6 @@ public class MemberOperationController { ...@@ -104,27 +70,6 @@ public class MemberOperationController {
104 MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId); 70 MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId);
105 return ResultInfo.success(memberProfileDTO); 71 return ResultInfo.success(memberProfileDTO);
106 } 72 }
107
108 @PutMapping("/buyVip")
109 @ApiOperation("购买vip")
110 @AnonymousAccess
111 @Deprecated
112 public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) {
113
114 /* // 小程序账户id
115 Long id = buyVipBean.getId();
116 if (Objects.isNull(id))
117 throw new BadRequestException("参数异常: id is null !");
118
119 // vip等级
120 Integer vip = buyVipBean.getVip();
121 if (Objects.isNull(vip) || vip <= 0)
122 throw new BadRequestException("vip 等级有误");
123
124 MemberDTO memberDTO = this.memberOperationService.buyVip(buyVipBean);
125 return ResultInfo.success(memberDTO);*/
126 return null;
127 }
128 } 73 }
129 74
130 75
......
...@@ -61,23 +61,26 @@ public class PointsOperationController { ...@@ -61,23 +61,26 @@ public class PointsOperationController {
61 @AnonymousAccess 61 @AnonymousAccess
62 public ResultInfo addPoints(@Validated @RequestBody TempPoints tempPoints) { 62 public ResultInfo addPoints(@Validated @RequestBody TempPoints tempPoints) {
63 log.info("手动发放积分,参数 ==>>{} ", tempPoints); 63 log.info("手动发放积分,参数 ==>>{} ", tempPoints);
64
64 Long memberId = tempPoints.getMemberId(); 65 Long memberId = tempPoints.getMemberId();
65 if (Objects.isNull(memberId)) { 66 if (Objects.isNull(memberId)) {
66 log.error("积分发放失败,参数错误,会员id 不存在"); 67 log.error("积分发放失败,参数错误,会员id 不存在");
67 return ResultInfo.failure("积分发放失败,参数错误"); 68 return ResultInfo.failure("积分发放失败,参数错误");
68 } 69 }
70
69 Long points = tempPoints.getPoints(); 71 Long points = tempPoints.getPoints();
70 if (Objects.isNull(points) || points <= 0L) { 72 if (Objects.isNull(points) || points <= 0L) {
71 log.error("积分发放失败,参数错误,积分不存在或者积分小于0"); 73 log.error("积分发放失败,参数错误,积分不存在或者积分小于0");
72 return ResultInfo.failure("积分发放失败,参数错误"); 74 return ResultInfo.failure("积分发放失败,参数错误");
73 } 75 }
76
74 MemberDTO memberDTO = this.memberService.findById(memberId); 77 MemberDTO memberDTO = this.memberService.findById(memberId);
75 if (Objects.nonNull(memberDTO)) { 78 if (Objects.nonNull(memberDTO.getId())) {
76 String code = memberDTO.getCode();
77 tempPoints.setMemberCode(code);
78 tempPoints.setMemberId(memberDTO.getId()); 79 tempPoints.setMemberId(memberDTO.getId());
80 tempPoints.setMemberCode(memberDTO.getCode());
79 this.pointsOperationService.grantPointsByManualByTempPoints(tempPoints); 81 this.pointsOperationService.grantPointsByManualByTempPoints(tempPoints);
80 } 82 }
83
81 return ResultInfo.success(); 84 return ResultInfo.success();
82 } 85 }
83 86
......
...@@ -14,6 +14,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTv; ...@@ -14,6 +14,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTv;
14 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 14 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
15 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 15 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
16 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 16 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
17 import com.topdraw.business.process.domian.member.MemberOperationBean;
17 import com.topdraw.business.process.domian.weixin.*; 18 import com.topdraw.business.process.domian.weixin.*;
18 import com.topdraw.business.process.service.UserOperationService; 19 import com.topdraw.business.process.service.UserOperationService;
19 import com.topdraw.business.process.service.member.MemberOperationService; 20 import com.topdraw.business.process.service.member.MemberOperationService;
...@@ -89,30 +90,14 @@ public class UserOperationController { ...@@ -89,30 +90,14 @@ public class UserOperationController {
89 Long memberId = userWeixinDTO.getMemberId(); 90 Long memberId = userWeixinDTO.getMemberId();
90 MemberDTO memberDTO = this.memberService.findById(memberId); 91 MemberDTO memberDTO = this.memberService.findById(memberId);
91 92
92 Member member = new Member(); 93 MemberOperationBean memberOperationBean = new MemberOperationBean();
93 member.setId(memberDTO.getId()); 94 memberOperationBean.setMemberCode(memberDTO.getCode());
94 member.setCode(memberDTO.getCode()); 95 memberOperationBean.setVip(vip);
95 if (Objects.nonNull(vip)) { 96 memberOperationBean.setVipExpireTime(vipExpireTime);
96 member.setVip(vip);
97 }
98 if (Objects.nonNull(vipExpireTime)) {
99 member.setVipExpireTime(vipExpireTime);
100 }
101
102 this.memberOperationService.doUpdateMemberVipAndVipExpireTime(member);
103
104 this.createVipHistory(userId, vip, vipExpireTime);
105
106 return ResultInfo.success();
107 }
108 97
98 MemberDTO memberDTO1 = this.memberOperationService.doUpdateVipByMemberCode(memberOperationBean);
109 99
110 private void createVipHistory(Long weixinUserId, Integer vip , Timestamp vipExpireTime){ 100 return ResultInfo.success(memberDTO1);
111 BuyVipBean buyVipBean = new BuyVipBean();
112 buyVipBean.setId(weixinUserId);
113 buyVipBean.setVip(vip);
114 buyVipBean.setVipExpireTime(vipExpireTime);
115 this.memberOperationService.buyVipByUserId(buyVipBean);
116 } 101 }
117 102
118 @PostMapping(value = "/createWeixinUserAndCreateMember") 103 @PostMapping(value = "/createWeixinUserAndCreateMember")
......
...@@ -160,10 +160,4 @@ public interface UserOperationService { ...@@ -160,10 +160,4 @@ public interface UserOperationService {
160 */ 160 */
161 UserTvDTO updateUserTv(UserTv resources); 161 UserTvDTO updateUserTv(UserTv resources);
162 162
163 /**
164 * 修改大屏账号vis_user_id
165 * @param resources
166 * @return
167 */
168 UserTvDTO updateUserTvVisUserId(UserTv resources);
169 } 163 }
......
...@@ -90,6 +90,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -90,6 +90,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
90 if (Objects.isNull(expireTime)){ 90 if (Objects.isNull(expireTime)){
91 tempPoints.setExpireTime(TimestampUtil.localDateTime2Timestamp(DateUtil.getLastDateTimeSecondYear())); 91 tempPoints.setExpireTime(TimestampUtil.localDateTime2Timestamp(DateUtil.getLastDateTimeSecondYear()));
92 } 92 }
93
93 this.refresh(tempPoints); 94 this.refresh(tempPoints);
94 } 95 }
95 96
......
...@@ -54,7 +54,6 @@ import org.springframework.data.domain.Sort; ...@@ -54,7 +54,6 @@ import org.springframework.data.domain.Sort;
54 import org.springframework.stereotype.Service; 54 import org.springframework.stereotype.Service;
55 import org.springframework.transaction.annotation.Propagation; 55 import org.springframework.transaction.annotation.Propagation;
56 import org.springframework.transaction.annotation.Transactional; 56 import org.springframework.transaction.annotation.Transactional;
57 import org.springframework.util.Assert;
58 import org.springframework.util.Base64Utils; 57 import org.springframework.util.Base64Utils;
59 import org.springframework.util.CollectionUtils; 58 import org.springframework.util.CollectionUtils;
60 59
...@@ -95,7 +94,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -95,7 +94,7 @@ public class UserOperationServiceImpl implements UserOperationService {
95 /** 取消关注 */ 94 /** 取消关注 */
96 private static final Integer UNSUBSCRIBE_STATUS = 0; 95 private static final Integer UNSUBSCRIBE_STATUS = 0;
97 private static final Integer SUBSCRIBE_STATUS = 1; 96 private static final Integer SUBSCRIBE_STATUS = 1;
98 97 // 服务域 0:电信 1:联通 2:移动 3:其他
99 private static final Integer[] PLATFORM_LIST = new Integer[]{0,1,2,3}; 98 private static final Integer[] PLATFORM_LIST = new Integer[]{0,1,2,3};
100 99
101 @Value("${uc.app.h5AppId:wxca962918dfeed88c}") 100 @Value("${uc.app.h5AppId:wxca962918dfeed88c}")
...@@ -104,26 +103,6 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -104,26 +103,6 @@ public class UserOperationServiceImpl implements UserOperationService {
104 @Value("${uc.app.appletAppid:wxc57d42de3d351cec}") 103 @Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
105 private String appletAppid; 104 private String appletAppid;
106 105
107
108 @AsyncMqSend
109 public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
110 @AsyncMqSend
111 public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTv) {}
112 @AsyncMqSend
113 public void asyncWeixin(UserWeixinDTO weixinDTO) {}
114 @AsyncMqSend
115 public void asyncUserTv(UserTvDTO userTvDTO) {}
116 @AsyncMqSend
117 public void asyncUserTvChangeMainAccount(UserTvDTO userTvDTO) {}
118 @AsyncMqSend
119 public void asyncAppletBind(MemberAndUserTvDTO memberAndUserTvDTO) {}
120 @AsyncMqSend
121 public void asyncUnbind(MemberAndUserTvDTO memberAndUserTvDTO) {}
122 @AsyncMqSend
123 public void asyncUnsubscribe(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
124 @AsyncMqSend
125 public void asyncSubscribe(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
126
127 /** 106 /**
128 * 创建大屏账户同时创建会员 107 * 创建大屏账户同时创建会员
129 * 108 *
...@@ -134,8 +113,6 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -134,8 +113,6 @@ public class UserOperationServiceImpl implements UserOperationService {
134 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 113 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
135 public UserTvDTO createTvUserAndMember(UserTv resources) { 114 public UserTvDTO createTvUserAndMember(UserTv resources) {
136 115
137 boolean flag = true;
138
139 // 大屏账户 116 // 大屏账户
140 String platformAccount = resources.getPlatformAccount(); 117 String platformAccount = resources.getPlatformAccount();
141 118
...@@ -144,10 +121,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -144,10 +121,8 @@ public class UserOperationServiceImpl implements UserOperationService {
144 // 无账号 121 // 无账号
145 if (Objects.isNull(userTvDTO)) { 122 if (Objects.isNull(userTvDTO)) {
146 123
147 String platformAccountEncode = platformAccount; 124 String platformAccountEncode = Base64Utils.encodeToString(platformAccount.getBytes());
148 if (flag) { 125
149 platformAccountEncode = Base64Utils.encodeToString(platformAccount.getBytes());
150 }
151 // x_member 126 // x_member
152 Member member = 127 Member member =
153 MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_VIS, 128 MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_VIS,
...@@ -204,7 +179,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -204,7 +179,7 @@ public class UserOperationServiceImpl implements UserOperationService {
204 179
205 /** 180 /**
206 * 创建小屏账户同时创建会员 181 * 创建小屏账户同时创建会员
207 * @param resources 182 * @param resources 微信信息
208 * @return UserWeixinDTO 183 * @return UserWeixinDTO
209 */ 184 */
210 @Override 185 @Override
...@@ -239,7 +214,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -239,7 +214,7 @@ public class UserOperationServiceImpl implements UserOperationService {
239 if (Objects.nonNull(_userWeixinDTO.getMemberId())) { 214 if (Objects.nonNull(_userWeixinDTO.getMemberId())) {
240 215
241 // 有其他账号的话,将此账号与对应的会员进行绑定 216 // 有其他账号的话,将此账号与对应的会员进行绑定
242 MemberDTO memberDTO = this.findMemberById(_userWeixinDTO.getMemberId()); 217 MemberDTO memberDTO = this.memberService.findById(_userWeixinDTO.getMemberId());
243 userWeixinDTO.setMemberId(memberDTO.getId()); 218 userWeixinDTO.setMemberId(memberDTO.getId());
244 userWeixinDTO.setMemberCode(memberDTO.getCode()); 219 userWeixinDTO.setMemberCode(memberDTO.getCode());
245 if (StringUtils.isBlank(userWeixinDTO.getUnionid())) { 220 if (StringUtils.isBlank(userWeixinDTO.getUnionid())) {
...@@ -247,17 +222,15 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -247,17 +222,15 @@ public class UserOperationServiceImpl implements UserOperationService {
247 } 222 }
248 UserWeixin userWeixin = new UserWeixin(); 223 UserWeixin userWeixin = new UserWeixin();
249 BeanUtils.copyProperties(userWeixinDTO, userWeixin); 224 BeanUtils.copyProperties(userWeixinDTO, userWeixin);
250 UserWeixinDTO _userWeixinDTO1 = this.updateWeixin(userWeixin); 225 return this.updateWeixin(userWeixin);
251 return _userWeixinDTO1;
252 226
253 } else { 227 } else {
254 228
255 // 有其他账号但都无会员,新建会员并将此账号绑定新建的这个会员 229 // 有其他账号但都无会员,新建会员并将此账号绑定新建的这个会员
256 Member _member = 230 Member member = MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_WEIXIN,
257 MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_WEIXIN,
258 headimgurl, nickname, vip, sex); 231 headimgurl, nickname, vip, sex);
259 232
260 MemberDTO memberDTO = this.createMember(_member); 233 MemberDTO memberDTO = this.createMember(member);
261 234
262 if (Objects.nonNull(memberDTO)) { 235 if (Objects.nonNull(memberDTO)) {
263 userWeixinDTO.setMemberId(memberDTO.getId()); 236 userWeixinDTO.setMemberId(memberDTO.getId());
...@@ -267,8 +240,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -267,8 +240,7 @@ public class UserOperationServiceImpl implements UserOperationService {
267 } 240 }
268 UserWeixin userWeixin = new UserWeixin(); 241 UserWeixin userWeixin = new UserWeixin();
269 BeanUtils.copyProperties(userWeixinDTO, userWeixin); 242 BeanUtils.copyProperties(userWeixinDTO, userWeixin);
270 UserWeixinDTO _userWeixinDTO1 = this.updateWeixin(userWeixin); 243 return this.updateWeixin(userWeixin);
271 return _userWeixinDTO1;
272 244
273 } 245 }
274 246
...@@ -277,11 +249,11 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -277,11 +249,11 @@ public class UserOperationServiceImpl implements UserOperationService {
277 } else { 249 } else {
278 250
279 // 该账号存在但无其他账号,新建会员 251 // 该账号存在但无其他账号,新建会员
280 Member _member = 252 Member member =
281 MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_WEIXIN, 253 MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_WEIXIN,
282 headimgurl, nickname, vip, sex); 254 headimgurl, nickname, vip, sex);
283 255
284 MemberDTO memberDTO = this.createMember(_member); 256 MemberDTO memberDTO = this.createMember(member);
285 257
286 if (Objects.nonNull(memberDTO)) { 258 if (Objects.nonNull(memberDTO)) {
287 userWeixinDTO.setMemberId(memberDTO.getId()); 259 userWeixinDTO.setMemberId(memberDTO.getId());
...@@ -291,8 +263,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -291,8 +263,7 @@ public class UserOperationServiceImpl implements UserOperationService {
291 } 263 }
292 UserWeixin userWeixin = new UserWeixin(); 264 UserWeixin userWeixin = new UserWeixin();
293 BeanUtils.copyProperties(userWeixinDTO, userWeixin); 265 BeanUtils.copyProperties(userWeixinDTO, userWeixin);
294 UserWeixinDTO _userWeixinDTO1 = this.updateWeixin(userWeixin); 266 return this.updateWeixin(userWeixin);
295 return _userWeixinDTO1;
296 267
297 } 268 }
298 269
...@@ -374,11 +345,10 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -374,11 +345,10 @@ public class UserOperationServiceImpl implements UserOperationService {
374 return userWeixinDTO; 345 return userWeixinDTO;
375 } 346 }
376 347
377
378 /** 348 /**
379 * 服务号登录 349 * 服务号登录
380 * @param resources 350 * @param resources 微信信息
381 * @return 351 * @return UserWeixinDTO
382 */ 352 */
383 @Override 353 @Override
384 public UserWeixinDTO serviceLogin(UserWeixin resources) { 354 public UserWeixinDTO serviceLogin(UserWeixin resources) {
...@@ -387,14 +357,13 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -387,14 +357,13 @@ public class UserOperationServiceImpl implements UserOperationService {
387 UserWeixinDTO userWeixinDTO = this.createWeixinUserAndMember(resources); 357 UserWeixinDTO userWeixinDTO = this.createWeixinUserAndMember(resources);
388 358
389 // 为了保证返回的同一用户 359 // 为了保证返回的同一用户
390 UserWeixinDTO userWeixinDTO_0 = this.getFirstId(userWeixinDTO); 360 return this.getFirstId(userWeixinDTO);
391 return userWeixinDTO_0;
392 } 361 }
393 362
394 /** 363 /**
395 * 小程序登录 364 * 小程序登录
396 * @param resources 365 * @param resources 微信
397 * @return 366 * @return UserWeixinDTO
398 */ 367 */
399 @Override 368 @Override
400 @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class) 369 @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class)
...@@ -404,8 +373,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -404,8 +373,7 @@ public class UserOperationServiceImpl implements UserOperationService {
404 UserWeixinDTO userWeixinDTO = this.createWeixinUserAndMember(resources); 373 UserWeixinDTO userWeixinDTO = this.createWeixinUserAndMember(resources);
405 374
406 // 为了保证返回的同一用户 375 // 为了保证返回的同一用户
407 UserWeixinDTO userWeixinDTO_0 = this.getFirstId(userWeixinDTO); 376 return this.getFirstId(userWeixinDTO);
408 return userWeixinDTO_0;
409 } 377 }
410 378
411 /** 379 /**
...@@ -417,8 +385,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -417,8 +385,8 @@ public class UserOperationServiceImpl implements UserOperationService {
417 * 2). 大屏账户保存小屏会员的code 385 * 2). 大屏账户保存小屏会员的code
418 * 3). 小屏会员中保存大屏的id 386 * 3). 小屏会员中保存大屏的id
419 * @description 大小屏绑定,大屏账户保存小屏会员编码 387 * @description 大小屏绑定,大屏账户保存小屏会员编码
420 * @param resources 388 * @param resources 关注信息
421 * @return 389 * @return boolean
422 */ 390 */
423 @Override 391 @Override
424 public boolean subscribe(SubscribeBean resources) { 392 public boolean subscribe(SubscribeBean resources) {
...@@ -431,13 +399,15 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -431,13 +399,15 @@ public class UserOperationServiceImpl implements UserOperationService {
431 // 小屏账户 399 // 小屏账户
432 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionId, appId, openId); 400 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionId, appId, openId);
433 401
434 MemberDTO memberDTO = null; 402 MemberDTO memberDTO;
435 if (Objects.isNull(userWeixinDTO.getId()) || StringUtils.isBlank(userWeixinDTO.getUnionid()) || 403 if (Objects.isNull(userWeixinDTO.getId()) || StringUtils.isBlank(userWeixinDTO.getUnionid()) ||
436 Objects.isNull(userWeixinDTO.getMemberId())) { 404 Objects.isNull(userWeixinDTO.getMemberId())) {
437 405
438 UserWeixin userWeixin = new UserWeixin(); 406 UserWeixin userWeixin = new UserWeixin();
439 BeanUtils.copyProperties(resources, userWeixin); 407 BeanUtils.copyProperties(resources, userWeixin);
440 userWeixin.setStatus(SUBSCRIBE_STATUS); 408 userWeixin.setStatus(SUBSCRIBE_STATUS);
409 userWeixin.setNickname(nickname);
410 userWeixin.setHeadimgurl(headImgUrl);
441 411
442 // 创建小屏账户同时创建会员 412 // 创建小屏账户同时创建会员
443 userWeixinDTO = this.createWeixinUserAndMember(userWeixin, 1); 413 userWeixinDTO = this.createWeixinUserAndMember(userWeixin, 1);
...@@ -502,9 +472,9 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -502,9 +472,9 @@ public class UserOperationServiceImpl implements UserOperationService {
502 472
503 /** 473 /**
504 * 474 *
505 * @param memberDTO 475 * @param memberDTO 会员
506 * @param subscribe 476 * @param subscribe 关注状态
507 * @param sourceInfo 477 * @param sourceInfo 来源描述
508 */ 478 */
509 private void saveWechatSubscribeRecord(MemberDTO memberDTO, String sourceInfo, int subscribe) { 479 private void saveWechatSubscribeRecord(MemberDTO memberDTO, String sourceInfo, int subscribe) {
510 480
...@@ -550,8 +520,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -550,8 +520,8 @@ public class UserOperationServiceImpl implements UserOperationService {
550 520
551 /** 521 /**
552 * 微信公众号取消关注 522 * 微信公众号取消关注
553 * @param resources 523 * @param resources 参数
554 * @return 524 * @return boolean
555 */ 525 */
556 @Override 526 @Override
557 public boolean unsubscribe(SubscribeBean resources) { 527 public boolean unsubscribe(SubscribeBean resources) {
...@@ -607,8 +577,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -607,8 +577,7 @@ public class UserOperationServiceImpl implements UserOperationService {
607 try { 577 try {
608 if (StringUtils.isNotBlank(headimgurl)) { 578 if (StringUtils.isNotBlank(headimgurl)) {
609 String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8"); 579 String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8");
610 String image = RestTemplateClient.netImage(headimgurlDecode); 580 return RestTemplateClient.netImage(headimgurlDecode);
611 return image;
612 } 581 }
613 } catch (Exception e) { 582 } catch (Exception e) {
614 log.info("头像解析失败!!!"); 583 log.info("头像解析失败!!!");
...@@ -620,8 +589,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -620,8 +589,8 @@ public class UserOperationServiceImpl implements UserOperationService {
620 589
621 /** 590 /**
622 * 更新大屏信息,同时判断是否已经关注,如果关注了则不跳转H5页面 591 * 更新大屏信息,同时判断是否已经关注,如果关注了则不跳转H5页面
623 * @param data 592 * @param data 参数
624 * @return 593 * @return UserWeixinDTO
625 */ 594 */
626 @Override 595 @Override
627 public UserWeixinDTO saveUserInfo(String data) { 596 public UserWeixinDTO saveUserInfo(String data) {
...@@ -631,7 +600,6 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -631,7 +600,6 @@ public class UserOperationServiceImpl implements UserOperationService {
631 JSONObject json = JSONObject.parseObject(data); 600 JSONObject json = JSONObject.parseObject(data);
632 String unionId = json.getString("unionid"); 601 String unionId = json.getString("unionid");
633 // 订阅号appid 602 // 订阅号appid
634 // String appId = json.getString("dyAppid");
635 String appId = json.getString("appid"); 603 String appId = json.getString("appid");
636 604
637 try { 605 try {
...@@ -661,8 +629,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -661,8 +629,7 @@ public class UserOperationServiceImpl implements UserOperationService {
661 629
662 // 若未传dyAppId。不走下面的流程 630 // 若未传dyAppId。不走下面的流程
663 if (StrUtil.isNotBlank(appId)) { 631 if (StrUtil.isNotBlank(appId)) {
664 UserWeixinDTO userWeixinDTO = this.findUserWeiXinByUnionIdAndAppId(unionId,appId); 632 return this.findUserWeiXinByUnionIdAndAppId(unionId,appId);
665 return userWeixinDTO;
666 } 633 }
667 634
668 } catch (Exception e) { 635 } catch (Exception e) {
...@@ -674,7 +641,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -674,7 +641,8 @@ public class UserOperationServiceImpl implements UserOperationService {
674 641
675 /** 642 /**
676 * 大屏更换主账号 643 * 大屏更换主账号
677 * @param resources 644 * @param resources 大屏账号信息
645 * @return boolean
678 */ 646 */
679 @Override 647 @Override
680 public boolean changeMainAccount(UserTv resources) { 648 public boolean changeMainAccount(UserTv resources) {
...@@ -697,7 +665,6 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -697,7 +665,6 @@ public class UserOperationServiceImpl implements UserOperationService {
697 } 665 }
698 666
699 // 设置主会员 667 // 设置主会员
700 // UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberCode, "manual");
701 UserTv userTv = new UserTv(); 668 UserTv userTv = new UserTv();
702 userTv.setId(userTvDTO.getId()); 669 userTv.setId(userTvDTO.getId());
703 userTv.setPriorityMemberCode(memberCode); 670 userTv.setPriorityMemberCode(memberCode);
...@@ -710,7 +677,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -710,7 +677,8 @@ public class UserOperationServiceImpl implements UserOperationService {
710 677
711 /** 678 /**
712 * 大屏解绑 679 * 大屏解绑
713 * @param resources 680 * @param resources 大屏解绑参数
681 * @return boolean
714 */ 682 */
715 @Override 683 @Override
716 public boolean tvUnbind(TvUnBindBean resources) { 684 public boolean tvUnbind(TvUnBindBean resources) {
...@@ -1029,25 +997,24 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1029,25 +997,24 @@ public class UserOperationServiceImpl implements UserOperationService {
1029 memberDTO.setPlatformAccount(platformAccount); 997 memberDTO.setPlatformAccount(platformAccount);
1030 // 同步至iptv 998 // 同步至iptv
1031 ((UserOperationServiceImpl)AopContext.currentProxy()) 999 ((UserOperationServiceImpl)AopContext.currentProxy())
1032 .asyncAppletBind(new MemberAndUserTvDTO(memberDTO, userTvDTO)); 1000 .asyncMinaBind(new MemberAndUserTvDTO(memberDTO, userTvDTO));
1033 1001
1034 return true; 1002 return true;
1035 } 1003 }
1036 1004
1037 /** 1005 /**
1038 * 1006 *
1039 * @param memberDTO 1007 * @param resource 会员信息
1040 * @param platformAccount 1008 * @param platformAccount 大屏账号
1041 * @return 1009 * @return UserTvDTO
1042 */ 1010 */
1043 @Override 1011 @Override
1044 public UserTvDTO bind(MemberDTO memberDTO, String platformAccount) { 1012 public UserTvDTO bind(MemberDTO resource, String platformAccount) {
1045 log.info("bind start"); 1013 log.info("bind start");
1046 MemberDTO memberDTO1 = this.memberService.findByCode(memberDTO.getCode()); 1014 MemberDTO memberDTO = this.memberService.findByCode(resource.getCode());
1047 log.info("查询会员信息 ==>> {}", memberDTO1); 1015 log.info("查询会员信息 ==>> {}", memberDTO);
1048 if (Objects.nonNull(memberDTO1.getUserIptvId())) { 1016 if (Objects.nonNull(memberDTO.getUserIptvId())) {
1049 UserTvDTO userTvDTO = this.userTvService.findById(memberDTO1.getUserIptvId()); 1017 return this.userTvService.findById(memberDTO.getUserIptvId());
1050 return userTvDTO;
1051 } 1018 }
1052 1019
1053 // 大屏账户 1020 // 大屏账户
...@@ -1057,9 +1024,17 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1057,9 +1024,17 @@ public class UserOperationServiceImpl implements UserOperationService {
1057 throw new BadRequestException(GlobeExceptionMsg.IPTV_IS_NULL); 1024 throw new BadRequestException(GlobeExceptionMsg.IPTV_IS_NULL);
1058 } 1025 }
1059 1026
1060 // mq同步数据时使用 1027 // 大屏是否绑定主账号,如果绑定了主账户则不操作大屏账户表
1061 memberDTO.setPlatformAccount(platformAccount); 1028 String priorityMemberCode = userTvDTO.getPriorityMemberCode();
1029 if (StringUtils.isBlank(priorityMemberCode)) {
1030 UserTv userTv = new UserTv();
1031 userTv.setId(userTvDTO.getId());
1032 userTv.setPriorityMemberCode(memberDTO.getCode());
1062 1033
1034 userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv);
1035 }
1036
1037 Member member = new Member();
1063 // 构建小屏会员对象,绑定user_iptv_id字段 1038 // 构建小屏会员对象,绑定user_iptv_id字段
1064 String platform = userTvDTO.getPlatform(); 1039 String platform = userTvDTO.getPlatform();
1065 // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 1040 // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通
...@@ -1076,172 +1051,46 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1076,172 +1051,46 @@ public class UserOperationServiceImpl implements UserOperationService {
1076 if (UserConstant.platform_dx.contains(platform)) { 1051 if (UserConstant.platform_dx.contains(platform)) {
1077 bindIptvPlatformType = PLATFORM_LIST[1]; 1052 bindIptvPlatformType = PLATFORM_LIST[1];
1078 } 1053 }
1079 memberDTO.setUserIptvId(userTvDTO.getId()); 1054 member.setUserIptvId(userTvDTO.getId());
1080 memberDTO.setBindIptvTime(TimestampUtil.now()); 1055 member.setBindIptvTime(TimestampUtil.now());
1081 memberDTO.setBindIptvPlatformType(bindIptvPlatformType); 1056 member.setBindIptvPlatformType(bindIptvPlatformType);
1082 memberDTO.setPlatformAccount(platformAccount); 1057 member.setPlatformAccount(platformAccount);
1083 1058
1084 // 大屏是否绑定主账号,如果绑定了主账户则不操作大屏账户表
1085 UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTO.getCode(), "auto");
1086 if (Objects.isNull(_userTvDTO)) {
1087 _userTvDTO = userTvDTO;
1088 }
1089 // 修改会员 1059 // 修改会员
1090 MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); 1060 memberDTO = this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member);
1091
1092 _memberDTO.setPlatformAccount(platformAccount);
1093 1061
1062 memberDTO.setPlatformAccount(platformAccount);
1094 1063
1095 log.info("发送到大屏侧的消息对象 会员信息 ==>> {} || 账号信息 ==>> {}", _memberDTO , _userTvDTO); 1064 log.info("发送到大屏侧的消息对象 会员信息 ==>> {} || 账号信息 ==>> {}", memberDTO , userTvDTO);
1096 // 同步至iptv 1065 // 同步至iptv
1097 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncAppletBind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); 1066 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMinaBind(new MemberAndUserTvDTO(memberDTO, userTvDTO));
1098 1067
1099 return null; 1068 return userTvDTO;
1100 } 1069 }
1101 1070
1102 /** 1071 /**
1103 * 1072 *
1104 * @param unionid 1073 * @param unionId 身份唯一标识
1105 * @param appId 1074 * @param appId 应用标识
1106 * @return 1075 * @return UserWeixinDTO
1107 */
1108 private UserWeixinDTO findUserWeiXinByUnionIdAndAppId(String unionid, String appId) {
1109 return this.userWeixinService.findFirstByUnionidAndAppid(unionid,appId);
1110 }
1111
1112 /**
1113 * 修改会员vip状态
1114 */
1115 private MemberDTO doUpdateMemberVip(MemberDTO memberDTO,Integer vip1) {
1116 if (memberDTO != null) {
1117 Integer vip = memberDTO.getVip();
1118 vip = (vip == null ? 0 : vip);
1119 // 未购买付费会员
1120 if (vip <= 1) {
1121
1122 memberDTO.setVip(vip1);
1123
1124 Member member = new Member();
1125 member.setId(memberDTO.getId());
1126 member.setCode(memberDTO.getCode());
1127 member.setVipExpireTime(null);
1128 // this.memberService.update(member);
1129 this.memberService.doUpdateMemberVipAndVipExpireTime(member);
1130
1131 return memberDTO;
1132 }
1133 }
1134
1135 return null;
1136 }
1137
1138 /**
1139 * 获取小屏会员
1140 * @param userWeixinDTO
1141 * @return
1142 */
1143 private MemberDTO findMemberByUserWeixinDTO(UserWeixinDTO userWeixinDTO) {
1144 Long memberId = userWeixinDTO.getMemberId();
1145 if (Objects.nonNull(memberId)) {
1146 MemberDTO memberDTO = this.findMemberById(memberId);
1147 return memberDTO;
1148 }
1149 return null;
1150 }
1151
1152 /**
1153 * 修改微信公众号关注状态
1154 * @param status 0:取消关注 1:关注
1155 */
1156 private UserWeixinDTO doUpdateUserWeiXinStatus(String appId, String openId, Integer status) {
1157
1158 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId);
1159
1160 if (Objects.nonNull(userWeixinDTO.getId())) {
1161
1162 UserWeixin userWeixin = new UserWeixin();
1163 userWeixin.setId(userWeixinDTO.getId());
1164 userWeixin.setStatus(status);
1165 userWeixinDTO = this.userWeixinService.doUpdateWeixinStatus(userWeixin);
1166 return userWeixinDTO;
1167 }
1168
1169 return userWeixinDTO;
1170
1171 }
1172
1173 /**
1174 * 修改微信公众号关注状态
1175 * @param status 0:取消关注 1:关注
1176 */ 1076 */
1177 public UserWeixinDTO doUpdateUserWeiXinStatus(UserWeixinDTO userWeixinDTO, Integer status) { 1077 private UserWeixinDTO findUserWeiXinByUnionIdAndAppId(String unionId, String appId) {
1178 1078 return this.userWeixinService.findFirstByUnionidAndAppid(unionId, appId);
1179 userWeixinDTO.setStatus(status);
1180
1181 UserWeixin userWeixin = new UserWeixin();
1182 BeanUtils.copyProperties(userWeixinDTO,userWeixin);
1183
1184 this.userWeixinService.update(userWeixin);
1185
1186 return userWeixinDTO;
1187
1188 } 1079 }
1189 1080
1190 /** 1081 /**
1191 * 获取会员 1082 * 获取会员
1192 * @param memberId 1083 * @param memberId 会员id
1193 * @return 1084 * @return MemberDTO
1194 */ 1085 */
1195 private MemberDTO findMemberById(Long memberId) { 1086 private MemberDTO findMemberById(Long memberId) {
1196 MemberDTO memberDTO = this.memberService.findById(memberId); 1087 return this.memberService.findById(memberId);
1197 return memberDTO;
1198 }
1199
1200 /**
1201 * 获取小屏会员
1202 * @param appId
1203 * @param openId
1204 * @return
1205 */
1206 private MemberDTO findMemberByAppIdAndOpenId(String appId, String openId) {
1207 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId,openId);
1208 if (Objects.nonNull(userWeixinDTO)) {
1209 Long memberId = userWeixinDTO.getMemberId();
1210 return this.findMemberById(memberId);
1211 }
1212 return null;
1213 }
1214
1215 /**
1216 * 设置主会员
1217 * @description 检查大屏账户有没有绑定小屏会员,如果没有绑定就将当前会员的code保存到大屏账户中
1218 * @param userTvDTO
1219 * @param memberCode
1220 * @param auto manual:手动 auto:自动
1221 */
1222 private UserTvDTO bondPriorityMember(UserTvDTO userTvDTO, String memberCode, String auto) {
1223
1224 if (auto.equalsIgnoreCase("auto")) {
1225 // 主账户
1226 String priorityMemberCode = userTvDTO.getPriorityMemberCode();
1227 if (StringUtils.isNotEmpty(priorityMemberCode)) {
1228 return null;
1229 }
1230 }
1231
1232 userTvDTO.setPriorityMemberCode(memberCode);
1233
1234 UserTv userTv = new UserTv();
1235 BeanUtils.copyProperties(userTvDTO, userTv);
1236 UserTvDTO _userTvDTO = this.updateUserTvUnsyncIptv(userTv);
1237
1238 return _userTvDTO;
1239 } 1088 }
1240 1089
1241 /** 1090 /**
1242 * 1091 *
1243 * @param userTv 1092 * @param userTv 大屏账号
1244 * @return 1093 * @return UserTvDTO
1245 */ 1094 */
1246 private UserTvDTO updateUserTvUnsyncIptv(UserTv userTv){ 1095 private UserTvDTO updateUserTvUnsyncIptv(UserTv userTv){
1247 return this.userTvService.update(userTv); 1096 return this.userTvService.update(userTv);
...@@ -1316,37 +1165,15 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1316,37 +1165,15 @@ public class UserOperationServiceImpl implements UserOperationService {
1316 userTv.setPlatform(userTvDTO.getPlatformAccount()); 1165 userTv.setPlatform(userTvDTO.getPlatformAccount());
1317 userTv.setPriorityMemberCode(bindMemberCode); 1166 userTv.setPriorityMemberCode(bindMemberCode);
1318 // 绑定新的主账号 1167 // 绑定新的主账号
1319 UserTvDTO _userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); 1168 return this.userTvService.doUpdatePriorityMemberCode(userTv);
1320
1321 return _userTvDTO;
1322 1169
1323 } 1170 }
1324 } 1171 }
1325 1172
1326 /** 1173 /**
1327 * 修改会员
1328 * @param memberDTO
1329 */
1330 private MemberDTO doUpdateMemberByMemberDTO(MemberDTO memberDTO){
1331 Member member = new Member();
1332 BeanUtils.copyProperties(memberDTO,member);
1333 member.setUpdateTime(TimestampUtil.now());
1334 log.info("doUpdateMemberByMemberDTO=====?>>member ==>> [{}]",member);
1335 return this.doUpdateMember(member);
1336 }
1337
1338 /**
1339 * 修改会员
1340 * @param member
1341 */
1342 private MemberDTO doUpdateMember(Member member){
1343 return this.memberService.update(member);
1344 }
1345
1346 /**
1347 * 1174 *
1348 * @param unionId 1175 * @param unionId 身份标识
1349 * @return 1176 * @return UserWeixinDTO
1350 */ 1177 */
1351 private UserWeixinDTO findFirstByUnionId(String unionId) { 1178 private UserWeixinDTO findFirstByUnionId(String unionId) {
1352 return this.userWeixinService.findFirstByUnionId(unionId); 1179 return this.userWeixinService.findFirstByUnionId(unionId);
...@@ -1355,7 +1182,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1355,7 +1182,7 @@ public class UserOperationServiceImpl implements UserOperationService {
1355 /** 1182 /**
1356 * 同一用户有多个微信APP的情况下展示同一个账户信息 1183 * 同一用户有多个微信APP的情况下展示同一个账户信息
1357 * 原则:那个先创建就用那个id 1184 * 原则:那个先创建就用那个id
1358 * @param userWeixinDTO 1185 * @param userWeixinDTO 微信信息
1359 */ 1186 */
1360 private UserWeixinDTO getFirstId(UserWeixinDTO userWeixinDTO) { 1187 private UserWeixinDTO getFirstId(UserWeixinDTO userWeixinDTO) {
1361 String unionid = userWeixinDTO.getUnionid(); 1188 String unionid = userWeixinDTO.getUnionid();
...@@ -1402,9 +1229,9 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1402,9 +1229,9 @@ public class UserOperationServiceImpl implements UserOperationService {
1402 1229
1403 /** 1230 /**
1404 * 获取小屏账户 1231 * 获取小屏账户
1405 * @param appId 1232 * @param appId 应用标识
1406 * @param openId 1233 * @param openId 应用唯一标识
1407 * @return 1234 * @return UserWeixinDTO
1408 */ 1235 */
1409 private UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId) { 1236 private UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId) {
1410 return this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId); 1237 return this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId);
...@@ -1412,8 +1239,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1412,8 +1239,8 @@ public class UserOperationServiceImpl implements UserOperationService {
1412 1239
1413 /** 1240 /**
1414 * 1241 *
1415 * @param member 1242 * @param member 会员信息
1416 * @return 1243 * @return MemberDTO
1417 */ 1244 */
1418 private MemberDTO createMember(Member member){ 1245 private MemberDTO createMember(Member member){
1419 return this.memberService.create(member); 1246 return this.memberService.create(member);
...@@ -1421,53 +1248,49 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1421,53 +1248,49 @@ public class UserOperationServiceImpl implements UserOperationService {
1421 1248
1422 /** 1249 /**
1423 * 1250 *
1424 * @param resources 1251 * @param resources 大屏账号信息
1425 * @param memberId 1252 * @param memberId 会员id
1426 * @return 1253 * @return UserTvDTO
1427 */ 1254 */
1428 private UserTvDTO createTvUser(UserTv resources, Long memberId, String memberCode){ 1255 private UserTvDTO createTvUser(UserTv resources, Long memberId, String memberCode){
1429 1256
1430 resources.setMemberId(memberId); 1257 resources.setMemberId(memberId);
1431 resources.setMemberCode(memberCode); 1258 resources.setMemberCode(memberCode);
1432 UserTvDTO userTvDTO = this.userTvService.create(resources); 1259 return this.userTvService.create(resources);
1433 return userTvDTO;
1434 } 1260 }
1435 1261
1436 /** 1262 /**
1437 * 1263 *
1438 * @param resource 1264 * @param resource 微信信息
1439 * @param memberId 1265 * @param memberId 会员id
1440 * @param memberCode 1266 * @param memberCode 会员code
1441 * @return 1267 * @return UserWeixinDTO
1442 */ 1268 */
1443 private UserWeixinDTO createWeixinUser(UserWeixin resource, Long memberId, String memberCode){ 1269 private UserWeixinDTO createWeixinUser(UserWeixin resource, Long memberId, String memberCode){
1444 if (Objects.nonNull(memberId)) resource.setMemberId(memberId); 1270 if (Objects.nonNull(memberId)) resource.setMemberId(memberId);
1445 if (StringUtils.isNotBlank(memberCode)) resource.setMemberCode(memberCode); 1271 if (StringUtils.isNotBlank(memberCode)) resource.setMemberCode(memberCode);
1446 1272
1447 UserWeixinDTO userWeixinDTO = this.userWeixinService.create(resource); 1273 return this.userWeixinService.create(resource);
1448
1449 return userWeixinDTO;
1450 } 1274 }
1451 1275
1452 /** 1276 /**
1453 * 1277 *
1454 * @param memberDTO 1278 * @param memberDTO 会员信息
1455 * @return 1279 * @return UserTvDTO
1456 */ 1280 */
1457 @Override 1281 @Override
1458 public UserTvDTO checkBind(MemberDTO memberDTO) { 1282 public UserTvDTO checkBind(MemberDTO memberDTO) {
1459 MemberDTO memberDTO1 = this.memberService.findByCode(memberDTO.getCode()); 1283 MemberDTO memberDTO1 = this.memberService.findByCode(memberDTO.getCode());
1460 if (Objects.nonNull(memberDTO1.getUserIptvId())) { 1284 if (Objects.nonNull(memberDTO1.getUserIptvId())) {
1461 UserTvDTO userTvDTO = this.userTvService.findById(memberDTO1.getUserIptvId()); 1285 return this.userTvService.findById(memberDTO1.getUserIptvId());
1462 return userTvDTO;
1463 } 1286 }
1464 return null; 1287 return null;
1465 } 1288 }
1466 1289
1467 /** 1290 /**
1468 * 1291 *
1469 * @param platformAccount 1292 * @param platformAccount 大屏账号
1470 * @return 1293 * @return UserTvDTO
1471 */ 1294 */
1472 @Override 1295 @Override
1473 public UserTvDTO findByPlatformAccount(String platformAccount) { 1296 public UserTvDTO findByPlatformAccount(String platformAccount) {
...@@ -1495,8 +1318,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1495,8 +1318,7 @@ public class UserOperationServiceImpl implements UserOperationService {
1495 return false; 1318 return false;
1496 } 1319 }
1497 1320
1498 boolean b = this.tvUnbindAndSetNewPriorityMemberCode(memberDTO, userTvDTO); 1321 return this.tvUnbindAndSetNewPriorityMemberCode(memberDTO, userTvDTO);
1499 return b;
1500 } 1322 }
1501 1323
1502 private boolean tvUnbindAndSetNewPriorityMemberCode(MemberDTO memberDTO, UserTvDTO userTvDTO) { 1324 private boolean tvUnbindAndSetNewPriorityMemberCode(MemberDTO memberDTO, UserTvDTO userTvDTO) {
...@@ -1559,8 +1381,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1559,8 +1381,7 @@ public class UserOperationServiceImpl implements UserOperationService {
1559 1381
1560 @Override 1382 @Override
1561 public UserWeixinDTO findById(Long userId) { 1383 public UserWeixinDTO findById(Long userId) {
1562 UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(userId); 1384 return this.userWeixinService.findById(userId);
1563 return userWeixinDTO;
1564 } 1385 }
1565 1386
1566 @Override 1387 @Override
...@@ -1580,7 +1401,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1580,7 +1401,7 @@ public class UserOperationServiceImpl implements UserOperationService {
1580 Long memberId = userTvDTO.getMemberId(); 1401 Long memberId = userTvDTO.getMemberId();
1581 if (Objects.nonNull(memberId)) { 1402 if (Objects.nonNull(memberId)) {
1582 MemberDTO memberDTO = this.memberService.findById(memberId); 1403 MemberDTO memberDTO = this.memberService.findById(memberId);
1583 resources.setMemberCode(memberDTO.getCode()); 1404 userTvDTO.setMemberCode(memberDTO.getCode());
1584 } 1405 }
1585 // 同步至iptv 1406 // 同步至iptv
1586 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(userTvDTO); 1407 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(userTvDTO);
...@@ -1588,19 +1409,24 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1588,19 +1409,24 @@ public class UserOperationServiceImpl implements UserOperationService {
1588 } 1409 }
1589 1410
1590 1411
1591 @Override
1592 public UserTvDTO updateUserTvVisUserId(UserTv resources) {
1593
1594 UserTvDTO userTvDTO = this.userTvService.update(resources);
1595 Long memberId = userTvDTO.getMemberId();
1596 1412
1597 if (Objects.nonNull(memberId)) { 1413 @AsyncMqSend
1598 MemberDTO memberDTO = this.memberService.findById(memberId); 1414 public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
1599 resources.setMemberCode(memberDTO.getCode()); 1415 @AsyncMqSend
1600 } 1416 public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTv) {}
1417 @AsyncMqSend
1418 public void asyncWeixin(UserWeixinDTO weixinDTO) {}
1419 @AsyncMqSend
1420 public void asyncUserTv(UserTvDTO userTvDTO) {}
1421 @AsyncMqSend
1422 public void asyncUserTvChangeMainAccount(UserTvDTO userTvDTO) {}
1423 @AsyncMqSend
1424 public void asyncMinaBind(MemberAndUserTvDTO memberAndUserTvDTO) {}
1425 @AsyncMqSend
1426 public void asyncUnbind(MemberAndUserTvDTO memberAndUserTvDTO) {}
1427 @AsyncMqSend
1428 public void asyncUnsubscribe(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
1429 @AsyncMqSend
1430 public void asyncSubscribe(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
1601 1431
1602 // 同步至iptv
1603 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(userTvDTO);
1604 return userTvDTO;
1605 }
1606 } 1432 }
......
...@@ -9,13 +9,12 @@ import com.topdraw.business.module.member.service.MemberService; ...@@ -9,13 +9,12 @@ import com.topdraw.business.module.member.service.MemberService;
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.member.viphistory.domain.MemberVipHistory; 10 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
11 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; 11 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
12 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 12 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
13 import com.topdraw.business.module.user.weixin.service.UserWeixinService; 13 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
14 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 14 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
15 import com.topdraw.business.process.domian.weixin.BuyVipBean; 15 import com.topdraw.business.process.domian.member.MemberOperationBean;
16 import com.topdraw.business.process.service.member.MemberOperationService; 16 import com.topdraw.business.process.service.member.MemberOperationService;
17 import com.topdraw.config.RedisKeyConstants; 17 import com.topdraw.config.RedisKeyConstants;
18 import com.topdraw.exception.EntityNotFoundException;
19 import com.topdraw.util.TimestampUtil; 18 import com.topdraw.util.TimestampUtil;
20 import lombok.extern.slf4j.Slf4j; 19 import lombok.extern.slf4j.Slf4j;
21 import org.springframework.aop.framework.AopContext; 20 import org.springframework.aop.framework.AopContext;
...@@ -27,7 +26,6 @@ import org.springframework.stereotype.Service; ...@@ -27,7 +26,6 @@ import org.springframework.stereotype.Service;
27 import org.springframework.util.Assert; 26 import org.springframework.util.Assert;
28 27
29 import java.sql.Timestamp; 28 import java.sql.Timestamp;
30 import java.time.LocalDateTime;
31 import java.util.Objects; 29 import java.util.Objects;
32 30
33 @Service 31 @Service
...@@ -45,81 +43,17 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -45,81 +43,17 @@ public class MemberOperationServiceImpl implements MemberOperationService {
45 @Autowired 43 @Autowired
46 private MemberVipHistoryService memberVipHistoryService; 44 private MemberVipHistoryService memberVipHistoryService;
47 45
48
49
50 @AsyncMqSend 46 @AsyncMqSend
51 public void asyncUpdateMemberVip(MemberDTO memberDTO) {} 47 public void asyncUpdateMemberVipAndVipExpireTime(MemberDTO memberDTO) {}
52
53 @Override
54 public MemberDTO buyVipByUserId(BuyVipBean resources) {
55 // 小程序账户id
56 Long id = resources.getId();
57 // 查询微信账户
58 UserWeixinDTO userWeixin = this.findWeiXinById(id);
59 Long memberId = userWeixin.getMemberId();
60 resources.setMemberId(memberId);
61 return this.buyVipByMemberId(resources);
62 }
63
64 @Override
65 public MemberDTO buyVipByMemberId(BuyVipBean resources) {
66
67 Timestamp vipExpireTime1 = resources.getVipExpireTime();
68 Integer vip1 = resources.getVip();
69
70 Long memberId = resources.getMemberId();
71 //
72 MemberDTO memberDTO = this.findById(memberId);
73 String memberCode = memberDTO.getCode();
74 Integer vip = memberDTO.getVip();
75
76 //
77 Timestamp vipExpireTime = memberDTO.getVipExpireTime();
78 if (Objects.nonNull(vipExpireTime1)) {
79 vipExpireTime = vipExpireTime1;
80 }
81
82 //判断之前有没有买过,没买过,失效时间为一年后;
83 if (Objects.isNull(vipExpireTime1)) {
84 if (ObjectUtil.isNull(vipExpireTime)) {
85 LocalDateTime now = LocalDateTime.now();
86 vipExpireTime = TimestampUtil.localDateTime2Timestamp(now.plusYears(1L));
87 } else {
88 LocalDateTime localDateTime = TimestampUtil.timestamp2LocalDateTime(vipExpireTime).plusYears(1L);
89 vipExpireTime = TimestampUtil.localDateTime2Timestamp(localDateTime);
90 }
91
92 }
93
94
95 Member member = new Member();
96 member.setVip(vip1);
97 member.setVipExpireTime(vipExpireTime);
98
99 this.doUpdateMemberVipAndVipExpireTime(member);
100 48
101 MemberVipHistory memberVipHistory = new MemberVipHistory(); 49 @AsyncMqSend
102 memberVipHistory.setMemberId(memberId).setVip(vip1).setBeforeVip(vip); 50 public void asyncCreateMemberVipHistory(MemberVipHistoryDTO memberVipHistoryDTO) {}
103 if (ObjectUtil.equal(vip1,vip)) {
104 memberVipHistory.setStatus(1);
105 }
106 memberVipHistory.setMemberCode(memberCode);
107 memberVipHistory.setVipExpireTime(member.getVipExpireTime());
108 this.createVipHistory(memberVipHistory);
109 51
110 return memberDTO;
111 }
112
113 @Override
114 public void createVipHistory(MemberVipHistory memberVipHistory){
115 this.memberVipHistoryService.create(memberVipHistory);
116 }
117 52
118 @AsyncMqSend 53 @AsyncMqSend
119 @Override 54 @Override
120 public MemberDTO update(Member resources) { 55 public MemberDTO update(Member resources) {
121 MemberDTO memberDTO = this.memberService.update(resources); 56 return this.memberService.update(resources);
122 return memberDTO;
123 } 57 }
124 58
125 @Override 59 @Override
...@@ -127,22 +61,6 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -127,22 +61,6 @@ public class MemberOperationServiceImpl implements MemberOperationService {
127 return this.memberService.findByCode(code); 61 return this.memberService.findByCode(code);
128 } 62 }
129 63
130 private UserWeixinDTO findWeiXinById(Long id) {
131 UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id);
132 if (Objects.isNull(userWeixinDTO)) {
133 throw new EntityNotFoundException(UserWeixin.class, "id", userWeixinDTO.getId().toString());
134 }
135
136 return userWeixinDTO;
137 }
138
139 @Override
140 public MemberDTO doUpdateMember(Member resources) {
141 Long id = resources.getId();
142 Assert.notNull(id,"ERROR MSG: MemberOperationServiceImpl -> doUpdateMemberInfo -> id not be null!!");
143 return this.update(resources);
144 }
145
146 @Override 64 @Override
147 public MemberDTO doInsertMember(Member resources) { 65 public MemberDTO doInsertMember(Member resources) {
148 return this.memberService.create(resources); 66 return this.memberService.create(resources);
...@@ -159,7 +77,6 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -159,7 +77,6 @@ public class MemberOperationServiceImpl implements MemberOperationService {
159 return this.memberService.doUpdateMemberExpAndLevel(resources); 77 return this.memberService.doUpdateMemberExpAndLevel(resources);
160 } 78 }
161 79
162
163 @Override 80 @Override
164 public MemberDTO doUpdateMemberPoints(Member resources) { 81 public MemberDTO doUpdateMemberPoints(Member resources) {
165 return this.memberService.doUpdateMemberPoints(resources); 82 return this.memberService.doUpdateMemberPoints(resources);
...@@ -174,23 +91,56 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -174,23 +91,56 @@ public class MemberOperationServiceImpl implements MemberOperationService {
174 91
175 @Override 92 @Override
176 // @CachePut(cacheNames = RedisKeyConstants.cacheMemberById, key = "#member.id") 93 // @CachePut(cacheNames = RedisKeyConstants.cacheMemberById, key = "#member.id")
177 public MemberDTO doUpdateMemberVipAndVipExpireTime(Member member) { 94 public MemberDTO doUpdateMemberVipAndVipExpireTime(Member resource) {
178 MemberDTO memberDTO1 = this.memberService.findByCode(member.getCode()); 95 MemberDTO memberDTO1 = this.memberService.findByCode(resource.getCode());
179 96
180 Member member1 = new Member(); 97 Member member = new Member();
181 member1.setId(memberDTO1.getId()); 98 member.setId(memberDTO1.getId());
182 member1.setCode(memberDTO1.getCode()); 99 member.setCode(memberDTO1.getCode());
183 member1.setVip(member.getVip()); 100 member.setVip(resource.getVip());
184 member1.setVipExpireTime(member.getVipExpireTime()); 101 member.setVipExpireTime(resource.getVipExpireTime());
185 MemberDTO memberDTO_ = this.memberService.doUpdateMemberVipAndVipExpireTime(member1); 102 MemberDTO memberDTO = this.memberService.doUpdateMemberVipAndVipExpireTime(member);
186 103
187 ((MemberOperationServiceImpl) AopContext.currentProxy()).asyncUpdateMemberVip(memberDTO_); 104 ((MemberOperationServiceImpl) AopContext.currentProxy()).asyncUpdateMemberVipAndVipExpireTime(memberDTO);
105
106 return memberDTO;
107 }
108
109 @Override
110 public MemberDTO doUpdateVipByMemberCode(MemberOperationBean resources) {
111 Integer nowVip = resources.getVip();
112 Long memberId = resources.getMemberId();
113 Timestamp vipExpireTime = resources.getVipExpireTime();
114
115 MemberDTO memberDTO = this.memberService.findById(memberId);
116
117 String memberCode = memberDTO.getCode();
118 Integer vip = memberDTO.getVip();
119
120 Member member = new Member();
121 member.setId(memberDTO.getId());
122 member.setCode(memberCode);
123 member.setVip(vip);
124 member.setVipExpireTime(vipExpireTime);
125
126 MemberDTO memberDTO_ = this.memberService.doUpdateMemberVipAndVipExpireTime(member);
127
128 ((MemberOperationServiceImpl) AopContext.currentProxy()).asyncUpdateMemberVipAndVipExpireTime(memberDTO_);
129
130 MemberVipHistory memberVipHistory = new MemberVipHistory();
131 memberVipHistory.setMemberId(memberId).setVip(nowVip).setBeforeVip(vip);
132 memberVipHistory.setMemberCode(memberCode);
133 memberVipHistory.setVipExpireTime(vipExpireTime);
134 MemberVipHistoryDTO memberVipHistoryDTO = this.memberVipHistoryService.create(memberVipHistory);
135
136 ((MemberOperationServiceImpl) AopContext.currentProxy()).asyncCreateMemberVipHistory(memberVipHistoryDTO);
188 137
189 return memberDTO_; 138 return memberDTO_;
190 } 139 }
191 140
141
192 @Override 142 @Override
193 public MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appid) { 143 public MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appId) {
194 144
195 // 会员加密信息 145 // 会员加密信息
196 MemberProfileDTO memberProfileDTO_0 = this.findMemberProfileByMemberId(memberId); 146 MemberProfileDTO memberProfileDTO_0 = this.findMemberProfileByMemberId(memberId);
...@@ -199,13 +149,11 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -199,13 +149,11 @@ public class MemberOperationServiceImpl implements MemberOperationService {
199 MemberDTO memberDTO = this.findById(memberId); 149 MemberDTO memberDTO = this.findById(memberId);
200 150
201 // 初始化会员加密信息 151 // 初始化会员加密信息
202 MemberProfileDTO memberProfileDTO_1 = this.configMemberProfile(memberProfileDTO_0,memberDTO,appid); 152 return this.configMemberProfile(memberProfileDTO_0, memberDTO, appId);
203
204 return memberProfileDTO_1;
205 } 153 }
206 154
207 155
208 private MemberProfileDTO configMemberProfile(MemberProfileDTO memberProfileDTO_0, MemberDTO memberDTO, String appid) { 156 private MemberProfileDTO configMemberProfile(MemberProfileDTO memberProfileDTO_0, MemberDTO memberDTO, String appId) {
209 157
210 if (Objects.isNull(memberProfileDTO_0)) return memberProfileDTO_0; 158 if (Objects.isNull(memberProfileDTO_0)) return memberProfileDTO_0;
211 159
...@@ -217,11 +165,11 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -217,11 +165,11 @@ public class MemberOperationServiceImpl implements MemberOperationService {
217 // 过期时间 165 // 过期时间
218 Timestamp vipExpireTime = memberDTO.getVipExpireTime(); 166 Timestamp vipExpireTime = memberDTO.getVipExpireTime();
219 167
220 Long timeLong = 0L; 168 long timeLong = 0L;
221 if (ObjectUtil.isNotNull(vipExpireTime)) { 169 if (ObjectUtil.isNotNull(vipExpireTime)) {
222 170
223 // 检查vip 171 // 检查vip
224 MemberDTO memberDTO1 = this.checkVipStatus(memberDTO,vipExpireTime,appid); 172 MemberDTO memberDTO1 = this.checkVipStatus(memberDTO, vipExpireTime, appId);
225 173
226 // 更新会员信息 174 // 更新会员信息
227 Member member = new Member(); 175 Member member = new Member();
...@@ -259,10 +207,10 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -259,10 +207,10 @@ public class MemberOperationServiceImpl implements MemberOperationService {
259 * 1.当前vip如果过期则查看是否有vip历史变动 207 * 1.当前vip如果过期则查看是否有vip历史变动
260 * 2.如果vip变动历史有记录则获取vip变动记录 208 * 2.如果vip变动历史有记录则获取vip变动记录
261 * 3.如果vip没有记录则查看是否关注了公众号 209 * 3.如果vip没有记录则查看是否关注了公众号
262 * @param vipExpireTime 210 * @param vipExpireTime 过期时间
263 * @return 211 * @return MemberDTO
264 */ 212 */
265 private MemberDTO checkVipStatus(MemberDTO memberDTO,Timestamp vipExpireTime, String appid) { 213 private MemberDTO checkVipStatus(MemberDTO memberDTO,Timestamp vipExpireTime, String appId) {
266 214
267 Long memberId = memberDTO.getId(); 215 Long memberId = memberDTO.getId();
268 Timestamp nowTime = TimestampUtil.now(); 216 Timestamp nowTime = TimestampUtil.now();
...@@ -271,16 +219,16 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -271,16 +219,16 @@ public class MemberOperationServiceImpl implements MemberOperationService {
271 if (nowTime.compareTo(vipExpireTime) >= 0 ) { 219 if (nowTime.compareTo(vipExpireTime) >= 0 ) {
272 220
273 Integer vip = 0; 221 Integer vip = 0;
274 Timestamp vipExpireTime1 = memberDTO.getVipExpireTime(); 222 Timestamp vipExpireTime1;
275 223
276 //查询小于失效时间的那条记录 查不到 取微信表里 关注状态 224 //查询小于失效时间的那条记录 查不到 取微信表里 关注状态
277 MemberVipHistory memberVipHistory = this.memberVipHistoryService.findByTime(memberId, nowTime); 225 MemberVipHistory memberVipHistory = this.memberVipHistoryService.findByTime(memberId, nowTime);
278 226
279 if (ObjectUtil.isNull(memberVipHistory.getId())) { 227 if (ObjectUtil.isNull(memberVipHistory.getId())) {
280 228
281 UserWeixinDTO userWeixin = this.userWeixinService.findFirstByMemberIdAndAppid(memberId, appid); 229 UserWeixinDTO userWeiXin = this.userWeixinService.findFirstByMemberIdAndAppid(memberId, appId);
282 // 微信公众号关注的状态 0:未关注 1:关注 230 // 微信公众号关注的状态 0:未关注 1:关注
283 Integer status = userWeixin.getStatus(); 231 Integer status = userWeiXin.getStatus();
284 232
285 if (status != 1) vip = 0; else vip = 1; 233 if (status != 1) vip = 0; else vip = 1;
286 vipExpireTime1 = null; 234 vipExpireTime1 = null;
...@@ -300,8 +248,8 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -300,8 +248,8 @@ public class MemberOperationServiceImpl implements MemberOperationService {
300 248
301 /** 249 /**
302 * 查询会员加密信息 250 * 查询会员加密信息
303 * @param memberId 251 * @param memberId 会员id
304 * @return 252 * @return MemberProfileDTO
305 */ 253 */
306 private MemberProfileDTO findMemberProfileByMemberId(Long memberId) { 254 private MemberProfileDTO findMemberProfileByMemberId(Long memberId) {
307 return this.memberProfileService.findByMemberId(memberId); 255 return this.memberProfileService.findByMemberId(memberId);
......
...@@ -11,13 +11,11 @@ import com.topdraw.business.process.service.dto.MemberProfileAndMemberDTO; ...@@ -11,13 +11,11 @@ import com.topdraw.business.process.service.dto.MemberProfileAndMemberDTO;
11 import com.topdraw.business.process.service.member.MemberProfileOperationService; 11 import com.topdraw.business.process.service.member.MemberProfileOperationService;
12 import com.topdraw.exception.EntityExistException; 12 import com.topdraw.exception.EntityExistException;
13 import com.topdraw.exception.EntityNotFoundException; 13 import com.topdraw.exception.EntityNotFoundException;
14 import org.apache.commons.lang3.StringUtils;
15 import org.springframework.aop.framework.AopContext; 14 import org.springframework.aop.framework.AopContext;
16 import org.springframework.beans.BeanUtils; 15 import org.springframework.beans.BeanUtils;
17 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
19 18
20 import javax.validation.constraints.NotNull;
21 import java.util.Objects; 19 import java.util.Objects;
22 20
23 21
...@@ -39,25 +37,16 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation ...@@ -39,25 +37,16 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation
39 private MemberService memberService; 37 private MemberService memberService;
40 38
41 @AsyncMqSend 39 @AsyncMqSend
42 public void asyncMemberProfile(MemberProfileDTO memberProfileDTO){} 40 public void asyncUpdateMemberProfileAndSyncMember(MemberProfileAndMemberDTO memberProfileAndMemberDTO){}
43 @AsyncMqSend 41 @AsyncMqSend
44 public void asyncMemberProfileAndMember(MemberProfileAndMemberDTO memberProfileAndMemberDTO){} 42 public void asyncCreateMemberProfileAndSyncMember(MemberProfileDTO memberProfileDTO) {}
45 @AsyncMqSend
46 public void asyncCreateMemberProfile(MemberProfileDTO memberProfileDTO) {}
47
48 @Override
49 public MemberProfileDTO update(MemberProfile resources) {
50 MemberProfileDTO memberProfileDTO = this.memberProfileService.update(resources);
51 memberProfileDTO.setMemberCode(resources.getMemberCode());
52 ((MemberProfileOperationServiceImpl) AopContext.currentProxy()).asyncMemberProfile(memberProfileDTO);
53 return memberProfileDTO;
54 }
55 43
56 @Override 44 @Override
57 public MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources) { 45 public MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources) {
58 Long id = resources.getId(); 46 Long id = resources.getId();
59 MemberProfileDTO _memberProfile = this.memberProfileService.findById(id); 47 MemberProfileDTO memberProfile = this.memberProfileService.findById(id);
60 Long memberId = _memberProfile.getMemberId(); 48
49 Long memberId = memberProfile.getMemberId();
61 resources.setMemberId(memberId); 50 resources.setMemberId(memberId);
62 51
63 MemberDTO memberDTO = this.memberService.checkMember(resources.getMemberId(), resources.getMemberCode()); 52 MemberDTO memberDTO = this.memberService.checkMember(resources.getMemberId(), resources.getMemberCode());
...@@ -68,7 +57,7 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation ...@@ -68,7 +57,7 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation
68 memberProfileDTO.setMemberCode(memberDTO.getCode()); 57 memberProfileDTO.setMemberCode(memberDTO.getCode());
69 58
70 ((MemberProfileOperationServiceImpl)AopContext.currentProxy()) 59 ((MemberProfileOperationServiceImpl)AopContext.currentProxy())
71 .asyncMemberProfileAndMember(new MemberProfileAndMemberDTO(memberProfileDTO, memberDTO)); 60 .asyncUpdateMemberProfileAndSyncMember(new MemberProfileAndMemberDTO(memberProfileDTO, memberDTO));
72 61
73 return memberProfileDTO; 62 return memberProfileDTO;
74 } 63 }
...@@ -88,7 +77,7 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation ...@@ -88,7 +77,7 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation
88 77
89 this.createMemberProfileAndSyncMember(memberProfileDTO, memberDTO); 78 this.createMemberProfileAndSyncMember(memberProfileDTO, memberDTO);
90 79
91 ((MemberProfileOperationServiceImpl) AopContext.currentProxy()).asyncCreateMemberProfile(memberProfileDTO); 80 ((MemberProfileOperationServiceImpl) AopContext.currentProxy()).asyncCreateMemberProfileAndSyncMember(memberProfileDTO);
92 81
93 } else { 82 } else {
94 83
...@@ -112,13 +101,11 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation ...@@ -112,13 +101,11 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation
112 101
113 private void syncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) { 102 private void syncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) {
114 Member member = new Member(); 103 Member member = new Member();
115
116 member.setId(memberDTO.getId()); 104 member.setId(memberDTO.getId());
117 member.setCode(memberDTO.getCode()); 105 member.setCode(memberDTO.getCode());
118 member.setAvatarUrl(memberProfileDTO.getAvatarUrl()); 106 member.setAvatarUrl(memberProfileDTO.getAvatarUrl());
119 member.setNickname(memberProfileDTO.getRealname()); 107 member.setNickname(memberProfileDTO.getRealname());
120 member.setGender(memberProfileDTO.getGender()); 108 member.setGender(memberProfileDTO.getGender());
121 // this.memberService.update(member);
122 this.memberService.doUpdateMemberAvatarUrlAndNicknameAndGender(member); 109 this.memberService.doUpdateMemberAvatarUrlAndNicknameAndGender(member);
123 } 110 }
124 111
......
...@@ -4,6 +4,7 @@ import com.topdraw.business.module.member.domain.Member; ...@@ -4,6 +4,7 @@ import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; 4 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
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.member.viphistory.domain.MemberVipHistory; 6 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
7 import com.topdraw.business.process.domian.member.MemberOperationBean;
7 import com.topdraw.business.process.domian.weixin.BuyVipBean; 8 import com.topdraw.business.process.domian.weixin.BuyVipBean;
8 9
9 public interface MemberOperationService { 10 public interface MemberOperationService {
...@@ -31,26 +32,6 @@ public interface MemberOperationService { ...@@ -31,26 +32,6 @@ public interface MemberOperationService {
31 MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appid); 32 MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appid);
32 33
33 /** 34 /**
34 *
35 * @param resources
36 * @return
37 */
38 MemberDTO buyVipByUserId(BuyVipBean resources);
39
40 /**
41 *
42 * @param resources
43 * @return
44 */
45 MemberDTO buyVipByMemberId(BuyVipBean resources);
46
47 /**
48 *
49 * @param memberVipHistory
50 */
51 void createVipHistory(MemberVipHistory memberVipHistory);
52
53 /**
54 * 修改会员 35 * 修改会员
55 * @param resources 36 * @param resources
56 */ 37 */
...@@ -60,12 +41,6 @@ public interface MemberOperationService { ...@@ -60,12 +41,6 @@ public interface MemberOperationService {
60 * 41 *
61 * @param resources 42 * @param resources
62 */ 43 */
63 MemberDTO doUpdateMember(Member resources);
64
65 /**
66 *
67 * @param resources
68 */
69 MemberDTO doInsertMember(Member resources); 44 MemberDTO doInsertMember(Member resources);
70 45
71 /** 46 /**
...@@ -91,4 +66,10 @@ public interface MemberOperationService { ...@@ -91,4 +66,10 @@ public interface MemberOperationService {
91 * @param member 66 * @param member
92 */ 67 */
93 MemberDTO doUpdateMemberVipAndVipExpireTime(Member member); 68 MemberDTO doUpdateMemberVipAndVipExpireTime(Member member);
69
70 /**
71 *
72 * @param resources
73 */
74 MemberDTO doUpdateVipByMemberCode(MemberOperationBean resources);
94 } 75 }
......
...@@ -6,12 +6,6 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; ...@@ -6,12 +6,6 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
6 public interface MemberProfileOperationService { 6 public interface MemberProfileOperationService {
7 7
8 /** 8 /**
9 * 修改
10 * @param resources
11 */
12 MemberProfileDTO update(MemberProfile resources);
13
14 /**
15 * 修改会员属性并同步会员信息 9 * 修改会员属性并同步会员信息
16 * @param resources 10 * @param resources
17 */ 11 */
......
1 package com.topdraw.config;
2
3 /**
4 * @author :
5 * @description:\
6 * @function :
7 * @date :Created in 2022/6/18 13:25
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/18 13:25
11 */
12 public interface RedisKeyConstants {
13
14 String cacheMemberById = "uce::member::id";
15 String updateCacheMemberById = "uce::updateMember::id";
16
17 String updateCachePointsByMemberId = "uce::updatePoints::memberId";
18 String updateCacheExpByMemberId = "uce::updateExp::memberId";
19 String updateCacheCouponByMemberId = "uce::updateCoupon::memberId";
20
21 String cacheUserTvByPlatformAccount = "uce::userTv::platformAccount";
22 String cacheTaskProcessByMemberId = "uce::taskProcess::memberId";
23 String cacheTaskByTaskTemplateId = "uce::task::taskTemplateId";
24 }
1 package com.topdraw.config;
2
3
4 import com.fasterxml.jackson.annotation.JsonAutoDetect;
5 import com.fasterxml.jackson.annotation.PropertyAccessor;
6 import com.fasterxml.jackson.databind.ObjectMapper;
7 import lombok.extern.slf4j.Slf4j;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.cache.annotation.CachingConfigurerSupport;
10 import org.springframework.context.annotation.Bean;
11 import org.springframework.context.annotation.Configuration;
12 import org.springframework.context.annotation.Primary;
13 import org.springframework.data.redis.cache.RedisCacheConfiguration;
14 import org.springframework.data.redis.cache.RedisCacheManager;
15 import org.springframework.data.redis.connection.RedisConnectionFactory;
16 import org.springframework.data.redis.core.RedisTemplate;
17 import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
18
19 import java.time.Duration;
20 import java.util.HashSet;
21 import java.util.Set;
22 import java.util.concurrent.ConcurrentHashMap;
23
24 /**
25 * @author :
26 * @description:
27 * @function :
28 * @date :Created in 2022/6/19 16:30
29 * @version: :
30 * @modified By:
31 * @since : modified in 2022/6/19 16:30
32 */
33 @Slf4j
34 @Configuration
35 public class UceRedisConfig {
36
37 @Autowired
38 private RedisConfig redisConfig;
39 @Autowired
40 private RedisConnectionFactory redisConnectionFactory;
41
42 @Bean(value = "uceRedisTemplate")
43 public RedisTemplate<Object, Object> uceRedisTemplate() {
44 return redisConfig.redisTemplate(redisConnectionFactory);
45 }
46 /**
47 * 自定义缓存管理器
48 */
49 @Bean(value = "uceCacheManagemer")
50 @Primary
51 public RedisCacheManager cacheManager(RedisConnectionFactory factory) {
52 RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
53 Set<String> cacheNames = new HashSet<>();
54 // cacheNames.add("car");
55 // cacheNames.add(RedisKeyConstants.cacheTaskByEvent);
56 cacheNames.add(RedisKeyConstants.cacheTaskProcessByMemberId);
57 ConcurrentHashMap<String, RedisCacheConfiguration> configMap = new ConcurrentHashMap<>();
58 // configMap.put("car", config.entryTtl(Duration.ofMinutes(6L)));
59 configMap.put(RedisKeyConstants.cacheTaskProcessByMemberId, config.entryTtl(Duration.ofDays(1)));
60 // configMap.put(RedisKeyConstants.cacheTaskByEvent, config);
61
62 //需要先初始化缓存名称,再初始化其它的配置。
63 RedisCacheManager cacheManager = RedisCacheManager.builder(factory).
64 initialCacheNames(cacheNames).withInitialCacheConfigurations(configMap).build();
65 return cacheManager;
66 }
67 }
...@@ -23,35 +23,6 @@ public class MemberOperationServiceTest extends BaseTest { ...@@ -23,35 +23,6 @@ public class MemberOperationServiceTest extends BaseTest {
23 } 23 }
24 24
25 @Test 25 @Test
26 public void doUpdateMemberInfo() {
27 Member member = new Member();
28 member.setId(2L);
29 member.setCode(String.valueOf(IdWorker.generator()));
30 member.setType(1);
31 member.setStatus(1);
32 member.setNickname("nickname");
33 member.setDescription("description");
34 member.setGender(1);
35 member.setBirthday("birthday");
36 member.setAvatarUrl("avatarUrl");
37 member.setGroups("groups");
38 member.setTags("tags");
39 member.setVip(1);
40 member.setLevel(1);
41 member.setExp(10L);
42 member.setPoints(5L);
43 member.setDuePoints(0L);
44 member.setCouponAmount(1L);
45 member.setDueCouponAmount(0L);
46 member.setUserIptvId(1L);
47 member.setBindIptvPlatformType(0);
48 member.setUpdateTime(TimestampUtil.now());
49 String s = JSONObject.toJSONString(member);
50
51 this.memberOperationService.doUpdateMember(member);
52 }
53
54 @Test
55 public void doInsertMember() { 26 public void doInsertMember() {
56 Member member = new Member(); 27 Member member = new Member();
57 member.setCode(String.valueOf(IdWorker.generator())); 28 member.setCode(String.valueOf(IdWorker.generator()));
......