演示前最后版本修改
Showing
19 changed files
with
535 additions
and
133 deletions
document/sql/structure/update.sql
0 → 100644
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 | } |
... | @@ -283,7 +283,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -283,7 +283,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
283 | */ | 283 | */ |
284 | private void cleanInvalidAvailablePointsByMemberId(Long memberId) { | 284 | private void cleanInvalidAvailablePointsByMemberId(Long memberId) { |
285 | List<PointsAvailableDTO> pointsAvailableDTOS = | 285 | List<PointsAvailableDTO> pointsAvailableDTOS = |
286 | pointsAvailableService.findByMemberIdAndExpireTimeAfter(memberId,TimestampUtil.now()); | 286 | pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId,TimestampUtil.now()); |
287 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS)) { | 287 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS)) { |
288 | //1.获取原始积分 | 288 | //1.获取原始积分 |
289 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS) { | 289 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS) { |
... | @@ -366,6 +366,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -366,6 +366,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
366 | 366 | ||
367 | PointsDetail pointsDetail = new PointsDetail(); | 367 | PointsDetail pointsDetail = new PointsDetail(); |
368 | BeanUtils.copyProperties(pointsAvailableDTO,pointsDetail); | 368 | BeanUtils.copyProperties(pointsAvailableDTO,pointsDetail); |
369 | pointsDetail.setId(null); | ||
369 | pointsDetail.setPoints(-Math.abs(l)); | 370 | pointsDetail.setPoints(-Math.abs(l)); |
370 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); | 371 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); |
371 | pointsDetail.setOriginalPoints(availablePoints); | 372 | pointsDetail.setOriginalPoints(availablePoints); |
... | @@ -531,11 +532,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -531,11 +532,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
531 | 532 | ||
532 | PointsDetail pointsDetail = new PointsDetail(); | 533 | PointsDetail pointsDetail = new PointsDetail(); |
533 | BeanUtils.copyProperties(tempPoints,pointsDetail); | 534 | BeanUtils.copyProperties(tempPoints,pointsDetail); |
535 | pointsDetail.setId(null); | ||
534 | pointsDetail.setMemberId(memberId); | 536 | pointsDetail.setMemberId(memberId); |
535 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); | 537 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); |
536 | pointsDetail.setPoints(tempPoints.getPoints()); | 538 | pointsDetail.setPoints(tempPoints.getPoints()); |
537 | pointsDetail.setOriginalPoints(currentPoints); | 539 | pointsDetail.setOriginalPoints(currentPoints); |
538 | pointsDetail.setResultPoints(totalPoints); | 540 | pointsDetail.setResultPoints(totalPoints); |
541 | pointsDetail.setCreateTime(null); | ||
542 | pointsDetail.setUpdateTime(null); | ||
539 | String description = pointsDetail.getDescription(); | 543 | String description = pointsDetail.getDescription(); |
540 | if (StringUtils.isEmpty(description)) { | 544 | if (StringUtils.isEmpty(description)) { |
541 | pointsDetail.setDescription("#"); | 545 | pointsDetail.setDescription("#"); | ... | ... |
... | @@ -3,6 +3,9 @@ package com.topdraw.business.process.service.impl; | ... | @@ -3,6 +3,9 @@ package com.topdraw.business.process.service.impl; |
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.topdraw.business.basicdata.coupon.service.CouponService; | 4 | import com.topdraw.business.basicdata.coupon.service.CouponService; |
5 | import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; | 5 | import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; |
6 | import com.topdraw.business.basicdata.member.group.service.MemberGroupService; | ||
7 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; | ||
8 | import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria; | ||
6 | import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService; | 9 | import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService; |
7 | import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO; | 10 | import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO; |
8 | import com.topdraw.business.basicdata.rights.service.RightsService; | 11 | import com.topdraw.business.basicdata.rights.service.RightsService; |
... | @@ -20,7 +23,6 @@ import com.topdraw.business.basicdata.task.service.TaskService; | ... | @@ -20,7 +23,6 @@ import com.topdraw.business.basicdata.task.service.TaskService; |
20 | import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; | 23 | import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; |
21 | import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; | 24 | import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; |
22 | import com.topdraw.business.process.domian.*; | 25 | import com.topdraw.business.process.domian.*; |
23 | import com.topdraw.exception.BadRequestException; | ||
24 | import com.topdraw.module.mq.DataSyncMsg; | 26 | import com.topdraw.module.mq.DataSyncMsg; |
25 | import com.topdraw.util.*; | 27 | import com.topdraw.util.*; |
26 | import lombok.extern.slf4j.Slf4j; | 28 | import lombok.extern.slf4j.Slf4j; |
... | @@ -37,8 +39,8 @@ import java.math.RoundingMode; | ... | @@ -37,8 +39,8 @@ import java.math.RoundingMode; |
37 | import java.sql.Timestamp; | 39 | import java.sql.Timestamp; |
38 | import java.time.LocalDate; | 40 | import java.time.LocalDate; |
39 | import java.util.*; | 41 | import java.util.*; |
40 | import java.util.concurrent.locks.ReentrantReadWriteLock; | 42 | |
41 | import java.util.stream.Collectors; | 43 | import static java.util.stream.Collectors.toList; |
42 | 44 | ||
43 | /** | 45 | /** |
44 | * 任务处理 | 46 | * 任务处理 |
... | @@ -68,6 +70,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -68,6 +70,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
68 | PermanentRightsService permanentRightsService; | 70 | PermanentRightsService permanentRightsService; |
69 | @Autowired | 71 | @Autowired |
70 | CouponService couponService; | 72 | CouponService couponService; |
73 | @Autowired | ||
74 | MemberGroupService memberGroupService; | ||
71 | 75 | ||
72 | private static final Integer TASK_FINISH_STATUS = 1; | 76 | private static final Integer TASK_FINISH_STATUS = 1; |
73 | private static final Integer TASK_UNFINISH_STATUS = 2; | 77 | private static final Integer TASK_UNFINISH_STATUS = 2; |
... | @@ -543,7 +547,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -543,7 +547,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
543 | * 1. task_repeat_type 任务重复类型,-1:不限次;1:单次;>1:多次 | 547 | * 1. task_repeat_type 任务重复类型,-1:不限次;1:单次;>1:多次 |
544 | * 5. member_level 会员等级门槛(0表示无门槛) | 548 | * 5. member_level 会员等级门槛(0表示无门槛) |
545 | * 6. member_vip 会员vip门槛(0表示没有门槛) | 549 | * 6. member_vip 会员vip门槛(0表示没有门槛) |
546 | * 7. groups 能够获取该任务的用户分组,为空则都能获取 | 550 | * 7. groups 能够获取该任务的用户分组,为空则都能获取 , 0 |
547 | * 8. action_amount 行为量(完成此任务需要多少次相同行为的触发) | 551 | * 8. action_amount 行为量(完成此任务需要多少次相同行为的触发) |
548 | * | 552 | * |
549 | * @param taskList 任务列表 | 553 | * @param taskList 任务列表 |
... | @@ -555,24 +559,27 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -555,24 +559,27 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
555 | // 会员信息 | 559 | // 会员信息 |
556 | MemberDTO memberDTO = this.memberService.findById(memberId); | 560 | MemberDTO memberDTO = this.memberService.findById(memberId); |
557 | 561 | ||
558 | |||
559 | |||
560 | // 判断是否完成任务 | 562 | // 判断是否完成任务 |
561 | CompareTaskCondition compareTaskCondition =(MemberDTO memberDTO1,List<Task> taskList1) -> { | 563 | CompareTaskCondition compareTaskCondition =(MemberDTO memberDTO1,List<Task> taskList1) -> { |
562 | 564 | ||
563 | List<Task> taskStream = taskList1.stream().filter(task1 -> | 565 | List<Task> taskStream = taskList1.stream().filter(task1 -> |
564 | task1.getStatus() == 1 && | 566 | task1.getStatus() == 1 && |
565 | (Objects.isNull(task1.getExpireTime()) || task1.getExpireTime().compareTo(TimestampUtil.now()) >= 0) && | 567 | (Objects.isNull(task1.getExpireTime()) || task1.getExpireTime().compareTo(TimestampUtil.now()) >= 0) && |
566 | (Objects.isNull(task1.getGroups()) || task1.getGroups().equals("0") || task1.getGroups().equalsIgnoreCase(memberDTO1.getGroups())) && | ||
567 | (Objects.isNull(task1.getValidTime()) || task1.getValidTime().compareTo(TimestampUtil.now()) <= 0) && | 568 | (Objects.isNull(task1.getValidTime()) || task1.getValidTime().compareTo(TimestampUtil.now()) <= 0) && |
568 | (Objects.isNull(task1.getMemberLevel()) || task1.getMemberLevel() <= memberDTO1.getLevel()) && | 569 | (Objects.isNull(task1.getMemberLevel()) || task1.getMemberLevel() <= memberDTO1.getLevel()) && |
569 | (Objects.isNull(task1.getMemberVip()) || task1.getMemberVip() <= memberDTO1.getVip()) | 570 | (Objects.isNull(task1.getMemberVip()) || task1.getMemberVip() <= memberDTO1.getVip()) |
570 | ).collect(Collectors.toList()); | 571 | ).collect(toList()); |
571 | 572 | ||
572 | // 没有满足条件的数据 | 573 | // 没有满足条件的数据 |
573 | if (CollectionUtils.isEmpty(taskStream)) { | 574 | if (CollectionUtils.isEmpty(taskStream)) { |
574 | return false; | 575 | return false; |
575 | } else { | 576 | } else { |
577 | |||
578 | // 验证会员分组 | ||
579 | boolean result1 = this.validatedMemberGroup(memberId,taskList); | ||
580 | if (!result1) | ||
581 | return false; | ||
582 | |||
576 | // 获取当前任务的完成情况 | 583 | // 获取当前任务的完成情况 |
577 | boolean result = this.checkAndRefreshTaskCompletion(memberId,taskList); | 584 | boolean result = this.checkAndRefreshTaskCompletion(memberId,taskList); |
578 | return result; | 585 | return result; |
... | @@ -586,6 +593,96 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -586,6 +593,96 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
586 | } | 593 | } |
587 | 594 | ||
588 | /** | 595 | /** |
596 | * 验证会员分组 | ||
597 | * @param memberId | ||
598 | * @param taskList | ||
599 | * @return | ||
600 | */ | ||
601 | private boolean validatedMemberGroup(Long memberId,List<Task> taskList) { | ||
602 | List<MemberGroupDTO> groupDTO = this.findGroupByMemberId(memberId); | ||
603 | |||
604 | if (!CollectionUtils.isEmpty(groupDTO)) { | ||
605 | |||
606 | // 会员分组 | ||
607 | List<String> list = new ArrayList<>(); | ||
608 | for (MemberGroupDTO memberGroupDTO : groupDTO) { | ||
609 | String groupId = memberGroupDTO.getGroupId().toString(); | ||
610 | list.add(groupId); | ||
611 | } | ||
612 | |||
613 | // 任务分组 | ||
614 | List<String> strings = new ArrayList<>(); | ||
615 | for (Task task : taskList) { | ||
616 | String groups = task.getGroups(); | ||
617 | List<String> strings1 = UcStringUtils.parse2StrList(groups); | ||
618 | if (StringUtils.isEmpty(groups)) { | ||
619 | return true; | ||
620 | } | ||
621 | strings.addAll(strings1); | ||
622 | break; | ||
623 | } | ||
624 | |||
625 | // 如果任务分组为null或者空字符,则放过所有的会员 | ||
626 | if (CollectionUtils.isEmpty(strings)) { | ||
627 | return true; | ||
628 | } | ||
629 | |||
630 | // 如果任务分组为0,则放过所有的分组 | ||
631 | if (!CollectionUtils.isEmpty(strings) && (!CollectionUtils.isEmpty(list) && strings.contains("0")) ) { | ||
632 | return true; | ||
633 | } | ||
634 | |||
635 | if (!CollectionUtils.isEmpty(list)) { | ||
636 | // 只要会员分组满足任务分组之一就满足要求 | ||
637 | if (list.size() > strings.size()) { | ||
638 | for (String s : list) { | ||
639 | boolean contains = strings.contains(s); | ||
640 | if (contains) { | ||
641 | return true; | ||
642 | } | ||
643 | } | ||
644 | } | ||
645 | } | ||
646 | |||
647 | if (!CollectionUtils.isEmpty(strings)) { | ||
648 | for (String s : strings) { | ||
649 | boolean contains = list.contains(s); | ||
650 | if (contains) { | ||
651 | return true; | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | |||
656 | |||
657 | } | ||
658 | return false; | ||
659 | } | ||
660 | |||
661 | |||
662 | /** | ||
663 | * | ||
664 | * @param memberId | ||
665 | * @return | ||
666 | */ | ||
667 | private List<MemberGroupDTO> findGroupByMemberId(Long memberId) { | ||
668 | MemberGroupQueryCriteria memberGroupQueryCriteria = new MemberGroupQueryCriteria(); | ||
669 | memberGroupQueryCriteria.setMemberId(memberId); | ||
670 | return this.memberGroupService.queryAll(memberGroupQueryCriteria); | ||
671 | } | ||
672 | |||
673 | /** | ||
674 | * 通过会员id获取分组 | ||
675 | * @param memberId | ||
676 | * @return | ||
677 | */ | ||
678 | /*private List<GroupDTO> findGroupByMemberId(Long memberId) { | ||
679 | GroupQueryCriteria groupQueryCriteria = new GroupQueryCriteria(); | ||
680 | groupQueryCriteria.setUserId(memberId); | ||
681 | List<GroupDTO> groupDTO = this.groupService.queryAll(groupQueryCriteria); | ||
682 | return groupDTO; | ||
683 | }*/ | ||
684 | |||
685 | /** | ||
589 | * 检查并更新当前任务的完成情况 | 686 | * 检查并更新当前任务的完成情况 |
590 | * | 687 | * |
591 | * 1.每天都能做,但要求总次数达到行为量 | 688 | * 1.每天都能做,但要求总次数达到行为量 | ... | ... |
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,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,7 +53,7 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -53,7 +53,7 @@ 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(5L); | 56 | tempPoints.setMemberId(10L); |
57 | tempPoints.setPoints(10L); | 57 | tempPoints.setPoints(10L); |
58 | tempPoints.setPointsType(0); | 58 | tempPoints.setPointsType(0); |
59 | tempPoints.setRightsSendStrategy(0); | 59 | tempPoints.setRightsSendStrategy(0); | ... | ... |
... | @@ -8,11 +8,13 @@ import com.topdraw.module.mq.DataSyncMsg; | ... | @@ -8,11 +8,13 @@ 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; |
13 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 14 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
14 | 15 | ||
15 | import javax.annotation.Resource; | 16 | import javax.annotation.Resource; |
17 | import java.util.List; | ||
16 | import java.util.concurrent.ArrayBlockingQueue; | 18 | import java.util.concurrent.ArrayBlockingQueue; |
17 | import java.util.concurrent.FutureTask; | 19 | import java.util.concurrent.FutureTask; |
18 | import java.util.concurrent.ThreadPoolExecutor; | 20 | import java.util.concurrent.ThreadPoolExecutor; |
... | @@ -29,9 +31,9 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -29,9 +31,9 @@ public class TaskOperationControllerTest extends BaseTest { |
29 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); | 31 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); |
30 | dataSyncMsg.setEventType(EventType.VIEWING.name()); | 32 | dataSyncMsg.setEventType(EventType.VIEWING.name()); |
31 | DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); | 33 | DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); |
32 | msgData.setEvent(3); // 类型 1-登录 2-观影 3-参加活动 4-订购 5-优享会员 6-签到 | 34 | msgData.setEvent(6); // 类型 1-登录 2-观影 3-参加活动 4-订购 5-优享会员 6-签到 |
33 | msgData.setRemarks("remark"); | 35 | msgData.setRemarks("remark"); |
34 | msgData.setMemberId(5L); | 36 | msgData.setMemberId(4L); |
35 | msgData.setDeviceType(2); | 37 | msgData.setDeviceType(2); |
36 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); | 38 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); |
37 | dataSyncMsg.setMsg(msgData); | 39 | dataSyncMsg.setMsg(msgData); |
... | @@ -44,7 +46,6 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -44,7 +46,6 @@ public class TaskOperationControllerTest extends BaseTest { |
44 | } catch (Exception e) { | 46 | } catch (Exception e) { |
45 | e.printStackTrace(); | 47 | e.printStackTrace(); |
46 | } | 48 | } |
47 | |||
48 | } | 49 | } |
49 | 50 | ||
50 | 51 | ... | ... |
... | @@ -46,7 +46,7 @@ public class PointsOperationServiceTest extends BaseTest { | ... | @@ -46,7 +46,7 @@ public class PointsOperationServiceTest extends BaseTest { |
46 | 46 | ||
47 | @Test | 47 | @Test |
48 | public void cleanInvalidAvailablePoints() { | 48 | public void cleanInvalidAvailablePoints() { |
49 | Long memberId = 2L; | 49 | Long memberId = 10L; |
50 | this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(memberId); | 50 | this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(memberId); |
51 | } | 51 | } |
52 | 52 | ... | ... |
-
Please register or sign in to post a comment