Merge tag '1.0.3' into develop
Tagging version 1.0.4 1.0.3
Showing
41 changed files
with
763 additions
and
257 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)") | ... | ... |
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 | } |
... | @@ -90,7 +90,6 @@ public class MemberLevelServiceImpl implements MemberLevelService { | ... | @@ -90,7 +90,6 @@ public class MemberLevelServiceImpl implements MemberLevelService { |
90 | : new MemberLevelDTO(); | 90 | : new MemberLevelDTO(); |
91 | } | 91 | } |
92 | 92 | ||
93 | @Cacheable(cacheNames = "uc-member_level",key = "#level") | ||
94 | @Override | 93 | @Override |
95 | public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) { | 94 | public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) { |
96 | return MemberLevelMapper.toDto(MemberLevelRepository.findByLevelAndStatus(level,status)); | 95 | return MemberLevelMapper.toDto(MemberLevelRepository.findByLevelAndStatus(level,status)); | ... | ... |
... | @@ -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) { | ... | ... |
... | @@ -80,7 +80,7 @@ public class TaskServiceImpl implements TaskService { | ... | @@ -80,7 +80,7 @@ public class TaskServiceImpl implements TaskService { |
80 | TaskRepository.delete(Task); | 80 | TaskRepository.delete(Task); |
81 | } | 81 | } |
82 | 82 | ||
83 | @Cacheable(cacheNames = "uc-admin_taskList" , key = "#taskTemplateId") | 83 | // @Cacheable(cacheNames = "uc-admin_taskList" , key = "#taskTemplateId") |
84 | @Override | 84 | @Override |
85 | public List<Task> findByTemplateId(Long taskTemplateId) { | 85 | public List<Task> findByTemplateId(Long taskTemplateId) { |
86 | return Objects.nonNull(taskTemplateId) ? this.TaskRepository.findByTaskTemplateId(taskTemplateId) : null; | 86 | return Objects.nonNull(taskTemplateId) ? this.TaskRepository.findByTaskTemplateId(taskTemplateId) : null; | ... | ... |
... | @@ -93,10 +93,9 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { | ... | @@ -93,10 +93,9 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { |
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 | // @Cacheable(cacheNames = "uc-admin_taskTemplate" , key = "#event") |
97 | @Override | 97 | @Override |
98 | public TaskTemplate findByType(Integer event) { | 98 | public TaskTemplate findByType(Integer event) { |
99 | System.out.println("查询数据库了!!"); | ||
100 | return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null; | 99 | return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null; |
101 | } | 100 | } |
102 | } | 101 | } | ... | ... |
... | @@ -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(); | ... | ... |
... | @@ -35,13 +35,11 @@ public interface PointsOperationService { | ... | @@ -35,13 +35,11 @@ public interface PointsOperationService { |
35 | */ | 35 | */ |
36 | void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList); | 36 | void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList); |
37 | 37 | ||
38 | /** | ||
39 | * 清理过期的积分 | ||
40 | */ | ||
41 | void cleanInvalidAvailablePoints(); | ||
42 | 38 | ||
43 | /** | 39 | /** |
44 | * 清理过期的积分 | 40 | * 清理过期并计算可用总积分 |
41 | * @param memberId | ||
42 | * @return | ||
45 | */ | 43 | */ |
46 | void cleanInvalidAvailablePointsByMemberId(Long memberId); | 44 | Long cleanInvalidPointsAndCalculateCurrentPoints(Long memberId); |
47 | } | 45 | } | ... | ... |
... | @@ -45,14 +45,12 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -45,14 +45,12 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
45 | RightsOperationService rightsOperationService; | 45 | RightsOperationService rightsOperationService; |
46 | @Autowired | 46 | @Autowired |
47 | RedissonClient redissonClient; | 47 | RedissonClient redissonClient; |
48 | @Resource(name = "executorTask") | 48 | @Autowired |
49 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 49 | ThreadPoolTaskExecutor threadPoolTaskExecutor; |
50 | 50 | ||
51 | // 过期阀值(默认一个月) | 51 | // 过期阀值(默认一个月) |
52 | private static final Integer EXPIRE_FACTOR_DAY = 30; | 52 | private static final Integer EXPIRE_FACTOR_DAY = 30; |
53 | 53 | ||
54 | |||
55 | |||
56 | @Override | 54 | @Override |
57 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { | 55 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { |
58 | // 优惠券领取、使用历史记录表 | 56 | // 优惠券领取、使用历史记录表 |
... | @@ -99,9 +97,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -99,9 +97,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
99 | // Long userId = tempCoupon.getUserId(); | 97 | // Long userId = tempCoupon.getUserId(); |
100 | Long memberId = tempCoupon.getMemberId(); | 98 | Long memberId = tempCoupon.getMemberId(); |
101 | Integer rightsAmount = tempCoupon.getRightsAmount(); | 99 | Integer rightsAmount = tempCoupon.getRightsAmount(); |
102 | // RLock rLock = this.redissonClient.getLock("refreshMemberCoupon:" + memberId.toString()); | 100 | RLock rLock = this.redissonClient.getLock("refreshMemberCoupon:" + memberId.toString()); |
103 | try { | 101 | try { |
104 | // RedissonUtil.lock(rLock); | 102 | RedissonUtil.lock(rLock); |
105 | // 1.历史总优惠券数量 | 103 | // 1.历史总优惠券数量 |
106 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); | 104 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); |
107 | // 1.当前总优惠券数量 | 105 | // 1.当前总优惠券数量 |
... | @@ -118,7 +116,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -118,7 +116,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
118 | e.printStackTrace(); | 116 | e.printStackTrace(); |
119 | throw e; | 117 | throw e; |
120 | } finally { | 118 | } finally { |
121 | // RedissonUtil.unlock(rLock); | 119 | RedissonUtil.unlock(rLock); |
122 | } | 120 | } |
123 | } | 121 | } |
124 | 122 | ||
... | @@ -160,7 +158,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -160,7 +158,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
160 | * @return | 158 | * @return |
161 | */ | 159 | */ |
162 | private Long getTotalExpireSoonCoupon(Long userId, Integer expireFactor) { | 160 | private Long getTotalExpireSoonCoupon(Long userId, Integer expireFactor) { |
163 | Timestamp expireTime = TimestampUtil.localDateTime2Timestamp1(LocalDateTime.now().plusDays(expireFactor)); | 161 | Timestamp expireTime = TimestampUtil.localDateTime2Timestamp(LocalDateTime.now().plusDays(expireFactor)); |
164 | return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,TimestampUtil.now(),expireTime); | 162 | return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,TimestampUtil.now(),expireTime); |
165 | } | 163 | } |
166 | 164 | ... | ... |
... | @@ -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 |
... | @@ -83,10 +83,12 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -83,10 +83,12 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
83 | // 总积分 | 83 | // 总积分 |
84 | long totalExp = this.calculateTotalExp(originExp, tempExp); | 84 | long totalExp = this.calculateTotalExp(originExp, tempExp); |
85 | // 1.添加成长值记录 | 85 | // 1.添加成长值记录 |
86 | this.threadPoolTaskExecutor.execute(() -> this.doInsertExpDetail(tempExp, originExp, totalExp)); | 86 | // this.threadPoolTaskExecutor.execute(() -> this.doInsertExpDetail(tempExp, originExp, totalExp)); |
87 | // this.doInsertExpDetail(tempExp, originExp, totalExp); | ||
88 | // 2.更新成长值与等级 | 87 | // 2.更新成长值与等级 |
89 | this.refreshMemberExpAndLevel(tempExp,totalExp); | 88 | this.refreshMemberExpAndLevel(tempExp,totalExp); |
89 | |||
90 | this.doInsertExpDetail(tempExp, originExp, totalExp); | ||
91 | |||
90 | } catch (Exception e) { | 92 | } catch (Exception e) { |
91 | e.printStackTrace(); | 93 | e.printStackTrace(); |
92 | throw e; | 94 | throw e; |
... | @@ -116,24 +118,14 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -116,24 +118,14 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
116 | private void refreshMemberExpAndLevel(TempExp tempExp,long totalExp) { | 118 | private void refreshMemberExpAndLevel(TempExp tempExp,long totalExp) { |
117 | 119 | ||
118 | Long memberId = tempExp.getMemberId(); | 120 | Long memberId = tempExp.getMemberId(); |
119 | 121 | // 1.获取当前成长值 | |
120 | // RLock rLock = this.redissonClient.getLock("refresh" + memberId.toString()); | 122 | MemberDTO memberDTO = this.getMemberInfoByMemberId(memberId); |
121 | try { | 123 | // 2.获取下一级需要的成长值 |
122 | // RedissonUtil.lock(rLock); | 124 | MemberLevelDTO memberLevelDTO = this.getNextLevelExp(memberDTO.getLevel() + 1, 1); |
123 | // 1.获取当前成长值 | 125 | // 4.成长值比较,判断是否升级 |
124 | MemberDTO memberDTO = this.getMemberInfoByMemberId(memberId); | 126 | Integer level = this.compareExp(totalExp, memberLevelDTO,memberDTO); |
125 | // 2.获取下一级需要的成长值 | 127 | // 5.更新用户信息 |
126 | MemberLevelDTO memberLevelDTO = this.getNextLevelExp(memberDTO.getLevel() + 1, 1); | 128 | this.updateMemberInfo(level, totalExp, memberId); |
127 | // 4.成长值比较,判断是否升级 | ||
128 | Integer level = this.compareExp(totalExp, memberLevelDTO,memberDTO); | ||
129 | // 5.更新用户信息 | ||
130 | this.updateMemberInfo(level, totalExp, memberId); | ||
131 | } catch (Exception e) { | ||
132 | e.printStackTrace(); | ||
133 | throw e; | ||
134 | } finally { | ||
135 | // RedissonUtil.unlock(rLock); | ||
136 | } | ||
137 | } | 129 | } |
138 | 130 | ||
139 | /** | 131 | /** | ... | ... |
This diff is collapsed.
Click to expand it.
1 | package com.topdraw.business.process.service.impl; | 1 | package com.topdraw.business.process.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.basicdata.coupon.service.CouponService; | ||
4 | import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; | ||
3 | import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; | 5 | import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; |
4 | import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService; | 6 | import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService; |
5 | import com.topdraw.business.basicdata.rights.service.RightsService; | 7 | import com.topdraw.business.basicdata.rights.service.RightsService; |
... | @@ -19,10 +21,8 @@ import org.springframework.stereotype.Service; | ... | @@ -19,10 +21,8 @@ import org.springframework.stereotype.Service; |
19 | import org.springframework.util.CollectionUtils; | 21 | import org.springframework.util.CollectionUtils; |
20 | import org.springframework.util.StringUtils; | 22 | import org.springframework.util.StringUtils; |
21 | 23 | ||
22 | import javax.annotation.Resource; | ||
23 | import java.sql.Timestamp; | ||
24 | import java.util.*; | 24 | import java.util.*; |
25 | import java.util.concurrent.Future; | 25 | import java.util.concurrent.*; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * 权益处理 | 28 | * 权益处理 |
... | @@ -46,9 +46,13 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -46,9 +46,13 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
46 | ExpOperationService expOperationService; | 46 | ExpOperationService expOperationService; |
47 | @Autowired | 47 | @Autowired |
48 | PointsOperationService pointsOperationService; | 48 | PointsOperationService pointsOperationService; |
49 | @Autowired | ||
50 | CouponService couponService; | ||
51 | |||
52 | // @Autowired | ||
53 | // ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
49 | 54 | ||
50 | @Resource(name = "executorTask") | 55 | private ExecutorService threadPoolTaskExecutor = Executors.newFixedThreadPool(10); |
51 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
52 | 56 | ||
53 | /** | 57 | /** |
54 | * 系统手动发放 | 58 | * 系统手动发放 |
... | @@ -73,16 +77,15 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -73,16 +77,15 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
73 | @Override | 77 | @Override |
74 | public void grantRights(Map<RightType, Object> tempRightsMap) { | 78 | public void grantRights(Map<RightType, Object> tempRightsMap) { |
75 | 79 | ||
76 | this.threadPoolTaskExecutor.execute(()-> { | 80 | // this.threadPoolTaskExecutor.execute(()-> { |
77 | // 2.创建权益历史对象 | 81 | // 2.创建权益历史对象 |
78 | List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap); | 82 | List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap); |
79 | // 3.保存权益历史 | 83 | // 3.保存权益历史 |
80 | this.doInsertTrRightHistory(rightsList); | 84 | this.doInsertTrRightHistory(rightsList); |
81 | }); | 85 | // }); |
82 | 86 | ||
83 | // 1.权益下发 | 87 | // 1.权益下发 |
84 | this.refresh(tempRightsMap); | 88 | this.refresh(tempRightsMap); |
85 | |||
86 | } | 89 | } |
87 | 90 | ||
88 | /** | 91 | /** |
... | @@ -106,7 +109,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -106,7 +109,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
106 | return rightsHistoryList; | 109 | return rightsHistoryList; |
107 | } | 110 | } |
108 | 111 | ||
109 | |||
110 | /** | 112 | /** |
111 | * 成长值发放,基于已获得的权益 | 113 | * 成长值发放,基于已获得的权益 |
112 | * @param tempExpList 权益列表 | 114 | * @param tempExpList 权益列表 |
... | @@ -116,18 +118,18 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -116,18 +118,18 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
116 | this.expOperationService.grantPointsThroughTempExp(tempExpList); | 118 | this.expOperationService.grantPointsThroughTempExp(tempExpList); |
117 | } | 119 | } |
118 | 120 | ||
119 | |||
120 | /** | 121 | /** |
121 | * 发放积分,基于已获得的权益 | 122 | * 发放积分,基于已获得的权益 |
122 | * | 123 | * |
123 | * @param tempPointsList 权益列表 | 124 | * @param tempPointsList 权益列表 |
124 | */ | 125 | */ |
125 | private void grantPoint(List<TempPoints> tempPointsList) { | 126 | private void grantPoint(List<TempPoints> tempPointsList) { |
127 | log.info(Thread.currentThread().getName() + "=========>>grantPoint start"); | ||
126 | if (!CollectionUtils.isEmpty(tempPointsList)) | 128 | if (!CollectionUtils.isEmpty(tempPointsList)) |
129 | log.info("=======>> tempPointsList ======>> " + tempPointsList.toString()); | ||
127 | this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList); | 130 | this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList); |
128 | } | 131 | } |
129 | 132 | ||
130 | |||
131 | /** | 133 | /** |
132 | * 发放优惠券,基于已获得的权益 | 134 | * 发放优惠券,基于已获得的权益 |
133 | * | 135 | * |
... | @@ -139,21 +141,78 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -139,21 +141,78 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
139 | this.couponOperationService.grantCouponThroughTempCoupon(tempCouponList); | 141 | this.couponOperationService.grantCouponThroughTempCoupon(tempCouponList); |
140 | } | 142 | } |
141 | 143 | ||
142 | |||
143 | /** | 144 | /** |
144 | * 权益发放 | 145 | * 权益发放 |
145 | * @param tempRightsMap | 146 | * @param tempRightsMap |
146 | */ | 147 | */ |
147 | private void refresh(Map<RightType, Object> tempRightsMap) { | 148 | private void refresh(Map<RightType, Object> tempRightsMap) { |
148 | 149 | /*FutureTask<Map<Long,Long>> futureTask1 = new FutureTask(()->{ | |
149 | this.threadPoolTaskExecutor.submit(() -> { | 150 | log.info(Thread.currentThread().getName() + "=========>> start"); |
151 | // 积分 | ||
152 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
153 | log.info(Thread.currentThread().getName() + "=========>>grantPoint end"); | ||
154 | // 成长值 | ||
155 | // this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | ||
156 | // 优惠券 | ||
157 | // this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | ||
158 | return null; | ||
159 | }); | ||
160 | FutureTask<Map<Long,Long>> futureTask2 = new FutureTask(()->{ | ||
161 | // 积分 | ||
162 | // this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
163 | // 成长值 | ||
164 | this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | ||
165 | // 优惠券 | ||
166 | // this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | ||
167 | return null; | ||
168 | }); | ||
169 | FutureTask<Map<Long,Long>> futureTask3 = new FutureTask(()->{ | ||
170 | // 积分 | ||
171 | // this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
172 | // 成长值 | ||
173 | // this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | ||
174 | // 优惠券 | ||
175 | this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | ||
176 | return null; | ||
177 | }); | ||
178 | this.threadPoolTaskExecutor.execute(futureTask1); | ||
179 | this.threadPoolTaskExecutor.execute(futureTask2); | ||
180 | this.threadPoolTaskExecutor.execute(futureTask3);*/ | ||
181 | /*this.threadPoolTaskExecutor.execute(() -> { | ||
150 | // 积分 | 182 | // 积分 |
151 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | 183 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); |
152 | // 成长值 | 184 | // 成长值 |
153 | this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | 185 | this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); |
154 | // 优惠券 | 186 | // 优惠券 |
155 | this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | 187 | this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); |
156 | }); | 188 | });*/ |
189 | |||
190 | |||
191 | /*this.threadPoolTaskExecutor.execute(() -> { | ||
192 | log.info(Thread.currentThread().getName() + "=========>> start"); | ||
193 | // 积分 | ||
194 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
195 | log.info(Thread.currentThread().getName() + "=========>> end"); | ||
196 | });*/ | ||
197 | |||
198 | List<TempPoints> tempPointsList = (List<TempPoints>) tempRightsMap.get(RightType.POINTS); | ||
199 | if (!CollectionUtils.isEmpty(tempPointsList)) { | ||
200 | // 积分 | ||
201 | this.grantPoint(tempPointsList); | ||
202 | } | ||
203 | |||
204 | List<TempExp> tempExpList = (List<TempExp>) tempRightsMap.get(RightType.EXP); | ||
205 | if (!CollectionUtils.isEmpty(tempExpList)) { | ||
206 | // 成长值 | ||
207 | this.grantExp(tempExpList); | ||
208 | } | ||
209 | |||
210 | List<TempCoupon> tempCouponList = (List<TempCoupon>) tempRightsMap.get(RightType.COUPON); | ||
211 | if (!CollectionUtils.isEmpty(tempCouponList)) { | ||
212 | // 优惠券 | ||
213 | this.grantCoupon(tempCouponList); | ||
214 | } | ||
215 | |||
157 | } | 216 | } |
158 | 217 | ||
159 | /** | 218 | /** |
... | @@ -167,8 +226,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -167,8 +226,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
167 | 226 | ||
168 | // 优惠券 | 227 | // 优惠券 |
169 | List<TempCoupon> tempCouponList = new ArrayList<>(); | 228 | List<TempCoupon> tempCouponList = new ArrayList<>(); |
170 | List<TempExp> tempExpList = new ArrayList<>(); | ||
171 | List<TempPoints> tempPointsList = new ArrayList<>(); | ||
172 | 229 | ||
173 | for (RightsHistory right : rightsList) { | 230 | for (RightsHistory right : rightsList) { |
174 | Long rightId = right.getRightsId(); | 231 | Long rightId = right.getRightsId(); |
... | @@ -178,62 +235,55 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -178,62 +235,55 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
178 | RightsDTO rightsDTO = this.getRights(rightId); | 235 | RightsDTO rightsDTO = this.getRights(rightId); |
179 | // 权益的实体类型 1:积分;2成长值;3优惠券 | 236 | // 权益的实体类型 1:积分;2成长值;3优惠券 |
180 | String type = rightsDTO.getEntityType(); | 237 | String type = rightsDTO.getEntityType(); |
181 | String code = rightsDTO.getCode(); | ||
182 | Long expireTime = rightsDTO.getExpireTime(); | 238 | Long expireTime = rightsDTO.getExpireTime(); |
183 | Timestamp validTime = rightsDTO.getValidTime(); | ||
184 | |||
185 | 239 | ||
186 | switch (type) { | 240 | switch (type) { |
187 | // 优惠券 | 241 | // 优惠券 |
188 | case "3": | 242 | case "1": |
189 | TempCoupon tempCoupon = new TempCoupon(); | 243 | Long entityId = rightsDTO.getEntityId(); |
190 | tempCoupon.setId(rightId); | 244 | CouponDTO couponDTO = this.findCouponById(entityId); |
191 | tempCoupon.setMemberId(memberId); | 245 | if (Objects.nonNull(couponDTO)) { |
192 | tempCoupon.setUserId(userId); | 246 | TempCoupon tempCoupon = new TempCoupon(); |
193 | tempCoupon.setRightsAmount(1); | 247 | tempCoupon.setId(couponDTO.getId()); |
194 | tempCoupon.setRightsSendStrategy(0); | 248 | tempCoupon.setMemberId(memberId); |
195 | tempCoupon.setExpireTime(TimestampUtil.long2Timestamp(expireTime)); | 249 | tempCoupon.setUserId(userId); |
196 | tempCouponList.add(tempCoupon); | 250 | tempCoupon.setRightsAmount(1); |
251 | tempCoupon.setRightsSendStrategy(0); | ||
252 | tempCoupon.setCode(couponDTO.getCode()); | ||
253 | if (Objects.nonNull(expireTime)) | ||
254 | tempCoupon.setExpireTime(TimestampUtil.long2Timestamp(expireTime)); | ||
255 | tempCouponList.add(tempCoupon); | ||
256 | } | ||
197 | break; | 257 | break; |
198 | // 成长值 | 258 | // 观影券 |
199 | case "2": | 259 | case "2": |
200 | TempExp tempExp = new TempExp(); | ||
201 | tempExp.setId(rightId); | ||
202 | tempExp.setMemberId(memberId); | ||
203 | tempExp.setUserId(userId); | ||
204 | tempExp.setRightsAmount(1); | ||
205 | tempExp.setRightsSendStrategy(0); | ||
206 | tempExpList.add(tempExp); | ||
207 | break; | 260 | break; |
208 | // 积分 | 261 | // 活动参与机会 |
209 | case "1": | 262 | case "3": |
210 | TempPoints tempPoints = new TempPoints(); | ||
211 | tempPoints.setId(rightId); | ||
212 | tempPoints.setMemberId(memberId); | ||
213 | tempPoints.setUserId(userId); | ||
214 | tempPoints.setRightsAmount(1); | ||
215 | tempPoints.setRightsSendStrategy(0); | ||
216 | tempPointsList.add(tempPoints); | ||
217 | break; | 263 | break; |
264 | |||
265 | default: | ||
266 | break; | ||
218 | } | 267 | } |
219 | } | 268 | } |
220 | 269 | ||
221 | // TODO 其他 | ||
222 | |||
223 | // 优惠券 | 270 | // 优惠券 |
224 | if (!CollectionUtils.isEmpty(tempCouponList)) | 271 | if (!CollectionUtils.isEmpty(tempCouponList)) |
225 | map.put(RightType.COUPON,tempCouponList); | 272 | map.put(RightType.COUPON,tempCouponList); |
226 | // 成长值 | ||
227 | if (!CollectionUtils.isEmpty(tempExpList)) | ||
228 | map.put(RightType.EXP,tempExpList); | ||
229 | // 积分 | ||
230 | if (!CollectionUtils.isEmpty(tempPointsList)) | ||
231 | map.put(RightType.POINTS,tempPointsList); | ||
232 | |||
233 | return map; | 273 | return map; |
234 | } | 274 | } |
235 | 275 | ||
236 | /** | 276 | /** |
277 | * 获取优惠券信息 | ||
278 | * @param id | ||
279 | * @return | ||
280 | */ | ||
281 | private CouponDTO findCouponById(Long id) { | ||
282 | CouponDTO couponDTO = this.couponService.findById(id); | ||
283 | return couponDTO; | ||
284 | } | ||
285 | |||
286 | /** | ||
237 | * 权益详情 | 287 | * 权益详情 |
238 | * @param rightsId | 288 | * @param rightsId |
239 | * @return | 289 | * @return | ... | ... |
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 | ... | ... |
... | @@ -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,33 +13,46 @@ public class TimestampUtil { | ... | @@ -12,33 +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 | ||
24 | public static Timestamp localDateTime2Timestamp1(LocalDateTime localDateTime){ | 25 | public static Timestamp localDateTime2Timestamp(LocalDateTime localDateTime){ |
25 | long epochSecond = localDateTime.atZone(ZoneOffset.systemDefault()).toEpochSecond(); | 26 | long epochSecond = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
26 | return long2Timestamp(epochSecond); | 27 | return long2Timestamp(epochSecond); |
27 | } | 28 | } |
28 | public static Timestamp long2Timestamp(long timestamp){ | 29 | public static Timestamp long2Timestamp(long timestamp){ |
29 | Timestamp timestamp1 = Timestamp.from(Instant.ofEpochSecond(timestamp)); | 30 | Timestamp timestamp1 = Timestamp.from(Instant.ofEpochMilli(timestamp)); |
30 | return timestamp1; | 31 | return timestamp1; |
31 | } | 32 | } |
32 | 33 | ||
33 | public static long Timestamp2long(Timestamp timestamp){ | 34 | public static long timestamp2long(Timestamp timestamp){ |
34 | return timestamp.toInstant().getEpochSecond(); | 35 | long l = timestamp.toInstant().toEpochMilli(); |
36 | return l; | ||
35 | } | 37 | } |
36 | 38 | ||
37 | public static void main(String[] args) { | 39 | public static void main(String[] args) { |
38 | LocalDateTime of = LocalDateTime.of(2021, 10, 28, 11, 00, 00); | 40 | long a = 1636616464000L; |
39 | long l = localDateTime2Timestamp(of); | 41 | long b = 1637046948588L; |
42 | long c = 1637047122176L; | ||
40 | // long l = 16342727230L; | 43 | // long l = 16342727230L; |
41 | Timestamp timestamp = long2Timestamp(l); | 44 | // Timestamp now = now(LocalDateTime.now()); |
42 | System.out.println(timestamp.toString()); | 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); | ||
51 | // long l = 16342727230L; | ||
52 | // Timestamp timestamp = long2Timestamp(l); | ||
53 | System.out.println(timestamp1.toString()); | ||
54 | |||
55 | long l1 = localDateTime2long(LocalDateTime.now()); | ||
56 | System.out.println(l1); | ||
43 | } | 57 | } |
44 | } | 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的部分属性。 | ... | ... |
... | @@ -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 -> { | ... | ... |
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 | } |
... | @@ -53,9 +53,9 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -53,9 +53,9 @@ 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-11-27 09:00:00")); | 61 | tempPoints.setExpireTime(Timestamp.valueOf("2021-11-27 09:00:00")); |
... | @@ -72,6 +72,28 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -72,6 +72,28 @@ public class PointsOperationControllerTest extends BaseTest { |
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(); | ... | ... |
... | @@ -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,8 +46,71 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -37,8 +46,71 @@ 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"); | ||
40 | 67 | ||
41 | } | 68 | } |
69 | public void t3() throws InterruptedException { | ||
70 | |||
71 | Thread.sleep(1*1000); | ||
72 | System.out.println(Thread.currentThread().getName()+"=======>>> t3"); | ||
73 | |||
74 | } | ||
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 | |||
42 | 114 | ||
43 | 115 | ||
44 | 116 | ... | ... |
... | @@ -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