Merge branch 'release/1.0.3'
Showing
49 changed files
with
733 additions
and
248 deletions
document/sql/structure/update.sql
0 → 100644
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | <entry key="lastExternalPluginCheckTime" value="1636770952724" /> | 10 | <entry key="lastExternalPluginCheckTime" value="1636770952724" /> |
11 | </map> | 11 | </map> |
12 | </option> | 12 | </option> |
13 | <option name="version" value="5" /> | 13 | <option name="version" value="6" /> |
14 | </configuration> | 14 | </configuration> |
15 | </facet> | 15 | </facet> |
16 | </component> | 16 | </component> | ... | ... |
1 | package com.topdraw.module.mq; | 1 | package com.topdraw.module.mq; |
2 | 2 | ||
3 | import javax.annotation.Resource; | ||
4 | |||
3 | // 关注的事件 | 5 | // 关注的事件 |
4 | public enum EventType { | 6 | public enum EventType { |
5 | 7 | ||
... | @@ -22,7 +24,7 @@ public enum EventType { | ... | @@ -22,7 +24,7 @@ public enum EventType { |
22 | // 登录 | 24 | // 登录 |
23 | LOGIN, | 25 | LOGIN, |
24 | // 订购产品包 | 26 | // 订购产品包 |
25 | SUBSCRIBE_PRODUCT_PACKAGE | 27 | SUBSCRIBE_PRODUCT_PACKAGE, |
26 | 28 | // 签到 | |
27 | 29 | SIGN | |
28 | } | 30 | } | ... | ... |
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | <entry key="lastExternalPluginCheckTime" value="1636770952726" /> | 10 | <entry key="lastExternalPluginCheckTime" value="1636770952726" /> |
11 | </map> | 11 | </map> |
12 | </option> | 12 | </option> |
13 | <option name="version" value="5" /> | 13 | <option name="version" value="6" /> |
14 | </configuration> | 14 | </configuration> |
15 | </facet> | 15 | </facet> |
16 | </component> | 16 | </component> | ... | ... |
... | @@ -125,6 +125,17 @@ | ... | @@ -125,6 +125,17 @@ |
125 | 125 | ||
126 | <build> | 126 | <build> |
127 | <finalName>member-service</finalName> | 127 | <finalName>member-service</finalName> |
128 | <resources> | ||
129 | <resource> | ||
130 | <directory>src/main/java</directory> | ||
131 | <includes> | ||
132 | <include>**/*.xml</include> | ||
133 | </includes> | ||
134 | </resource> | ||
135 | <resource> | ||
136 | <directory>src/main/resources</directory> | ||
137 | </resource> | ||
138 | </resources> | ||
128 | <plugins> | 139 | <plugins> |
129 | <plugin> | 140 | <plugin> |
130 | <groupId>org.springframework.boot</groupId> | 141 | <groupId>org.springframework.boot</groupId> |
... | @@ -143,6 +154,7 @@ | ... | @@ -143,6 +154,7 @@ |
143 | </plugin> | 154 | </plugin> |
144 | <!-- 复制指定配置文件到指定目录 --> | 155 | <!-- 复制指定配置文件到指定目录 --> |
145 | <plugin> | 156 | <plugin> |
157 | <groupId>org.apache.maven.plugins</groupId> | ||
146 | <artifactId>maven-resources-plugin</artifactId> | 158 | <artifactId>maven-resources-plugin</artifactId> |
147 | <executions> | 159 | <executions> |
148 | <execution> | 160 | <execution> | ... | ... |
... | @@ -28,7 +28,7 @@ public class AsyncMqProducer { | ... | @@ -28,7 +28,7 @@ public class AsyncMqProducer { |
28 | @Autowired | 28 | @Autowired |
29 | MessageProducer messageProducer; | 29 | MessageProducer messageProducer; |
30 | 30 | ||
31 | @Resource(name = "executorTask") | 31 | @Autowired |
32 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 32 | ThreadPoolTaskExecutor threadPoolTaskExecutor; |
33 | 33 | ||
34 | @Pointcut(value = "@annotation(asyncMqSend)") | 34 | @Pointcut(value = "@annotation(asyncMqSend)") | ... | ... |
... | @@ -121,7 +121,7 @@ public class Member implements Serializable { | ... | @@ -121,7 +121,7 @@ public class Member implements Serializable { |
121 | 121 | ||
122 | // 是否在黑名单 1:是;0否 | 122 | // 是否在黑名单 1:是;0否 |
123 | @Column(name = "black_status") | 123 | @Column(name = "black_status") |
124 | private Integer blackStatus; | 124 | private Long 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)); | ... | ... |
1 | package com.topdraw.business.basicdata.member.group.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-11-17 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_member_group") | ||
24 | public class MemberGroup implements Serializable { | ||
25 | |||
26 | // ID ID | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 分组ID | ||
33 | @Column(name = "group_id") | ||
34 | private Long groupId; | ||
35 | |||
36 | // 会员ID | ||
37 | @Column(name = "member_id") | ||
38 | private Long memberId; | ||
39 | |||
40 | // 运营商平台账号 | ||
41 | @Column(name = "platform_account") | ||
42 | private String platformAccount; | ||
43 | |||
44 | // 手机号 | ||
45 | @Column(name = "cellphone") | ||
46 | private String cellphone; | ||
47 | |||
48 | // 设备 | ||
49 | @Column(name = "stb_id") | ||
50 | private String stbId; | ||
51 | |||
52 | // 有线MAC地址 | ||
53 | @Column(name = "eth_mac") | ||
54 | private String ethMac; | ||
55 | |||
56 | // 无线MAC地址 | ||
57 | @Column(name = "wifi_mac") | ||
58 | private String wifiMac; | ||
59 | |||
60 | // 描述 | ||
61 | @Column(name = "description") | ||
62 | private String description; | ||
63 | |||
64 | // 创建者 | ||
65 | @Column(name = "create_by") | ||
66 | private String createBy; | ||
67 | |||
68 | // 创建时间 | ||
69 | @CreatedDate | ||
70 | @Column(name = "create_time") | ||
71 | private Timestamp createTime; | ||
72 | |||
73 | // 更新者 | ||
74 | @Column(name = "update_by") | ||
75 | private String updateBy; | ||
76 | |||
77 | // 更新时间 | ||
78 | @LastModifiedDate | ||
79 | @Column(name = "update_time") | ||
80 | private Timestamp updateTime; | ||
81 | |||
82 | public void copy(MemberGroup source){ | ||
83 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
84 | } | ||
85 | } |
1 | package com.topdraw.business.basicdata.member.group.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.group.domain.MemberGroup; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | |||
7 | import java.util.Optional; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-11-17 | ||
12 | */ | ||
13 | public interface MemberGroupRepository extends JpaRepository<MemberGroup, Long>, JpaSpecificationExecutor<MemberGroup> { | ||
14 | |||
15 | } |
1 | package com.topdraw.business.basicdata.member.group.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.member.group.domain.MemberGroup; | ||
6 | import com.topdraw.business.basicdata.member.group.service.MemberGroupService; | ||
7 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.http.HttpStatus; | ||
11 | import org.springframework.http.ResponseEntity; | ||
12 | import org.springframework.validation.annotation.Validated; | ||
13 | import org.springframework.web.bind.annotation.*; | ||
14 | import io.swagger.annotations.*; | ||
15 | import java.io.IOException; | ||
16 | import javax.servlet.http.HttpServletResponse; | ||
17 | |||
18 | /** | ||
19 | * @author XiangHan | ||
20 | * @date 2021-11-17 | ||
21 | */ | ||
22 | @Api(tags = "MemberGroup管理") | ||
23 | @RestController | ||
24 | @RequestMapping("/api/MemberGroup") | ||
25 | public class MemberGroupController { | ||
26 | |||
27 | @Autowired | ||
28 | private MemberGroupService MemberGroupService; | ||
29 | |||
30 | @GetMapping | ||
31 | @ApiOperation("查询MemberGroup") | ||
32 | public ResultInfo getMemberGroups(MemberGroupQueryCriteria criteria, Pageable pageable) { | ||
33 | return ResultInfo.successPage(MemberGroupService.queryAll(criteria,pageable)); | ||
34 | } | ||
35 | |||
36 | @GetMapping(value = "/all") | ||
37 | @ApiOperation("查询所有MemberGroup") | ||
38 | public ResultInfo getMemberGroups(MemberGroupQueryCriteria criteria) { | ||
39 | return ResultInfo.success(MemberGroupService.queryAll(criteria)); | ||
40 | } | ||
41 | |||
42 | @Log | ||
43 | @PostMapping | ||
44 | @ApiOperation("新增MemberGroup") | ||
45 | public ResultInfo create(@Validated @RequestBody MemberGroup resources) { | ||
46 | MemberGroupService.create(resources); | ||
47 | return ResultInfo.success(); | ||
48 | } | ||
49 | |||
50 | @Log | ||
51 | @PutMapping | ||
52 | @ApiOperation("修改MemberGroup") | ||
53 | public ResultInfo update(@Validated @RequestBody MemberGroup resources) { | ||
54 | MemberGroupService.update(resources); | ||
55 | return ResultInfo.success(); | ||
56 | } | ||
57 | |||
58 | |||
59 | @Log | ||
60 | @DeleteMapping(value = "/{id}") | ||
61 | @ApiOperation("删除MemberGroup") | ||
62 | public ResultInfo delete(@PathVariable Long id) { | ||
63 | MemberGroupService.delete(id); | ||
64 | return ResultInfo.success(); | ||
65 | } | ||
66 | |||
67 | } |
1 | package com.topdraw.business.basicdata.member.group.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.group.domain.MemberGroup; | ||
4 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; | ||
5 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | import java.io.IOException; | ||
10 | import javax.servlet.http.HttpServletResponse; | ||
11 | |||
12 | /** | ||
13 | * @author XiangHan | ||
14 | * @date 2021-11-17 | ||
15 | */ | ||
16 | public interface MemberGroupService { | ||
17 | |||
18 | /** | ||
19 | * 查询数据分页 | ||
20 | * @param criteria 条件参数 | ||
21 | * @param pageable 分页参数 | ||
22 | * @return Map<String,Object> | ||
23 | */ | ||
24 | Map<String,Object> queryAll(MemberGroupQueryCriteria criteria, Pageable pageable); | ||
25 | |||
26 | /** | ||
27 | * 查询所有数据不分页 | ||
28 | * @param criteria 条件参数 | ||
29 | * @return List<MemberGroupDTO> | ||
30 | */ | ||
31 | List<MemberGroupDTO> queryAll(MemberGroupQueryCriteria criteria); | ||
32 | |||
33 | /** | ||
34 | * 根据ID查询 | ||
35 | * @param id ID | ||
36 | * @return MemberGroupDTO | ||
37 | */ | ||
38 | MemberGroupDTO findById(Long id); | ||
39 | |||
40 | void create(MemberGroup resources); | ||
41 | |||
42 | void update(MemberGroup resources); | ||
43 | |||
44 | void delete(Long id); | ||
45 | |||
46 | } |
1 | package com.topdraw.business.basicdata.member.group.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-11-17 | ||
11 | */ | ||
12 | @Data | ||
13 | public class MemberGroupDTO implements Serializable { | ||
14 | |||
15 | // ID ID | ||
16 | private Long id; | ||
17 | |||
18 | // 分组ID | ||
19 | private Long groupId; | ||
20 | |||
21 | // 会员ID | ||
22 | private Long memberId; | ||
23 | |||
24 | // 运营商平台账号 | ||
25 | private String platformAccount; | ||
26 | |||
27 | // 手机号 | ||
28 | private String cellphone; | ||
29 | |||
30 | // 设备 | ||
31 | private String stbId; | ||
32 | |||
33 | // 有线MAC地址 | ||
34 | private String ethMac; | ||
35 | |||
36 | // 无线MAC地址 | ||
37 | private String wifiMac; | ||
38 | |||
39 | // 描述 | ||
40 | private String description; | ||
41 | |||
42 | // 创建者 | ||
43 | private String createBy; | ||
44 | |||
45 | // 创建时间 | ||
46 | private Timestamp createTime; | ||
47 | |||
48 | // 更新者 | ||
49 | private String updateBy; | ||
50 | |||
51 | // 更新时间 | ||
52 | private Timestamp updateTime; | ||
53 | } |
1 | package com.topdraw.business.basicdata.member.group.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import com.topdraw.annotation.Query; | ||
5 | |||
6 | /** | ||
7 | * @author XiangHan | ||
8 | * @date 2021-11-17 | ||
9 | */ | ||
10 | @Data | ||
11 | public class MemberGroupQueryCriteria{ | ||
12 | |||
13 | @Query(type = Query.Type.EQUAL) | ||
14 | private Long memberId; | ||
15 | } |
1 | package com.topdraw.business.basicdata.member.group.service.impl; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.group.domain.MemberGroup; | ||
4 | import com.topdraw.utils.ValidationUtil; | ||
5 | import com.topdraw.utils.FileUtil; | ||
6 | import com.topdraw.business.basicdata.member.group.repository.MemberGroupRepository; | ||
7 | import com.topdraw.business.basicdata.member.group.service.MemberGroupService; | ||
8 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; | ||
9 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.member.group.service.mapper.MemberGroupMapper; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | import org.springframework.transaction.annotation.Propagation; | ||
14 | import org.springframework.transaction.annotation.Transactional; | ||
15 | import org.springframework.dao.EmptyResultDataAccessException; | ||
16 | import org.springframework.data.domain.Page; | ||
17 | import org.springframework.data.domain.Pageable; | ||
18 | import org.springframework.util.Assert; | ||
19 | import com.topdraw.utils.PageUtil; | ||
20 | import com.topdraw.utils.QueryHelp; | ||
21 | import com.topdraw.utils.StringUtils; | ||
22 | |||
23 | import java.util.List; | ||
24 | import java.util.Map; | ||
25 | import java.io.IOException; | ||
26 | import javax.servlet.http.HttpServletResponse; | ||
27 | import java.util.ArrayList; | ||
28 | import java.util.LinkedHashMap; | ||
29 | |||
30 | /** | ||
31 | * @author XiangHan | ||
32 | * @date 2021-11-17 | ||
33 | */ | ||
34 | @Service | ||
35 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
36 | public class MemberGroupServiceImpl implements MemberGroupService { | ||
37 | |||
38 | @Autowired | ||
39 | private MemberGroupRepository MemberGroupRepository; | ||
40 | |||
41 | @Autowired | ||
42 | private MemberGroupMapper MemberGroupMapper; | ||
43 | |||
44 | @Override | ||
45 | public Map<String, Object> queryAll(MemberGroupQueryCriteria criteria, Pageable pageable) { | ||
46 | Page<MemberGroup> page = MemberGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
47 | return PageUtil.toPage(page.map(MemberGroupMapper::toDto)); | ||
48 | } | ||
49 | |||
50 | @Override | ||
51 | public List<MemberGroupDTO> queryAll(MemberGroupQueryCriteria criteria) { | ||
52 | return MemberGroupMapper.toDto(MemberGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
53 | } | ||
54 | |||
55 | @Override | ||
56 | public MemberGroupDTO findById(Long id) { | ||
57 | MemberGroup MemberGroup = MemberGroupRepository.findById(id).orElseGet(MemberGroup::new); | ||
58 | ValidationUtil.isNull(MemberGroup.getId(),"MemberGroup","id",id); | ||
59 | return MemberGroupMapper.toDto(MemberGroup); | ||
60 | } | ||
61 | |||
62 | @Override | ||
63 | @Transactional(rollbackFor = Exception.class) | ||
64 | public void create(MemberGroup resources) { | ||
65 | MemberGroupRepository.save(resources); | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | @Transactional(rollbackFor = Exception.class) | ||
70 | public void update(MemberGroup resources) { | ||
71 | MemberGroup MemberGroup = MemberGroupRepository.findById(resources.getId()).orElseGet(MemberGroup::new); | ||
72 | ValidationUtil.isNull( MemberGroup.getId(),"MemberGroup","id",resources.getId()); | ||
73 | MemberGroup.copy(resources); | ||
74 | MemberGroupRepository.save(MemberGroup); | ||
75 | } | ||
76 | |||
77 | @Override | ||
78 | @Transactional(rollbackFor = Exception.class) | ||
79 | public void delete(Long id) { | ||
80 | Assert.notNull(id, "The given id must not be null!"); | ||
81 | MemberGroup MemberGroup = MemberGroupRepository.findById(id).orElseThrow( | ||
82 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberGroup.class, id), 1)); | ||
83 | MemberGroupRepository.delete(MemberGroup); | ||
84 | } | ||
85 | |||
86 | |||
87 | } |
1 | package com.topdraw.business.basicdata.member.group.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.member.group.domain.MemberGroup; | ||
5 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-11-17 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberGroupMapper extends BaseMapper<MemberGroupDTO, MemberGroup> { | ||
15 | |||
16 | } |
... | @@ -9,6 +9,7 @@ import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; | ... | @@ -9,6 +9,7 @@ import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; |
9 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria; | 9 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria; |
10 | import com.topdraw.business.basicdata.member.level.service.mapper.MemberLevelMapper; | 10 | import com.topdraw.business.basicdata.member.level.service.mapper.MemberLevelMapper; |
11 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
12 | import org.springframework.cache.annotation.Cacheable; | ||
12 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
13 | import org.springframework.transaction.annotation.Propagation; | 14 | import org.springframework.transaction.annotation.Propagation; |
14 | import org.springframework.transaction.annotation.Transactional; | 15 | import org.springframework.transaction.annotation.Transactional; | ... | ... |
... | @@ -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 Long blackStatus; |
87 | } | 87 | } | ... | ... |
... | @@ -19,13 +19,18 @@ import org.redisson.api.RLock; | ... | @@ -19,13 +19,18 @@ 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.CacheConfig; | ||
22 | import org.springframework.cache.annotation.Cacheable; | 23 | import org.springframework.cache.annotation.Cacheable; |
23 | import org.springframework.dao.EmptyResultDataAccessException; | 24 | import org.springframework.dao.EmptyResultDataAccessException; |
24 | import org.springframework.data.domain.Page; | 25 | import org.springframework.data.domain.Page; |
25 | import org.springframework.data.domain.Pageable; | 26 | import org.springframework.data.domain.Pageable; |
26 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
28 | import org.springframework.transaction.PlatformTransactionManager; | ||
29 | import org.springframework.transaction.TransactionDefinition; | ||
30 | import org.springframework.transaction.TransactionStatus; | ||
27 | import org.springframework.transaction.annotation.Propagation; | 31 | import org.springframework.transaction.annotation.Propagation; |
28 | import org.springframework.transaction.annotation.Transactional; | 32 | import org.springframework.transaction.annotation.Transactional; |
33 | import org.springframework.transaction.support.DefaultTransactionDefinition; | ||
29 | import org.springframework.util.Assert; | 34 | import org.springframework.util.Assert; |
30 | 35 | ||
31 | import java.util.List; | 36 | import java.util.List; |
... | @@ -38,6 +43,7 @@ import java.util.Objects; | ... | @@ -38,6 +43,7 @@ import java.util.Objects; |
38 | */ | 43 | */ |
39 | @Service | 44 | @Service |
40 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 45 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
46 | //@CacheConfig(cacheNames = "uc-member-info") | ||
41 | public class MemberServiceImpl implements MemberService { | 47 | public class MemberServiceImpl implements MemberService { |
42 | 48 | ||
43 | @Autowired | 49 | @Autowired |
... | @@ -61,12 +67,12 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -61,12 +67,12 @@ public class MemberServiceImpl implements MemberService { |
61 | return memberMapper.toDto(memberRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | 67 | return memberMapper.toDto(memberRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
62 | } | 68 | } |
63 | 69 | ||
64 | // @Cacheable(cacheNames = "",key = "") | ||
65 | @Override | 70 | @Override |
66 | public MemberDTO findById(Long id) { | 71 | public MemberDTO findById(Long id) { |
67 | Member member = memberRepository.findById(id).orElseGet(Member::new); | 72 | Member member = memberRepository.findById(id).orElseGet(Member::new); |
68 | ValidationUtil.isNull(member.getId(),"Member","id",id); | 73 | ValidationUtil.isNull(member.getId(),"Member","id",id); |
69 | return memberMapper.toDto(member); | 74 | return memberMapper.toDto(member); |
75 | |||
70 | } | 76 | } |
71 | 77 | ||
72 | @Override | 78 | @Override |
... | @@ -99,6 +105,9 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -99,6 +105,9 @@ public class MemberServiceImpl implements MemberService { |
99 | return member; | 105 | return member; |
100 | } | 106 | } |
101 | 107 | ||
108 | @Autowired | ||
109 | PlatformTransactionManager platformTransactionManager; | ||
110 | |||
102 | @Override | 111 | @Override |
103 | @Transactional(rollbackFor = Exception.class) | 112 | @Transactional(rollbackFor = Exception.class) |
104 | @AsyncMqSend() | 113 | @AsyncMqSend() |
... | @@ -106,10 +115,18 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -106,10 +115,18 @@ public class MemberServiceImpl implements MemberService { |
106 | RLock rLock = this.redissonClient.getLock("updateMember" + resources.getId().toString()); | 115 | RLock rLock = this.redissonClient.getLock("updateMember" + resources.getId().toString()); |
107 | try { | 116 | try { |
108 | RedissonUtil.lock(rLock); | 117 | RedissonUtil.lock(rLock); |
118 | String name = Thread.currentThread().getName(); | ||
119 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> start ===>> "); | ||
120 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【resources】 ===>> " + resources); | ||
109 | Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new); | 121 | Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new); |
110 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | 122 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); |
123 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【member-search】 ===>> " + member); | ||
111 | member.copy(resources); | 124 | member.copy(resources); |
112 | memberRepository.save(member); | 125 | this.save(member); |
126 | // platformTransactionManager.commit(transaction); | ||
127 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【exp】 ===>> " + member.getExp()); | ||
128 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【point】 ===>> " + member.getPoints()); | ||
129 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【member】 ===>> " + member); | ||
113 | } catch (Exception e) { | 130 | } catch (Exception e) { |
114 | e.printStackTrace(); | 131 | e.printStackTrace(); |
115 | throw e; | 132 | throw e; |
... | @@ -118,6 +135,11 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -118,6 +135,11 @@ public class MemberServiceImpl implements MemberService { |
118 | } | 135 | } |
119 | } | 136 | } |
120 | 137 | ||
138 | @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
139 | public void save(Member member){ | ||
140 | memberRepository.save(member); | ||
141 | } | ||
142 | |||
121 | @Override | 143 | @Override |
122 | @Transactional(rollbackFor = Exception.class) | 144 | @Transactional(rollbackFor = Exception.class) |
123 | @AsyncMqSend() | 145 | @AsyncMqSend() | ... | ... |
... | @@ -75,7 +75,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable | ... | @@ -75,7 +75,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable |
75 | * @param memberId | 75 | * @param memberId |
76 | * @return | 76 | * @return |
77 | */ | 77 | */ |
78 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where upa.member_id = ?1 and upa.expire_time >= now()" | 78 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where upa.member_id = ?1 and upa.expire_time > now()" |
79 | ,nativeQuery = true) | 79 | ,nativeQuery = true) |
80 | Long findAvailablePointsByMemberId(long memberId); | 80 | Long findAvailablePointsByMemberId(long memberId); |
81 | 81 | ||
... | @@ -87,4 +87,10 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable | ... | @@ -87,4 +87,10 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable |
87 | void deleteBatchByIds(List<Long> id); | 87 | void deleteBatchByIds(List<Long> id); |
88 | 88 | ||
89 | List<PointsAvailable> findByExpireTimeBefore(Timestamp now); | 89 | List<PointsAvailable> findByExpireTimeBefore(Timestamp now); |
90 | |||
91 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where upa.member_id = ?1" | ||
92 | ,nativeQuery = true) | ||
93 | long findTotalCountByMemberId(Long memberId); | ||
94 | |||
95 | List<PointsAvailable> findByMemberIdAndExpireTimeAfter(Long memberId, Date timestamp); | ||
90 | } | 96 | } | ... | ... |
... | @@ -80,6 +80,8 @@ public interface PointsAvailableService { | ... | @@ -80,6 +80,8 @@ public interface PointsAvailableService { |
80 | */ | 80 | */ |
81 | List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, Date timestamp); | 81 | List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, Date timestamp); |
82 | 82 | ||
83 | List<PointsAvailableDTO> findByMemberIdAndExpireTimeAfter(Long memberId, Date timestamp); | ||
84 | |||
83 | /** | 85 | /** |
84 | * 即将过期的积分 | 86 | * 即将过期的积分 |
85 | * @param memberId 会员id | 87 | * @param memberId 会员id |
... | @@ -136,4 +138,6 @@ public interface PointsAvailableService { | ... | @@ -136,4 +138,6 @@ public interface PointsAvailableService { |
136 | 138 | ||
137 | 139 | ||
138 | List<PointsAvailableDTO> findByExpireTimeBefore(Timestamp now); | 140 | List<PointsAvailableDTO> findByExpireTimeBefore(Timestamp now); |
141 | |||
142 | long findTotalPointsByMemberId(Long memberId); | ||
139 | } | 143 | } | ... | ... |
... | @@ -127,6 +127,13 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -127,6 +127,13 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
127 | } | 127 | } |
128 | 128 | ||
129 | @Override | 129 | @Override |
130 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeAfter(Long memberId, Date timestamp) { | ||
131 | return Objects.nonNull(memberId)? | ||
132 | PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdAndExpireTimeAfter(memberId, timestamp)) | ||
133 | :null; | ||
134 | } | ||
135 | |||
136 | @Override | ||
130 | public Long findSoonExpireTime(Long memberId, Integer factor) { | 137 | public Long findSoonExpireTime(Long memberId, Integer factor) { |
131 | return PointsAvailableRepository.findSoonExpireTime(memberId, factor); | 138 | return PointsAvailableRepository.findSoonExpireTime(memberId, factor); |
132 | } | 139 | } |
... | @@ -163,4 +170,9 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -163,4 +170,9 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
163 | return PointsAvailableMapper.toDto(this.PointsAvailableRepository.findByExpireTimeBefore(now)); | 170 | return PointsAvailableMapper.toDto(this.PointsAvailableRepository.findByExpireTimeBefore(now)); |
164 | } | 171 | } |
165 | 172 | ||
173 | @Override | ||
174 | public long findTotalPointsByMemberId(Long memberId) { | ||
175 | return this.PointsAvailableRepository.findTotalCountByMemberId(memberId); | ||
176 | } | ||
177 | |||
166 | } | 178 | } | ... | ... |
... | @@ -20,7 +20,7 @@ import io.swagger.annotations.*; | ... | @@ -20,7 +20,7 @@ import io.swagger.annotations.*; |
20 | //@RequestMapping("/api/Points") | 20 | //@RequestMapping("/api/Points") |
21 | public class PointsController { | 21 | public class PointsController { |
22 | 22 | ||
23 | /* @Autowired | 23 | /*@Autowired |
24 | private PointsService PointsService; | 24 | private PointsService PointsService; |
25 | 25 | ||
26 | @GetMapping | 26 | @GetMapping |
... | @@ -33,9 +33,9 @@ public class PointsController { | ... | @@ -33,9 +33,9 @@ public class PointsController { |
33 | @ApiOperation("查询所有Points") | 33 | @ApiOperation("查询所有Points") |
34 | public ResultInfo getPointss(PointsQueryCriteria criteria) { | 34 | public ResultInfo getPointss(PointsQueryCriteria criteria) { |
35 | return ResultInfo.success(PointsService.queryAll(criteria)); | 35 | return ResultInfo.success(PointsService.queryAll(criteria)); |
36 | } | 36 | }*/ |
37 | 37 | ||
38 | @Log | 38 | /*@Log |
39 | @PostMapping | 39 | @PostMapping |
40 | @ApiOperation("新增Points") | 40 | @ApiOperation("新增Points") |
41 | public ResultInfo create(@Validated @RequestBody Points resources) { | 41 | public ResultInfo create(@Validated @RequestBody Points resources) { | ... | ... |
... | @@ -9,6 +9,7 @@ import com.topdraw.business.basicdata.task.service.dto.TaskDTO; | ... | @@ -9,6 +9,7 @@ import com.topdraw.business.basicdata.task.service.dto.TaskDTO; |
9 | import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria; | 9 | import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria; |
10 | import com.topdraw.business.basicdata.task.service.mapper.TaskMapper; | 10 | import com.topdraw.business.basicdata.task.service.mapper.TaskMapper; |
11 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
12 | import org.springframework.cache.annotation.Cacheable; | ||
12 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
13 | import org.springframework.transaction.annotation.Propagation; | 14 | import org.springframework.transaction.annotation.Propagation; |
14 | import org.springframework.transaction.annotation.Transactional; | 15 | import org.springframework.transaction.annotation.Transactional; |
... | @@ -79,6 +80,7 @@ public class TaskServiceImpl implements TaskService { | ... | @@ -79,6 +80,7 @@ public class TaskServiceImpl implements TaskService { |
79 | TaskRepository.delete(Task); | 80 | TaskRepository.delete(Task); |
80 | } | 81 | } |
81 | 82 | ||
83 | // @Cacheable(cacheNames = "uc-admin_taskList" , key = "#taskTemplateId") | ||
82 | @Override | 84 | @Override |
83 | public List<Task> findByTemplateId(Long taskTemplateId) { | 85 | public List<Task> findByTemplateId(Long taskTemplateId) { |
84 | return Objects.nonNull(taskTemplateId) ? this.TaskRepository.findByTaskTemplateId(taskTemplateId) : null; | 86 | return Objects.nonNull(taskTemplateId) ? this.TaskRepository.findByTaskTemplateId(taskTemplateId) : null; | ... | ... |
... | @@ -87,12 +87,13 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { | ... | @@ -87,12 +87,13 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { |
87 | : new TaskTemplateDTO(); | 87 | : new TaskTemplateDTO(); |
88 | } | 88 | } |
89 | 89 | ||
90 | // @Cacheable(cacheNames = "uc.taskTemplate" , key = "event") | 90 | |
91 | @Override | 91 | @Override |
92 | public TaskTemplate findByEvent(String event) { | 92 | public TaskTemplate findByEvent(String event) { |
93 | return StringUtils.isNotEmpty(event) ? this.TaskTemplateRepository.findByEvent(event) : null; | 93 | return StringUtils.isNotEmpty(event) ? this.TaskTemplateRepository.findByEvent(event) : null; |
94 | } | 94 | } |
95 | 95 | ||
96 | // @Cacheable(cacheNames = "uc-admin_taskTemplate" , key = "#event") | ||
96 | @Override | 97 | @Override |
97 | public TaskTemplate findByType(Integer event) { | 98 | public TaskTemplate findByType(Integer event) { |
98 | return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null; | 99 | return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null; | ... | ... |
... | @@ -20,6 +20,14 @@ public class TempRights { | ... | @@ -20,6 +20,14 @@ public class TempRights { |
20 | @Transient | 20 | @Transient |
21 | protected Long id; | 21 | protected Long id; |
22 | 22 | ||
23 | /** 编号 */ | ||
24 | @Transient | ||
25 | protected String code; | ||
26 | |||
27 | /** 权益名称 */ | ||
28 | @Transient | ||
29 | protected String name; | ||
30 | |||
23 | /** 会员ID */ | 31 | /** 会员ID */ |
24 | @Transient | 32 | @Transient |
25 | @NotNull(message = "") | 33 | @NotNull(message = "") | ... | ... |
... | @@ -17,9 +17,13 @@ import org.slf4j.LoggerFactory; | ... | @@ -17,9 +17,13 @@ import org.slf4j.LoggerFactory; |
17 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
18 | import org.springframework.data.domain.Pageable; | 18 | import org.springframework.data.domain.Pageable; |
19 | import org.springframework.util.Assert; | 19 | import org.springframework.util.Assert; |
20 | import org.springframework.util.CollectionUtils; | ||
20 | import org.springframework.validation.annotation.Validated; | 21 | import org.springframework.validation.annotation.Validated; |
21 | import org.springframework.web.bind.annotation.*; | 22 | import org.springframework.web.bind.annotation.*; |
22 | 23 | ||
24 | import java.util.List; | ||
25 | import java.util.Objects; | ||
26 | |||
23 | /** | 27 | /** |
24 | * @author XiangHan | 28 | * @author XiangHan |
25 | * @date 2021-10-22 | 29 | * @date 2021-10-22 |
... | @@ -32,11 +36,11 @@ public class PointsOperationController { | ... | @@ -32,11 +36,11 @@ public class PointsOperationController { |
32 | private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class); | 36 | private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class); |
33 | 37 | ||
34 | @Autowired | 38 | @Autowired |
35 | private PointsOperationService pointsOperationService; | 39 | PointsOperationService pointsOperationService; |
36 | @Autowired | 40 | @Autowired |
37 | private PointsDetailService pointsDetailService; | 41 | PointsDetailService pointsDetailService; |
38 | @Autowired | 42 | @Autowired |
39 | private PointsAvailableService pointsAvailableService; | 43 | PointsAvailableService pointsAvailableService; |
40 | 44 | ||
41 | @GetMapping(value = "/pagePointsDetails") | 45 | @GetMapping(value = "/pagePointsDetails") |
42 | @ApiOperation("查询PointsDetail") | 46 | @ApiOperation("查询PointsDetail") |
... | @@ -56,10 +60,29 @@ public class PointsOperationController { | ... | @@ -56,10 +60,29 @@ public class PointsOperationController { |
56 | } | 60 | } |
57 | 61 | ||
58 | @Log | 62 | @Log |
63 | @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") | ||
64 | @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") | ||
65 | public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) { | ||
66 | Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id); | ||
67 | return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); | ||
68 | } | ||
69 | |||
70 | /*@Log | ||
71 | @PostMapping(value = "/cleanInvalidPointsAndCalculateCurrentPointsByMemberIds") | ||
72 | @ApiOperation("清除过期积分并计算总积分,管理端使用") | ||
73 | public ResultInfo cleanInvalidPointsAndCalculateCurrentPointsByMemberIds(List<Long> memberIds) { | ||
74 | if (!CollectionUtils.isEmpty(memberIds)) { | ||
75 | for (Long memberId : memberIds) { | ||
76 | this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(memberId); | ||
77 | } | ||
78 | } | ||
79 | return ResultInfo.success(); | ||
80 | }*/ | ||
81 | |||
82 | @Log | ||
59 | @PostMapping(value = "/grantPointsByManual") | 83 | @PostMapping(value = "/grantPointsByManual") |
60 | @ApiOperation("新增PointsDetail") | 84 | @ApiOperation("新增PointsDetail") |
61 | public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) { | 85 | public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) { |
62 | LOG.info("======>>>>> grantPointsByManual start"); | ||
63 | Long memberId = tempPoints.getMemberId(); | 86 | Long memberId = tempPoints.getMemberId(); |
64 | this.pointsOperationService.grantPointsByManual(memberId,tempPoints); | 87 | this.pointsOperationService.grantPointsByManual(memberId,tempPoints); |
65 | return ResultInfo.success(); | 88 | return ResultInfo.success(); | ... | ... |
... | @@ -5,6 +5,7 @@ import com.topdraw.business.basicdata.task.domain.Task; | ... | @@ -5,6 +5,7 @@ import com.topdraw.business.basicdata.task.domain.Task; |
5 | import com.topdraw.business.process.domian.TempPoints; | 5 | import com.topdraw.business.process.domian.TempPoints; |
6 | 6 | ||
7 | import java.util.List; | 7 | import java.util.List; |
8 | import java.util.Map; | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * @description 积分操作接口 | 11 | * @description 积分操作接口 |
... | @@ -34,13 +35,11 @@ public interface PointsOperationService { | ... | @@ -34,13 +35,11 @@ public interface PointsOperationService { |
34 | */ | 35 | */ |
35 | void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList); | 36 | void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList); |
36 | 37 | ||
37 | /** | ||
38 | * 清理过期的积分 | ||
39 | */ | ||
40 | void cleanInvalidAvailablePoints(); | ||
41 | 38 | ||
42 | /** | 39 | /** |
43 | * 清理过期的积分 | 40 | * 清理过期并计算可用总积分 |
41 | * @param memberId | ||
42 | * @return | ||
44 | */ | 43 | */ |
45 | void cleanInvalidAvailablePointsByMemberId(Long memberId); | 44 | Long cleanInvalidPointsAndCalculateCurrentPoints(Long memberId); |
46 | } | 45 | } | ... | ... |
... | @@ -19,10 +19,14 @@ import org.springframework.beans.factory.annotation.Autowired; | ... | @@ -19,10 +19,14 @@ import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 19 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
20 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
21 | 21 | ||
22 | import javax.annotation.Resource; | ||
22 | import java.sql.Timestamp; | 23 | import java.sql.Timestamp; |
23 | import java.time.LocalDateTime; | 24 | import java.time.LocalDateTime; |
25 | import java.util.HashMap; | ||
24 | import java.util.List; | 26 | import java.util.List; |
27 | import java.util.Map; | ||
25 | import java.util.Objects; | 28 | import java.util.Objects; |
29 | import java.util.concurrent.ConcurrentHashMap; | ||
26 | import java.util.concurrent.locks.ReentrantLock; | 30 | import java.util.concurrent.locks.ReentrantLock; |
27 | 31 | ||
28 | 32 | ||
... | @@ -45,9 +49,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -45,9 +49,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
45 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 49 | ThreadPoolTaskExecutor threadPoolTaskExecutor; |
46 | 50 | ||
47 | // 过期阀值(默认一个月) | 51 | // 过期阀值(默认一个月) |
48 | private static final Integer EXPIRE_FACTOR_MONTH = 1; | 52 | private static final Integer EXPIRE_FACTOR_DAY = 30; |
49 | |||
50 | |||
51 | 53 | ||
52 | @Override | 54 | @Override |
53 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { | 55 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { |
... | @@ -80,10 +82,10 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -80,10 +82,10 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
80 | * @param tempCoupon 领取的优惠券 | 82 | * @param tempCoupon 领取的优惠券 |
81 | */ | 83 | */ |
82 | private void refresh(TempCoupon tempCoupon) { | 84 | private void refresh(TempCoupon tempCoupon) { |
83 | // 1.保存优惠券领取、使用历史记录表 | 85 | // 1.更新会员优惠券数量 |
84 | this.threadPoolTaskExecutor.execute(()->this.doInsertCouponHistory(tempCoupon)); | ||
85 | // 2.更新会员优惠券数量 | ||
86 | this.refreshMemberCoupon(tempCoupon); | 86 | this.refreshMemberCoupon(tempCoupon); |
87 | // 2.保存优惠券领取、使用历史记录表 | ||
88 | this.doInsertCouponHistory(tempCoupon); | ||
87 | } | 89 | } |
88 | 90 | ||
89 | 91 | ||
... | @@ -92,17 +94,20 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -92,17 +94,20 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
92 | * @param tempCoupon 账号id | 94 | * @param tempCoupon 账号id |
93 | */ | 95 | */ |
94 | private void refreshMemberCoupon(TempCoupon tempCoupon) { | 96 | private void refreshMemberCoupon(TempCoupon tempCoupon) { |
95 | Long userId = tempCoupon.getUserId(); | 97 | // Long userId = tempCoupon.getUserId(); |
96 | Long memberId = tempCoupon.getMemberId(); | 98 | Long memberId = tempCoupon.getMemberId(); |
99 | Integer rightsAmount = tempCoupon.getRightsAmount(); | ||
97 | RLock rLock = this.redissonClient.getLock("refreshMemberCoupon:" + memberId.toString()); | 100 | RLock rLock = this.redissonClient.getLock("refreshMemberCoupon:" + memberId.toString()); |
98 | try { | 101 | try { |
99 | RedissonUtil.lock(rLock); | 102 | RedissonUtil.lock(rLock); |
100 | // 1.获取用户领取的总优惠券 | 103 | // 1.历史总优惠券数量 |
101 | Long totalCouponCount = this.getTotalCoupon(userId); | 104 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); |
105 | // 1.当前总优惠券数量 | ||
106 | Long totalCouponCount = this.getTotalCoupon(historyCouponCount,rightsAmount); | ||
102 | // 2.获取已过期的优惠券数量 | 107 | // 2.获取已过期的优惠券数量 |
103 | Long expireCouponCount = this.getTotalExpireCoupon(userId); | 108 | Long expireCouponCount = this.getTotalExpireCoupon(memberId); |
104 | // 3.即将过期的优惠券数量 | 109 | // 3.即将过期的优惠券数量 |
105 | Long expireSoonCouponCount = this.getTotalExpireSoonCoupon(userId,EXPIRE_FACTOR_MONTH); | 110 | Long expireSoonCouponCount = this.getTotalExpireSoonCoupon(memberId,EXPIRE_FACTOR_DAY); |
106 | // 4.当前优惠券数量 = 总优惠券-已过期的优惠券 | 111 | // 4.当前优惠券数量 = 总优惠券-已过期的优惠券 |
107 | Long currentCoupon = this.getCurrentCoupon(totalCouponCount,expireCouponCount); | 112 | Long currentCoupon = this.getCurrentCoupon(totalCouponCount,expireCouponCount); |
108 | // 5.更新用户信息(优惠券数量、即将过期的优惠券数量) | 113 | // 5.更新用户信息(优惠券数量、即将过期的优惠券数量) |
... | @@ -115,6 +120,10 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -115,6 +120,10 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
115 | } | 120 | } |
116 | } | 121 | } |
117 | 122 | ||
123 | private Long getTotalCoupon(Long historyCouponCount, Integer rightsAmount) { | ||
124 | return (Objects.nonNull(historyCouponCount) ? historyCouponCount: 0L) + (Objects.nonNull(rightsAmount) ? rightsAmount: 0L); | ||
125 | } | ||
126 | |||
118 | 127 | ||
119 | /** | 128 | /** |
120 | * 更新当前用户优惠券信息 | 129 | * 更新当前用户优惠券信息 |
... | @@ -149,28 +158,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -149,28 +158,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
149 | * @return | 158 | * @return |
150 | */ | 159 | */ |
151 | private Long getTotalExpireSoonCoupon(Long userId, Integer expireFactor) { | 160 | private Long getTotalExpireSoonCoupon(Long userId, Integer expireFactor) { |
152 | LocalDateTime localDateTime = LocalDateTime.now(); | 161 | Timestamp expireTime = TimestampUtil.localDateTime2Timestamp(LocalDateTime.now().plusDays(expireFactor)); |
153 | String s = EXPIRE_FACTOR_MONTH.toString(); | ||
154 | String[] s1 = s.split("_"); | ||
155 | String s2 = s1[s1.length-1]; | ||
156 | switch (s2) { | ||
157 | case "YEAR": | ||
158 | localDateTime.plusYears(expireFactor); | ||
159 | break; | ||
160 | case "MONTH": | ||
161 | localDateTime.plusMonths(expireFactor); | ||
162 | break; | ||
163 | case "DAY": | ||
164 | localDateTime.plusDays(expireFactor); | ||
165 | break; | ||
166 | case "HOUR": | ||
167 | localDateTime.plusHours(expireFactor); | ||
168 | break; | ||
169 | default: | ||
170 | break; | ||
171 | } | ||
172 | |||
173 | Timestamp expireTime = TimestampUtil.now(localDateTime); | ||
174 | return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,TimestampUtil.now(),expireTime); | 162 | return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,TimestampUtil.now(),expireTime); |
175 | } | 163 | } |
176 | 164 | ||
... | @@ -190,7 +178,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -190,7 +178,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
190 | * @param userId | 178 | * @param userId |
191 | * @return | 179 | * @return |
192 | */ | 180 | */ |
193 | private Long getTotalCoupon(Long userId) { | 181 | private Long getTotalHistoryCoupon(Long userId) { |
194 | return this.couponHistoryService.countByUserId(userId); | 182 | return this.couponHistoryService.countByUserId(userId); |
195 | } | 183 | } |
196 | 184 | ||
... | @@ -204,10 +192,12 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -204,10 +192,12 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
204 | BeanUtils.copyProperties(tempCoupon,couponHistory); | 192 | BeanUtils.copyProperties(tempCoupon,couponHistory); |
205 | couponHistory.setId(null); | 193 | couponHistory.setId(null); |
206 | couponHistory.setCouponId(tempCoupon.getId()); | 194 | couponHistory.setCouponId(tempCoupon.getId()); |
207 | couponHistory.setUserId(tempCoupon.getUserId()); | 195 | couponHistory.setUserId(tempCoupon.getMemberId()); |
208 | couponHistory.setCouponCode(tempCoupon.getCode()); | 196 | couponHistory.setCouponCode(tempCoupon.getCode()); |
209 | couponHistory.setUserNickname(tempCoupon.getUserNickname()); | 197 | couponHistory.setUserNickname(tempCoupon.getUserNickname()); |
210 | couponHistory.setOrderDetailId(tempCoupon.getOrderId()); | 198 | couponHistory.setOrderDetailId(tempCoupon.getOrderId()); |
199 | couponHistory.setReceiveTime(TimestampUtil.now()); | ||
200 | couponHistory.setUseStatus(Objects.nonNull(couponHistory.getUseStatus()) ? couponHistory.getUseStatus():0); | ||
211 | this.couponHistoryService.create(couponHistory); | 201 | this.couponHistoryService.create(couponHistory); |
212 | } | 202 | } |
213 | 203 | ... | ... |
... | @@ -43,7 +43,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -43,7 +43,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
43 | MemberLevelService memberLevelService; | 43 | MemberLevelService memberLevelService; |
44 | @Autowired | 44 | @Autowired |
45 | RedissonClient redissonClient; | 45 | RedissonClient redissonClient; |
46 | @Resource(name = "executorTask") | 46 | @Autowired |
47 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 47 | ThreadPoolTaskExecutor threadPoolTaskExecutor; |
48 | 48 | ||
49 | @Override | 49 | @Override |
... | @@ -75,18 +75,19 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -75,18 +75,19 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
75 | * @param tempExp | 75 | * @param tempExp |
76 | */ | 76 | */ |
77 | private void refresh(TempExp tempExp) { | 77 | private void refresh(TempExp tempExp) { |
78 | RLock lock = this.redissonClient.getLock("refresh_exp:" + tempExp.getMemberId()); | 78 | RLock lock = this.redissonClient.getLock("uc-refresh-exp:" + tempExp.getMemberId()); |
79 | try { | 79 | try { |
80 | RedissonUtil.lock(lock); | 80 | RedissonUtil.lock(lock); |
81 | // 原始积分 | 81 | // 原始积分 |
82 | long originExp = this.getExpByMemberId(tempExp); | 82 | long originExp = this.getExpByMemberId(tempExp); |
83 | // 总积分 | 83 | // 总积分 |
84 | long totalExp = this.calculateTotalExp(originExp, tempExp); | 84 | long totalExp = this.calculateTotalExp(originExp, tempExp); |
85 | |||
86 | // 1.添加成长值记录 | 85 | // 1.添加成长值记录 |
87 | this.threadPoolTaskExecutor.execute(() -> this.doInsertExpDetail(tempExp, originExp, totalExp)); | 86 | // this.threadPoolTaskExecutor.execute(() -> this.doInsertExpDetail(tempExp, originExp, totalExp)); |
88 | // 2.更新成长值与等级 | 87 | // 2.更新成长值与等级 |
89 | this.refreshMemberExpAndLevel(tempExp); | 88 | this.refreshMemberExpAndLevel(tempExp,totalExp); |
89 | |||
90 | this.doInsertExpDetail(tempExp, originExp, totalExp); | ||
90 | 91 | ||
91 | } catch (Exception e) { | 92 | } catch (Exception e) { |
92 | e.printStackTrace(); | 93 | e.printStackTrace(); |
... | @@ -98,7 +99,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -98,7 +99,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
98 | 99 | ||
99 | private long calculateTotalExp(long originalExp,TempExp tempExp) { | 100 | private long calculateTotalExp(long originalExp,TempExp tempExp) { |
100 | Long rewardExp = tempExp.getRewardExp(); | 101 | Long rewardExp = tempExp.getRewardExp(); |
101 | return (Objects.nonNull(rewardExp) ? rewardExp : 0L) + (Objects.nonNull(originalExp) ? originalExp : 0L); | 102 | return rewardExp + originalExp; |
102 | } | 103 | } |
103 | 104 | ||
104 | private long getExpByMemberId(TempExp tempExp) { | 105 | private long getExpByMemberId(TempExp tempExp) { |
... | @@ -114,57 +115,43 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -114,57 +115,43 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
114 | * | 115 | * |
115 | * @param tempExp 成长值列表 | 116 | * @param tempExp 成长值列表 |
116 | */ | 117 | */ |
117 | private void refreshMemberExpAndLevel(TempExp tempExp) { | 118 | private void refreshMemberExpAndLevel(TempExp tempExp,long totalExp) { |
118 | 119 | ||
119 | Long memberId = tempExp.getMemberId(); | 120 | Long memberId = tempExp.getMemberId(); |
120 | |||
121 | RLock rLock = this.redissonClient.getLock("refreshMemberExpAndLevel" + memberId.toString()); | ||
122 | try { | ||
123 | RedissonUtil.lock(rLock); | ||
124 | // 1.获取当前成长值 | 121 | // 1.获取当前成长值 |
125 | MemberDTO memberDTO = this.getMemberInfoByMemberId(memberId); | 122 | MemberDTO memberDTO = this.getMemberInfoByMemberId(memberId); |
126 | // 2.获取下一级需要的成长值 | 123 | // 2.获取下一级需要的成长值 |
127 | MemberLevelDTO memberLevelDTO = this.getNextLevelExp(memberDTO.getLevel() + 1, 1); | 124 | MemberLevelDTO memberLevelDTO = this.getNextLevelExp(memberDTO.getLevel() + 1, 1); |
128 | // 3.成长值累加 | ||
129 | Long newExp = memberDTO.getExp() + tempExp.getRewardExp(); | ||
130 | // 4.成长值比较,判断是否升级 | 125 | // 4.成长值比较,判断是否升级 |
131 | long i = this.compareExp(newExp, memberLevelDTO); | 126 | Integer level = this.compareExp(totalExp, memberLevelDTO,memberDTO); |
132 | // 5.更新用户信息 | 127 | // 5.更新用户信息 |
133 | this.updateMemberInfo(i, newExp, memberLevelDTO, memberId); | 128 | this.updateMemberInfo(level, totalExp, memberId); |
134 | } catch (Exception e) { | ||
135 | e.printStackTrace(); | ||
136 | throw e; | ||
137 | } finally { | ||
138 | RedissonUtil.unlock(rLock); | ||
139 | } | ||
140 | } | 129 | } |
141 | 130 | ||
142 | /** | 131 | /** |
143 | * | 132 | * |
144 | * @param i | 133 | * @param level |
145 | * @param newExp 总积分 | 134 | * @param totalExp 总积分 |
146 | * @param memberLevelDTO 下一级 | ||
147 | * @param memberId 会员id | 135 | * @param memberId 会员id |
148 | */ | 136 | */ |
149 | private void updateMemberInfo(long i,Long newExp,MemberLevelDTO memberLevelDTO,Long memberId) { | 137 | private void updateMemberInfo(Integer level,Long totalExp,Long memberId) { |
150 | Member member = new Member(); | 138 | Member member = new Member(); |
151 | member.setId(memberId); | 139 | member.setId(memberId); |
152 | member.setExp(newExp); | 140 | member.setExp(totalExp); |
153 | if (i > 0) { | ||
154 | Integer level = memberLevelDTO.getLevel(); | ||
155 | member.setLevel(level); | 141 | member.setLevel(level); |
156 | } | ||
157 | member.setUpdateTime(TimestampUtil.now()); | 142 | member.setUpdateTime(TimestampUtil.now()); |
158 | this.memberOperationService.doUpdateMemberInfo(member); | 143 | this.memberOperationService.doUpdateMemberInfo(member); |
159 | } | 144 | } |
160 | 145 | ||
161 | private long compareExp(long newExp, MemberLevelDTO memberLevelDTO) { | 146 | private Integer compareExp(long newExp, MemberLevelDTO memberLevelDTO,MemberDTO memberDTO) { |
162 | if (Objects.nonNull(memberLevelDTO)) { | 147 | if (Objects.nonNull(memberLevelDTO)) { |
163 | Long nextLevelExp = memberLevelDTO.getExpValue(); | 148 | Long nextLevelExp = memberLevelDTO.getExpValue(); |
164 | if (Objects.nonNull(nextLevelExp) && nextLevelExp > 0) | 149 | if (Objects.nonNull(nextLevelExp) && nextLevelExp > 0) |
165 | return newExp - nextLevelExp; | 150 | if(newExp - nextLevelExp >= 0){ |
151 | return memberLevelDTO.getLevel(); | ||
152 | } | ||
166 | } | 153 | } |
167 | return -1; | 154 | return memberDTO.getLevel(); |
168 | } | 155 | } |
169 | 156 | ||
170 | private MemberLevelDTO getNextLevelExp(Integer i,Integer status) { | 157 | private MemberLevelDTO getNextLevelExp(Integer i,Integer status) { |
... | @@ -200,7 +187,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -200,7 +187,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
200 | 187 | ||
201 | expDetail.setCode(String.valueOf(IdWorker.generator())); | 188 | expDetail.setCode(String.valueOf(IdWorker.generator())); |
202 | // 原始积分 | 189 | // 原始积分 |
203 | expDetail.setOriginalExp(Objects.nonNull(originalExp) ? originalExp : 0L); | 190 | expDetail.setOriginalExp(originalExp); |
204 | // 总积分 | 191 | // 总积分 |
205 | expDetail.setResultExp(totalExp); | 192 | expDetail.setResultExp(totalExp); |
206 | // 获得的积分 | 193 | // 获得的积分 | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
... | @@ -22,11 +22,10 @@ public class RedissonConfig { | ... | @@ -22,11 +22,10 @@ public class RedissonConfig { |
22 | private String password; | 22 | private String password; |
23 | 23 | ||
24 | @Bean | 24 | @Bean |
25 | public RedissonClient redisson(){ | 25 | public Redisson redisson(){ |
26 | Config config = new Config(); | 26 | Config config = new Config(); |
27 | // config.useSingleServer().setAddress("redis://"+redisHost+":"+port).setPassword("redis123"); | ||
28 | if (StringUtils.isNotEmpty(password)) { | 27 | if (StringUtils.isNotEmpty(password)) { |
29 | config.useSingleServer().setAddress("redis://"+redisHost+":"+port).setPassword(password);; | 28 | config.useSingleServer().setAddress("redis://"+redisHost+":"+port).setPassword(password); |
30 | } else { | 29 | } else { |
31 | config.useSingleServer().setAddress("redis://"+redisHost+":"+port); | 30 | config.useSingleServer().setAddress("redis://"+redisHost+":"+port); |
32 | } | 31 | } |
... | @@ -34,7 +33,8 @@ public class RedissonConfig { | ... | @@ -34,7 +33,8 @@ public class RedissonConfig { |
34 | "redis://172.29.3.245:6375","redis://172.29.3.245:6376", "redis://172.29.3.245:6377", | 33 | "redis://172.29.3.245:6375","redis://172.29.3.245:6376", "redis://172.29.3.245:6377", |
35 | "redis://172.29.3.245:6378","redis://172.29.3.245:6i379", "redis://172.29.3.245:6380") | 34 | "redis://172.29.3.245:6378","redis://172.29.3.245:6i379", "redis://172.29.3.245:6380") |
36 | .setPassword("a123456").setScanInterval(5000);*/ | 35 | .setPassword("a123456").setScanInterval(5000);*/ |
37 | return Redisson.create(config); | 36 | Redisson redissonClient = (Redisson)Redisson.create(config); |
37 | return redissonClient; | ||
38 | } | 38 | } |
39 | 39 | ||
40 | } | 40 | } | ... | ... |
... | @@ -11,13 +11,12 @@ import org.springframework.stereotype.Component; | ... | @@ -11,13 +11,12 @@ import org.springframework.stereotype.Component; |
11 | 11 | ||
12 | import java.util.concurrent.ThreadPoolExecutor; | 12 | import java.util.concurrent.ThreadPoolExecutor; |
13 | 13 | ||
14 | @Configuration | 14 | /*@Configuration |
15 | @PropertySource(value = {"classpath:executor.properties"}, ignoreResourceNotFound=false, encoding="UTF-8") | 15 | @PropertySource(value = {"classpath:executor.properties"}, ignoreResourceNotFound=false, encoding="UTF-8") |
16 | @Slf4j | 16 | @Slf4j*/ |
17 | @EnableAsync | ||
18 | public class ThreadPoolTaskExecutorConfig { | 17 | public class ThreadPoolTaskExecutorConfig { |
19 | 18 | ||
20 | @Value("${threadPoolExecutor.core_pool_size}") | 19 | /*@Value("${threadPoolExecutor.core_pool_size}") |
21 | private int corePoolSize; | 20 | private int corePoolSize; |
22 | @Value("${threadPoolExecutor.max_pool_size}") | 21 | @Value("${threadPoolExecutor.max_pool_size}") |
23 | private int maxPoolSize; | 22 | private int maxPoolSize; |
... | @@ -28,7 +27,7 @@ public class ThreadPoolTaskExecutorConfig { | ... | @@ -28,7 +27,7 @@ public class ThreadPoolTaskExecutorConfig { |
28 | @Value("${threadPoolExecutor.keep_alive_seconds}") | 27 | @Value("${threadPoolExecutor.keep_alive_seconds}") |
29 | private int keepAliveSeconds; | 28 | private int keepAliveSeconds; |
30 | 29 | ||
31 | @Bean(value = "executorTask") | 30 | @Bean |
32 | public ThreadPoolTaskExecutor executorTask(){ | 31 | public ThreadPoolTaskExecutor executorTask(){ |
33 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | 32 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
34 | // 核心线程数 | 33 | // 核心线程数 |
... | @@ -46,6 +45,6 @@ public class ThreadPoolTaskExecutorConfig { | ... | @@ -46,6 +45,6 @@ public class ThreadPoolTaskExecutorConfig { |
46 | // 线程初始化 | 45 | // 线程初始化 |
47 | executor.initialize(); | 46 | executor.initialize(); |
48 | return executor; | 47 | return executor; |
49 | } | 48 | }*/ |
50 | 49 | ||
51 | } | 50 | } | ... | ... |
... | @@ -31,12 +31,12 @@ public class RabbitMqConfig { | ... | @@ -31,12 +31,12 @@ public class RabbitMqConfig { |
31 | } | 31 | } |
32 | 32 | ||
33 | @Bean | 33 | @Bean |
34 | Binding fanoutExchangeBindingIptv(FanoutExchange ucFanoutExchange , Queue ucFanoutQueueIptv){ | 34 | Binding fanoutExchangeBindingIptv(FanoutExchange ucFanoutExchange , Queue ucFanoutQueueIptv) { |
35 | return BindingBuilder.bind(ucFanoutQueueIptv).to(ucFanoutExchange); | 35 | return BindingBuilder.bind(ucFanoutQueueIptv).to(ucFanoutExchange); |
36 | } | 36 | } |
37 | 37 | ||
38 | @Bean | 38 | @Bean |
39 | Binding fanoutExchangeBindingWeiXin(FanoutExchange ucFanoutExchange , Queue ucFanoutQueueWeiXin){ | 39 | Binding fanoutExchangeBindingWeiXin(FanoutExchange ucFanoutExchange , Queue ucFanoutQueueWeiXin) { |
40 | return BindingBuilder.bind(ucFanoutQueueWeiXin).to(ucFanoutExchange); | 40 | return BindingBuilder.bind(ucFanoutQueueWeiXin).to(ucFanoutExchange); |
41 | } | 41 | } |
42 | 42 | ... | ... |
... | @@ -8,7 +8,7 @@ public class LocalDateTimeUtil { | ... | @@ -8,7 +8,7 @@ public class LocalDateTimeUtil { |
8 | public static String todayStart() { | 8 | public static String todayStart() { |
9 | LocalDate now = LocalDate.now(); | 9 | LocalDate now = LocalDate.now(); |
10 | 10 | ||
11 | return now+" 00:00:00"; | 11 | return now.toString(); |
12 | } | 12 | } |
13 | 13 | ||
14 | public static String todayEnd() { | 14 | public static String todayEnd() { | ... | ... |
... | @@ -3,6 +3,7 @@ package com.topdraw.util; | ... | @@ -3,6 +3,7 @@ package com.topdraw.util; |
3 | import java.sql.Timestamp; | 3 | import java.sql.Timestamp; |
4 | import java.time.Instant; | 4 | import java.time.Instant; |
5 | import java.time.LocalDateTime; | 5 | import java.time.LocalDateTime; |
6 | import java.time.ZoneId; | ||
6 | import java.time.ZoneOffset; | 7 | import java.time.ZoneOffset; |
7 | 8 | ||
8 | public class TimestampUtil { | 9 | public class TimestampUtil { |
... | @@ -12,29 +13,46 @@ public class TimestampUtil { | ... | @@ -12,29 +13,46 @@ public class TimestampUtil { |
12 | } | 13 | } |
13 | 14 | ||
14 | public static Timestamp now(LocalDateTime localDateTime) { | 15 | public static Timestamp now(LocalDateTime localDateTime) { |
15 | long epochSecond = localDateTime.toInstant(ZoneOffset.of("+8")).getEpochSecond(); | 16 | long epochSecond = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
16 | return new Timestamp(epochSecond); | 17 | return new Timestamp(epochSecond); |
17 | } | 18 | } |
18 | 19 | ||
19 | public static long localDateTime2Timestamp(LocalDateTime localDateTime){ | 20 | public static long localDateTime2long(LocalDateTime localDateTime){ |
20 | long epochSecond = localDateTime.atZone(ZoneOffset.systemDefault()).toEpochSecond(); | 21 | long epochSecond = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
21 | return epochSecond; | 22 | return epochSecond; |
22 | } | 23 | } |
23 | 24 | ||
25 | public static Timestamp localDateTime2Timestamp(LocalDateTime localDateTime){ | ||
26 | long epochSecond = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); | ||
27 | return long2Timestamp(epochSecond); | ||
28 | } | ||
24 | public static Timestamp long2Timestamp(long timestamp){ | 29 | public static Timestamp long2Timestamp(long timestamp){ |
25 | Timestamp timestamp1 = Timestamp.from(Instant.ofEpochSecond(timestamp)); | 30 | Timestamp timestamp1 = Timestamp.from(Instant.ofEpochMilli(timestamp)); |
26 | return timestamp1; | 31 | return timestamp1; |
27 | } | 32 | } |
28 | 33 | ||
29 | public static long Timestamp2long(Timestamp timestamp){ | 34 | public static long timestamp2long(Timestamp timestamp){ |
30 | return timestamp.toInstant().getEpochSecond(); | 35 | long l = timestamp.toInstant().toEpochMilli(); |
36 | return l; | ||
31 | } | 37 | } |
32 | 38 | ||
33 | public static void main(String[] args) { | 39 | public static void main(String[] args) { |
34 | LocalDateTime of = LocalDateTime.of(2021, 10, 28, 11, 00, 00); | 40 | long a = 1636616464000L; |
35 | long l = localDateTime2Timestamp(of); | 41 | long b = 1637046948588L; |
42 | long c = 1637047122176L; | ||
43 | // long l = 16342727230L; | ||
44 | // Timestamp now = now(LocalDateTime.now()); | ||
45 | long l = localDateTime2long(LocalDateTime.now()); | ||
46 | System.out.println(l); | ||
47 | // System.out.println(now.toString()); | ||
48 | |||
49 | Timestamp timestamp1 = long2Timestamp(a); | ||
50 | // long l = localDateTime2Timestamp(of); | ||
36 | // long l = 16342727230L; | 51 | // long l = 16342727230L; |
37 | Timestamp timestamp = long2Timestamp(l); | 52 | // Timestamp timestamp = long2Timestamp(l); |
38 | System.out.println(timestamp.toString()); | 53 | System.out.println(timestamp1.toString()); |
54 | |||
55 | long l1 = localDateTime2long(LocalDateTime.now()); | ||
56 | System.out.println(l1); | ||
39 | } | 57 | } |
40 | } | 58 | } | ... | ... |
1 | package com.topdraw.util; | ||
2 | |||
3 | import java.util.Arrays; | ||
4 | import java.util.List; | ||
5 | import java.util.stream.Collectors; | ||
6 | |||
7 | public class UcStringUtils { | ||
8 | |||
9 | |||
10 | public static List<String> parse2StrList(String resouce){ | ||
11 | String[] split = resouce.split(","); | ||
12 | if (split.length > 0) { | ||
13 | List<String> collect = Arrays.stream(resouce.split(",")).collect(Collectors.toList()); | ||
14 | return collect; | ||
15 | } else { | ||
16 | List<String> strings = Arrays.asList(resouce); | ||
17 | return strings; | ||
18 | } | ||
19 | } | ||
20 | |||
21 | } |
... | @@ -2,12 +2,15 @@ | ... | @@ -2,12 +2,15 @@ |
2 | spring: | 2 | spring: |
3 | datasource: | 3 | datasource: |
4 | # 测试/演示库 | 4 | # 测试/演示库 |
5 | url: jdbc:log4jdbc:mysql://139.196.192.242:3306/tj_user_0819?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | 5 | # url: jdbc:log4jdbc:mysql://139.196.192.242:3306/tj_user_0819?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false |
6 | # username: root | ||
7 | # password: Tjlh@2017 | ||
8 | |||
9 | url: jdbc:log4jdbc:mysql://47.100.212.170:3306/ucs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
6 | username: root | 10 | username: root |
7 | password: Tjlh@2017 | 11 | password: Tjlh@2021 |
8 | 12 | ||
9 | # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | 13 | # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false |
10 | # url: jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
11 | # username: root | 14 | # username: root |
12 | # password: root | 15 | # password: root |
13 | driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy | 16 | driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy | ... | ... |
... | @@ -2,14 +2,9 @@ | ... | @@ -2,14 +2,9 @@ |
2 | spring: | 2 | spring: |
3 | datasource: | 3 | datasource: |
4 | # 测试/演示库 | 4 | # 测试/演示库 |
5 | url: jdbc:log4jdbc:mysql://139.196.192.242:3306/tj_user_0819?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | 5 | url: jdbc:log4jdbc:mysql://172.0.31.10:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false |
6 | username: root | 6 | username: root |
7 | password: Tjlh@2017 | 7 | password: Tjlh@2021 |
8 | |||
9 | # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
10 | # url: jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
11 | # username: root | ||
12 | # password: root | ||
13 | driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy | 8 | driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy |
14 | #Druid | 9 | #Druid |
15 | type: com.alibaba.druid.pool.DruidDataSource | 10 | type: com.alibaba.druid.pool.DruidDataSource |
... | @@ -53,24 +48,21 @@ spring: | ... | @@ -53,24 +48,21 @@ spring: |
53 | max-request-size: 200MB | 48 | max-request-size: 200MB |
54 | redis: | 49 | redis: |
55 | #数据库索引 | 50 | #数据库索引 |
56 | database: 16 | 51 | database: 0 |
57 | host: 122.112.214.149 | 52 | host: 127.0.0.1 |
58 | # host: 139.196.4.234 | ||
59 | port: 6379 | 53 | port: 6379 |
60 | password: redis123 | ||
61 | # password: | ||
62 | #连接超时时间 | 54 | #连接超时时间 |
63 | timeout: 5000 | 55 | timeout: 5000 |
64 | rabbitmq: | 56 | rabbitmq: |
65 | host: 122.112.214.149 # rabbitmq的连接地址 | 57 | host: 172.0.31.96 # rabbitmq的连接地址 |
66 | #host: 139.196.192.242 # rabbitmq的连接地址 | 58 | #host: 139.196.192.242 # rabbitmq的连接地址 |
67 | port: 5672 # rabbitmq的连接端口号 | 59 | port: 5672 # rabbitmq的连接端口号 |
68 | #virtual-host: /member_center # rabbitmq的虚拟host | 60 | #virtual-host: /member_center # rabbitmq的虚拟host |
69 | #username: member_center # rabbitmq的用户名 | 61 | #username: member_center # rabbitmq的用户名 |
70 | #password: Tjlh@2021 # rabbitmq的密码 | 62 | #password: Tjlh@2021 # rabbitmq的密码 |
71 | virtual-host: / # rabbitmq的虚拟host | 63 | virtual-host: member_center # rabbitmq的虚拟host |
72 | username: guest # rabbitmq的用户名 | 64 | username: admin # rabbitmq的用户名 |
73 | password: guest # rabbitmq的密码 | 65 | password: Tjlh@2021 # rabbitmq的密码 |
74 | publisher-confirms: true #如果对异步消息需要回调必须设置为true | 66 | publisher-confirms: true #如果对异步消息需要回调必须设置为true |
75 | 67 | ||
76 | #jwt。依赖的common中有需要jwt的部分属性。 | 68 | #jwt。依赖的common中有需要jwt的部分属性。 | ... | ... |
1 | server: | 1 | server: |
2 | port: 8447 | 2 | port: 8447 |
3 | |||
4 | spring: | 3 | spring: |
5 | application: | 4 | application: |
6 | name: member-service | 5 | name: member-service |
... | @@ -10,6 +9,8 @@ spring: | ... | @@ -10,6 +9,8 @@ spring: |
10 | active: dev | 9 | active: dev |
11 | jackson: | 10 | jackson: |
12 | time-zone: GMT+8 | 11 | time-zone: GMT+8 |
12 | cache: | ||
13 | type: simple | ||
13 | data: | 14 | data: |
14 | redis: | 15 | redis: |
15 | repositories: | 16 | repositories: | ... | ... |
... | @@ -39,16 +39,16 @@ public class GeneratorCode extends BaseTest { | ... | @@ -39,16 +39,16 @@ public class GeneratorCode extends BaseTest { |
39 | @Rollback(value = false) | 39 | @Rollback(value = false) |
40 | @Transactional(rollbackFor = Exception.class) | 40 | @Transactional(rollbackFor = Exception.class) |
41 | public void generator() { | 41 | public void generator() { |
42 | var dbName = "uc_tr_task_progress"; | 42 | var dbName = "uc_member_group"; |
43 | // 表名称,支持多表 | 43 | // 表名称,支持多表 |
44 | var tableNames = Arrays.asList(dbName); | 44 | var tableNames = Arrays.asList(dbName); |
45 | String[] s = dbName.split("_"); | 45 | String[] s = dbName.split("_"); |
46 | 46 | ||
47 | var pre = s[0]; | 47 | var pre = s[0]; |
48 | var target1 = s[s.length-1]; | 48 | var target1 = s[s.length-1]; |
49 | var preRoute = "com.topdraw.business.basicdata.task."; | 49 | var preRoute = "com.topdraw.business.basicdata.member."; |
50 | StringBuilder builder = new StringBuilder(preRoute); | 50 | StringBuilder builder = new StringBuilder(preRoute); |
51 | builder.append("progress"); | 51 | builder.append("group"); |
52 | // builder.append(target); | 52 | // builder.append(target); |
53 | 53 | ||
54 | tableNames.forEach(tableName -> { | 54 | tableNames.forEach(tableName -> { | ... | ... |
... | @@ -13,7 +13,7 @@ public class MemberServiceTest extends BaseTest { | ... | @@ -13,7 +13,7 @@ public class MemberServiceTest extends BaseTest { |
13 | 13 | ||
14 | @Test | 14 | @Test |
15 | public void findById(){ | 15 | public void findById(){ |
16 | Long memberId = 1L; | 16 | Long memberId = 3L; |
17 | MemberDTO memberDTO = this.memberService.findById(memberId); | 17 | MemberDTO memberDTO = this.memberService.findById(memberId); |
18 | LOG.info("=====>>>" + memberDTO); | 18 | LOG.info("=====>>>" + memberDTO); |
19 | 19 | ... | ... |
1 | package com.topdraw.test.business.basicdata.task; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.domain.Member; | ||
4 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
5 | import com.topdraw.business.basicdata.task.domain.Task; | ||
6 | import com.topdraw.business.basicdata.task.service.TaskService; | ||
7 | import com.topdraw.BaseTest; | ||
8 | import com.topdraw.business.process.service.impl.CompareTaskCondition; | ||
9 | import com.topdraw.util.IdWorker; | ||
10 | import com.topdraw.util.TimestampUtil; | ||
11 | import org.assertj.core.util.Arrays; | ||
12 | import org.junit.Assert; | ||
13 | import org.junit.Test; | ||
14 | import org.springframework.beans.factory.annotation.Autowired; | ||
15 | import org.springframework.util.CollectionUtils; | ||
16 | |||
17 | import java.sql.Timestamp; | ||
18 | import java.util.ArrayList; | ||
19 | import java.util.List; | ||
20 | import java.util.Objects; | ||
21 | import java.util.stream.Collectors; | ||
22 | |||
23 | //public class TaskServiceTest extends BaseTest { | ||
24 | public class TaskServiceTest { | ||
25 | |||
26 | @Test | ||
27 | public void dealTaskTest(){ | ||
28 | // List<Task> taskList = this.taskService.findByTemplateId(1L); | ||
29 | // LOG.info("=====>>>" + taskList); | ||
30 | Task task = new Task(); | ||
31 | task.setTaskTemplateId(1L); | ||
32 | task.setTaskDailyReset(1); | ||
33 | task.setActionAmount(1); | ||
34 | task.setValidTime(TimestampUtil.now()); | ||
35 | task.setExpireTime(TimestampUtil.now()); | ||
36 | task.setSequence(1); | ||
37 | task.setRewardExp(10L); | ||
38 | task.setRewardPoints(1L); | ||
39 | task.setRewardPointsExpireTime(TimestampUtil.Timestamp2long(TimestampUtil.now())); | ||
40 | task.setPointsType(1); | ||
41 | task.setRewardMaxPoints(1); | ||
42 | task.setGroups("groups"); | ||
43 | task.setRightsSendStrategy(1); | ||
44 | task.setMemberLevel(1); | ||
45 | task.setMemberVip(1); | ||
46 | task.setRightsId(1L); | ||
47 | task.setRightsAmount(1); | ||
48 | task.setRights2Id(2L); | ||
49 | task.setRights2Amount(1); | ||
50 | task.setRights3Id(3L); | ||
51 | task.setRights3Amount(1); | ||
52 | task.setStatus(1); | ||
53 | List<Task> taskList = new ArrayList<>(); | ||
54 | taskList.add(task); | ||
55 | |||
56 | MemberDTO member = new MemberDTO(); | ||
57 | member.setCode(String.valueOf(IdWorker.generator())); | ||
58 | member.setType(1); | ||
59 | member.setStatus(1); | ||
60 | member.setNickname("nickname"); | ||
61 | member.setDescription("description"); | ||
62 | member.setGender(1); | ||
63 | member.setBirthday("birthday"); | ||
64 | member.setAvatarUrl("avatarUrl"); | ||
65 | member.setGroups("groups"); | ||
66 | member.setTags("tags"); | ||
67 | member.setVip(1); | ||
68 | member.setLevel(1); | ||
69 | member.setExp(10L); | ||
70 | member.setPoints(5L); | ||
71 | member.setDuePoints(0L); | ||
72 | member.setCouponAmount(1L); | ||
73 | member.setDueCouponAmount(0L); | ||
74 | member.setUserIptvId(1L); | ||
75 | member.setBindIptvPlatformType(0); | ||
76 | member.setUpdateTime(TimestampUtil.now()); | ||
77 | |||
78 | // 判断是否完成任务 | ||
79 | CompareTaskCondition compareTaskCondition =(MemberDTO memberDTO1, List<Task> taskList1) -> { | ||
80 | |||
81 | List<Task> taskStream = taskList1.stream().filter(task1 -> | ||
82 | task1.getStatus() == 1 && | ||
83 | (Objects.isNull(task1.getExpireTime()) || task1.getExpireTime().compareTo(TimestampUtil.now()) <= 0) && | ||
84 | (Objects.isNull(task1.getGroups()) || task1.getGroups().equalsIgnoreCase(memberDTO1.getGroups())) && | ||
85 | (Objects.isNull(task1.getValidTime()) || task1.getValidTime().compareTo(TimestampUtil.now()) <= 0) && | ||
86 | (task1.getMemberLevel() == 0 || task1.getMemberLevel() <= memberDTO1.getLevel()) && | ||
87 | (task1.getMemberVip() == 0 || task1.getMemberVip() == memberDTO1.getVip()) | ||
88 | ).collect(Collectors.toList()); | ||
89 | |||
90 | if (CollectionUtils.isEmpty(taskStream)) { | ||
91 | return false; | ||
92 | } | ||
93 | return true; | ||
94 | }; | ||
95 | boolean b = compareTaskCondition.compareCondition(member, taskList); | ||
96 | System.out.println(b); | ||
97 | } | ||
98 | } |
... | @@ -21,12 +21,11 @@ public class ExpOperationControllerTest extends BaseTest { | ... | @@ -21,12 +21,11 @@ public class ExpOperationControllerTest extends BaseTest { |
21 | 21 | ||
22 | @Test | 22 | @Test |
23 | public void grantExpByManual(){ | 23 | public void grantExpByManual(){ |
24 | Long memberId = 2L; | 24 | Long memberId = 3L; |
25 | Long userId = 2L; | 25 | Long userId = 2L; |
26 | TempExp tempExp = new TempExp(); | 26 | TempExp tempExp = new TempExp(); |
27 | tempExp.setMemberId(memberId); | 27 | tempExp.setMemberId(memberId); |
28 | tempExp.setRewardExp(10L); | 28 | tempExp.setRewardExp(10L); |
29 | tempExp.setMemberId(2L); | ||
30 | tempExp.setRightsSendStrategy(0); | 29 | tempExp.setRightsSendStrategy(0); |
31 | tempExp.setAccountId(userId); | 30 | tempExp.setAccountId(userId); |
32 | tempExp.setExpireTime(Timestamp.valueOf("2021-10-28 09:00:00")); | 31 | tempExp.setExpireTime(Timestamp.valueOf("2021-10-28 09:00:00")); | ... | ... |
... | @@ -53,25 +53,47 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -53,25 +53,47 @@ public class PointsOperationControllerTest extends BaseTest { |
53 | @Test | 53 | @Test |
54 | public void grantPointsByManual(){ | 54 | public void grantPointsByManual(){ |
55 | TempPoints tempPoints = new TempPoints(); | 55 | TempPoints tempPoints = new TempPoints(); |
56 | tempPoints.setMemberId(10L); | ||
56 | tempPoints.setPoints(10L); | 57 | tempPoints.setPoints(10L); |
57 | tempPoints.setPointsType(0); | 58 | tempPoints.setPointsType(0); |
58 | tempPoints.setMemberId(3L); | ||
59 | tempPoints.setRightsSendStrategy(0); | 59 | tempPoints.setRightsSendStrategy(0); |
60 | tempPoints.setAccountId(2L); | 60 | tempPoints.setAccountId(2L); |
61 | tempPoints.setExpireTime(Timestamp.valueOf("2021-10-27 09:00:00")); | 61 | tempPoints.setExpireTime(Timestamp.valueOf("2021-11-27 09:00:00")); |
62 | tempPoints.setDeviceType(2); | 62 | tempPoints.setDeviceType(2); |
63 | tempPoints.setAppCode("WEI_XIN_GOLD_PANDA"); | 63 | tempPoints.setAppCode("WEI_XIN_GOLD_PANDA"); |
64 | tempPoints.setOrderId(null); | 64 | tempPoints.setOrderId(null); |
65 | tempPoints.setMediaId(null); | 65 | tempPoints.setMediaId(null); |
66 | tempPoints.setActivityId(null); | 66 | tempPoints.setActivityId(null); |
67 | tempPoints.setItemId(null); | 67 | tempPoints.setItemId(null); |
68 | tempPoints.setDescription("#"); | 68 | tempPoints.setDescription("系统发放"); |
69 | tempPoints.setEvtType(1); | 69 | tempPoints.setEvtType(1); |
70 | String s = JSON.toJSONString(tempPoints); | 70 | String s = JSON.toJSONString(tempPoints); |
71 | ResultInfo byId = this.pointsOperationController.grantPointsByManual(tempPoints); | 71 | ResultInfo byId = this.pointsOperationController.grantPointsByManual(tempPoints); |
72 | LOG.info("===>>>"+byId); | 72 | LOG.info("===>>>"+byId); |
73 | } | 73 | } |
74 | 74 | ||
75 | @Test | ||
76 | public void cleanInvalidPointsAndCalculateCurrentPoints(){ | ||
77 | /*TempPoints tempPoints = new TempPoints(); | ||
78 | tempPoints.setMemberId(5L); | ||
79 | tempPoints.setPoints(10L); | ||
80 | tempPoints.setPointsType(0); | ||
81 | tempPoints.setRightsSendStrategy(0); | ||
82 | tempPoints.setAccountId(2L); | ||
83 | tempPoints.setExpireTime(Timestamp.valueOf("2021-11-27 09:00:00")); | ||
84 | tempPoints.setDeviceType(2); | ||
85 | tempPoints.setAppCode("WEI_XIN_GOLD_PANDA"); | ||
86 | tempPoints.setOrderId(null); | ||
87 | tempPoints.setMediaId(null); | ||
88 | tempPoints.setActivityId(null); | ||
89 | tempPoints.setItemId(null); | ||
90 | tempPoints.setDescription("系统发放"); | ||
91 | tempPoints.setEvtType(1); | ||
92 | String s = JSON.toJSONString(tempPoints);*/ | ||
93 | ResultInfo byId = this.pointsOperationController.cleanInvalidPointsAndCalculateCurrentPoints(5L); | ||
94 | LOG.info("===>>>"+byId); | ||
95 | } | ||
96 | |||
75 | /*@Test | 97 | /*@Test |
76 | public void update(){ | 98 | public void update(){ |
77 | MemberAddress memberAddress = new MemberAddress(); | 99 | MemberAddress memberAddress = new MemberAddress(); | ... | ... |
... | @@ -18,7 +18,7 @@ public class RightOperationControllerTest extends BaseTest { | ... | @@ -18,7 +18,7 @@ public class RightOperationControllerTest extends BaseTest { |
18 | public void grantRightsByManual(){ | 18 | public void grantRightsByManual(){ |
19 | RightsHistory rightsHistory = new RightsHistory(); | 19 | RightsHistory rightsHistory = new RightsHistory(); |
20 | rightsHistory.setRightsId(1L); | 20 | rightsHistory.setRightsId(1L); |
21 | rightsHistory.setMemberId(5L); | 21 | rightsHistory.setMemberId(3L); |
22 | rightsHistory.setOperatorId(3L); | 22 | rightsHistory.setOperatorId(3L); |
23 | rightsHistory.setOperatorName("鲁二龙"); | 23 | rightsHistory.setOperatorName("鲁二龙"); |
24 | rightsHistory.setExpireTime(TimestampUtil.now()); | 24 | rightsHistory.setExpireTime(TimestampUtil.now()); | ... | ... |
... | @@ -8,8 +8,17 @@ import com.topdraw.module.mq.DataSyncMsg; | ... | @@ -8,8 +8,17 @@ import com.topdraw.module.mq.DataSyncMsg; |
8 | import com.topdraw.module.mq.EntityType; | 8 | import com.topdraw.module.mq.EntityType; |
9 | import com.topdraw.module.mq.EventType; | 9 | import com.topdraw.module.mq.EventType; |
10 | import com.topdraw.BaseTest; | 10 | import com.topdraw.BaseTest; |
11 | import com.topdraw.utils.StringUtils; | ||
11 | import org.junit.Test; | 12 | import org.junit.Test; |
12 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
15 | |||
16 | import javax.annotation.Resource; | ||
17 | import java.util.List; | ||
18 | import java.util.concurrent.ArrayBlockingQueue; | ||
19 | import java.util.concurrent.FutureTask; | ||
20 | import java.util.concurrent.ThreadPoolExecutor; | ||
21 | import java.util.concurrent.TimeUnit; | ||
13 | 22 | ||
14 | public class TaskOperationControllerTest extends BaseTest { | 23 | public class TaskOperationControllerTest extends BaseTest { |
15 | 24 | ||
... | @@ -20,11 +29,11 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -20,11 +29,11 @@ public class TaskOperationControllerTest extends BaseTest { |
20 | public void dealTask() { | 29 | public void dealTask() { |
21 | try { | 30 | try { |
22 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); | 31 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); |
23 | dataSyncMsg.setEventType(EventType.LOGIN.name()); | 32 | dataSyncMsg.setEventType(EventType.VIEWING.name()); |
24 | DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); | 33 | DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); |
25 | msgData.setEvent(1); | 34 | msgData.setEvent(6); // 类型 1-登录 2-观影 3-参加活动 4-订购 5-优享会员 6-签到 |
26 | msgData.setRemarks("remark"); | 35 | msgData.setRemarks("remark"); |
27 | msgData.setMemberId(3L); | 36 | msgData.setMemberId(4L); |
28 | msgData.setDeviceType(2); | 37 | msgData.setDeviceType(2); |
29 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); | 38 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); |
30 | dataSyncMsg.setMsg(msgData); | 39 | dataSyncMsg.setMsg(msgData); |
... | @@ -37,9 +46,72 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -37,9 +46,72 @@ public class TaskOperationControllerTest extends BaseTest { |
37 | } catch (Exception e) { | 46 | } catch (Exception e) { |
38 | e.printStackTrace(); | 47 | e.printStackTrace(); |
39 | } | 48 | } |
49 | } | ||
50 | |||
51 | |||
52 | @Autowired | ||
53 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
54 | |||
55 | |||
56 | |||
57 | public void t1() throws InterruptedException { | ||
58 | |||
59 | Thread.sleep(1*1000); | ||
60 | System.out.println(Thread.currentThread().getName()+"=======>>> t1"); | ||
61 | |||
62 | } | ||
63 | public void t2() throws InterruptedException { | ||
64 | |||
65 | Thread.sleep(1*1000); | ||
66 | System.out.println(Thread.currentThread().getName()+"=======>>> t2"); | ||
67 | |||
68 | } | ||
69 | public void t3() throws InterruptedException { | ||
70 | |||
71 | Thread.sleep(1*1000); | ||
72 | System.out.println(Thread.currentThread().getName()+"=======>>> t3"); | ||
40 | 73 | ||
41 | } | 74 | } |
42 | 75 | ||
76 | @Test | ||
77 | public void main() { | ||
78 | long l = System.currentTimeMillis(); | ||
79 | FutureTask futureTask1 = new FutureTask(()->{ | ||
80 | t1(); | ||
81 | return null; | ||
82 | }); | ||
83 | FutureTask futureTask2 = new FutureTask(()->{ | ||
84 | t2(); | ||
85 | return null; | ||
86 | }); | ||
87 | |||
88 | FutureTask futureTask3 = new FutureTask(()->{ | ||
89 | t3(); | ||
90 | return null; | ||
91 | }); | ||
92 | |||
93 | threadPoolTaskExecutor.execute(futureTask1); | ||
94 | threadPoolTaskExecutor.execute(futureTask2); | ||
95 | threadPoolTaskExecutor.execute(futureTask3); | ||
96 | |||
97 | long l1 = System.currentTimeMillis(); | ||
98 | System.out.println(l1-l); | ||
99 | /*threadPoolTaskExecutor.execute(()->{ | ||
100 | for (int i = 0; i < 10; i++) { | ||
101 | try { | ||
102 | // Thread.sleep(2*1000); | ||
103 | System.out.println("===>>>> "); | ||
104 | } catch (Exception e) { | ||
105 | e.printStackTrace(); | ||
106 | } | ||
107 | |||
108 | } | ||
109 | });*/ | ||
110 | |||
111 | System.out.println("======>>> main end"); | ||
112 | } | ||
113 | |||
114 | |||
43 | 115 | ||
44 | 116 | ||
45 | } | 117 | } | ... | ... |
... | @@ -46,7 +46,8 @@ public class PointsOperationServiceTest extends BaseTest { | ... | @@ -46,7 +46,8 @@ public class PointsOperationServiceTest extends BaseTest { |
46 | 46 | ||
47 | @Test | 47 | @Test |
48 | public void cleanInvalidAvailablePoints() { | 48 | public void cleanInvalidAvailablePoints() { |
49 | this.pointsOperationService.cleanInvalidAvailablePoints(); | 49 | Long memberId = 10L; |
50 | this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(memberId); | ||
50 | } | 51 | } |
51 | 52 | ||
52 | } | 53 | } | ... | ... |
-
Please register or sign in to post a comment