1.优化
Showing
13 changed files
with
129 additions
and
67 deletions
... | @@ -24,6 +24,9 @@ import java.time.LocalDateTime; | ... | @@ -24,6 +24,9 @@ import java.time.LocalDateTime; |
24 | @Table(name="m_coupon_history") | 24 | @Table(name="m_coupon_history") |
25 | public class CouponHistory implements Serializable { | 25 | public class CouponHistory implements Serializable { |
26 | 26 | ||
27 | @Transient | ||
28 | private String memberCode; | ||
29 | |||
27 | /** 主键 */ | 30 | /** 主键 */ |
28 | @Id | 31 | @Id |
29 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 32 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ... | ... |
... | @@ -23,6 +23,9 @@ import java.io.Serializable; | ... | @@ -23,6 +23,9 @@ import java.io.Serializable; |
23 | @Table(name="uc_exp_detail") | 23 | @Table(name="uc_exp_detail") |
24 | public class ExpDetail implements Serializable { | 24 | public class ExpDetail implements Serializable { |
25 | 25 | ||
26 | @Transient | ||
27 | private String memberCode; | ||
28 | |||
26 | /** 主键 */ | 29 | /** 主键 */ |
27 | @Id | 30 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ... | ... |
... | @@ -77,4 +77,18 @@ public interface MemberService { | ... | @@ -77,4 +77,18 @@ public interface MemberService { |
77 | * @param member 会员 | 77 | * @param member 会员 |
78 | */ | 78 | */ |
79 | MemberDTO checkMember(Member member); | 79 | MemberDTO checkMember(Member member); |
80 | |||
81 | /** | ||
82 | * | ||
83 | * @param resources | ||
84 | * @return | ||
85 | */ | ||
86 | MemberDTO doUpdateMemberExpAndLevel(Member resources); | ||
87 | |||
88 | /** | ||
89 | * | ||
90 | * @param member | ||
91 | * @return | ||
92 | */ | ||
93 | MemberDTO doUpdateMemberCoupon(Member member); | ||
80 | } | 94 | } | ... | ... |
... | @@ -117,6 +117,18 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -117,6 +117,18 @@ public class MemberServiceImpl implements MemberService { |
117 | } | 117 | } |
118 | 118 | ||
119 | @Override | 119 | @Override |
120 | public MemberDTO doUpdateMemberExpAndLevel(Member resources) { | ||
121 | MemberDTO memberDTO = this.update(resources); | ||
122 | return memberDTO; | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public MemberDTO doUpdateMemberCoupon(Member member) { | ||
127 | MemberDTO memberDTO = this.update(member); | ||
128 | return memberDTO; | ||
129 | } | ||
130 | |||
131 | @Override | ||
120 | @Transactional(rollbackFor = Exception.class) | 132 | @Transactional(rollbackFor = Exception.class) |
121 | public MemberDTO create(Member resources) { | 133 | public MemberDTO create(Member resources) { |
122 | 134 | ... | ... |
... | @@ -15,7 +15,7 @@ public interface ExpOperationService { | ... | @@ -15,7 +15,7 @@ public interface ExpOperationService { |
15 | * 任务完成后自动发放成长值 | 15 | * 任务完成后自动发放成长值 |
16 | * @param tempExpList | 16 | * @param tempExpList |
17 | */ | 17 | */ |
18 | void grantPointsThroughTempExp( List<TempExp> tempExpList); | 18 | void grantExpThroughTempExp( List<TempExp> tempExpList); |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * 系统手动发放优惠券 | 21 | * 系统手动发放优惠券 | ... | ... |
... | @@ -36,7 +36,7 @@ public interface PointsOperationService { | ... | @@ -36,7 +36,7 @@ public interface PointsOperationService { |
36 | * 积分发放,基于已获得的权益 | 36 | * 积分发放,基于已获得的权益 |
37 | * @param tempPointsList 已获得的权益 | 37 | * @param tempPointsList 已获得的权益 |
38 | */ | 38 | */ |
39 | void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList); | 39 | void grantPointsThroughTempPoint(List<TempPoints> tempPointsList); |
40 | 40 | ||
41 | 41 | ||
42 | /** | 42 | /** | ... | ... |
... | @@ -4,6 +4,7 @@ import com.topdraw.aspect.AsyncMqSend; | ... | @@ -4,6 +4,7 @@ import com.topdraw.aspect.AsyncMqSend; |
4 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; | 4 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
5 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; | 5 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; |
6 | import com.topdraw.business.module.coupon.service.CouponService; | 6 | import com.topdraw.business.module.coupon.service.CouponService; |
7 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; | ||
7 | import com.topdraw.business.module.member.domain.Member; | 8 | import com.topdraw.business.module.member.domain.Member; |
8 | import com.topdraw.business.module.member.service.MemberService; | 9 | import com.topdraw.business.module.member.service.MemberService; |
9 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 10 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
... | @@ -13,6 +14,7 @@ import com.topdraw.business.process.domian.TempCoupon; | ... | @@ -13,6 +14,7 @@ import com.topdraw.business.process.domian.TempCoupon; |
13 | import com.topdraw.business.process.service.RightsOperationService; | 14 | import com.topdraw.business.process.service.RightsOperationService; |
14 | import com.topdraw.util.TimestampUtil; | 15 | import com.topdraw.util.TimestampUtil; |
15 | import com.topdraw.utils.RedisUtils; | 16 | import com.topdraw.utils.RedisUtils; |
17 | import org.springframework.aop.framework.AopContext; | ||
16 | import org.springframework.beans.BeanUtils; | 18 | import org.springframework.beans.BeanUtils; |
17 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
18 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 20 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
... | @@ -46,8 +48,13 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -46,8 +48,13 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
46 | // 过期阀值(默认一个月) | 48 | // 过期阀值(默认一个月) |
47 | private static final Integer EXPIRE_FACTOR_DAY = 30; | 49 | private static final Integer EXPIRE_FACTOR_DAY = 30; |
48 | 50 | ||
49 | @Override | 51 | |
50 | @AsyncMqSend | 52 | @AsyncMqSend |
53 | public void asyncMemberCoupon(Member member) {} | ||
54 | @AsyncMqSend | ||
55 | public void asyncCouponHistory(CouponHistory couponHistory) {} | ||
56 | |||
57 | @Override | ||
51 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { | 58 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { |
52 | // 优惠券领取、使用历史记录表 | 59 | // 优惠券领取、使用历史记录表 |
53 | for (TempCoupon tempCoupon : tempCouponList) { | 60 | for (TempCoupon tempCoupon : tempCouponList) { |
... | @@ -131,7 +138,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -131,7 +138,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
131 | member.setCouponAmount(currentCoupon); | 138 | member.setCouponAmount(currentCoupon); |
132 | member.setDueCouponAmount(expireSoonCouponCount); | 139 | member.setDueCouponAmount(expireSoonCouponCount); |
133 | member.setUpdateTime(TimestampUtil.now()); | 140 | member.setUpdateTime(TimestampUtil.now()); |
134 | this.memberOperationService.doUpdateMember(member); | 141 | this.memberOperationService.doUpdateMemberCoupon(member); |
142 | |||
143 | ((CouponOperationServiceImpl) AopContext.currentProxy()).asyncMemberCoupon(member); | ||
135 | } | 144 | } |
136 | 145 | ||
137 | private MemberDTO findMemberByMemberId(Long memberId) { | 146 | private MemberDTO findMemberByMemberId(Long memberId) { |
... | @@ -194,11 +203,14 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -194,11 +203,14 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
194 | couponHistory.setCouponId(tempCoupon.getId()); | 203 | couponHistory.setCouponId(tempCoupon.getId()); |
195 | couponHistory.setUserId(tempCoupon.getMemberId()); | 204 | couponHistory.setUserId(tempCoupon.getMemberId()); |
196 | couponHistory.setCouponCode(tempCoupon.getCode()); | 205 | couponHistory.setCouponCode(tempCoupon.getCode()); |
206 | couponHistory.setMemberCode(tempCoupon.getMemberCode()); | ||
197 | couponHistory.setUserNickname(tempCoupon.getUserNickname()); | 207 | couponHistory.setUserNickname(tempCoupon.getUserNickname()); |
198 | couponHistory.setOrderDetailId(tempCoupon.getOrderId()); | 208 | couponHistory.setOrderDetailId(tempCoupon.getOrderId()); |
199 | couponHistory.setReceiveTime(LocalDateTime.now()); | 209 | couponHistory.setReceiveTime(LocalDateTime.now()); |
200 | couponHistory.setUseStatus(Objects.nonNull(couponHistory.getUseStatus()) ? couponHistory.getUseStatus():0); | 210 | couponHistory.setUseStatus(Objects.nonNull(couponHistory.getUseStatus()) ? couponHistory.getUseStatus():0); |
201 | this.couponHistoryService.create(couponHistory); | 211 | this.couponHistoryService.create(couponHistory); |
212 | |||
213 | ((CouponOperationServiceImpl) AopContext.currentProxy()).asyncCouponHistory(couponHistory); | ||
202 | } | 214 | } |
203 | 215 | ||
204 | 216 | ... | ... |
... | @@ -8,6 +8,8 @@ import com.topdraw.business.module.member.level.service.MemberLevelService; | ... | @@ -8,6 +8,8 @@ import com.topdraw.business.module.member.level.service.MemberLevelService; |
8 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; | 8 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; |
9 | import com.topdraw.business.module.member.service.MemberService; | 9 | import com.topdraw.business.module.member.service.MemberService; |
10 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 10 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
11 | import com.topdraw.business.module.points.available.domain.PointsAvailable; | ||
12 | import com.topdraw.business.module.points.detail.domain.PointsDetail; | ||
11 | import com.topdraw.business.process.service.ExpOperationService; | 13 | import com.topdraw.business.process.service.ExpOperationService; |
12 | import com.topdraw.business.process.service.member.MemberOperationService; | 14 | import com.topdraw.business.process.service.member.MemberOperationService; |
13 | import com.topdraw.business.process.domian.TempExp; | 15 | import com.topdraw.business.process.domian.TempExp; |
... | @@ -17,6 +19,7 @@ import com.topdraw.utils.RedisUtils; | ... | @@ -17,6 +19,7 @@ import com.topdraw.utils.RedisUtils; |
17 | import com.topdraw.utils.StringUtils; | 19 | import com.topdraw.utils.StringUtils; |
18 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
19 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
22 | import org.springframework.aop.framework.AopContext; | ||
20 | import org.springframework.beans.BeanUtils; | 23 | import org.springframework.beans.BeanUtils; |
21 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
22 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 25 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
... | @@ -33,8 +36,6 @@ import java.util.Objects; | ... | @@ -33,8 +36,6 @@ import java.util.Objects; |
33 | @Service | 36 | @Service |
34 | public class ExpOperationServiceImpl implements ExpOperationService { | 37 | public class ExpOperationServiceImpl implements ExpOperationService { |
35 | 38 | ||
36 | private static final Logger LOG = LoggerFactory.getLogger(ExpOperationServiceImpl.class); | ||
37 | |||
38 | @Autowired | 39 | @Autowired |
39 | ExpDetailService expDetailService; | 40 | ExpDetailService expDetailService; |
40 | @Autowired | 41 | @Autowired |
... | @@ -50,9 +51,13 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -50,9 +51,13 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
50 | @Autowired | 51 | @Autowired |
51 | private RedisUtils redisUtils; | 52 | private RedisUtils redisUtils; |
52 | 53 | ||
53 | @Override | ||
54 | @AsyncMqSend | 54 | @AsyncMqSend |
55 | public void grantPointsThroughTempExp(List<TempExp> tempExpList) { | 55 | public void asyncMemberExpAndLevel(Member member) {} |
56 | @AsyncMqSend | ||
57 | public void asyncExpDetail(ExpDetail expDetail) {} | ||
58 | |||
59 | @Override | ||
60 | public void grantExpThroughTempExp(List<TempExp> tempExpList) { | ||
56 | for (TempExp tempExp : tempExpList) { | 61 | for (TempExp tempExp : tempExpList) { |
57 | this.refresh(tempExp); | 62 | this.refresh(tempExp); |
58 | } | 63 | } |
... | @@ -86,7 +91,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -86,7 +91,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
86 | // 1.添加成长值记录 | 91 | // 1.添加成长值记录 |
87 | // this.threadPoolTaskExecutor.execute(() -> this.doInsertExpDetail(tempExp, originExp, totalExp)); | 92 | // this.threadPoolTaskExecutor.execute(() -> this.doInsertExpDetail(tempExp, originExp, totalExp)); |
88 | // 2.更新成长值与等级 | 93 | // 2.更新成长值与等级 |
89 | this.refreshMemberExpAndLevel(tempExp,totalExp); | 94 | this.refreshMemberExpAndLevel(tempExp, totalExp); |
90 | 95 | ||
91 | this.doInsertExpDetail(tempExp, originExp, totalExp); | 96 | this.doInsertExpDetail(tempExp, originExp, totalExp); |
92 | 97 | ||
... | @@ -98,7 +103,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -98,7 +103,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
98 | } | 103 | } |
99 | } | 104 | } |
100 | 105 | ||
101 | private long calculateTotalExp(long originalExp,TempExp tempExp) { | 106 | private long calculateTotalExp(long originalExp, TempExp tempExp) { |
102 | Long rewardExp = tempExp.getRewardExp(); | 107 | Long rewardExp = tempExp.getRewardExp(); |
103 | return rewardExp + originalExp; | 108 | return rewardExp + originalExp; |
104 | } | 109 | } |
... | @@ -146,12 +151,14 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -146,12 +151,14 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
146 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 151 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
147 | 152 | ||
148 | Member member = new Member(); | 153 | Member member = new Member(); |
149 | BeanUtils.copyProperties(memberDTO,member); | 154 | BeanUtils.copyProperties(memberDTO, member); |
150 | 155 | ||
151 | member.setExp(totalExp); | 156 | member.setExp(totalExp); |
152 | member.setLevel(level); | 157 | member.setLevel(level); |
153 | member.setUpdateTime(TimestampUtil.now()); | 158 | member.setUpdateTime(TimestampUtil.now()); |
154 | this.memberOperationService.doUpdateMember(member); | 159 | this.memberOperationService.doUpdateMemberExpAndLevel(member); |
160 | |||
161 | ((ExpOperationServiceImpl) AopContext.currentProxy()).asyncMemberExpAndLevel(member); | ||
155 | } | 162 | } |
156 | 163 | ||
157 | private MemberDTO findMemberByMemberId(Long memberId) { | 164 | private MemberDTO findMemberByMemberId(Long memberId) { |
... | @@ -212,6 +219,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -212,6 +219,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
212 | expDetail.setDescription("#"); | 219 | expDetail.setDescription("#"); |
213 | } | 220 | } |
214 | this.expDetailService.create(expDetail); | 221 | this.expDetailService.create(expDetail); |
222 | |||
223 | |||
224 | ((ExpOperationServiceImpl) AopContext.currentProxy()).asyncExpDetail(expDetail); | ||
215 | } | 225 | } |
216 | 226 | ||
217 | } | 227 | } | ... | ... |
... | @@ -12,6 +12,7 @@ import com.topdraw.business.module.points.detail.detailhistory.service.PointsDet | ... | @@ -12,6 +12,7 @@ import com.topdraw.business.module.points.detail.detailhistory.service.PointsDet |
12 | import com.topdraw.business.module.points.detail.domain.PointsDetail; | 12 | import com.topdraw.business.module.points.detail.domain.PointsDetail; |
13 | import com.topdraw.business.module.points.detail.service.PointsDetailService; | 13 | import com.topdraw.business.module.points.detail.service.PointsDetailService; |
14 | import com.topdraw.business.module.points.service.PointsService; | 14 | import com.topdraw.business.module.points.service.PointsService; |
15 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ||
15 | import com.topdraw.business.process.service.dto.CustomPointsResult; | 16 | import com.topdraw.business.process.service.dto.CustomPointsResult; |
16 | import com.topdraw.business.process.service.member.MemberOperationService; | 17 | import com.topdraw.business.process.service.member.MemberOperationService; |
17 | import com.topdraw.business.process.service.PointsOperationService; | 18 | import com.topdraw.business.process.service.PointsOperationService; |
... | @@ -23,6 +24,7 @@ import com.topdraw.utils.StringUtils; | ... | @@ -23,6 +24,7 @@ import com.topdraw.utils.StringUtils; |
23 | import lombok.extern.slf4j.Slf4j; | 24 | import lombok.extern.slf4j.Slf4j; |
24 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
25 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
27 | import org.springframework.aop.framework.AopContext; | ||
26 | import org.springframework.beans.BeanUtils; | 28 | import org.springframework.beans.BeanUtils; |
27 | import org.springframework.beans.factory.annotation.Autowired; | 29 | import org.springframework.beans.factory.annotation.Autowired; |
28 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 30 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
... | @@ -44,17 +46,17 @@ import java.util.stream.Collectors; | ... | @@ -44,17 +46,17 @@ import java.util.stream.Collectors; |
44 | public class PointsOperationServiceImpl implements PointsOperationService { | 46 | public class PointsOperationServiceImpl implements PointsOperationService { |
45 | 47 | ||
46 | @Autowired | 48 | @Autowired |
47 | PointsService pointsService; | 49 | private PointsService pointsService; |
48 | @Autowired | 50 | @Autowired |
49 | PointsDetailService pointsDetailService; | 51 | private PointsDetailService pointsDetailService; |
50 | @Autowired | 52 | @Autowired |
51 | PointsAvailableService pointsAvailableService; | 53 | private PointsAvailableService pointsAvailableService; |
52 | @Autowired | 54 | @Autowired |
53 | PointsDetailHistoryService pointsDetailHistoryService; | 55 | private PointsDetailHistoryService pointsDetailHistoryService; |
54 | @Autowired | 56 | @Autowired |
55 | MemberOperationService memberOperationService; | 57 | private MemberOperationService memberOperationService; |
56 | @Autowired | 58 | @Autowired |
57 | MemberService memberService; | 59 | private MemberService memberService; |
58 | 60 | ||
59 | @Autowired | 61 | @Autowired |
60 | private RedisUtils redisUtils; | 62 | private RedisUtils redisUtils; |
... | @@ -67,9 +69,16 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -67,9 +69,16 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
67 | private static final String DELETE_AVAILABLE_POINTS = "delete"; | 69 | private static final String DELETE_AVAILABLE_POINTS = "delete"; |
68 | private static final String INSERT_AVAILABLE_POINTS = "insert"; | 70 | private static final String INSERT_AVAILABLE_POINTS = "insert"; |
69 | 71 | ||
72 | @AsyncMqSend | ||
73 | public void asyncMemberPoint(Member member) {} | ||
74 | @AsyncMqSend | ||
75 | public void asyncPointsAvailable(PointsAvailable pointsAvailable) {} | ||
76 | @AsyncMqSend | ||
77 | public void asyncPointsDetail(PointsDetail pointsDetail) {} | ||
78 | |||
70 | @Override | 79 | @Override |
71 | @Transactional(rollbackFor = Exception.class) | 80 | @Transactional(rollbackFor = Exception.class) |
72 | public void grantPointsByManual(Long memberId,TempPoints tempPoints){ | 81 | public void grantPointsByManual(Long memberId, TempPoints tempPoints){ |
73 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { | 82 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { |
74 | MemberDTO memberDTo = this.memberService.findById(memberId); | 83 | MemberDTO memberDTo = this.memberService.findById(memberId); |
75 | String memberCode = memberDTo.getCode(); | 84 | String memberCode = memberDTo.getCode(); |
... | @@ -79,7 +88,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -79,7 +88,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
79 | } | 88 | } |
80 | 89 | ||
81 | @Override | 90 | @Override |
82 | @AsyncMqSend | ||
83 | public void grantPointsByManualByTempPoints(TempPoints tempPoints) { | 91 | public void grantPointsByManualByTempPoints(TempPoints tempPoints) { |
84 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { | 92 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { |
85 | this.refresh(tempPoints); | 93 | this.refresh(tempPoints); |
... | @@ -93,7 +101,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -93,7 +101,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
93 | */ | 101 | */ |
94 | @Override | 102 | @Override |
95 | @Transactional(rollbackFor = Exception.class) | 103 | @Transactional(rollbackFor = Exception.class) |
96 | @AsyncMqSend | ||
97 | public CustomPointsResult customPoints(TempPoints tempPoints) { | 104 | public CustomPointsResult customPoints(TempPoints tempPoints) { |
98 | 105 | ||
99 | CustomPointsResult customPointsResult = new CustomPointsResult(); | 106 | CustomPointsResult customPointsResult = new CustomPointsResult(); |
... | @@ -121,15 +128,17 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -121,15 +128,17 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
121 | // 5.即将过期的积分 | 128 | // 5.即将过期的积分 |
122 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 129 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
123 | // 6.更新会员积分信息 | 130 | // 6.更新会员积分信息 |
124 | this.freshMemberCurrentPoints(memberId, totalPoints,soonExpirePoints,tempPoints); | 131 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); |
125 | 132 | ||
126 | customPointsResult.setResult(true); | 133 | customPointsResult.setResult(true); |
127 | customPointsResult.setPoint(totalPoints); | 134 | customPointsResult.setPoint(totalPoints); |
128 | return customPointsResult; | 135 | return customPointsResult; |
136 | |||
129 | } else { | 137 | } else { |
130 | customPointsResult.setResult(false); | 138 | customPointsResult.setResult(false); |
131 | customPointsResult.setPoint(currentPoints); | 139 | customPointsResult.setPoint(currentPoints); |
132 | } | 140 | } |
141 | |||
133 | }catch (Exception e) { | 142 | }catch (Exception e) { |
134 | e.printStackTrace(); | 143 | e.printStackTrace(); |
135 | throw e; | 144 | throw e; |
... | @@ -145,7 +154,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -145,7 +154,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
145 | * @param customAvailablePointsMap | 154 | * @param customAvailablePointsMap |
146 | */ | 155 | */ |
147 | private long doFreshTrPointsAvailableByAvailablePointsMap( | 156 | private long doFreshTrPointsAvailableByAvailablePointsMap( |
148 | Map<String, List<PointsAvailableDTO>> customAvailablePointsMap,long currentPoints) { | 157 | Map<String, List<PointsAvailableDTO>> customAvailablePointsMap, long currentPoints) { |
149 | 158 | ||
150 | long totalCustomAvailablePoints = 0L; | 159 | long totalCustomAvailablePoints = 0L; |
151 | if (customAvailablePointsMap != null) { | 160 | if (customAvailablePointsMap != null) { |
... | @@ -290,8 +299,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -290,8 +299,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
290 | */ | 299 | */ |
291 | @Override | 300 | @Override |
292 | @Transactional(rollbackFor = Exception.class) | 301 | @Transactional(rollbackFor = Exception.class) |
293 | @AsyncMqSend() | 302 | public void grantPointsThroughTempPoint(List<TempPoints> tempPointsList){ |
294 | public void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList){ | ||
295 | log.info("------->>grantPointsThroughTempRightsList start1"); | 303 | log.info("------->>grantPointsThroughTempRightsList start1"); |
296 | for (TempPoints tempPoints : tempPointsList){ | 304 | for (TempPoints tempPoints : tempPointsList){ |
297 | log.info("------->>grantPointsThroughTempRightsList start"); | 305 | log.info("------->>grantPointsThroughTempRightsList start"); |
... | @@ -304,9 +312,12 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -304,9 +312,12 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
304 | * @param memberId | 312 | * @param memberId |
305 | */ | 313 | */ |
306 | private void cleanInvalidAvailablePointsByMemberId(Long memberId) { | 314 | private void cleanInvalidAvailablePointsByMemberId(Long memberId) { |
315 | |||
307 | List<PointsAvailableDTO> pointsAvailableDTOS = | 316 | List<PointsAvailableDTO> pointsAvailableDTOS = |
308 | pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId,LocalDateTime.now()); | 317 | pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId,LocalDateTime.now()); |
318 | |||
309 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS)) { | 319 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS)) { |
320 | |||
310 | //1.获取原始积分 | 321 | //1.获取原始积分 |
311 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS) { | 322 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS) { |
312 | // 添加积分明细 uc_points_detail | 323 | // 添加积分明细 uc_points_detail |
... | @@ -347,7 +358,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -347,7 +358,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
347 | * @param memberId | 358 | * @param memberId |
348 | * @param currentPoints | 359 | * @param currentPoints |
349 | */ | 360 | */ |
350 | private void doUpdateMemberPoints(Long memberId, long currentPoints,long soonExpirePoints) { | 361 | private void doUpdateMemberPoints(Long memberId, long currentPoints, long soonExpirePoints) { |
351 | Member member = new Member(); | 362 | Member member = new Member(); |
352 | member.setId(memberId); | 363 | member.setId(memberId); |
353 | member.setPoints(currentPoints); | 364 | member.setPoints(currentPoints); |
... | @@ -404,27 +415,27 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -404,27 +415,27 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
404 | this.redisUtils.doLock("member::id::" + memberId.toString()); | 415 | this.redisUtils.doLock("member::id::" + memberId.toString()); |
405 | // 1.可用总积分 | 416 | // 1.可用总积分 |
406 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); | 417 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); |
407 | log.info("----------->> 可用总积分 --->>>> " + currentPoints); | 418 | log.info("----------->> 可用总积分 --->>>> {}", currentPoints); |
408 | 419 | ||
409 | // 2.计算总积分 | 420 | // 2.计算总积分 |
410 | Long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); | 421 | Long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); |
411 | log.info("----------->> 总积分(可用总积分+获得的积分) --->>> " + totalPoints); | 422 | log.info("----------->> 总积分(可用总积分+获得的积分) --->>> {}", totalPoints); |
412 | 423 | ||
413 | // 3.添加积分明细 | 424 | // 3.添加积分明细 |
414 | this.doInsertTrPointsDetail(memberId, tempPoints, currentPoints, totalPoints); | 425 | this.doInsertTrPointsDetail(memberId, tempPoints, currentPoints, totalPoints); |
415 | log.info("----------->> 添加积分明细 "); | 426 | log.info("----------->> 添加积分明细 --->>> "); |
416 | 427 | ||
417 | // 4.添加可用积分 | 428 | // 4.添加可用积分 |
418 | this.doInsertTrPointsAvailable(tempPoints); | 429 | this.doInsertTrPointsAvailable(tempPoints); |
419 | log.info("----------->> 添加可用积分 "); | 430 | log.info("----------->> 添加可用积分 -->>> "); |
420 | 431 | ||
421 | // 5.即将过期的积分 | 432 | // 5.即将过期的积分 |
422 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 433 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
423 | log.info("----------->> 即将过期的积分 ------->>>>> " + soonExpirePoints); | 434 | log.info("----------->> 即将过期的积分 ------->>>>> {}", soonExpirePoints); |
424 | 435 | ||
425 | // 6.更新会员的总积分 | 436 | // 6.更新会员的总积分 |
426 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>>" + totalPoints); | 437 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>> {}", totalPoints); |
427 | this.freshMemberCurrentPoints(memberId, totalPoints,soonExpirePoints,tempPoints); | 438 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); |
428 | 439 | ||
429 | } catch (Exception e) { | 440 | } catch (Exception e) { |
430 | e.printStackTrace(); | 441 | e.printStackTrace(); |
... | @@ -453,7 +464,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -453,7 +464,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
453 | * @param memberId | 464 | * @param memberId |
454 | * @return | 465 | * @return |
455 | */ | 466 | */ |
456 | private long getSoonExpirePoints(Long memberId,TempPoints tempPoints) { | 467 | private long getSoonExpirePoints(Long memberId, TempPoints tempPoints) { |
457 | // 计算即将过期的天数 | 468 | // 计算即将过期的天数 |
458 | Integer factor = this.calculateExpireFactor(tempPoints); | 469 | Integer factor = this.calculateExpireFactor(tempPoints); |
459 | if (Objects.isNull(factor)) { | 470 | if (Objects.isNull(factor)) { |
... | @@ -479,7 +490,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -479,7 +490,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
479 | * @param memberId 会员Id | 490 | * @param memberId 会员Id |
480 | * @param currentPoints 当前总积分 | 491 | * @param currentPoints 当前总积分 |
481 | */ | 492 | */ |
482 | private void freshMemberCurrentPoints(Long memberId, Long currentPoints,long duePoints,TempPoints tempPoints) { | 493 | private void freshMemberCurrentPoints(Long memberId, Long currentPoints, long duePoints) { |
483 | 494 | ||
484 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 495 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
485 | 496 | ||
... | @@ -491,6 +502,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -491,6 +502,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
491 | member.setUpdateTime(TimestampUtil.now()); | 502 | member.setUpdateTime(TimestampUtil.now()); |
492 | try { | 503 | try { |
493 | this.memberOperationService.doUpdateMemberPoints(member); | 504 | this.memberOperationService.doUpdateMemberPoints(member); |
505 | |||
506 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncMemberPoint(member); | ||
494 | } catch (Exception e){ | 507 | } catch (Exception e){ |
495 | throw e; | 508 | throw e; |
496 | } | 509 | } |
... | @@ -520,6 +533,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -520,6 +533,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
520 | 533 | ||
521 | this.pointsAvailableService.create4Custom(pointsAvailable); | 534 | this.pointsAvailableService.create4Custom(pointsAvailable); |
522 | 535 | ||
536 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncPointsAvailable(pointsAvailable); | ||
523 | } | 537 | } |
524 | 538 | ||
525 | /** | 539 | /** |
... | @@ -528,7 +542,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -528,7 +542,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
528 | * @param tempPoints 积分 | 542 | * @param tempPoints 积分 |
529 | * @return Integer 总积分 | 543 | * @return Integer 总积分 |
530 | */ | 544 | */ |
531 | private void doInsertTrPointsDetail(Long memberId, TempPoints tempPoints,Long currentPoints,Long totalPoints){ | 545 | private void doInsertTrPointsDetail(Long memberId, TempPoints tempPoints, Long currentPoints, Long totalPoints){ |
532 | 546 | ||
533 | PointsDetail pointsDetail = new PointsDetail(); | 547 | PointsDetail pointsDetail = new PointsDetail(); |
534 | BeanUtils.copyProperties(tempPoints,pointsDetail); | 548 | BeanUtils.copyProperties(tempPoints,pointsDetail); |
... | @@ -549,6 +563,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -549,6 +563,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
549 | // 保存积分流水 | 563 | // 保存积分流水 |
550 | this.pointsDetailService.create4Custom(pointsDetail); | 564 | this.pointsDetailService.create4Custom(pointsDetail); |
551 | 565 | ||
566 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncPointsDetail(pointsDetail); | ||
552 | } | 567 | } |
553 | 568 | ||
554 | } | 569 | } | ... | ... |
... | @@ -37,22 +37,17 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -37,22 +37,17 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
37 | private static final Logger LOG = LoggerFactory.getLogger(RightsOperationServiceImpl.class); | 37 | private static final Logger LOG = LoggerFactory.getLogger(RightsOperationServiceImpl.class); |
38 | 38 | ||
39 | @Autowired | 39 | @Autowired |
40 | RightsHistoryService rightsHistoryService; | 40 | private RightsHistoryService rightsHistoryService; |
41 | @Autowired | 41 | @Autowired |
42 | CouponOperationService couponOperationService; | 42 | private CouponOperationService couponOperationService; |
43 | @Autowired | 43 | @Autowired |
44 | RightsService rightsService; | 44 | private RightsService rightsService; |
45 | @Autowired | 45 | @Autowired |
46 | ExpOperationService expOperationService; | 46 | private ExpOperationService expOperationService; |
47 | @Autowired | 47 | @Autowired |
48 | PointsOperationService pointsOperationService; | 48 | private PointsOperationService pointsOperationService; |
49 | @Autowired | 49 | @Autowired |
50 | CouponService couponService; | 50 | private CouponService couponService; |
51 | |||
52 | // @Autowired | ||
53 | // ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
54 | |||
55 | private ExecutorService threadPoolTaskExecutor = Executors.newFixedThreadPool(10); | ||
56 | 51 | ||
57 | /** | 52 | /** |
58 | * 系统手动发放 | 53 | * 系统手动发放 |
... | @@ -117,7 +112,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -117,7 +112,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
117 | */ | 112 | */ |
118 | private void grantExp(List<TempExp> tempExpList) { | 113 | private void grantExp(List<TempExp> tempExpList) { |
119 | if (!CollectionUtils.isEmpty(tempExpList)) | 114 | if (!CollectionUtils.isEmpty(tempExpList)) |
120 | this.expOperationService.grantPointsThroughTempExp(tempExpList); | 115 | this.expOperationService.grantExpThroughTempExp(tempExpList); |
121 | } | 116 | } |
122 | 117 | ||
123 | /** | 118 | /** |
... | @@ -127,7 +122,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -127,7 +122,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
127 | */ | 122 | */ |
128 | private void grantPoint(List<TempPoints> tempPointsList) { | 123 | private void grantPoint(List<TempPoints> tempPointsList) { |
129 | if (!CollectionUtils.isEmpty(tempPointsList)) | 124 | if (!CollectionUtils.isEmpty(tempPointsList)) |
130 | this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList); | 125 | this.pointsOperationService.grantPointsThroughTempPoint(tempPointsList); |
131 | } | 126 | } |
132 | 127 | ||
133 | /** | 128 | /** | ... | ... |
... | @@ -64,27 +64,25 @@ import static java.util.stream.Collectors.toList; | ... | @@ -64,27 +64,25 @@ import static java.util.stream.Collectors.toList; |
64 | public class TaskOperationServiceImpl implements TaskOperationService { | 64 | public class TaskOperationServiceImpl implements TaskOperationService { |
65 | 65 | ||
66 | @Autowired | 66 | @Autowired |
67 | TaskService taskService; | 67 | private TaskService taskService; |
68 | @Autowired | 68 | @Autowired |
69 | MemberService memberService; | 69 | private MemberService memberService; |
70 | @Autowired | 70 | @Autowired |
71 | RightsService rightsService; | 71 | private RightsService rightsService; |
72 | @Autowired | 72 | @Autowired |
73 | TaskTemplateService taskTemplateService; | 73 | private TaskTemplateService taskTemplateService; |
74 | @Autowired | 74 | @Autowired |
75 | RightsOperationService rightsOperationService; | 75 | private RightsOperationService rightsOperationService; |
76 | @Autowired | 76 | @Autowired |
77 | TrTaskProgressService trTaskProgressService; | 77 | private TrTaskProgressService trTaskProgressService; |
78 | @Autowired | 78 | @Autowired |
79 | PermanentRightsService permanentRightsService; | 79 | private CouponService couponService; |
80 | @Autowired | 80 | @Autowired |
81 | CouponService couponService; | 81 | private MemberGroupService memberGroupService; |
82 | @Autowired | 82 | @Autowired |
83 | MemberGroupService memberGroupService; | 83 | private TaskAttrService taskAttrService; |
84 | @Autowired | 84 | @Autowired |
85 | TaskAttrService taskAttrService; | 85 | private UserTvService userTvService; |
86 | @Autowired | ||
87 | UserTvService userTvService; | ||
88 | 86 | ||
89 | 87 | ||
90 | private static final Integer TASK_FINISH_STATUS = 1; | 88 | private static final Integer TASK_FINISH_STATUS = 1; | ... | ... |
... | @@ -45,7 +45,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -45,7 +45,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
45 | @Autowired | 45 | @Autowired |
46 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; | 46 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
47 | 47 | ||
48 | @CachePut(key = "#resources.memberId") | 48 | // @CachePut(key = "#resources.memberId") |
49 | @Override | 49 | @Override |
50 | public MemberDTO buyVip(BuyVipBean resources) { | 50 | public MemberDTO buyVip(BuyVipBean resources) { |
51 | // 小程序账户id | 51 | // 小程序账户id |
... | @@ -134,7 +134,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -134,7 +134,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
134 | return this.update(resources); | 134 | return this.update(resources); |
135 | } | 135 | } |
136 | 136 | ||
137 | @CachePut(key = "#resources.id") | 137 | // @CachePut(key = "#resources.id") |
138 | @Override | 138 | @Override |
139 | public MemberDTO doInsertMember(Member resources) { | 139 | public MemberDTO doInsertMember(Member resources) { |
140 | return this.memberService.create(resources); | 140 | return this.memberService.create(resources); |
... | @@ -148,8 +148,8 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -148,8 +148,8 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
148 | 148 | ||
149 | // @CachePut(key = "#resources.id") | 149 | // @CachePut(key = "#resources.id") |
150 | @Override | 150 | @Override |
151 | public MemberDTO doUpdateMemberExp(Member resources) { | 151 | public MemberDTO doUpdateMemberExpAndLevel(Member resources) { |
152 | return this.update(resources); | 152 | return this.memberService.doUpdateMemberExpAndLevel(resources); |
153 | } | 153 | } |
154 | 154 | ||
155 | // @CachePut(key = "#resources.id") | 155 | // @CachePut(key = "#resources.id") |
... | @@ -161,7 +161,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -161,7 +161,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
161 | // @CachePut(key = "#resources.id") | 161 | // @CachePut(key = "#resources.id") |
162 | @Override | 162 | @Override |
163 | public MemberDTO doUpdateMemberCoupon(Member member) { | 163 | public MemberDTO doUpdateMemberCoupon(Member member) { |
164 | return this.update(member); | 164 | return this.memberService.doUpdateMemberCoupon(member); |
165 | } | 165 | } |
166 | 166 | ||
167 | @Override | 167 | @Override | ... | ... |
... | @@ -65,7 +65,7 @@ public interface MemberOperationService { | ... | @@ -65,7 +65,7 @@ public interface MemberOperationService { |
65 | * | 65 | * |
66 | * @param resources | 66 | * @param resources |
67 | */ | 67 | */ |
68 | MemberDTO doUpdateMemberExp(Member resources); | 68 | MemberDTO doUpdateMemberExpAndLevel(Member resources); |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * | 71 | * | ... | ... |
-
Please register or sign in to post a comment