V2.0.0.REALESE
Showing
88 changed files
with
2053 additions
and
338 deletions
document/sql/data/uc_permanent_rights.sql
0 → 100644
1 | |||
2 | INSERT INTO `uc_permanent_rights` VALUES (6, '', '优享白银', 0, 1, 90.00, 10.00, 0, 2, 0, 0, '2021-10-26 18:18:49', '2021-10-26 18:18:49'); | ||
3 | INSERT INTO `uc_permanent_rights` VALUES (7, '', '优享黄金', 0, 3, 1.00, 20.00, 1, 1, 0, 0, '2021-10-26 18:19:52', '2021-10-28 10:59:26'); | ||
4 | INSERT INTO `uc_permanent_rights` VALUES (8, '', '优享白金', 0, 4, 2.00, 40.00, 1, 1, 1, 0, '2021-10-26 18:20:13', '2021-10-28 10:59:18'); | ||
5 | INSERT INTO `uc_permanent_rights` VALUES (9, '', '优享钻石', 0, 2, 4.00, 80.00, 1, 1, 1, 1, '2021-10-26 18:20:39', '2021-10-28 11:56:04'); | ||
6 | INSERT INTO `uc_permanent_rights` VALUES (10, '', '优享黑钻', 0, 6, 8.00, 160.00, 1, 2, 1, 1, '2021-10-26 18:21:09', '2021-10-28 10:58:56'); |
1 | RENAME TABLE tj_user_0819.uc_user__group TO tj_user_0819.uc_member_group; | 1 | |
2 | ALTER TABLE tj_user_0819.uc_member_group ADD member_id varchar(100) NULL COMMENT '会员id'; | 2 | ALTER TABLE `tj_user`.`uc_member` |
3 | ADD COLUMN `vip_expire_time` datetime NULL DEFAULT NULL COMMENT 'vip失效时间' AFTER `black_status`; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -7,10 +7,10 @@ | ... | @@ -7,10 +7,10 @@ |
7 | <map> | 7 | <map> |
8 | <entry key="com.zeroturnaround.jrebel.FormatVersion" value="7.0.0" /> | 8 | <entry key="com.zeroturnaround.jrebel.FormatVersion" value="7.0.0" /> |
9 | <entry key="jrebelEnabled" value="true" /> | 9 | <entry key="jrebelEnabled" value="true" /> |
10 | <entry key="lastExternalPluginCheckTime" value="1636770952724" /> | 10 | <entry key="lastExternalPluginCheckTime" value="1639400088018" /> |
11 | </map> | 11 | </map> |
12 | </option> | 12 | </option> |
13 | <option name="version" value="6" /> | 13 | <option name="version" value="7" /> |
14 | </configuration> | 14 | </configuration> |
15 | </facet> | 15 | </facet> |
16 | </component> | 16 | </component> | ... | ... |
... | @@ -124,7 +124,7 @@ | ... | @@ -124,7 +124,7 @@ |
124 | </profiles> | 124 | </profiles> |
125 | 125 | ||
126 | <build> | 126 | <build> |
127 | <finalName>member-service</finalName> | 127 | <finalName>uc-engine</finalName> |
128 | <resources> | 128 | <resources> |
129 | <resource> | 129 | <resource> |
130 | <directory>src/main/java</directory> | 130 | <directory>src/main/java</directory> | ... | ... |
... | @@ -12,6 +12,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ... | @@ -12,6 +12,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing; |
12 | import org.springframework.retry.annotation.EnableRetry; | 12 | import org.springframework.retry.annotation.EnableRetry; |
13 | import org.springframework.scheduling.annotation.EnableAsync; | 13 | import org.springframework.scheduling.annotation.EnableAsync; |
14 | import org.springframework.transaction.annotation.EnableTransactionManagement; | 14 | import org.springframework.transaction.annotation.EnableTransactionManagement; |
15 | import org.springframework.web.bind.annotation.CrossOrigin; | ||
15 | 16 | ||
16 | /** | 17 | /** |
17 | * @author XiangHan | 18 | * @author XiangHan | ... | ... |
... | @@ -52,6 +52,7 @@ public class AsyncMqProducer { | ... | @@ -52,6 +52,7 @@ public class AsyncMqProducer { |
52 | 52 | ||
53 | String entityName = asyncMqSend.entityName(); | 53 | String entityName = asyncMqSend.entityName(); |
54 | String methodName = asyncMqSend.method(); | 54 | String methodName = asyncMqSend.method(); |
55 | String exchangeName = asyncMqSend.exchangeName(); | ||
55 | 56 | ||
56 | Object defaultServiceImpl = joinPoint.getTarget(); | 57 | Object defaultServiceImpl = joinPoint.getTarget(); |
57 | String defaultServiceImplName = defaultServiceImpl.getClass().getName(); | 58 | String defaultServiceImplName = defaultServiceImpl.getClass().getName(); |
... | @@ -83,7 +84,7 @@ public class AsyncMqProducer { | ... | @@ -83,7 +84,7 @@ public class AsyncMqProducer { |
83 | } | 84 | } |
84 | 85 | ||
85 | private void sendMqMessage(TableOperationMsg tableOperationMsg){ | 86 | private void sendMqMessage(TableOperationMsg tableOperationMsg){ |
86 | this.messageProducer.sendFanoutMessage(JSON.toJSONString(tableOperationMsg)); | 87 | this.messageProducer.sendMessage(JSON.toJSONString(tableOperationMsg)); |
87 | } | 88 | } |
88 | 89 | ||
89 | } | 90 | } | ... | ... |
... | @@ -12,6 +12,7 @@ import java.sql.Timestamp; | ... | @@ -12,6 +12,7 @@ import java.sql.Timestamp; |
12 | import java.math.BigDecimal; | 12 | import java.math.BigDecimal; |
13 | 13 | ||
14 | import java.io.Serializable; | 14 | import java.io.Serializable; |
15 | import java.time.LocalDateTime; | ||
15 | 16 | ||
16 | /** | 17 | /** |
17 | * @author XiangHan | 18 | * @author XiangHan |
... | @@ -92,7 +93,7 @@ public class Coupon implements Serializable { | ... | @@ -92,7 +93,7 @@ public class Coupon implements Serializable { |
92 | 93 | ||
93 | // 过期时间 | 94 | // 过期时间 |
94 | @Column(name = "expire_time") | 95 | @Column(name = "expire_time") |
95 | private Timestamp expireTime; | 96 | private LocalDateTime expireTime; |
96 | 97 | ||
97 | // 自领取当日,几天内有效 | 98 | // 自领取当日,几天内有效 |
98 | @Column(name = "valid_days") | 99 | @Column(name = "valid_days") | ... | ... |
... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
11 | import java.sql.Timestamp; | 11 | import java.sql.Timestamp; |
12 | 12 | ||
13 | import java.io.Serializable; | 13 | import java.io.Serializable; |
14 | import java.time.LocalDateTime; | ||
14 | 15 | ||
15 | /** | 16 | /** |
16 | * @author XiangHan | 17 | * @author XiangHan |
... | @@ -51,7 +52,7 @@ public class CouponHistory implements Serializable { | ... | @@ -51,7 +52,7 @@ public class CouponHistory implements Serializable { |
51 | 52 | ||
52 | // 失效时间 | 53 | // 失效时间 |
53 | @Column(name = "expire_time") | 54 | @Column(name = "expire_time") |
54 | private Timestamp expireTime; | 55 | private LocalDateTime expireTime; |
55 | 56 | ||
56 | // 使用状态 0:未使用;1:已使用;-1:已过期 | 57 | // 使用状态 0:未使用;1:已使用;-1:已过期 |
57 | @Column(name = "use_status") | 58 | @Column(name = "use_status") | ... | ... |
... | @@ -3,6 +3,7 @@ package com.topdraw.business.basicdata.coupon.history.service.dto; | ... | @@ -3,6 +3,7 @@ package com.topdraw.business.basicdata.coupon.history.service.dto; |
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | import java.sql.Timestamp; | 4 | import java.sql.Timestamp; |
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.time.LocalDateTime; | ||
6 | 7 | ||
7 | 8 | ||
8 | /** | 9 | /** |
... | @@ -31,7 +32,7 @@ public class CouponHistoryDTO implements Serializable { | ... | @@ -31,7 +32,7 @@ public class CouponHistoryDTO implements Serializable { |
31 | private Timestamp receiveTime; | 32 | private Timestamp receiveTime; |
32 | 33 | ||
33 | // 失效时间 | 34 | // 失效时间 |
34 | private Timestamp expireTime; | 35 | private LocalDateTime expireTime; |
35 | 36 | ||
36 | // 使用状态 0:未使用;1:已使用;-1:已过期 | 37 | // 使用状态 0:未使用;1:已使用;-1:已过期 |
37 | private Integer useStatus; | 38 | private Integer useStatus; | ... | ... |
... | @@ -4,6 +4,7 @@ import lombok.Data; | ... | @@ -4,6 +4,7 @@ import lombok.Data; |
4 | import java.sql.Timestamp; | 4 | import java.sql.Timestamp; |
5 | import java.math.BigDecimal; | 5 | import java.math.BigDecimal; |
6 | import java.io.Serializable; | 6 | import java.io.Serializable; |
7 | import java.time.LocalDateTime; | ||
7 | 8 | ||
8 | 9 | ||
9 | /** | 10 | /** |
... | @@ -62,7 +63,7 @@ public class CouponDTO implements Serializable { | ... | @@ -62,7 +63,7 @@ public class CouponDTO implements Serializable { |
62 | private Timestamp startTime; | 63 | private Timestamp startTime; |
63 | 64 | ||
64 | // 过期时间 | 65 | // 过期时间 |
65 | private Timestamp expireTime; | 66 | private LocalDateTime expireTime; |
66 | 67 | ||
67 | // 自领取当日,几天内有效 | 68 | // 自领取当日,几天内有效 |
68 | private Integer validDays; | 69 | private Integer validDays; | ... | ... |
... | @@ -57,7 +57,7 @@ public class ExpHistoryServiceImpl implements ExpHistoryService { | ... | @@ -57,7 +57,7 @@ public class ExpHistoryServiceImpl implements ExpHistoryService { |
57 | 57 | ||
58 | @Override | 58 | @Override |
59 | @Transactional(rollbackFor = Exception.class) | 59 | @Transactional(rollbackFor = Exception.class) |
60 | // @AsyncMqSend() | 60 | @AsyncMqSend() |
61 | public void create(ExpHistory resources) { | 61 | public void create(ExpHistory resources) { |
62 | ExpHistoryRepository.save(resources); | 62 | ExpHistoryRepository.save(resources); |
63 | } | 63 | } | ... | ... |
... | @@ -33,6 +33,9 @@ public class MemberAddress implements Serializable { | ... | @@ -33,6 +33,9 @@ public class MemberAddress implements Serializable { |
33 | @Column(name = "member_id", nullable = false) | 33 | @Column(name = "member_id", nullable = false) |
34 | private Long memberId; | 34 | private Long memberId; |
35 | 35 | ||
36 | @Transient | ||
37 | private String memberCode; | ||
38 | |||
36 | // 类型 1:家;2:公司;3:学校 | 39 | // 类型 1:家;2:公司;3:学校 |
37 | @Column(name = "type", nullable = false) | 40 | @Column(name = "type", nullable = false) |
38 | private Integer type; | 41 | private Integer type; | ... | ... |
1 | package com.topdraw.business.basicdata.member.address.rest; | 1 | package com.topdraw.business.basicdata.member.address.rest; |
2 | 2 | ||
3 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
4 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
3 | import com.topdraw.common.ResultInfo; | 5 | import com.topdraw.common.ResultInfo; |
4 | import com.topdraw.annotation.Log; | 6 | import com.topdraw.annotation.Log; |
5 | import com.topdraw.business.basicdata.member.address.domain.MemberAddress; | 7 | import com.topdraw.business.basicdata.member.address.domain.MemberAddress; |
... | @@ -7,10 +9,13 @@ import com.topdraw.business.basicdata.member.address.service.MemberAddressServic | ... | @@ -7,10 +9,13 @@ import com.topdraw.business.basicdata.member.address.service.MemberAddressServic |
7 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; | 9 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; |
8 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.data.domain.Pageable; | 11 | import org.springframework.data.domain.Pageable; |
12 | import org.springframework.util.Assert; | ||
10 | import org.springframework.validation.annotation.Validated; | 13 | import org.springframework.validation.annotation.Validated; |
11 | import org.springframework.web.bind.annotation.*; | 14 | import org.springframework.web.bind.annotation.*; |
12 | import io.swagger.annotations.*; | 15 | import io.swagger.annotations.*; |
13 | 16 | ||
17 | import java.util.Objects; | ||
18 | |||
14 | /** | 19 | /** |
15 | * @author XiangHan | 20 | * @author XiangHan |
16 | * @date 2021-10-22 | 21 | * @date 2021-10-22 |
... | @@ -18,10 +23,13 @@ import io.swagger.annotations.*; | ... | @@ -18,10 +23,13 @@ import io.swagger.annotations.*; |
18 | @Api(tags = "MemberAddress管理") | 23 | @Api(tags = "MemberAddress管理") |
19 | @RestController | 24 | @RestController |
20 | @RequestMapping("/api/MemberAddress") | 25 | @RequestMapping("/api/MemberAddress") |
26 | @CrossOrigin | ||
21 | public class MemberAddressController { | 27 | public class MemberAddressController { |
22 | 28 | ||
23 | @Autowired | 29 | @Autowired |
24 | private MemberAddressService MemberAddressService; | 30 | private MemberAddressService MemberAddressService; |
31 | @Autowired | ||
32 | private MemberService memberService; | ||
25 | 33 | ||
26 | @GetMapping(value = "/pageMemberAddress") | 34 | @GetMapping(value = "/pageMemberAddress") |
27 | @ApiOperation("查询MemberAddress") | 35 | @ApiOperation("查询MemberAddress") |
... | @@ -47,7 +55,17 @@ public class MemberAddressController { | ... | @@ -47,7 +55,17 @@ public class MemberAddressController { |
47 | @PutMapping(value = "/update") | 55 | @PutMapping(value = "/update") |
48 | @ApiOperation("修改MemberAddress") | 56 | @ApiOperation("修改MemberAddress") |
49 | public ResultInfo update(@Validated @RequestBody MemberAddress resources) { | 57 | public ResultInfo update(@Validated @RequestBody MemberAddress resources) { |
58 | Long memberId = resources.getMemberId(); | ||
59 | Integer sequence = resources.getSequence(); | ||
60 | Assert.notNull(memberId,"memberId can't be null"); | ||
61 | Assert.notNull(sequence,"sequence can't be null"); | ||
62 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
63 | if (Objects.nonNull(memberDTO)) { | ||
64 | String code = memberDTO.getCode(); | ||
65 | Assert.notNull(code,"code can't be null"); | ||
66 | resources.setMemberCode(code); | ||
50 | MemberAddressService.update(resources); | 67 | MemberAddressService.update(resources); |
68 | } | ||
51 | return ResultInfo.success(); | 69 | return ResultInfo.success(); |
52 | } | 70 | } |
53 | 71 | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.basicdata.member.domain; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.basicdata.member.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | ||
6 | import io.swagger.annotations.ApiModelProperty; | ||
5 | import lombok.Data; | 7 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 8 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 9 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -11,6 +13,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -11,6 +13,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
11 | import javax.persistence.*; | 13 | import javax.persistence.*; |
12 | import java.io.Serializable; | 14 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | 15 | import java.sql.Timestamp; |
16 | import java.time.LocalDateTime; | ||
14 | 17 | ||
15 | /** | 18 | /** |
16 | * @author XiangHan | 19 | * @author XiangHan |
... | @@ -23,103 +26,111 @@ import java.sql.Timestamp; | ... | @@ -23,103 +26,111 @@ import java.sql.Timestamp; |
23 | @Table(name="uc_member") | 26 | @Table(name="uc_member") |
24 | public class Member implements Serializable { | 27 | public class Member implements Serializable { |
25 | 28 | ||
26 | // 主键 | 29 | /** 运营商平台账号 */ |
30 | @Transient | ||
31 | private String platformAccount; | ||
32 | |||
33 | /** 会员过期时间 */ | ||
34 | @Column(name = "vip_expire_time", nullable = false) | ||
35 | private LocalDateTime vipExpireTime; | ||
36 | |||
37 | /** 主键 */ | ||
27 | @Id | 38 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 39 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
29 | @Column(name = "id") | 40 | @Column(name = "id") |
30 | private Long id; | 41 | private Long id; |
31 | 42 | ||
32 | // 标识 | 43 | /** 标识 */ |
33 | @Column(name = "code", nullable = false) | 44 | @Column(name = "code", nullable = false) |
34 | private String code; | 45 | private String code; |
35 | 46 | ||
36 | // 类型 1:大屏;2:小屏 | 47 | /** 类型 1:大屏;2:小屏 */ |
37 | @Column(name = "`type`", nullable = false) | 48 | @Column(name = "`type`", nullable = false) |
38 | private Integer type; | 49 | private Integer type; |
39 | 50 | ||
40 | // 状态 0:不可用;1:可用 | 51 | /** 状态 0:不可用;1:可用 */ |
41 | @Column(name = "`status`", nullable = false) | 52 | @Column(name = "`status`", nullable = false) |
42 | private Integer status; | 53 | private Integer status; |
43 | 54 | ||
44 | // 昵称 base64 | 55 | /** 昵称 base64 */ |
45 | @Column(name = "nickname") | 56 | @Column(name = "nickname") |
46 | private String nickname; | 57 | private String nickname; |
47 | 58 | ||
48 | // 描述 | 59 | /** 描述 */ |
49 | @Column(name = "description") | 60 | @Column(name = "description") |
50 | private String description; | 61 | private String description; |
51 | 62 | ||
52 | // 性别 0:女;1:男;-1:未知 | 63 | /** 性别 0:女;1:男;-1:未知 */ |
53 | @Column(name = "gender", nullable = false) | 64 | @Column(name = "gender", nullable = false) |
54 | private Integer gender; | 65 | private Integer gender; |
55 | 66 | ||
56 | // 生日 | 67 | /** 生日 */ |
57 | @Column(name = "birthday") | 68 | @Column(name = "birthday") |
58 | private String birthday; | 69 | private String birthday; |
59 | 70 | ||
60 | // 头像 | 71 | /** 头像 */ |
61 | @Column(name = "avatar_url") | 72 | @Column(name = "avatar_url") |
62 | private String avatarUrl; | 73 | private String avatarUrl; |
63 | 74 | ||
64 | // 分组信息 | 75 | /** 分组信息 */ |
65 | @Column(name = "`groups`") | 76 | @Column(name = "`groups`") |
66 | private String groups; | 77 | private String groups; |
67 | 78 | ||
68 | // 标签 | 79 | /** 标签 */ |
69 | @Column(name = "tags") | 80 | @Column(name = "tags") |
70 | private String tags; | 81 | private String tags; |
71 | 82 | ||
72 | // 是否会员 0:非会员;1:会员 | 83 | /** 是否会员 0:非会员;1:会员 */ |
73 | @Column(name = "vip", nullable = false) | 84 | @Column(name = "vip", nullable = false) |
74 | private Integer vip; | 85 | private Integer vip; |
75 | 86 | ||
76 | // 会员等级(对应level表的level字段,非id) | 87 | /** 会员等级(对应level表的level字段,非id) */ |
77 | @Column(name = "`level`", nullable = false) | 88 | @Column(name = "`level`", nullable = false) |
78 | private Integer level; | 89 | private Integer level; |
79 | 90 | ||
80 | // 成长值 | 91 | /** 成长值 */ |
81 | @Column(name = "`exp`") | 92 | @Column(name = "`exp`") |
82 | private Long exp; | 93 | private Long exp; |
83 | 94 | ||
84 | // 当前积分 | 95 | /** 当前积分 */ |
85 | @Column(name = "`points`") | 96 | @Column(name = "`points`") |
86 | private Long points; | 97 | private Long points; |
87 | 98 | ||
88 | // 即将到期积分(一个月内) | 99 | /** 即将到期积分(一个月内) */ |
89 | @Column(name = "due_points") | 100 | @Column(name = "due_points") |
90 | private Long duePoints; | 101 | private Long duePoints; |
91 | 102 | ||
92 | // 优惠券数量 | 103 | /** 优惠券数量 */ |
93 | @Column(name = "coupon_amount") | 104 | @Column(name = "coupon_amount") |
94 | private Long couponAmount; | 105 | private Long couponAmount; |
95 | 106 | ||
96 | // 即将过期优惠券数量 | 107 | /** 即将过期优惠券数量 */ |
97 | @Column(name = "due_coupon_amount") | 108 | @Column(name = "due_coupon_amount") |
98 | private Long dueCouponAmount; | 109 | private Long dueCouponAmount; |
99 | 110 | ||
100 | // iptv账号id | 111 | /** iptv账号id */ |
101 | @Column(name = "user_iptv_id") | 112 | @Column(name = "user_iptv_id") |
102 | private Long userIptvId; | 113 | private Long userIptvId; |
103 | 114 | ||
104 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 | 115 | /** 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 */ |
105 | @Column(name = "bind_iptv_platform_type") | 116 | @Column(name = "bind_iptv_platform_type") |
106 | private Integer bindIptvPlatformType; | 117 | private Integer bindIptvPlatformType; |
107 | 118 | ||
108 | // iptv账号绑定时间 | 119 | /** iptv账号绑定时间 */ |
109 | @Column(name = "bind_iptv_time") | 120 | @Column(name = "bind_iptv_time") |
110 | private Timestamp bindIptvTime; | 121 | private Timestamp bindIptvTime; |
111 | 122 | ||
112 | // 创建时间 | 123 | /** 创建时间 */ |
113 | @CreatedDate | 124 | @CreatedDate |
114 | @Column(name = "create_time") | 125 | @Column(name = "create_time") |
115 | private Timestamp createTime; | 126 | private Timestamp createTime; |
116 | 127 | ||
117 | // 更新时间 | 128 | /** 更新时间 */ |
118 | @LastModifiedDate | 129 | @LastModifiedDate |
119 | @Column(name = "update_time") | 130 | @Column(name = "update_time") |
120 | private Timestamp updateTime; | 131 | private Timestamp updateTime; |
121 | 132 | ||
122 | // 是否在黑名单 1:是;0否 | 133 | /** 是否在黑名单 1:是;0否 */ |
123 | @Column(name = "black_status") | 134 | @Column(name = "black_status") |
124 | private Long blackStatus; | 135 | private Long blackStatus; |
125 | 136 | ... | ... |
... | @@ -27,6 +27,9 @@ import java.io.Serializable; | ... | @@ -27,6 +27,9 @@ import java.io.Serializable; |
27 | @Table(name="uc_member_profile") | 27 | @Table(name="uc_member_profile") |
28 | public class MemberProfile implements Serializable { | 28 | public class MemberProfile implements Serializable { |
29 | 29 | ||
30 | @Transient | ||
31 | private String memberCode; | ||
32 | |||
30 | // 主键 | 33 | // 主键 |
31 | @Id | 34 | @Id |
32 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 35 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ... | ... |
... | @@ -4,10 +4,13 @@ import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | ... | @@ -4,10 +4,13 @@ import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; |
4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | 6 | ||
7 | import java.util.Optional; | ||
8 | |||
7 | /** | 9 | /** |
8 | * @author XiangHan | 10 | * @author XiangHan |
9 | * @date 2021-10-22 | 11 | * @date 2021-10-22 |
10 | */ | 12 | */ |
11 | public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> { | 13 | public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> { |
12 | 14 | ||
15 | Optional<MemberProfile> findByMemberId(Long memberId); | ||
13 | } | 16 | } | ... | ... |
1 | package com.topdraw.business.basicdata.member.profile.rest; | 1 | package com.topdraw.business.basicdata.member.profile.rest; |
2 | 2 | ||
3 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; | ||
4 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
5 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
3 | import com.topdraw.common.ResultInfo; | 6 | import com.topdraw.common.ResultInfo; |
4 | import com.topdraw.annotation.Log; | 7 | import com.topdraw.annotation.Log; |
5 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | 8 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; |
6 | import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; | 9 | import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; |
7 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria; | 10 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria; |
11 | import com.topdraw.utils.StringUtils; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.data.domain.Pageable; | 13 | import org.springframework.data.domain.Pageable; |
14 | import org.springframework.util.Assert; | ||
10 | import org.springframework.validation.annotation.Validated; | 15 | import org.springframework.validation.annotation.Validated; |
11 | import org.springframework.web.bind.annotation.*; | 16 | import org.springframework.web.bind.annotation.*; |
12 | import io.swagger.annotations.*; | 17 | import io.swagger.annotations.*; |
13 | 18 | ||
19 | import java.util.Objects; | ||
20 | |||
14 | /** | 21 | /** |
15 | * @author XiangHan | 22 | * @author XiangHan |
16 | * @date 2021-10-22 | 23 | * @date 2021-10-22 |
... | @@ -18,10 +25,13 @@ import io.swagger.annotations.*; | ... | @@ -18,10 +25,13 @@ import io.swagger.annotations.*; |
18 | @Api(tags = "MemberProfile管理") | 25 | @Api(tags = "MemberProfile管理") |
19 | @RestController | 26 | @RestController |
20 | @RequestMapping("/api/MemberProfile") | 27 | @RequestMapping("/api/MemberProfile") |
28 | @CrossOrigin | ||
21 | public class MemberProfileController { | 29 | public class MemberProfileController { |
22 | 30 | ||
23 | @Autowired | 31 | @Autowired |
24 | private MemberProfileService MemberProfileService; | 32 | private MemberProfileService MemberProfileService; |
33 | @Autowired | ||
34 | private MemberService memberService; | ||
25 | 35 | ||
26 | /*@GetMapping | 36 | /*@GetMapping |
27 | @ApiOperation("查询MemberProfile") | 37 | @ApiOperation("查询MemberProfile") |
... | @@ -47,7 +57,23 @@ public class MemberProfileController { | ... | @@ -47,7 +57,23 @@ public class MemberProfileController { |
47 | @PutMapping(value = "/update") | 57 | @PutMapping(value = "/update") |
48 | @ApiOperation("修改MemberProfile") | 58 | @ApiOperation("修改MemberProfile") |
49 | public ResultInfo update(@Validated @RequestBody MemberProfile resources) { | 59 | public ResultInfo update(@Validated @RequestBody MemberProfile resources) { |
60 | Long memberId = resources.getMemberId(); | ||
61 | Assert.notNull(memberId,"memberId can't be null"); | ||
62 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
63 | if (Objects.nonNull(memberDTO)) { | ||
64 | String code = memberDTO.getCode(); | ||
65 | if (StringUtils.isNotEmpty(code)) { | ||
66 | resources.setMemberCode(code); | ||
67 | MemberProfileDTO memberProfile = this.MemberProfileService.findByMemberId(memberId); | ||
68 | if (Objects.nonNull(memberProfile)) { | ||
69 | resources.setId(memberProfile.getId()); | ||
50 | MemberProfileService.update(resources); | 70 | MemberProfileService.update(resources); |
71 | } else { | ||
72 | resources.setId(null); | ||
73 | this.create(resources); | ||
74 | } | ||
75 | } | ||
76 | } | ||
51 | return ResultInfo.success(); | 77 | return ResultInfo.success(); |
52 | } | 78 | } |
53 | 79 | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.basicdata.member.profile.service.impl; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.basicdata.member.profile.service.impl; |
2 | 2 | ||
3 | import com.topdraw.aspect.AsyncMqSend; | 3 | import com.topdraw.aspect.AsyncMqSend; |
4 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | 4 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; |
5 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
6 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
5 | import com.topdraw.utils.ValidationUtil; | 7 | import com.topdraw.utils.ValidationUtil; |
6 | import com.topdraw.business.basicdata.member.profile.repository.MemberProfileRepository; | 8 | import com.topdraw.business.basicdata.member.profile.repository.MemberProfileRepository; |
7 | import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; | 9 | import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; |
... | @@ -21,6 +23,7 @@ import com.topdraw.utils.QueryHelp; | ... | @@ -21,6 +23,7 @@ import com.topdraw.utils.QueryHelp; |
21 | 23 | ||
22 | import java.util.List; | 24 | import java.util.List; |
23 | import java.util.Map; | 25 | import java.util.Map; |
26 | import java.util.Optional; | ||
24 | 27 | ||
25 | /** | 28 | /** |
26 | * @author XiangHan | 29 | * @author XiangHan |
... | @@ -36,6 +39,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -36,6 +39,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
36 | @Autowired | 39 | @Autowired |
37 | private MemberProfileMapper MemberProfileMapper; | 40 | private MemberProfileMapper MemberProfileMapper; |
38 | 41 | ||
42 | |||
39 | @Override | 43 | @Override |
40 | public Map<String, Object> queryAll(MemberProfileQueryCriteria criteria, Pageable pageable) { | 44 | public Map<String, Object> queryAll(MemberProfileQueryCriteria criteria, Pageable pageable) { |
41 | Page<MemberProfile> page = MemberProfileRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | 45 | Page<MemberProfile> page = MemberProfileRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
... | @@ -81,5 +85,15 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -81,5 +85,15 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
81 | MemberProfileRepository.delete(MemberProfile); | 85 | MemberProfileRepository.delete(MemberProfile); |
82 | } | 86 | } |
83 | 87 | ||
88 | @Override | ||
89 | public MemberProfileDTO findByMemberId(Long memberId) { | ||
90 | Optional<MemberProfile> memberProfile = MemberProfileRepository.findByMemberId(memberId); | ||
91 | if (memberProfile.isPresent()) { | ||
92 | MemberProfile memberProfile1 = memberProfile.get(); | ||
93 | return MemberProfileMapper.toDto(memberProfile1); | ||
94 | } | ||
95 | return null; | ||
96 | } | ||
97 | |||
84 | 98 | ||
85 | } | 99 | } | ... | ... |
... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
11 | import java.sql.Timestamp; | 11 | import java.sql.Timestamp; |
12 | 12 | ||
13 | import java.io.Serializable; | 13 | import java.io.Serializable; |
14 | import java.time.LocalDate; | ||
14 | 15 | ||
15 | /** | 16 | /** |
16 | * @author XiangHan | 17 | * @author XiangHan |
... | @@ -33,6 +34,9 @@ public class MemberRelatedInfo implements Serializable { | ... | @@ -33,6 +34,9 @@ public class MemberRelatedInfo implements Serializable { |
33 | @Column(name = "member_id", nullable = false) | 34 | @Column(name = "member_id", nullable = false) |
34 | private Long memberId; | 35 | private Long memberId; |
35 | 36 | ||
37 | @Transient | ||
38 | private String memberCode; | ||
39 | |||
36 | // 人物关系 0:子女;1:父母 | 40 | // 人物关系 0:子女;1:父母 |
37 | @Column(name = "type") | 41 | @Column(name = "type") |
38 | private Integer type; | 42 | private Integer type; |
... | @@ -53,6 +57,14 @@ public class MemberRelatedInfo implements Serializable { | ... | @@ -53,6 +57,14 @@ public class MemberRelatedInfo implements Serializable { |
53 | @Column(name = "sex") | 57 | @Column(name = "sex") |
54 | private Integer sex; | 58 | private Integer sex; |
55 | 59 | ||
60 | // 生日 | ||
61 | @Column(name = "birthday") | ||
62 | private LocalDate birthday; | ||
63 | |||
64 | // 头像地址 | ||
65 | @Column(name = "avatar_url") | ||
66 | private String avatarUrl; | ||
67 | |||
56 | // 创建时间 | 68 | // 创建时间 |
57 | @CreatedDate | 69 | @CreatedDate |
58 | @Column(name = "create_time") | 70 | @Column(name = "create_time") | ... | ... |
1 | package com.topdraw.business.basicdata.member.relatedinfo.rest; | 1 | package com.topdraw.business.basicdata.member.relatedinfo.rest; |
2 | 2 | ||
3 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
4 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
3 | import com.topdraw.common.ResultInfo; | 5 | import com.topdraw.common.ResultInfo; |
4 | import com.topdraw.annotation.Log; | 6 | import com.topdraw.annotation.Log; |
5 | import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; | 7 | import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; |
... | @@ -8,10 +10,13 @@ import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelat | ... | @@ -8,10 +10,13 @@ import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelat |
8 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.data.domain.PageRequest; | 11 | import org.springframework.data.domain.PageRequest; |
10 | import org.springframework.data.domain.Pageable; | 12 | import org.springframework.data.domain.Pageable; |
13 | import org.springframework.util.Assert; | ||
11 | import org.springframework.validation.annotation.Validated; | 14 | import org.springframework.validation.annotation.Validated; |
12 | import org.springframework.web.bind.annotation.*; | 15 | import org.springframework.web.bind.annotation.*; |
13 | import io.swagger.annotations.*; | 16 | import io.swagger.annotations.*; |
14 | 17 | ||
18 | import java.util.Objects; | ||
19 | |||
15 | /** | 20 | /** |
16 | * @author XiangHan /api/MemberRelatedInfo | 21 | * @author XiangHan /api/MemberRelatedInfo |
17 | * @date 2021-10-22 | 22 | * @date 2021-10-22 |
... | @@ -19,10 +24,13 @@ import io.swagger.annotations.*; | ... | @@ -19,10 +24,13 @@ import io.swagger.annotations.*; |
19 | @Api(tags = "MemberRelatedInfo管理") | 24 | @Api(tags = "MemberRelatedInfo管理") |
20 | @RestController | 25 | @RestController |
21 | @RequestMapping("/api/MemberRelatedInfo") | 26 | @RequestMapping("/api/MemberRelatedInfo") |
27 | @CrossOrigin | ||
22 | public class MemberRelatedInfoController { | 28 | public class MemberRelatedInfoController { |
23 | 29 | ||
24 | @Autowired | 30 | @Autowired |
25 | private MemberRelatedInfoService MemberRelatedInfoService; | 31 | private MemberRelatedInfoService MemberRelatedInfoService; |
32 | @Autowired | ||
33 | private MemberService memberService; | ||
26 | 34 | ||
27 | @GetMapping(value = "/pageMemberRelatedInfos") | 35 | @GetMapping(value = "/pageMemberRelatedInfos") |
28 | @ApiOperation("查询MemberRelatedInfo") | 36 | @ApiOperation("查询MemberRelatedInfo") |
... | @@ -42,7 +50,17 @@ public class MemberRelatedInfoController { | ... | @@ -42,7 +50,17 @@ public class MemberRelatedInfoController { |
42 | @PutMapping(value = "/update") | 50 | @PutMapping(value = "/update") |
43 | @ApiOperation("修改MemberRelatedInfo") | 51 | @ApiOperation("修改MemberRelatedInfo") |
44 | public ResultInfo update(@Validated @RequestBody MemberRelatedInfo resources) { | 52 | public ResultInfo update(@Validated @RequestBody MemberRelatedInfo resources) { |
53 | Long memberId = resources.getMemberId(); | ||
54 | String idCard = resources.getIdCard(); | ||
55 | Assert.notNull(memberId,"memberId can't be null"); | ||
56 | Assert.notNull(idCard,"idCard can't be null"); | ||
57 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
58 | if (Objects.nonNull(memberDTO)) { | ||
59 | String code = memberDTO.getCode(); | ||
60 | Assert.notNull(code,"code can't be null"); | ||
61 | resources.setMemberCode(code); | ||
45 | MemberRelatedInfoService.update(resources); | 62 | MemberRelatedInfoService.update(resources); |
63 | } | ||
46 | return ResultInfo.success(); | 64 | return ResultInfo.success(); |
47 | } | 65 | } |
48 | 66 | ... | ... |
1 | package com.topdraw.business.basicdata.member.relatedinfo.service.dto; | 1 | package com.topdraw.business.basicdata.member.relatedinfo.service.dto; |
2 | 2 | ||
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | |||
5 | import javax.persistence.Column; | ||
4 | import java.sql.Timestamp; | 6 | import java.sql.Timestamp; |
5 | import java.io.Serializable; | 7 | import java.io.Serializable; |
8 | import java.time.LocalDate; | ||
6 | 9 | ||
7 | 10 | ||
8 | /** | 11 | /** |
... | @@ -33,6 +36,12 @@ public class MemberRelatedInfoDTO implements Serializable { | ... | @@ -33,6 +36,12 @@ public class MemberRelatedInfoDTO implements Serializable { |
33 | // 性别 0:女;1:男;-1:未知 | 36 | // 性别 0:女;1:男;-1:未知 |
34 | private Integer sex; | 37 | private Integer sex; |
35 | 38 | ||
39 | // 生日 | ||
40 | private LocalDate birthday; | ||
41 | |||
42 | // 头像地址 | ||
43 | private String avatarUrl; | ||
44 | |||
36 | // 创建时间 | 45 | // 创建时间 |
37 | private Timestamp createTime; | 46 | private Timestamp createTime; |
38 | 47 | ... | ... |
... | @@ -3,16 +3,22 @@ package com.topdraw.business.basicdata.member.rest; | ... | @@ -3,16 +3,22 @@ package com.topdraw.business.basicdata.member.rest; |
3 | import com.topdraw.annotation.Log; | 3 | import com.topdraw.annotation.Log; |
4 | import com.topdraw.business.basicdata.member.domain.Member; | 4 | import com.topdraw.business.basicdata.member.domain.Member; |
5 | import com.topdraw.business.basicdata.member.service.MemberService; | 5 | import com.topdraw.business.basicdata.member.service.MemberService; |
6 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; | 6 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; |
7 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
8 | import com.topdraw.business.process.service.UserTvOperationService; | ||
7 | import com.topdraw.common.ResultInfo; | 9 | import com.topdraw.common.ResultInfo; |
10 | import com.topdraw.util.Base64Util; | ||
8 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
9 | import io.swagger.annotations.ApiOperation; | 12 | import io.swagger.annotations.ApiOperation; |
10 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.data.domain.Pageable; | ||
12 | import org.springframework.util.Assert; | 14 | import org.springframework.util.Assert; |
15 | import org.springframework.util.StringUtils; | ||
13 | import org.springframework.validation.annotation.Validated; | 16 | import org.springframework.validation.annotation.Validated; |
14 | import org.springframework.web.bind.annotation.*; | 17 | import org.springframework.web.bind.annotation.*; |
15 | 18 | ||
19 | import java.util.Objects; | ||
20 | |||
21 | |||
16 | /** | 22 | /** |
17 | * @author XiangHan | 23 | * @author XiangHan |
18 | * @date 2021-10-22 | 24 | * @date 2021-10-22 |
... | @@ -20,11 +26,33 @@ import org.springframework.web.bind.annotation.*; | ... | @@ -20,11 +26,33 @@ import org.springframework.web.bind.annotation.*; |
20 | @Api(tags = "Member管理") | 26 | @Api(tags = "Member管理") |
21 | @RestController | 27 | @RestController |
22 | @RequestMapping("/api/member") | 28 | @RequestMapping("/api/member") |
29 | @CrossOrigin | ||
23 | public class MemberController { | 30 | public class MemberController { |
24 | 31 | ||
25 | @Autowired | 32 | @Autowired |
26 | private MemberService memberService; | 33 | private MemberService memberService; |
27 | 34 | ||
35 | @Autowired | ||
36 | private UserTvOperationService userTvOperationService; | ||
37 | |||
38 | @Log | ||
39 | @GetMapping(value = "/findById/{id}") | ||
40 | @ApiOperation("新增UserTv会员") | ||
41 | public ResultInfo findById(@PathVariable Long id) { | ||
42 | MemberDTO memberDTO = this.memberService.findById(id); | ||
43 | return ResultInfo.success(memberDTO); | ||
44 | } | ||
45 | |||
46 | @Log | ||
47 | @PostMapping(value = "/createMemberByUserTv") | ||
48 | @ApiOperation("新增UserTv会员") | ||
49 | public ResultInfo createMemberByUserTv(@Validated @RequestBody UserTv resources) { | ||
50 | String platformAccount = resources.getPlatformAccount(); | ||
51 | Assert.notNull(platformAccount, "The given platformAccount must not be null!"); | ||
52 | boolean result = this.userTvOperationService.createMemberByUserTv(resources); | ||
53 | return ResultInfo.success(result); | ||
54 | } | ||
55 | |||
28 | @Log | 56 | @Log |
29 | @PostMapping(value = "/create") | 57 | @PostMapping(value = "/create") |
30 | @ApiOperation("新增Member") | 58 | @ApiOperation("新增Member") |
... | @@ -45,7 +73,19 @@ public class MemberController { | ... | @@ -45,7 +73,19 @@ public class MemberController { |
45 | @PutMapping(value = "/update") | 73 | @PutMapping(value = "/update") |
46 | @ApiOperation("修改Member") | 74 | @ApiOperation("修改Member") |
47 | public ResultInfo update(@Validated @RequestBody Member resources) { | 75 | public ResultInfo update(@Validated @RequestBody Member resources) { |
76 | Long memberId = resources.getId(); | ||
77 | Assert.notNull(memberId,"memberId can't be null"); | ||
78 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
79 | if (Objects.nonNull(memberDTO)) { | ||
80 | String code = memberDTO.getCode(); | ||
81 | Assert.notNull(code, "code can't be null"); | ||
82 | resources.setCode(code); | ||
83 | String nickname = resources.getNickname(); | ||
84 | if (!StringUtils.isEmpty(nickname)) { | ||
85 | resources.setNickname(Base64Util.encode(nickname)); | ||
86 | } | ||
48 | memberService.update(resources); | 87 | memberService.update(resources); |
88 | } | ||
49 | return ResultInfo.success(); | 89 | return ResultInfo.success(); |
50 | } | 90 | } |
51 | 91 | ... | ... |
... | @@ -3,6 +3,7 @@ package com.topdraw.business.basicdata.member.service; | ... | @@ -3,6 +3,7 @@ package com.topdraw.business.basicdata.member.service; |
3 | import com.topdraw.business.basicdata.member.domain.Member; | 3 | import com.topdraw.business.basicdata.member.domain.Member; |
4 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | 4 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; |
5 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; | 5 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; |
6 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
6 | import org.springframework.data.domain.Pageable; | 7 | import org.springframework.data.domain.Pageable; |
7 | 8 | ||
8 | import java.util.List; | 9 | import java.util.List; |
... | @@ -48,4 +49,6 @@ public interface MemberService { | ... | @@ -48,4 +49,6 @@ public interface MemberService { |
48 | * @return MemberDTO | 49 | * @return MemberDTO |
49 | */ | 50 | */ |
50 | MemberDTO getByCode(String code); | 51 | MemberDTO getByCode(String code); |
52 | |||
53 | void doUpdateMemberPoints(Member member); | ||
51 | } | 54 | } | ... | ... |
... | @@ -4,6 +4,7 @@ import lombok.Data; | ... | @@ -4,6 +4,7 @@ import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.sql.Timestamp; | 6 | import java.sql.Timestamp; |
7 | import java.time.LocalDateTime; | ||
7 | 8 | ||
8 | 9 | ||
9 | /** | 10 | /** |
... | @@ -13,6 +14,9 @@ import java.sql.Timestamp; | ... | @@ -13,6 +14,9 @@ import java.sql.Timestamp; |
13 | @Data | 14 | @Data |
14 | public class MemberDTO implements Serializable { | 15 | public class MemberDTO implements Serializable { |
15 | 16 | ||
17 | // vip过期时间 | ||
18 | private LocalDateTime vipExpireTime; | ||
19 | |||
16 | // 主键 | 20 | // 主键 |
17 | private Long id; | 21 | private Long id; |
18 | 22 | ... | ... |
... | @@ -7,6 +7,11 @@ import com.topdraw.business.basicdata.member.service.MemberService; | ... | @@ -7,6 +7,11 @@ import com.topdraw.business.basicdata.member.service.MemberService; |
7 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | 7 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; |
8 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; | 8 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; |
9 | import com.topdraw.business.basicdata.member.service.mapper.MemberMapper; | 9 | import com.topdraw.business.basicdata.member.service.mapper.MemberMapper; |
10 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
11 | import com.topdraw.business.basicdata.user.iptv.service.UserTvService; | ||
12 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
13 | import com.topdraw.common.ResultInfo; | ||
14 | import com.topdraw.config.LocalConstants; | ||
10 | import com.topdraw.mq.config.RabbitMqConfig; | 15 | import com.topdraw.mq.config.RabbitMqConfig; |
11 | import com.topdraw.util.IdWorker; | 16 | import com.topdraw.util.IdWorker; |
12 | import com.topdraw.util.RedissonUtil; | 17 | import com.topdraw.util.RedissonUtil; |
... | @@ -15,11 +20,13 @@ import com.topdraw.utils.PageUtil; | ... | @@ -15,11 +20,13 @@ import com.topdraw.utils.PageUtil; |
15 | import com.topdraw.utils.QueryHelp; | 20 | import com.topdraw.utils.QueryHelp; |
16 | import com.topdraw.utils.StringUtils; | 21 | import com.topdraw.utils.StringUtils; |
17 | import com.topdraw.utils.ValidationUtil; | 22 | import com.topdraw.utils.ValidationUtil; |
23 | import lombok.extern.slf4j.Slf4j; | ||
18 | import org.redisson.api.RLock; | 24 | import org.redisson.api.RLock; |
19 | import org.redisson.api.RedissonClient; | 25 | import org.redisson.api.RedissonClient; |
20 | import org.springframework.beans.BeanUtils; | 26 | import org.springframework.beans.BeanUtils; |
21 | import org.springframework.beans.factory.annotation.Autowired; | 27 | import org.springframework.beans.factory.annotation.Autowired; |
22 | import org.springframework.cache.annotation.CacheConfig; | 28 | import org.springframework.cache.annotation.CacheConfig; |
29 | import org.springframework.cache.annotation.CacheEvict; | ||
23 | import org.springframework.cache.annotation.Cacheable; | 30 | import org.springframework.cache.annotation.Cacheable; |
24 | import org.springframework.dao.EmptyResultDataAccessException; | 31 | import org.springframework.dao.EmptyResultDataAccessException; |
25 | import org.springframework.data.domain.Page; | 32 | import org.springframework.data.domain.Page; |
... | @@ -33,9 +40,8 @@ import org.springframework.transaction.annotation.Transactional; | ... | @@ -33,9 +40,8 @@ import org.springframework.transaction.annotation.Transactional; |
33 | import org.springframework.transaction.support.DefaultTransactionDefinition; | 40 | import org.springframework.transaction.support.DefaultTransactionDefinition; |
34 | import org.springframework.util.Assert; | 41 | import org.springframework.util.Assert; |
35 | 42 | ||
36 | import java.util.List; | 43 | import java.nio.charset.StandardCharsets; |
37 | import java.util.Map; | 44 | import java.util.*; |
38 | import java.util.Objects; | ||
39 | 45 | ||
40 | /** | 46 | /** |
41 | * @author XiangHan | 47 | * @author XiangHan |
... | @@ -43,7 +49,7 @@ import java.util.Objects; | ... | @@ -43,7 +49,7 @@ import java.util.Objects; |
43 | */ | 49 | */ |
44 | @Service | 50 | @Service |
45 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 51 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
46 | //@CacheConfig(cacheNames = "uc-member-info") | 52 | @Slf4j |
47 | public class MemberServiceImpl implements MemberService { | 53 | public class MemberServiceImpl implements MemberService { |
48 | 54 | ||
49 | @Autowired | 55 | @Autowired |
... | @@ -55,6 +61,12 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -55,6 +61,12 @@ public class MemberServiceImpl implements MemberService { |
55 | @Autowired | 61 | @Autowired |
56 | private RedissonClient redissonClient; | 62 | private RedissonClient redissonClient; |
57 | 63 | ||
64 | @Autowired | ||
65 | PlatformTransactionManager platformTransactionManager; | ||
66 | |||
67 | @Autowired | ||
68 | private com.topdraw.business.basicdata.user.iptv.service.UserTvService UserTvService; | ||
69 | |||
58 | @Override | 70 | @Override |
59 | public Map<String, Object> queryAll(MemberQueryCriteria criteria, Pageable pageable) { | 71 | public Map<String, Object> queryAll(MemberQueryCriteria criteria, Pageable pageable) { |
60 | Page<Member> page = memberRepository.findAll((root, criteriaQuery, criteriaBuilder) | 72 | Page<Member> page = memberRepository.findAll((root, criteriaQuery, criteriaBuilder) |
... | @@ -68,6 +80,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -68,6 +80,7 @@ public class MemberServiceImpl implements MemberService { |
68 | } | 80 | } |
69 | 81 | ||
70 | @Override | 82 | @Override |
83 | // @Cacheable(value = "member::memberId",key = "#p0") | ||
71 | public MemberDTO findById(Long id) { | 84 | public MemberDTO findById(Long id) { |
72 | Member member = memberRepository.findById(id).orElseGet(Member::new); | 85 | Member member = memberRepository.findById(id).orElseGet(Member::new); |
73 | ValidationUtil.isNull(member.getId(),"Member","id",id); | 86 | ValidationUtil.isNull(member.getId(),"Member","id",id); |
... | @@ -77,8 +90,9 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -77,8 +90,9 @@ public class MemberServiceImpl implements MemberService { |
77 | 90 | ||
78 | @Override | 91 | @Override |
79 | @Transactional(rollbackFor = Exception.class) | 92 | @Transactional(rollbackFor = Exception.class) |
80 | @AsyncMqSend() | 93 | @AsyncMqSend |
81 | public Long create(Member resources) { | 94 | public Long create(Member resources) { |
95 | log.info("start=====>>>>>resources======>>>>接收到的数据 --->>>> " + resources); | ||
82 | Member member = this.checkMemberData(resources); | 96 | Member member = this.checkMemberData(resources); |
83 | memberRepository.save(member); | 97 | memberRepository.save(member); |
84 | return member.getId(); | 98 | return member.getId(); |
... | @@ -86,7 +100,8 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -86,7 +100,8 @@ public class MemberServiceImpl implements MemberService { |
86 | 100 | ||
87 | private Member checkMemberData(Member member) { | 101 | private Member checkMemberData(Member member) { |
88 | Long defaultValue = 0L; | 102 | Long defaultValue = 0L; |
89 | member.setCode(String.valueOf(IdWorker.generator())); | 103 | String code = member.getCode(); |
104 | member.setCode(StringUtils.isEmpty(code)?String.valueOf(IdWorker.generator()):code); | ||
90 | Integer gender = member.getGender(); | 105 | Integer gender = member.getGender(); |
91 | member.setGender(Objects.nonNull(gender) ? gender : 0); | 106 | member.setGender(Objects.nonNull(gender) ? gender : 0); |
92 | Integer type = member.getType(); | 107 | Integer type = member.getType(); |
... | @@ -94,39 +109,36 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -94,39 +109,36 @@ public class MemberServiceImpl implements MemberService { |
94 | Integer status = member.getStatus(); | 109 | Integer status = member.getStatus(); |
95 | member.setStatus(Objects.nonNull(status) ? status:1); | 110 | member.setStatus(Objects.nonNull(status) ? status:1); |
96 | Integer vip = member.getVip(); | 111 | Integer vip = member.getVip(); |
97 | member.setVip(Objects.nonNull(vip) ? status:0); | 112 | member.setVip(Objects.nonNull(vip) ? vip:0); |
98 | Integer level = member.getLevel(); | 113 | Integer level = member.getLevel(); |
99 | member.setLevel(Objects.nonNull(level) ? level:0); | 114 | member.setLevel(Objects.nonNull(level) ? level:1); |
100 | member.setExp(defaultValue); | 115 | member.setExp(defaultValue); |
101 | member.setPoints(defaultValue); | 116 | member.setPoints(defaultValue); |
102 | member.setDuePoints(defaultValue); | 117 | member.setDuePoints(defaultValue); |
103 | member.setCouponAmount(defaultValue); | 118 | member.setCouponAmount(defaultValue); |
104 | member.setDueCouponAmount(defaultValue); | 119 | member.setDueCouponAmount(defaultValue); |
120 | member.setBlackStatus(0L); | ||
121 | String nickname = member.getNickname(); | ||
122 | if (StringUtils.isEmpty(nickname)) { | ||
123 | nickname = "未设置"; | ||
124 | } | ||
125 | String base64Nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8))); | ||
126 | member.setNickname(base64Nickname); | ||
105 | return member; | 127 | return member; |
106 | } | 128 | } |
107 | 129 | ||
108 | @Autowired | ||
109 | PlatformTransactionManager platformTransactionManager; | ||
110 | |||
111 | @Override | 130 | @Override |
112 | @Transactional(rollbackFor = Exception.class) | 131 | @Transactional(rollbackFor = Exception.class) |
113 | @AsyncMqSend() | 132 | @AsyncMqSend() |
133 | @CacheEvict(value = "member::memberId",key = "#p0.id") | ||
114 | public void update(Member resources) { | 134 | public void update(Member resources) { |
115 | RLock rLock = this.redissonClient.getLock("updateMember" + resources.getId().toString()); | 135 | RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString()); |
116 | try { | 136 | try { |
117 | RedissonUtil.lock(rLock); | 137 | RedissonUtil.lock(rLock); |
118 | String name = Thread.currentThread().getName(); | ||
119 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> start ===>> "); | ||
120 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【resources】 ===>> " + resources); | ||
121 | Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new); | 138 | Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new); |
122 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | 139 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); |
123 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【member-search】 ===>> " + member); | ||
124 | member.copy(resources); | 140 | member.copy(resources); |
125 | this.save(member); | 141 | this.save(member); |
126 | // platformTransactionManager.commit(transaction); | ||
127 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【exp】 ===>> " + member.getExp()); | ||
128 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【point】 ===>> " + member.getPoints()); | ||
129 | System.out.println("=============>>>>【name】 ===== >> " + name + " =======>> 【member】 ===>> " + member); | ||
130 | } catch (Exception e) { | 142 | } catch (Exception e) { |
131 | e.printStackTrace(); | 143 | e.printStackTrace(); |
132 | throw e; | 144 | throw e; |
... | @@ -135,8 +147,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -135,8 +147,7 @@ public class MemberServiceImpl implements MemberService { |
135 | } | 147 | } |
136 | } | 148 | } |
137 | 149 | ||
138 | @Transactional(propagation = Propagation.REQUIRES_NEW) | 150 | private void save(Member member){ |
139 | public void save(Member member){ | ||
140 | memberRepository.save(member); | 151 | memberRepository.save(member); |
141 | } | 152 | } |
142 | 153 | ||
... | @@ -145,9 +156,18 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -145,9 +156,18 @@ public class MemberServiceImpl implements MemberService { |
145 | @AsyncMqSend() | 156 | @AsyncMqSend() |
146 | public void delete(Long id) { | 157 | public void delete(Long id) { |
147 | Assert.notNull(id, "The given id must not be null!"); | 158 | Assert.notNull(id, "The given id must not be null!"); |
159 | RLock rLock = this.redissonClient.getLock("member::delete::id" + id); | ||
160 | try { | ||
161 | RedissonUtil.lock(rLock); | ||
148 | Member member = memberRepository.findById(id).orElseThrow( | 162 | Member member = memberRepository.findById(id).orElseThrow( |
149 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Member.class, id), 1)); | 163 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Member.class, id), 1)); |
150 | memberRepository.delete(member); | 164 | memberRepository.delete(member); |
165 | } catch (Exception e) { | ||
166 | e.printStackTrace(); | ||
167 | throw e; | ||
168 | } finally { | ||
169 | RedissonUtil.unlock(rLock); | ||
170 | } | ||
151 | } | 171 | } |
152 | 172 | ||
153 | 173 | ||
... | @@ -156,4 +176,23 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -156,4 +176,23 @@ public class MemberServiceImpl implements MemberService { |
156 | return StringUtils.isNotEmpty(code) ? memberMapper.toDto(memberRepository.findFirstByCode(code).orElseGet(Member::new)) | 176 | return StringUtils.isNotEmpty(code) ? memberMapper.toDto(memberRepository.findFirstByCode(code).orElseGet(Member::new)) |
157 | : new MemberDTO(); | 177 | : new MemberDTO(); |
158 | } | 178 | } |
179 | |||
180 | @Override | ||
181 | public void doUpdateMemberPoints(Member resources) { | ||
182 | RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString()); | ||
183 | try { | ||
184 | RedissonUtil.lock(rLock); | ||
185 | Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new); | ||
186 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | ||
187 | member.copy(resources); | ||
188 | this.save(member); | ||
189 | } catch (Exception e) { | ||
190 | e.printStackTrace(); | ||
191 | throw e; | ||
192 | } finally { | ||
193 | RedissonUtil.unlock(rLock); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | |||
159 | } | 198 | } | ... | ... |
... | @@ -10,6 +10,7 @@ import org.springframework.data.annotation.CreatedDate; | ... | @@ -10,6 +10,7 @@ import org.springframework.data.annotation.CreatedDate; |
10 | import org.springframework.data.annotation.LastModifiedDate; | 10 | import org.springframework.data.annotation.LastModifiedDate; |
11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | 11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
12 | import java.sql.Timestamp; | 12 | import java.sql.Timestamp; |
13 | import java.time.LocalDateTime; | ||
13 | import java.util.UUID; | 14 | import java.util.UUID; |
14 | 15 | ||
15 | import java.io.Serializable; | 16 | import java.io.Serializable; |
... | @@ -27,6 +28,10 @@ import java.io.Serializable; | ... | @@ -27,6 +28,10 @@ import java.io.Serializable; |
27 | @Table(name="uc_points_available") | 28 | @Table(name="uc_points_available") |
28 | public class PointsAvailable implements Serializable { | 29 | public class PointsAvailable implements Serializable { |
29 | 30 | ||
31 | /** 会员编号 */ | ||
32 | @Transient | ||
33 | private String memberCode; | ||
34 | |||
30 | // 主键 | 35 | // 主键 |
31 | @Id | 36 | @Id |
32 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 37 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
... | @@ -54,9 +59,9 @@ public class PointsAvailable implements Serializable { | ... | @@ -54,9 +59,9 @@ public class PointsAvailable implements Serializable { |
54 | private Long points; | 59 | private Long points; |
55 | 60 | ||
56 | // 过期时间 | 61 | // 过期时间 |
57 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 62 | // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
58 | @Column(name = "expire_time") | 63 | @Column(name = "expire_time") |
59 | private Timestamp expireTime; | 64 | private LocalDateTime expireTime; |
60 | 65 | ||
61 | // 描述 | 66 | // 描述 |
62 | @Column(name = "description") | 67 | @Column(name = "description") | ... | ... |
... | @@ -10,6 +10,7 @@ import org.springframework.data.jpa.repository.Query; | ... | @@ -10,6 +10,7 @@ import org.springframework.data.jpa.repository.Query; |
10 | import org.springframework.transaction.annotation.Transactional; | 10 | import org.springframework.transaction.annotation.Transactional; |
11 | 11 | ||
12 | import java.sql.Timestamp; | 12 | import java.sql.Timestamp; |
13 | import java.time.LocalDateTime; | ||
13 | import java.util.Date; | 14 | import java.util.Date; |
14 | import java.util.List; | 15 | import java.util.List; |
15 | import java.util.Optional; | 16 | import java.util.Optional; |
... | @@ -24,7 +25,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable | ... | @@ -24,7 +25,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable |
24 | 25 | ||
25 | List<PointsAvailableDTO> findByMemberId(Long memberId); | 26 | List<PointsAvailableDTO> findByMemberId(Long memberId); |
26 | 27 | ||
27 | List<PointsAvailable> findByMemberIdAndExpireTimeBefore(Long memberId , Date now); | 28 | List<PointsAvailable> findByMemberIdAndExpireTimeBefore(Long memberId , LocalDateTime now); |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * 即将过期的积分 | 31 | * 即将过期的积分 |
... | @@ -75,7 +76,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable | ... | @@ -75,7 +76,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable |
75 | * @param memberId | 76 | * @param memberId |
76 | * @return | 77 | * @return |
77 | */ | 78 | */ |
78 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where upa.member_id = ?1 and upa.expire_time > now()" | 79 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where upa.member_id = ?1 and (upa.expire_time > now() or upa.expire_time is null)" |
79 | ,nativeQuery = true) | 80 | ,nativeQuery = true) |
80 | Long findAvailablePointsByMemberId(long memberId); | 81 | Long findAvailablePointsByMemberId(long memberId); |
81 | 82 | ... | ... |
... | @@ -3,15 +3,12 @@ package com.topdraw.business.basicdata.points.available.service; | ... | @@ -3,15 +3,12 @@ package com.topdraw.business.basicdata.points.available.service; |
3 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; | 3 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; |
4 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; | 4 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; |
5 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; | 5 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; |
6 | import com.topdraw.business.process.domian.TempPoints; | ||
7 | import org.springframework.data.domain.Pageable; | 6 | import org.springframework.data.domain.Pageable; |
8 | 7 | ||
9 | import java.sql.Timestamp; | 8 | import java.time.LocalDateTime; |
10 | import java.util.Date; | 9 | import java.util.Date; |
11 | import java.util.Map; | 10 | import java.util.Map; |
12 | import java.util.List; | 11 | import java.util.List; |
13 | import java.io.IOException; | ||
14 | import javax.servlet.http.HttpServletResponse; | ||
15 | 12 | ||
16 | /** | 13 | /** |
17 | * @author XiangHan | 14 | * @author XiangHan |
... | @@ -78,9 +75,7 @@ public interface PointsAvailableService { | ... | @@ -78,9 +75,7 @@ public interface PointsAvailableService { |
78 | * @param timestamp | 75 | * @param timestamp |
79 | * @return | 76 | * @return |
80 | */ | 77 | */ |
81 | List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, Date timestamp); | 78 | List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, LocalDateTime timestamp); |
82 | |||
83 | List<PointsAvailableDTO> findByMemberIdAndExpireTimeAfter(Long memberId, Date timestamp); | ||
84 | 79 | ||
85 | /** | 80 | /** |
86 | * 即将过期的积分 | 81 | * 即将过期的积分 |
... | @@ -91,14 +86,6 @@ public interface PointsAvailableService { | ... | @@ -91,14 +86,6 @@ public interface PointsAvailableService { |
91 | Long findSoonExpireTime(Long memberId,Integer factor); | 86 | Long findSoonExpireTime(Long memberId,Integer factor); |
92 | 87 | ||
93 | /** | 88 | /** |
94 | * 查询数据分页 | ||
95 | * @param criteria 条件参数 | ||
96 | * @param pageable 分页参数 | ||
97 | * @return Map<String,Object> | ||
98 | */ | ||
99 | Map<String,Object> findByMemberIdAndExpireTimeBefore(PointsAvailableQueryCriteria criteria, Pageable pageable); | ||
100 | |||
101 | /** | ||
102 | * | 89 | * |
103 | * @param memberId | 90 | * @param memberId |
104 | * @return | 91 | * @return |
... | @@ -106,38 +93,20 @@ public interface PointsAvailableService { | ... | @@ -106,38 +93,20 @@ public interface PointsAvailableService { |
106 | List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId); | 93 | List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId); |
107 | 94 | ||
108 | /** | 95 | /** |
109 | * 可用总积分 | 96 | * |
110 | * @param criteria 条件参数 | 97 | * @param memberId |
111 | * @return Map<String,Object> | ||
112 | */ | ||
113 | Long findEveryDayPointsAvailable(PointsAvailableQueryCriteria criteria); | ||
114 | |||
115 | /** | ||
116 | * 总积分 | ||
117 | * @param criteria | ||
118 | * @return | ||
119 | */ | ||
120 | Long findEveryDayPointsProduce(PointsAvailableQueryCriteria criteria); | ||
121 | |||
122 | /** | ||
123 | * 积分消耗 | ||
124 | * @param criteria | ||
125 | * @return | 98 | * @return |
126 | */ | 99 | */ |
127 | Long findEveryDayPointsConsume(PointsAvailableQueryCriteria criteria); | 100 | long findAvailablePointsByMemberId(long memberId); |
128 | 101 | ||
129 | /** | 102 | /** |
130 | * 积分过期 | 103 | * |
131 | * @param criteria | 104 | * @param memberId |
132 | * @return | 105 | * @return |
133 | */ | 106 | */ |
134 | Long findEveryDayPointsExpire(PointsAvailableQueryCriteria criteria); | 107 | long findTotalPointsByMemberId(Long memberId); |
135 | |||
136 | |||
137 | long findAvailablePointsByMemberId(long memberId); | ||
138 | |||
139 | 108 | ||
140 | List<PointsAvailableDTO> findByExpireTimeBefore(Timestamp now); | 109 | void delete4Custom(Long id); |
141 | 110 | ||
142 | long findTotalPointsByMemberId(Long memberId); | 111 | void create4Custom(PointsAvailable pointsAvailable); |
143 | } | 112 | } | ... | ... |
... | @@ -3,6 +3,7 @@ package com.topdraw.business.basicdata.points.available.service.dto; | ... | @@ -3,6 +3,7 @@ package com.topdraw.business.basicdata.points.available.service.dto; |
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | import java.sql.Timestamp; | 4 | import java.sql.Timestamp; |
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.time.LocalDateTime; | ||
6 | 7 | ||
7 | 8 | ||
8 | /** | 9 | /** |
... | @@ -31,7 +32,7 @@ public class PointsAvailableDTO implements Serializable { | ... | @@ -31,7 +32,7 @@ public class PointsAvailableDTO implements Serializable { |
31 | private Long points; | 32 | private Long points; |
32 | 33 | ||
33 | // 过期时间 | 34 | // 过期时间 |
34 | private Timestamp expireTime; | 35 | private LocalDateTime expireTime; |
35 | 36 | ||
36 | // 描述 | 37 | // 描述 |
37 | private String description; | 38 | private String description; | ... | ... |
1 | package com.topdraw.business.basicdata.points.available.service.impl; | 1 | package com.topdraw.business.basicdata.points.available.service.impl; |
2 | 2 | ||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
3 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; | 4 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; |
4 | import com.topdraw.util.RedissonUtil; | 5 | import com.topdraw.util.RedissonUtil; |
5 | import com.topdraw.util.TimestampUtil; | ||
6 | import com.topdraw.utils.ValidationUtil; | 6 | import com.topdraw.utils.ValidationUtil; |
7 | import com.topdraw.business.basicdata.points.available.repository.PointsAvailableRepository; | 7 | import com.topdraw.business.basicdata.points.available.repository.PointsAvailableRepository; |
8 | import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; | 8 | import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; |
... | @@ -24,6 +24,7 @@ import com.topdraw.utils.QueryHelp; | ... | @@ -24,6 +24,7 @@ import com.topdraw.utils.QueryHelp; |
24 | import com.topdraw.utils.StringUtils; | 24 | import com.topdraw.utils.StringUtils; |
25 | 25 | ||
26 | import java.sql.Timestamp; | 26 | import java.sql.Timestamp; |
27 | import java.time.LocalDateTime; | ||
27 | import java.util.*; | 28 | import java.util.*; |
28 | import java.io.IOException; | 29 | import java.io.IOException; |
29 | import javax.servlet.http.HttpServletResponse; | 30 | import javax.servlet.http.HttpServletResponse; |
... | @@ -53,11 +54,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -53,11 +54,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
53 | } | 54 | } |
54 | 55 | ||
55 | @Override | 56 | @Override |
56 | public Map<String, Object> findByMemberIdAndExpireTimeBefore(PointsAvailableQueryCriteria criteria, Pageable pageable) { | ||
57 | return this.queryAll(criteria,pageable); | ||
58 | } | ||
59 | |||
60 | @Override | ||
61 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { | 57 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { |
62 | return PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdOrderByExpireTime(memberId)); | 58 | return PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdOrderByExpireTime(memberId)); |
63 | } | 59 | } |
... | @@ -76,14 +72,24 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -76,14 +72,24 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
76 | 72 | ||
77 | @Override | 73 | @Override |
78 | @Transactional(rollbackFor = Exception.class) | 74 | @Transactional(rollbackFor = Exception.class) |
75 | @AsyncMqSend | ||
79 | public void create(PointsAvailable resources) { | 76 | public void create(PointsAvailable resources) { |
77 | RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | ||
78 | try { | ||
79 | RedissonUtil.lock(rLock); | ||
80 | PointsAvailableRepository.save(resources); | 80 | PointsAvailableRepository.save(resources); |
81 | } catch (Exception e) { | ||
82 | e.printStackTrace(); | ||
83 | throw e; | ||
84 | } finally { | ||
85 | RedissonUtil.unlock(rLock); | ||
86 | } | ||
81 | } | 87 | } |
82 | 88 | ||
83 | @Override | 89 | @Override |
84 | @Transactional(rollbackFor = Exception.class) | 90 | @Transactional(rollbackFor = Exception.class) |
85 | public void update(PointsAvailable resources) { | 91 | public void update(PointsAvailable resources) { |
86 | RLock rLock = this.redissonClient.getLock("updatePointsAvailable"+resources.getId().toString()); | 92 | RLock rLock = this.redissonClient.getLock("PointsAvailable::update::id"+resources.getMemberId().toString()); |
87 | try { | 93 | try { |
88 | RedissonUtil.lock(rLock); | 94 | RedissonUtil.lock(rLock); |
89 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); | 95 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); |
... | @@ -102,14 +108,33 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -102,14 +108,33 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
102 | @Transactional(rollbackFor = Exception.class) | 108 | @Transactional(rollbackFor = Exception.class) |
103 | public void delete(Long id) { | 109 | public void delete(Long id) { |
104 | Assert.notNull(id, "The given id must not be null!"); | 110 | Assert.notNull(id, "The given id must not be null!"); |
111 | RLock rLock = this.redissonClient.getLock("PointsAvailable::delete::id"+id); | ||
112 | try { | ||
113 | RedissonUtil.lock(rLock); | ||
105 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | 114 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( |
106 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | 115 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); |
107 | PointsAvailableRepository.delete(PointsAvailable); | 116 | PointsAvailableRepository.delete(PointsAvailable); |
117 | } catch (Exception e) { | ||
118 | e.printStackTrace(); | ||
119 | throw e; | ||
120 | } finally { | ||
121 | RedissonUtil.unlock(rLock); | ||
122 | } | ||
108 | } | 123 | } |
109 | 124 | ||
110 | @Override | 125 | @Override |
126 | @Transactional(rollbackFor = Exception.class) | ||
111 | public void deleteBatchByIds(List<Long> id) { | 127 | public void deleteBatchByIds(List<Long> id) { |
128 | RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+id.get(0)); | ||
129 | try { | ||
130 | RedissonUtil.lock(rLock); | ||
112 | PointsAvailableRepository.deleteBatchByIds(id); | 131 | PointsAvailableRepository.deleteBatchByIds(id); |
132 | } catch (Exception e) { | ||
133 | e.printStackTrace(); | ||
134 | throw e; | ||
135 | } finally { | ||
136 | RedissonUtil.unlock(rLock); | ||
137 | } | ||
113 | } | 138 | } |
114 | 139 | ||
115 | 140 | ||
... | @@ -120,59 +145,57 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -120,59 +145,57 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
120 | } | 145 | } |
121 | 146 | ||
122 | @Override | 147 | @Override |
123 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, Date timestamp) { | 148 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, LocalDateTime timestamp) { |
124 | return Objects.nonNull(memberId)? | 149 | return Objects.nonNull(memberId)? |
125 | PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdAndExpireTimeBefore(memberId, timestamp)) | 150 | PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdAndExpireTimeBefore(memberId, timestamp)) |
126 | :null; | 151 | :null; |
127 | } | 152 | } |
128 | 153 | ||
129 | @Override | 154 | @Override |
130 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeAfter(Long memberId, Date timestamp) { | ||
131 | return Objects.nonNull(memberId)? | ||
132 | PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdAndExpireTimeAfter(memberId, timestamp)) | ||
133 | :null; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public Long findSoonExpireTime(Long memberId, Integer factor) { | 155 | public Long findSoonExpireTime(Long memberId, Integer factor) { |
138 | return PointsAvailableRepository.findSoonExpireTime(memberId, factor); | 156 | return PointsAvailableRepository.findSoonExpireTime(memberId, factor); |
139 | } | 157 | } |
140 | 158 | ||
141 | |||
142 | @Override | ||
143 | public Long findEveryDayPointsAvailable(PointsAvailableQueryCriteria criteria) { | ||
144 | return PointsAvailableRepository.findEveryDayPointsAvailable(criteria); | ||
145 | } | ||
146 | |||
147 | @Override | 159 | @Override |
148 | public Long findEveryDayPointsProduce(PointsAvailableQueryCriteria criteria) { | 160 | public long findAvailablePointsByMemberId(long memberId) { |
149 | return this.PointsAvailableRepository.findEveryDayPointsProduce(criteria); | 161 | Long availablePoints = this.PointsAvailableRepository.findAvailablePointsByMemberId(memberId); |
162 | return availablePoints == null ? 0L : availablePoints; | ||
150 | } | 163 | } |
151 | 164 | ||
152 | @Override | 165 | @Override |
153 | public Long findEveryDayPointsConsume(PointsAvailableQueryCriteria criteria) { | 166 | public long findTotalPointsByMemberId(Long memberId) { |
154 | return 0L; | 167 | return this.PointsAvailableRepository.findTotalCountByMemberId(memberId); |
155 | } | 168 | } |
156 | 169 | ||
157 | @Override | 170 | @Override |
158 | public Long findEveryDayPointsExpire(PointsAvailableQueryCriteria criteria) { | 171 | public void delete4Custom(Long id) { |
159 | return this.PointsAvailableRepository.findEveryDayPointsExpire(criteria); | 172 | Assert.notNull(id, "The given id must not be null!"); |
173 | RLock rLock = this.redissonClient.getLock("PointsAvailable::delete::id"+id); | ||
174 | try { | ||
175 | RedissonUtil.lock(rLock); | ||
176 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | ||
177 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | ||
178 | PointsAvailableRepository.delete(PointsAvailable); | ||
179 | } catch (Exception e) { | ||
180 | e.printStackTrace(); | ||
181 | throw e; | ||
182 | } finally { | ||
183 | RedissonUtil.unlock(rLock); | ||
160 | } | 184 | } |
161 | |||
162 | @Override | ||
163 | public long findAvailablePointsByMemberId(long memberId) { | ||
164 | Long availablePoints = this.PointsAvailableRepository.findAvailablePointsByMemberId(memberId); | ||
165 | return availablePoints == null ? 0L : availablePoints; | ||
166 | } | 185 | } |
167 | 186 | ||
168 | @Override | 187 | @Override |
169 | public List<PointsAvailableDTO> findByExpireTimeBefore(Timestamp now) { | 188 | public void create4Custom(PointsAvailable resources) { |
170 | return PointsAvailableMapper.toDto(this.PointsAvailableRepository.findByExpireTimeBefore(now)); | 189 | RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+resources.getMemberId().toString()); |
190 | try { | ||
191 | RedissonUtil.lock(rLock); | ||
192 | PointsAvailableRepository.save(resources); | ||
193 | } catch (Exception e) { | ||
194 | e.printStackTrace(); | ||
195 | throw e; | ||
196 | } finally { | ||
197 | RedissonUtil.unlock(rLock); | ||
171 | } | 198 | } |
172 | |||
173 | @Override | ||
174 | public long findTotalPointsByMemberId(Long memberId) { | ||
175 | return this.PointsAvailableRepository.findTotalCountByMemberId(memberId); | ||
176 | } | 199 | } |
177 | 200 | ||
178 | } | 201 | } | ... | ... |
... | @@ -23,6 +23,9 @@ import java.io.Serializable; | ... | @@ -23,6 +23,9 @@ import java.io.Serializable; |
23 | @Table(name="uc_points_detail") | 23 | @Table(name="uc_points_detail") |
24 | public class PointsDetail implements Serializable { | 24 | public class PointsDetail implements Serializable { |
25 | 25 | ||
26 | @Transient | ||
27 | private String memberCode; | ||
28 | |||
26 | // 主键 | 29 | // 主键 |
27 | @Id | 30 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ... | ... |
... | @@ -60,4 +60,6 @@ public interface PointsDetailService { | ... | @@ -60,4 +60,6 @@ public interface PointsDetailService { |
60 | * @return | 60 | * @return |
61 | */ | 61 | */ |
62 | List<PointsDetailDTO> findByMemberId(Long memberId); | 62 | List<PointsDetailDTO> findByMemberId(Long memberId); |
63 | |||
64 | void create4Custom(PointsDetail pointsDetail); | ||
63 | } | 65 | } | ... | ... |
... | @@ -59,14 +59,13 @@ public class PointsDetailServiceImpl implements PointsDetailService { | ... | @@ -59,14 +59,13 @@ public class PointsDetailServiceImpl implements PointsDetailService { |
59 | 59 | ||
60 | @Override | 60 | @Override |
61 | @Transactional(rollbackFor = Exception.class) | 61 | @Transactional(rollbackFor = Exception.class) |
62 | @AsyncMqSend() | 62 | @AsyncMqSend |
63 | public void create(PointsDetail resources) { | 63 | public void create(PointsDetail resources) { |
64 | PointsDetailRepository.save(resources); | 64 | PointsDetailRepository.save(resources); |
65 | } | 65 | } |
66 | 66 | ||
67 | @Override | 67 | @Override |
68 | @Transactional(rollbackFor = Exception.class) | 68 | @Transactional(rollbackFor = Exception.class) |
69 | @AsyncMqSend() | ||
70 | public void update(PointsDetail resources) { | 69 | public void update(PointsDetail resources) { |
71 | PointsDetail PointsDetail = PointsDetailRepository.findById(resources.getId()).orElseGet(PointsDetail::new); | 70 | PointsDetail PointsDetail = PointsDetailRepository.findById(resources.getId()).orElseGet(PointsDetail::new); |
72 | ValidationUtil.isNull( PointsDetail.getId(),"PointsDetail","id",resources.getId()); | 71 | ValidationUtil.isNull( PointsDetail.getId(),"PointsDetail","id",resources.getId()); |
... | @@ -76,7 +75,6 @@ public class PointsDetailServiceImpl implements PointsDetailService { | ... | @@ -76,7 +75,6 @@ public class PointsDetailServiceImpl implements PointsDetailService { |
76 | 75 | ||
77 | @Override | 76 | @Override |
78 | @Transactional(rollbackFor = Exception.class) | 77 | @Transactional(rollbackFor = Exception.class) |
79 | @AsyncMqSend() | ||
80 | public void delete(Long id) { | 78 | public void delete(Long id) { |
81 | Assert.notNull(id, "The given id must not be null!"); | 79 | Assert.notNull(id, "The given id must not be null!"); |
82 | PointsDetail PointsDetail = PointsDetailRepository.findById(id).orElseThrow( | 80 | PointsDetail PointsDetail = PointsDetailRepository.findById(id).orElseThrow( |
... | @@ -102,4 +100,9 @@ public class PointsDetailServiceImpl implements PointsDetailService { | ... | @@ -102,4 +100,9 @@ public class PointsDetailServiceImpl implements PointsDetailService { |
102 | PointsDetailMapper.toDto(PointsDetailRepository.findByMemberId(memberId)) | 100 | PointsDetailMapper.toDto(PointsDetailRepository.findByMemberId(memberId)) |
103 | :null; | 101 | :null; |
104 | } | 102 | } |
103 | |||
104 | @Override | ||
105 | public void create4Custom(PointsDetail pointsDetail) { | ||
106 | PointsDetailRepository.save(pointsDetail); | ||
107 | } | ||
105 | } | 108 | } | ... | ... |
... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
11 | import java.sql.Timestamp; | 11 | import java.sql.Timestamp; |
12 | 12 | ||
13 | import java.io.Serializable; | 13 | import java.io.Serializable; |
14 | import java.time.LocalDateTime; | ||
14 | 15 | ||
15 | /** | 16 | /** |
16 | * @author XiangHan | 17 | * @author XiangHan |
... | @@ -54,7 +55,7 @@ public class RightsHistory implements Serializable { | ... | @@ -54,7 +55,7 @@ public class RightsHistory implements Serializable { |
54 | 55 | ||
55 | // 失效时间 | 56 | // 失效时间 |
56 | @Column(name = "expire_time") | 57 | @Column(name = "expire_time") |
57 | private Timestamp expireTime; | 58 | private LocalDateTime expireTime; |
58 | 59 | ||
59 | @CreatedDate | 60 | @CreatedDate |
60 | @Column(name = "create_time") | 61 | @Column(name = "create_time") | ... | ... |
... | @@ -5,6 +5,7 @@ import lombok.Data; | ... | @@ -5,6 +5,7 @@ import lombok.Data; |
5 | import javax.persistence.Column; | 5 | import javax.persistence.Column; |
6 | import java.sql.Timestamp; | 6 | import java.sql.Timestamp; |
7 | import java.io.Serializable; | 7 | import java.io.Serializable; |
8 | import java.time.LocalDateTime; | ||
8 | 9 | ||
9 | 10 | ||
10 | /** | 11 | /** |
... | @@ -33,7 +34,7 @@ public class RightsHistoryDTO implements Serializable { | ... | @@ -33,7 +34,7 @@ public class RightsHistoryDTO implements Serializable { |
33 | private Timestamp sendTime; | 34 | private Timestamp sendTime; |
34 | 35 | ||
35 | // 失效时间 | 36 | // 失效时间 |
36 | private Timestamp expireTime; | 37 | private LocalDateTime expireTime; |
37 | 38 | ||
38 | private Timestamp createTime; | 39 | private Timestamp createTime; |
39 | 40 | ... | ... |
... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
11 | import java.sql.Timestamp; | 11 | import java.sql.Timestamp; |
12 | 12 | ||
13 | import java.io.Serializable; | 13 | import java.io.Serializable; |
14 | import java.time.LocalDateTime; | ||
14 | 15 | ||
15 | /** | 16 | /** |
16 | * @author XiangHan | 17 | * @author XiangHan |
... | @@ -50,7 +51,7 @@ public class Task implements Serializable { | ... | @@ -50,7 +51,7 @@ public class Task implements Serializable { |
50 | 51 | ||
51 | // 任务失效时间 | 52 | // 任务失效时间 |
52 | @Column(name = "expire_time") | 53 | @Column(name = "expire_time") |
53 | private Timestamp expireTime; | 54 | private LocalDateTime expireTime; |
54 | 55 | ||
55 | // 显示顺序 | 56 | // 显示顺序 |
56 | @Column(name = "sequence") | 57 | @Column(name = "sequence") | ... | ... |
... | @@ -5,6 +5,7 @@ import lombok.Data; | ... | @@ -5,6 +5,7 @@ import lombok.Data; |
5 | import javax.persistence.Column; | 5 | import javax.persistence.Column; |
6 | import java.sql.Timestamp; | 6 | import java.sql.Timestamp; |
7 | import java.io.Serializable; | 7 | import java.io.Serializable; |
8 | import java.time.LocalDateTime; | ||
8 | 9 | ||
9 | 10 | ||
10 | /** | 11 | /** |
... | @@ -32,7 +33,7 @@ public class TaskDTO implements Serializable { | ... | @@ -32,7 +33,7 @@ public class TaskDTO implements Serializable { |
32 | private Timestamp validTime; | 33 | private Timestamp validTime; |
33 | 34 | ||
34 | // 任务失效时间 | 35 | // 任务失效时间 |
35 | private Timestamp expireTime; | 36 | private LocalDateTime expireTime; |
36 | 37 | ||
37 | // 显示顺序 | 38 | // 显示顺序 |
38 | private Integer sequence; | 39 | private Integer sequence; | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/basicdata/user/iptv/domain/UserTv.java
0 → 100644
1 | package com.topdraw.business.basicdata.user.iptv.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-12-16 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_user_tv") | ||
24 | public class UserTv implements Serializable { | ||
25 | |||
26 | @Transient | ||
27 | private String memberCode; | ||
28 | |||
29 | // ID | ||
30 | @Id | ||
31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
32 | @Column(name = "id") | ||
33 | private Long id; | ||
34 | |||
35 | // 人ID | ||
36 | @Column(name = "person_id") | ||
37 | private Long personId; | ||
38 | |||
39 | // 运营商平台 | ||
40 | @Column(name = "platform") | ||
41 | private String platform; | ||
42 | |||
43 | // 运营商平台账号 | ||
44 | @Column(name = "platform_account") | ||
45 | private String platformAccount; | ||
46 | |||
47 | // 手机号 | ||
48 | @Column(name = "cellphone") | ||
49 | private String cellphone; | ||
50 | |||
51 | // 用户名 | ||
52 | @Column(name = "username") | ||
53 | private String username; | ||
54 | |||
55 | // 密码 MD5 | ||
56 | @Column(name = "password") | ||
57 | private String password; | ||
58 | |||
59 | // 昵称 Base64 | ||
60 | @Column(name = "nickname") | ||
61 | private String nickname; | ||
62 | |||
63 | // 头像 | ||
64 | @Column(name = "image") | ||
65 | private String image; | ||
66 | |||
67 | // 登录天数(总天数) | ||
68 | @Column(name = "login_days") | ||
69 | private Integer loginDays; | ||
70 | |||
71 | // 连续登录天数 | ||
72 | @Column(name = "continue_days") | ||
73 | private Integer continueDays; | ||
74 | |||
75 | // 活跃时间 | ||
76 | @Column(name = "active_time") | ||
77 | private Timestamp activeTime; | ||
78 | |||
79 | // 分组 分组ID用逗号分隔 | ||
80 | @Column(name = "groups") | ||
81 | private String groups; | ||
82 | |||
83 | // 标签 标签用逗号分隔 | ||
84 | @Column(name = "tags") | ||
85 | private String tags; | ||
86 | |||
87 | // 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 | ||
88 | @Column(name = "login_type") | ||
89 | private Integer loginType; | ||
90 | |||
91 | // 状态 0-下线 1-上线 | ||
92 | @Column(name = "status") | ||
93 | private Integer status; | ||
94 | |||
95 | // 描述 | ||
96 | @Column(name = "description") | ||
97 | private String description; | ||
98 | |||
99 | // 创建者 | ||
100 | @Column(name = "create_by") | ||
101 | private String createBy; | ||
102 | |||
103 | // 创建时间 | ||
104 | @CreatedDate | ||
105 | @Column(name = "create_time") | ||
106 | private Timestamp createTime; | ||
107 | |||
108 | // 更新者 | ||
109 | @Column(name = "update_by") | ||
110 | private String updateBy; | ||
111 | |||
112 | // 更新时间 | ||
113 | @LastModifiedDate | ||
114 | @Column(name = "update_time") | ||
115 | private Timestamp updateTime; | ||
116 | |||
117 | // 会员id | ||
118 | @Column(name = "member_id") | ||
119 | private Long memberId; | ||
120 | |||
121 | public void copy(UserTv source){ | ||
122 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
123 | } | ||
124 | } |
1 | package com.topdraw.business.basicdata.user.iptv.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
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-12-16 | ||
12 | */ | ||
13 | public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecificationExecutor<UserTv> { | ||
14 | |||
15 | Optional<UserTv> findByPlatformAccount(String platformAccount); | ||
16 | } |
1 | package com.topdraw.business.basicdata.user.iptv.rest; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.domain.Member; | ||
4 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
5 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
6 | import com.topdraw.common.ResultInfo; | ||
7 | import com.topdraw.annotation.Log; | ||
8 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
9 | import com.topdraw.business.basicdata.user.iptv.service.UserTvService; | ||
10 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.data.domain.Pageable; | ||
13 | import org.springframework.http.HttpStatus; | ||
14 | import org.springframework.http.ResponseEntity; | ||
15 | import org.springframework.util.Assert; | ||
16 | import org.springframework.validation.annotation.Validated; | ||
17 | import org.springframework.web.bind.annotation.*; | ||
18 | import io.swagger.annotations.*; | ||
19 | import java.io.IOException; | ||
20 | import java.util.Objects; | ||
21 | import javax.servlet.http.HttpServletResponse; | ||
22 | |||
23 | /** | ||
24 | * @author XiangHan | ||
25 | * @date 2021-12-16 | ||
26 | */ | ||
27 | @Api(tags = "UserTv管理") | ||
28 | @RestController | ||
29 | @RequestMapping("/api/UserTv") | ||
30 | public class UserTvController { | ||
31 | |||
32 | @Autowired | ||
33 | private UserTvService UserTvService; | ||
34 | |||
35 | @GetMapping | ||
36 | @ApiOperation("查询UserTv") | ||
37 | public ResultInfo getUserTvs(UserTvQueryCriteria criteria, Pageable pageable) { | ||
38 | return ResultInfo.successPage(UserTvService.queryAll(criteria,pageable)); | ||
39 | } | ||
40 | |||
41 | @GetMapping(value = "/all") | ||
42 | @ApiOperation("查询所有UserTv") | ||
43 | public ResultInfo getUserTvs(UserTvQueryCriteria criteria) { | ||
44 | return ResultInfo.success(UserTvService.queryAll(criteria)); | ||
45 | } | ||
46 | |||
47 | @Log | ||
48 | @PostMapping | ||
49 | @ApiOperation("新增UserTv") | ||
50 | public ResultInfo create(@Validated @RequestBody UserTv resources) { | ||
51 | UserTvService.create(resources); | ||
52 | return ResultInfo.success(); | ||
53 | } | ||
54 | |||
55 | @Log | ||
56 | @PutMapping | ||
57 | @ApiOperation("修改UserTv") | ||
58 | public ResultInfo update(@Validated @RequestBody UserTv resources) { | ||
59 | UserTvService.update(resources); | ||
60 | return ResultInfo.success(); | ||
61 | } | ||
62 | |||
63 | @Log | ||
64 | @DeleteMapping(value = "/{id}") | ||
65 | @ApiOperation("删除UserTv") | ||
66 | public ResultInfo delete(@PathVariable Long id) { | ||
67 | UserTvService.delete(id); | ||
68 | return ResultInfo.success(); | ||
69 | } | ||
70 | |||
71 | } |
1 | package com.topdraw.business.basicdata.user.iptv.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
4 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
5 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria; | ||
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-12-16 | ||
15 | */ | ||
16 | public interface UserTvService { | ||
17 | |||
18 | /** | ||
19 | * 查询数据分页 | ||
20 | * @param criteria 条件参数 | ||
21 | * @param pageable 分页参数 | ||
22 | * @return Map<String,Object> | ||
23 | */ | ||
24 | Map<String,Object> queryAll(UserTvQueryCriteria criteria, Pageable pageable); | ||
25 | |||
26 | /** | ||
27 | * 查询所有数据不分页 | ||
28 | * @param criteria 条件参数 | ||
29 | * @return List<UserTvDTO> | ||
30 | */ | ||
31 | List<UserTvDTO> queryAll(UserTvQueryCriteria criteria); | ||
32 | |||
33 | /** | ||
34 | * 根据ID查询 | ||
35 | * @param id ID | ||
36 | * @return UserTvDTO | ||
37 | */ | ||
38 | UserTvDTO findById(Long id); | ||
39 | |||
40 | Long create(UserTv resources); | ||
41 | |||
42 | void update(UserTv resources); | ||
43 | |||
44 | void delete(Long id); | ||
45 | |||
46 | UserTvDTO findByPlatformAccount(String platformAccount); | ||
47 | |||
48 | |||
49 | } |
1 | package com.topdraw.business.basicdata.user.iptv.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-12-16 | ||
11 | */ | ||
12 | @Data | ||
13 | public class UserTvDTO implements Serializable { | ||
14 | |||
15 | // ID | ||
16 | private Long id; | ||
17 | |||
18 | // 人ID | ||
19 | private Long personId; | ||
20 | |||
21 | // 运营商平台 | ||
22 | private String platform; | ||
23 | |||
24 | // 运营商平台账号 | ||
25 | private String platformAccount; | ||
26 | |||
27 | // 手机号 | ||
28 | private String cellphone; | ||
29 | |||
30 | // 用户名 | ||
31 | private String username; | ||
32 | |||
33 | // 密码 MD5 | ||
34 | private String password; | ||
35 | |||
36 | // 昵称 Base64 | ||
37 | private String nickname; | ||
38 | |||
39 | // 头像 | ||
40 | private String image; | ||
41 | |||
42 | // 登录天数(总天数) | ||
43 | private Integer loginDays; | ||
44 | |||
45 | // 连续登录天数 | ||
46 | private Integer continueDays; | ||
47 | |||
48 | // 活跃时间 | ||
49 | private Timestamp activeTime; | ||
50 | |||
51 | // 分组 分组ID用逗号分隔 | ||
52 | private String groups; | ||
53 | |||
54 | // 标签 标签用逗号分隔 | ||
55 | private String tags; | ||
56 | |||
57 | // 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 | ||
58 | private Integer loginType; | ||
59 | |||
60 | // 状态 0-下线 1-上线 | ||
61 | private Integer status; | ||
62 | |||
63 | // 描述 | ||
64 | private String description; | ||
65 | |||
66 | // 创建者 | ||
67 | private String createBy; | ||
68 | |||
69 | // 创建时间 | ||
70 | private Timestamp createTime; | ||
71 | |||
72 | // 更新者 | ||
73 | private String updateBy; | ||
74 | |||
75 | // 更新时间 | ||
76 | private Timestamp updateTime; | ||
77 | |||
78 | // 会员id | ||
79 | private Long memberId; | ||
80 | } | ||
81 | |||
82 |
1 | package com.topdraw.business.basicdata.user.iptv.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.member.domain.Member; | ||
5 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
6 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
7 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
8 | import com.topdraw.config.LocalConstants; | ||
9 | import com.topdraw.util.IdWorker; | ||
10 | import com.topdraw.util.RedissonUtil; | ||
11 | import com.topdraw.util.TimestampUtil; | ||
12 | import com.topdraw.utils.StringUtils; | ||
13 | import com.topdraw.utils.ValidationUtil; | ||
14 | import com.topdraw.business.basicdata.user.iptv.repository.UserTvRepository; | ||
15 | import com.topdraw.business.basicdata.user.iptv.service.UserTvService; | ||
16 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
17 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria; | ||
18 | import com.topdraw.business.basicdata.user.iptv.service.mapper.UserTvMapper; | ||
19 | import org.redisson.api.RLock; | ||
20 | import org.redisson.api.RedissonClient; | ||
21 | import org.springframework.beans.BeanUtils; | ||
22 | import org.springframework.beans.factory.annotation.Autowired; | ||
23 | import org.springframework.stereotype.Service; | ||
24 | import org.springframework.transaction.annotation.Propagation; | ||
25 | import org.springframework.transaction.annotation.Transactional; | ||
26 | import org.springframework.dao.EmptyResultDataAccessException; | ||
27 | import org.springframework.data.domain.Page; | ||
28 | import org.springframework.data.domain.Pageable; | ||
29 | import org.springframework.util.Assert; | ||
30 | import com.topdraw.utils.PageUtil; | ||
31 | import com.topdraw.utils.QueryHelp; | ||
32 | |||
33 | import java.util.List; | ||
34 | import java.util.Map; | ||
35 | import java.util.Objects; | ||
36 | import java.util.Optional; | ||
37 | |||
38 | /** | ||
39 | * @author XiangHan | ||
40 | * @date 2021-12-16 | ||
41 | */ | ||
42 | @Service | ||
43 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
44 | public class UserTvServiceImpl implements UserTvService { | ||
45 | |||
46 | @Autowired | ||
47 | private UserTvRepository UserTvRepository; | ||
48 | |||
49 | @Autowired | ||
50 | private UserTvMapper UserTvMapper; | ||
51 | |||
52 | @Autowired | ||
53 | private MemberService memberService; | ||
54 | |||
55 | @Override | ||
56 | public Map<String, Object> queryAll(UserTvQueryCriteria criteria, Pageable pageable) { | ||
57 | Page<UserTv> page = UserTvRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
58 | return PageUtil.toPage(page.map(UserTvMapper::toDto)); | ||
59 | } | ||
60 | |||
61 | @Override | ||
62 | public List<UserTvDTO> queryAll(UserTvQueryCriteria criteria) { | ||
63 | return UserTvMapper.toDto(UserTvRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
64 | } | ||
65 | |||
66 | @Override | ||
67 | public UserTvDTO findById(Long id) { | ||
68 | UserTv UserTv = UserTvRepository.findById(id).orElseGet(UserTv::new); | ||
69 | ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id); | ||
70 | return UserTvMapper.toDto(UserTv); | ||
71 | } | ||
72 | |||
73 | @Override | ||
74 | @Transactional(rollbackFor = Exception.class) | ||
75 | @AsyncMqSend | ||
76 | public Long create(UserTv resources) { | ||
77 | MemberDTO memberDTO = memberService.getByCode(resources.getMemberCode()); | ||
78 | if (Objects.nonNull(memberDTO)) { | ||
79 | Long id = memberDTO.getId(); | ||
80 | resources.setMemberId(id); | ||
81 | UserTvRepository.save(resources); | ||
82 | return resources.getId(); | ||
83 | } | ||
84 | return null; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | @Transactional(rollbackFor = Exception.class) | ||
89 | @AsyncMqSend | ||
90 | public void update(UserTv resources) { | ||
91 | UserTv UserTv = UserTvRepository.findById(resources.getId()).orElseGet(UserTv::new); | ||
92 | ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); | ||
93 | UserTv.copy(resources); | ||
94 | UserTvRepository.save(UserTv); | ||
95 | } | ||
96 | |||
97 | @Override | ||
98 | @Transactional(rollbackFor = Exception.class) | ||
99 | @AsyncMqSend | ||
100 | public void delete(Long id) { | ||
101 | Assert.notNull(id, "The given id must not be null!"); | ||
102 | UserTv UserTv = UserTvRepository.findById(id).orElseThrow( | ||
103 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserTv.class, id), 1)); | ||
104 | UserTvRepository.delete(UserTv); | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public UserTvDTO findByPlatformAccount(String platformAccount) { | ||
109 | Optional<UserTv> userTv = UserTvRepository.findByPlatformAccount(platformAccount); | ||
110 | if (userTv.isPresent()) { | ||
111 | ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId()); | ||
112 | return UserTvMapper.toDto(userTv.get()); | ||
113 | } | ||
114 | return null; | ||
115 | } | ||
116 | |||
117 | |||
118 | } |
1 | package com.topdraw.business.basicdata.user.iptv.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
5 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-12-16 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface UserTvMapper extends BaseMapper<UserTvDTO, UserTv> { | ||
15 | |||
16 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/user/weixin/domain/UserWeixin.java
0 → 100644
1 | package com.topdraw.business.basicdata.user.weixin.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-12-16 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_user_weixin") | ||
24 | public class UserWeixin implements Serializable { | ||
25 | |||
26 | // ID | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 用户ID | ||
33 | @Column(name = "member_id") | ||
34 | private Long memberId; | ||
35 | |||
36 | // 微信unionid,针对开发者 | ||
37 | @Column(name = "unionid") | ||
38 | private String unionid; | ||
39 | |||
40 | // 微信appid | ||
41 | @Column(name = "appid") | ||
42 | private String appid; | ||
43 | |||
44 | // 微信openid,针对微信app | ||
45 | @Column(name = "openid") | ||
46 | private String openid; | ||
47 | |||
48 | // 关注状态 0 -未关注 1 - 已关注 | ||
49 | @Column(name = "status") | ||
50 | private Integer status; | ||
51 | |||
52 | // 关注同步状态 0-未同步,1-已同步 | ||
53 | @Column(name = "sync_status") | ||
54 | private Integer syncStatus; | ||
55 | |||
56 | // 昵称 | ||
57 | @Column(name = "nickname") | ||
58 | private String nickname; | ||
59 | |||
60 | // 头像地址 | ||
61 | @Column(name = "headimgurl") | ||
62 | private String headimgurl; | ||
63 | |||
64 | // 特权信息 | ||
65 | @Column(name = "privilege") | ||
66 | private String privilege; | ||
67 | |||
68 | // 刷新凭据 | ||
69 | @Column(name = "refresh_token") | ||
70 | private String refreshToken; | ||
71 | |||
72 | // 凭据 | ||
73 | @Column(name = "access_token") | ||
74 | private String accessToken; | ||
75 | |||
76 | // 超时(秒) | ||
77 | @Column(name = "expires_in") | ||
78 | private Integer expiresIn; | ||
79 | |||
80 | // 超时时间 | ||
81 | @Column(name = "expires_time") | ||
82 | private Timestamp expiresTime; | ||
83 | |||
84 | // 描述 | ||
85 | @Column(name = "description") | ||
86 | private String description; | ||
87 | |||
88 | // 创建者 | ||
89 | @Column(name = "create_by") | ||
90 | private String createBy; | ||
91 | |||
92 | // 创建时间 | ||
93 | @CreatedDate | ||
94 | @Column(name = "create_time") | ||
95 | private Timestamp createTime; | ||
96 | |||
97 | // 更新者 | ||
98 | @Column(name = "update_by") | ||
99 | private String updateBy; | ||
100 | |||
101 | // 更新时间 | ||
102 | @LastModifiedDate | ||
103 | @Column(name = "update_time") | ||
104 | private Timestamp updateTime; | ||
105 | |||
106 | // 来源类型 | ||
107 | @Column(name = "source_type") | ||
108 | private String sourceType; | ||
109 | |||
110 | // 来源id | ||
111 | @Column(name = "source_id") | ||
112 | private String sourceId; | ||
113 | |||
114 | // 来源id | ||
115 | @Column(name = "source_desc") | ||
116 | private String sourceDesc; | ||
117 | |||
118 | // 人id | ||
119 | @Column(name = "person_id") | ||
120 | private Long personId; | ||
121 | |||
122 | // 来源用户id | ||
123 | @Column(name = "source_user") | ||
124 | private Long sourceUser; | ||
125 | |||
126 | // 来源实体:活动-activity/商品-item | ||
127 | @Column(name = "source_entity") | ||
128 | private String sourceEntity; | ||
129 | |||
130 | // 授权时间 | ||
131 | @Column(name = "auth_time") | ||
132 | private Timestamp authTime; | ||
133 | |||
134 | @Column(name = "sex") | ||
135 | private Integer sex; | ||
136 | |||
137 | @Column(name = "country") | ||
138 | private String country; | ||
139 | |||
140 | @Column(name = "province") | ||
141 | private String province; | ||
142 | |||
143 | @Column(name = "city") | ||
144 | private String city; | ||
145 | |||
146 | public void copy(UserWeixin source){ | ||
147 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
148 | } | ||
149 | } |
1 | package com.topdraw.business.basicdata.user.weixin.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; | ||
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-12-16 | ||
12 | */ | ||
13 | public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, JpaSpecificationExecutor<UserWeixin> { | ||
14 | |||
15 | } |
1 | package com.topdraw.business.basicdata.user.weixin.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; | ||
6 | import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService; | ||
7 | import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria; | ||
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-12-16 | ||
21 | */ | ||
22 | @Api(tags = "UserWeixin管理") | ||
23 | @RestController | ||
24 | @RequestMapping("/api/UserWeixin") | ||
25 | public class UserWeixinController { | ||
26 | |||
27 | @Autowired | ||
28 | private UserWeixinService UserWeixinService; | ||
29 | |||
30 | @GetMapping | ||
31 | @ApiOperation("查询UserWeixin") | ||
32 | public ResultInfo getUserWeixins(UserWeixinQueryCriteria criteria, Pageable pageable) { | ||
33 | return ResultInfo.successPage(UserWeixinService.queryAll(criteria,pageable)); | ||
34 | } | ||
35 | |||
36 | @GetMapping(value = "/all") | ||
37 | @ApiOperation("查询所有UserWeixin") | ||
38 | public ResultInfo getUserWeixins(UserWeixinQueryCriteria criteria) { | ||
39 | return ResultInfo.success(UserWeixinService.queryAll(criteria)); | ||
40 | } | ||
41 | |||
42 | @Log | ||
43 | @PostMapping | ||
44 | @ApiOperation("新增UserWeixin") | ||
45 | public ResultInfo create(@Validated @RequestBody UserWeixin resources) { | ||
46 | UserWeixinService.create(resources); | ||
47 | return ResultInfo.success(); | ||
48 | } | ||
49 | |||
50 | @Log | ||
51 | @PutMapping | ||
52 | @ApiOperation("修改UserWeixin") | ||
53 | public ResultInfo update(@Validated @RequestBody UserWeixin resources) { | ||
54 | UserWeixinService.update(resources); | ||
55 | return ResultInfo.success(); | ||
56 | } | ||
57 | |||
58 | |||
59 | @Log | ||
60 | @DeleteMapping(value = "/{id}") | ||
61 | @ApiOperation("删除UserWeixin") | ||
62 | public ResultInfo delete(@PathVariable Long id) { | ||
63 | UserWeixinService.delete(id); | ||
64 | return ResultInfo.success(); | ||
65 | } | ||
66 | |||
67 | } |
1 | package com.topdraw.business.basicdata.user.weixin.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; | ||
4 | import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO; | ||
5 | import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria; | ||
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-12-16 | ||
15 | */ | ||
16 | public interface UserWeixinService { | ||
17 | |||
18 | /** | ||
19 | * 查询数据分页 | ||
20 | * @param criteria 条件参数 | ||
21 | * @param pageable 分页参数 | ||
22 | * @return Map<String,Object> | ||
23 | */ | ||
24 | Map<String,Object> queryAll(UserWeixinQueryCriteria criteria, Pageable pageable); | ||
25 | |||
26 | /** | ||
27 | * 查询所有数据不分页 | ||
28 | * @param criteria 条件参数 | ||
29 | * @return List<UserWeixinDTO> | ||
30 | */ | ||
31 | List<UserWeixinDTO> queryAll(UserWeixinQueryCriteria criteria); | ||
32 | |||
33 | /** | ||
34 | * 根据ID查询 | ||
35 | * @param id ID | ||
36 | * @return UserWeixinDTO | ||
37 | */ | ||
38 | UserWeixinDTO findById(Long id); | ||
39 | |||
40 | void create(UserWeixin resources); | ||
41 | |||
42 | void update(UserWeixin resources); | ||
43 | |||
44 | void delete(Long id); | ||
45 | |||
46 | } |
1 | package com.topdraw.business.basicdata.user.weixin.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-12-16 | ||
11 | */ | ||
12 | @Data | ||
13 | public class UserWeixinDTO implements Serializable { | ||
14 | |||
15 | // ID | ||
16 | private Long id; | ||
17 | |||
18 | // 用户ID | ||
19 | private Long memberId; | ||
20 | |||
21 | // 微信unionid,针对开发者 | ||
22 | private String unionid; | ||
23 | |||
24 | // 微信appid | ||
25 | private String appid; | ||
26 | |||
27 | // 微信openid,针对微信app | ||
28 | private String openid; | ||
29 | |||
30 | // 关注状态 0 -未关注 1 - 已关注 | ||
31 | private Integer status; | ||
32 | |||
33 | // 关注同步状态 0-未同步,1-已同步 | ||
34 | private Integer syncStatus; | ||
35 | |||
36 | // 昵称 | ||
37 | private String nickname; | ||
38 | |||
39 | // 头像地址 | ||
40 | private String headimgurl; | ||
41 | |||
42 | // 特权信息 | ||
43 | private String privilege; | ||
44 | |||
45 | // 刷新凭据 | ||
46 | private String refreshToken; | ||
47 | |||
48 | // 凭据 | ||
49 | private String accessToken; | ||
50 | |||
51 | // 超时(秒) | ||
52 | private Integer expiresIn; | ||
53 | |||
54 | // 超时时间 | ||
55 | private Timestamp expiresTime; | ||
56 | |||
57 | // 描述 | ||
58 | private String description; | ||
59 | |||
60 | // 创建者 | ||
61 | private String createBy; | ||
62 | |||
63 | // 创建时间 | ||
64 | private Timestamp createTime; | ||
65 | |||
66 | // 更新者 | ||
67 | private String updateBy; | ||
68 | |||
69 | // 更新时间 | ||
70 | private Timestamp updateTime; | ||
71 | |||
72 | // 来源类型 | ||
73 | private String sourceType; | ||
74 | |||
75 | // 来源id | ||
76 | private String sourceId; | ||
77 | |||
78 | // 来源id | ||
79 | private String sourceDesc; | ||
80 | |||
81 | // 人id | ||
82 | private Long personId; | ||
83 | |||
84 | // 来源用户id | ||
85 | private Long sourceUser; | ||
86 | |||
87 | // 来源实体:活动-activity/商品-item | ||
88 | private String sourceEntity; | ||
89 | |||
90 | // 授权时间 | ||
91 | private Timestamp authTime; | ||
92 | |||
93 | private Integer sex; | ||
94 | |||
95 | private String country; | ||
96 | |||
97 | private String province; | ||
98 | |||
99 | private String city; | ||
100 | } |
1 | package com.topdraw.business.basicdata.user.weixin.service.impl; | ||
2 | |||
3 | import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; | ||
4 | import com.topdraw.utils.ValidationUtil; | ||
5 | import com.topdraw.utils.FileUtil; | ||
6 | import com.topdraw.business.basicdata.user.weixin.repository.UserWeixinRepository; | ||
7 | import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService; | ||
8 | import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO; | ||
9 | import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.user.weixin.service.mapper.UserWeixinMapper; | ||
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-12-16 | ||
33 | */ | ||
34 | @Service | ||
35 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
36 | public class UserWeixinServiceImpl implements UserWeixinService { | ||
37 | |||
38 | @Autowired | ||
39 | private UserWeixinRepository UserWeixinRepository; | ||
40 | |||
41 | @Autowired | ||
42 | private UserWeixinMapper UserWeixinMapper; | ||
43 | |||
44 | @Override | ||
45 | public Map<String, Object> queryAll(UserWeixinQueryCriteria criteria, Pageable pageable) { | ||
46 | Page<UserWeixin> page = UserWeixinRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
47 | return PageUtil.toPage(page.map(UserWeixinMapper::toDto)); | ||
48 | } | ||
49 | |||
50 | @Override | ||
51 | public List<UserWeixinDTO> queryAll(UserWeixinQueryCriteria criteria) { | ||
52 | return UserWeixinMapper.toDto(UserWeixinRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
53 | } | ||
54 | |||
55 | @Override | ||
56 | public UserWeixinDTO findById(Long id) { | ||
57 | UserWeixin UserWeixin = UserWeixinRepository.findById(id).orElseGet(UserWeixin::new); | ||
58 | ValidationUtil.isNull(UserWeixin.getId(),"UserWeixin","id",id); | ||
59 | return UserWeixinMapper.toDto(UserWeixin); | ||
60 | } | ||
61 | |||
62 | @Override | ||
63 | @Transactional(rollbackFor = Exception.class) | ||
64 | public void create(UserWeixin resources) { | ||
65 | UserWeixinRepository.save(resources); | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | @Transactional(rollbackFor = Exception.class) | ||
70 | public void update(UserWeixin resources) { | ||
71 | UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new); | ||
72 | ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); | ||
73 | UserWeixin.copy(resources); | ||
74 | UserWeixinRepository.save(UserWeixin); | ||
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 | UserWeixin UserWeixin = UserWeixinRepository.findById(id).orElseThrow( | ||
82 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserWeixin.class, id), 1)); | ||
83 | UserWeixinRepository.delete(UserWeixin); | ||
84 | } | ||
85 | |||
86 | |||
87 | } |
1 | package com.topdraw.business.basicdata.user.weixin.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; | ||
5 | import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-12-16 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface UserWeixinMapper extends BaseMapper<UserWeixinDTO, UserWeixin> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.process.domian; | ||
2 | |||
3 | import lombok.AllArgsConstructor; | ||
4 | import lombok.Data; | ||
5 | import lombok.NoArgsConstructor; | ||
6 | |||
7 | import javax.persistence.Transient; | ||
8 | |||
9 | @Data | ||
10 | @AllArgsConstructor | ||
11 | @NoArgsConstructor | ||
12 | public class TempIptvUser { | ||
13 | |||
14 | // 账户 | ||
15 | @Transient | ||
16 | private String platformAccount; | ||
17 | |||
18 | // 分数 | ||
19 | @Transient | ||
20 | private Long points; | ||
21 | |||
22 | |||
23 | |||
24 | } |
... | @@ -24,7 +24,6 @@ public class TempPoints extends TempRights { | ... | @@ -24,7 +24,6 @@ public class TempPoints extends TempRights { |
24 | 24 | ||
25 | // 积分类型 0:通用 | 25 | // 积分类型 0:通用 |
26 | @Transient | 26 | @Transient |
27 | @NotNull(message = "【pointsType】积分类型不得为空!!") | ||
28 | protected Integer pointsType; | 27 | protected Integer pointsType; |
29 | 28 | ||
30 | @Transient | 29 | @Transient | ... | ... |
... | @@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; | ... | @@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; |
7 | import javax.persistence.Transient; | 7 | import javax.persistence.Transient; |
8 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
9 | import java.sql.Timestamp; | 9 | import java.sql.Timestamp; |
10 | import java.time.LocalDateTime; | ||
10 | 11 | ||
11 | /** | 12 | /** |
12 | * 权益-非持久化数据 | 13 | * 权益-非持久化数据 |
... | @@ -30,9 +31,12 @@ public class TempRights { | ... | @@ -30,9 +31,12 @@ public class TempRights { |
30 | 31 | ||
31 | /** 会员ID */ | 32 | /** 会员ID */ |
32 | @Transient | 33 | @Transient |
33 | @NotNull(message = "") | ||
34 | protected Long memberId; | 34 | protected Long memberId; |
35 | 35 | ||
36 | /** 会员编号 */ | ||
37 | @Transient | ||
38 | protected String memberCode; | ||
39 | |||
36 | /** 账号id */ | 40 | /** 账号id */ |
37 | @Transient | 41 | @Transient |
38 | protected Long userId; | 42 | protected Long userId; |
... | @@ -43,21 +47,20 @@ public class TempRights { | ... | @@ -43,21 +47,20 @@ public class TempRights { |
43 | 47 | ||
44 | /** 账号id */ | 48 | /** 账号id */ |
45 | @Transient | 49 | @Transient |
46 | private Long accountId; | 50 | protected Long accountId; |
47 | 51 | ||
48 | /** 过期时间 */ | 52 | /** 过期时间 */ |
49 | @Transient | 53 | @Transient |
50 | protected Timestamp expireTime; | 54 | protected LocalDateTime expireTime; |
51 | 55 | ||
52 | 56 | ||
53 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ | 57 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ |
54 | @Transient | 58 | @Transient |
55 | @NotNull(message = "") | 59 | @NotNull(message = "设备类型不得为空") |
56 | protected Integer deviceType; | 60 | protected Integer deviceType; |
57 | 61 | ||
58 | /** 应用code(表示当前用户对应应用的标识) */ | 62 | /** 应用code(表示当前用户对应应用的标识) */ |
59 | @Transient | 63 | @Transient |
60 | // @NotNull | ||
61 | protected String appCode; | 64 | protected String appCode; |
62 | 65 | ||
63 | /** 订单id */ | 66 | /** 订单id */ | ... | ... |
1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
2 | 2 | ||
3 | import com.topdraw.annotation.Log; | 3 | import com.topdraw.annotation.Log; |
4 | import com.topdraw.business.basicdata.member.domain.Member; | ||
5 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
6 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
4 | import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; | 7 | import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; |
5 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; | 8 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; |
6 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryType; | 9 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryType; |
7 | import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; | 10 | import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; |
8 | import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria; | 11 | import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria; |
12 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
13 | import com.topdraw.business.basicdata.user.iptv.service.UserTvService; | ||
14 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
15 | import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService; | ||
16 | import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO; | ||
17 | import com.topdraw.business.process.domian.TempIptvUser; | ||
9 | import com.topdraw.business.process.domian.TempPoints; | 18 | import com.topdraw.business.process.domian.TempPoints; |
19 | import com.topdraw.business.process.domian.result.CustomPointsResult; | ||
10 | import com.topdraw.business.process.service.PointsOperationService; | 20 | import com.topdraw.business.process.service.PointsOperationService; |
21 | import com.topdraw.business.process.service.UserTvOperationService; | ||
22 | import com.topdraw.common.ResultCode; | ||
11 | import com.topdraw.common.ResultInfo; | 23 | import com.topdraw.common.ResultInfo; |
24 | import com.topdraw.config.LocalConstants; | ||
12 | import com.topdraw.util.TimestampUtil; | 25 | import com.topdraw.util.TimestampUtil; |
13 | import io.swagger.annotations.Api; | 26 | import io.swagger.annotations.Api; |
14 | import io.swagger.annotations.ApiOperation; | 27 | import io.swagger.annotations.ApiOperation; |
28 | import lombok.Data; | ||
29 | import org.redisson.api.RedissonClient; | ||
15 | import org.slf4j.Logger; | 30 | import org.slf4j.Logger; |
16 | import org.slf4j.LoggerFactory; | 31 | import org.slf4j.LoggerFactory; |
17 | import org.springframework.beans.factory.annotation.Autowired; | 32 | import org.springframework.beans.factory.annotation.Autowired; |
... | @@ -21,6 +36,7 @@ import org.springframework.util.CollectionUtils; | ... | @@ -21,6 +36,7 @@ import org.springframework.util.CollectionUtils; |
21 | import org.springframework.validation.annotation.Validated; | 36 | import org.springframework.validation.annotation.Validated; |
22 | import org.springframework.web.bind.annotation.*; | 37 | import org.springframework.web.bind.annotation.*; |
23 | 38 | ||
39 | import java.util.Arrays; | ||
24 | import java.util.List; | 40 | import java.util.List; |
25 | import java.util.Objects; | 41 | import java.util.Objects; |
26 | 42 | ||
... | @@ -30,7 +46,7 @@ import java.util.Objects; | ... | @@ -30,7 +46,7 @@ import java.util.Objects; |
30 | */ | 46 | */ |
31 | @Api(tags = "PointsOperation管理") | 47 | @Api(tags = "PointsOperation管理") |
32 | @RestController | 48 | @RestController |
33 | @RequestMapping("/api/PointsOperation") | 49 | @RequestMapping("/api/pointsOperation") |
34 | public class PointsOperationController { | 50 | public class PointsOperationController { |
35 | 51 | ||
36 | private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class); | 52 | private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class); |
... | @@ -41,6 +57,13 @@ public class PointsOperationController { | ... | @@ -41,6 +57,13 @@ public class PointsOperationController { |
41 | PointsDetailService pointsDetailService; | 57 | PointsDetailService pointsDetailService; |
42 | @Autowired | 58 | @Autowired |
43 | PointsAvailableService pointsAvailableService; | 59 | PointsAvailableService pointsAvailableService; |
60 | @Autowired | ||
61 | UserTvService userTvService; | ||
62 | @Autowired | ||
63 | UserWeixinService userWeixinService; | ||
64 | @Autowired | ||
65 | MemberService memberService; | ||
66 | |||
44 | 67 | ||
45 | @GetMapping(value = "/pagePointsDetails") | 68 | @GetMapping(value = "/pagePointsDetails") |
46 | @ApiOperation("查询PointsDetail") | 69 | @ApiOperation("查询PointsDetail") |
... | @@ -67,32 +90,116 @@ public class PointsOperationController { | ... | @@ -67,32 +90,116 @@ public class PointsOperationController { |
67 | return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); | 90 | return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); |
68 | } | 91 | } |
69 | 92 | ||
70 | /*@Log | ||
71 | @PostMapping(value = "/cleanInvalidPointsAndCalculateCurrentPointsByMemberIds") | ||
72 | @ApiOperation("清除过期积分并计算总积分,管理端使用") | ||
73 | public ResultInfo cleanInvalidPointsAndCalculateCurrentPointsByMemberIds(List<Long> memberIds) { | ||
74 | if (!CollectionUtils.isEmpty(memberIds)) { | ||
75 | for (Long memberId : memberIds) { | ||
76 | this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(memberId); | ||
77 | } | ||
78 | } | ||
79 | return ResultInfo.success(); | ||
80 | }*/ | ||
81 | |||
82 | @Log | 93 | @Log |
83 | @PostMapping(value = "/grantPointsByManual") | 94 | @PostMapping(value = "/grantPointsByManual") |
84 | @ApiOperation("新增PointsDetail") | 95 | @ApiOperation("手动发放积分") |
85 | public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) { | 96 | public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) { |
86 | Long memberId = tempPoints.getMemberId(); | 97 | Long memberId = tempPoints.getMemberId(); |
87 | this.pointsOperationService.grantPointsByManual(memberId,tempPoints); | 98 | Long points = tempPoints.getPoints(); |
99 | Assert.notNull(memberId,"memberId can't be null!"); | ||
100 | Assert.notNull(points,"points can't be null!"); | ||
101 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
102 | if (Objects.nonNull(memberDTO)) { | ||
103 | String code = memberDTO.getCode(); | ||
104 | Assert.notNull(code,"code can't be null!"); | ||
105 | tempPoints.setMemberCode(code); | ||
106 | this.pointsOperationService.grantPointsByManualByTempPoints(tempPoints); | ||
107 | } | ||
88 | return ResultInfo.success(); | 108 | return ResultInfo.success(); |
89 | } | 109 | } |
90 | 110 | ||
111 | /** | ||
112 | * 通过用户账户id消耗积分 | ||
113 | * @param tempIptvUser | ||
114 | * @return | ||
115 | */ | ||
116 | @Log | ||
117 | @PostMapping(value = "/customPointsByUserTvPlatformAccount") | ||
118 | @ApiOperation("通过大屏账户积分消耗") | ||
119 | public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempIptvUser tempIptvUser) { | ||
120 | String platformAccount = tempIptvUser.getPlatformAccount(); | ||
121 | Long points = tempIptvUser.getPoints(); | ||
122 | |||
123 | TempPoints tempPoints = new TempPoints(); | ||
124 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
125 | if (Objects.nonNull(userTvDTO)) { | ||
126 | Long memberId = userTvDTO.getMemberId(); | ||
127 | if (Objects.isNull(memberId)) { | ||
128 | return ResultInfo.failed("会员信息不存在"); | ||
129 | } | ||
130 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
131 | tempPoints.setMemberCode(memberDTO.getCode()); | ||
132 | tempPoints.setMemberId(memberId); | ||
133 | } | ||
134 | tempPoints.setPoints(points); | ||
135 | tempPoints.setDeviceType(LocalConstants.DEVICE_VIS); | ||
136 | tempPoints.setAppCode(LocalConstants.APP_CODE_CHONGQING_CHONGSHU_VIS); | ||
137 | tempPoints.setEvtType(LocalConstants.EVT_TYPE_ACTIVITY); | ||
138 | return this.customPoints(tempPoints); | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * 通过用户账户id消耗积分 | ||
143 | * @param tempPoints | ||
144 | * @return | ||
145 | */ | ||
146 | @Log | ||
147 | @PostMapping(value = "/customPointsByUserId") | ||
148 | @ApiOperation("积分消耗") | ||
149 | public ResultInfo customPointsByUserId(@Validated @RequestBody TempPoints tempPoints) { | ||
150 | Long userId = tempPoints.getUserId(); | ||
151 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | ||
152 | Integer deviceType = tempPoints.getDeviceType(); | ||
153 | Long memberId = null; | ||
154 | if (deviceType == LocalConstants.DEVICE_VIS) { | ||
155 | memberId = this.getMemberIdByIpTvUserId(userId); | ||
156 | } | ||
157 | if (deviceType == LocalConstants.DEVICE_MOBILE) { | ||
158 | memberId = this.getMemberIdByWeiXinUserId(userId); | ||
159 | } | ||
160 | if (Objects.isNull(memberId)) { | ||
161 | return ResultInfo.failed("会员信息不存在"); | ||
162 | } | ||
163 | tempPoints.setMemberId(memberId); | ||
164 | return this.customPoints(tempPoints); | ||
165 | } | ||
166 | |||
167 | /** | ||
168 | * 获取iptv账户对应的会员id | ||
169 | * @param userId | ||
170 | * @return | ||
171 | */ | ||
172 | private Long getMemberIdByIpTvUserId(Long userId) { | ||
173 | UserTvDTO userTvDTO = this.userTvService.findById(userId); | ||
174 | return userTvDTO.getMemberId(); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * 获取微信账户对应的会员id | ||
179 | * @param userId | ||
180 | * @return | ||
181 | */ | ||
182 | private Long getMemberIdByWeiXinUserId(Long userId) { | ||
183 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(userId); | ||
184 | return userWeixinDTO.getMemberId(); | ||
185 | } | ||
186 | |||
91 | @Log | 187 | @Log |
92 | @PostMapping(value = "/consumePoints") | 188 | @PostMapping(value = "/consumePoints") |
93 | @ApiOperation("积分消耗") | 189 | @ApiOperation("积分消耗") |
94 | public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) { | 190 | public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) { |
95 | this.pointsOperationService.customPoints(tempPoints); | 191 | Integer pointsType = tempPoints.getPointsType(); |
96 | return ResultInfo.success(); | 192 | if (Objects.isNull(pointsType)) { |
193 | tempPoints.setPointsType(0); | ||
194 | } | ||
195 | CustomPointsResult b = this.pointsOperationService.customPoints(tempPoints); | ||
196 | String description = "操作成功"; | ||
197 | if (!b.isResult()) { | ||
198 | description = "操作失败,积分不足"; | ||
97 | } | 199 | } |
200 | return ResultInfo.success(Arrays.asList(b),description); | ||
201 | } | ||
202 | |||
203 | |||
204 | |||
98 | } | 205 | } | ... | ... |
... | @@ -6,9 +6,6 @@ import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQu | ... | @@ -6,9 +6,6 @@ import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQu |
6 | import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryType; | 6 | import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryType; |
7 | import com.topdraw.business.process.service.RightsOperationService; | 7 | import com.topdraw.business.process.service.RightsOperationService; |
8 | import com.topdraw.common.ResultInfo; | 8 | import com.topdraw.common.ResultInfo; |
9 | import com.topdraw.annotation.Log; | ||
10 | import com.topdraw.business.basicdata.rights.domain.Rights; | ||
11 | import com.topdraw.business.basicdata.rights.service.RightsService; | ||
12 | import com.topdraw.util.TimestampUtil; | 9 | import com.topdraw.util.TimestampUtil; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.data.domain.Pageable; | 11 | import org.springframework.data.domain.Pageable; |
... | @@ -33,9 +30,13 @@ public class RightsOperationController { | ... | @@ -33,9 +30,13 @@ public class RightsOperationController { |
33 | private RightsOperationService rightsOperationService; | 30 | private RightsOperationService rightsOperationService; |
34 | @Autowired | 31 | @Autowired |
35 | private RightsHistoryService rightsHistoryService; | 32 | private RightsHistoryService rightsHistoryService; |
36 | @Autowired | ||
37 | private RightsService rightsService; | ||
38 | 33 | ||
34 | /** | ||
35 | * | ||
36 | * @param criteria | ||
37 | * @param pageable | ||
38 | * @return | ||
39 | */ | ||
39 | @GetMapping | 40 | @GetMapping |
40 | @ApiOperation("查询RightsHistory") | 41 | @ApiOperation("查询RightsHistory") |
41 | public ResultInfo queryRightsHistory(RightsHistoryQueryCriteria criteria, Pageable pageable) { | 42 | public ResultInfo queryRightsHistory(RightsHistoryQueryCriteria criteria, Pageable pageable) { |
... | @@ -46,13 +47,22 @@ public class RightsOperationController { | ... | @@ -46,13 +47,22 @@ public class RightsOperationController { |
46 | return ResultInfo.successPage(rightsHistoryService.queryAll(criteria,pageable)); | 47 | return ResultInfo.successPage(rightsHistoryService.queryAll(criteria,pageable)); |
47 | } | 48 | } |
48 | 49 | ||
50 | /** | ||
51 | * | ||
52 | * @param id | ||
53 | * @return | ||
54 | */ | ||
49 | @GetMapping(value = "/findRightsHistoryById/{id}") | 55 | @GetMapping(value = "/findRightsHistoryById/{id}") |
50 | @ApiOperation("查询RightsHistory") | 56 | @ApiOperation("查询RightsHistory") |
51 | public ResultInfo findRightsHistoryById(@PathVariable Long id) { | 57 | public ResultInfo findRightsHistoryById(@PathVariable Long id) { |
52 | return ResultInfo.success(rightsHistoryService.findById(id)); | 58 | return ResultInfo.success(rightsHistoryService.findById(id)); |
53 | } | 59 | } |
54 | 60 | ||
55 | 61 | /** | |
62 | * | ||
63 | * @param rightsHistory | ||
64 | * @return | ||
65 | */ | ||
56 | @PostMapping(value = "/grantRightsByManual") | 66 | @PostMapping(value = "/grantRightsByManual") |
57 | @ApiOperation("查询RightsHistory") | 67 | @ApiOperation("查询RightsHistory") |
58 | public ResultInfo grantRightsByManual(@Validated @RequestBody RightsHistory rightsHistory) { | 68 | public ResultInfo grantRightsByManual(@Validated @RequestBody RightsHistory rightsHistory) { | ... | ... |
1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
2 | 2 | ||
3 | import com.topdraw.annotation.Log; | 3 | import com.topdraw.annotation.Log; |
4 | import com.topdraw.business.process.domian.TempIptvUser; | ||
4 | import com.topdraw.business.process.service.TaskOperationService; | 5 | import com.topdraw.business.process.service.TaskOperationService; |
6 | import com.topdraw.common.ResultInfo; | ||
5 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
6 | import io.swagger.annotations.ApiOperation; | 8 | import io.swagger.annotations.ApiOperation; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
8 | import org.springframework.validation.annotation.Validated; | 10 | import org.springframework.validation.annotation.Validated; |
9 | import org.springframework.web.bind.annotation.*; | 11 | import org.springframework.web.bind.annotation.*; |
10 | 12 | ||
13 | import java.util.Arrays; | ||
14 | |||
11 | @Api("任务处理") | 15 | @Api("任务处理") |
12 | @RestController | 16 | @RestController |
13 | @RequestMapping(value = "/api/TaskOperation") | 17 | @RequestMapping(value = "/api/TaskOperation") |
... | @@ -30,6 +34,27 @@ public class TaskOperationController { | ... | @@ -30,6 +34,27 @@ public class TaskOperationController { |
30 | } | 34 | } |
31 | 35 | ||
32 | 36 | ||
37 | |||
38 | /** | ||
39 | * 针对重庆20211220号的积分兑换活动专门定制的接口 | ||
40 | * 1.用户每天首次进入活动详情页的时候赠送5个积分 | ||
41 | * 2.判断任务是否已经做过,没有做过的话,保存任务记录,任务记录通过redis保存即可 | ||
42 | */ | ||
43 | @Log | ||
44 | @PostMapping(value = "/createPoint4ChongQing") | ||
45 | @ApiOperation("针对重庆大屏20211220号的积分兑换活动专门定制的接口") | ||
46 | public ResultInfo createPoint4ChongQing(@RequestBody TempIptvUser tempIptvUser){ | ||
47 | String platformAccount = tempIptvUser.getPlatformAccount(); | ||
48 | Long points = tempIptvUser.getPoints(); | ||
49 | // 判断任务是否已经做过 | ||
50 | boolean result = this.taskOperationService.createPoint2ChongQing(platformAccount,points); | ||
51 | String message = "操作成功"; | ||
52 | if (!result){ | ||
53 | message = "操作失败,该会员今日已参加过活动"; | ||
54 | } | ||
55 | return ResultInfo.success(Arrays.asList(result),message); | ||
56 | } | ||
57 | |||
33 | } | 58 | } |
34 | 59 | ||
35 | 60 | ... | ... |
... | @@ -3,6 +3,7 @@ package com.topdraw.business.process.service; | ... | @@ -3,6 +3,7 @@ package com.topdraw.business.process.service; |
3 | import com.topdraw.business.basicdata.points.domain.Points; | 3 | import com.topdraw.business.basicdata.points.domain.Points; |
4 | import com.topdraw.business.basicdata.task.domain.Task; | 4 | import com.topdraw.business.basicdata.task.domain.Task; |
5 | import com.topdraw.business.process.domian.TempPoints; | 5 | import com.topdraw.business.process.domian.TempPoints; |
6 | import com.topdraw.business.process.domian.result.CustomPointsResult; | ||
6 | 7 | ||
7 | import java.util.List; | 8 | import java.util.List; |
8 | import java.util.Map; | 9 | import java.util.Map; |
... | @@ -21,12 +22,17 @@ public interface PointsOperationService { | ... | @@ -21,12 +22,17 @@ public interface PointsOperationService { |
21 | */ | 22 | */ |
22 | void grantPointsByManual(Long memberId , TempPoints tempPoints); | 23 | void grantPointsByManual(Long memberId , TempPoints tempPoints); |
23 | 24 | ||
25 | /** | ||
26 | * | ||
27 | * @param tempPoints | ||
28 | */ | ||
29 | void grantPointsByManualByTempPoints(TempPoints tempPoints); | ||
24 | 30 | ||
25 | /** | 31 | /** |
26 | * 积分扣减 | 32 | * 积分扣减 |
27 | * @param tempPoints 积分对象 | 33 | * @param tempPoints 积分对象 |
28 | */ | 34 | */ |
29 | boolean customPoints(TempPoints tempPoints); | 35 | CustomPointsResult customPoints(TempPoints tempPoints); |
30 | 36 | ||
31 | 37 | ||
32 | /** | 38 | /** | ... | ... |
1 | package com.topdraw.business.process.service; | 1 | package com.topdraw.business.process.service; |
2 | 2 | ||
3 | import com.topdraw.common.ResultInfo; | 3 | import com.topdraw.common.ResultInfo; |
4 | import com.topdraw.module.mq.DataSyncMsg; | ||
5 | 4 | ||
6 | /** | 5 | /** |
7 | * @description 权益操作接口 | 6 | * @description 权益操作接口 |
... | @@ -18,4 +17,5 @@ public interface TaskOperationService { | ... | @@ -18,4 +17,5 @@ public interface TaskOperationService { |
18 | ResultInfo dealTask(String content); | 17 | ResultInfo dealTask(String content); |
19 | 18 | ||
20 | 19 | ||
20 | boolean createPoint2ChongQing(String platformAccount, Long points); | ||
21 | } | 21 | } | ... | ... |
... | @@ -105,8 +105,11 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -105,8 +105,11 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
105 | private long getExpByMemberId(TempExp tempExp) { | 105 | private long getExpByMemberId(TempExp tempExp) { |
106 | Long memberId = tempExp.getMemberId(); | 106 | Long memberId = tempExp.getMemberId(); |
107 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); | 107 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); |
108 | if (Objects.nonNull(memberDTO)) { | ||
108 | Long exp = memberDTO.getExp(); | 109 | Long exp = memberDTO.getExp(); |
109 | return exp; | 110 | return Objects.isNull(exp) ? 0L : exp; |
111 | } | ||
112 | return 0L; | ||
110 | } | 113 | } |
111 | 114 | ||
112 | 115 | ... | ... |
1 | package com.topdraw.business.process.service.impl; | 1 | package com.topdraw.business.process.service.impl; |
2 | 2 | ||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
3 | import com.topdraw.business.basicdata.member.domain.Member; | 4 | import com.topdraw.business.basicdata.member.domain.Member; |
4 | import com.topdraw.business.basicdata.member.service.MemberService; | 5 | import com.topdraw.business.basicdata.member.service.MemberService; |
5 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | 6 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; |
... | @@ -42,7 +43,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -42,7 +43,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
42 | 43 | ||
43 | @Override | 44 | @Override |
44 | public void doUpdateMemberPoints(Member member) { | 45 | public void doUpdateMemberPoints(Member member) { |
45 | this.doUpdateMemberInfo(member); | 46 | this.memberService.doUpdateMemberPoints(member); |
46 | } | 47 | } |
47 | 48 | ||
48 | @Override | 49 | @Override | ... | ... |
1 | package com.topdraw.business.process.service.impl; | 1 | package com.topdraw.business.process.service.impl; |
2 | 2 | ||
3 | 3 | ||
4 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.member.domain.Member; | 5 | import com.topdraw.business.basicdata.member.domain.Member; |
6 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
7 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
5 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; | 8 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; |
6 | import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; | 9 | import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; |
7 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; | 10 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; |
... | @@ -9,6 +12,9 @@ import com.topdraw.business.basicdata.points.detail.detailhistory.service.Points | ... | @@ -9,6 +12,9 @@ import com.topdraw.business.basicdata.points.detail.detailhistory.service.Points |
9 | import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; | 12 | import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; |
10 | import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; | 13 | import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; |
11 | import com.topdraw.business.basicdata.points.service.PointsService; | 14 | import com.topdraw.business.basicdata.points.service.PointsService; |
15 | import com.topdraw.business.basicdata.user.iptv.service.UserTvService; | ||
16 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
17 | import com.topdraw.business.process.domian.result.CustomPointsResult; | ||
12 | import com.topdraw.business.process.service.MemberOperationService; | 18 | import com.topdraw.business.process.service.MemberOperationService; |
13 | import com.topdraw.business.process.service.PointsOperationService; | 19 | import com.topdraw.business.process.service.PointsOperationService; |
14 | import com.topdraw.business.process.domian.TempPoints; | 20 | import com.topdraw.business.process.domian.TempPoints; |
... | @@ -16,6 +22,7 @@ import com.topdraw.util.IdWorker; | ... | @@ -16,6 +22,7 @@ import com.topdraw.util.IdWorker; |
16 | import com.topdraw.util.RedissonUtil; | 22 | import com.topdraw.util.RedissonUtil; |
17 | import com.topdraw.util.TimestampUtil; | 23 | import com.topdraw.util.TimestampUtil; |
18 | import com.topdraw.utils.StringUtils; | 24 | import com.topdraw.utils.StringUtils; |
25 | import lombok.Data; | ||
19 | import lombok.extern.slf4j.Slf4j; | 26 | import lombok.extern.slf4j.Slf4j; |
20 | import org.redisson.api.RLock; | 27 | import org.redisson.api.RLock; |
21 | import org.redisson.api.RedissonClient; | 28 | import org.redisson.api.RedissonClient; |
... | @@ -23,6 +30,8 @@ import org.slf4j.Logger; | ... | @@ -23,6 +30,8 @@ import org.slf4j.Logger; |
23 | import org.slf4j.LoggerFactory; | 30 | import org.slf4j.LoggerFactory; |
24 | import org.springframework.beans.BeanUtils; | 31 | import org.springframework.beans.BeanUtils; |
25 | import org.springframework.beans.factory.annotation.Autowired; | 32 | import org.springframework.beans.factory.annotation.Autowired; |
33 | import org.springframework.data.redis.core.StringRedisTemplate; | ||
34 | import org.springframework.data.redis.core.ValueOperations; | ||
26 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 35 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
27 | import org.springframework.stereotype.Service; | 36 | import org.springframework.stereotype.Service; |
28 | import org.springframework.transaction.annotation.Propagation; | 37 | import org.springframework.transaction.annotation.Propagation; |
... | @@ -31,8 +40,10 @@ import org.springframework.util.CollectionUtils; | ... | @@ -31,8 +40,10 @@ import org.springframework.util.CollectionUtils; |
31 | 40 | ||
32 | import javax.annotation.Resource; | 41 | import javax.annotation.Resource; |
33 | import java.sql.Timestamp; | 42 | import java.sql.Timestamp; |
43 | import java.time.LocalDate; | ||
34 | import java.time.LocalDateTime; | 44 | import java.time.LocalDateTime; |
35 | import java.util.*; | 45 | import java.util.*; |
46 | import java.util.concurrent.TimeUnit; | ||
36 | import java.util.stream.Collectors; | 47 | import java.util.stream.Collectors; |
37 | 48 | ||
38 | /** | 49 | /** |
... | @@ -55,6 +66,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -55,6 +66,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
55 | PointsDetailHistoryService pointsDetailHistoryService; | 66 | PointsDetailHistoryService pointsDetailHistoryService; |
56 | @Autowired | 67 | @Autowired |
57 | MemberOperationService memberOperationService; | 68 | MemberOperationService memberOperationService; |
69 | @Autowired | ||
70 | MemberService memberService; | ||
58 | 71 | ||
59 | // 过期阈值 30天 | 72 | // 过期阈值 30天 |
60 | private static final Integer EXPIRE_FACTOR = 30; | 73 | private static final Integer EXPIRE_FACTOR = 30; |
... | @@ -70,9 +83,21 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -70,9 +83,21 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
70 | @Override | 83 | @Override |
71 | @Transactional(rollbackFor = Exception.class) | 84 | @Transactional(rollbackFor = Exception.class) |
72 | public void grantPointsByManual(Long memberId,TempPoints tempPoints){ | 85 | public void grantPointsByManual(Long memberId,TempPoints tempPoints){ |
73 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) | 86 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { |
87 | MemberDTO memberDTo = this.memberService.findById(memberId); | ||
88 | String memberCode = memberDTo.getCode(); | ||
89 | tempPoints.setMemberCode(memberCode); | ||
74 | this.refresh(tempPoints); | 90 | this.refresh(tempPoints); |
75 | } | 91 | } |
92 | } | ||
93 | |||
94 | @Override | ||
95 | @AsyncMqSend | ||
96 | public void grantPointsByManualByTempPoints(TempPoints tempPoints) { | ||
97 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { | ||
98 | this.refresh(tempPoints); | ||
99 | } | ||
100 | } | ||
76 | 101 | ||
77 | /** | 102 | /** |
78 | * 积分消耗 | 103 | * 积分消耗 |
... | @@ -81,23 +106,28 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -81,23 +106,28 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
81 | */ | 106 | */ |
82 | @Override | 107 | @Override |
83 | @Transactional(rollbackFor = Exception.class) | 108 | @Transactional(rollbackFor = Exception.class) |
84 | public boolean customPoints(TempPoints tempPoints) { | 109 | @AsyncMqSend |
110 | public CustomPointsResult customPoints(TempPoints tempPoints) { | ||
111 | |||
112 | CustomPointsResult customPointsResult = new CustomPointsResult(); | ||
113 | |||
85 | Long memberId = tempPoints.getMemberId(); | 114 | Long memberId = tempPoints.getMemberId(); |
86 | 115 | ||
87 | RLock rLock = this.redissonClient.getLock("refresh" + memberId.toString()); | 116 | RLock rLock = this.redissonClient.getLock("member::id::" + memberId.toString()); |
88 | try { | 117 | try { |
89 | RedissonUtil.lock(rLock); | 118 | RedissonUtil.lock(rLock); |
119 | //1.删除过期的积分 | ||
120 | this.cleanInvalidAvailablePointsByMemberId(memberId); | ||
90 | // 1.判断可用积分是否够用 | 121 | // 1.判断可用积分是否够用 |
91 | boolean b = this.checkAvailablePoints(tempPoints); | 122 | boolean b = this.checkAvailablePoints(tempPoints); |
123 | // 3.当前可用总积分 | ||
124 | long currentPoints = this.findAvailablePointsByMemberId(memberId); | ||
92 | if (b) { | 125 | if (b) { |
93 | //1.删除过期的积分 | ||
94 | this.cleanInvalidAvailablePointsByMemberId(memberId); | ||
95 | // 2.可用积分表,按照过期时间进行升序排列 | 126 | // 2.可用积分表,按照过期时间进行升序排列 |
96 | List<PointsAvailableDTO> pointsAvailableDTOS = this.findByMemberIdOrderByExpireTime(tempPoints); | 127 | List<PointsAvailableDTO> pointsAvailableDTOS = this.findByMemberIdOrderByExpireTime(tempPoints); |
97 | // 3.当前可用总积分 | ||
98 | long currentPoints = this.findAvailablePointsByMemberId(memberId); | ||
99 | // 2.优先使用即将过期的积分,累加到超过需兑换积分时,需要进行拆分 | 128 | // 2.优先使用即将过期的积分,累加到超过需兑换积分时,需要进行拆分 |
100 | Map<String, List<PointsAvailableDTO>> customAvailablePointsMap = this.customAvailablePoints(tempPoints, pointsAvailableDTOS); | 129 | Map<String, List<PointsAvailableDTO>> customAvailablePointsMap = |
130 | this.customAvailablePoints(tempPoints, pointsAvailableDTOS); | ||
101 | // 3.添加积分明细 | 131 | // 3.添加积分明细 |
102 | this.doInsertTrPointsDetailByAvailablePointsMap(tempPoints, customAvailablePointsMap, currentPoints); | 132 | this.doInsertTrPointsDetailByAvailablePointsMap(tempPoints, customAvailablePointsMap, currentPoints); |
103 | // 4.更新可用积分表,超过的删除,剩余的新增 | 133 | // 4.更新可用积分表,超过的删除,剩余的新增 |
... | @@ -105,9 +135,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -105,9 +135,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
105 | // 5.即将过期的积分 | 135 | // 5.即将过期的积分 |
106 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 136 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
107 | // 6.更新会员积分信息 | 137 | // 6.更新会员积分信息 |
108 | this.freshMemberCurrentPoints(memberId, totalPoints,soonExpirePoints); | 138 | this.freshMemberCurrentPoints(memberId, totalPoints,soonExpirePoints,tempPoints); |
109 | 139 | ||
110 | return true; | 140 | customPointsResult.setResult(true); |
141 | customPointsResult.setPoint(totalPoints); | ||
142 | return customPointsResult; | ||
143 | } else { | ||
144 | customPointsResult.setResult(false); | ||
145 | customPointsResult.setPoint(currentPoints); | ||
111 | } | 146 | } |
112 | }catch (Exception e) { | 147 | }catch (Exception e) { |
113 | e.printStackTrace(); | 148 | e.printStackTrace(); |
... | @@ -116,7 +151,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -116,7 +151,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
116 | RedissonUtil.unlock(rLock); | 151 | RedissonUtil.unlock(rLock); |
117 | } | 152 | } |
118 | 153 | ||
119 | return false; | 154 | return customPointsResult; |
120 | } | 155 | } |
121 | 156 | ||
122 | /** | 157 | /** |
... | @@ -133,7 +168,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -133,7 +168,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
133 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS1)) { | 168 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS1)) { |
134 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS1) { | 169 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS1) { |
135 | totalCustomAvailablePoints = (totalCustomAvailablePoints+pointsAvailableDTO.getPoints()); | 170 | totalCustomAvailablePoints = (totalCustomAvailablePoints+pointsAvailableDTO.getPoints()); |
136 | this.pointsAvailableService.delete(pointsAvailableDTO.getId()); | 171 | this.pointsAvailableService.delete4Custom(pointsAvailableDTO.getId()); |
137 | } | 172 | } |
138 | } | 173 | } |
139 | 174 | ||
... | @@ -145,7 +180,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -145,7 +180,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
145 | BeanUtils.copyProperties(pointsAvailableDTO,pointsAvailable); | 180 | BeanUtils.copyProperties(pointsAvailableDTO,pointsAvailable); |
146 | pointsAvailable.setId(null); | 181 | pointsAvailable.setId(null); |
147 | pointsAvailable.setCode(String.valueOf(IdWorker.generator())); | 182 | pointsAvailable.setCode(String.valueOf(IdWorker.generator())); |
148 | this.pointsAvailableService.create(pointsAvailable); | 183 | this.pointsAvailableService.create4Custom(pointsAvailable); |
149 | } | 184 | } |
150 | } | 185 | } |
151 | 186 | ||
... | @@ -283,7 +318,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -283,7 +318,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
283 | */ | 318 | */ |
284 | private void cleanInvalidAvailablePointsByMemberId(Long memberId) { | 319 | private void cleanInvalidAvailablePointsByMemberId(Long memberId) { |
285 | List<PointsAvailableDTO> pointsAvailableDTOS = | 320 | List<PointsAvailableDTO> pointsAvailableDTOS = |
286 | pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId,TimestampUtil.now()); | 321 | pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId,LocalDateTime.now()); |
287 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS)) { | 322 | if (!CollectionUtils.isEmpty(pointsAvailableDTOS)) { |
288 | //1.获取原始积分 | 323 | //1.获取原始积分 |
289 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS) { | 324 | for (PointsAvailableDTO pointsAvailableDTO : pointsAvailableDTOS) { |
... | @@ -347,7 +382,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -347,7 +382,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
347 | * @param pointsAvailableDTO | 382 | * @param pointsAvailableDTO |
348 | */ | 383 | */ |
349 | private void doDeleteInvalidAvailablePoints(PointsAvailableDTO pointsAvailableDTO) { | 384 | private void doDeleteInvalidAvailablePoints(PointsAvailableDTO pointsAvailableDTO) { |
350 | this.pointsAvailableService.delete(pointsAvailableDTO.getId()); | 385 | this.pointsAvailableService.delete4Custom(pointsAvailableDTO.getId()); |
351 | } | 386 | } |
352 | 387 | ||
353 | /** | 388 | /** |
... | @@ -375,7 +410,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -375,7 +410,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
375 | pointsDetail.setEvtType(99); | 410 | pointsDetail.setEvtType(99); |
376 | pointsDetail.setCreateTime(TimestampUtil.now()); | 411 | pointsDetail.setCreateTime(TimestampUtil.now()); |
377 | pointsDetail.setUpdateTime(TimestampUtil.now()); | 412 | pointsDetail.setUpdateTime(TimestampUtil.now()); |
378 | this.doInsertPointsDetail(pointsDetail); | 413 | this.pointsDetailService.create4Custom(pointsDetail); |
379 | } | 414 | } |
380 | 415 | ||
381 | /** | 416 | /** |
... | @@ -383,39 +418,38 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -383,39 +418,38 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
383 | * | 418 | * |
384 | * @param tempPoints 积分 | 419 | * @param tempPoints 积分 |
385 | */ | 420 | */ |
421 | |||
386 | private void refresh(TempPoints tempPoints) { | 422 | private void refresh(TempPoints tempPoints) { |
387 | Long memberId = tempPoints.getMemberId(); | 423 | Long memberId = tempPoints.getMemberId(); |
388 | log.info("----------->> points refresh start"); | 424 | log.info("----------->> 会员id ===>>>>" + memberId); |
389 | RLock rLock = this.redissonClient.getLock("uc-refresh-points:" + memberId.toString()); | 425 | RLock rLock = this.redissonClient.getLock("member::id::" + memberId.toString()); |
390 | log.info("----------->> rLock --->> start" ); | 426 | log.info("----------->> rLock --->> start" ); |
391 | try { | 427 | try { |
392 | RedissonUtil.lock(rLock); | 428 | RedissonUtil.lock(rLock); |
393 | log.info("----------->> refresh findAvailablePointsByMemberId start"); | 429 | |
394 | // 1.可用总积分 | 430 | // 1.可用总积分 |
395 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); | 431 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); |
396 | log.info("----------->> refresh findAvailablePointsByMemberId currentPoints " + currentPoints); | 432 | log.info("----------->> 可用总积分 --->>>> " + currentPoints); |
397 | 433 | ||
398 | // 2.计算总积分 | 434 | // 2.计算总积分 |
399 | Long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); | 435 | Long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); |
400 | log.info("----------->> refresh findAvailablePointsByMemberId totalPoints " + totalPoints); | 436 | log.info("----------->> 总积分(可用总积分+获得的积分) --->>> " + totalPoints); |
401 | 437 | ||
402 | // 3.添加积分明细,并计算总积分 | 438 | // 3.添加积分明细 |
403 | log.info(Thread.currentThread().getName() + "----------->> refresh doInsertTrPointsDetail start "); | ||
404 | this.doInsertTrPointsDetail(memberId, tempPoints, currentPoints, totalPoints); | 439 | this.doInsertTrPointsDetail(memberId, tempPoints, currentPoints, totalPoints); |
405 | log.info(Thread.currentThread().getName() + "----------->> refresh doInsertTrPointsDetail end "); | 440 | log.info("----------->> 添加积分明细 "); |
406 | 441 | ||
407 | // 4.添加可用积分 | 442 | // 4.添加可用积分 |
408 | log.info("----------->> refresh doInsertTrPointsAvailable start "); | ||
409 | this.doInsertTrPointsAvailable(tempPoints); | 443 | this.doInsertTrPointsAvailable(tempPoints); |
410 | log.info("----------->> refresh doInsertTrPointsAvailable end "); | 444 | log.info("----------->> 添加可用积分 "); |
411 | 445 | ||
412 | // 即将过期的积分 | 446 | // 5.即将过期的积分 |
413 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 447 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
448 | log.info("----------->> 即将过期的积分 ------->>>>> " + soonExpirePoints); | ||
414 | 449 | ||
415 | // 6.更新会员的总积分 | 450 | // 6.更新会员的总积分 |
416 | log.info("----------->> refresh freshMemberCurrentPoints start "); | 451 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>>" + totalPoints); |
417 | this.freshMemberCurrentPoints(memberId, totalPoints,soonExpirePoints); | 452 | this.freshMemberCurrentPoints(memberId, totalPoints,soonExpirePoints,tempPoints); |
418 | log.info("----------->> refresh freshMemberCurrentPoints end "); | ||
419 | 453 | ||
420 | } catch (Exception e) { | 454 | } catch (Exception e) { |
421 | e.printStackTrace(); | 455 | e.printStackTrace(); |
... | @@ -470,12 +504,13 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -470,12 +504,13 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
470 | * @param memberId 会员Id | 504 | * @param memberId 会员Id |
471 | * @param currentPoints 当前总积分 | 505 | * @param currentPoints 当前总积分 |
472 | */ | 506 | */ |
473 | private void freshMemberCurrentPoints(Long memberId, Long currentPoints,long duePoints) { | 507 | private void freshMemberCurrentPoints(Long memberId, Long currentPoints,long duePoints,TempPoints tempPoints) { |
474 | Member member = new Member(); | 508 | Member member = new Member(); |
475 | member.setId(memberId); | 509 | member.setId(memberId); |
476 | member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0); | 510 | member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0); |
477 | member.setDuePoints(duePoints); | 511 | member.setDuePoints(duePoints); |
478 | member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now())); | 512 | member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now())); |
513 | member.setCode(tempPoints.getMemberCode()); | ||
479 | try { | 514 | try { |
480 | this.memberOperationService.doUpdateMemberPoints(member); | 515 | this.memberOperationService.doUpdateMemberPoints(member); |
481 | } catch (Exception e){ | 516 | } catch (Exception e){ |
... | @@ -501,28 +536,20 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -501,28 +536,20 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
501 | 536 | ||
502 | PointsAvailable pointsAvailable = new PointsAvailable(); | 537 | PointsAvailable pointsAvailable = new PointsAvailable(); |
503 | BeanUtils.copyProperties(tempPoints,pointsAvailable); | 538 | BeanUtils.copyProperties(tempPoints,pointsAvailable); |
539 | |||
504 | String description = pointsAvailable.getDescription(); | 540 | String description = pointsAvailable.getDescription(); |
505 | pointsAvailable.setCode(String.valueOf(IdWorker.generator())); | 541 | pointsAvailable.setCode(String.valueOf(IdWorker.generator())); |
506 | pointsAvailable.setDescription(StringUtils.isEmpty(description)?"#":description); | 542 | pointsAvailable.setDescription(StringUtils.isEmpty(description)?"#":description); |
507 | Timestamp timestamp = tempPoints.getExpireTime(); | 543 | LocalDateTime timestamp = tempPoints.getExpireTime(); |
508 | if (Objects.nonNull(timestamp)) { | 544 | if (Objects.nonNull(timestamp)) { |
509 | pointsAvailable.setExpireTime(timestamp); | 545 | pointsAvailable.setExpireTime(timestamp); |
510 | } | 546 | } |
511 | 547 | ||
512 | // 添加可用积分记录 | 548 | this.pointsAvailableService.create4Custom(pointsAvailable); |
513 | this.doInsertTrPointsAvailable(pointsAvailable); | ||
514 | 549 | ||
515 | } | 550 | } |
516 | 551 | ||
517 | /** | 552 | /** |
518 | * 添加可用积分记录 | ||
519 | * @param pointsAvailable 可用积分 | ||
520 | */ | ||
521 | private void doInsertTrPointsAvailable(PointsAvailable pointsAvailable) { | ||
522 | this.pointsAvailableService.create(pointsAvailable); | ||
523 | } | ||
524 | |||
525 | /** | ||
526 | * 添加积分明细 | 553 | * 添加积分明细 |
527 | * @param memberId 会员Id | 554 | * @param memberId 会员Id |
528 | * @param tempPoints 积分 | 555 | * @param tempPoints 积分 |
... | @@ -534,6 +561,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -534,6 +561,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
534 | BeanUtils.copyProperties(tempPoints,pointsDetail); | 561 | BeanUtils.copyProperties(tempPoints,pointsDetail); |
535 | pointsDetail.setId(null); | 562 | pointsDetail.setId(null); |
536 | pointsDetail.setMemberId(memberId); | 563 | pointsDetail.setMemberId(memberId); |
564 | pointsDetail.setMemberCode(tempPoints.getMemberCode()); | ||
537 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); | 565 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); |
538 | pointsDetail.setPoints(tempPoints.getPoints()); | 566 | pointsDetail.setPoints(tempPoints.getPoints()); |
539 | pointsDetail.setOriginalPoints(currentPoints); | 567 | pointsDetail.setOriginalPoints(currentPoints); |
... | @@ -546,15 +574,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -546,15 +574,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
546 | } | 574 | } |
547 | 575 | ||
548 | // 保存积分流水 | 576 | // 保存积分流水 |
549 | this.doInsertPointsDetail(pointsDetail); | 577 | this.pointsDetailService.create4Custom(pointsDetail); |
550 | 578 | ||
551 | } | 579 | } |
552 | 580 | ||
553 | /** | ||
554 | * | ||
555 | * @param pointsDetail | ||
556 | */ | ||
557 | private void doInsertPointsDetail(PointsDetail pointsDetail){ | ||
558 | this.pointsDetailService.create(pointsDetail); | ||
559 | } | ||
560 | } | 581 | } | ... | ... |
... | @@ -251,7 +251,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -251,7 +251,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
251 | tempCoupon.setRightsSendStrategy(0); | 251 | tempCoupon.setRightsSendStrategy(0); |
252 | tempCoupon.setCode(couponDTO.getCode()); | 252 | tempCoupon.setCode(couponDTO.getCode()); |
253 | if (Objects.nonNull(expireTime)) | 253 | if (Objects.nonNull(expireTime)) |
254 | tempCoupon.setExpireTime(TimestampUtil.long2Timestamp(expireTime)); | 254 | tempCoupon.setExpireTime(TimestampUtil.long2LocalDateTime(expireTime)); |
255 | tempCouponList.add(tempCoupon); | 255 | tempCouponList.add(tempCoupon); |
256 | } | 256 | } |
257 | break; | 257 | break; | ... | ... |
... | @@ -14,6 +14,10 @@ import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; | ... | @@ -14,6 +14,10 @@ import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; |
14 | import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService; | 14 | import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService; |
15 | import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO; | 15 | import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO; |
16 | import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria; | 16 | import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria; |
17 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
18 | import com.topdraw.business.basicdata.user.iptv.service.UserTvService; | ||
19 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
20 | import com.topdraw.business.process.service.PointsOperationService; | ||
17 | import com.topdraw.business.process.service.RightsOperationService; | 21 | import com.topdraw.business.process.service.RightsOperationService; |
18 | import com.topdraw.business.process.service.TaskOperationService; | 22 | import com.topdraw.business.process.service.TaskOperationService; |
19 | import com.topdraw.business.basicdata.member.service.MemberService; | 23 | import com.topdraw.business.basicdata.member.service.MemberService; |
... | @@ -23,23 +27,24 @@ import com.topdraw.business.basicdata.task.service.TaskService; | ... | @@ -23,23 +27,24 @@ import com.topdraw.business.basicdata.task.service.TaskService; |
23 | import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; | 27 | import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; |
24 | import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; | 28 | import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; |
25 | import com.topdraw.business.process.domian.*; | 29 | import com.topdraw.business.process.domian.*; |
30 | import com.topdraw.business.process.service.UserTvOperationService; | ||
26 | import com.topdraw.common.ResultInfo; | 31 | import com.topdraw.common.ResultInfo; |
27 | import com.topdraw.module.mq.DataSyncMsg; | 32 | import com.topdraw.module.mq.DataSyncMsg; |
28 | import com.topdraw.util.*; | 33 | import com.topdraw.util.*; |
29 | import lombok.extern.slf4j.Slf4j; | 34 | import lombok.extern.slf4j.Slf4j; |
30 | import org.slf4j.Logger; | ||
31 | import org.slf4j.LoggerFactory; | ||
32 | import org.springframework.beans.BeanUtils; | 35 | import org.springframework.beans.BeanUtils; |
33 | import org.springframework.beans.factory.annotation.Autowired; | 36 | import org.springframework.beans.factory.annotation.Autowired; |
37 | import org.springframework.data.redis.core.StringRedisTemplate; | ||
38 | import org.springframework.data.redis.core.ValueOperations; | ||
34 | import org.springframework.stereotype.Service; | 39 | import org.springframework.stereotype.Service; |
35 | import org.springframework.util.CollectionUtils; | 40 | import org.springframework.util.CollectionUtils; |
36 | import org.springframework.util.StringUtils; | 41 | import org.springframework.util.StringUtils; |
37 | 42 | ||
38 | import java.math.BigDecimal; | ||
39 | import java.math.RoundingMode; | ||
40 | import java.sql.Timestamp; | 43 | import java.sql.Timestamp; |
41 | import java.time.LocalDate; | 44 | import java.time.LocalDate; |
45 | import java.time.LocalDateTime; | ||
42 | import java.util.*; | 46 | import java.util.*; |
47 | import java.util.concurrent.TimeUnit; | ||
43 | 48 | ||
44 | import static java.util.stream.Collectors.toList; | 49 | import static java.util.stream.Collectors.toList; |
45 | 50 | ||
... | @@ -53,8 +58,6 @@ import static java.util.stream.Collectors.toList; | ... | @@ -53,8 +58,6 @@ import static java.util.stream.Collectors.toList; |
53 | @Slf4j | 58 | @Slf4j |
54 | public class TaskOperationServiceImpl implements TaskOperationService { | 59 | public class TaskOperationServiceImpl implements TaskOperationService { |
55 | 60 | ||
56 | private static final Logger LOG = LoggerFactory.getLogger(PointsOperationServiceImpl.class); | ||
57 | |||
58 | @Autowired | 61 | @Autowired |
59 | TaskService taskService; | 62 | TaskService taskService; |
60 | @Autowired | 63 | @Autowired |
... | @@ -74,6 +77,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -74,6 +77,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
74 | @Autowired | 77 | @Autowired |
75 | MemberGroupService memberGroupService; | 78 | MemberGroupService memberGroupService; |
76 | 79 | ||
80 | |||
77 | private static final Integer TASK_FINISH_STATUS = 1; | 81 | private static final Integer TASK_FINISH_STATUS = 1; |
78 | private static final Integer TASK_UNFINISH_STATUS = 2; | 82 | private static final Integer TASK_UNFINISH_STATUS = 2; |
79 | private static final Integer POINTS_TYPE_RANDOM = 1; | 83 | private static final Integer POINTS_TYPE_RANDOM = 1; |
... | @@ -111,7 +115,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -111,7 +115,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
111 | } | 115 | } |
112 | 116 | ||
113 | long r = System.currentTimeMillis(); | 117 | long r = System.currentTimeMillis(); |
114 | LOG.info("总耗时======>>>>>" + (r-l)); | 118 | log.info("总耗时======>>>>>" + (r-l)); |
115 | return ResultInfo.success(); | 119 | return ResultInfo.success(); |
116 | 120 | ||
117 | 121 | ||
... | @@ -221,65 +225,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -221,65 +225,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
221 | } | 225 | } |
222 | 226 | ||
223 | /** | 227 | /** |
224 | * 计算总权益 = 已获得的积分 + 已获得的积分 * 额外积分比率 | ||
225 | * @param permanentRights | ||
226 | * @param map | ||
227 | */ | ||
228 | @Deprecated | ||
229 | private Map<RightType, Object> calculateRight(PermanentRightsDTO permanentRights, Map<RightType, Object> map,Long memberId) { | ||
230 | |||
231 | // 验证永久权益 | ||
232 | boolean b = this.validatedPermanentRights(permanentRights, memberId); | ||
233 | |||
234 | if (b) { | ||
235 | // 获得的积分 | ||
236 | List<TempPoints> tempPointsList = (List<TempPoints>)map.get(RightType.POINTS); | ||
237 | |||
238 | if (!CollectionUtils.isEmpty(tempPointsList)) { | ||
239 | // 经过永久权益计算后的总积分 | ||
240 | this.calculateTotalPoints(permanentRights,tempPointsList); | ||
241 | map.put(RightType.POINTS,tempPointsList); | ||
242 | } | ||
243 | |||
244 | // TODO 其他权益 | ||
245 | |||
246 | } | ||
247 | |||
248 | return map; | ||
249 | } | ||
250 | |||
251 | /** | ||
252 | * 经过永久权益计算后的总积分 | ||
253 | * @param permanentRights 永久权益 | ||
254 | * @param tempPointsList 积分 | ||
255 | * @return BigDecimal 总积分 | ||
256 | */ | ||
257 | @Deprecated | ||
258 | private BigDecimal calculateTotalPoints(PermanentRightsDTO permanentRights, List<TempPoints> tempPointsList) { | ||
259 | |||
260 | // 总积分 | ||
261 | BigDecimal rewardsPoints = null; | ||
262 | // 额外积分费率 | ||
263 | BigDecimal extraPoints = permanentRights.getExtraPoints(); | ||
264 | |||
265 | for (TempPoints tempPoints : tempPointsList) { | ||
266 | |||
267 | rewardsPoints = new BigDecimal(tempPoints.getPoints()); | ||
268 | if (Objects.nonNull(extraPoints) && extraPoints.compareTo(BigDecimal.ZERO) > 0) { | ||
269 | // 已获得的积分 * 额外积分比率 | ||
270 | BigDecimal multiply = (extraPoints.divide(new BigDecimal(100),4,RoundingMode.HALF_UP)).multiply(rewardsPoints); | ||
271 | // 四舍五入 | ||
272 | BigDecimal bigDecimal = multiply.setScale(0, RoundingMode.HALF_UP); | ||
273 | // 已获得的积分 + 已获得的积分 * 额外积分比率 | ||
274 | rewardsPoints = rewardsPoints.add(bigDecimal); | ||
275 | tempPoints.setPoints(rewardsPoints.longValue()); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | return rewardsPoints; | ||
280 | } | ||
281 | |||
282 | /** | ||
283 | * 验证是否满足永久权益 | 228 | * 验证是否满足永久权益 |
284 | * @param permanentRights | 229 | * @param permanentRights |
285 | * @param memberId | 230 | * @param memberId |
... | @@ -336,7 +281,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -336,7 +281,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
336 | tempRights.setRightsAmount(rightsAmount); | 281 | tempRights.setRightsAmount(rightsAmount); |
337 | Long expireTime = rightsDTO.getExpireTime(); | 282 | Long expireTime = rightsDTO.getExpireTime(); |
338 | if (Objects.nonNull(expireTime)) | 283 | if (Objects.nonNull(expireTime)) |
339 | tempRights.setExpireTime(TimestampUtil.long2Timestamp(expireTime)); | 284 | tempRights.setExpireTime(TimestampUtil.long2LocalDateTime(expireTime)); |
340 | return tempRights; | 285 | return tempRights; |
341 | } | 286 | } |
342 | 287 | ||
... | @@ -515,7 +460,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -515,7 +460,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
515 | Long rewardPoints = task.getRewardPoints(); | 460 | Long rewardPoints = task.getRewardPoints(); |
516 | // 过期时间 | 461 | // 过期时间 |
517 | Long rewardPointsExpireTime = task.getRewardPointsExpireTime(); | 462 | Long rewardPointsExpireTime = task.getRewardPointsExpireTime(); |
518 | Timestamp expireTime = task.getExpireTime(); | 463 | LocalDateTime expireTime = task.getExpireTime(); |
519 | // 积分类型(0:定值、1:随机) | 464 | // 积分类型(0:定值、1:随机) |
520 | Integer pointsType = task.getPointsType(); | 465 | Integer pointsType = task.getPointsType(); |
521 | // 随机积分的最大值 | 466 | // 随机积分的最大值 |
... | @@ -573,7 +518,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -573,7 +518,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
573 | 518 | ||
574 | List<Task> taskStream = taskList1.stream().filter(task1 -> | 519 | List<Task> taskStream = taskList1.stream().filter(task1 -> |
575 | task1.getStatus() == 1 && | 520 | task1.getStatus() == 1 && |
576 | (Objects.isNull(task1.getExpireTime()) || task1.getExpireTime().compareTo(TimestampUtil.now()) >= 0) && | 521 | (Objects.isNull(task1.getExpireTime()) || task1.getExpireTime().compareTo(LocalDateTime.now()) >= 0) && |
577 | (Objects.isNull(task1.getValidTime()) || task1.getValidTime().compareTo(TimestampUtil.now()) <= 0) && | 522 | (Objects.isNull(task1.getValidTime()) || task1.getValidTime().compareTo(TimestampUtil.now()) <= 0) && |
578 | (Objects.isNull(task1.getMemberLevel()) || task1.getMemberLevel() <= memberDTO1.getLevel()) && | 523 | (Objects.isNull(task1.getMemberLevel()) || task1.getMemberLevel() <= memberDTO1.getLevel()) && |
579 | (Objects.isNull(task1.getMemberVip()) || task1.getMemberVip() <= memberDTO1.getVip()) | 524 | (Objects.isNull(task1.getMemberVip()) || task1.getMemberVip() <= memberDTO1.getVip()) |
... | @@ -852,4 +797,95 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -852,4 +797,95 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
852 | private TaskTemplate getTaskTemplate(Integer event) { | 797 | private TaskTemplate getTaskTemplate(Integer event) { |
853 | return this.taskTemplateService.findByType(event); | 798 | return this.taskTemplateService.findByType(event); |
854 | } | 799 | } |
800 | |||
801 | |||
802 | |||
803 | |||
804 | |||
805 | //////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
806 | |||
807 | @Autowired | ||
808 | UserTvService userTvService; | ||
809 | @Autowired | ||
810 | private StringRedisTemplate stringRedisTemplate; | ||
811 | @Autowired | ||
812 | private PointsOperationService pointsOperationService; | ||
813 | @Autowired | ||
814 | private UserTvOperationService userTvOperationService; | ||
815 | |||
816 | private UserTv checkUserTv(String platformAccount){ | ||
817 | UserTv userTv = new UserTv(); | ||
818 | userTv.setPlatformAccount(platformAccount); | ||
819 | userTv.setStatus(0); | ||
820 | userTv.setNickname("未设置"); | ||
821 | userTv.setPlatform("CTC.ChongQing"); | ||
822 | userTv.setCreateBy("#"); | ||
823 | userTv.setUpdateBy("#"); | ||
824 | return userTv; | ||
825 | } | ||
826 | |||
827 | @Override | ||
828 | public boolean createPoint2ChongQing(String platformAccount, Long points) { | ||
829 | |||
830 | boolean result = this.verificationActivity(platformAccount); | ||
831 | if (!result) { | ||
832 | return result; | ||
833 | } | ||
834 | |||
835 | long l = System.currentTimeMillis(); | ||
836 | |||
837 | this.userTvOperationService.createMemberByUserTv(this.checkUserTv(platformAccount)); | ||
838 | |||
839 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
840 | if (Objects.nonNull(userTvDTO)) { | ||
841 | Long memberId = userTvDTO.getMemberId(); | ||
842 | if (Objects.nonNull(memberId)) { | ||
843 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
844 | if (Objects.nonNull(memberDTO)) { | ||
845 | String code = memberDTO.getCode(); | ||
846 | TempPoints tempPoints = new TempPoints(); | ||
847 | tempPoints.setMemberId(memberId); | ||
848 | tempPoints.setMemberCode(code); | ||
849 | tempPoints.setPoints(points); | ||
850 | tempPoints.setDescription("重庆重数大屏积分兑换活动,时间:202112"); | ||
851 | tempPoints.setDeviceType(1); | ||
852 | tempPoints.setEvtType(3); | ||
853 | tempPoints.setPointsType(0); | ||
854 | tempPoints.setExpireTime(LocalDateTime.of(2022,12,31,23,59,59)); | ||
855 | this.pointsOperationService.grantPointsByManualByTempPoints(tempPoints); | ||
856 | } | ||
857 | |||
858 | } | ||
859 | |||
860 | } | ||
861 | |||
862 | long currentTimeMillis = System.currentTimeMillis(); | ||
863 | log.info("领取积分总耗时--->>>>" + (currentTimeMillis-l)); | ||
864 | return true; | ||
865 | } | ||
866 | |||
867 | /** | ||
868 | * 验证是否首次进入活动页面 | ||
869 | * @param platform | ||
870 | * @return | ||
871 | */ | ||
872 | private boolean verificationActivity(String platform) { | ||
873 | boolean result = false; | ||
874 | |||
875 | LocalDate now = LocalDate.now(); | ||
876 | String s = now+"::"+"chongshujifenduihuanchoujiang"+"::"+platform; | ||
877 | |||
878 | ValueOperations<String, String> stringValueOperations = stringRedisTemplate.opsForValue(); | ||
879 | |||
880 | String s1 = stringValueOperations.get(s); | ||
881 | if (org.springframework.util.StringUtils.isEmpty(s1)) { | ||
882 | stringValueOperations.set(s,"true",2, TimeUnit.DAYS); | ||
883 | result = true; | ||
884 | } else { | ||
885 | result = false; | ||
886 | } | ||
887 | |||
888 | return result; | ||
889 | } | ||
890 | |||
855 | } | 891 | } | ... | ... |
1 | package com.topdraw.business.process.service.impl; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.domain.Member; | ||
4 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
5 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
6 | import com.topdraw.business.basicdata.user.iptv.domain.UserTv; | ||
7 | import com.topdraw.business.basicdata.user.iptv.repository.UserTvRepository; | ||
8 | import com.topdraw.business.basicdata.user.iptv.service.UserTvService; | ||
9 | import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; | ||
10 | import com.topdraw.business.basicdata.user.iptv.service.mapper.UserTvMapper; | ||
11 | import com.topdraw.business.process.service.UserTvOperationService; | ||
12 | import com.topdraw.config.LocalConstants; | ||
13 | import com.topdraw.util.Base64Util; | ||
14 | import com.topdraw.util.IdWorker; | ||
15 | import com.topdraw.util.RedissonUtil; | ||
16 | import com.topdraw.util.TimestampUtil; | ||
17 | import com.topdraw.utils.StringUtils; | ||
18 | import lombok.extern.slf4j.Slf4j; | ||
19 | import org.redisson.api.RLock; | ||
20 | import org.redisson.api.RedissonClient; | ||
21 | import org.springframework.beans.BeanUtils; | ||
22 | import org.springframework.beans.factory.annotation.Autowired; | ||
23 | import org.springframework.stereotype.Service; | ||
24 | import org.springframework.transaction.annotation.Transactional; | ||
25 | |||
26 | import java.util.Objects; | ||
27 | |||
28 | @Service | ||
29 | @Slf4j | ||
30 | public class UserTvOperationServiceImpl implements UserTvOperationService { | ||
31 | |||
32 | @Autowired | ||
33 | private RedissonClient redissonClient; | ||
34 | |||
35 | @Autowired | ||
36 | private MemberService memberService; | ||
37 | |||
38 | @Autowired | ||
39 | private UserTvService userTvService; | ||
40 | |||
41 | |||
42 | @Override | ||
43 | @Transactional | ||
44 | public boolean createMemberByUserTv(UserTv resources) { | ||
45 | String platformAccount = resources.getPlatformAccount(); | ||
46 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
47 | if (Objects.isNull(userTvDTO)) { | ||
48 | Member member = new Member(); | ||
49 | // 大屏 | ||
50 | member.setType(LocalConstants.MEMBER_PLATFORM_TYPE_VIS); | ||
51 | String code = member.getCode(); | ||
52 | member.setCode(StringUtils.isEmpty(code)?String.valueOf(IdWorker.generator()):code); | ||
53 | String platformAccount1 = resources.getPlatformAccount(); | ||
54 | member.setNickname(Base64Util.encode(platformAccount1)); | ||
55 | member.setBindIptvPlatformType(1); | ||
56 | member.setType(1); | ||
57 | Long memberId = this.memberService.create(member); | ||
58 | |||
59 | if (Objects.nonNull(memberId)) { | ||
60 | UserTv userTv = new UserTv(); | ||
61 | BeanUtils.copyProperties(resources,userTv); | ||
62 | userTv.setPlatformAccount(platformAccount); | ||
63 | userTv.setMemberCode(member.getCode()); | ||
64 | Long userIptvId = this.userTvService.create(userTv); | ||
65 | |||
66 | if (Objects.nonNull(userIptvId)) { | ||
67 | member.setId(memberId); | ||
68 | member.setUserIptvId(userIptvId); | ||
69 | member.setBindIptvTime(TimestampUtil.now()); | ||
70 | member.setPlatformAccount(platformAccount); | ||
71 | this.bindIptvId(member); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | } else { | ||
76 | return false; | ||
77 | } | ||
78 | |||
79 | return true; | ||
80 | } | ||
81 | |||
82 | private void bindIptvId(Member resources) { | ||
83 | RLock rLock = this.redissonClient.getLock("Member::update::code" + resources.getCode()); | ||
84 | try { | ||
85 | RedissonUtil.lock(rLock); | ||
86 | MemberDTO member = this.memberService.getByCode(resources.getCode()); | ||
87 | if (member!=null) { | ||
88 | this.memberService.update(resources); | ||
89 | } | ||
90 | } catch (Exception e) { | ||
91 | e.printStackTrace(); | ||
92 | throw e; | ||
93 | } finally { | ||
94 | RedissonUtil.unlock(rLock); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | } |
... | @@ -13,4 +13,19 @@ public class LocalConstants { | ... | @@ -13,4 +13,19 @@ public class LocalConstants { |
13 | 13 | ||
14 | // 小屏类型 | 14 | // 小屏类型 |
15 | public static final int DEVICE_MOBILE = 2; | 15 | public static final int DEVICE_MOBILE = 2; |
16 | |||
17 | // 平台类型 | ||
18 | public static final String PLATFORM_TYPE_SERVICE = "service"; | ||
19 | public static final String PLATFORM_TYPE_MANAGEMENT = "management"; | ||
20 | |||
21 | //会员平台类型 类型 1:大屏;2:小屏 | ||
22 | public static final Integer MEMBER_PLATFORM_TYPE_VIS = 1; | ||
23 | public static final Integer MEMBER_PLATFORM_TYPE_WEIXIN = 2; | ||
24 | |||
25 | // 重庆_重数_vis | ||
26 | public static final String APP_CODE_CHONGQING_CHONGSHU_VIS = "CHONGQING_chongshu_vis"; | ||
27 | |||
28 | |||
29 | // 事件类型 3:参加活动 | ||
30 | public static final Integer EVT_TYPE_ACTIVITY = 3; | ||
16 | } | 31 | } | ... | ... |
... | @@ -10,17 +10,52 @@ public class RabbitMqConfig { | ... | @@ -10,17 +10,52 @@ public class RabbitMqConfig { |
10 | 10 | ||
11 | /** 交换机--广播*/ | 11 | /** 交换机--广播*/ |
12 | public static final String UC_EXCHANGE_FANOUT = "uc.fanout"; | 12 | public static final String UC_EXCHANGE_FANOUT = "uc.fanout"; |
13 | public static final String UC_EXCHANGE_DIRECT = "uc.direct"; | ||
14 | |||
15 | /** 队列-- */ | ||
16 | public static final String UC_QUEUE_DIRECT_BBB = "uc.route.key.direct.event.bbb"; | ||
17 | public static final String UC_QUEUE_DIRECT_CCC = "uc.route.key.direct.event.ccc"; | ||
13 | 18 | ||
14 | /** 队列-- */ | 19 | /** 队列-- */ |
15 | public static final String UC_QUEUE_FANOUT_IPTV = "uc.fanout.iptv"; | 20 | public static final String UC_QUEUE_FANOUT_IPTV = "uc.fanout.iptv"; |
16 | public static final String UC_QUEUE_FANOUT_WEIXIN = "uc.fanout.weixin"; | 21 | public static final String UC_QUEUE_FANOUT_WEIXIN = "uc.fanout.weixin"; |
17 | 22 | ||
23 | |||
18 | @Bean | 24 | @Bean |
19 | FanoutExchange ucFanoutExchange(){ | 25 | FanoutExchange ucFanoutExchange(){ |
20 | return ExchangeBuilder.fanoutExchange(UC_EXCHANGE_FANOUT).build(); | 26 | return ExchangeBuilder.fanoutExchange(UC_EXCHANGE_FANOUT).build(); |
21 | } | 27 | } |
22 | 28 | ||
23 | @Bean | 29 | @Bean |
30 | DirectExchange ucDirectExchange(){ | ||
31 | return ExchangeBuilder.directExchange(UC_EXCHANGE_DIRECT).build(); | ||
32 | } | ||
33 | |||
34 | @Bean | ||
35 | Queue ucDirectQueueCCC(){ | ||
36 | return new Queue(UC_QUEUE_DIRECT_CCC); | ||
37 | } | ||
38 | |||
39 | @Bean | ||
40 | Queue ucDirectQueueBBB(){ | ||
41 | return new Queue(UC_QUEUE_DIRECT_BBB); | ||
42 | } | ||
43 | |||
44 | @Bean | ||
45 | Binding directExchangeBindingBBB(DirectExchange directExchange , Queue ucDirectQueueBBB) { | ||
46 | BindingBuilder.DirectExchangeRoutingKeyConfigurer directExchangeRoutingKeyConfigurer = | ||
47 | BindingBuilder.bind(ucDirectQueueBBB).to(directExchange); | ||
48 | return directExchangeRoutingKeyConfigurer.with(UC_QUEUE_DIRECT_BBB); | ||
49 | } | ||
50 | |||
51 | @Bean | ||
52 | Binding directExchangeBindingCCC(DirectExchange directExchange , Queue ucDirectQueueCCC) { | ||
53 | BindingBuilder.DirectExchangeRoutingKeyConfigurer directExchangeRoutingKeyConfigurer = | ||
54 | BindingBuilder.bind(ucDirectQueueCCC).to(directExchange); | ||
55 | return directExchangeRoutingKeyConfigurer.with(UC_QUEUE_DIRECT_CCC); | ||
56 | } | ||
57 | |||
58 | @Bean | ||
24 | Queue ucFanoutQueueIptv(){ | 59 | Queue ucFanoutQueueIptv(){ |
25 | return new Queue(UC_QUEUE_FANOUT_IPTV); | 60 | return new Queue(UC_QUEUE_FANOUT_IPTV); |
26 | } | 61 | } |
... | @@ -40,4 +75,5 @@ public class RabbitMqConfig { | ... | @@ -40,4 +75,5 @@ public class RabbitMqConfig { |
40 | return BindingBuilder.bind(ucFanoutQueueWeiXin).to(ucFanoutExchange); | 75 | return BindingBuilder.bind(ucFanoutQueueWeiXin).to(ucFanoutExchange); |
41 | } | 76 | } |
42 | 77 | ||
78 | |||
43 | } | 79 | } | ... | ... |
1 | package com.topdraw.mq.producer; | 1 | package com.topdraw.mq.producer; |
2 | 2 | ||
3 | import com.topdraw.config.LocalConstants; | ||
3 | import com.topdraw.mq.config.RabbitMqConfig; | 4 | import com.topdraw.mq.config.RabbitMqConfig; |
4 | import lombok.extern.slf4j.Slf4j; | 5 | import lombok.extern.slf4j.Slf4j; |
5 | import org.springframework.amqp.core.AmqpTemplate; | 6 | import org.springframework.amqp.core.AmqpTemplate; |
6 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
8 | import org.springframework.beans.factory.annotation.Value; | ||
7 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
8 | import org.springframework.util.StringUtils; | 10 | import org.springframework.util.StringUtils; |
9 | 11 | ||
... | @@ -16,6 +18,30 @@ public class MessageProducer { | ... | @@ -16,6 +18,30 @@ public class MessageProducer { |
16 | @Autowired | 18 | @Autowired |
17 | private AmqpTemplate amqpTemplate; | 19 | private AmqpTemplate amqpTemplate; |
18 | 20 | ||
21 | |||
22 | @Value("${service.platform}") | ||
23 | private String platformType; | ||
24 | |||
25 | public void sendMessage(String msg,String exchangeName){ | ||
26 | |||
27 | // 管理侧 | ||
28 | if (platformType.equalsIgnoreCase(LocalConstants.PLATFORM_TYPE_MANAGEMENT)) { | ||
29 | if (StringUtils.isEmpty(exchangeName)) { | ||
30 | exchangeName = RabbitMqConfig.UC_QUEUE_DIRECT_CCC; | ||
31 | } | ||
32 | this.sendDirectMessage(msg,exchangeName); | ||
33 | } | ||
34 | |||
35 | // 服务侧 | ||
36 | if (platformType.equalsIgnoreCase(LocalConstants.PLATFORM_TYPE_SERVICE)) { | ||
37 | if (StringUtils.isEmpty(exchangeName)) { | ||
38 | exchangeName = RabbitMqConfig.UC_QUEUE_DIRECT_BBB; | ||
39 | } | ||
40 | this.sendDirectMessage(msg,exchangeName); | ||
41 | } | ||
42 | |||
43 | } | ||
44 | |||
19 | /** | 45 | /** |
20 | * 广播 | 46 | * 广播 |
21 | * @param msg | 47 | * @param msg |
... | @@ -23,7 +49,7 @@ public class MessageProducer { | ... | @@ -23,7 +49,7 @@ public class MessageProducer { |
23 | * @author XiangHan | 49 | * @author XiangHan |
24 | * @date 2021/9/7 11:10 上午 | 50 | * @date 2021/9/7 11:10 上午 |
25 | */ | 51 | */ |
26 | public void sendFanoutMessage(String msg,String exchangeName) { | 52 | private void sendFanoutMessage(String msg,String exchangeName) { |
27 | if (StringUtils.isEmpty(exchangeName)) { | 53 | if (StringUtils.isEmpty(exchangeName)) { |
28 | exchangeName = RabbitMqConfig.UC_EXCHANGE_FANOUT; | 54 | exchangeName = RabbitMqConfig.UC_EXCHANGE_FANOUT; |
29 | } | 55 | } |
... | @@ -32,12 +58,25 @@ public class MessageProducer { | ... | @@ -32,12 +58,25 @@ public class MessageProducer { |
32 | } | 58 | } |
33 | 59 | ||
34 | /** | 60 | /** |
35 | * 广播 | 61 | * 直连 |
62 | * @param msg | ||
63 | * @param queueName | ||
64 | * @author XiangHan | ||
65 | * @date 2021/9/7 11:10 上午 | ||
66 | */ | ||
67 | private void sendDirectMessage(String msg,String queueName) { | ||
68 | |||
69 | amqpTemplate.convertAndSend(queueName, msg); | ||
70 | log.info("send sendFanoutMessage msg || entityType: {} || msg:{} ", msg); | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | * 发送 | ||
36 | * @param msg | 75 | * @param msg |
37 | * @author XiangHan | 76 | * @author XiangHan |
38 | * @date 2021/9/7 11:10 上午 | 77 | * @date 2021/9/7 11:10 上午 |
39 | */ | 78 | */ |
40 | public void sendFanoutMessage(String msg) { | 79 | public void sendMessage(String msg) { |
41 | this.sendFanoutMessage(msg,null); | 80 | this.sendMessage(msg,null); |
42 | } | 81 | } |
43 | } | 82 | } | ... | ... |
1 | package com.topdraw.util; | ||
2 | |||
3 | import java.nio.charset.StandardCharsets; | ||
4 | import java.util.Base64; | ||
5 | |||
6 | public class Base64Util { | ||
7 | |||
8 | public static String encode(String name){ | ||
9 | String name1 = new String(Base64.getEncoder().encode(name.getBytes(StandardCharsets.UTF_8))); | ||
10 | return name1; | ||
11 | } | ||
12 | |||
13 | public static void main(String[] args) { | ||
14 | // String name = "test005@itv"; | ||
15 | String name = "18580619168a@iptv"; | ||
16 | String encode = encode(name); | ||
17 | System.out.println(encode); | ||
18 | } | ||
19 | } |
... | @@ -15,5 +15,14 @@ public class RedissonUtil { | ... | @@ -15,5 +15,14 @@ public class RedissonUtil { |
15 | rLock.unlock(); | 15 | rLock.unlock(); |
16 | } | 16 | } |
17 | 17 | ||
18 | /** | ||
19 | * 保存数据 | ||
20 | * @param key 键 | ||
21 | * @param value 值 | ||
22 | * @param validTime 过期时间 | ||
23 | */ | ||
24 | public static void doSave(String key , String value , Integer validTime){ | ||
25 | |||
26 | } | ||
18 | 27 | ||
19 | } | 28 | } | ... | ... |
... | @@ -36,6 +36,10 @@ public class TimestampUtil { | ... | @@ -36,6 +36,10 @@ public class TimestampUtil { |
36 | return l; | 36 | return l; |
37 | } | 37 | } |
38 | 38 | ||
39 | public static LocalDateTime long2LocalDateTime(Long expireTime) { | ||
40 | return LocalDateTime.ofInstant(Instant.ofEpochMilli(expireTime),ZoneOffset.of("+8")); | ||
41 | } | ||
42 | |||
39 | public static void main(String[] args) { | 43 | public static void main(String[] args) { |
40 | long a = 1636616464000L; | 44 | long a = 1636616464000L; |
41 | long b = 1637046948588L; | 45 | long b = 1637046948588L; |
... | @@ -55,4 +59,6 @@ public class TimestampUtil { | ... | @@ -55,4 +59,6 @@ public class TimestampUtil { |
55 | long l1 = localDateTime2long(LocalDateTime.now()); | 59 | long l1 = localDateTime2long(LocalDateTime.now()); |
56 | System.out.println(l1); | 60 | System.out.println(l1); |
57 | } | 61 | } |
62 | |||
63 | |||
58 | } | 64 | } | ... | ... |
... | @@ -12,5 +12,25 @@ import org.springframework.test.context.junit4.SpringRunner; | ... | @@ -12,5 +12,25 @@ import org.springframework.test.context.junit4.SpringRunner; |
12 | public class BaseTest { | 12 | public class BaseTest { |
13 | 13 | ||
14 | public Logger LOG = LoggerFactory.getLogger(BaseTest.class); | 14 | public Logger LOG = LoggerFactory.getLogger(BaseTest.class); |
15 | private static String replaceUrl(String body, String ftpPath) { | ||
16 | boolean contains = body.contains("<source src="); | ||
17 | if (contains) { | ||
18 | body = body.replaceAll( "(<source src=(.*?)/>)","<source src="+"\""+ftpPath+"\"/>"); | ||
19 | } | ||
20 | return body; | ||
21 | } | ||
15 | 22 | ||
23 | public static void main(String[] args) { | ||
24 | String a = "<p>gfdsgf <video controls=\"controls\" width=\"300\" height=\"150\">\n" + | ||
25 | "<source src=\"dddd\" /></video></p>"; | ||
26 | |||
27 | String c = "<p>测试正文<br /><br /><video controls=\"controls\" width=\"360\" height=\"180\">\n" + | ||
28 | "<source src=\"test\" /></video></p>"; | ||
29 | |||
30 | |||
31 | |||
32 | String b = "{{nas-base-url.cms-upload}}/upload/commonFile/theme_activity/2021-12-15/aebd8dbb-87bb-4523-921f-4354c3298fdd.mp4"; | ||
33 | String s = replaceUrl(c, b); | ||
34 | System.out.println(s); | ||
35 | } | ||
16 | } | 36 | } | ... | ... |
... | @@ -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_member_group"; | 42 | var dbName = "uc_user_weixin"; |
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.member."; | 49 | var preRoute = "com.topdraw.business.basicdata.user."; |
50 | StringBuilder builder = new StringBuilder(preRoute); | 50 | StringBuilder builder = new StringBuilder(preRoute); |
51 | builder.append("group"); | 51 | builder.append("weixin"); |
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.member; | 1 | package com.topdraw.test.business.basicdata.member; |
2 | 2 | ||
3 | import com.topdraw.business.basicdata.member.rest.MemberController; | ||
3 | import com.topdraw.business.basicdata.member.service.MemberService; | 4 | import com.topdraw.business.basicdata.member.service.MemberService; |
4 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | 5 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; |
5 | import com.topdraw.BaseTest; | 6 | import com.topdraw.BaseTest; |
7 | import com.topdraw.common.ResultInfo; | ||
6 | import org.junit.Test; | 8 | import org.junit.Test; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 10 | ||
... | @@ -10,13 +12,14 @@ public class MemberServiceTest extends BaseTest { | ... | @@ -10,13 +12,14 @@ public class MemberServiceTest extends BaseTest { |
10 | 12 | ||
11 | @Autowired | 13 | @Autowired |
12 | private MemberService memberService; | 14 | private MemberService memberService; |
15 | @Autowired | ||
16 | private MemberController memberController; | ||
13 | 17 | ||
14 | @Test | 18 | @Test |
15 | public void findById(){ | 19 | public void findById(){ |
16 | Long memberId = 3L; | 20 | Long memberId = 1L; |
17 | MemberDTO memberDTO = this.memberService.findById(memberId); | 21 | ResultInfo memberDTO = this.memberController.findById(memberId); |
18 | LOG.info("=====>>>" + memberDTO); | 22 | LOG.info("=====>>>" + memberDTO); |
19 | |||
20 | } | 23 | } |
21 | 24 | ||
22 | } | 25 | } | ... | ... |
... | @@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; | ... | @@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.data.domain.PageRequest; | 11 | import org.springframework.data.domain.PageRequest; |
12 | import org.springframework.data.domain.Pageable; | 12 | import org.springframework.data.domain.Pageable; |
13 | 13 | ||
14 | import java.time.LocalDate; | ||
15 | |||
14 | //public class MemberControllerTest { | 16 | //public class MemberControllerTest { |
15 | public class MemberRelatedInfoControllerTest extends BaseTest { | 17 | public class MemberRelatedInfoControllerTest extends BaseTest { |
16 | 18 | ||
... | @@ -29,13 +31,15 @@ public class MemberRelatedInfoControllerTest extends BaseTest { | ... | @@ -29,13 +31,15 @@ public class MemberRelatedInfoControllerTest extends BaseTest { |
29 | @Test | 31 | @Test |
30 | public void update(){ | 32 | public void update(){ |
31 | MemberRelatedInfo member = new MemberRelatedInfo(); | 33 | MemberRelatedInfo member = new MemberRelatedInfo(); |
32 | member.setId(1L); | 34 | member.setId(15L); |
33 | // member.setMemberId(2L); | 35 | // member.setMemberId(2L); |
34 | member.setType(1); | 36 | member.setType(1); |
35 | member.setCellphone("18271269120"); | 37 | member.setCellphone("18271269120"); |
36 | member.setIdCard("422827199208010713"); | 38 | member.setIdCard("422827199208010713"); |
37 | member.setName("fdfd"); | 39 | member.setName("fdfd"); |
38 | member.setSex(1); | 40 | member.setSex(1); |
41 | member.setBirthday(LocalDate.of(2021,8,23)); | ||
42 | member.setAvatarUrl("www.sougou.com"); | ||
39 | // member.setCreateTime(); | 43 | // member.setCreateTime(); |
40 | // member.setUpdateTime(); | 44 | // member.setUpdateTime(); |
41 | String s = JSON.toJSONString(member); | 45 | String s = JSON.toJSONString(member); |
... | @@ -53,6 +57,8 @@ public class MemberRelatedInfoControllerTest extends BaseTest { | ... | @@ -53,6 +57,8 @@ public class MemberRelatedInfoControllerTest extends BaseTest { |
53 | member.setIdCard("422827199208010713"); | 57 | member.setIdCard("422827199208010713"); |
54 | member.setName("fdfd"); | 58 | member.setName("fdfd"); |
55 | member.setSex(1); | 59 | member.setSex(1); |
60 | member.setBirthday(LocalDate.now()); | ||
61 | member.setAvatarUrl("www.baidu.com"); | ||
56 | // member.setCreateTime(); | 62 | // member.setCreateTime(); |
57 | // member.setUpdateTime(); | 63 | // member.setUpdateTime(); |
58 | String s = JSON.toJSONString(member); | 64 | String s = JSON.toJSONString(member); | ... | ... |
... | @@ -12,6 +12,7 @@ import org.junit.Test; | ... | @@ -12,6 +12,7 @@ import org.junit.Test; |
12 | import org.springframework.beans.BeanUtils; | 12 | import org.springframework.beans.BeanUtils; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
14 | 14 | ||
15 | import java.time.LocalDateTime; | ||
15 | import java.util.List; | 16 | import java.util.List; |
16 | 17 | ||
17 | public class PointsAvailableServiceTest extends BaseTest { | 18 | public class PointsAvailableServiceTest extends BaseTest { |
... | @@ -23,7 +24,7 @@ public class PointsAvailableServiceTest extends BaseTest { | ... | @@ -23,7 +24,7 @@ public class PointsAvailableServiceTest extends BaseTest { |
23 | public void loadListExpirePointsByMemberId() { | 24 | public void loadListExpirePointsByMemberId() { |
24 | Long memberId = 2L; | 25 | Long memberId = 2L; |
25 | List<PointsAvailableDTO> pointsAvailableDTOS = | 26 | List<PointsAvailableDTO> pointsAvailableDTOS = |
26 | this.pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId, DateUtil.newDate()); | 27 | this.pointsAvailableService.findByMemberIdAndExpireTimeBefore(memberId, LocalDateTime.now()); |
27 | LOG.info("===>>>"+pointsAvailableDTOS); | 28 | LOG.info("===>>>"+pointsAvailableDTOS); |
28 | } | 29 | } |
29 | 30 | ||
... | @@ -52,7 +53,7 @@ public class PointsAvailableServiceTest extends BaseTest { | ... | @@ -52,7 +53,7 @@ public class PointsAvailableServiceTest extends BaseTest { |
52 | // tempPoints.setDescription("#"); | 53 | // tempPoints.setDescription("#"); |
53 | tempPoints.setEvtType(1); | 54 | tempPoints.setEvtType(1); |
54 | tempPoints.setPoints(10L); | 55 | tempPoints.setPoints(10L); |
55 | tempPoints.setExpireTime(TimestampUtil.now()); | 56 | tempPoints.setExpireTime(LocalDateTime.now()); |
56 | 57 | ||
57 | PointsAvailable pointsAvailable = new PointsAvailable(); | 58 | PointsAvailable pointsAvailable = new PointsAvailable(); |
58 | BeanUtils.copyProperties(tempPoints,pointsAvailable); | 59 | BeanUtils.copyProperties(tempPoints,pointsAvailable); | ... | ... |
... | @@ -12,6 +12,8 @@ import org.junit.Test; | ... | @@ -12,6 +12,8 @@ import org.junit.Test; |
12 | import org.springframework.beans.BeanUtils; | 12 | import org.springframework.beans.BeanUtils; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
14 | 14 | ||
15 | import java.time.LocalDateTime; | ||
16 | |||
15 | public class PointsDetailServiceTest extends BaseTest { | 17 | public class PointsDetailServiceTest extends BaseTest { |
16 | 18 | ||
17 | @Autowired | 19 | @Autowired |
... | @@ -36,7 +38,7 @@ public class PointsDetailServiceTest extends BaseTest { | ... | @@ -36,7 +38,7 @@ public class PointsDetailServiceTest extends BaseTest { |
36 | tempPoints.setDescription(""); | 38 | tempPoints.setDescription(""); |
37 | tempPoints.setEvtType(1); | 39 | tempPoints.setEvtType(1); |
38 | tempPoints.setPoints(10L); | 40 | tempPoints.setPoints(10L); |
39 | tempPoints.setExpireTime(TimestampUtil.now()); | 41 | tempPoints.setExpireTime(LocalDateTime.now()); |
40 | 42 | ||
41 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); | 43 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); |
42 | 44 | ... | ... |
... | @@ -12,6 +12,8 @@ import org.junit.Test; | ... | @@ -12,6 +12,8 @@ import org.junit.Test; |
12 | import org.springframework.beans.BeanUtils; | 12 | import org.springframework.beans.BeanUtils; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
14 | 14 | ||
15 | import java.time.LocalDateTime; | ||
16 | |||
15 | public class RightsServiceTest extends BaseTest { | 17 | public class RightsServiceTest extends BaseTest { |
16 | 18 | ||
17 | @Autowired | 19 | @Autowired |
... | @@ -36,7 +38,7 @@ public class RightsServiceTest extends BaseTest { | ... | @@ -36,7 +38,7 @@ public class RightsServiceTest extends BaseTest { |
36 | tempPoints.setDescription(""); | 38 | tempPoints.setDescription(""); |
37 | tempPoints.setEvtType(1); | 39 | tempPoints.setEvtType(1); |
38 | tempPoints.setPoints(10L); | 40 | tempPoints.setPoints(10L); |
39 | tempPoints.setExpireTime(TimestampUtil.now()); | 41 | tempPoints.setExpireTime(LocalDateTime.now()); |
40 | 42 | ||
41 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); | 43 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); |
42 | 44 | ... | ... |
... | @@ -9,6 +9,7 @@ import org.junit.Test; | ... | @@ -9,6 +9,7 @@ import org.junit.Test; |
9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | 10 | ||
11 | import java.sql.Timestamp; | 11 | import java.sql.Timestamp; |
12 | import java.time.LocalDateTime; | ||
12 | import java.util.ArrayList; | 13 | import java.util.ArrayList; |
13 | import java.util.List; | 14 | import java.util.List; |
14 | 15 | ||
... | @@ -30,7 +31,7 @@ public class CouponOperationControllerTest extends BaseTest { | ... | @@ -30,7 +31,7 @@ public class CouponOperationControllerTest extends BaseTest { |
30 | tempCoupon.setMemberId(2L); | 31 | tempCoupon.setMemberId(2L); |
31 | tempCoupon.setRightsSendStrategy(0); | 32 | tempCoupon.setRightsSendStrategy(0); |
32 | tempCoupon.setAccountId(2L); | 33 | tempCoupon.setAccountId(2L); |
33 | tempCoupon.setExpireTime(Timestamp.valueOf("2021-10-28 09:00:00")); | 34 | tempCoupon.setExpireTime(LocalDateTime.now()); |
34 | tempCoupon.setDeviceType(2); | 35 | tempCoupon.setDeviceType(2); |
35 | tempCoupon.setAppCode("WEI_XIN_GOLD_PANDA"); | 36 | tempCoupon.setAppCode("WEI_XIN_GOLD_PANDA"); |
36 | tempCoupon.setOrderId(null); | 37 | tempCoupon.setOrderId(null); | ... | ... |
... | @@ -11,6 +11,7 @@ import org.junit.Test; | ... | @@ -11,6 +11,7 @@ import org.junit.Test; |
11 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
12 | 12 | ||
13 | import java.sql.Timestamp; | 13 | import java.sql.Timestamp; |
14 | import java.time.LocalDateTime; | ||
14 | import java.util.ArrayList; | 15 | import java.util.ArrayList; |
15 | import java.util.List; | 16 | import java.util.List; |
16 | 17 | ||
... | @@ -28,7 +29,7 @@ public class ExpOperationControllerTest extends BaseTest { | ... | @@ -28,7 +29,7 @@ public class ExpOperationControllerTest extends BaseTest { |
28 | tempExp.setRewardExp(10L); | 29 | tempExp.setRewardExp(10L); |
29 | tempExp.setRightsSendStrategy(0); | 30 | tempExp.setRightsSendStrategy(0); |
30 | tempExp.setAccountId(userId); | 31 | tempExp.setAccountId(userId); |
31 | tempExp.setExpireTime(Timestamp.valueOf("2021-10-28 09:00:00")); | 32 | tempExp.setExpireTime(LocalDateTime.now()); |
32 | tempExp.setDeviceType(2); | 33 | tempExp.setDeviceType(2); |
33 | tempExp.setAppCode("WEI_XIN_GOLD_PANDA"); | 34 | tempExp.setAppCode("WEI_XIN_GOLD_PANDA"); |
34 | tempExp.setOrderId(null); | 35 | tempExp.setOrderId(null); | ... | ... |
... | @@ -15,6 +15,7 @@ import org.springframework.data.domain.PageRequest; | ... | @@ -15,6 +15,7 @@ import org.springframework.data.domain.PageRequest; |
15 | import org.springframework.data.domain.Pageable; | 15 | import org.springframework.data.domain.Pageable; |
16 | 16 | ||
17 | import java.sql.Timestamp; | 17 | import java.sql.Timestamp; |
18 | import java.time.LocalDateTime; | ||
18 | 19 | ||
19 | public class PointsOperationControllerTest extends BaseTest { | 20 | public class PointsOperationControllerTest extends BaseTest { |
20 | 21 | ||
... | @@ -24,19 +25,7 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -24,19 +25,7 @@ public class PointsOperationControllerTest extends BaseTest { |
24 | 25 | ||
25 | @Test | 26 | @Test |
26 | public void customPoints() { | 27 | public void customPoints() { |
27 | Long memberId = 2L; | 28 | Long memberId = 1L; |
28 | /*DataSyncMsg dataSyncMsg = new DataSyncMsg(); | ||
29 | dataSyncMsg.setEntityType(EntityType.MEMBER); | ||
30 | dataSyncMsg.setEventType(EventType.VIEWING); | ||
31 | DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); | ||
32 | msgData.setEvent(1); | ||
33 | msgData.setRemarks("remark"); | ||
34 | msgData.setMemberId(memberId); | ||
35 | msgData.setDeviceType(2); | ||
36 | |||
37 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); | ||
38 | dataSyncMsg.setMsgData(msgData);*/ | ||
39 | |||
40 | TempPoints tempPoints = new TempPoints(); | 29 | TempPoints tempPoints = new TempPoints(); |
41 | tempPoints.setMemberId(memberId); | 30 | tempPoints.setMemberId(memberId); |
42 | tempPoints.setPoints(1L); | 31 | tempPoints.setPoints(1L); |
... | @@ -45,7 +34,6 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -45,7 +34,6 @@ public class PointsOperationControllerTest extends BaseTest { |
45 | tempPoints.setPointsType(0); | 34 | tempPoints.setPointsType(0); |
46 | tempPoints.setMediaId(1L); | 35 | tempPoints.setMediaId(1L); |
47 | tempPoints.setDeviceType(1); | 36 | tempPoints.setDeviceType(1); |
48 | |||
49 | String s = JSON.toJSONString(tempPoints); | 37 | String s = JSON.toJSONString(tempPoints); |
50 | this.pointsOperationController.customPoints(tempPoints); | 38 | this.pointsOperationController.customPoints(tempPoints); |
51 | } | 39 | } |
... | @@ -53,12 +41,12 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -53,12 +41,12 @@ public class PointsOperationControllerTest extends BaseTest { |
53 | @Test | 41 | @Test |
54 | public void grantPointsByManual(){ | 42 | public void grantPointsByManual(){ |
55 | TempPoints tempPoints = new TempPoints(); | 43 | TempPoints tempPoints = new TempPoints(); |
56 | tempPoints.setMemberId(10L); | 44 | tempPoints.setMemberId(1L); |
57 | tempPoints.setPoints(10L); | 45 | tempPoints.setPoints(10L); |
58 | tempPoints.setPointsType(0); | 46 | tempPoints.setPointsType(0); |
59 | tempPoints.setRightsSendStrategy(0); | 47 | tempPoints.setRightsSendStrategy(0); |
60 | tempPoints.setAccountId(2L); | 48 | tempPoints.setAccountId(2L); |
61 | tempPoints.setExpireTime(Timestamp.valueOf("2021-11-27 09:00:00")); | 49 | tempPoints.setExpireTime(LocalDateTime.now()); |
62 | tempPoints.setDeviceType(2); | 50 | tempPoints.setDeviceType(2); |
63 | tempPoints.setAppCode("WEI_XIN_GOLD_PANDA"); | 51 | tempPoints.setAppCode("WEI_XIN_GOLD_PANDA"); |
64 | tempPoints.setOrderId(null); | 52 | tempPoints.setOrderId(null); |
... | @@ -67,6 +55,7 @@ public class PointsOperationControllerTest extends BaseTest { | ... | @@ -67,6 +55,7 @@ public class PointsOperationControllerTest extends BaseTest { |
67 | tempPoints.setItemId(null); | 55 | tempPoints.setItemId(null); |
68 | tempPoints.setDescription("系统发放"); | 56 | tempPoints.setDescription("系统发放"); |
69 | tempPoints.setEvtType(1); | 57 | tempPoints.setEvtType(1); |
58 | tempPoints.setActivityId(1L); | ||
70 | String s = JSON.toJSONString(tempPoints); | 59 | String s = JSON.toJSONString(tempPoints); |
71 | ResultInfo byId = this.pointsOperationController.grantPointsByManual(tempPoints); | 60 | ResultInfo byId = this.pointsOperationController.grantPointsByManual(tempPoints); |
72 | LOG.info("===>>>"+byId); | 61 | LOG.info("===>>>"+byId); | ... | ... |
... | @@ -9,6 +9,8 @@ import com.topdraw.util.TimestampUtil; | ... | @@ -9,6 +9,8 @@ import com.topdraw.util.TimestampUtil; |
9 | import org.junit.Test; | 9 | import org.junit.Test; |
10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | 11 | ||
12 | import java.time.LocalDateTime; | ||
13 | |||
12 | public class RightOperationControllerTest extends BaseTest { | 14 | public class RightOperationControllerTest extends BaseTest { |
13 | 15 | ||
14 | @Autowired | 16 | @Autowired |
... | @@ -21,7 +23,7 @@ public class RightOperationControllerTest extends BaseTest { | ... | @@ -21,7 +23,7 @@ public class RightOperationControllerTest extends BaseTest { |
21 | rightsHistory.setMemberId(3L); | 23 | rightsHistory.setMemberId(3L); |
22 | rightsHistory.setOperatorId(3L); | 24 | rightsHistory.setOperatorId(3L); |
23 | rightsHistory.setOperatorName("鲁二龙"); | 25 | rightsHistory.setOperatorName("鲁二龙"); |
24 | rightsHistory.setExpireTime(TimestampUtil.now()); | 26 | rightsHistory.setExpireTime(LocalDateTime.now()); |
25 | rightsHistory.setUserId(2L); | 27 | rightsHistory.setUserId(2L); |
26 | ResultInfo byId = this.rightsOperationController.grantRightsByManual(rightsHistory); | 28 | ResultInfo byId = this.rightsOperationController.grantRightsByManual(rightsHistory); |
27 | LOG.info("===>>>"+byId); | 29 | LOG.info("===>>>"+byId); | ... | ... |
-
Please register or sign in to post a comment