1.优化
Showing
28 changed files
with
228 additions
and
343 deletions
| 1 | package com.topdraw.business.module.coupon.service; | 1 | package com.topdraw.business.module.coupon.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.coupon.domain.Coupon; | ||
| 4 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; | 3 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; |
| 5 | 4 | ||
| 6 | import java.util.List; | ||
| 7 | |||
| 8 | /** | 5 | /** |
| 9 | * @author XiangHan | 6 | * @author XiangHan |
| 10 | * @date 2021-10-22 | 7 | * @date 2021-10-22 | ... | ... |
| ... | @@ -12,6 +12,7 @@ import java.util.List; | ... | @@ -12,6 +12,7 @@ import java.util.List; |
| 12 | * @date 2021-10-22 | 12 | * @date 2021-10-22 |
| 13 | */ | 13 | */ |
| 14 | public interface ExpHistoryService { | 14 | public interface ExpHistoryService { |
| 15 | |||
| 15 | /** | 16 | /** |
| 16 | * 根据ID查询 | 17 | * 根据ID查询 |
| 17 | * @param id ID | 18 | * @param id ID | ... | ... |
| ... | @@ -28,47 +28,47 @@ import java.io.Serializable; | ... | @@ -28,47 +28,47 @@ import java.io.Serializable; |
| 28 | @Table(name="uc_points_available") | 28 | @Table(name="uc_points_available") |
| 29 | public class PointsAvailable extends AsyncMqModule implements Serializable { | 29 | public class PointsAvailable extends AsyncMqModule implements Serializable { |
| 30 | 30 | ||
| 31 | // 主键 | 31 | /** 主键 */ |
| 32 | @Id | 32 | @Id |
| 33 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 33 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 34 | @Column(name = "id") | 34 | @Column(name = "id") |
| 35 | private Long id; | 35 | private Long id; |
| 36 | 36 | ||
| 37 | // 标识 | 37 | /** 标识 */ |
| 38 | @Column(name = "code") | 38 | @Column(name = "code") |
| 39 | private String code; | 39 | private String code; |
| 40 | 40 | ||
| 41 | // 积分类型 0:通用型 | 41 | /** 积分类型 0:通用型 */ |
| 42 | @Column(name = "points_type") | 42 | @Column(name = "points_type") |
| 43 | private Integer pointsType; | 43 | private Integer pointsType; |
| 44 | 44 | ||
| 45 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 45 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ |
| 46 | @Column(name = "device_type") | 46 | @Column(name = "device_type") |
| 47 | private Integer deviceType; | 47 | private Integer deviceType; |
| 48 | 48 | ||
| 49 | // 会员id | 49 | /** 会员id */ |
| 50 | @Column(name = "member_id", nullable = false) | 50 | @Column(name = "member_id", nullable = false) |
| 51 | private Long memberId; | 51 | private Long memberId; |
| 52 | 52 | ||
| 53 | // 积分值 | 53 | /** 积分值 */ |
| 54 | @Column(name = "points") | 54 | @Column(name = "points") |
| 55 | private Long points; | 55 | private Long points; |
| 56 | 56 | ||
| 57 | // 过期时间 | 57 | /** 过期时间 */ |
| 58 | // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "") | 58 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "") |
| 59 | @Column(name = "expire_time") | 59 | @Column(name = "expire_time") |
| 60 | private LocalDateTime expireTime; | 60 | private LocalDateTime expireTime; |
| 61 | 61 | ||
| 62 | // 描述 | 62 | /** 描述 */ |
| 63 | @Column(name = "description") | 63 | @Column(name = "description") |
| 64 | private String description; | 64 | private String description; |
| 65 | 65 | ||
| 66 | // 创建时间 | 66 | /** 创建时间 */ |
| 67 | @CreatedDate | 67 | @CreatedDate |
| 68 | @Column(name = "create_time") | 68 | @Column(name = "create_time") |
| 69 | private Timestamp createTime; | 69 | private Timestamp createTime; |
| 70 | 70 | ||
| 71 | // 更新时间 | 71 | /** 更新时间 */ |
| 72 | @LastModifiedDate | 72 | @LastModifiedDate |
| 73 | @Column(name = "update_time") | 73 | @Column(name = "update_time") |
| 74 | private Timestamp updateTime; | 74 | private Timestamp updateTime; | ... | ... |
| ... | @@ -26,13 +26,13 @@ public interface PointsAvailableService { | ... | @@ -26,13 +26,13 @@ public interface PointsAvailableService { |
| 26 | * | 26 | * |
| 27 | * @param resources | 27 | * @param resources |
| 28 | */ | 28 | */ |
| 29 | void create(PointsAvailable resources); | 29 | PointsAvailableDTO create(PointsAvailable resources); |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | * | 32 | * |
| 33 | * @param resources | 33 | * @param resources |
| 34 | */ | 34 | */ |
| 35 | void update(PointsAvailable resources); | 35 | PointsAvailableDTO update(PointsAvailable resources); |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| 38 | * | 38 | * |
| ... | @@ -90,7 +90,15 @@ public interface PointsAvailableService { | ... | @@ -90,7 +90,15 @@ public interface PointsAvailableService { |
| 90 | */ | 90 | */ |
| 91 | long findTotalPointsByMemberId(Long memberId); | 91 | long findTotalPointsByMemberId(Long memberId); |
| 92 | 92 | ||
| 93 | /** | ||
| 94 | * | ||
| 95 | * @param id | ||
| 96 | */ | ||
| 93 | void delete4Custom(Long id); | 97 | void delete4Custom(Long id); |
| 94 | 98 | ||
| 95 | void create4Custom(PointsAvailable pointsAvailable); | 99 | /** |
| 100 | * | ||
| 101 | * @param pointsAvailable | ||
| 102 | */ | ||
| 103 | PointsAvailableDTO create4Custom(PointsAvailable pointsAvailable); | ||
| 96 | } | 104 | } | ... | ... |
| ... | @@ -13,33 +13,33 @@ import java.time.LocalDateTime; | ... | @@ -13,33 +13,33 @@ import java.time.LocalDateTime; |
| 13 | @Data | 13 | @Data |
| 14 | public class PointsAvailableDTO implements Serializable { | 14 | public class PointsAvailableDTO implements Serializable { |
| 15 | 15 | ||
| 16 | // 主键 | 16 | /** 主键 */ |
| 17 | private Long id; | 17 | private Long id; |
| 18 | 18 | ||
| 19 | // 标识 | 19 | /** 标识 */ |
| 20 | private String code; | 20 | private String code; |
| 21 | 21 | ||
| 22 | // 积分类型 0:通用型 | 22 | /** 积分类型 0:通用型 */ |
| 23 | private Integer pointsType; | 23 | private Integer pointsType; |
| 24 | 24 | ||
| 25 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 25 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ |
| 26 | private Integer deviceType; | 26 | private Integer deviceType; |
| 27 | 27 | ||
| 28 | // 会员id | 28 | /** 会员id */ |
| 29 | private Long memberId; | 29 | private Long memberId; |
| 30 | 30 | ||
| 31 | // 积分值 | 31 | /** 积分值 */ |
| 32 | private Long points; | 32 | private Long points; |
| 33 | 33 | ||
| 34 | // 过期时间 | 34 | /** 过期时间 */ |
| 35 | private LocalDateTime expireTime; | 35 | private LocalDateTime expireTime; |
| 36 | 36 | ||
| 37 | // 描述 | 37 | /** 描述 */ |
| 38 | private String description; | 38 | private String description; |
| 39 | 39 | ||
| 40 | // 创建时间 | 40 | /** 创建时间 */ |
| 41 | private Timestamp createTime; | 41 | private Timestamp createTime; |
| 42 | 42 | ||
| 43 | // 更新时间 | 43 | /** 更新时间 */ |
| 44 | private Timestamp updateTime; | 44 | private Timestamp updateTime; |
| 45 | } | 45 | } | ... | ... |
| ... | @@ -27,32 +27,33 @@ import java.util.*; | ... | @@ -27,32 +27,33 @@ import java.util.*; |
| 27 | public class PointsAvailableServiceImpl implements PointsAvailableService { | 27 | public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 28 | 28 | ||
| 29 | @Autowired | 29 | @Autowired |
| 30 | private PointsAvailableRepository PointsAvailableRepository; | 30 | private PointsAvailableRepository pointsAvailableRepository; |
| 31 | |||
| 32 | @Autowired | 31 | @Autowired |
| 33 | private PointsAvailableMapper PointsAvailableMapper; | 32 | private PointsAvailableMapper pointsAvailableMapper; |
| 34 | |||
| 35 | @Autowired | 33 | @Autowired |
| 36 | private RedisUtils redisUtils; | 34 | private RedisUtils redisUtils; |
| 37 | 35 | ||
| 38 | @Override | 36 | @Override |
| 39 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { | 37 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { |
| 40 | return PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdOrderByExpireTime(memberId)); | 38 | return this.pointsAvailableMapper.toDto(this.pointsAvailableRepository.findByMemberIdOrderByExpireTime(memberId)); |
| 41 | } | 39 | } |
| 42 | 40 | ||
| 43 | @Override | 41 | @Override |
| 44 | public PointsAvailableDTO findById(Long id) { | 42 | public PointsAvailableDTO findById(Long id) { |
| 45 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseGet(PointsAvailable::new); | 43 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.findById(id).orElseGet(PointsAvailable::new); |
| 46 | ValidationUtil.isNull(PointsAvailable.getId(),"PointsAvailable","id",id); | 44 | ValidationUtil.isNull(pointsAvailable.getId(),"PointsAvailable","id",id); |
| 47 | return PointsAvailableMapper.toDto(PointsAvailable); | 45 | return this.pointsAvailableMapper.toDto(pointsAvailable); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | @Override | 48 | @Override |
| 51 | @Transactional(rollbackFor = Exception.class) | 49 | @Transactional(rollbackFor = Exception.class) |
| 52 | public void create(PointsAvailable resources) { | 50 | public PointsAvailableDTO create(PointsAvailable resources) { |
| 53 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | ||
| 54 | try { | 51 | try { |
| 55 | PointsAvailableRepository.save(resources); | 52 | |
| 53 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | ||
| 54 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources); | ||
| 55 | |||
| 56 | return this.pointsAvailableMapper.toDto(pointsAvailable); | ||
| 56 | } catch (Exception e) { | 57 | } catch (Exception e) { |
| 57 | e.printStackTrace(); | 58 | e.printStackTrace(); |
| 58 | throw e; | 59 | throw e; |
| ... | @@ -63,13 +64,15 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -63,13 +64,15 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 63 | 64 | ||
| 64 | @Override | 65 | @Override |
| 65 | @Transactional(rollbackFor = Exception.class) | 66 | @Transactional(rollbackFor = Exception.class) |
| 66 | public void update(PointsAvailable resources) { | 67 | public PointsAvailableDTO update(PointsAvailable resources) { |
| 67 | this.redisUtils.doLock("PointsAvailable::update::id"+resources.getMemberId().toString()); | ||
| 68 | try { | 68 | try { |
| 69 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); | 69 | this.redisUtils.doLock("PointsAvailable::update::id"+resources.getMemberId().toString()); |
| 70 | ValidationUtil.isNull( PointsAvailable.getId(),"PointsAvailable","id",resources.getId()); | 70 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); |
| 71 | PointsAvailable.copy(resources); | 71 | ValidationUtil.isNull(pointsAvailable.getId(),"PointsAvailable","id",resources.getId()); |
| 72 | PointsAvailableRepository.save(PointsAvailable); | 72 | pointsAvailable.copy(resources); |
| 73 | PointsAvailable _pointsAvailable = this.pointsAvailableRepository.save(pointsAvailable); | ||
| 74 | |||
| 75 | return this.pointsAvailableMapper.toDto(_pointsAvailable); | ||
| 73 | } catch (Exception e) { | 76 | } catch (Exception e) { |
| 74 | e.printStackTrace(); | 77 | e.printStackTrace(); |
| 75 | throw e; | 78 | throw e; |
| ... | @@ -84,9 +87,9 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -84,9 +87,9 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 84 | Assert.notNull(id, "The given id must not be null!"); | 87 | Assert.notNull(id, "The given id must not be null!"); |
| 85 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); | 88 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); |
| 86 | try { | 89 | try { |
| 87 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | 90 | PointsAvailable PointsAvailable = this.pointsAvailableRepository.findById(id).orElseThrow( |
| 88 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | 91 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); |
| 89 | PointsAvailableRepository.delete(PointsAvailable); | 92 | this.pointsAvailableRepository.delete(PointsAvailable); |
| 90 | } catch (Exception e) { | 93 | } catch (Exception e) { |
| 91 | e.printStackTrace(); | 94 | e.printStackTrace(); |
| 92 | throw e; | 95 | throw e; |
| ... | @@ -100,7 +103,7 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -100,7 +103,7 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 100 | public void deleteBatchByIds(List<Long> id) { | 103 | public void deleteBatchByIds(List<Long> id) { |
| 101 | this.redisUtils.doLock("PointsAvailable::create::id"+id); | 104 | this.redisUtils.doLock("PointsAvailable::create::id"+id); |
| 102 | try { | 105 | try { |
| 103 | PointsAvailableRepository.deleteBatchByIds(id); | 106 | this.pointsAvailableRepository.deleteBatchByIds(id); |
| 104 | } catch (Exception e) { | 107 | } catch (Exception e) { |
| 105 | e.printStackTrace(); | 108 | e.printStackTrace(); |
| 106 | throw e; | 109 | throw e; |
| ... | @@ -112,31 +115,31 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -112,31 +115,31 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 112 | 115 | ||
| 113 | @Override | 116 | @Override |
| 114 | public PointsAvailableDTO getByCode(String code) { | 117 | public PointsAvailableDTO getByCode(String code) { |
| 115 | return StringUtils.isNotEmpty(code) ? PointsAvailableMapper.toDto(PointsAvailableRepository.findFirstByCode(code).orElseGet(PointsAvailable::new)) | 118 | return StringUtils.isNotEmpty(code) ? this.pointsAvailableMapper.toDto(this.pointsAvailableRepository.findFirstByCode(code).orElseGet(PointsAvailable::new)) |
| 116 | : new PointsAvailableDTO(); | 119 | : new PointsAvailableDTO(); |
| 117 | } | 120 | } |
| 118 | 121 | ||
| 119 | @Override | 122 | @Override |
| 120 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, LocalDateTime timestamp) { | 123 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, LocalDateTime timestamp) { |
| 121 | return Objects.nonNull(memberId)? | 124 | return Objects.nonNull(memberId)? |
| 122 | PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdAndExpireTimeBefore(memberId, timestamp)) | 125 | this.pointsAvailableMapper.toDto(this.pointsAvailableRepository.findByMemberIdAndExpireTimeBefore(memberId, timestamp)) |
| 123 | :null; | 126 | :null; |
| 124 | } | 127 | } |
| 125 | 128 | ||
| 126 | @Override | 129 | @Override |
| 127 | public Long findSoonExpireTime(Long memberId, Integer factor) { | 130 | public Long findSoonExpireTime(Long memberId, Integer factor) { |
| 128 | return PointsAvailableRepository.findSoonExpireTime(memberId, factor); | 131 | return this.pointsAvailableRepository.findSoonExpireTime(memberId, factor); |
| 129 | } | 132 | } |
| 130 | 133 | ||
| 131 | @Override | 134 | @Override |
| 132 | public long findAvailablePointsByMemberId(long memberId) { | 135 | public long findAvailablePointsByMemberId(long memberId) { |
| 133 | Long availablePoints = this.PointsAvailableRepository.findAvailablePointsByMemberId(memberId); | 136 | Long availablePoints = this.pointsAvailableRepository.findAvailablePointsByMemberId(memberId); |
| 134 | return availablePoints == null ? 0L : availablePoints; | 137 | return availablePoints == null ? 0L : availablePoints; |
| 135 | } | 138 | } |
| 136 | 139 | ||
| 137 | @Override | 140 | @Override |
| 138 | public long findTotalPointsByMemberId(Long memberId) { | 141 | public long findTotalPointsByMemberId(Long memberId) { |
| 139 | return this.PointsAvailableRepository.findTotalCountByMemberId(memberId); | 142 | return this.pointsAvailableRepository.findTotalCountByMemberId(memberId); |
| 140 | } | 143 | } |
| 141 | 144 | ||
| 142 | @Override | 145 | @Override |
| ... | @@ -144,9 +147,9 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -144,9 +147,9 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 144 | Assert.notNull(id, "The given id must not be null!"); | 147 | Assert.notNull(id, "The given id must not be null!"); |
| 145 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); | 148 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); |
| 146 | try { | 149 | try { |
| 147 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | 150 | PointsAvailable PointsAvailable = this.pointsAvailableRepository.findById(id).orElseThrow( |
| 148 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | 151 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); |
| 149 | PointsAvailableRepository.delete(PointsAvailable); | 152 | this.pointsAvailableRepository.delete(PointsAvailable); |
| 150 | } catch (Exception e) { | 153 | } catch (Exception e) { |
| 151 | e.printStackTrace(); | 154 | e.printStackTrace(); |
| 152 | throw e; | 155 | throw e; |
| ... | @@ -156,10 +159,11 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -156,10 +159,11 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 156 | } | 159 | } |
| 157 | 160 | ||
| 158 | @Override | 161 | @Override |
| 159 | public void create4Custom(PointsAvailable resources) { | 162 | public PointsAvailableDTO create4Custom(PointsAvailable resources) { |
| 160 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | 163 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); |
| 161 | try { | 164 | try { |
| 162 | PointsAvailableRepository.save(resources); | 165 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources); |
| 166 | return this.pointsAvailableMapper.toDto(pointsAvailable); | ||
| 163 | } catch (Exception e) { | 167 | } catch (Exception e) { |
| 164 | e.printStackTrace(); | 168 | e.printStackTrace(); |
| 165 | throw e; | 169 | throw e; | ... | ... |
| ... | @@ -2,10 +2,7 @@ package com.topdraw.business.module.points.detail.service; | ... | @@ -2,10 +2,7 @@ package com.topdraw.business.module.points.detail.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.points.detail.domain.PointsDetail; | 3 | import com.topdraw.business.module.points.detail.domain.PointsDetail; |
| 4 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; | 4 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; |
| 5 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria; | ||
| 6 | import org.springframework.data.domain.Pageable; | ||
| 7 | 5 | ||
| 8 | import java.util.Map; | ||
| 9 | import java.util.List; | 6 | import java.util.List; |
| 10 | 7 | ||
| 11 | /** | 8 | /** |
| ... | @@ -15,31 +12,30 @@ import java.util.List; | ... | @@ -15,31 +12,30 @@ import java.util.List; |
| 15 | public interface PointsDetailService { | 12 | public interface PointsDetailService { |
| 16 | 13 | ||
| 17 | /** | 14 | /** |
| 18 | * 查询数据分页 | ||
| 19 | * @param criteria 条件参数 | ||
| 20 | * @param pageable 分页参数 | ||
| 21 | * @return Map<String,Object> | ||
| 22 | */ | ||
| 23 | Map<String,Object> queryAll(PointsDetailQueryCriteria criteria, Pageable pageable); | ||
| 24 | |||
| 25 | /** | ||
| 26 | * 查询所有数据不分页 | ||
| 27 | * @param criteria 条件参数 | ||
| 28 | * @return List<PointsDetailDTO> | ||
| 29 | */ | ||
| 30 | List<PointsDetailDTO> queryAll(PointsDetailQueryCriteria criteria); | ||
| 31 | |||
| 32 | /** | ||
| 33 | * 根据ID查询 | 15 | * 根据ID查询 |
| 34 | * @param id ID | 16 | * @param id ID |
| 35 | * @return PointsDetailDTO | 17 | * @return PointsDetailDTO |
| 36 | */ | 18 | */ |
| 37 | PointsDetailDTO findById(Long id); | 19 | PointsDetailDTO findById(Long id); |
| 38 | 20 | ||
| 39 | void create(PointsDetail resources); | 21 | /** |
| 22 | * | ||
| 23 | * @param resources | ||
| 24 | * @return | ||
| 25 | */ | ||
| 26 | PointsDetailDTO create(PointsDetail resources); | ||
| 40 | 27 | ||
| 41 | void update(PointsDetail resources); | 28 | /** |
| 29 | * | ||
| 30 | * @param resources | ||
| 31 | * @return | ||
| 32 | */ | ||
| 33 | PointsDetailDTO update(PointsDetail resources); | ||
| 42 | 34 | ||
| 35 | /** | ||
| 36 | * | ||
| 37 | * @param id | ||
| 38 | */ | ||
| 43 | void delete(Long id); | 39 | void delete(Long id); |
| 44 | 40 | ||
| 45 | /** | 41 | /** |
| ... | @@ -49,9 +45,13 @@ public interface PointsDetailService { | ... | @@ -49,9 +45,13 @@ public interface PointsDetailService { |
| 49 | */ | 45 | */ |
| 50 | PointsDetailDTO getByCode(String code); | 46 | PointsDetailDTO getByCode(String code); |
| 51 | 47 | ||
| 48 | /** | ||
| 49 | * | ||
| 50 | * @param memberId | ||
| 51 | * @return | ||
| 52 | */ | ||
| 52 | List<PointsDetailDTO> loadListExpirePointsByMemberId(Long memberId); | 53 | List<PointsDetailDTO> loadListExpirePointsByMemberId(Long memberId); |
| 53 | 54 | ||
| 54 | |||
| 55 | /** | 55 | /** |
| 56 | * 已过期的积分 | 56 | * 已过期的积分 |
| 57 | * @param memberId | 57 | * @param memberId |
| ... | @@ -59,5 +59,9 @@ public interface PointsDetailService { | ... | @@ -59,5 +59,9 @@ public interface PointsDetailService { |
| 59 | */ | 59 | */ |
| 60 | List<PointsDetailDTO> findByMemberId(Long memberId); | 60 | List<PointsDetailDTO> findByMemberId(Long memberId); |
| 61 | 61 | ||
| 62 | /** | ||
| 63 | * | ||
| 64 | * @param pointsDetail | ||
| 65 | */ | ||
| 62 | void create4Custom(PointsDetail pointsDetail); | 66 | void create4Custom(PointsDetail pointsDetail); |
| 63 | } | 67 | } | ... | ... |
| 1 | package com.topdraw.business.module.points.detail.service.impl; | 1 | package com.topdraw.business.module.points.detail.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 4 | import com.topdraw.business.module.points.detail.domain.PointsDetail; | 3 | import com.topdraw.business.module.points.detail.domain.PointsDetail; |
| 5 | import com.topdraw.utils.ValidationUtil; | 4 | import com.topdraw.utils.ValidationUtil; |
| 6 | import com.topdraw.business.module.points.detail.repository.PointsDetailRepository; | 5 | import com.topdraw.business.module.points.detail.repository.PointsDetailRepository; |
| 7 | import com.topdraw.business.module.points.detail.service.PointsDetailService; | 6 | import com.topdraw.business.module.points.detail.service.PointsDetailService; |
| 8 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; | 7 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; |
| 9 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria; | ||
| 10 | import com.topdraw.business.module.points.detail.service.mapper.PointsDetailMapper; | 8 | import com.topdraw.business.module.points.detail.service.mapper.PointsDetailMapper; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 13 | import org.springframework.transaction.annotation.Propagation; | 11 | import org.springframework.transaction.annotation.Propagation; |
| 14 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
| 15 | import org.springframework.dao.EmptyResultDataAccessException; | 13 | 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; | 14 | import org.springframework.util.Assert; |
| 19 | import com.topdraw.utils.PageUtil; | ||
| 20 | import com.topdraw.utils.QueryHelp; | ||
| 21 | import com.topdraw.utils.StringUtils; | 15 | import com.topdraw.utils.StringUtils; |
| 22 | 16 | ||
| 23 | import java.util.List; | 17 | import java.util.List; |
| 24 | import java.util.Map; | ||
| 25 | import java.util.Objects; | 18 | import java.util.Objects; |
| 26 | 19 | ||
| 27 | /** | 20 | /** |
| ... | @@ -33,57 +26,47 @@ import java.util.Objects; | ... | @@ -33,57 +26,47 @@ import java.util.Objects; |
| 33 | public class PointsDetailServiceImpl implements PointsDetailService { | 26 | public class PointsDetailServiceImpl implements PointsDetailService { |
| 34 | 27 | ||
| 35 | @Autowired | 28 | @Autowired |
| 36 | private PointsDetailRepository PointsDetailRepository; | 29 | private PointsDetailRepository pointsDetailRepository; |
| 37 | |||
| 38 | @Autowired | 30 | @Autowired |
| 39 | private PointsDetailMapper PointsDetailMapper; | 31 | private PointsDetailMapper pointsDetailMapper; |
| 40 | |||
| 41 | @Override | ||
| 42 | public Map<String, Object> queryAll(PointsDetailQueryCriteria criteria, Pageable pageable) { | ||
| 43 | Page<PointsDetail> page = PointsDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
| 44 | return PageUtil.toPage(page.map(PointsDetailMapper::toDto)); | ||
| 45 | } | ||
| 46 | |||
| 47 | @Override | ||
| 48 | public List<PointsDetailDTO> queryAll(PointsDetailQueryCriteria criteria) { | ||
| 49 | return PointsDetailMapper.toDto(PointsDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
| 50 | } | ||
| 51 | 32 | ||
| 52 | @Override | 33 | @Override |
| 53 | public PointsDetailDTO findById(Long id) { | 34 | public PointsDetailDTO findById(Long id) { |
| 54 | PointsDetail PointsDetail = PointsDetailRepository.findById(id).orElseGet(PointsDetail::new); | 35 | PointsDetail pointsDetail = this.pointsDetailRepository.findById(id).orElseGet(PointsDetail::new); |
| 55 | ValidationUtil.isNull(PointsDetail.getId(),"PointsDetail","id",id); | 36 | ValidationUtil.isNull(pointsDetail.getId(),"PointsDetail","id",id); |
| 56 | return PointsDetailMapper.toDto(PointsDetail); | 37 | return this.pointsDetailMapper.toDto(pointsDetail); |
| 57 | } | 38 | } |
| 58 | 39 | ||
| 59 | @Override | 40 | @Override |
| 60 | @Transactional(rollbackFor = Exception.class) | 41 | @Transactional(rollbackFor = Exception.class) |
| 61 | public void create(PointsDetail resources) { | 42 | public PointsDetailDTO create(PointsDetail resources) { |
| 62 | PointsDetailRepository.save(resources); | 43 | PointsDetail pointsDetail = this.pointsDetailRepository.save(resources); |
| 44 | return this.pointsDetailMapper.toDto(pointsDetail); | ||
| 63 | } | 45 | } |
| 64 | 46 | ||
| 65 | @Override | 47 | @Override |
| 66 | @Transactional(rollbackFor = Exception.class) | 48 | @Transactional(rollbackFor = Exception.class) |
| 67 | public void update(PointsDetail resources) { | 49 | public PointsDetailDTO update(PointsDetail resources) { |
| 68 | PointsDetail PointsDetail = PointsDetailRepository.findById(resources.getId()).orElseGet(PointsDetail::new); | 50 | PointsDetail pointsDetail = this.pointsDetailRepository.findById(resources.getId()).orElseGet(PointsDetail::new); |
| 69 | ValidationUtil.isNull( PointsDetail.getId(),"PointsDetail","id",resources.getId()); | 51 | ValidationUtil.isNull( pointsDetail.getId(),"PointsDetail","id",resources.getId()); |
| 70 | PointsDetail.copy(resources); | 52 | pointsDetail.copy(resources); |
| 71 | PointsDetailRepository.save(PointsDetail); | 53 | PointsDetail _pointsDetail = this.pointsDetailRepository.save(pointsDetail); |
| 54 | return this.pointsDetailMapper.toDto(_pointsDetail); | ||
| 72 | } | 55 | } |
| 73 | 56 | ||
| 74 | @Override | 57 | @Override |
| 75 | @Transactional(rollbackFor = Exception.class) | 58 | @Transactional(rollbackFor = Exception.class) |
| 76 | public void delete(Long id) { | 59 | public void delete(Long id) { |
| 77 | Assert.notNull(id, "The given id must not be null!"); | 60 | Assert.notNull(id, "The given id must not be null!"); |
| 78 | PointsDetail PointsDetail = PointsDetailRepository.findById(id).orElseThrow( | 61 | PointsDetail pointsDetail = this.pointsDetailRepository.findById(id).orElseThrow( |
| 79 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsDetail.class, id), 1)); | 62 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsDetail.class, id), 1)); |
| 80 | PointsDetailRepository.delete(PointsDetail); | 63 | this.pointsDetailRepository.delete(pointsDetail); |
| 81 | } | 64 | } |
| 82 | 65 | ||
| 83 | 66 | ||
| 84 | @Override | 67 | @Override |
| 85 | public PointsDetailDTO getByCode(String code) { | 68 | public PointsDetailDTO getByCode(String code) { |
| 86 | return StringUtils.isNotEmpty(code) ? PointsDetailMapper.toDto(PointsDetailRepository.findFirstByCode(code).orElseGet(PointsDetail::new)) | 69 | return StringUtils.isNotEmpty(code) ? this.pointsDetailMapper.toDto(this.pointsDetailRepository.findFirstByCode(code).orElseGet(PointsDetail::new)) |
| 87 | : new PointsDetailDTO(); | 70 | : new PointsDetailDTO(); |
| 88 | } | 71 | } |
| 89 | 72 | ||
| ... | @@ -95,12 +78,12 @@ public class PointsDetailServiceImpl implements PointsDetailService { | ... | @@ -95,12 +78,12 @@ public class PointsDetailServiceImpl implements PointsDetailService { |
| 95 | @Override | 78 | @Override |
| 96 | public List<PointsDetailDTO> findByMemberId(Long memberId) { | 79 | public List<PointsDetailDTO> findByMemberId(Long memberId) { |
| 97 | return Objects.nonNull(memberId)? | 80 | return Objects.nonNull(memberId)? |
| 98 | PointsDetailMapper.toDto(PointsDetailRepository.findByMemberId(memberId)) | 81 | this.pointsDetailMapper.toDto(this.pointsDetailRepository.findByMemberId(memberId)) |
| 99 | :null; | 82 | :null; |
| 100 | } | 83 | } |
| 101 | 84 | ||
| 102 | @Override | 85 | @Override |
| 103 | public void create4Custom(PointsDetail pointsDetail) { | 86 | public void create4Custom(PointsDetail pointsDetail) { |
| 104 | PointsDetailRepository.save(pointsDetail); | 87 | this.pointsDetailRepository.save(pointsDetail); |
| 105 | } | 88 | } |
| 106 | } | 89 | } | ... | ... |
| ... | @@ -27,35 +27,37 @@ public class Points implements Serializable { | ... | @@ -27,35 +27,37 @@ public class Points implements Serializable { |
| 27 | @Column(name = "id") | 27 | @Column(name = "id") |
| 28 | private Long id; | 28 | private Long id; |
| 29 | 29 | ||
| 30 | /** 账号id */ | ||
| 30 | @Column(name = "user_id") | 31 | @Column(name = "user_id") |
| 31 | private Long userId; | 32 | private Long userId; |
| 32 | 33 | ||
| 33 | // 积分类型,通用,绑定, 区分大小屏 | 34 | /** 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) |
| 35 | 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途)*/ | ||
| 34 | @Column(name = "point_type") | 36 | @Column(name = "point_type") |
| 35 | private Integer pointType; | 37 | private Integer pointType; |
| 36 | 38 | ||
| 37 | // 绑定对应的实体, 如何描述? | 39 | /** 绑定对应的实体, 如何描述? */ |
| 38 | @Column(name = "target_no") | 40 | @Column(name = "target_no") |
| 39 | private String targetNo; | 41 | private String targetNo; |
| 40 | 42 | ||
| 41 | // 本月期初积分值 | 43 | /** 本月期初积分值 */ |
| 42 | @Column(name = "begin_points") | 44 | @Column(name = "begin_points") |
| 43 | private Integer beginPoints; | 45 | private Integer beginPoints; |
| 44 | 46 | ||
| 45 | // 当前积分余额 | 47 | /** 当前积分余额 */ |
| 46 | @Column(name = "current_points") | 48 | @Column(name = "current_points") |
| 47 | private Integer currentPoints; | 49 | private Integer currentPoints; |
| 48 | 50 | ||
| 49 | // 本月到期积分 | 51 | /** 本月到期积分 */ |
| 50 | @Column(name = "expire_points") | 52 | @Column(name = "expire_points") |
| 51 | private Integer expirePoints; | 53 | private Integer expirePoints; |
| 52 | 54 | ||
| 53 | // 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途) | 55 | /** 创建时间 */ |
| 54 | @CreatedDate | 56 | @CreatedDate |
| 55 | @Column(name = "create_time") | 57 | @Column(name = "create_time") |
| 56 | private Timestamp createTime; | 58 | private Timestamp createTime; |
| 57 | 59 | ||
| 58 | // 最后修改时间 | 60 | /** 最后修改时间 */ |
| 59 | @LastModifiedDate | 61 | @LastModifiedDate |
| 60 | @Column(name = "update_time") | 62 | @Column(name = "update_time") |
| 61 | private Timestamp updateTime; | 63 | private Timestamp updateTime; | ... | ... |
| ... | @@ -2,10 +2,6 @@ package com.topdraw.business.module.points.service; | ... | @@ -2,10 +2,6 @@ package com.topdraw.business.module.points.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.points.domain.Points; | 3 | import com.topdraw.business.module.points.domain.Points; |
| 4 | import com.topdraw.business.module.points.service.dto.PointsDTO; | 4 | import com.topdraw.business.module.points.service.dto.PointsDTO; |
| 5 | import com.topdraw.business.module.points.service.dto.PointsQueryCriteria; | ||
| 6 | import org.springframework.data.domain.Pageable; | ||
| 7 | import java.util.Map; | ||
| 8 | import java.util.List; | ||
| 9 | 5 | ||
| 10 | /** | 6 | /** |
| 11 | * @author XiangHan | 7 | * @author XiangHan |
| ... | @@ -14,31 +10,28 @@ import java.util.List; | ... | @@ -14,31 +10,28 @@ import java.util.List; |
| 14 | public interface PointsService { | 10 | public interface PointsService { |
| 15 | 11 | ||
| 16 | /** | 12 | /** |
| 17 | * 查询数据分页 | ||
| 18 | * @param criteria 条件参数 | ||
| 19 | * @param pageable 分页参数 | ||
| 20 | * @return Map<String,Object> | ||
| 21 | */ | ||
| 22 | Map<String,Object> queryAll(PointsQueryCriteria criteria, Pageable pageable); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * 查询所有数据不分页 | ||
| 26 | * @param criteria 条件参数 | ||
| 27 | * @return List<PointsDTO> | ||
| 28 | */ | ||
| 29 | List<PointsDTO> queryAll(PointsQueryCriteria criteria); | ||
| 30 | |||
| 31 | /** | ||
| 32 | * 根据ID查询 | 13 | * 根据ID查询 |
| 33 | * @param id ID | 14 | * @param id ID |
| 34 | * @return PointsDTO | 15 | * @return PointsDTO |
| 35 | */ | 16 | */ |
| 36 | PointsDTO findById(Long id); | 17 | PointsDTO findById(Long id); |
| 37 | 18 | ||
| 38 | void create(Points resources); | 19 | /** |
| 20 | * | ||
| 21 | * @param resources | ||
| 22 | */ | ||
| 23 | PointsDTO create(Points resources); | ||
| 39 | 24 | ||
| 40 | void update(Points resources); | 25 | /** |
| 26 | * | ||
| 27 | * @param resources | ||
| 28 | */ | ||
| 29 | PointsDTO update(Points resources); | ||
| 41 | 30 | ||
| 31 | /** | ||
| 32 | * | ||
| 33 | * @param id | ||
| 34 | */ | ||
| 42 | void delete(Long id); | 35 | void delete(Long id); |
| 43 | 36 | ||
| 44 | } | 37 | } | ... | ... |
| ... | @@ -18,26 +18,30 @@ public class PointsDTO implements Serializable { | ... | @@ -18,26 +18,30 @@ public class PointsDTO implements Serializable { |
| 18 | @JsonSerialize(using= ToStringSerializer.class) | 18 | @JsonSerialize(using= ToStringSerializer.class) |
| 19 | private Long id; | 19 | private Long id; |
| 20 | 20 | ||
| 21 | /** 账号id */ | ||
| 21 | private Long userId; | 22 | private Long userId; |
| 22 | 23 | ||
| 23 | // 积分类型,通用,绑定, 区分大小屏 todo | 24 | /** 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) |
| 25 | 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途)*/ | ||
| 24 | private Integer pointType; | 26 | private Integer pointType; |
| 25 | 27 | ||
| 26 | // 绑定对应的实体, 如何描述? | 28 | /** 绑定对应的实体, 如何描述? */ |
| 27 | private String targetNo; | 29 | private String targetNo; |
| 28 | 30 | ||
| 29 | // 本月期初积分值 | 31 | /** 本月期初积分值 */ |
| 30 | private Integer beginPoints; | 32 | private Integer beginPoints; |
| 31 | 33 | ||
| 32 | // 当前积分余额 | 34 | /** 当前积分余额 */ |
| 33 | private Integer currentPoints; | 35 | private Integer currentPoints; |
| 34 | 36 | ||
| 35 | // 本月到期积分 | 37 | /** 本月到期积分 */ |
| 36 | private Integer expirePoints; | 38 | private Integer expirePoints; |
| 37 | 39 | ||
| 38 | // 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途) | 40 | /** 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) |
| 41 | * 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途) | ||
| 42 | */ | ||
| 39 | private Timestamp createTime; | 43 | private Timestamp createTime; |
| 40 | 44 | ||
| 41 | // 最后修改时间 | 45 | /** 最后修改时间 */ |
| 42 | private Timestamp updateTime; | 46 | private Timestamp updateTime; |
| 43 | } | 47 | } | ... | ... |
| ... | @@ -6,23 +6,14 @@ import com.topdraw.utils.ValidationUtil; | ... | @@ -6,23 +6,14 @@ import com.topdraw.utils.ValidationUtil; |
| 6 | import com.topdraw.business.module.points.repository.PointsRepository; | 6 | import com.topdraw.business.module.points.repository.PointsRepository; |
| 7 | import com.topdraw.business.module.points.service.PointsService; | 7 | import com.topdraw.business.module.points.service.PointsService; |
| 8 | import com.topdraw.business.module.points.service.dto.PointsDTO; | 8 | import com.topdraw.business.module.points.service.dto.PointsDTO; |
| 9 | import com.topdraw.business.module.points.service.dto.PointsQueryCriteria; | ||
| 10 | import com.topdraw.business.module.points.service.mapper.PointsMapper; | 9 | import com.topdraw.business.module.points.service.mapper.PointsMapper; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 13 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
| 14 | import org.springframework.transaction.annotation.Transactional; | 13 | import org.springframework.transaction.annotation.Transactional; |
| 15 | import org.springframework.dao.EmptyResultDataAccessException; | 14 | import org.springframework.dao.EmptyResultDataAccessException; |
| 16 | import cn.hutool.core.lang.Snowflake; | ||
| 17 | import cn.hutool.core.util.IdUtil; | ||
| 18 | import org.springframework.data.domain.Page; | ||
| 19 | import org.springframework.data.domain.Pageable; | ||
| 20 | import org.springframework.util.Assert; | 15 | import org.springframework.util.Assert; |
| 21 | import com.topdraw.utils.PageUtil; | ||
| 22 | import com.topdraw.utils.QueryHelp; | ||
| 23 | 16 | ||
| 24 | import java.util.List; | ||
| 25 | import java.util.Map; | ||
| 26 | 17 | ||
| 27 | /** | 18 | /** |
| 28 | * @author XiangHan | 19 | * @author XiangHan |
| ... | @@ -33,49 +24,39 @@ import java.util.Map; | ... | @@ -33,49 +24,39 @@ import java.util.Map; |
| 33 | public class PointsServiceImpl implements PointsService { | 24 | public class PointsServiceImpl implements PointsService { |
| 34 | 25 | ||
| 35 | @Autowired | 26 | @Autowired |
| 36 | private PointsRepository PointsRepository; | 27 | private PointsRepository pointsRepository; |
| 37 | |||
| 38 | @Autowired | 28 | @Autowired |
| 39 | private PointsMapper PointsMapper; | 29 | private PointsMapper pointsMapper; |
| 40 | |||
| 41 | @Autowired | 30 | @Autowired |
| 42 | private RedisUtils redisUtils; | 31 | private RedisUtils redisUtils; |
| 43 | 32 | ||
| 44 | @Override | 33 | @Override |
| 45 | public Map<String, Object> queryAll(PointsQueryCriteria criteria, Pageable pageable) { | ||
| 46 | Page<Points> page = PointsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
| 47 | return PageUtil.toPage(page.map(PointsMapper::toDto)); | ||
| 48 | } | ||
| 49 | |||
| 50 | @Override | ||
| 51 | public List<PointsDTO> queryAll(PointsQueryCriteria criteria) { | ||
| 52 | return PointsMapper.toDto(PointsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
| 53 | } | ||
| 54 | |||
| 55 | @Override | ||
| 56 | public PointsDTO findById(Long id) { | 34 | public PointsDTO findById(Long id) { |
| 57 | Points Points = PointsRepository.findById(id).orElseGet(Points::new); | 35 | Points Points = this.pointsRepository.findById(id).orElseGet(Points::new); |
| 58 | ValidationUtil.isNull(Points.getId(),"Points","id",id); | 36 | ValidationUtil.isNull(Points.getId(),"Points","id",id); |
| 59 | return PointsMapper.toDto(Points); | 37 | return this.pointsMapper.toDto(Points); |
| 60 | } | 38 | } |
| 61 | 39 | ||
| 62 | @Override | 40 | @Override |
| 63 | @Transactional(rollbackFor = Exception.class) | 41 | @Transactional(rollbackFor = Exception.class) |
| 64 | public void create(Points resources) { | 42 | public PointsDTO create(Points resources) { |
| 65 | Snowflake snowflake = IdUtil.createSnowflake(1, 1); | 43 | |
| 66 | resources.setId(snowflake.nextId()); | 44 | Points points = this.pointsRepository.save(resources); |
| 67 | PointsRepository.save(resources); | 45 | |
| 46 | return this.pointsMapper.toDto(points); | ||
| 68 | } | 47 | } |
| 69 | 48 | ||
| 70 | @Override | 49 | @Override |
| 71 | @Transactional(rollbackFor = Exception.class) | 50 | @Transactional(rollbackFor = Exception.class) |
| 72 | public void update(Points resources) { | 51 | public PointsDTO update(Points resources) { |
| 73 | this.redisUtils.doLock("Points::update::userId"+resources.getUserId().toString()); | 52 | this.redisUtils.doLock("Points::update::userId"+resources.getUserId().toString()); |
| 74 | try { | 53 | try { |
| 75 | Points Points = PointsRepository.findById(resources.getId()).orElseGet(Points::new); | 54 | Points points = this.pointsRepository.findById(resources.getId()).orElseGet(Points::new); |
| 76 | ValidationUtil.isNull(Points.getId(), "Points", "id", resources.getId()); | 55 | ValidationUtil.isNull(points.getId(), "Points", "id", resources.getId()); |
| 77 | Points.copy(resources); | 56 | points.copy(resources); |
| 78 | PointsRepository.save(Points); | 57 | this.pointsRepository.save(points); |
| 58 | |||
| 59 | return this.pointsMapper.toDto(points); | ||
| 79 | } catch (Exception e) { | 60 | } catch (Exception e) { |
| 80 | e.printStackTrace(); | 61 | e.printStackTrace(); |
| 81 | throw e; | 62 | throw e; |
| ... | @@ -88,9 +69,9 @@ public class PointsServiceImpl implements PointsService { | ... | @@ -88,9 +69,9 @@ public class PointsServiceImpl implements PointsService { |
| 88 | @Transactional(rollbackFor = Exception.class) | 69 | @Transactional(rollbackFor = Exception.class) |
| 89 | public void delete(Long id) { | 70 | public void delete(Long id) { |
| 90 | Assert.notNull(id, "The given id must not be null!"); | 71 | Assert.notNull(id, "The given id must not be null!"); |
| 91 | Points Points = PointsRepository.findById(id).orElseThrow( | 72 | Points Points = this.pointsRepository.findById(id).orElseThrow( |
| 92 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Points.class, id), 1)); | 73 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Points.class, id), 1)); |
| 93 | PointsRepository.delete(Points); | 74 | this.pointsRepository.delete(Points); |
| 94 | } | 75 | } |
| 95 | 76 | ||
| 96 | 77 | ... | ... |
| ... | @@ -23,63 +23,63 @@ import java.io.Serializable; | ... | @@ -23,63 +23,63 @@ import java.io.Serializable; |
| 23 | @Table(name="tr_rights") | 23 | @Table(name="tr_rights") |
| 24 | public class Rights implements Serializable { | 24 | public class Rights implements Serializable { |
| 25 | 25 | ||
| 26 | // 主键 | 26 | /** 主键 */ |
| 27 | @Id | 27 | @Id |
| 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 29 | @Column(name = "id") | 29 | @Column(name = "id") |
| 30 | private Long id; | 30 | private Long id; |
| 31 | 31 | ||
| 32 | // 标识 | 32 | /** 标识 */ |
| 33 | @Column(name = "code", nullable = false) | 33 | @Column(name = "code", nullable = false) |
| 34 | private String code; | 34 | private String code; |
| 35 | 35 | ||
| 36 | // 权益名称 | 36 | /** 权益名称 */ |
| 37 | // @Column(name = "name") | 37 | @Column(name = "name") |
| 38 | // private String name; | 38 | private String name; |
| 39 | 39 | ||
| 40 | // 类型 1:实体类 (预留字段) | 40 | /** 类型 1:实体类 (预留字段) */ |
| 41 | @Column(name = "type", nullable = false) | 41 | @Column(name = "type", nullable = false) |
| 42 | private Integer type; | 42 | private Integer type; |
| 43 | 43 | ||
| 44 | // 终端类型 0:大屏;1:微信小程序/公众号;2:App | 44 | /** 终端类型 0:大屏;1:微信小程序/公众号;2:App */ |
| 45 | @Column(name = "device_type", nullable = false) | 45 | @Column(name = "device_type", nullable = false) |
| 46 | private Integer deviceType; | 46 | private Integer deviceType; |
| 47 | 47 | ||
| 48 | // 权益的实体类型 1:积分;2成长值;3优惠券 | 48 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ |
| 49 | @Column(name = "entity_type", nullable = false) | 49 | @Column(name = "entity_type", nullable = false) |
| 50 | private String entityType; | 50 | private String entityType; |
| 51 | 51 | ||
| 52 | // 实体id | 52 | /** 实体id */ |
| 53 | @Column(name = "entity_id", nullable = false) | 53 | @Column(name = "entity_id", nullable = false) |
| 54 | private Long entityId; | 54 | private Long entityId; |
| 55 | 55 | ||
| 56 | // 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 | 56 | /** 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 */ |
| 57 | @Column(name = "valid_time") | 57 | @Column(name = "valid_time") |
| 58 | private Timestamp validTime; | 58 | private Timestamp validTime; |
| 59 | 59 | ||
| 60 | // 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 | 60 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ |
| 61 | @Column(name = "expire_time") | 61 | @Column(name = "expire_time") |
| 62 | private Long expireTime; | 62 | private Long expireTime; |
| 63 | 63 | ||
| 64 | // 创建时间 | 64 | /** 创建时间 */ |
| 65 | @CreatedDate | 65 | @CreatedDate |
| 66 | @Column(name = "create_time") | 66 | @Column(name = "create_time") |
| 67 | private Timestamp createTime; | 67 | private Timestamp createTime; |
| 68 | 68 | ||
| 69 | // 更新时间 | 69 | /** 更新时间 */ |
| 70 | @LastModifiedDate | 70 | @LastModifiedDate |
| 71 | @Column(name = "update_time") | 71 | @Column(name = "update_time") |
| 72 | private Timestamp updateTime; | 72 | private Timestamp updateTime; |
| 73 | 73 | ||
| 74 | // 图片 | 74 | /** 图片 */ |
| 75 | @Column(name = "image") | 75 | @Column(name = "image") |
| 76 | private String image; | 76 | private String image; |
| 77 | 77 | ||
| 78 | // 图片 | 78 | /** 图片 */ |
| 79 | @Column(name = "images") | 79 | @Column(name = "images") |
| 80 | private String images; | 80 | private String images; |
| 81 | 81 | ||
| 82 | // 描述 | 82 | /** 描述 */ |
| 83 | @Column(name = "description") | 83 | @Column(name = "description") |
| 84 | private String description; | 84 | private String description; |
| 85 | 85 | ... | ... |
| ... | @@ -12,44 +12,45 @@ import java.io.Serializable; | ... | @@ -12,44 +12,45 @@ import java.io.Serializable; |
| 12 | @Data | 12 | @Data |
| 13 | public class RightsDTO implements Serializable { | 13 | public class RightsDTO implements Serializable { |
| 14 | 14 | ||
| 15 | // 主键 | 15 | /** 主键 */ |
| 16 | private Long id; | 16 | private Long id; |
| 17 | 17 | ||
| 18 | // 标识 | 18 | /** 标识 */ |
| 19 | private String code; | 19 | private String code; |
| 20 | 20 | ||
| 21 | // 权益名称 | 21 | /** 权益名称 */ |
| 22 | // private String name; | 22 | private String name; |
| 23 | // 终端类型 0:大屏;1:微信小程序/公众号;2:App | 23 | |
| 24 | /** 终端类型 0:大屏;1:微信小程序/公众号;2:App */ | ||
| 24 | private Integer deviceType; | 25 | private Integer deviceType; |
| 25 | 26 | ||
| 26 | // 类型 1:实体类 (预留字段) | 27 | /** 类型 1:实体类 (预留字段) */ |
| 27 | private Integer type; | 28 | private Integer type; |
| 28 | 29 | ||
| 29 | // 权益的实体类型 1:积分;2成长值;3优惠券 | 30 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ |
| 30 | private String entityType; | 31 | private String entityType; |
| 31 | 32 | ||
| 32 | // 实体id | 33 | /** 实体id */ |
| 33 | private Long entityId; | 34 | private Long entityId; |
| 34 | 35 | ||
| 35 | // 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 | 36 | /** 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 */ |
| 36 | private Timestamp validTime; | 37 | private Timestamp validTime; |
| 37 | 38 | ||
| 38 | // 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 | 39 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ |
| 39 | private Long expireTime; | 40 | private Long expireTime; |
| 40 | 41 | ||
| 41 | // 创建时间 | 42 | /** 创建时间 */ |
| 42 | private Timestamp createTime; | 43 | private Timestamp createTime; |
| 43 | 44 | ||
| 44 | // 更新时间 | 45 | /** 更新时间 */ |
| 45 | private Timestamp updateTime; | 46 | private Timestamp updateTime; |
| 46 | 47 | ||
| 47 | // 图片 | 48 | /** 图片 */ |
| 48 | private String image; | 49 | private String image; |
| 49 | 50 | ||
| 50 | // 图片 | 51 | /** 图片 */ |
| 51 | private String images; | 52 | private String images; |
| 52 | 53 | ||
| 53 | // 描述 | 54 | /** 描述 */ |
| 54 | private String description; | 55 | private String description; |
| 55 | } | 56 | } | ... | ... |
| 1 | package com.topdraw.business.module.rights.service.dto; | ||
| 2 | |||
| 3 | import com.topdraw.annotation.Query; | ||
| 4 | import lombok.Data; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * @author XiangHan | ||
| 8 | * @date 2021-10-22 | ||
| 9 | */ | ||
| 10 | @Data | ||
| 11 | public class RightsQueryCriteria{ | ||
| 12 | |||
| 13 | @Query | ||
| 14 | private Long memberId; | ||
| 15 | |||
| 16 | private RightsQueryType queryType; | ||
| 17 | |||
| 18 | } |
| ... | @@ -20,24 +20,20 @@ import org.springframework.transaction.annotation.Transactional; | ... | @@ -20,24 +20,20 @@ import org.springframework.transaction.annotation.Transactional; |
| 20 | public class RightsServiceImpl implements RightsService { | 20 | public class RightsServiceImpl implements RightsService { |
| 21 | 21 | ||
| 22 | @Autowired | 22 | @Autowired |
| 23 | private RightsRepository RightsRepository; | 23 | private RightsRepository rightsRepository; |
| 24 | |||
| 25 | @Autowired | ||
| 26 | private RightsMapper RightsMapper; | ||
| 27 | |||
| 28 | @Autowired | 24 | @Autowired |
| 29 | private RedisUtils redisUtils; | 25 | private RightsMapper rightsMapper; |
| 30 | 26 | ||
| 31 | @Override | 27 | @Override |
| 32 | public RightsDTO findById(Long id) { | 28 | public RightsDTO findById(Long id) { |
| 33 | Rights Rights = RightsRepository.findById(id).orElseGet(Rights::new); | 29 | Rights Rights = this.rightsRepository.findById(id).orElseGet(Rights::new); |
| 34 | ValidationUtil.isNull(Rights.getId(),"Rights","id",id); | 30 | ValidationUtil.isNull(Rights.getId(),"Rights","id",id); |
| 35 | return RightsMapper.toDto(Rights); | 31 | return this.rightsMapper.toDto(Rights); |
| 36 | } | 32 | } |
| 37 | 33 | ||
| 38 | @Override | 34 | @Override |
| 39 | public RightsDTO getByCode(String code) { | 35 | public RightsDTO getByCode(String code) { |
| 40 | return StringUtils.isNotEmpty(code) ? RightsMapper.toDto(RightsRepository.findFirstByCode(code).orElseGet(Rights::new)) | 36 | return StringUtils.isNotEmpty(code) ? this.rightsMapper.toDto(this.rightsRepository.findFirstByCode(code).orElseGet(Rights::new)) |
| 41 | : new RightsDTO(); | 37 | : new RightsDTO(); |
| 42 | } | 38 | } |
| 43 | } | 39 | } | ... | ... |
| ... | @@ -22,13 +22,13 @@ public interface UserTvService { | ... | @@ -22,13 +22,13 @@ public interface UserTvService { |
| 22 | * @param resources | 22 | * @param resources |
| 23 | * @return | 23 | * @return |
| 24 | */ | 24 | */ |
| 25 | UserTv create(UserTv resources); | 25 | UserTvDTO create(UserTv resources); |
| 26 | 26 | ||
| 27 | /** | 27 | /** |
| 28 | * | 28 | * |
| 29 | * @param resources | 29 | * @param resources |
| 30 | */ | 30 | */ |
| 31 | void update(UserTv resources); | 31 | UserTvDTO update(UserTv resources); |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * | 34 | * | ... | ... |
| ... | @@ -81,24 +81,25 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -81,24 +81,25 @@ public class UserTvServiceImpl implements UserTvService { |
| 81 | 81 | ||
| 82 | @Override | 82 | @Override |
| 83 | @Transactional(rollbackFor = Exception.class) | 83 | @Transactional(rollbackFor = Exception.class) |
| 84 | public UserTv create(UserTv resources) { | 84 | public UserTvDTO create(UserTv resources) { |
| 85 | MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode()); | 85 | MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode()); |
| 86 | if (Objects.nonNull(memberDTO)) { | 86 | if (Objects.nonNull(memberDTO)) { |
| 87 | Long id = memberDTO.getId(); | 87 | Long id = memberDTO.getId(); |
| 88 | resources.setMemberId(id); | 88 | resources.setMemberId(id); |
| 89 | this.userTvRepository.save(resources); | 89 | UserTv userTv = this.userTvRepository.save(resources); |
| 90 | return resources; | 90 | return this.userTvMapper.toDto(userTv); |
| 91 | } | 91 | } |
| 92 | return null; | 92 | return null; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | @Override | 95 | @Override |
| 96 | @Transactional(rollbackFor = Exception.class) | 96 | @Transactional(rollbackFor = Exception.class) |
| 97 | public void update(UserTv resources) { | 97 | public UserTvDTO update(UserTv resources) { |
| 98 | UserTv UserTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new); | 98 | UserTv userTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new); |
| 99 | ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); | 99 | ValidationUtil.isNull(userTv.getId(),"UserTv","id",resources.getId()); |
| 100 | UserTv.copy(resources); | 100 | userTv.copy(resources); |
| 101 | this.userTvRepository.save(UserTv); | 101 | UserTv _userTv = this.userTvRepository.save(userTv); |
| 102 | return this.userTvMapper.toDto(_userTv); | ||
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | @Override | 105 | @Override | ... | ... |
| 1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.aop.log.Log; | ||
| 3 | import com.topdraw.business.process.domian.TempCoupon; | 4 | import com.topdraw.business.process.domian.TempCoupon; |
| 4 | import com.topdraw.business.process.service.CouponOperationService; | 5 | import com.topdraw.business.process.service.CouponOperationService; |
| 5 | import com.topdraw.common.ResultInfo; | 6 | import com.topdraw.common.ResultInfo; |
| ... | @@ -14,14 +15,15 @@ import java.util.List; | ... | @@ -14,14 +15,15 @@ import java.util.List; |
| 14 | * @author XiangHan | 15 | * @author XiangHan |
| 15 | * @date 2021-10-22 | 16 | * @date 2021-10-22 |
| 16 | */ | 17 | */ |
| 17 | @Api(tags = "CouponOperation管理") | 18 | @Api(tags = "优惠券管理") |
| 18 | @RestController | 19 | @RestController |
| 19 | @RequestMapping("/ucEngine/api/couponOperation") | 20 | @RequestMapping("/ucEngine/couponOperation") |
| 20 | public class CouponOperationController { | 21 | public class CouponOperationController { |
| 21 | 22 | ||
| 22 | @Autowired | 23 | @Autowired |
| 23 | private CouponOperationService couponOperationService; | 24 | private CouponOperationService couponOperationService; |
| 24 | 25 | ||
| 26 | @Log("手动发放优惠券") | ||
| 25 | @PostMapping(value = "/grantCouponByManual") | 27 | @PostMapping(value = "/grantCouponByManual") |
| 26 | @ApiOperation("手动发放优惠券") | 28 | @ApiOperation("手动发放优惠券") |
| 27 | public ResultInfo grantCouponByManual(List<TempCoupon> tempCouponList) { | 29 | public ResultInfo grantCouponByManual(List<TempCoupon> tempCouponList) { | ... | ... |
| 1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.process.domian.TempCoupon; | 3 | import com.topdraw.aop.log.Log; |
| 4 | import com.topdraw.business.process.domian.TempExp; | 4 | import com.topdraw.business.process.domian.TempExp; |
| 5 | import com.topdraw.business.process.service.CouponOperationService; | ||
| 6 | import com.topdraw.business.process.service.ExpOperationService; | 5 | import com.topdraw.business.process.service.ExpOperationService; |
| 7 | import com.topdraw.common.ResultInfo; | 6 | import com.topdraw.common.ResultInfo; |
| 8 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| ... | @@ -21,14 +20,15 @@ import java.util.List; | ... | @@ -21,14 +20,15 @@ import java.util.List; |
| 21 | * @author XiangHan | 20 | * @author XiangHan |
| 22 | * @date 2021-10-22 | 21 | * @date 2021-10-22 |
| 23 | */ | 22 | */ |
| 24 | @Api(tags = "ExpOperation管理") | 23 | @Api(tags = "成长值管理") |
| 25 | @RestController | 24 | @RestController |
| 26 | @RequestMapping("/ucEngine/api/expOperation") | 25 | @RequestMapping("/ucEngine/expOperation") |
| 27 | public class ExpOperationController { | 26 | public class ExpOperationController { |
| 28 | 27 | ||
| 29 | @Autowired | 28 | @Autowired |
| 30 | private ExpOperationService expOperationService; | 29 | private ExpOperationService expOperationService; |
| 31 | 30 | ||
| 31 | @Log("手动发放成长值") | ||
| 32 | @PostMapping(value = "/grantExpByManual") | 32 | @PostMapping(value = "/grantExpByManual") |
| 33 | @ApiOperation("手动发放成长值") | 33 | @ApiOperation("手动发放成长值") |
| 34 | public ResultInfo grantExpByManual(@Validated @RequestBody TempExp tempExp) { | 34 | public ResultInfo grantExpByManual(@Validated @RequestBody TempExp tempExp) { | ... | ... |
| ... | @@ -46,14 +46,6 @@ public class PointsOperationController { | ... | @@ -46,14 +46,6 @@ public class PointsOperationController { |
| 46 | @Autowired | 46 | @Autowired |
| 47 | private PointsOperationService pointsOperationService; | 47 | private PointsOperationService pointsOperationService; |
| 48 | 48 | ||
| 49 | |||
| 50 | @GetMapping(value = "/pagePointsDetails") | ||
| 51 | @ApiOperation("查询PointsDetail") | ||
| 52 | @AnonymousAccess | ||
| 53 | public ResultInfo pagePointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) { | ||
| 54 | return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable)); | ||
| 55 | } | ||
| 56 | |||
| 57 | @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") | 49 | @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") |
| 58 | @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") | 50 | @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") |
| 59 | @AnonymousAccess | 51 | @AnonymousAccess | ... | ... |
| 1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.aop.log.Log; | ||
| 3 | import com.topdraw.business.module.rights.history.domain.RightsHistory; | 4 | import com.topdraw.business.module.rights.history.domain.RightsHistory; |
| 4 | import com.topdraw.business.module.rights.history.service.RightsHistoryService; | ||
| 5 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria; | ||
| 6 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryType; | ||
| 7 | import com.topdraw.business.process.service.RightsOperationService; | 5 | import com.topdraw.business.process.service.RightsOperationService; |
| 8 | import com.topdraw.common.ResultInfo; | 6 | import com.topdraw.common.ResultInfo; |
| 9 | import com.topdraw.util.TimestampUtil; | ||
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.data.domain.Pageable; | ||
| 12 | import org.springframework.validation.annotation.Validated; | 8 | import org.springframework.validation.annotation.Validated; |
| 13 | import org.springframework.web.bind.annotation.*; | 9 | import org.springframework.web.bind.annotation.*; |
| 14 | import io.swagger.annotations.*; | 10 | import io.swagger.annotations.*; |
| ... | @@ -23,32 +19,20 @@ import java.util.List; | ... | @@ -23,32 +19,20 @@ import java.util.List; |
| 23 | */ | 19 | */ |
| 24 | @Api(tags = "Rights管理") | 20 | @Api(tags = "Rights管理") |
| 25 | @RestController | 21 | @RestController |
| 26 | @RequestMapping("/ucEngine/api/rightsOperation") | 22 | @RequestMapping("/ucEngine/rightsOperation") |
| 27 | public class RightsOperationController { | 23 | public class RightsOperationController { |
| 28 | 24 | ||
| 29 | @Autowired | 25 | @Autowired |
| 30 | private RightsOperationService rightsOperationService; | 26 | private RightsOperationService rightsOperationService; |
| 31 | @Autowired | ||
| 32 | private RightsHistoryService rightsHistoryService; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * | ||
| 36 | * @param id | ||
| 37 | * @return | ||
| 38 | */ | ||
| 39 | @GetMapping(value = "/findRightsHistoryById/{id}") | ||
| 40 | @ApiOperation("查询RightsHistory") | ||
| 41 | public ResultInfo findRightsHistoryById(@PathVariable Long id) { | ||
| 42 | return ResultInfo.success(rightsHistoryService.findById(id)); | ||
| 43 | } | ||
| 44 | 27 | ||
| 45 | /** | 28 | /** |
| 46 | * | 29 | * |
| 47 | * @param rightsHistory | 30 | * @param rightsHistory |
| 48 | * @return | 31 | * @return |
| 49 | */ | 32 | */ |
| 33 | @Log("手动发放优惠券") | ||
| 50 | @PostMapping(value = "/grantRightsByManual") | 34 | @PostMapping(value = "/grantRightsByManual") |
| 51 | @ApiOperation("查询RightsHistory") | 35 | @ApiOperation("手动发放优惠券") |
| 52 | public ResultInfo grantRightsByManual(@Validated @RequestBody RightsHistory rightsHistory) { | 36 | public ResultInfo grantRightsByManual(@Validated @RequestBody RightsHistory rightsHistory) { |
| 53 | List<RightsHistory> rightsHistories = Arrays.asList(rightsHistory); | 37 | List<RightsHistory> rightsHistories = Arrays.asList(rightsHistory); |
| 54 | this.rightsOperationService.grantRightsByManual(rightsHistories); | 38 | this.rightsOperationService.grantRightsByManual(rightsHistories); | ... | ... |
| 1 | package com.topdraw.business.process.service; | 1 | package com.topdraw.business.process.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.process.domian.TempCoupon; | ||
| 4 | import com.topdraw.business.process.domian.TempExp; | 3 | import com.topdraw.business.process.domian.TempExp; |
| 5 | import com.topdraw.business.process.domian.TempRights; | ||
| 6 | 4 | ||
| 7 | import java.util.List; | 5 | import java.util.List; |
| 8 | 6 | ... | ... |
| ... | @@ -52,11 +52,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -52,11 +52,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 52 | @Override | 52 | @Override |
| 53 | @AsyncMqSend | 53 | @AsyncMqSend |
| 54 | public void grantPointsThroughTempExp(List<TempExp> tempExpList) { | 54 | public void grantPointsThroughTempExp(List<TempExp> tempExpList) { |
| 55 | |||
| 56 | for (TempExp tempExp : tempExpList) { | 55 | for (TempExp tempExp : tempExpList) { |
| 57 | this.refresh(tempExp); | 56 | this.refresh(tempExp); |
| 58 | } | 57 | } |
| 59 | |||
| 60 | } | 58 | } |
| 61 | 59 | ||
| 62 | @Override | 60 | @Override |
| ... | @@ -73,7 +71,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -73,7 +71,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 73 | } | 71 | } |
| 74 | } | 72 | } |
| 75 | 73 | ||
| 76 | |||
| 77 | /** | 74 | /** |
| 78 | * | 75 | * |
| 79 | * @param tempExp | 76 | * @param tempExp |
| ... | @@ -105,6 +102,11 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -105,6 +102,11 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 105 | return rewardExp + originalExp; | 102 | return rewardExp + originalExp; |
| 106 | } | 103 | } |
| 107 | 104 | ||
| 105 | /** | ||
| 106 | * | ||
| 107 | * @param tempExp | ||
| 108 | * @return | ||
| 109 | */ | ||
| 108 | private long getExpByMemberId(TempExp tempExp) { | 110 | private long getExpByMemberId(TempExp tempExp) { |
| 109 | Long memberId = tempExp.getMemberId(); | 111 | Long memberId = tempExp.getMemberId(); |
| 110 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); | 112 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); |
| ... | @@ -115,7 +117,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -115,7 +117,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 115 | return 0L; | 117 | return 0L; |
| 116 | } | 118 | } |
| 117 | 119 | ||
| 118 | |||
| 119 | /** | 120 | /** |
| 120 | * 更新成长值与等级 | 121 | * 更新成长值与等级 |
| 121 | * | 122 | * | ... | ... |
| ... | @@ -43,8 +43,6 @@ import java.util.stream.Collectors; | ... | @@ -43,8 +43,6 @@ import java.util.stream.Collectors; |
| 43 | @Slf4j | 43 | @Slf4j |
| 44 | public class PointsOperationServiceImpl implements PointsOperationService { | 44 | public class PointsOperationServiceImpl implements PointsOperationService { |
| 45 | 45 | ||
| 46 | private static final Logger LOG = LoggerFactory.getLogger(PointsOperationServiceImpl.class); | ||
| 47 | |||
| 48 | @Autowired | 46 | @Autowired |
| 49 | PointsService pointsService; | 47 | PointsService pointsService; |
| 50 | @Autowired | 48 | @Autowired |
| ... | @@ -69,8 +67,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -69,8 +67,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 69 | private static final String DELETE_AVAILABLE_POINTS = "delete"; | 67 | private static final String DELETE_AVAILABLE_POINTS = "delete"; |
| 70 | private static final String INSERT_AVAILABLE_POINTS = "insert"; | 68 | private static final String INSERT_AVAILABLE_POINTS = "insert"; |
| 71 | 69 | ||
| 72 | |||
| 73 | |||
| 74 | @Override | 70 | @Override |
| 75 | @Transactional(rollbackFor = Exception.class) | 71 | @Transactional(rollbackFor = Exception.class) |
| 76 | public void grantPointsByManual(Long memberId,TempPoints tempPoints){ | 72 | public void grantPointsByManual(Long memberId,TempPoints tempPoints){ |
| ... | @@ -361,15 +357,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -361,15 +357,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 361 | 357 | ||
| 362 | /** | 358 | /** |
| 363 | * | 359 | * |
| 364 | * @param pointsAvailableDTOS | ||
| 365 | */ | ||
| 366 | private void doDeleteBatchInvalidAvailablePoints(List<PointsAvailableDTO> pointsAvailableDTOS) { | ||
| 367 | List<Long> collect = pointsAvailableDTOS.stream().map(pointsAvailableDTO -> pointsAvailableDTO.getId()).collect(Collectors.toList()); | ||
| 368 | this.pointsAvailableService.deleteBatchByIds(collect); | ||
| 369 | } | ||
| 370 | |||
| 371 | /** | ||
| 372 | * | ||
| 373 | * @param pointsAvailableDTO | 360 | * @param pointsAvailableDTO |
| 374 | */ | 361 | */ |
| 375 | private void doDeleteInvalidAvailablePoints(PointsAvailableDTO pointsAvailableDTO) { | 362 | private void doDeleteInvalidAvailablePoints(PointsAvailableDTO pointsAvailableDTO) { |
| ... | @@ -515,16 +502,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -515,16 +502,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 515 | } | 502 | } |
| 516 | 503 | ||
| 517 | /** | 504 | /** |
| 518 | * 计算当前总积分 | ||
| 519 | * @param memberId 会员id | ||
| 520 | * @return | ||
| 521 | */ | ||
| 522 | private Long findAvailablePointsByMemberId(long memberId){ | ||
| 523 | Long availablePoints = this.pointsAvailableService.findAvailablePointsByMemberId(memberId); | ||
| 524 | return Objects.nonNull(availablePoints) ? availablePoints : 0L; | ||
| 525 | } | ||
| 526 | |||
| 527 | /** | ||
| 528 | * 更新可用积分表 | 505 | * 更新可用积分表 |
| 529 | * @param tempPoints | 506 | * @param tempPoints |
| 530 | */ | 507 | */ | ... | ... |
| ... | @@ -1087,10 +1087,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1087,10 +1087,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1087 | 1087 | ||
| 1088 | resources.setMemberId(memberId); | 1088 | resources.setMemberId(memberId); |
| 1089 | resources.setMemberCode(memberCode); | 1089 | resources.setMemberCode(memberCode); |
| 1090 | UserTv userTv = this.userTvService.create(resources); | 1090 | UserTvDTO userTvDTO = this.userTvService.create(resources); |
| 1091 | |||
| 1092 | UserTvDTO userTvDTO = new UserTvDTO(); | ||
| 1093 | BeanUtils.copyProperties(userTv,userTvDTO); | ||
| 1094 | return userTvDTO; | 1091 | return userTvDTO; |
| 1095 | } | 1092 | } |
| 1096 | 1093 | ... | ... |
-
Please register or sign in to post a comment