Commit 9db5a924 9db5a924fe17d2da9fa53110a3290ae50a730e1f by xianghan@topdraw.cn

Merge branch 'release/1.0.1'

2 parents 11227f2b b2cf3020
Showing 31 changed files with 291 additions and 134 deletions
...@@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
6 import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; 6 import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
7 import org.springframework.boot.builder.SpringApplicationBuilder; 7 import org.springframework.boot.builder.SpringApplicationBuilder;
8 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 8 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
9 import org.springframework.cache.annotation.EnableCaching;
9 import org.springframework.context.annotation.Bean; 10 import org.springframework.context.annotation.Bean;
10 import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 11 import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
11 import org.springframework.retry.annotation.EnableRetry; 12 import org.springframework.retry.annotation.EnableRetry;
...@@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
21 @SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) 22 @SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
22 @EnableTransactionManagement 23 @EnableTransactionManagement
23 @EnableRetry 24 @EnableRetry
25 @EnableCaching
24 public class MemberServiceApplication extends SpringBootServletInitializer { 26 public class MemberServiceApplication extends SpringBootServletInitializer {
25 27
26 public static void main(String[] args) { 28 public static void main(String[] args) {
......
...@@ -73,7 +73,7 @@ public class AsyncMqProducer { ...@@ -73,7 +73,7 @@ public class AsyncMqProducer {
73 boolean async = asyncMqSend.async(); 73 boolean async = asyncMqSend.async();
74 if (async) { 74 if (async) {
75 // 异步 75 // 异步
76 this.sendMqMessage(tableOperationMsg); 76 this.threadPoolTaskExecutor.execute(()->this.sendMqMessage(tableOperationMsg));
77 } else { 77 } else {
78 // 同步 78 // 同步
79 this.sendMqMessage(tableOperationMsg); 79 this.sendMqMessage(tableOperationMsg);
......
...@@ -40,7 +40,7 @@ public class CouponHistoryController { ...@@ -40,7 +40,7 @@ public class CouponHistoryController {
40 } 40 }
41 41
42 @Log 42 @Log
43 @PostMapping 43 @PostMapping(value = "/create")
44 @ApiOperation("新增CouponHistory") 44 @ApiOperation("新增CouponHistory")
45 public ResultInfo create(@Validated @RequestBody CouponHistory resources) { 45 public ResultInfo create(@Validated @RequestBody CouponHistory resources) {
46 CouponHistoryService.create(resources); 46 CouponHistoryService.create(resources);
...@@ -48,7 +48,7 @@ public class CouponHistoryController { ...@@ -48,7 +48,7 @@ public class CouponHistoryController {
48 } 48 }
49 49
50 @Log 50 @Log
51 @PutMapping 51 @PutMapping(value = "/update")
52 @ApiOperation("修改CouponHistory") 52 @ApiOperation("修改CouponHistory")
53 public ResultInfo update(@Validated @RequestBody CouponHistory resources) { 53 public ResultInfo update(@Validated @RequestBody CouponHistory resources) {
54 CouponHistoryService.update(resources); 54 CouponHistoryService.update(resources);
...@@ -57,7 +57,7 @@ public class CouponHistoryController { ...@@ -57,7 +57,7 @@ public class CouponHistoryController {
57 57
58 58
59 @Log 59 @Log
60 @DeleteMapping(value = "/{id}") 60 @DeleteMapping(value = "/delete/{id}")
61 @ApiOperation("删除CouponHistory") 61 @ApiOperation("删除CouponHistory")
62 public ResultInfo delete(@PathVariable Long id) { 62 public ResultInfo delete(@PathVariable Long id) {
63 CouponHistoryService.delete(id); 63 CouponHistoryService.delete(id);
......
...@@ -36,7 +36,7 @@ public class CouponController { ...@@ -36,7 +36,7 @@ public class CouponController {
36 } 36 }
37 37
38 @Log 38 @Log
39 @PostMapping 39 @PostMapping(value = "/create")
40 @ApiOperation("新增Coupon") 40 @ApiOperation("新增Coupon")
41 public ResultInfo create(@Validated @RequestBody Coupon resources) { 41 public ResultInfo create(@Validated @RequestBody Coupon resources) {
42 CouponService.create(resources); 42 CouponService.create(resources);
...@@ -44,7 +44,7 @@ public class CouponController { ...@@ -44,7 +44,7 @@ public class CouponController {
44 } 44 }
45 45
46 @Log 46 @Log
47 @PutMapping 47 @PutMapping(value = "/update")
48 @ApiOperation("修改Coupon") 48 @ApiOperation("修改Coupon")
49 public ResultInfo update(@Validated @RequestBody Coupon resources) { 49 public ResultInfo update(@Validated @RequestBody Coupon resources) {
50 CouponService.update(resources); 50 CouponService.update(resources);
...@@ -53,7 +53,7 @@ public class CouponController { ...@@ -53,7 +53,7 @@ public class CouponController {
53 53
54 54
55 @Log 55 @Log
56 @DeleteMapping(value = "/{id}") 56 @DeleteMapping(value = "/delete/{id}")
57 @ApiOperation("删除Coupon") 57 @ApiOperation("删除Coupon")
58 public ResultInfo delete(@PathVariable Long id) { 58 public ResultInfo delete(@PathVariable Long id) {
59 CouponService.delete(id); 59 CouponService.delete(id);
......
...@@ -36,7 +36,7 @@ public class ExpDetailController { ...@@ -36,7 +36,7 @@ public class ExpDetailController {
36 } 36 }
37 37
38 @Log 38 @Log
39 @PostMapping 39 @PostMapping(value = "/create")
40 @ApiOperation("新增ExpDetail") 40 @ApiOperation("新增ExpDetail")
41 public ResultInfo create(@Validated @RequestBody ExpDetail resources) { 41 public ResultInfo create(@Validated @RequestBody ExpDetail resources) {
42 ExpDetailService.create(resources); 42 ExpDetailService.create(resources);
...@@ -44,7 +44,7 @@ public class ExpDetailController { ...@@ -44,7 +44,7 @@ public class ExpDetailController {
44 } 44 }
45 45
46 @Log 46 @Log
47 @PutMapping 47 @PutMapping(value = "/update")
48 @ApiOperation("修改ExpDetail") 48 @ApiOperation("修改ExpDetail")
49 public ResultInfo update(@Validated @RequestBody ExpDetail resources) { 49 public ResultInfo update(@Validated @RequestBody ExpDetail resources) {
50 ExpDetailService.update(resources); 50 ExpDetailService.update(resources);
...@@ -53,7 +53,7 @@ public class ExpDetailController { ...@@ -53,7 +53,7 @@ public class ExpDetailController {
53 53
54 54
55 @Log 55 @Log
56 @DeleteMapping(value = "/{id}") 56 @DeleteMapping(value = "/delete/{id}")
57 @ApiOperation("删除ExpDetail") 57 @ApiOperation("删除ExpDetail")
58 public ResultInfo delete(@PathVariable Long id) { 58 public ResultInfo delete(@PathVariable Long id) {
59 ExpDetailService.delete(id); 59 ExpDetailService.delete(id);
......
...@@ -35,31 +35,6 @@ public class ExpHistoryController { ...@@ -35,31 +35,6 @@ public class ExpHistoryController {
35 return ResultInfo.success(ExpHistoryService.queryAll(criteria)); 35 return ResultInfo.success(ExpHistoryService.queryAll(criteria));
36 } 36 }
37 37
38 @Log
39 @PostMapping
40 @ApiOperation("新增ExpHistory")
41 public ResultInfo create(@Validated @RequestBody ExpHistory resources) {
42 ExpHistoryService.create(resources);
43 return ResultInfo.success();
44 }
45
46 @Log
47 @PutMapping
48 @ApiOperation("修改ExpHistory")
49 public ResultInfo update(@Validated @RequestBody ExpHistory resources) {
50 ExpHistoryService.update(resources);
51 return ResultInfo.success();
52 }
53
54
55 @Log
56 @DeleteMapping(value = "/{id}")
57 @ApiOperation("删除ExpHistory")
58 public ResultInfo delete(@PathVariable Long id) {
59 ExpHistoryService.delete(id);
60 return ResultInfo.success();
61 }
62
63 @GetMapping(value = "/getByCode/{code}") 38 @GetMapping(value = "/getByCode/{code}")
64 @ApiOperation(value = "根据标识查询") 39 @ApiOperation(value = "根据标识查询")
65 public ResultInfo getByCode(@PathVariable String code) { 40 public ResultInfo getByCode(@PathVariable String code) {
......
...@@ -120,8 +120,8 @@ public class Member implements Serializable { ...@@ -120,8 +120,8 @@ public class Member implements Serializable {
120 private Timestamp updateTime; 120 private Timestamp updateTime;
121 121
122 // 是否在黑名单 1:是;0否 122 // 是否在黑名单 1:是;0否
123 // @Column(name = "black_status") 123 @Column(name = "black_status")
124 // private Integer blackStatus; 124 private Integer blackStatus;
125 125
126 public void copy(Member source){ 126 public void copy(Member source){
127 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); 127 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
......
...@@ -35,8 +35,8 @@ public class MemberLevelController { ...@@ -35,8 +35,8 @@ public class MemberLevelController {
35 return ResultInfo.success(MemberLevelService.queryAll(criteria)); 35 return ResultInfo.success(MemberLevelService.queryAll(criteria));
36 } 36 }
37 37
38 @Log 38 /*@Log
39 @PostMapping 39 @PostMapping(value = "/create")
40 @ApiOperation("新增MemberLevel") 40 @ApiOperation("新增MemberLevel")
41 public ResultInfo create(@Validated @RequestBody MemberLevel resources) { 41 public ResultInfo create(@Validated @RequestBody MemberLevel resources) {
42 MemberLevelService.create(resources); 42 MemberLevelService.create(resources);
...@@ -44,7 +44,7 @@ public class MemberLevelController { ...@@ -44,7 +44,7 @@ public class MemberLevelController {
44 } 44 }
45 45
46 @Log 46 @Log
47 @PutMapping 47 @PutMapping(value = "/update")
48 @ApiOperation("修改MemberLevel") 48 @ApiOperation("修改MemberLevel")
49 public ResultInfo update(@Validated @RequestBody MemberLevel resources) { 49 public ResultInfo update(@Validated @RequestBody MemberLevel resources) {
50 MemberLevelService.update(resources); 50 MemberLevelService.update(resources);
...@@ -53,12 +53,12 @@ public class MemberLevelController { ...@@ -53,12 +53,12 @@ public class MemberLevelController {
53 53
54 54
55 @Log 55 @Log
56 @DeleteMapping(value = "/{id}") 56 @DeleteMapping(value = "/delete/{id}")
57 @ApiOperation("删除MemberLevel") 57 @ApiOperation("删除MemberLevel")
58 public ResultInfo delete(@PathVariable Long id) { 58 public ResultInfo delete(@PathVariable Long id) {
59 MemberLevelService.delete(id); 59 MemberLevelService.delete(id);
60 return ResultInfo.success(); 60 return ResultInfo.success();
61 } 61 }*/
62 62
63 @GetMapping(value = "/getByCode/{code}") 63 @GetMapping(value = "/getByCode/{code}")
64 @ApiOperation(value = "根据标识查询") 64 @ApiOperation(value = "根据标识查询")
......
...@@ -53,6 +53,10 @@ public class MemberProfile implements Serializable { ...@@ -53,6 +53,10 @@ public class MemberProfile implements Serializable {
53 @Column(name = "birthday", nullable = false) 53 @Column(name = "birthday", nullable = false)
54 private Timestamp birthday; 54 private Timestamp birthday;
55 55
56 // 手机号
57 @Column(name = "phone")
58 private String phone;
59
56 // 星座 60 // 星座
57 @Column(name = "constellation") 61 @Column(name = "constellation")
58 private String constellation; 62 private String constellation;
......
...@@ -36,7 +36,7 @@ public class MemberProfileController { ...@@ -36,7 +36,7 @@ public class MemberProfileController {
36 }*/ 36 }*/
37 37
38 @Log 38 @Log
39 @PostMapping 39 @PostMapping(value = "/create")
40 @ApiOperation("新增MemberProfile") 40 @ApiOperation("新增MemberProfile")
41 public ResultInfo create(@Validated @RequestBody MemberProfile resources) { 41 public ResultInfo create(@Validated @RequestBody MemberProfile resources) {
42 MemberProfileService.create(resources); 42 MemberProfileService.create(resources);
...@@ -44,7 +44,7 @@ public class MemberProfileController { ...@@ -44,7 +44,7 @@ public class MemberProfileController {
44 } 44 }
45 45
46 @Log 46 @Log
47 @PutMapping 47 @PutMapping(value = "/update")
48 @ApiOperation("修改MemberProfile") 48 @ApiOperation("修改MemberProfile")
49 public ResultInfo update(@Validated @RequestBody MemberProfile resources) { 49 public ResultInfo update(@Validated @RequestBody MemberProfile resources) {
50 MemberProfileService.update(resources); 50 MemberProfileService.update(resources);
...@@ -53,7 +53,7 @@ public class MemberProfileController { ...@@ -53,7 +53,7 @@ public class MemberProfileController {
53 53
54 54
55 @Log 55 @Log
56 @DeleteMapping(value = "/{id}") 56 @DeleteMapping(value = "/delete/{id}")
57 @ApiOperation("删除MemberProfile") 57 @ApiOperation("删除MemberProfile")
58 public ResultInfo delete(@PathVariable Long id) { 58 public ResultInfo delete(@PathVariable Long id) {
59 MemberProfileService.delete(id); 59 MemberProfileService.delete(id);
......
...@@ -33,6 +33,9 @@ public class MemberProfileDTO implements Serializable { ...@@ -33,6 +33,9 @@ public class MemberProfileDTO implements Serializable {
33 // 身份证 33 // 身份证
34 private String idCard; 34 private String idCard;
35 35
36 // 电话
37 private String phone;
38
36 // 电子邮件 39 // 电子邮件
37 private String email; 40 private String email;
38 41
......
...@@ -53,7 +53,7 @@ public class MemberRelatedInfoController { ...@@ -53,7 +53,7 @@ public class MemberRelatedInfoController {
53 } 53 }
54 54
55 @Log 55 @Log
56 @DeleteMapping(value = "/delete//{id}") 56 @DeleteMapping(value = "/delete/{id}")
57 @ApiOperation("删除MemberRelatedInfo") 57 @ApiOperation("删除MemberRelatedInfo")
58 public ResultInfo delete(@PathVariable Long id) { 58 public ResultInfo delete(@PathVariable Long id) {
59 MemberRelatedInfoService.delete(id); 59 MemberRelatedInfoService.delete(id);
......
...@@ -50,7 +50,7 @@ public class MemberController { ...@@ -50,7 +50,7 @@ public class MemberController {
50 @ApiOperation("修改Member等级") 50 @ApiOperation("修改Member等级")
51 public ResultInfo doUpdateVip(Long memberId , Integer vip) { 51 public ResultInfo doUpdateVip(Long memberId , Integer vip) {
52 Assert.isNull(memberId,"MemberController -->> doUpdateVip -->>【memberId】 not be null!!"); 52 Assert.isNull(memberId,"MemberController -->> doUpdateVip -->>【memberId】 not be null!!");
53 Assert.isNull(vip,"MemberController -->> doUpdateVip -->>【memberId】 not be null!!"); 53 Assert.isNull(vip,"MemberController -->> doUpdateVip -->>【vip】 not be null!!");
54 Member member = new Member(); 54 Member member = new Member();
55 member.setId(memberId); 55 member.setId(memberId);
56 member.setVip(vip); 56 member.setVip(vip);
......
...@@ -83,5 +83,5 @@ public class MemberDTO implements Serializable { ...@@ -83,5 +83,5 @@ public class MemberDTO implements Serializable {
83 private Timestamp updateTime; 83 private Timestamp updateTime;
84 84
85 // 是否在黑名单 1:是;0否 85 // 是否在黑名单 1:是;0否
86 // private Integer blackStatus; 86 private Integer blackStatus;
87 } 87 }
......
...@@ -19,6 +19,7 @@ import org.redisson.api.RLock; ...@@ -19,6 +19,7 @@ import org.redisson.api.RLock;
19 import org.redisson.api.RedissonClient; 19 import org.redisson.api.RedissonClient;
20 import org.springframework.beans.BeanUtils; 20 import org.springframework.beans.BeanUtils;
21 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.cache.annotation.Cacheable;
22 import org.springframework.dao.EmptyResultDataAccessException; 23 import org.springframework.dao.EmptyResultDataAccessException;
23 import org.springframework.data.domain.Page; 24 import org.springframework.data.domain.Page;
24 import org.springframework.data.domain.Pageable; 25 import org.springframework.data.domain.Pageable;
...@@ -60,6 +61,7 @@ public class MemberServiceImpl implements MemberService { ...@@ -60,6 +61,7 @@ public class MemberServiceImpl implements MemberService {
60 return memberMapper.toDto(memberRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); 61 return memberMapper.toDto(memberRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
61 } 62 }
62 63
64 // @Cacheable(cacheNames = "",key = "")
63 @Override 65 @Override
64 public MemberDTO findById(Long id) { 66 public MemberDTO findById(Long id) {
65 Member member = memberRepository.findById(id).orElseGet(Member::new); 67 Member member = memberRepository.findById(id).orElseGet(Member::new);
......
...@@ -30,7 +30,7 @@ public class Points implements Serializable { ...@@ -30,7 +30,7 @@ public class Points implements Serializable {
30 @Column(name = "user_id") 30 @Column(name = "user_id")
31 private Long userId; 31 private Long userId;
32 32
33 // 积分类型,通用,绑定, 区分大小屏 todo 33 // 积分类型,通用,绑定, 区分大小屏
34 @Column(name = "point_type") 34 @Column(name = "point_type")
35 private Integer pointType; 35 private Integer pointType;
36 36
......
...@@ -15,4 +15,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long ...@@ -15,4 +15,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long
15 Optional<TaskTemplate> findFirstByCode(String code); 15 Optional<TaskTemplate> findFirstByCode(String code);
16 16
17 TaskTemplate findByEvent(String event); 17 TaskTemplate findByEvent(String event);
18
19 TaskTemplate findByType(Integer event);
18 } 20 }
......
...@@ -49,4 +49,6 @@ public interface TaskTemplateService { ...@@ -49,4 +49,6 @@ public interface TaskTemplateService {
49 TaskTemplateDTO getByCode(String code); 49 TaskTemplateDTO getByCode(String code);
50 50
51 TaskTemplate findByEvent(String event); 51 TaskTemplate findByEvent(String event);
52
53 TaskTemplate findByType(Integer event);
52 } 54 }
......
...@@ -8,6 +8,7 @@ import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO; ...@@ -8,6 +8,7 @@ import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO;
8 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria; 8 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria;
9 import com.topdraw.business.basicdata.task.template.service.mapper.TaskTemplateMapper; 9 import com.topdraw.business.basicdata.task.template.service.mapper.TaskTemplateMapper;
10 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.cache.annotation.Cacheable;
11 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
12 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
13 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
...@@ -21,6 +22,7 @@ import com.topdraw.utils.StringUtils; ...@@ -21,6 +22,7 @@ import com.topdraw.utils.StringUtils;
21 22
22 import java.util.List; 23 import java.util.List;
23 import java.util.Map; 24 import java.util.Map;
25 import java.util.Objects;
24 26
25 /** 27 /**
26 * @author XiangHan 28 * @author XiangHan
...@@ -85,8 +87,14 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { ...@@ -85,8 +87,14 @@ public class TaskTemplateServiceImpl implements TaskTemplateService {
85 : new TaskTemplateDTO(); 87 : new TaskTemplateDTO();
86 } 88 }
87 89
90 // @Cacheable(cacheNames = "uc.taskTemplate" , key = "event")
88 @Override 91 @Override
89 public TaskTemplate findByEvent(String event) { 92 public TaskTemplate findByEvent(String event) {
90 return StringUtils.isNotEmpty(event) ? this.TaskTemplateRepository.findByEvent(event) : null; 93 return StringUtils.isNotEmpty(event) ? this.TaskTemplateRepository.findByEvent(event) : null;
91 } 94 }
95
96 @Override
97 public TaskTemplate findByType(Integer event) {
98 return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null;
99 }
92 } 100 }
......
...@@ -38,4 +38,9 @@ public interface PointsOperationService { ...@@ -38,4 +38,9 @@ public interface PointsOperationService {
38 * 清理过期的积分 38 * 清理过期的积分
39 */ 39 */
40 void cleanInvalidAvailablePoints(); 40 void cleanInvalidAvailablePoints();
41
42 /**
43 * 清理过期的积分
44 */
45 void cleanInvalidAvailablePointsByMemberId(Long memberId);
41 } 46 }
......
1 package com.topdraw.business.process.service.builder;
2
3 import com.topdraw.business.process.domian.TempCoupon;
4
5 public class TempCouponBuilder {
6
7
8
9 public TempCoupon build(){
10 TempCoupon tempCoupon = new TempCoupon();
11
12 return tempCoupon;
13 }
14
15 }
...@@ -16,6 +16,7 @@ import org.slf4j.Logger; ...@@ -16,6 +16,7 @@ import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory; 16 import org.slf4j.LoggerFactory;
17 import org.springframework.beans.BeanUtils; 17 import org.springframework.beans.BeanUtils;
18 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
19 import org.springframework.stereotype.Service; 20 import org.springframework.stereotype.Service;
20 21
21 import java.sql.Timestamp; 22 import java.sql.Timestamp;
...@@ -40,11 +41,13 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -40,11 +41,13 @@ public class CouponOperationServiceImpl implements CouponOperationService {
40 RightsOperationService rightsOperationService; 41 RightsOperationService rightsOperationService;
41 @Autowired 42 @Autowired
42 RedissonClient redissonClient; 43 RedissonClient redissonClient;
44 @Autowired
45 ThreadPoolTaskExecutor threadPoolTaskExecutor;
43 46
44 // 过期阀值(默认一个月) 47 // 过期阀值(默认一个月)
45 private static final Integer EXPIRE_FACTOR_MONTH = 1; 48 private static final Integer EXPIRE_FACTOR_MONTH = 1;
46 49
47 private ReentrantLock reentrantLock = new ReentrantLock(true); 50
48 51
49 @Override 52 @Override
50 public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { 53 public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) {
...@@ -78,7 +81,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -78,7 +81,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
78 */ 81 */
79 private void refresh(TempCoupon tempCoupon) { 82 private void refresh(TempCoupon tempCoupon) {
80 // 1.保存优惠券领取、使用历史记录表 83 // 1.保存优惠券领取、使用历史记录表
81 this.doInsertCouponHistory(tempCoupon); 84 this.threadPoolTaskExecutor.execute(()->this.doInsertCouponHistory(tempCoupon));
82 // 2.更新会员优惠券数量 85 // 2.更新会员优惠券数量
83 this.refreshMemberCoupon(tempCoupon); 86 this.refreshMemberCoupon(tempCoupon);
84 } 87 }
...@@ -91,7 +94,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -91,7 +94,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
91 private void refreshMemberCoupon(TempCoupon tempCoupon) { 94 private void refreshMemberCoupon(TempCoupon tempCoupon) {
92 Long userId = tempCoupon.getUserId(); 95 Long userId = tempCoupon.getUserId();
93 Long memberId = tempCoupon.getMemberId(); 96 Long memberId = tempCoupon.getMemberId();
94 RLock rLock = this.redissonClient.getLock("refreshMemberCoupon" + memberId.toString()); 97 RLock rLock = this.redissonClient.getLock("refreshMemberCoupon:" + memberId.toString());
95 try { 98 try {
96 RedissonUtil.lock(rLock); 99 RedissonUtil.lock(rLock);
97 // 1.获取用户领取的总优惠券 100 // 1.获取用户领取的总优惠券
......
...@@ -19,9 +19,11 @@ import org.slf4j.Logger; ...@@ -19,9 +19,11 @@ import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory; 19 import org.slf4j.LoggerFactory;
20 import org.springframework.beans.BeanUtils; 20 import org.springframework.beans.BeanUtils;
21 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
22 import org.springframework.stereotype.Service; 23 import org.springframework.stereotype.Service;
23 import org.springframework.util.CollectionUtils; 24 import org.springframework.util.CollectionUtils;
24 25
26 import javax.annotation.Resource;
25 import java.util.List; 27 import java.util.List;
26 import java.util.Objects; 28 import java.util.Objects;
27 29
...@@ -41,6 +43,8 @@ public class ExpOperationServiceImpl implements ExpOperationService { ...@@ -41,6 +43,8 @@ public class ExpOperationServiceImpl implements ExpOperationService {
41 MemberLevelService memberLevelService; 43 MemberLevelService memberLevelService;
42 @Autowired 44 @Autowired
43 RedissonClient redissonClient; 45 RedissonClient redissonClient;
46 @Resource(name = "executorTask")
47 ThreadPoolTaskExecutor threadPoolTaskExecutor;
44 48
45 @Override 49 @Override
46 public void grantPointsThroughTempExp(List<TempExp> tempExpList) { 50 public void grantPointsThroughTempExp(List<TempExp> tempExpList) {
...@@ -71,11 +75,35 @@ public class ExpOperationServiceImpl implements ExpOperationService { ...@@ -71,11 +75,35 @@ public class ExpOperationServiceImpl implements ExpOperationService {
71 * @param tempExp 75 * @param tempExp
72 */ 76 */
73 private void refresh(TempExp tempExp) { 77 private void refresh(TempExp tempExp) {
74 // 1.添加成长值记录 78 RLock lock = this.redissonClient.getLock("refresh_exp:" + tempExp.getMemberId());
75 this.doInsertExpDetail(tempExp); 79 try {
80 RedissonUtil.lock(lock);
81 // 原始积分
82 long originExp = this.getExpByMemberId(tempExp);
83 // 总积分
84 long totalExp = this.calculateTotalExp(originExp, tempExp);
85 // 1.添加成长值记录
86 this.threadPoolTaskExecutor.execute(()->this.doInsertExpDetail(tempExp, originExp, totalExp));
87 // 2.更新成长值与等级
88 this.refreshMemberExpAndLevel(tempExp);
89 } catch (Exception e) {
90 e.printStackTrace();
91 throw e;
92 } finally {
93 RedissonUtil.unlock(lock);
94 }
95 }
96
97 private long calculateTotalExp(long originalExp,TempExp tempExp) {
98 Long rewardExp = tempExp.getRewardExp();
99 return (Objects.nonNull(rewardExp) ? rewardExp : 0L) + (Objects.nonNull(originalExp) ? originalExp : 0L);
100 }
76 101
77 // 2.更新成长值与等级 102 private long getExpByMemberId(TempExp tempExp) {
78 this.refreshMemberExpAndLevel(tempExp); 103 Long memberId = tempExp.getMemberId();
104 MemberDTO memberDTO = this.memberOperationService.findById(memberId);
105 Long exp = memberDTO.getExp();
106 return exp;
79 } 107 }
80 108
81 109
...@@ -156,26 +184,24 @@ public class ExpOperationServiceImpl implements ExpOperationService { ...@@ -156,26 +184,24 @@ public class ExpOperationServiceImpl implements ExpOperationService {
156 return memberDTO; 184 return memberDTO;
157 } 185 }
158 186
159
160 /** 187 /**
161 * 添加成长值记录 188 * 添加成长值记录
162 * 189 *
163 * @param tempExp 成长值列表 190 * @param tempExp 成长值列表
164 */ 191 */
165 private void doInsertExpDetail(TempExp tempExp) { 192 private void doInsertExpDetail(TempExp tempExp,long originalExp,long totalExp) {
193 // 获得的积分
194 Long rewardExp = tempExp.getRewardExp();
166 195
167 ExpDetail expDetail = new ExpDetail(); 196 ExpDetail expDetail = new ExpDetail();
168 BeanUtils.copyProperties(tempExp,expDetail); 197 BeanUtils.copyProperties(tempExp,expDetail);
169 198
170 MemberDTO memberDTO = this.memberOperationService.findById(expDetail.getMemberId());
171 Long exp = memberDTO.getExp();
172
173 Long rewardExp = tempExp.getRewardExp();
174 Long originalExp = exp;
175
176 expDetail.setCode(String.valueOf(IdWorker.generator())); 199 expDetail.setCode(String.valueOf(IdWorker.generator()));
200 // 原始积分
177 expDetail.setOriginalExp(Objects.nonNull(originalExp) ? originalExp : 0L); 201 expDetail.setOriginalExp(Objects.nonNull(originalExp) ? originalExp : 0L);
178 expDetail.setResultExp((Objects.nonNull(rewardExp) ? rewardExp : 0L) + (Objects.nonNull(originalExp) ? originalExp : 0L)); 202 // 总积分
203 expDetail.setResultExp(totalExp);
204 // 获得的积分
179 expDetail.setExp(rewardExp); 205 expDetail.setExp(rewardExp);
180 if (StringUtils.isEmpty(expDetail.getDescription())) { 206 if (StringUtils.isEmpty(expDetail.getDescription())) {
181 expDetail.setDescription("#"); 207 expDetail.setDescription("#");
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import cn.hutool.core.map.MapUtil; 3
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.basicdata.member.domain.Member;
5 import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
6 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; 5 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
7 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; 6 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
8 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 7 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
...@@ -17,25 +16,22 @@ import com.topdraw.util.IdWorker; ...@@ -17,25 +16,22 @@ import com.topdraw.util.IdWorker;
17 import com.topdraw.util.RedissonUtil; 16 import com.topdraw.util.RedissonUtil;
18 import com.topdraw.util.TimestampUtil; 17 import com.topdraw.util.TimestampUtil;
19 import com.topdraw.utils.StringUtils; 18 import com.topdraw.utils.StringUtils;
20 import io.swagger.models.auth.In;
21 import org.redisson.api.RLock; 19 import org.redisson.api.RLock;
22 import org.redisson.api.RedissonClient; 20 import org.redisson.api.RedissonClient;
23 import org.slf4j.Logger; 21 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory; 22 import org.slf4j.LoggerFactory;
25 import org.springframework.beans.BeanUtils; 23 import org.springframework.beans.BeanUtils;
26 import org.springframework.beans.factory.annotation.Autowired; 24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
27 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
28 import org.springframework.transaction.annotation.Propagation; 27 import org.springframework.transaction.annotation.Propagation;
29 import org.springframework.transaction.annotation.Transactional; 28 import org.springframework.transaction.annotation.Transactional;
30 import org.springframework.util.CollectionUtils; 29 import org.springframework.util.CollectionUtils;
31 30
32 import java.sql.Time; 31 import javax.annotation.Resource;
33 import java.sql.Timestamp; 32 import java.sql.Timestamp;
34 import java.time.LocalDateTime; 33 import java.time.LocalDateTime;
35 import java.util.*; 34 import java.util.*;
36 import java.util.concurrent.ForkJoinPool;
37 import java.util.concurrent.ForkJoinTask;
38 import java.util.concurrent.RecursiveTask;
39 import java.util.stream.Collectors; 35 import java.util.stream.Collectors;
40 36
41 /** 37 /**
...@@ -65,7 +61,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -65,7 +61,9 @@ public class PointsOperationServiceImpl implements PointsOperationService {
65 private static final String INSERT_AVAILABLE_POINTS = "insert"; 61 private static final String INSERT_AVAILABLE_POINTS = "insert";
66 62
67 @Autowired 63 @Autowired
68 private RedissonClient redissonClient; 64 RedissonClient redissonClient;
65 @Resource(name = "executorTask")
66 ThreadPoolTaskExecutor threadPoolTaskExecutor;
69 67
70 @Override 68 @Override
71 @Transactional(rollbackFor = Exception.class) 69 @Transactional(rollbackFor = Exception.class)
...@@ -89,11 +87,11 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -89,11 +87,11 @@ public class PointsOperationServiceImpl implements PointsOperationService {
89 // 1.判断可用积分是否够用 87 // 1.判断可用积分是否够用
90 boolean b = this.checkAvailablePoints(tempPoints); 88 boolean b = this.checkAvailablePoints(tempPoints);
91 if (b) { 89 if (b) {
92 // 1.可用积分表,按照过期时间进行升序排列 90 //1.删除过期的积分
93 // TODO 删除过期的积分 91 this.cleanInvalidAvailablePointsByMemberId(memberId);
92 // 2.可用积分表,按照过期时间进行升序排列
94 List<PointsAvailableDTO> pointsAvailableDTOS = this.findByMemberIdOrderByExpireTime(tempPoints); 93 List<PointsAvailableDTO> pointsAvailableDTOS = this.findByMemberIdOrderByExpireTime(tempPoints);
95 94 // 3.当前可用总积分
96 // 当前可用总积分
97 long currentPoints = this.findAvailablePointsByMemberId(memberId); 95 long currentPoints = this.findAvailablePointsByMemberId(memberId);
98 // 2.优先使用即将过期的积分,累加到超过需兑换积分时,需要进行拆分 96 // 2.优先使用即将过期的积分,累加到超过需兑换积分时,需要进行拆分
99 Map<String, List<PointsAvailableDTO>> customAvailablePointsMap = this.customAvailablePoints(tempPoints, pointsAvailableDTOS); 97 Map<String, List<PointsAvailableDTO>> customAvailablePointsMap = this.customAvailablePoints(tempPoints, pointsAvailableDTOS);
...@@ -101,11 +99,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -101,11 +99,8 @@ public class PointsOperationServiceImpl implements PointsOperationService {
101 this.doInsertTrPointsDetailByAvailablePointsMap(tempPoints, customAvailablePointsMap, currentPoints); 99 this.doInsertTrPointsDetailByAvailablePointsMap(tempPoints, customAvailablePointsMap, currentPoints);
102 // 4.更新可用积分表,超过的删除,剩余的新增 100 // 4.更新可用积分表,超过的删除,剩余的新增
103 long totalPoints = this.doFreshTrPointsAvailableByAvailablePointsMap(customAvailablePointsMap, currentPoints); 101 long totalPoints = this.doFreshTrPointsAvailableByAvailablePointsMap(customAvailablePointsMap, currentPoints);
104 // 4.获取即将过期的积分
105 // TODO 不用在这里查询
106 long soonExpireTime = this.getSoonExpirePoints(memberId, tempPoints);
107 // 6.更新会员积分信息 102 // 6.更新会员积分信息
108 this.freshMemberCurrentPoints(memberId, totalPoints, soonExpireTime); 103 this.freshMemberCurrentPoints(memberId, totalPoints);
109 104
110 return true; 105 return true;
111 } 106 }
...@@ -290,6 +285,17 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -290,6 +285,17 @@ public class PointsOperationServiceImpl implements PointsOperationService {
290 } 285 }
291 } 286 }
292 287
288 @Override
289 public void cleanInvalidAvailablePointsByMemberId(Long memberId) {
290 List<PointsAvailableDTO> pointsAvailableDTOS = pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId,TimestampUtil.now());
291 if (!CollectionUtils.isEmpty(pointsAvailableDTOS)) {
292 // 添加积分明细 uc_points_detail
293 this.doCreatePointsDetail(pointsAvailableDTOS);
294 // 删除已过期的积分
295 this.doDeleteInvalidAvailablePoints(pointsAvailableDTOS);
296 }
297 }
298
293 /** 299 /**
294 * 300 *
295 * @param pointsAvailableDTOS 301 * @param pointsAvailableDTOS
...@@ -325,9 +331,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -325,9 +331,8 @@ public class PointsOperationServiceImpl implements PointsOperationService {
325 pointsDetail.setEvtType(99); 331 pointsDetail.setEvtType(99);
326 this.doInsertPointsDetail(pointsDetail); 332 this.doInsertPointsDetail(pointsDetail);
327 333
328 long soonExpireTime = this.getSoonExpirePoints(memberId,null);
329 // 更新会员积分 334 // 更新会员积分
330 this.freshMemberCurrentPoints(memberId,resultPoints,soonExpireTime); 335 this.freshMemberCurrentPoints(memberId,resultPoints);
331 } 336 }
332 337
333 } 338 }
...@@ -339,7 +344,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -339,7 +344,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
339 */ 344 */
340 private void refresh(TempPoints tempPoints) { 345 private void refresh(TempPoints tempPoints) {
341 Long memberId = tempPoints.getMemberId(); 346 Long memberId = tempPoints.getMemberId();
342 RLock rLock = this.redissonClient.getLock("refresh" + memberId.toString()); 347 RLock rLock = this.redissonClient.getLock("refresh_point:" + memberId.toString());
343 try { 348 try {
344 RedissonUtil.lock(rLock); 349 RedissonUtil.lock(rLock);
345 // 1.可用总积分 350 // 1.可用总积分
...@@ -347,13 +352,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -347,13 +352,9 @@ public class PointsOperationServiceImpl implements PointsOperationService {
347 // 2.计算总积分 352 // 2.计算总积分
348 long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); 353 long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints);
349 // 2.添加积分明细,并计算总积分 354 // 2.添加积分明细,并计算总积分
350 // TODO 把计算总积分的过程单独提取出来,保存积分流水的时候可以异步 355 this.threadPoolTaskExecutor.execute(()->this.doInsertTrPointsDetail(memberId, tempPoints, currentPoints,totalPoints));
351 this.doInsertTrPointsDetail(memberId, tempPoints, currentPoints,totalPoints);
352 // 3.获取即将过期的积分
353 // TODO 不需要在这里查询过期积分,用的时候再去查看
354 long soonExpireTime = this.getSoonExpirePoints(memberId, tempPoints);
355 // 4.更新会员的总积分 356 // 4.更新会员的总积分
356 this.freshMemberCurrentPoints(memberId, totalPoints, soonExpireTime); 357 this.freshMemberCurrentPoints(memberId, totalPoints);
357 // 5.添加可用积分 358 // 5.添加可用积分
358 this.doInsertTrPointsAvailable(tempPoints); 359 this.doInsertTrPointsAvailable(tempPoints);
359 } catch (Exception e) { 360 } catch (Exception e) {
...@@ -408,13 +409,12 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -408,13 +409,12 @@ public class PointsOperationServiceImpl implements PointsOperationService {
408 * 更新会员总积分 409 * 更新会员总积分
409 * @param memberId 会员Id 410 * @param memberId 会员Id
410 * @param currentPoints 当前总积分 411 * @param currentPoints 当前总积分
411 * @param duePoints 即将过期的积分
412 */ 412 */
413 private void freshMemberCurrentPoints(Long memberId, Long currentPoints,long duePoints){ 413 private void freshMemberCurrentPoints(Long memberId, Long currentPoints) {
414 Member member = new Member(); 414 Member member = new Member();
415 member.setId(memberId); 415 member.setId(memberId);
416 member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0); 416 member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0);
417 member.setDuePoints(duePoints); 417 // member.setDuePoints(duePoints);
418 member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now())); 418 member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now()));
419 try { 419 try {
420 this.memberOperationService.doUpdateMemberPoints(member); 420 this.memberOperationService.doUpdateMemberPoints(member);
......
...@@ -10,9 +10,9 @@ import com.topdraw.business.process.service.PointsOperationService; ...@@ -10,9 +10,9 @@ import com.topdraw.business.process.service.PointsOperationService;
10 import com.topdraw.business.process.service.RightsOperationService; 10 import com.topdraw.business.process.service.RightsOperationService;
11 import com.topdraw.business.process.domian.*; 11 import com.topdraw.business.process.domian.*;
12 import com.topdraw.util.TimestampUtil; 12 import com.topdraw.util.TimestampUtil;
13 import lombok.extern.slf4j.Slf4j;
13 import org.slf4j.Logger; 14 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory; 15 import org.slf4j.LoggerFactory;
15 import org.springframework.beans.BeanUtils;
16 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 17 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
18 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
...@@ -29,6 +29,7 @@ import java.util.*; ...@@ -29,6 +29,7 @@ import java.util.*;
29 * @date 2021.10.23 29 * @date 2021.10.23
30 */ 30 */
31 @Service 31 @Service
32 @Slf4j
32 public class RightsOperationServiceImpl implements RightsOperationService { 33 public class RightsOperationServiceImpl implements RightsOperationService {
33 34
34 private static final Logger LOG = LoggerFactory.getLogger(RightsOperationServiceImpl.class); 35 private static final Logger LOG = LoggerFactory.getLogger(RightsOperationServiceImpl.class);
...@@ -69,12 +70,17 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -69,12 +70,17 @@ public class RightsOperationServiceImpl implements RightsOperationService {
69 */ 70 */
70 @Override 71 @Override
71 public void grantRights(Map<RightType, Object> tempRightsMap) { 72 public void grantRights(Map<RightType, Object> tempRightsMap) {
73
74 this.threadPoolTaskExecutor.execute(()-> {
75 // 2.创建权益历史对象
76 List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap);
77 // 3.保存权益历史
78 this.doInsertTrRightHistory(rightsList);
79 });
80
72 // 1.权益下发 81 // 1.权益下发
73 this.refresh(tempRightsMap); 82 this.refresh(tempRightsMap);
74 // 2.创建权益历史对象 83
75 List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap);
76 // 3.保存权益历史
77 this.doInsertTrRightHistory(rightsList);
78 } 84 }
79 85
80 /** 86 /**
...@@ -138,24 +144,24 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -138,24 +144,24 @@ public class RightsOperationServiceImpl implements RightsOperationService {
138 */ 144 */
139 private void refresh(Map<RightType, Object> tempRightsMap) { 145 private void refresh(Map<RightType, Object> tempRightsMap) {
140 146
141 /*threadPoolTaskExecutor.execute(()->{ 147 this.threadPoolTaskExecutor.execute(()->{
142 // 积分 148 // 积分
143 this.grantPoint((List<TempPoints>)tempRightsMap.get(RightType.POINTS)); 149 this.grantPoint((List<TempPoints>)tempRightsMap.get(RightType.POINTS));
144 }); 150 });
145 151
146 threadPoolTaskExecutor.execute(()->{ 152 this.threadPoolTaskExecutor.execute(()->{
147 // 成长值 153 // 成长值
148 this.grantExp((List<TempExp>)tempRightsMap.get(RightType.EXP)); 154 this.grantExp((List<TempExp>)tempRightsMap.get(RightType.EXP));
149 }); 155 });
150 156
151 threadPoolTaskExecutor.execute(()->{ 157 this.threadPoolTaskExecutor.execute(()->{
152 // 优惠券 158 // 优惠券
153 this.grantCoupon((List<TempCoupon>)tempRightsMap.get(RightType.COUPON)); 159 this.grantCoupon((List<TempCoupon>)tempRightsMap.get(RightType.COUPON));
154 });*/ 160 });
155 161
156 this.grantPoint((List<TempPoints>)tempRightsMap.get(RightType.POINTS)); 162 /*this.grantPoint((List<TempPoints>)tempRightsMap.get(RightType.POINTS));
157 this.grantExp((List<TempExp>)tempRightsMap.get(RightType.EXP)); 163 this.grantExp((List<TempExp>)tempRightsMap.get(RightType.EXP));
158 this.grantCoupon((List<TempCoupon>)tempRightsMap.get(RightType.COUPON)); 164 this.grantCoupon((List<TempCoupon>)tempRightsMap.get(RightType.COUPON));*/
159 } 165 }
160 166
161 /** 167 /**
...@@ -255,6 +261,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -255,6 +261,7 @@ public class RightsOperationServiceImpl implements RightsOperationService {
255 261
256 for (RightsHistory rightsHistory : rightsHistories) { 262 for (RightsHistory rightsHistory : rightsHistories) {
257 rightsHistory.setSendTime(TimestampUtil.now()); 263 rightsHistory.setSendTime(TimestampUtil.now());
264
258 this.rightsHistoryService.create(rightsHistory); 265 this.rightsHistoryService.create(rightsHistory);
259 } 266 }
260 267
......
...@@ -18,11 +18,15 @@ import com.topdraw.business.basicdata.task.service.TaskService; ...@@ -18,11 +18,15 @@ import com.topdraw.business.basicdata.task.service.TaskService;
18 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 18 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
19 import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; 19 import com.topdraw.business.basicdata.task.template.service.TaskTemplateService;
20 import com.topdraw.business.process.domian.*; 20 import com.topdraw.business.process.domian.*;
21 import com.topdraw.exception.BadRequestException;
21 import com.topdraw.module.mq.DataSyncMsg; 22 import com.topdraw.module.mq.DataSyncMsg;
22 import com.topdraw.util.*; 23 import com.topdraw.util.*;
24 import lombok.extern.slf4j.Slf4j;
23 import org.slf4j.Logger; 25 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory; 26 import org.slf4j.LoggerFactory;
25 import org.springframework.beans.factory.annotation.Autowired; 27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.cache.annotation.CacheEvict;
29 import org.springframework.cache.annotation.Cacheable;
26 import org.springframework.cache.annotation.EnableCaching; 30 import org.springframework.cache.annotation.EnableCaching;
27 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 31 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
28 import org.springframework.stereotype.Service; 32 import org.springframework.stereotype.Service;
...@@ -46,6 +50,7 @@ import java.util.stream.Collectors; ...@@ -46,6 +50,7 @@ import java.util.stream.Collectors;
46 * @date 2021.10.23 50 * @date 2021.10.23
47 */ 51 */
48 @Service 52 @Service
53 @Slf4j
49 public class TaskOperationServiceImpl implements TaskOperationService { 54 public class TaskOperationServiceImpl implements TaskOperationService {
50 55
51 private static final Logger LOG = LoggerFactory.getLogger(PointsOperationServiceImpl.class); 56 private static final Logger LOG = LoggerFactory.getLogger(PointsOperationServiceImpl.class);
...@@ -75,30 +80,52 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -75,30 +80,52 @@ public class TaskOperationServiceImpl implements TaskOperationService {
75 @Override 80 @Override
76 public void dealTask(String content) { 81 public void dealTask(String content) {
77 82
78 long l = System.currentTimeMillis();
79
80 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); 83 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
81 String eventType = dataSyncMsg.getEventType();
82 DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); 84 DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg();
85 Integer event = msgData.getEvent();
83 Long memberId = msgData.getMemberId(); 86 Long memberId = msgData.getMemberId();
84 87
88 long l = System.currentTimeMillis();
89 // 验证会员信息
90 boolean b = this.validatedMember(memberId);
91 if (b) {
92 throw new BadRequestException("【member status exception!!】");
93 }
94
85 // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板 95 // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板
86 TaskTemplate taskTemplate = this.getTaskTemplate(eventType); 96 TaskTemplate taskTemplate = this.getTaskTemplate(event);
87 // 2.解析模板参数 97 // 2.通过任务模板获取对应的任务列表
88 Map<String,Object> paramMap = this.parseTaskTemplateParam(taskTemplate); 98 List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate);
89 // 3.通过任务模板获取对应的任务列表
90 List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate,paramMap);
91 // 4.判断当前用户是否满足任务完成条件 99 // 4.判断当前用户是否满足任务完成条件
92 boolean checkResult = this.checkTaskCompletion(memberId,taskList); 100 boolean checkResult = this.checkTaskCompletion(memberId,taskList);
93 if (checkResult) { 101 if (checkResult) {
94 // 5.权益区分(积分、权益、成长值) 102 // 5.权益区分(积分、权益、成长值)
95 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId,taskList,msgData); 103 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId,taskList,msgData);
104
96 // 6.权益发放 105 // 6.权益发放
97 this.grantRight(tempRightsMap); 106 this.grantRight(tempRightsMap);
107
98 } 108 }
99 109
100 long r = System.currentTimeMillis(); 110 long r = System.currentTimeMillis();
101 LOG.info("总耗时======>>>>>" + (r-l)); 111 LOG.info("总耗时======>>>>>" + (r-l));
112
113 }
114
115 /**
116 * 验证会员信息
117 * @param memberId
118 * @return
119 */
120 private boolean validatedMember(Long memberId) {
121 log.info("validatedMember -->>【memberId】 -->> " + memberId);
122 MemberDTO memberDTO = this.memberService.findById(memberId);
123 Integer blackStatus = memberDTO.getBlackStatus();
124 if (Objects.nonNull(blackStatus) && blackStatus == 1) {
125 log.error("validatedMember -->> 会员已被加入黑名单 【blackStatus】 -->> " + blackStatus);
126 return false;
127 }
128 return Objects.nonNull(memberDTO) ? true:false;
102 } 129 }
103 130
104 /** 131 /**
...@@ -674,11 +701,27 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -674,11 +701,27 @@ public class TaskOperationServiceImpl implements TaskOperationService {
674 } 701 }
675 702
676 /** 703 /**
704 * 获取任务模板对应的任务列表
705 *
706 * @param taskTemplate 任务模板
707 * @return List<task> 任务列表
708 */
709 private List<Task> loadListTaskByTaskTemplate(TaskTemplate taskTemplate) {
710
711 if (Objects.nonNull(taskTemplate)) {
712 Long taskTemplateId = taskTemplate.getId();
713 return this.taskService.findByTemplateId(taskTemplateId);
714 }
715
716 return null;
717 }
718
719 /**
677 * 获取任务模板 720 * 获取任务模板
678 * @param event 任务 721 * @param event 任务
679 * @return TaskTemplate 任务模板 722 * @return TaskTemplate 任务模板
680 */ 723 */
681 private TaskTemplate getTaskTemplate(String event) { 724 private TaskTemplate getTaskTemplate(Integer event) {
682 return this.taskTemplateService.findByEvent(event); 725 return this.taskTemplateService.findByType(event);
683 } 726 }
684 } 727 }
......
...@@ -53,7 +53,7 @@ spring: ...@@ -53,7 +53,7 @@ spring:
53 max-request-size: 200MB 53 max-request-size: 200MB
54 redis: 54 redis:
55 #数据库索引 55 #数据库索引
56 database: 16 56 database: 0
57 host: 122.112.214.149 57 host: 122.112.214.149
58 # host: 139.196.4.234 58 # host: 139.196.4.234
59 port: 6379 59 port: 6379
...@@ -61,17 +61,23 @@ spring: ...@@ -61,17 +61,23 @@ spring:
61 # password: 61 # password:
62 #连接超时时间 62 #连接超时时间
63 timeout: 5000 63 timeout: 5000
64 # rabbitmq:
65 # host: 47.100.212.170 # rabbitmq的连接地址
66 ## host: 122.112.214.149 # rabbitmq的连接地址
67 # #host: 139.196.192.242 # rabbitmq的连接地址
68 # port: 5672 # rabbitmq的连接端口号
69 # #virtual-host: /member_center # rabbitmq的虚拟host
70 # #username: member_center # rabbitmq的用户名
71 # #password: Tjlh@2021 # rabbitmq的密码
72 # virtual-host: test # rabbitmq的虚拟host
73 # username: omo_test # rabbitmq的用户名
74 # password: omo_test # rabbitmq的密码
64 rabbitmq: 75 rabbitmq:
65 host: 47.100.212.170 # rabbitmq的连接地址 76 host: 139.196.145.150 # rabbitmq的连接地址
66 # host: 122.112.214.149 # rabbitmq的连接地址
67 #host: 139.196.192.242 # rabbitmq的连接地址
68 port: 5672 # rabbitmq的连接端口号 77 port: 5672 # rabbitmq的连接端口号
69 #virtual-host: /member_center # rabbitmq的虚拟host 78 virtual-host: member_center # rabbitmq的虚拟host
70 #username: member_center # rabbitmq的用户名 79 username: admin # rabbitmq的用户名
71 #password: Tjlh@2021 # rabbitmq的密码 80 password: Topdraw1qaz # rabbitmq的密码
72 virtual-host: test # rabbitmq的虚拟host
73 username: omo_test # rabbitmq的用户名
74 password: omo_test # rabbitmq的密码
75 publisher-confirms: true #如果对异步消息需要回调必须设置为true 81 publisher-confirms: true #如果对异步消息需要回调必须设置为true
76 82
77 #jwt。依赖的common中有需要jwt的部分属性。 83 #jwt。依赖的common中有需要jwt的部分属性。
......
...@@ -62,15 +62,11 @@ spring: ...@@ -62,15 +62,11 @@ spring:
62 #连接超时时间 62 #连接超时时间
63 timeout: 5000 63 timeout: 5000
64 rabbitmq: 64 rabbitmq:
65 host: 122.112.214.149 # rabbitmq的连接地址 65 host: 139.196.145.150 # rabbitmq的连接地址
66 #host: 139.196.192.242 # rabbitmq的连接地址
67 port: 5672 # rabbitmq的连接端口号 66 port: 5672 # rabbitmq的连接端口号
68 #virtual-host: /member_center # rabbitmq的虚拟host 67 virtual-host: member_center # rabbitmq的虚拟host
69 #username: member_center # rabbitmq的用户名 68 username: admin # rabbitmq的用户名
70 #password: Tjlh@2021 # rabbitmq的密码 69 password: Topdraw1qaz # rabbitmq的密码
71 virtual-host: / # rabbitmq的虚拟host
72 username: guest # rabbitmq的用户名
73 password: guest # rabbitmq的密码
74 publisher-confirms: true #如果对异步消息需要回调必须设置为true 70 publisher-confirms: true #如果对异步消息需要回调必须设置为true
75 71
76 #jwt。依赖的common中有需要jwt的部分属性。 72 #jwt。依赖的common中有需要jwt的部分属性。
......
...@@ -7,7 +7,7 @@ spring: ...@@ -7,7 +7,7 @@ spring:
7 freemarker: 7 freemarker:
8 check-template-location: false 8 check-template-location: false
9 profiles: 9 profiles:
10 active: test 10 active: dev
11 jackson: 11 jackson:
12 time-zone: GMT+8 12 time-zone: GMT+8
13 data: 13 data:
......
1 package com.topdraw.test.business.basicdata.member.rest;
2
3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.BaseTest;
5 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
6 import com.topdraw.business.basicdata.member.profile.rest.MemberProfileController;
7 import com.topdraw.business.basicdata.member.profile.service.MemberProfileService;
8 import com.topdraw.util.TimestampUtil;
9 import org.junit.Test;
10 import org.springframework.beans.factory.annotation.Autowired;
11
12 public class MemberProfileControllerTest extends BaseTest {
13
14 @Autowired
15 private MemberProfileController memberProfileController;
16
17 @Test
18 public void create(){
19 Long memberId = 1L;
20 MemberProfile resources = new MemberProfile();
21 resources.setMemberId(memberId);
22 resources.setIdCard("422827199208010713");
23 resources.setBirthday(TimestampUtil.now());
24 resources.setGender(1);
25 resources.setDescription("");
26 resources.setRealname("");
27 resources.setConstellation("");
28 resources.setProvince("");
29 resources.setCity("");
30 resources.setEmail("");
31 resources.setDistrict("");
32 String s = JSON.toJSONString(resources);
33 this.memberProfileController.create(resources);
34 LOG.info("=====>>>"+s);
35 }
36
37 @Test
38 public void update(){
39 Long memberId = 1L;
40 MemberProfile resources = new MemberProfile();
41 resources.setId(1L);
42 resources.setMemberId(memberId);
43 resources.setCity("sh");
44 String s = JSON.toJSONString(resources);
45 this.memberProfileController.update(resources);
46 LOG.info("=====>>>s=====>>>" + s);
47 }
48
49 @Test
50 public void delete(){
51 Long memberId = 1L;
52 this.memberProfileController.delete(memberId);
53 LOG.info("=====>>>s=====>>>");
54 }
55
56 }
...@@ -31,6 +31,8 @@ public class TaskOperationControllerTest extends BaseTest { ...@@ -31,6 +31,8 @@ public class TaskOperationControllerTest extends BaseTest {
31 String s = JSON.toJSONString(dataSyncMsg); 31 String s = JSON.toJSONString(dataSyncMsg);
32 TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); 32 TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria();
33 pointsQueryCriteria.setContent(s); 33 pointsQueryCriteria.setContent(s);
34 String s1 = JSON.toJSONString(pointsQueryCriteria);
35 System.out.println(s1);
34 this.taskOperationController.dealTask(pointsQueryCriteria); 36 this.taskOperationController.dealTask(pointsQueryCriteria);
35 } catch (Exception e) { 37 } catch (Exception e) {
36 e.printStackTrace(); 38 e.printStackTrace();
......