Commit 75d127a8 75d127a833a2c784c89ed5b9c0da62ab03fdc1ba by xianghan

Merge remote-tracking branch 'remotes/origin/1.1.0-STABLE' into master-copy

# Conflicts:
#	member-service-api/pom.xml
#	member-service-impl/.gitignore
#	member-service-impl/src/main/java/com/topdraw/business/basicdata/member/relatedinfo/rest/MemberRelatedInfoController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/coupon/history/rest/CouponHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/coupon/rest/CouponController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/exp/detail/rest/ExpDetailController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/exp/history/rest/ExpHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/address/rest/MemberAddressController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/group/rest/MemberGroupController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/level/rest/MemberLevelController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/profile/rest/MemberProfileController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/rest/MemberController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/available/rest/PointsAvailableController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/detail/detailhistory/rest/PointsDetailHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/detail/rest/PointsDetailController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/rest/PointsController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/standingbook/rest/PointsStandingBookController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/rights/history/rest/RightsHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/rights/permanentrights/rest/PermanentRightsController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/task/progress/rest/TrTaskProgressController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/task/rest/TaskController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/task/template/rest/TaskTemplateController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/user/iptv/rest/UserTvController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/user/weixin/rest/UserWeixinController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/CouponOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/ExpOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/PointsOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/TaskOperationController.java
#	member-service-impl/src/main/resources/config/application-dev.yml
2 parents 9ba9a1c0 3e7c3d3f
Showing 323 changed files with 8019 additions and 1340 deletions
...@@ -12,15 +12,21 @@ ...@@ -12,15 +12,21 @@
12 <artifactId>member-service-api</artifactId> 12 <artifactId>member-service-api</artifactId>
13 13
14 <properties> 14 <properties>
15 15 <cronos.version>1.1.0</cronos.version>
16 </properties> 16 </properties>
17 17
18 <dependencies> 18 <dependencies>
19 <!--代码生成器--> 19 <!--系统-->
20 <dependency> 20 <dependency>
21 <groupId>com.topdraw</groupId> 21 <groupId>com.topdraw</groupId>
22 <artifactId>cronos-system</artifactId> 22 <artifactId>cronos-system</artifactId>
23 <version>1.1.0</version> 23 <version>${cronos.version}</version>
24 </dependency>
25 <!--代码生成器-->
26 <dependency>
27 <groupId>com.topdraw</groupId>
28 <artifactId>cronos-generator</artifactId>
29 <version>${cronos.version}</version>
24 </dependency> 30 </dependency>
25 </dependencies> 31 </dependencies>
26 32
......
...@@ -25,6 +25,8 @@ public class DataSyncMsg implements Serializable { ...@@ -25,6 +25,8 @@ public class DataSyncMsg implements Serializable {
25 // 其他属性 25 // 其他属性
26 private String extraData; 26 private String extraData;
27 27
28 /** 模板参数 */
29 private TaskTemplateParam param;
28 30
29 /** 31 /**
30 * 消息体 32 * 消息体
...@@ -38,15 +40,29 @@ public class DataSyncMsg implements Serializable { ...@@ -38,15 +40,29 @@ public class DataSyncMsg implements Serializable {
38 private Integer event; // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 40 private Integer event; // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他
39 @NotNull 41 @NotNull
40 private Long memberId; // 会员id 42 private Long memberId; // 会员id
43 private Long userId; // 账户id
41 @NotNull 44 @NotNull
42 private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) 45 private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
43 @NotNull 46 @NotNull
44 private String appCode; //用户对应的应用code 47 private String appCode; //用户对应的应用code
48 private String memberCode;
45 private Long accountId; // 账号id 49 private Long accountId; // 账号id
46 private Long orderId; 50 private Long orderId;
47 private Long activityId; 51 private Long activityId;
48 private Long mediaId; 52 private Long mediaId;
49 private Long itemId; 53 private Long itemId;
54 private String param;
55
56 }
57
58 @Data
59 @AllArgsConstructor
60 @NoArgsConstructor
61 public static class TaskTemplateParam {
62 /** 类别 */
63 private String category;
64 /** 编码 */
65 private String code;
50 } 66 }
51 67
52 } 68 }
......
1 package com.topdraw.module.mq;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/2/3 22:46
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/2/3 22:46
11 */
12 public enum DeviceType {
13
14 IPTV(),
15 weixin();
16
17 }
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
2 /logs/ 2 /logs/
3 /member-service-impl.iml 3 /member-service-impl.iml
4 /src/main/resources/rebel.xml 4 /src/main/resources/rebel.xml
5 *.iml
...\ No newline at end of file ...\ No newline at end of file
5 /src/test/
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.topdraw; 1 package com.topdraw;
2 2
3
3 import com.topdraw.utils.SpringContextHolder; 4 import com.topdraw.utils.SpringContextHolder;
4 import org.springframework.boot.SpringApplication; 5 import org.springframework.boot.SpringApplication;
5 import org.springframework.boot.autoconfigure.SpringBootApplication; 6 import org.springframework.boot.autoconfigure.SpringBootApplication;
...@@ -12,7 +13,6 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing; ...@@ -12,7 +13,6 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
12 import org.springframework.retry.annotation.EnableRetry; 13 import org.springframework.retry.annotation.EnableRetry;
13 import org.springframework.scheduling.annotation.EnableAsync; 14 import org.springframework.scheduling.annotation.EnableAsync;
14 import org.springframework.transaction.annotation.EnableTransactionManagement; 15 import org.springframework.transaction.annotation.EnableTransactionManagement;
15 import org.springframework.web.bind.annotation.CrossOrigin;
16 16
17 /** 17 /**
18 * @author XiangHan 18 * @author XiangHan
...@@ -20,10 +20,10 @@ import org.springframework.web.bind.annotation.CrossOrigin; ...@@ -20,10 +20,10 @@ import org.springframework.web.bind.annotation.CrossOrigin;
20 */ 20 */
21 @EnableJpaAuditing 21 @EnableJpaAuditing
22 @EnableAsync 22 @EnableAsync
23 @SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
24 @EnableTransactionManagement 23 @EnableTransactionManagement
25 @EnableRetry 24 @EnableRetry
26 @EnableCaching 25 @EnableCaching
26 @SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
27 public class MemberServiceApplication extends SpringBootServletInitializer { 27 public class MemberServiceApplication extends SpringBootServletInitializer {
28 28
29 public static void main(String[] args) { 29 public static void main(String[] args) {
...@@ -39,4 +39,7 @@ public class MemberServiceApplication extends SpringBootServletInitializer { ...@@ -39,4 +39,7 @@ public class MemberServiceApplication extends SpringBootServletInitializer {
39 public SpringContextHolder springContextHolder() { 39 public SpringContextHolder springContextHolder() {
40 return new SpringContextHolder(); 40 return new SpringContextHolder();
41 } 41 }
42
42 } 43 }
44
45
......
1 package com.topdraw.business.module.common.domain;
2
3 import lombok.Data;
4 import lombok.experimental.Accessors;
5 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
6
7 import javax.persistence.Entity;
8 import javax.persistence.EntityListeners;
9 import javax.persistence.Transient;
10 import java.io.Serializable;
11
12 /**
13 * @author :
14 * @description:
15 * @function :
16 * @date :Created in 2022/2/10 10:12
17 * @version: :
18 * @modified By:
19 * @since : modified in 2022/2/10 10:12
20 */
21 @Data
22 @Accessors(chain = true)
23 public class DefaultAsyncMqModule {
24
25 @Transient
26 private String memberCode;
27
28 }
1 package com.topdraw.business.basicdata.coupon.domain; 1 package com.topdraw.business.module.coupon.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.coupon.history.domain; 1 package com.topdraw.business.module.coupon.history.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
...@@ -48,7 +48,7 @@ public class CouponHistory implements Serializable { ...@@ -48,7 +48,7 @@ public class CouponHistory implements Serializable {
48 48
49 // 领取时间 49 // 领取时间
50 @Column(name = "receive_time") 50 @Column(name = "receive_time")
51 private Timestamp receiveTime; 51 private LocalDateTime receiveTime;
52 52
53 // 失效时间 53 // 失效时间
54 @Column(name = "expire_time") 54 @Column(name = "expire_time")
...@@ -60,7 +60,7 @@ public class CouponHistory implements Serializable { ...@@ -60,7 +60,7 @@ public class CouponHistory implements Serializable {
60 60
61 // 使用时间 61 // 使用时间
62 @Column(name = "use_time") 62 @Column(name = "use_time")
63 private Timestamp useTime; 63 private LocalDateTime useTime;
64 64
65 // 订单详情id 65 // 订单详情id
66 @Column(name = "order_detail_id") 66 @Column(name = "order_detail_id")
...@@ -69,12 +69,12 @@ public class CouponHistory implements Serializable { ...@@ -69,12 +69,12 @@ public class CouponHistory implements Serializable {
69 // 创建时间 69 // 创建时间
70 @CreatedDate 70 @CreatedDate
71 @Column(name = "create_time") 71 @Column(name = "create_time")
72 private Timestamp createTime; 72 private LocalDateTime createTime;
73 73
74 // 更新时间 74 // 更新时间
75 @LastModifiedDate 75 @LastModifiedDate
76 @Column(name = "update_time") 76 @Column(name = "update_time")
77 private Timestamp updateTime; 77 private LocalDateTime updateTime;
78 78
79 public void copy(CouponHistory source){ 79 public void copy(CouponHistory source){
80 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); 80 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
......
1 package com.topdraw.business.basicdata.coupon.history.repository; 1 package com.topdraw.business.module.coupon.history.repository;
2 2
3 import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; 3 import com.topdraw.business.module.coupon.history.domain.CouponHistory;
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.sql.Timestamp; 7 import java.sql.Timestamp;
8 import java.util.Optional; 8 import java.time.LocalDateTime;
9 9
10 /** 10 /**
11 * @author XiangHan 11 * @author XiangHan
...@@ -15,7 +15,7 @@ public interface CouponHistoryRepository extends JpaRepository<CouponHistory, Lo ...@@ -15,7 +15,7 @@ public interface CouponHistoryRepository extends JpaRepository<CouponHistory, Lo
15 15
16 Long countByUserId(Long userId); 16 Long countByUserId(Long userId);
17 17
18 Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now); 18 Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now);
19 19
20 Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime); 20 Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime);
21 } 21 }
......
1 package com.topdraw.business.basicdata.coupon.history.rest; 1 package com.topdraw.business.module.coupon.history.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.coupon.history.domain.CouponHistory;
5 import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; 5 import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
6 import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService; 6 import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
7 import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 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; 9 import org.springframework.validation.annotation.Validated;
13 import org.springframework.web.bind.annotation.*; 10 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*; 11 import io.swagger.annotations.*;
15 import java.io.IOException;
16 import javax.servlet.http.HttpServletResponse;
17 12
18 /** 13 /**
19 * @author XiangHan 14 * @author XiangHan
...@@ -39,7 +34,6 @@ public class CouponHistoryController { ...@@ -39,7 +34,6 @@ public class CouponHistoryController {
39 return ResultInfo.success(CouponHistoryService.queryAll(criteria)); 34 return ResultInfo.success(CouponHistoryService.queryAll(criteria));
40 } 35 }
41 36
42 @Log
43 @PostMapping(value = "/create") 37 @PostMapping(value = "/create")
44 @ApiOperation("新增CouponHistory") 38 @ApiOperation("新增CouponHistory")
45 public ResultInfo create(@Validated @RequestBody CouponHistory resources) { 39 public ResultInfo create(@Validated @RequestBody CouponHistory resources) {
...@@ -47,7 +41,6 @@ public class CouponHistoryController { ...@@ -47,7 +41,6 @@ public class CouponHistoryController {
47 return ResultInfo.success(); 41 return ResultInfo.success();
48 } 42 }
49 43
50 @Log
51 @PutMapping(value = "/update") 44 @PutMapping(value = "/update")
52 @ApiOperation("修改CouponHistory") 45 @ApiOperation("修改CouponHistory")
53 public ResultInfo update(@Validated @RequestBody CouponHistory resources) { 46 public ResultInfo update(@Validated @RequestBody CouponHistory resources) {
...@@ -56,7 +49,6 @@ public class CouponHistoryController { ...@@ -56,7 +49,6 @@ public class CouponHistoryController {
56 } 49 }
57 50
58 51
59 @Log
60 @DeleteMapping(value = "/delete/{id}") 52 @DeleteMapping(value = "/delete/{id}")
61 @ApiOperation("删除CouponHistory") 53 @ApiOperation("删除CouponHistory")
62 public ResultInfo delete(@PathVariable Long id) { 54 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.coupon.history.service; 1 package com.topdraw.business.module.coupon.history.service;
2 2
3 import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; 3 import com.topdraw.business.module.coupon.history.domain.CouponHistory;
4 import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO; 4 import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
5 import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria; 5 import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 7
8 import java.sql.Timestamp; 8 import java.sql.Timestamp;
9 import java.time.LocalDateTime;
9 import java.util.Map; 10 import java.util.Map;
10 import java.util.List; 11 import java.util.List;
11 import java.io.IOException;
12 import javax.servlet.http.HttpServletResponse;
13 12
14 /** 13 /**
15 * @author XiangHan 14 * @author XiangHan
...@@ -47,7 +46,7 @@ public interface CouponHistoryService { ...@@ -47,7 +46,7 @@ public interface CouponHistoryService {
47 46
48 Long countByUserId(Long userId); 47 Long countByUserId(Long userId);
49 48
50 Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now); 49 Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now);
51 50
52 Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime); 51 Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime);
53 } 52 }
......
1 package com.topdraw.business.basicdata.coupon.history.service.dto; 1 package com.topdraw.business.module.coupon.history.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp;
5 import java.io.Serializable; 4 import java.io.Serializable;
6 import java.time.LocalDateTime; 5 import java.time.LocalDateTime;
7 6
...@@ -29,7 +28,7 @@ public class CouponHistoryDTO implements Serializable { ...@@ -29,7 +28,7 @@ public class CouponHistoryDTO implements Serializable {
29 private String userNickname; 28 private String userNickname;
30 29
31 // 领取时间 30 // 领取时间
32 private Timestamp receiveTime; 31 private LocalDateTime receiveTime;
33 32
34 // 失效时间 33 // 失效时间
35 private LocalDateTime expireTime; 34 private LocalDateTime expireTime;
...@@ -38,14 +37,14 @@ public class CouponHistoryDTO implements Serializable { ...@@ -38,14 +37,14 @@ public class CouponHistoryDTO implements Serializable {
38 private Integer useStatus; 37 private Integer useStatus;
39 38
40 // 使用时间 39 // 使用时间
41 private Timestamp useTime; 40 private LocalDateTime useTime;
42 41
43 // 订单详情id 42 // 订单详情id
44 private Long orderDetailId; 43 private Long orderDetailId;
45 44
46 // 创建时间 45 // 创建时间
47 private Timestamp createTime; 46 private LocalDateTime createTime;
48 47
49 // 更新时间 48 // 更新时间
50 private Timestamp updateTime; 49 private LocalDateTime updateTime;
51 } 50 }
......
1 package com.topdraw.business.basicdata.coupon.history.service.dto; 1 package com.topdraw.business.module.coupon.history.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import com.topdraw.annotation.Query;
5 4
6 /** 5 /**
7 * @author XiangHan 6 * @author XiangHan
......
1 package com.topdraw.business.basicdata.coupon.history.service.impl; 1 package com.topdraw.business.module.coupon.history.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; 4 import com.topdraw.business.module.coupon.history.domain.CouponHistory;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.coupon.history.repository.CouponHistoryRepository; 6 import com.topdraw.business.module.coupon.history.repository.CouponHistoryRepository;
7 import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService; 7 import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
8 import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO; 8 import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
9 import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria; 9 import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
10 import com.topdraw.business.basicdata.coupon.history.service.mapper.CouponHistoryMapper; 10 import com.topdraw.business.module.coupon.history.service.mapper.CouponHistoryMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
...@@ -20,6 +20,7 @@ import com.topdraw.utils.PageUtil; ...@@ -20,6 +20,7 @@ import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp; 20 import com.topdraw.utils.QueryHelp;
21 21
22 import java.sql.Timestamp; 22 import java.sql.Timestamp;
23 import java.time.LocalDateTime;
23 import java.util.List; 24 import java.util.List;
24 import java.util.Map; 25 import java.util.Map;
25 26
...@@ -87,12 +88,12 @@ public class CouponHistoryServiceImpl implements CouponHistoryService { ...@@ -87,12 +88,12 @@ public class CouponHistoryServiceImpl implements CouponHistoryService {
87 } 88 }
88 89
89 @Override 90 @Override
90 public Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now) { 91 public Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now) {
91 return this.CouponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now); 92 return this.CouponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now);
92 } 93 }
93 94
94 @Override 95 @Override
95 public Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime) { 96 public Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime) {
96 return this.CouponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime); 97 return this.CouponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime);
97 } 98 }
98 99
......
1 package com.topdraw.business.basicdata.coupon.history.service.mapper; 1 package com.topdraw.business.module.coupon.history.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; 4 import com.topdraw.business.module.coupon.history.domain.CouponHistory;
5 import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO; 5 import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.coupon.repository; 1 package com.topdraw.business.module.coupon.repository;
2 2
3 import com.topdraw.business.basicdata.coupon.domain.Coupon; 3 import com.topdraw.business.module.coupon.domain.Coupon;
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
......
1 package com.topdraw.business.basicdata.coupon.rest; 1 package com.topdraw.business.module.coupon.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.coupon.domain.Coupon;
5 import com.topdraw.business.basicdata.coupon.domain.Coupon; 5 import com.topdraw.business.module.coupon.service.CouponService;
6 import com.topdraw.business.basicdata.coupon.service.CouponService; 6 import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
7 import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated; 9 import org.springframework.validation.annotation.Validated;
...@@ -35,7 +34,6 @@ public class CouponController { ...@@ -35,7 +34,6 @@ public class CouponController {
35 return ResultInfo.success(CouponService.queryAll(criteria)); 34 return ResultInfo.success(CouponService.queryAll(criteria));
36 } 35 }
37 36
38 @Log
39 @PostMapping(value = "/create") 37 @PostMapping(value = "/create")
40 @ApiOperation("新增Coupon") 38 @ApiOperation("新增Coupon")
41 public ResultInfo create(@Validated @RequestBody Coupon resources) { 39 public ResultInfo create(@Validated @RequestBody Coupon resources) {
...@@ -43,7 +41,6 @@ public class CouponController { ...@@ -43,7 +41,6 @@ public class CouponController {
43 return ResultInfo.success(); 41 return ResultInfo.success();
44 } 42 }
45 43
46 @Log
47 @PutMapping(value = "/update") 44 @PutMapping(value = "/update")
48 @ApiOperation("修改Coupon") 45 @ApiOperation("修改Coupon")
49 public ResultInfo update(@Validated @RequestBody Coupon resources) { 46 public ResultInfo update(@Validated @RequestBody Coupon resources) {
...@@ -51,8 +48,6 @@ public class CouponController { ...@@ -51,8 +48,6 @@ public class CouponController {
51 return ResultInfo.success(); 48 return ResultInfo.success();
52 } 49 }
53 50
54
55 @Log
56 @DeleteMapping(value = "/delete/{id}") 51 @DeleteMapping(value = "/delete/{id}")
57 @ApiOperation("删除Coupon") 52 @ApiOperation("删除Coupon")
58 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.coupon.service; 1 package com.topdraw.business.module.coupon.service;
2 2
3 import com.topdraw.business.basicdata.coupon.domain.Coupon; 3 import com.topdraw.business.module.coupon.domain.Coupon;
4 import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; 4 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
5 import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria; 5 import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.coupon.service.dto; 1 package com.topdraw.business.module.coupon.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.coupon.service.dto; 1 package com.topdraw.business.module.coupon.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.coupon.service.impl; 1 package com.topdraw.business.module.coupon.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.coupon.domain.Coupon; 4 import com.topdraw.business.module.coupon.domain.Coupon;
5 import com.topdraw.util.RedissonUtil; 5 import com.topdraw.util.RedissonUtil;
6 import com.topdraw.utils.ValidationUtil; 6 import com.topdraw.utils.ValidationUtil;
7 import com.topdraw.business.basicdata.coupon.repository.CouponRepository; 7 import com.topdraw.business.module.coupon.repository.CouponRepository;
8 import com.topdraw.business.basicdata.coupon.service.CouponService; 8 import com.topdraw.business.module.coupon.service.CouponService;
9 import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; 9 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
10 import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria; 10 import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
11 import com.topdraw.business.basicdata.coupon.service.mapper.CouponMapper; 11 import com.topdraw.business.module.coupon.service.mapper.CouponMapper;
12 import org.redisson.api.RLock; 12 import org.redisson.api.RLock;
13 import org.redisson.api.RedissonClient; 13 import org.redisson.api.RedissonClient;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.business.basicdata.coupon.service.mapper; 1 package com.topdraw.business.module.coupon.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.coupon.domain.Coupon; 4 import com.topdraw.business.module.coupon.domain.Coupon;
5 import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; 5 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.exp.detail.domain; 1 package com.topdraw.business.module.exp.detail.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.exp.detail.repository; 1 package com.topdraw.business.module.exp.detail.repository;
2 2
3 import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; 3 import com.topdraw.business.module.exp.detail.domain.ExpDetail;
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
......
1 package com.topdraw.business.basicdata.exp.detail.rest; 1 package com.topdraw.business.module.exp.detail.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.exp.detail.domain.ExpDetail;
5 import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; 5 import com.topdraw.business.module.exp.detail.service.ExpDetailService;
6 import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService; 6 import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
7 import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated; 9 import org.springframework.validation.annotation.Validated;
...@@ -35,7 +34,6 @@ public class ExpDetailController { ...@@ -35,7 +34,6 @@ public class ExpDetailController {
35 return ResultInfo.success(ExpDetailService.queryAll(criteria)); 34 return ResultInfo.success(ExpDetailService.queryAll(criteria));
36 } 35 }
37 36
38 @Log
39 @PostMapping(value = "/create") 37 @PostMapping(value = "/create")
40 @ApiOperation("新增ExpDetail") 38 @ApiOperation("新增ExpDetail")
41 public ResultInfo create(@Validated @RequestBody ExpDetail resources) { 39 public ResultInfo create(@Validated @RequestBody ExpDetail resources) {
...@@ -43,7 +41,6 @@ public class ExpDetailController { ...@@ -43,7 +41,6 @@ public class ExpDetailController {
43 return ResultInfo.success(); 41 return ResultInfo.success();
44 } 42 }
45 43
46 @Log
47 @PutMapping(value = "/update") 44 @PutMapping(value = "/update")
48 @ApiOperation("修改ExpDetail") 45 @ApiOperation("修改ExpDetail")
49 public ResultInfo update(@Validated @RequestBody ExpDetail resources) { 46 public ResultInfo update(@Validated @RequestBody ExpDetail resources) {
...@@ -51,8 +48,6 @@ public class ExpDetailController { ...@@ -51,8 +48,6 @@ public class ExpDetailController {
51 return ResultInfo.success(); 48 return ResultInfo.success();
52 } 49 }
53 50
54
55 @Log
56 @DeleteMapping(value = "/delete/{id}") 51 @DeleteMapping(value = "/delete/{id}")
57 @ApiOperation("删除ExpDetail") 52 @ApiOperation("删除ExpDetail")
58 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.exp.detail.service; 1 package com.topdraw.business.module.exp.detail.service;
2 2
3 import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; 3 import com.topdraw.business.module.exp.detail.domain.ExpDetail;
4 import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO; 4 import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
5 import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria; 5 import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.exp.detail.service.dto; 1 package com.topdraw.business.module.exp.detail.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.exp.detail.service.dto; 1 package com.topdraw.business.module.exp.detail.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.exp.detail.service.impl; 1 package com.topdraw.business.module.exp.detail.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; 4 import com.topdraw.business.module.exp.detail.domain.ExpDetail;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.exp.detail.repository.ExpDetailRepository; 6 import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository;
7 import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService; 7 import com.topdraw.business.module.exp.detail.service.ExpDetailService;
8 import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO; 8 import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
9 import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria; 9 import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
10 import com.topdraw.business.basicdata.exp.detail.service.mapper.ExpDetailMapper; 10 import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper;
11 import org.redisson.api.RLock; 11 import org.redisson.api.RLock;
12 import org.redisson.api.RedissonClient; 12 import org.redisson.api.RedissonClient;
13 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.business.basicdata.exp.detail.service.mapper; 1 package com.topdraw.business.module.exp.detail.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; 4 import com.topdraw.business.module.exp.detail.domain.ExpDetail;
5 import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO; 5 import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.exp.history.domain; 1 package com.topdraw.business.module.exp.history.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.exp.history.repository; 1 package com.topdraw.business.module.exp.history.repository;
2 2
3 import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; 3 import com.topdraw.business.module.exp.history.domain.ExpHistory;
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
......
1 package com.topdraw.business.basicdata.exp.history.rest; 1 package com.topdraw.business.module.exp.history.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.exp.history.service.ExpHistoryService;
5 import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; 5 import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
6 import com.topdraw.business.basicdata.exp.history.service.ExpHistoryService;
7 import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 7 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*; 8 import org.springframework.web.bind.annotation.*;
12 import io.swagger.annotations.*; 9 import io.swagger.annotations.*;
13 10
......
1 package com.topdraw.business.basicdata.exp.history.service; 1 package com.topdraw.business.module.exp.history.service;
2 2
3 import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; 3 import com.topdraw.business.module.exp.history.domain.ExpHistory;
4 import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO; 4 import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO;
5 import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria; 5 import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.exp.history.service.dto; 1 package com.topdraw.business.module.exp.history.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.exp.history.service.dto; 1 package com.topdraw.business.module.exp.history.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.exp.history.service.impl; 1 package com.topdraw.business.module.exp.history.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; 4 import com.topdraw.business.module.exp.history.domain.ExpHistory;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.exp.history.repository.ExpHistoryRepository; 6 import com.topdraw.business.module.exp.history.repository.ExpHistoryRepository;
7 import com.topdraw.business.basicdata.exp.history.service.ExpHistoryService; 7 import com.topdraw.business.module.exp.history.service.ExpHistoryService;
8 import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO; 8 import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO;
9 import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria; 9 import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
10 import com.topdraw.business.basicdata.exp.history.service.mapper.ExpHistoryMapper; 10 import com.topdraw.business.module.exp.history.service.mapper.ExpHistoryMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
......
1 package com.topdraw.business.basicdata.exp.history.service.mapper; 1 package com.topdraw.business.module.exp.history.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; 4 import com.topdraw.business.module.exp.history.domain.ExpHistory;
5 import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO; 5 import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.member.address.domain; 1 package com.topdraw.business.module.member.address.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
...@@ -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
...@@ -90,12 +91,12 @@ public class MemberAddress implements Serializable { ...@@ -90,12 +91,12 @@ public class MemberAddress implements Serializable {
90 // 创建时间 91 // 创建时间
91 @CreatedDate 92 @CreatedDate
92 @Column(name = "create_time") 93 @Column(name = "create_time")
93 private Timestamp createTime; 94 private LocalDateTime createTime;
94 95
95 // 更新时间 96 // 更新时间
96 @LastModifiedDate 97 @LastModifiedDate
97 @Column(name = "update_time") 98 @Column(name = "update_time")
98 private Timestamp updateTime; 99 private LocalDateTime updateTime;
99 100
100 public void copy(MemberAddress source){ 101 public void copy(MemberAddress source){
101 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); 102 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
......
1 package com.topdraw.business.basicdata.member.address.repository; 1 package com.topdraw.business.module.member.address.repository;
2 2
3 import com.topdraw.business.basicdata.member.address.domain.MemberAddress; 3 import com.topdraw.business.module.member.address.domain.MemberAddress;
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
......
1 package com.topdraw.business.basicdata.member.address.rest; 1 package com.topdraw.business.module.member.address.rest;
2 2
3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.annotation.AnonymousAccess; 3 import com.topdraw.annotation.AnonymousAccess;
5 import com.topdraw.business.basicdata.member.service.MemberService; 4 import com.topdraw.business.module.member.service.MemberService;
6 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 5 import com.topdraw.business.module.member.service.dto.MemberDTO;
7 import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
8 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
9 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
10 import com.topdraw.aop.log.Log; 7 import com.topdraw.business.module.member.address.domain.MemberAddress;
11 import com.topdraw.business.basicdata.member.address.domain.MemberAddress; 8 import com.topdraw.business.module.member.address.service.MemberAddressService;
12 import com.topdraw.business.basicdata.member.address.service.MemberAddressService; 9 import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
13 import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; 10 import lombok.extern.slf4j.Slf4j;
14 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.data.domain.Pageable; 12 import org.springframework.data.domain.Pageable;
16 import org.springframework.util.Assert; 13 import org.springframework.util.Assert;
17 import org.springframework.util.Base64Utils;
18 import org.springframework.validation.annotation.Validated; 14 import org.springframework.validation.annotation.Validated;
19 import org.springframework.web.bind.annotation.*; 15 import org.springframework.web.bind.annotation.*;
20 import io.swagger.annotations.*; 16 import io.swagger.annotations.*;
21 17
22 import java.nio.charset.StandardCharsets;
23 import java.util.Base64;
24 import java.util.Objects; 18 import java.util.Objects;
25 19
26 /** 20 /**
...@@ -29,16 +23,15 @@ import java.util.Objects; ...@@ -29,16 +23,15 @@ import java.util.Objects;
29 */ 23 */
30 @Api(tags = "MemberAddress管理") 24 @Api(tags = "MemberAddress管理")
31 @RestController 25 @RestController
32 @RequestMapping("/api/MemberAddress") 26 @RequestMapping("/ucEngine/api/memberAddress")
33 @CrossOrigin 27 @CrossOrigin
28 @Slf4j
34 public class MemberAddressController { 29 public class MemberAddressController {
35 30
36 @Autowired 31 @Autowired
37 private MemberAddressService MemberAddressService; 32 private MemberAddressService MemberAddressService;
38 @Autowired 33 @Autowired
39 private MemberService memberService; 34 private MemberService memberService;
40 @Autowired
41 private UserTvService userTvService;
42 35
43 @GetMapping(value = "/pageMemberAddress") 36 @GetMapping(value = "/pageMemberAddress")
44 @ApiOperation("查询MemberAddress") 37 @ApiOperation("查询MemberAddress")
...@@ -52,50 +45,27 @@ public class MemberAddressController { ...@@ -52,50 +45,27 @@ public class MemberAddressController {
52 return ResultInfo.success(MemberAddressService.findById(id)); 45 return ResultInfo.success(MemberAddressService.findById(id));
53 } 46 }
54 47
55 @Log
56 @PostMapping(value = "/create") 48 @PostMapping(value = "/create")
57 @ApiOperation("新增MemberAddress") 49 @ApiOperation("新增MemberAddress")
58 public ResultInfo create(@Validated @RequestBody MemberAddress resources) {
59 MemberAddressService.create(resources);
60 return ResultInfo.success();
61 }
62
63 @Log
64 @PostMapping(value = "/createByPlatformAccount")
65 @ApiOperation("通过大屏账户创建会员地址")
66 @AnonymousAccess 50 @AnonymousAccess
67 public ResultInfo createByPlatformAccount(@RequestBody String contentDecode) { 51 public ResultInfo create(@Validated @RequestBody MemberAddress resources) {
68 byte[] bytes = contentDecode.getBytes(StandardCharsets.UTF_8); 52 log.info("MemberAddressController ==>> create ===>>[{}]",resources);
69 byte[] decode = Base64Utils.decode(bytes);
70 String content = new String(decode);
71 MemberAddress resources = JSONObject.parseObject(content,MemberAddress.class);
72 String platformAccount = resources.getPlatformAccount();
73 Assert.notNull(platformAccount,"platformAccount can't be null!");
74 53
75 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); 54 Long memberId = resources.getMemberId();
76 if (Objects.nonNull(userTvDTO) && Objects.nonNull(userTvDTO.getId())) { 55 MemberDTO memberDTO = this.memberService.findById(memberId);
77 Long memberId = userTvDTO.getMemberId(); 56 String code = memberDTO.getCode();
78 MemberDTO memberDTO = this.memberService.findById(memberId); 57 resources.setMemberCode(code);
79 String code = memberDTO.getCode(); 58 MemberAddressService.create(resources);
80 resources.setMemberCode(code);
81 resources.setMemberId(memberId);
82 resources.setCity("");
83 resources.setStatus(1);
84 resources.setContactor("");
85 resources.setCountry("cn");
86 resources.setDistrict("");
87 resources.setType(1);
88 resources.setIsDefault(2);
89 resources.setProvince("");
90 this.create(resources);
91 }
92 return ResultInfo.success(); 59 return ResultInfo.success();
93 } 60 }
94 61
95 @Log
96 @PutMapping(value = "/update") 62 @PutMapping(value = "/update")
97 @ApiOperation("修改MemberAddress") 63 @ApiOperation("修改MemberAddress")
64 @AnonymousAccess
98 public ResultInfo update(@Validated @RequestBody MemberAddress resources) { 65 public ResultInfo update(@Validated @RequestBody MemberAddress resources) {
66
67 log.info("MemberAddressController ==>> update ===>>[{}]",resources);
68
99 Long memberId = resources.getMemberId(); 69 Long memberId = resources.getMemberId();
100 Integer sequence = resources.getSequence(); 70 Integer sequence = resources.getSequence();
101 Assert.notNull(memberId,"memberId can't be null"); 71 Assert.notNull(memberId,"memberId can't be null");
...@@ -110,9 +80,9 @@ public class MemberAddressController { ...@@ -110,9 +80,9 @@ public class MemberAddressController {
110 return ResultInfo.success(); 80 return ResultInfo.success();
111 } 81 }
112 82
113 @Log
114 @DeleteMapping(value = "/delete/{id}") 83 @DeleteMapping(value = "/delete/{id}")
115 @ApiOperation("删除MemberAddress") 84 @ApiOperation("删除MemberAddress")
85 @AnonymousAccess
116 public ResultInfo delete(@PathVariable Long id) { 86 public ResultInfo delete(@PathVariable Long id) {
117 MemberAddressService.delete(id); 87 MemberAddressService.delete(id);
118 return ResultInfo.success(); 88 return ResultInfo.success();
......
1 package com.topdraw.business.basicdata.member.address.service; 1 package com.topdraw.business.module.member.address.service;
2 2
3 import com.topdraw.business.basicdata.member.address.domain.MemberAddress; 3 import com.topdraw.business.module.member.address.domain.MemberAddress;
4 import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO; 4 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
5 import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; 5 import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
...@@ -40,5 +40,4 @@ public interface MemberAddressService { ...@@ -40,5 +40,4 @@ public interface MemberAddressService {
40 void update(MemberAddress resources); 40 void update(MemberAddress resources);
41 41
42 void delete(Long id); 42 void delete(Long id);
43
44 } 43 }
......
1 package com.topdraw.business.basicdata.member.address.service.dto; 1 package com.topdraw.business.module.member.address.service.dto;
2 2
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 /**
...@@ -55,8 +56,8 @@ public class MemberAddressDTO implements Serializable { ...@@ -55,8 +56,8 @@ public class MemberAddressDTO implements Serializable {
55 private String zipCode; 56 private String zipCode;
56 57
57 // 创建时间 58 // 创建时间
58 private Timestamp createTime; 59 private LocalDateTime createTime;
59 60
60 // 更新时间 61 // 更新时间
61 private Timestamp updateTime; 62 private LocalDateTime updateTime;
62 } 63 }
......
1 package com.topdraw.business.basicdata.member.address.service.dto; 1 package com.topdraw.business.module.member.address.service.dto;
2 2
3 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data; 4 import lombok.Data;
......
1 package com.topdraw.business.basicdata.member.address.service.impl; 1 package com.topdraw.business.module.member.address.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.member.address.domain.MemberAddress; 4 import com.topdraw.business.module.member.address.domain.MemberAddress;
5 import com.topdraw.business.module.member.service.MemberService;
5 import com.topdraw.utils.ValidationUtil; 6 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.member.address.repository.MemberAddressRepository; 7 import com.topdraw.business.module.member.address.repository.MemberAddressRepository;
7 import com.topdraw.business.basicdata.member.address.service.MemberAddressService; 8 import com.topdraw.business.module.member.address.service.MemberAddressService;
8 import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO; 9 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
9 import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; 10 import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
10 import com.topdraw.business.basicdata.member.address.service.mapper.MemberAddressMapper; 11 import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 14 import org.springframework.transaction.annotation.Propagation;
......
1 package com.topdraw.business.basicdata.member.address.service.mapper; 1 package com.topdraw.business.module.member.address.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.member.address.domain.MemberAddress; 4 import com.topdraw.business.module.member.address.domain.MemberAddress;
5 import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO; 5 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.member.domain; 1 package com.topdraw.business.module.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;
7 import lombok.Data; 5 import lombok.Data;
8 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
9 import org.springframework.data.annotation.CreatedDate; 7 import org.springframework.data.annotation.CreatedDate;
...@@ -118,23 +116,23 @@ public class Member implements Serializable { ...@@ -118,23 +116,23 @@ public class Member implements Serializable {
118 116
119 /** iptv账号绑定时间 */ 117 /** iptv账号绑定时间 */
120 @Column(name = "bind_iptv_time") 118 @Column(name = "bind_iptv_time")
121 private Timestamp bindIptvTime; 119 private LocalDateTime bindIptvTime;
122 120
123 /** 创建时间 */ 121 /** 创建时间 */
124 @CreatedDate 122 @CreatedDate
125 @Column(name = "create_time") 123 @Column(name = "create_time")
126 private Timestamp createTime; 124 private LocalDateTime createTime;
127 125
128 /** 更新时间 */ 126 /** 更新时间 */
129 @LastModifiedDate 127 @LastModifiedDate
130 @Column(name = "update_time") 128 @Column(name = "update_time")
131 private Timestamp updateTime; 129 private LocalDateTime updateTime;
132 130
133 /** 是否在黑名单 1:是;0否 */ 131 /** 是否在黑名单 1:是;0否 */
134 @Column(name = "black_status") 132 @Column(name = "black_status")
135 private Long blackStatus; 133 private Long blackStatus;
136 134
137 public void copy(Member source){ 135 public void copy(Member source){
138 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); 136 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
139 } 137 }
140 } 138 }
......
1 package com.topdraw.business.module.member.domain;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions;
5 import com.topdraw.util.IdWorker;
6 import lombok.Data;
7 import lombok.experimental.Accessors;
8 import org.springframework.data.annotation.CreatedDate;
9 import org.springframework.data.annotation.LastModifiedDate;
10 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
11
12 import javax.persistence.*;
13 import java.io.Serializable;
14 import java.sql.Timestamp;
15 import java.time.LocalDateTime;
16
17 /**
18 * @author XiangHan
19 * @date 2021-10-22
20 */
21 public class MemberBuilder {
22
23 public static Member build(Integer type,String avatarUrl,String nickname,Integer vip){
24 Member member = new Member();
25 member.setType(type);
26 member.setBlackStatus(0L);
27 member.setGender(-1);
28 member.setVip(vip==null?0:vip);
29 member.setLevel(1);
30 member.setStatus(1);
31 member.setPoints(0L);
32 member.setDuePoints(0L);
33 member.setExp(0L);
34 member.setCouponAmount(0L);
35 member.setDueCouponAmount(0L);
36 member.setAvatarUrl(avatarUrl);
37 member.setCode(IdWorker.generator() + "");
38 member.setNickname(nickname);
39 return member;
40 }
41 }
1 package com.topdraw.business.module.member.domain;
2
3 public interface MemberConstant {
4
5 // vip等级
6 Integer vip[] = new Integer[]{0,1,2,3,4,5,6,7,8};
7
8 }
1 package com.topdraw.business.basicdata.member.group.domain; 1 package com.topdraw.business.module.member.group.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.member.group.repository; 1 package com.topdraw.business.module.member.group.repository;
2 2
3 import com.topdraw.business.basicdata.member.group.domain.MemberGroup; 3 import com.topdraw.business.module.member.group.domain.MemberGroup;
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
9 /** 7 /**
10 * @author XiangHan 8 * @author XiangHan
11 * @date 2021-11-17 9 * @date 2021-11-17
......
1 package com.topdraw.business.basicdata.member.group.rest; 1 package com.topdraw.business.module.member.group.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.member.group.domain.MemberGroup;
5 import com.topdraw.business.basicdata.member.group.domain.MemberGroup; 5 import com.topdraw.business.module.member.group.service.MemberGroupService;
6 import com.topdraw.business.basicdata.member.group.service.MemberGroupService; 6 import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
7 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 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; 9 import org.springframework.validation.annotation.Validated;
13 import org.springframework.web.bind.annotation.*; 10 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*; 11 import io.swagger.annotations.*;
15 import java.io.IOException;
16 import javax.servlet.http.HttpServletResponse;
17 12
18 /** 13 /**
19 * @author XiangHan 14 * @author XiangHan
...@@ -39,7 +34,6 @@ public class MemberGroupController { ...@@ -39,7 +34,6 @@ public class MemberGroupController {
39 return ResultInfo.success(MemberGroupService.queryAll(criteria)); 34 return ResultInfo.success(MemberGroupService.queryAll(criteria));
40 } 35 }
41 36
42 @Log
43 @PostMapping 37 @PostMapping
44 @ApiOperation("新增MemberGroup") 38 @ApiOperation("新增MemberGroup")
45 public ResultInfo create(@Validated @RequestBody MemberGroup resources) { 39 public ResultInfo create(@Validated @RequestBody MemberGroup resources) {
...@@ -47,7 +41,6 @@ public class MemberGroupController { ...@@ -47,7 +41,6 @@ public class MemberGroupController {
47 return ResultInfo.success(); 41 return ResultInfo.success();
48 } 42 }
49 43
50 @Log
51 @PutMapping 44 @PutMapping
52 @ApiOperation("修改MemberGroup") 45 @ApiOperation("修改MemberGroup")
53 public ResultInfo update(@Validated @RequestBody MemberGroup resources) { 46 public ResultInfo update(@Validated @RequestBody MemberGroup resources) {
...@@ -55,8 +48,6 @@ public class MemberGroupController { ...@@ -55,8 +48,6 @@ public class MemberGroupController {
55 return ResultInfo.success(); 48 return ResultInfo.success();
56 } 49 }
57 50
58
59 @Log
60 @DeleteMapping(value = "/{id}") 51 @DeleteMapping(value = "/{id}")
61 @ApiOperation("删除MemberGroup") 52 @ApiOperation("删除MemberGroup")
62 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.member.group.service; 1 package com.topdraw.business.module.member.group.service;
2 2
3 import com.topdraw.business.basicdata.member.group.domain.MemberGroup; 3 import com.topdraw.business.module.member.group.domain.MemberGroup;
4 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; 4 import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
5 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria; 5 import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
9 import java.io.IOException;
10 import javax.servlet.http.HttpServletResponse;
11 9
12 /** 10 /**
13 * @author XiangHan 11 * @author XiangHan
......
1 package com.topdraw.business.basicdata.member.group.service.dto; 1 package com.topdraw.business.module.member.group.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.member.group.service.dto; 1 package com.topdraw.business.module.member.group.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import com.topdraw.annotation.Query; 4 import com.topdraw.annotation.Query;
......
1 package com.topdraw.business.basicdata.member.group.service.impl; 1 package com.topdraw.business.module.member.group.service.impl;
2 2
3 import com.topdraw.business.basicdata.member.group.domain.MemberGroup; 3 import com.topdraw.business.module.member.group.domain.MemberGroup;
4 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.utils.FileUtil; 5 import com.topdraw.business.module.member.group.repository.MemberGroupRepository;
6 import com.topdraw.business.basicdata.member.group.repository.MemberGroupRepository; 6 import com.topdraw.business.module.member.group.service.MemberGroupService;
7 import com.topdraw.business.basicdata.member.group.service.MemberGroupService; 7 import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
8 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; 8 import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
9 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria; 9 import com.topdraw.business.module.member.group.service.mapper.MemberGroupMapper;
10 import com.topdraw.business.basicdata.member.group.service.mapper.MemberGroupMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 12 import org.springframework.transaction.annotation.Propagation;
...@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable; ...@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable;
18 import org.springframework.util.Assert; 17 import org.springframework.util.Assert;
19 import com.topdraw.utils.PageUtil; 18 import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp; 19 import com.topdraw.utils.QueryHelp;
21 import com.topdraw.utils.StringUtils;
22 20
23 import java.util.List; 21 import java.util.List;
24 import java.util.Map; 22 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 23
30 /** 24 /**
31 * @author XiangHan 25 * @author XiangHan
......
1 package com.topdraw.business.basicdata.member.group.service.mapper; 1 package com.topdraw.business.module.member.group.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.member.group.domain.MemberGroup; 4 import com.topdraw.business.module.member.group.domain.MemberGroup;
5 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; 5 import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.member.level.domain; 1 package com.topdraw.business.module.member.level.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.member.level.repository; 1 package com.topdraw.business.module.member.level.repository;
2 2
3 import com.topdraw.business.basicdata.member.level.domain.MemberLevel; 3 import com.topdraw.business.module.member.level.domain.MemberLevel;
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
......
1 package com.topdraw.business.basicdata.member.level.rest; 1 package com.topdraw.business.module.member.level.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.member.level.service.MemberLevelService;
5 import com.topdraw.business.basicdata.member.level.domain.MemberLevel; 5 import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
6 import com.topdraw.business.basicdata.member.level.service.MemberLevelService;
7 import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 7 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*; 8 import org.springframework.web.bind.annotation.*;
12 import io.swagger.annotations.*; 9 import io.swagger.annotations.*;
13 10
......
1 package com.topdraw.business.basicdata.member.level.service; 1 package com.topdraw.business.module.member.level.service;
2 2
3 import com.topdraw.business.basicdata.member.level.domain.MemberLevel; 3 import com.topdraw.business.module.member.level.domain.MemberLevel;
4 import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; 4 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
5 import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria; 5 import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.member.level.service.dto; 1 package com.topdraw.business.module.member.level.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.member.level.service.dto; 1 package com.topdraw.business.module.member.level.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.member.level.service.impl; 1 package com.topdraw.business.module.member.level.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.member.level.domain.MemberLevel; 4 import com.topdraw.business.module.member.level.domain.MemberLevel;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.member.level.repository.MemberLevelRepository; 6 import com.topdraw.business.module.member.level.repository.MemberLevelRepository;
7 import com.topdraw.business.basicdata.member.level.service.MemberLevelService; 7 import com.topdraw.business.module.member.level.service.MemberLevelService;
8 import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; 8 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
9 import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria; 9 import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
10 import com.topdraw.business.basicdata.member.level.service.mapper.MemberLevelMapper; 10 import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.cache.annotation.Cacheable;
13 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
14 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
15 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
......
1 package com.topdraw.business.basicdata.member.level.service.mapper; 1 package com.topdraw.business.module.member.level.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.member.level.domain.MemberLevel; 4 import com.topdraw.business.module.member.level.domain.MemberLevel;
5 import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; 5 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.member.profile; 1 package com.topdraw.business.module.member.profile;
2 2
3 public interface DoSaveMemberProfileGroup { 3 public interface DoSaveMemberProfileGroup {
4 } 4 }
......
1 package com.topdraw.business.basicdata.member.profile; 1 package com.topdraw.business.module.member.profile;
2 2
3 public interface DoUpdateMemberProfileGroup { 3 public interface DoUpdateMemberProfileGroup {
4 } 4 }
......
1 package com.topdraw.business.basicdata.member.profile.domain; 1 package com.topdraw.business.module.member.profile.domain;
2 2
3 import com.topdraw.business.basicdata.member.profile.DoSaveMemberProfileGroup; 3 import com.topdraw.business.module.member.profile.DoSaveMemberProfileGroup;
4 import com.topdraw.business.basicdata.member.profile.DoUpdateMemberProfileGroup; 4 import com.topdraw.business.module.member.profile.DoUpdateMemberProfileGroup;
5 import lombok.Data; 5 import lombok.Data;
6 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
7 import cn.hutool.core.bean.BeanUtil; 7 import cn.hutool.core.bean.BeanUtil;
...@@ -89,6 +89,10 @@ public class MemberProfile implements Serializable { ...@@ -89,6 +89,10 @@ public class MemberProfile implements Serializable {
89 @Column(name = "district") 89 @Column(name = "district")
90 private String district; 90 private String district;
91 91
92 //头像
93 @Transient
94 private String avatarUrl;
95
92 // 描述 96 // 描述
93 @Column(name = "description") 97 @Column(name = "description")
94 private String description; 98 private String description;
......
1 package com.topdraw.business.module.member.profile.domain;
2
3 import com.topdraw.utils.StringUtils;
4
5 import java.sql.Timestamp;
6 import java.util.Objects;
7
8 public class MemberProfileBuild {
9
10 public static MemberProfile build(Long memberId , String realname , Integer gender, Timestamp birthday){
11 MemberProfile memberProfile = build(memberId,realname,gender,"","","","","","",
12 "","","",birthday);
13 return memberProfile;
14 }
15
16 public static MemberProfile build(){
17 MemberProfile memberProfile = build(null,"",null,"","","","","","",
18 "","","",null);
19 return memberProfile;
20 }
21
22 public static MemberProfile build(Long memberId, String realName, Integer sex,
23 String contry, String district, String city, String idCard, String province,
24 String email, String description, String phone, String constellation,
25 Timestamp timestamp) {
26
27 if (memberId == null)
28 throw new NullPointerException("memberId is null");
29
30 MemberProfile memberProfile = new MemberProfile();
31 memberProfile.setMemberId(memberId);
32 memberProfile.setRealname(stringIsNull(realName));
33 memberProfile.setGender(sex == null ? 0 : sex);
34 memberProfile.setCountry(stringIsNull(contry));
35 memberProfile.setDistrict(stringIsNull(district));
36 memberProfile.setCity(stringIsNull(city));
37 memberProfile.setIdCard(stringIsNull(idCard));
38 memberProfile.setProvince(stringIsNull(province));
39 memberProfile.setEmail(stringIsNull(email));
40 memberProfile.setDescription(stringIsNull(description));
41 memberProfile.setPhone(stringIsNull(phone));
42 memberProfile.setConstellation(stringIsNull(constellation));
43 memberProfile.setBirthday(timestamp);
44
45 return memberProfile;
46 }
47
48 private static String stringIsNull(String s){
49 return StringUtils.isBlank(s)?"":s;
50 }
51
52 private static Object objectIsNull(Object s){
53 return Objects.nonNull(s)?null:s;
54 }
55
56 }
1 package com.topdraw.business.basicdata.member.profile.repository; 1 package com.topdraw.business.module.member.profile.repository;
2 2
3 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; 3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.profile.domain.MemberProfile;
4 import org.springframework.data.jpa.repository.JpaRepository; 5 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 7
...@@ -13,4 +14,6 @@ import java.util.Optional; ...@@ -13,4 +14,6 @@ import java.util.Optional;
13 public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> { 14 public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> {
14 15
15 Optional<MemberProfile> findByMemberId(Long memberId); 16 Optional<MemberProfile> findByMemberId(Long memberId);
17
18 Optional<MemberProfile> findFirstByMemberId(Long memberId);
16 } 19 }
......
1 package com.topdraw.business.basicdata.member.profile.rest; 1 package com.topdraw.business.module.member.profile.rest;
2 2
3 import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; 3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.basicdata.member.service.MemberService; 4 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
5 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 5 import com.topdraw.business.module.member.service.MemberService;
6 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.common.ResultInfo; 7 import com.topdraw.common.ResultInfo;
7 import com.topdraw.aop.log.Log; 8 import com.topdraw.business.module.member.profile.domain.MemberProfile;
8 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; 9 import com.topdraw.business.module.member.profile.service.MemberProfileService;
9 import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; 10 import com.topdraw.util.Base64Util;
10 import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria;
11 import com.topdraw.utils.StringUtils; 11 import com.topdraw.utils.StringUtils;
12 import lombok.extern.slf4j.Slf4j;
12 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.data.domain.Pageable;
14 import org.springframework.util.Assert; 14 import org.springframework.util.Assert;
15 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
16 import org.springframework.web.bind.annotation.*; 16 import org.springframework.web.bind.annotation.*;
...@@ -24,8 +24,9 @@ import java.util.Objects; ...@@ -24,8 +24,9 @@ import java.util.Objects;
24 */ 24 */
25 @Api(tags = "MemberProfile管理") 25 @Api(tags = "MemberProfile管理")
26 @RestController 26 @RestController
27 @RequestMapping("/api/MemberProfile") 27 @RequestMapping("/ucEngine/api/memberProfile")
28 @CrossOrigin 28 @CrossOrigin
29 @Slf4j
29 public class MemberProfileController { 30 public class MemberProfileController {
30 31
31 @Autowired 32 @Autowired
...@@ -45,18 +46,23 @@ public class MemberProfileController { ...@@ -45,18 +46,23 @@ public class MemberProfileController {
45 return ResultInfo.success(MemberProfileService.queryAll(criteria)); 46 return ResultInfo.success(MemberProfileService.queryAll(criteria));
46 }*/ 47 }*/
47 48
48 @Log
49 @PostMapping(value = "/create") 49 @PostMapping(value = "/create")
50 @ApiOperation("新增MemberProfile") 50 @ApiOperation("新增MemberProfile")
51 @AnonymousAccess
51 public ResultInfo create(@Validated @RequestBody MemberProfile resources) { 52 public ResultInfo create(@Validated @RequestBody MemberProfile resources) {
53 log.info("MemberProfileServiceImpl ==>> create ==>> resources ===>> [{}]",resources);
54 String realname = resources.getRealname();
52 MemberProfileService.create(resources); 55 MemberProfileService.create(resources);
53 return ResultInfo.success(); 56 return ResultInfo.success();
54 } 57 }
55 58
56 @Log
57 @PutMapping(value = "/update") 59 @PutMapping(value = "/update")
58 @ApiOperation("修改MemberProfile") 60 @ApiOperation("修改MemberProfile")
61 @AnonymousAccess
59 public ResultInfo update(@Validated @RequestBody MemberProfile resources) { 62 public ResultInfo update(@Validated @RequestBody MemberProfile resources) {
63
64 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
65
60 Long memberId = resources.getMemberId(); 66 Long memberId = resources.getMemberId();
61 Assert.notNull(memberId,"memberId can't be null"); 67 Assert.notNull(memberId,"memberId can't be null");
62 MemberDTO memberDTO = this.memberService.findById(memberId); 68 MemberDTO memberDTO = this.memberService.findById(memberId);
...@@ -77,8 +83,15 @@ public class MemberProfileController { ...@@ -77,8 +83,15 @@ public class MemberProfileController {
77 return ResultInfo.success(); 83 return ResultInfo.success();
78 } 84 }
79 85
86 @PutMapping
87 @ApiOperation("修改MemberProfile")
88 @AnonymousAccess
89 public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) {
90 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
91 this.MemberProfileService.updateMemberProfileAndMember(resources);
92 return ResultInfo.success();
93 }
80 94
81 @Log
82 @DeleteMapping(value = "/delete/{id}") 95 @DeleteMapping(value = "/delete/{id}")
83 @ApiOperation("删除MemberProfile") 96 @ApiOperation("删除MemberProfile")
84 public ResultInfo delete(@PathVariable Long id) { 97 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.member.profile.service; 1 package com.topdraw.business.module.member.profile.service;
2 2
3 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; 3 import com.topdraw.business.module.member.profile.domain.MemberProfile;
4 import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; 4 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
5 import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria; 5 import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
...@@ -35,11 +35,15 @@ public interface MemberProfileService { ...@@ -35,11 +35,15 @@ public interface MemberProfileService {
35 */ 35 */
36 MemberProfileDTO findById(Long id); 36 MemberProfileDTO findById(Long id);
37 37
38 void create(MemberProfile resources); 38 MemberProfile create(MemberProfile resources);
39
40 MemberProfile createDefault(MemberProfile resources);
39 41
40 void update(MemberProfile resources); 42 void update(MemberProfile resources);
41 43
42 void delete(Long id); 44 void delete(Long id);
43 45
44 MemberProfileDTO findByMemberId(Long memberId); 46 MemberProfileDTO findByMemberId(Long memberId);
47
48 void updateMemberProfileAndMember(MemberProfile resources);
45 } 49 }
......
1 package com.topdraw.business.basicdata.member.profile.service.dto; 1 package com.topdraw.business.module.member.profile.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
...@@ -21,21 +21,30 @@ public class MemberProfileDTO implements Serializable { ...@@ -21,21 +21,30 @@ public class MemberProfileDTO implements Serializable {
21 // 姓名 21 // 姓名
22 private String realname; 22 private String realname;
23 23
24 private String nickname;
25
24 // 性别 0:女; 1:男 -1:未知 26 // 性别 0:女; 1:男 -1:未知
25 private Integer gender; 27 private Integer gender;
26 28
27 // 生日 29 // 生日
28 private Timestamp birthday; 30 private Timestamp birthday;
29 31
32 // 生日字符串
33 private String birthdayStr;
34
35 // vip
36 private Integer vip;
37
30 // 星座 38 // 星座
31 private String constellation; 39 private String constellation;
32 40
33 // 身份证 41 private Long vipExpireTime;
34 private String idCard;
35 42
36 // 电话
37 private String phone; 43 private String phone;
38 44
45 // 身份证
46 private String idCard;
47
39 // 电子邮件 48 // 电子邮件
40 private String email; 49 private String email;
41 50
...@@ -48,6 +57,9 @@ public class MemberProfileDTO implements Serializable { ...@@ -48,6 +57,9 @@ public class MemberProfileDTO implements Serializable {
48 // 城市 57 // 城市
49 private String city; 58 private String city;
50 59
60 // 头像
61 private String avatarUrl;
62
51 // 区县 63 // 区县
52 private String district; 64 private String district;
53 65
......
1 package com.topdraw.business.basicdata.member.profile.service.dto; 1 package com.topdraw.business.module.member.profile.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.member.profile.service.impl; 1 package com.topdraw.business.module.member.profile.service.impl;
2 2
3 import cn.hutool.core.date.DateUtil;
3 import com.topdraw.aspect.AsyncMqSend; 4 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; 5 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.basicdata.member.service.MemberService; 6 import com.topdraw.business.module.member.profile.domain.MemberProfile;
6 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.member.profile.domain.MemberProfileBuild;
8 import com.topdraw.business.module.member.repository.MemberRepository;
9 import com.topdraw.business.module.member.service.MemberService;
10 import com.topdraw.utils.StringUtils;
7 import com.topdraw.utils.ValidationUtil; 11 import com.topdraw.utils.ValidationUtil;
8 import com.topdraw.business.basicdata.member.profile.repository.MemberProfileRepository; 12 import com.topdraw.business.module.member.profile.repository.MemberProfileRepository;
9 import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; 13 import com.topdraw.business.module.member.profile.service.MemberProfileService;
10 import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; 14 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
11 import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria; 15 import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
12 import com.topdraw.business.basicdata.member.profile.service.mapper.MemberProfileMapper; 16 import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper;
17 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
15 import org.springframework.transaction.annotation.Propagation; 20 import org.springframework.transaction.annotation.Propagation;
...@@ -21,6 +26,8 @@ import org.springframework.util.Assert; ...@@ -21,6 +26,8 @@ import org.springframework.util.Assert;
21 import com.topdraw.utils.PageUtil; 26 import com.topdraw.utils.PageUtil;
22 import com.topdraw.utils.QueryHelp; 27 import com.topdraw.utils.QueryHelp;
23 28
29 import java.nio.charset.StandardCharsets;
30 import java.util.Base64;
24 import java.util.List; 31 import java.util.List;
25 import java.util.Map; 32 import java.util.Map;
26 import java.util.Optional; 33 import java.util.Optional;
...@@ -31,13 +38,19 @@ import java.util.Optional; ...@@ -31,13 +38,19 @@ import java.util.Optional;
31 */ 38 */
32 @Service 39 @Service
33 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 40 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
41 @Slf4j
34 public class MemberProfileServiceImpl implements MemberProfileService { 42 public class MemberProfileServiceImpl implements MemberProfileService {
35 43
36 @Autowired 44 @Autowired
37 private MemberProfileRepository MemberProfileRepository; 45 private MemberProfileRepository MemberProfileRepository;
38 46
39 @Autowired 47 @Autowired
48 private MemberRepository memberRepository;
49
50 @Autowired
40 private MemberProfileMapper MemberProfileMapper; 51 private MemberProfileMapper MemberProfileMapper;
52 @Autowired
53 private MemberService memberService;
41 54
42 55
43 @Override 56 @Override
...@@ -61,17 +74,35 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -61,17 +74,35 @@ public class MemberProfileServiceImpl implements MemberProfileService {
61 @Override 74 @Override
62 @Transactional(rollbackFor = Exception.class) 75 @Transactional(rollbackFor = Exception.class)
63 @AsyncMqSend() 76 @AsyncMqSend()
64 public void create(MemberProfile resources) { 77 public MemberProfile create(MemberProfile resources) {
78 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
65 MemberProfileRepository.save(resources); 79 MemberProfileRepository.save(resources);
80 return resources;
81 }
82
83 @Override
84 public MemberProfile createDefault(MemberProfile resources) {
85
86 Long memberId = resources.getMemberId();
87 String realname = resources.getRealname();
88 Integer gender = resources.getGender();
89 MemberProfile memberProfile = MemberProfileBuild.build();
90 MemberProfile memberProfile1 = this.MemberProfileRepository.save(memberProfile);
91 return memberProfile1;
66 } 92 }
67 93
68 @Override 94 @Override
69 @Transactional(rollbackFor = Exception.class) 95 @Transactional(rollbackFor = Exception.class)
70 @AsyncMqSend() 96 @AsyncMqSend()
71 public void update(MemberProfile resources) { 97 public void update(MemberProfile resources) {
98
99 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
100
72 MemberProfile MemberProfile = MemberProfileRepository.findById(resources.getId()).orElseGet(MemberProfile::new); 101 MemberProfile MemberProfile = MemberProfileRepository.findById(resources.getId()).orElseGet(MemberProfile::new);
73 ValidationUtil.isNull( MemberProfile.getId(),"MemberProfile","id",resources.getId()); 102 ValidationUtil.isNull( MemberProfile.getId(),"MemberProfile","id",resources.getId());
74 MemberProfile.copy(resources); 103 MemberProfile.copy(resources);
104
105 log.info("MemberProfileServiceImpl ==>> update ==>> copy ===>> resources ===>> [{}]",resources);
75 MemberProfileRepository.save(MemberProfile); 106 MemberProfileRepository.save(MemberProfile);
76 } 107 }
77 108
...@@ -95,5 +126,37 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -95,5 +126,37 @@ public class MemberProfileServiceImpl implements MemberProfileService {
95 return null; 126 return null;
96 } 127 }
97 128
129 @Override
130 @Transactional(rollbackFor = Exception.class)
131 public void updateMemberProfileAndMember(MemberProfile resources) {
132 log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources);
133 String realname = resources.getRealname();
134 String nickNameStr = "";
135 if (StringUtils.isNotBlank(realname)) {
136 byte[] encode = Base64.getEncoder().encode(realname.getBytes(StandardCharsets.UTF_8));
137 nickNameStr = new String(encode);
138 resources.setRealname(nickNameStr);
139 }
140
141 if (StringUtils.isNotBlank(resources.getIdCard())) {
142 resources.setIdCard("000000000000000000");
143 }
144
145 this.MemberProfileRepository.save(resources);
146
147 //修改member相关信息
148 Long memberId = resources.getMemberId();
149 Member member = memberRepository.findById(memberId).orElseGet(Member::new);
150 ValidationUtil.isNull(member.getId(),"member","id", memberId);
151
152 member.setNickname(nickNameStr);
153 member.setGender(resources.getGender());
154 member.setBirthday(DateUtil.format(resources.getBirthday(), "yyyy-MM-dd"));
155 member.setAvatarUrl(resources.getAvatarUrl());
156
157 // memberRepository.save(member);
158 log.info("updateMemberProfileAndMember ==>> member ==>> [{}]",member);
159 memberService.update(member);
160 }
98 161
99 } 162 }
......
1 package com.topdraw.business.basicdata.member.profile.service.mapper; 1 package com.topdraw.business.module.member.profile.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; 4 import com.topdraw.business.module.member.profile.domain.MemberProfile;
5 import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; 5 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.member.relatedinfo.domain; 1 package com.topdraw.business.module.member.relatedinfo.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
5 import cn.hutool.core.bean.BeanUtil; 5 import cn.hutool.core.bean.BeanUtil;
6 import cn.hutool.core.bean.copier.CopyOptions; 6 import cn.hutool.core.bean.copier.CopyOptions;
7 import javax.persistence.*; 7 import javax.persistence.*;
8 import javax.validation.constraints.NotNull;
9
8 import org.springframework.data.annotation.CreatedDate; 10 import org.springframework.data.annotation.CreatedDate;
9 import org.springframework.data.annotation.LastModifiedDate; 11 import org.springframework.data.annotation.LastModifiedDate;
10 import org.springframework.data.jpa.domain.support.AuditingEntityListener; 12 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
...@@ -28,6 +30,7 @@ public class MemberRelatedInfo implements Serializable { ...@@ -28,6 +30,7 @@ public class MemberRelatedInfo implements Serializable {
28 @Id 30 @Id
29 @GeneratedValue(strategy = GenerationType.IDENTITY) 31 @GeneratedValue(strategy = GenerationType.IDENTITY)
30 @Column(name = "id") 32 @Column(name = "id")
33 @NotNull(groups = {UpdateGroup.class})
31 private Long id; 34 private Long id;
32 35
33 // 会员id 36 // 会员id
......
1 package com.topdraw.business.module.member.relatedinfo.domain;
2
3 public interface UpdateGroup {
4 }
1 package com.topdraw.business.basicdata.member.relatedinfo.repository; 1 package com.topdraw.business.module.member.relatedinfo.repository;
2 2
3 import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; 3 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
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
......
1 package com.topdraw.business.module.member.relatedinfo.rest;
2
3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.member.relatedinfo.domain.UpdateGroup;
5 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
6 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.common.ResultInfo;
9 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
10 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
11 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
12 import com.topdraw.exception.BadRequestException;
13 import com.topdraw.util.Base64Util;
14 import lombok.extern.slf4j.Slf4j;
15 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.data.domain.Pageable;
17 import org.springframework.util.Assert;
18 import org.springframework.util.StringUtils;
19 import org.springframework.validation.annotation.Validated;
20 import org.springframework.web.bind.annotation.*;
21 import io.swagger.annotations.*;
22
23 import java.util.Base64;
24 import java.util.Objects;
25
26 /**
27 * @author XiangHan
28 * @date 2021-10-22
29 */
30 @Slf4j
31 @Api(tags = "MemberRelatedInfo管理")
32 @RestController
33 @RequestMapping("/ucEngine/api/memberRelatedInfo")
34 @CrossOrigin
35 public class MemberRelatedInfoController {
36
37 @Autowired
38 private MemberRelatedInfoService MemberRelatedInfoService;
39 @Autowired
40 private MemberService memberService;
41
42 @GetMapping(value = "/pageMemberRelatedInfos")
43 @ApiOperation("查询MemberRelatedInfo")
44 public ResultInfo pageMemberRelatedInfos(@Validated MemberRelatedInfoQueryCriteria criteria, Pageable pageable) {
45 return ResultInfo.successPage(MemberRelatedInfoService.queryAll(criteria,pageable));
46 }
47
48 @PostMapping(value = "/create")
49 @ApiOperation("新增MemberRelatedInfo")
50 @AnonymousAccess
51 public ResultInfo create(@Validated @RequestBody MemberRelatedInfo resources) {
52 String name = resources.getName();
53 if (StringUtils.hasText(name)) {
54 String nickNameEncode = Base64Util.encode(name);
55 resources.setName(nickNameEncode);
56 }
57
58 MemberRelatedInfoService.create(resources);
59 return ResultInfo.success();
60 }
61
62 @PutMapping(value = "/update")
63 @ApiOperation("修改MemberRelatedInfo")
64 @AnonymousAccess
65 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberRelatedInfo resources) {
66
67 log.info("Param ===> resources ===> [{}]",resources);
68
69 String name = resources.getName();
70 if (StringUtils.hasText(name)) {
71 String nickNameEncode = Base64Util.encode(name);
72 resources.setName(nickNameEncode);
73 }
74
75 Long id = resources.getId();
76 MemberRelatedInfoDTO memberRelatedInfoDTO = this.MemberRelatedInfoService.findById(id);
77 if (memberRelatedInfoDTO.getId() != null) {
78 Long memberId = memberRelatedInfoDTO.getMemberId();
79 if (Objects.isNull(memberId)) {
80 log.info("id ==>> [{}]",id);
81 throw new BadRequestException("memberId is null! please check member info");
82 }
83
84 MemberDTO memberDTO = this.memberService.findById(memberId);
85 if (Objects.nonNull(memberDTO)) {
86 String code = memberDTO.getCode();
87 Assert.notNull(code,"code can't be null");
88 resources.setMemberCode(code);
89 MemberRelatedInfoService.update(resources);
90 }
91 }
92
93 return ResultInfo.success();
94 }
95
96 @GetMapping(value = "/findById/{id}")
97 @ApiOperation("查询指定MemberRelatedInfo")
98 public ResultInfo findById(@PathVariable("id") Long id) {
99 return ResultInfo.success(MemberRelatedInfoService.findById(id));
100 }
101
102 @DeleteMapping(value = "/delete/{id}")
103 @ApiOperation("删除MemberRelatedInfo")
104 @AnonymousAccess
105 public ResultInfo delete(@PathVariable Long id) {
106 MemberRelatedInfoService.delete(id);
107 return ResultInfo.success();
108 }
109
110 }
1 package com.topdraw.business.basicdata.member.relatedinfo.service; 1 package com.topdraw.business.module.member.relatedinfo.service;
2 2
3 import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; 3 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
4 import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO; 4 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
5 import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; 5 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.member.relatedinfo.service.dto; 1 package com.topdraw.business.module.member.relatedinfo.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
5 import javax.persistence.Column;
6 import java.sql.Timestamp; 5 import java.sql.Timestamp;
7 import java.io.Serializable; 6 import java.io.Serializable;
8 import java.time.LocalDate; 7 import java.time.LocalDate;
......
1 package com.topdraw.business.basicdata.member.relatedinfo.service.dto; 1 package com.topdraw.business.module.member.relatedinfo.service.dto;
2 2
3 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data; 4 import lombok.Data;
5 5
6 import javax.validation.constraints.NotNull;
7
8 /** 6 /**
9 * @author XiangHan 7 * @author XiangHan
10 * @date 2021-10-22 8 * @date 2021-10-22
......
1 package com.topdraw.business.basicdata.member.relatedinfo.service.impl; 1 package com.topdraw.business.module.member.relatedinfo.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; 4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.member.relatedinfo.repository.MemberRelatedInfoRepository; 6 import com.topdraw.business.module.member.relatedinfo.repository.MemberRelatedInfoRepository;
7 import com.topdraw.business.basicdata.member.relatedinfo.service.MemberRelatedInfoService; 7 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
8 import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO; 8 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
9 import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; 9 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
10 import com.topdraw.business.basicdata.member.relatedinfo.service.mapper.MemberRelatedInfoMapper; 10 import com.topdraw.business.module.member.relatedinfo.service.mapper.MemberRelatedInfoMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
......
1 package com.topdraw.business.basicdata.member.relatedinfo.service.mapper; 1 package com.topdraw.business.module.member.relatedinfo.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; 4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
5 import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO; 5 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.member.repository; 1 package com.topdraw.business.module.member.repository;
2 2
3 import com.topdraw.business.basicdata.member.domain.Member; 3 import com.topdraw.business.module.member.domain.Member;
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.List;
7 import java.util.Optional; 8 import java.util.Optional;
8 9
9 /** 10 /**
...@@ -13,4 +14,6 @@ import java.util.Optional; ...@@ -13,4 +14,6 @@ import java.util.Optional;
13 public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecificationExecutor<Member> { 14 public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecificationExecutor<Member> {
14 15
15 Optional<Member> findFirstByCode(String code); 16 Optional<Member> findFirstByCode(String code);
17
18 List<Member> findByUserIptvId(Long id);
16 } 19 }
......
1 package com.topdraw.business.basicdata.member.rest; 1 package com.topdraw.business.module.member.rest;
2
3 2
4 import com.topdraw.annotation.AnonymousAccess; 3 import com.topdraw.annotation.AnonymousAccess;
5 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.member.domain.Member;
6 import com.topdraw.business.basicdata.member.domain.Member; 5 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.basicdata.member.service.MemberService; 6 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.user.iptv.domain.UserTv;
9 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 8 import com.topdraw.business.process.service.UserOperationService;
10 import com.topdraw.business.process.service.UserTvOperationService;
11 import com.topdraw.common.ResultInfo; 9 import com.topdraw.common.ResultInfo;
12 import com.topdraw.util.Base64Util; 10 import com.topdraw.util.Base64Util;
13 import io.swagger.annotations.Api; 11 import io.swagger.annotations.Api;
...@@ -27,7 +25,7 @@ import java.util.Objects; ...@@ -27,7 +25,7 @@ import java.util.Objects;
27 */ 25 */
28 @Api(tags = "Member管理") 26 @Api(tags = "Member管理")
29 @RestController 27 @RestController
30 @RequestMapping("/api/member") 28 @RequestMapping("/ucEngine/api/member")
31 @CrossOrigin 29 @CrossOrigin
32 public class MemberController { 30 public class MemberController {
33 31
...@@ -35,9 +33,8 @@ public class MemberController { ...@@ -35,9 +33,8 @@ public class MemberController {
35 private MemberService memberService; 33 private MemberService memberService;
36 34
37 @Autowired 35 @Autowired
38 private UserTvOperationService userTvOperationService; 36 private UserOperationService userTvOperationService;
39 37
40 @Log
41 @GetMapping(value = "/findById/{id}") 38 @GetMapping(value = "/findById/{id}")
42 @ApiOperation("新增UserTv会员") 39 @ApiOperation("新增UserTv会员")
43 public ResultInfo findById(@PathVariable Long id) { 40 public ResultInfo findById(@PathVariable Long id) {
...@@ -45,10 +42,8 @@ public class MemberController { ...@@ -45,10 +42,8 @@ public class MemberController {
45 return ResultInfo.success(memberDTO); 42 return ResultInfo.success(memberDTO);
46 } 43 }
47 44
48 @Log
49 @PostMapping(value = "/createMemberByUserTv") 45 @PostMapping(value = "/createMemberByUserTv")
50 @ApiOperation("新增UserTv会员") 46 @ApiOperation("新增UserTv会员")
51 @AnonymousAccess
52 public ResultInfo createMemberByUserTv(@Validated @RequestBody UserTv resources) { 47 public ResultInfo createMemberByUserTv(@Validated @RequestBody UserTv resources) {
53 String platformAccount = resources.getPlatformAccount(); 48 String platformAccount = resources.getPlatformAccount();
54 Assert.notNull(platformAccount, "The given platformAccount must not be null!"); 49 Assert.notNull(platformAccount, "The given platformAccount must not be null!");
...@@ -56,15 +51,14 @@ public class MemberController { ...@@ -56,15 +51,14 @@ public class MemberController {
56 return ResultInfo.success(result); 51 return ResultInfo.success(result);
57 } 52 }
58 53
59 @Log
60 @PostMapping(value = "/create") 54 @PostMapping(value = "/create")
61 @ApiOperation("新增Member") 55 @ApiOperation("新增Member")
56 @AnonymousAccess
62 public ResultInfo create(@Validated @RequestBody Member resources) { 57 public ResultInfo create(@Validated @RequestBody Member resources) {
63 Long id = memberService.create(resources); 58 Long id = memberService.create(resources);
64 return ResultInfo.success(id); 59 return ResultInfo.success(id);
65 } 60 }
66 61
67 @Log
68 @PostMapping(value = "/doUpdateVip") 62 @PostMapping(value = "/doUpdateVip")
69 @ApiOperation("修改Member等级") 63 @ApiOperation("修改Member等级")
70 public ResultInfo doUpdateVip(@RequestBody Member member) { 64 public ResultInfo doUpdateVip(@RequestBody Member member) {
...@@ -72,9 +66,9 @@ public class MemberController { ...@@ -72,9 +66,9 @@ public class MemberController {
72 return ResultInfo.success(); 66 return ResultInfo.success();
73 } 67 }
74 68
75 @Log
76 @PutMapping(value = "/update") 69 @PutMapping(value = "/update")
77 @ApiOperation("修改Member") 70 @ApiOperation("修改Member")
71 @AnonymousAccess
78 public ResultInfo update(@Validated @RequestBody Member resources) { 72 public ResultInfo update(@Validated @RequestBody Member resources) {
79 Long memberId = resources.getId(); 73 Long memberId = resources.getId();
80 Assert.notNull(memberId,"memberId can't be null"); 74 Assert.notNull(memberId,"memberId can't be null");
...@@ -83,10 +77,6 @@ public class MemberController { ...@@ -83,10 +77,6 @@ public class MemberController {
83 String code = memberDTO.getCode(); 77 String code = memberDTO.getCode();
84 Assert.notNull(code, "code can't be null"); 78 Assert.notNull(code, "code can't be null");
85 resources.setCode(code); 79 resources.setCode(code);
86 String nickname = resources.getNickname();
87 if (!StringUtils.isEmpty(nickname)) {
88 resources.setNickname(Base64Util.encode(nickname));
89 }
90 memberService.update(resources); 80 memberService.update(resources);
91 } 81 }
92 return ResultInfo.success(); 82 return ResultInfo.success();
......
1 package com.topdraw.business.basicdata.member.service; 1 package com.topdraw.business.module.member.service;
2 2
3 import com.topdraw.business.basicdata.member.domain.Member; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; 5 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
6 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 6 import com.topdraw.business.module.member.service.dto.MemberDTO;
7 import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
7 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
9 import org.springframework.transaction.annotation.Transactional;
8 10
9 import java.util.List; 11 import java.util.List;
10 import java.util.Map; 12 import java.util.Map;
...@@ -37,10 +39,28 @@ public interface MemberService { ...@@ -37,10 +39,28 @@ public interface MemberService {
37 */ 39 */
38 MemberDTO findById(Long id); 40 MemberDTO findById(Long id);
39 41
42 /**
43 *
44 * @param resources
45 * @return
46 */
40 Long create(Member resources); 47 Long create(Member resources);
41 48
49 Member createAndReturnMember(Member resources);
50
51 /**
52 *
53 * @param resources
54 */
42 void update(Member resources); 55 void update(Member resources);
43 56
57
58 void unbind(Member resources);
59
60 /**
61 *
62 * @param id
63 */
44 void delete(Long id); 64 void delete(Long id);
45 65
46 /** 66 /**
...@@ -50,5 +70,11 @@ public interface MemberService { ...@@ -50,5 +70,11 @@ public interface MemberService {
50 */ 70 */
51 MemberDTO getByCode(String code); 71 MemberDTO getByCode(String code);
52 72
73 /**
74 *
75 * @param member
76 */
53 void doUpdateMemberPoints(Member member); 77 void doUpdateMemberPoints(Member member);
78
79 List<MemberDTO> findByUserIptvId(Long id);
54 } 80 }
......
1 package com.topdraw.business.basicdata.member.service.dto; 1 package com.topdraw.business.module.member.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
...@@ -14,6 +14,11 @@ import java.time.LocalDateTime; ...@@ -14,6 +14,11 @@ import java.time.LocalDateTime;
14 @Data 14 @Data
15 public class MemberDTO implements Serializable { 15 public class MemberDTO implements Serializable {
16 16
17 private String platformAccount;
18
19 // iptv绑定的主会员 0:否 1:是
20 private Integer iptvMajor;
21
17 // vip过期时间 22 // vip过期时间
18 private LocalDateTime vipExpireTime; 23 private LocalDateTime vipExpireTime;
19 24
...@@ -78,13 +83,13 @@ public class MemberDTO implements Serializable { ...@@ -78,13 +83,13 @@ public class MemberDTO implements Serializable {
78 private Integer bindIptvPlatformType; 83 private Integer bindIptvPlatformType;
79 84
80 // iptv账号绑定时间 85 // iptv账号绑定时间
81 private Timestamp bindIptvTime; 86 private LocalDateTime bindIptvTime;
82 87
83 // 创建时间 88 // 创建时间
84 private Timestamp createTime; 89 private LocalDateTime createTime;
85 90
86 // 更新时间 91 // 更新时间
87 private Timestamp updateTime; 92 private LocalDateTime updateTime;
88 93
89 // 是否在黑名单 1:是;0否 94 // 是否在黑名单 1:是;0否
90 private Long blackStatus; 95 private Long blackStatus;
......
1 package com.topdraw.business.basicdata.member.service.dto; 1 package com.topdraw.business.module.member.service.dto;
2 2
3 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data; 4 import lombok.Data;
......
1 package com.topdraw.business.basicdata.member.service.impl; 1 package com.topdraw.business.module.member.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.basicdata.member.repository.MemberRepository; 5 import com.topdraw.business.module.member.repository.MemberRepository;
6 import com.topdraw.business.basicdata.member.service.MemberService; 6 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; 8 import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
9 import com.topdraw.business.basicdata.member.service.mapper.MemberMapper; 9 import com.topdraw.business.module.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;
15 import com.topdraw.mq.config.RabbitMqConfig;
16 import com.topdraw.util.IdWorker; 10 import com.topdraw.util.IdWorker;
17 import com.topdraw.util.RedissonUtil; 11 import com.topdraw.util.RedissonUtil;
18 import com.topdraw.util.TimestampUtil;
19 import com.topdraw.utils.PageUtil; 12 import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp; 13 import com.topdraw.utils.QueryHelp;
21 import com.topdraw.utils.StringUtils; 14 import com.topdraw.utils.StringUtils;
...@@ -23,21 +16,15 @@ import com.topdraw.utils.ValidationUtil; ...@@ -23,21 +16,15 @@ import com.topdraw.utils.ValidationUtil;
23 import lombok.extern.slf4j.Slf4j; 16 import lombok.extern.slf4j.Slf4j;
24 import org.redisson.api.RLock; 17 import org.redisson.api.RLock;
25 import org.redisson.api.RedissonClient; 18 import org.redisson.api.RedissonClient;
26 import org.springframework.beans.BeanUtils;
27 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.cache.annotation.CacheConfig;
29 import org.springframework.cache.annotation.CacheEvict; 20 import org.springframework.cache.annotation.CacheEvict;
30 import org.springframework.cache.annotation.Cacheable;
31 import org.springframework.dao.EmptyResultDataAccessException; 21 import org.springframework.dao.EmptyResultDataAccessException;
32 import org.springframework.data.domain.Page; 22 import org.springframework.data.domain.Page;
33 import org.springframework.data.domain.Pageable; 23 import org.springframework.data.domain.Pageable;
34 import org.springframework.stereotype.Service; 24 import org.springframework.stereotype.Service;
35 import org.springframework.transaction.PlatformTransactionManager; 25 import org.springframework.transaction.PlatformTransactionManager;
36 import org.springframework.transaction.TransactionDefinition;
37 import org.springframework.transaction.TransactionStatus;
38 import org.springframework.transaction.annotation.Propagation; 26 import org.springframework.transaction.annotation.Propagation;
39 import org.springframework.transaction.annotation.Transactional; 27 import org.springframework.transaction.annotation.Transactional;
40 import org.springframework.transaction.support.DefaultTransactionDefinition;
41 import org.springframework.util.Assert; 28 import org.springframework.util.Assert;
42 29
43 import java.nio.charset.StandardCharsets; 30 import java.nio.charset.StandardCharsets;
...@@ -65,7 +52,7 @@ public class MemberServiceImpl implements MemberService { ...@@ -65,7 +52,7 @@ public class MemberServiceImpl implements MemberService {
65 PlatformTransactionManager platformTransactionManager; 52 PlatformTransactionManager platformTransactionManager;
66 53
67 @Autowired 54 @Autowired
68 private com.topdraw.business.basicdata.user.iptv.service.UserTvService UserTvService; 55 private com.topdraw.business.module.user.iptv.service.UserTvService UserTvService;
69 56
70 @Override 57 @Override
71 public Map<String, Object> queryAll(MemberQueryCriteria criteria, Pageable pageable) { 58 public Map<String, Object> queryAll(MemberQueryCriteria criteria, Pageable pageable) {
...@@ -80,7 +67,6 @@ public class MemberServiceImpl implements MemberService { ...@@ -80,7 +67,6 @@ public class MemberServiceImpl implements MemberService {
80 } 67 }
81 68
82 @Override 69 @Override
83 // @Cacheable(value = "member::memberId",key = "#p0")
84 public MemberDTO findById(Long id) { 70 public MemberDTO findById(Long id) {
85 Member member = memberRepository.findById(id).orElseGet(Member::new); 71 Member member = memberRepository.findById(id).orElseGet(Member::new);
86 ValidationUtil.isNull(member.getId(),"Member","id",id); 72 ValidationUtil.isNull(member.getId(),"Member","id",id);
...@@ -92,12 +78,20 @@ public class MemberServiceImpl implements MemberService { ...@@ -92,12 +78,20 @@ public class MemberServiceImpl implements MemberService {
92 @Transactional(rollbackFor = Exception.class) 78 @Transactional(rollbackFor = Exception.class)
93 @AsyncMqSend 79 @AsyncMqSend
94 public Long create(Member resources) { 80 public Long create(Member resources) {
95 log.info("start=====>>>>>resources======>>>>接收到的数据 --->>>> " + resources);
96 Member member = this.checkMemberData(resources); 81 Member member = this.checkMemberData(resources);
97 memberRepository.save(member); 82 memberRepository.save(member);
98 return member.getId(); 83 return member.getId();
99 } 84 }
100 85
86 @Override
87 @Transactional(rollbackFor = Exception.class)
88 @AsyncMqSend
89 public Member createAndReturnMember(Member resources) {
90 Member member = this.checkMemberData(resources);
91 memberRepository.save(member);
92 return resources;
93 }
94
101 private Member checkMemberData(Member member) { 95 private Member checkMemberData(Member member) {
102 Long defaultValue = 0L; 96 Long defaultValue = 0L;
103 String code = member.getCode(); 97 String code = member.getCode();
...@@ -119,18 +113,16 @@ public class MemberServiceImpl implements MemberService { ...@@ -119,18 +113,16 @@ public class MemberServiceImpl implements MemberService {
119 member.setDueCouponAmount(defaultValue); 113 member.setDueCouponAmount(defaultValue);
120 member.setBlackStatus(0L); 114 member.setBlackStatus(0L);
121 String nickname = member.getNickname(); 115 String nickname = member.getNickname();
122 if (StringUtils.isEmpty(nickname)) { 116 if (StringUtils.isNotEmpty(nickname)) {
123 nickname = "未设置"; 117 String base64Nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8)));
118 member.setNickname(base64Nickname);
124 } 119 }
125 String base64Nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8)));
126 member.setNickname(base64Nickname);
127 return member; 120 return member;
128 } 121 }
129 122
130 @Override 123 @Override
131 @Transactional(rollbackFor = Exception.class) 124 @Transactional(rollbackFor = Exception.class)
132 @AsyncMqSend() 125 @AsyncMqSend()
133 @CacheEvict(value = "member::memberId",key = "#p0.id")
134 public void update(Member resources) { 126 public void update(Member resources) {
135 RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString()); 127 RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
136 try { 128 try {
...@@ -147,6 +139,25 @@ public class MemberServiceImpl implements MemberService { ...@@ -147,6 +139,25 @@ public class MemberServiceImpl implements MemberService {
147 } 139 }
148 } 140 }
149 141
142 @Override
143 @Transactional(rollbackFor = Exception.class)
144 @AsyncMqSend()
145 public void unbind(Member resources) {
146 RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
147 try {
148 RedissonUtil.lock(rLock);
149 Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new);
150 ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId());
151 member.copy(resources);
152 this.save(member);
153 } catch (Exception e) {
154 e.printStackTrace();
155 throw e;
156 } finally {
157 RedissonUtil.unlock(rLock);
158 }
159 }
160
150 private void save(Member member){ 161 private void save(Member member){
151 memberRepository.save(member); 162 memberRepository.save(member);
152 } 163 }
...@@ -178,6 +189,7 @@ public class MemberServiceImpl implements MemberService { ...@@ -178,6 +189,7 @@ public class MemberServiceImpl implements MemberService {
178 } 189 }
179 190
180 @Override 191 @Override
192 @AsyncMqSend()
181 public void doUpdateMemberPoints(Member resources) { 193 public void doUpdateMemberPoints(Member resources) {
182 RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString()); 194 RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
183 try { 195 try {
...@@ -194,5 +206,11 @@ public class MemberServiceImpl implements MemberService { ...@@ -194,5 +206,11 @@ public class MemberServiceImpl implements MemberService {
194 } 206 }
195 } 207 }
196 208
209 @Override
210 public List<MemberDTO> findByUserIptvId(Long id) {
211 List<Member> memberList = this.memberRepository.findByUserIptvId(id);
212 return memberMapper.toDto(memberList);
213 }
214
197 215
198 } 216 }
......
1 package com.topdraw.business.basicdata.member.service.mapper; 1 package com.topdraw.business.module.member.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 5 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.module.member.viphistory.domain;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions;
5 import lombok.Data;
6 import lombok.experimental.Accessors;
7 import org.springframework.data.annotation.CreatedDate;
8 import org.springframework.data.annotation.LastModifiedDate;
9 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
10
11 import javax.persistence.*;
12 import java.io.Serializable;
13 import java.sql.Timestamp;
14 import java.time.LocalDateTime;
15
16 /**
17 * @author luerlong
18 * @date 2021-12-10
19 */
20 @Entity
21 @Data
22 @EntityListeners(AuditingEntityListener.class)
23 @Accessors(chain = true)
24 @Table(name="uc_member_vip_history")
25 public class MemberVipHistory implements Serializable {
26
27 // 主键
28 @Id
29 @GeneratedValue(strategy = GenerationType.IDENTITY)
30 @Column(name = "id")
31 private Long id;
32
33 // 会员id
34 @Column(name = "member_id")
35 private Long memberId;
36
37 // 会员vip等级
38 @Column(name = "vip")
39 private Integer vip;
40
41 // 修改之前vip等级
42 @Column(name = "before_vip")
43 private Integer beforeVip;
44
45 // vip失效时间
46 @Column(name = "vip_expire_time")
47 private LocalDateTime vipExpireTime;
48
49 // 状态 1正常 0已过期
50 @Column(name = "status")
51 private Integer status;
52
53 // 创建时间
54 @CreatedDate
55 @Column(name = "create_time")
56 private Timestamp createTime;
57
58 // 修改时间
59 @LastModifiedDate
60 @Column(name = "update_time")
61 private Timestamp updateTime;
62
63 public void copy(MemberVipHistory source){
64 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
65 }
66 }
1 package com.topdraw.business.module.member.viphistory.repository;
2
3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Query;
7
8 import java.time.LocalDateTime;
9 import java.util.Optional;
10
11 /**
12 * @author luerlong
13 * @date 2021-12-10
14 */
15 public interface MemberVipHistoryRepository extends JpaRepository<MemberVipHistory, Long>, JpaSpecificationExecutor<MemberVipHistory> {
16
17 @Query(value = "SELECT * FROM uc_member_vip_history " +
18 " WHERE vip_expire_time >= ?2 AND member_id = ?1 order by create_time desc limit 1 ", nativeQuery = true)
19 Optional<MemberVipHistory> findByTime(Long memberId, LocalDateTime nowTime);
20 }
1 package com.topdraw.business.module.member.viphistory.rest;
2
3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
4 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
5 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
6 import com.topdraw.common.ResultInfo;
7 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiOperation;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.data.domain.Pageable;
11 import org.springframework.validation.annotation.Validated;
12 import org.springframework.web.bind.annotation.*;
13
14 /**
15 * @author luerlong
16 * @date 2021-12-10
17 */
18 @Api(tags = "MemberVipHistory管理")
19 @RestController
20 @RequestMapping("/api/memberVipHistory")
21 public class MemberVipHistoryController {
22
23 @Autowired
24 private MemberVipHistoryService memberVipHistoryService;
25
26 @GetMapping
27 @ApiOperation("查询MemberVipHistory")
28 public ResultInfo getMemberVipHistorys(MemberVipHistoryQueryCriteria criteria, Pageable pageable) {
29 return ResultInfo.successPage(memberVipHistoryService.queryAll(criteria,pageable));
30 }
31
32 @GetMapping(value = "/all")
33 @ApiOperation("查询所有MemberVipHistory")
34 public ResultInfo getMemberVipHistorys(MemberVipHistoryQueryCriteria criteria) {
35 return ResultInfo.success(memberVipHistoryService.queryAll(criteria));
36 }
37
38 @PostMapping
39 @ApiOperation("新增MemberVipHistory")
40 public ResultInfo create(@Validated @RequestBody MemberVipHistory resources) {
41 memberVipHistoryService.create(resources);
42 return ResultInfo.success();
43 }
44
45 @PutMapping
46 @ApiOperation("修改MemberVipHistory")
47 public ResultInfo update(@Validated @RequestBody MemberVipHistory resources) {
48 memberVipHistoryService.update(resources);
49 return ResultInfo.success();
50 }
51
52 @DeleteMapping(value = "/{id}")
53 @ApiOperation("删除MemberVipHistory")
54 public ResultInfo delete(@PathVariable Long id) {
55 memberVipHistoryService.delete(id);
56 return ResultInfo.success();
57 }
58
59 }
1 package com.topdraw.business.module.member.viphistory.service;
2
3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
4 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
5 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
6 import org.springframework.data.domain.Pageable;
7
8 import java.time.LocalDateTime;
9 import java.util.List;
10 import java.util.Map;
11 import java.util.Optional;
12
13 /**
14 * @author luerlong
15 * @date 2021-12-10
16 */
17 public interface MemberVipHistoryService {
18
19 /**
20 * 查询数据分页
21 * @param criteria 条件参数
22 * @param pageable 分页参数
23 * @return Map<String,Object>
24 */
25 Map<String,Object> queryAll(MemberVipHistoryQueryCriteria criteria, Pageable pageable);
26
27 /**
28 * 查询所有数据不分页
29 * @param criteria 条件参数
30 * @return List<MemberVipHistoryDTO>
31 */
32 List<MemberVipHistoryDTO> queryAll(MemberVipHistoryQueryCriteria criteria);
33
34 /**
35 * 根据ID查询
36 * @param id ID
37 * @return MemberVipHistoryDTO
38 */
39 MemberVipHistoryDTO findById(Long id);
40
41 void create(MemberVipHistory resources);
42
43 void update(MemberVipHistory resources);
44
45 void delete(Long id);
46
47 MemberVipHistory findByTime(Long id, LocalDateTime nowTime);
48 }
1 package com.topdraw.business.module.member.viphistory.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6 import java.sql.Timestamp;
7 import java.time.LocalDateTime;
8
9
10 /**
11 * @author luerlong
12 * @date 2021-12-10
13 */
14 @Data
15 public class MemberVipHistoryDTO implements Serializable {
16
17 // 主键
18 private Long id;
19
20 // 会员id
21 private Long memberId;
22
23 // 会员vip等级
24 private Integer vip;
25
26 // 修改之前vip等级
27 private Integer beforeVip;
28
29 // vip失效时间
30 private LocalDateTime vipExpireTime;
31
32 // 状态 1正常 0已过期
33 private Integer status;
34
35 // 创建时间
36 private Timestamp createTime;
37
38 // 修改时间
39 private Timestamp updateTime;
40 }
1 package com.topdraw.business.module.member.viphistory.service.dto;
2
3 import lombok.Data;
4
5 /**
6 * @author luerlong
7 * @date 2021-12-10
8 */
9 @Data
10 public class MemberVipHistoryQueryCriteria {
11 }
1 package com.topdraw.business.module.member.viphistory.service.impl;
2
3
4 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
5 import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository;
6 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
7 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
8 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
9 import com.topdraw.business.module.member.viphistory.service.mapper.MemberVipHistoryMapper;
10 import com.topdraw.utils.PageUtil;
11 import com.topdraw.utils.QueryHelp;
12 import com.topdraw.utils.ValidationUtil;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.dao.EmptyResultDataAccessException;
15 import org.springframework.data.domain.Page;
16 import org.springframework.data.domain.Pageable;
17 import org.springframework.stereotype.Service;
18 import org.springframework.transaction.annotation.Propagation;
19 import org.springframework.transaction.annotation.Transactional;
20 import org.springframework.util.Assert;
21
22 import java.time.LocalDateTime;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Optional;
26
27 /**
28 * @author luerlong
29 * @date 2021-12-10
30 */
31 @Service
32 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
33 public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
34
35 @Autowired
36 private MemberVipHistoryRepository memberVipHistoryRepository;
37
38 @Autowired
39 private MemberVipHistoryMapper memberVipHistoryMapper;
40
41 @Override
42 public Map<String, Object> queryAll(MemberVipHistoryQueryCriteria criteria, Pageable pageable) {
43 Page<MemberVipHistory> page = memberVipHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
44 return PageUtil.toPage(page.map(memberVipHistoryMapper::toDto));
45 }
46
47 @Override
48 public List<MemberVipHistoryDTO> queryAll(MemberVipHistoryQueryCriteria criteria) {
49 return memberVipHistoryMapper.toDto(memberVipHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
50 }
51
52 @Override
53 public MemberVipHistoryDTO findById(Long id) {
54 MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseGet(MemberVipHistory::new);
55 ValidationUtil.isNull(memberVipHistory.getId(),"MemberVipHistory","id",id);
56 return memberVipHistoryMapper.toDto(memberVipHistory);
57 }
58
59 @Override
60 @Transactional(rollbackFor = Exception.class)
61 public void create(MemberVipHistory resources) {
62 memberVipHistoryRepository.save(resources);
63 }
64
65 @Override
66 @Transactional(rollbackFor = Exception.class)
67 public void update(MemberVipHistory resources) {
68 MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(resources.getId()).orElseGet(MemberVipHistory::new);
69 ValidationUtil.isNull( memberVipHistory.getId(),"MemberVipHistory","id",resources.getId());
70 memberVipHistory.copy(resources);
71 memberVipHistoryRepository.save(memberVipHistory);
72 }
73
74 @Override
75 @Transactional(rollbackFor = Exception.class)
76 public void delete(Long id) {
77 Assert.notNull(id, "The given id must not be null!");
78 MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseThrow(
79 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberVipHistory.class, id), 1));
80 memberVipHistoryRepository.delete(memberVipHistory);
81 }
82
83 @Override
84 public MemberVipHistory findByTime(Long memberId, LocalDateTime nowTime) {
85 MemberVipHistory memberVipHistory = this.memberVipHistoryRepository.findByTime(memberId, nowTime).orElseGet(MemberVipHistory::new);
86 return memberVipHistory;
87 }
88
89
90 }
1 package com.topdraw.business.module.member.viphistory.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
5 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author luerlong
11 * @date 2021-12-10
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface MemberVipHistoryMapper extends BaseMapper<MemberVipHistoryDTO, MemberVipHistory> {
15
16 }
1 package com.topdraw.business.basicdata.points.available.domain; 1 package com.topdraw.business.module.points.available.domain;
2 2
3 import com.fasterxml.jackson.annotation.JsonFormat; 3 import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
4 import lombok.Data; 4 import lombok.Data;
5 import lombok.experimental.Accessors; 5 import lombok.experimental.Accessors;
6 import cn.hutool.core.bean.BeanUtil; 6 import cn.hutool.core.bean.BeanUtil;
...@@ -11,7 +11,6 @@ import org.springframework.data.annotation.LastModifiedDate; ...@@ -11,7 +11,6 @@ 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.time.LocalDateTime;
14 import java.util.UUID;
15 14
16 import java.io.Serializable; 15 import java.io.Serializable;
17 16
...@@ -26,11 +25,7 @@ import java.io.Serializable; ...@@ -26,11 +25,7 @@ import java.io.Serializable;
26 @EntityListeners(AuditingEntityListener.class) 25 @EntityListeners(AuditingEntityListener.class)
27 @Accessors(chain = true) 26 @Accessors(chain = true)
28 @Table(name="uc_points_available") 27 @Table(name="uc_points_available")
29 public class PointsAvailable implements Serializable { 28 public class PointsAvailable extends DefaultAsyncMqModule implements Serializable {
30
31 /** 会员编号 */
32 @Transient
33 private String memberCode;
34 29
35 // 主键 30 // 主键
36 @Id 31 @Id
......
1 package com.topdraw.business.basicdata.points.available.repository; 1 package com.topdraw.business.module.points.available.repository;
2 2
3 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; 3 import com.topdraw.business.module.points.available.domain.PointsAvailable;
4 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 4 import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
5 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; 5 import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
6 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.JpaRepository;
7 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 7 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8 import org.springframework.data.jpa.repository.Modifying; 8 import org.springframework.data.jpa.repository.Modifying;
......
1 package com.topdraw.business.basicdata.points.available.rest; 1 package com.topdraw.business.module.points.available.rest;
2
3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log;
5 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
6 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
7 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
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 2
18 /** 3 /**
19 * @author XiangHan 4 * @author XiangHan
......
1 package com.topdraw.business.basicdata.points.available.service; 1 package com.topdraw.business.module.points.available.service;
2 2
3 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; 3 import com.topdraw.business.module.points.available.domain.PointsAvailable;
4 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 4 import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
5 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; 5 import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 7
8 import java.time.LocalDateTime; 8 import java.time.LocalDateTime;
9 import java.util.Date;
10 import java.util.Map; 9 import java.util.Map;
11 import java.util.List; 10 import java.util.List;
12 11
......
1 package com.topdraw.business.basicdata.points.available.service.dto; 1 package com.topdraw.business.module.points.available.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.points.available.service.dto; 1 package com.topdraw.business.module.points.available.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import com.topdraw.annotation.Query; 4 import com.topdraw.annotation.Query;
......
1 package com.topdraw.business.basicdata.points.available.service.dto; 1 package com.topdraw.business.module.points.available.service.dto;
2 2
3 public enum PointsAvailableQueryType { 3 public enum PointsAvailableQueryType {
4 4
......
1 package com.topdraw.business.basicdata.points.available.service.impl; 1 package com.topdraw.business.module.points.available.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; 4 import com.topdraw.business.module.points.available.domain.PointsAvailable;
5 import com.topdraw.util.RedissonUtil; 5 import com.topdraw.util.RedissonUtil;
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.module.points.available.repository.PointsAvailableRepository;
8 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; 8 import com.topdraw.business.module.points.available.service.PointsAvailableService;
9 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 9 import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
10 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; 10 import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
11 import com.topdraw.business.basicdata.points.available.service.mapper.PointsAvailableMapper; 11 import com.topdraw.business.module.points.available.service.mapper.PointsAvailableMapper;
12 import org.redisson.api.RLock; 12 import org.redisson.api.RLock;
13 import org.redisson.api.RedissonClient; 13 import org.redisson.api.RedissonClient;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
...@@ -23,11 +23,8 @@ import com.topdraw.utils.PageUtil; ...@@ -23,11 +23,8 @@ import com.topdraw.utils.PageUtil;
23 import com.topdraw.utils.QueryHelp; 23 import com.topdraw.utils.QueryHelp;
24 import com.topdraw.utils.StringUtils; 24 import com.topdraw.utils.StringUtils;
25 25
26 import java.sql.Timestamp;
27 import java.time.LocalDateTime; 26 import java.time.LocalDateTime;
28 import java.util.*; 27 import java.util.*;
29 import java.io.IOException;
30 import javax.servlet.http.HttpServletResponse;
31 28
32 /** 29 /**
33 * @author XiangHan 30 * @author XiangHan
......
1 package com.topdraw.business.basicdata.points.available.service.mapper; 1 package com.topdraw.business.module.points.available.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; 4 import com.topdraw.business.module.points.available.domain.PointsAvailable;
5 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 5 import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.domain; 1 package com.topdraw.business.module.points.detail.detailhistory.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.repository; 1 package com.topdraw.business.module.points.detail.detailhistory.repository;
2 2
3 import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory; 3 import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
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
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.rest; 1 package com.topdraw.business.module.points.detail.detailhistory.rest;
2 2
3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log;
5 import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory;
6 import com.topdraw.business.basicdata.points.detail.detailhistory.service.PointsDetailHistoryService;
7 import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*;
12 import io.swagger.annotations.*; 3 import io.swagger.annotations.*;
13 4
14 /** 5 /**
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.service; 1 package com.topdraw.business.module.points.detail.detailhistory.service;
2 2
3 import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory; 3 import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
4 import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO; 4 import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
5 import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria; 5 import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.service.dto; 1 package com.topdraw.business.module.points.detail.detailhistory.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.service.dto; 1 package com.topdraw.business.module.points.detail.detailhistory.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.service.impl; 1 package com.topdraw.business.module.points.detail.detailhistory.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory; 4 import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.points.detail.detailhistory.repository.PointsDetailHistoryRepository; 6 import com.topdraw.business.module.points.detail.detailhistory.repository.PointsDetailHistoryRepository;
7 import com.topdraw.business.basicdata.points.detail.detailhistory.service.PointsDetailHistoryService; 7 import com.topdraw.business.module.points.detail.detailhistory.service.PointsDetailHistoryService;
8 import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO; 8 import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
9 import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria; 9 import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
10 import com.topdraw.business.basicdata.points.detail.detailhistory.service.mapper.PointsDetailHistoryMapper; 10 import com.topdraw.business.module.points.detail.detailhistory.service.mapper.PointsDetailHistoryMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
......
1 package com.topdraw.business.basicdata.points.detail.detailhistory.service.mapper; 1 package com.topdraw.business.module.points.detail.detailhistory.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory; 4 import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
5 import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO; 5 import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.points.detail.domain; 1 package com.topdraw.business.module.points.detail.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.points.detail.repository; 1 package com.topdraw.business.module.points.detail.repository;
2 2
3 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; 3 import com.topdraw.business.module.points.detail.domain.PointsDetail;
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.Date;
8 import java.util.List; 7 import java.util.List;
9 import java.util.Optional; 8 import java.util.Optional;
10 9
......
1 package com.topdraw.business.basicdata.points.detail.rest; 1 package com.topdraw.business.module.points.detail.rest;
2 2
3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log;
5 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
6 import com.topdraw.business.basicdata.points.detail.service.PointsDetailService;
7 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*;
12 import io.swagger.annotations.*; 3 import io.swagger.annotations.*;
13 4
14 /** 5 /**
......
1 package com.topdraw.business.basicdata.points.detail.service; 1 package com.topdraw.business.module.points.detail.service;
2 2
3 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 3 import com.topdraw.business.module.points.detail.domain.PointsDetail;
4 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; 4 import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO;
5 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailDTO; 5 import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria;
6 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
7 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
8 7
9 import java.util.Date;
10 import java.util.Map; 8 import java.util.Map;
11 import java.util.List; 9 import java.util.List;
12 10
......
1 package com.topdraw.business.basicdata.points.detail.service.dto; 1 package com.topdraw.business.module.points.detail.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.points.detail.service.dto; 1 package com.topdraw.business.module.points.detail.service.dto;
2 2
3 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data; 4 import lombok.Data;
......
1 package com.topdraw.business.basicdata.points.detail.service.impl; 1 package com.topdraw.business.module.points.detail.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; 4 import com.topdraw.business.module.points.detail.domain.PointsDetail;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.points.detail.repository.PointsDetailRepository; 6 import com.topdraw.business.module.points.detail.repository.PointsDetailRepository;
7 import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; 7 import com.topdraw.business.module.points.detail.service.PointsDetailService;
8 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailDTO; 8 import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO;
9 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria; 9 import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria;
10 import com.topdraw.business.basicdata.points.detail.service.mapper.PointsDetailMapper; 10 import com.topdraw.business.module.points.detail.service.mapper.PointsDetailMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
...@@ -20,7 +20,6 @@ import com.topdraw.utils.PageUtil; ...@@ -20,7 +20,6 @@ import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp; 20 import com.topdraw.utils.QueryHelp;
21 import com.topdraw.utils.StringUtils; 21 import com.topdraw.utils.StringUtils;
22 22
23 import java.util.Date;
24 import java.util.List; 23 import java.util.List;
25 import java.util.Map; 24 import java.util.Map;
26 import java.util.Objects; 25 import java.util.Objects;
......
1 package com.topdraw.business.basicdata.points.detail.service.mapper; 1 package com.topdraw.business.module.points.detail.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; 4 import com.topdraw.business.module.points.detail.domain.PointsDetail;
5 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailDTO; 5 import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.points.domain; 1 package com.topdraw.business.module.points.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.points.repository; 1 package com.topdraw.business.module.points.repository;
2 2
3 import com.topdraw.business.basicdata.points.domain.Points; 3 import com.topdraw.business.module.points.domain.Points;
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
......
1 package com.topdraw.business.basicdata.points.rest; 1 package com.topdraw.business.module.points.rest;
2 2
3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log;
5 import com.topdraw.business.basicdata.points.domain.Points;
6 import com.topdraw.business.basicdata.points.service.PointsService;
7 import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*;
12 import io.swagger.annotations.*; 3 import io.swagger.annotations.*;
13 4
14 /** 5 /**
......
1 package com.topdraw.business.basicdata.points.service; 1 package com.topdraw.business.module.points.service;
2 2
3 import com.topdraw.business.basicdata.points.domain.Points; 3 import com.topdraw.business.module.points.domain.Points;
4 import com.topdraw.business.basicdata.points.service.dto.PointsDTO; 4 import com.topdraw.business.module.points.service.dto.PointsDTO;
5 import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria; 5 import com.topdraw.business.module.points.service.dto.PointsQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.points.service.dto; 1 package com.topdraw.business.module.points.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.points.service.dto; 1 package com.topdraw.business.module.points.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.points.service.impl; 1 package com.topdraw.business.module.points.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.points.domain.Points; 4 import com.topdraw.business.module.points.domain.Points;
5 import com.topdraw.util.RedissonUtil; 5 import com.topdraw.util.RedissonUtil;
6 import com.topdraw.utils.ValidationUtil; 6 import com.topdraw.utils.ValidationUtil;
7 import com.topdraw.business.basicdata.points.repository.PointsRepository; 7 import com.topdraw.business.module.points.repository.PointsRepository;
8 import com.topdraw.business.basicdata.points.service.PointsService; 8 import com.topdraw.business.module.points.service.PointsService;
9 import com.topdraw.business.basicdata.points.service.dto.PointsDTO; 9 import com.topdraw.business.module.points.service.dto.PointsDTO;
10 import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria; 10 import com.topdraw.business.module.points.service.dto.PointsQueryCriteria;
11 import com.topdraw.business.basicdata.points.service.mapper.PointsMapper; 11 import com.topdraw.business.module.points.service.mapper.PointsMapper;
12 import org.redisson.api.RLock; 12 import org.redisson.api.RLock;
13 import org.redisson.api.RedissonClient; 13 import org.redisson.api.RedissonClient;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.business.basicdata.points.service.mapper; 1 package com.topdraw.business.module.points.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.points.domain.Points; 4 import com.topdraw.business.module.points.domain.Points;
5 import com.topdraw.business.basicdata.points.service.dto.PointsDTO; 5 import com.topdraw.business.module.points.service.dto.PointsDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.points.standingbook.domain; 1 package com.topdraw.business.module.points.standingbook.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.points.standingbook.repository; 1 package com.topdraw.business.module.points.standingbook.repository;
2 2
3 import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook; 3 import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
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
9 /** 7 /**
10 * @author XiangHan 8 * @author XiangHan
11 * @date 2021-10-29 9 * @date 2021-10-29
......
1 package com.topdraw.business.basicdata.points.standingbook.rest; 1 package com.topdraw.business.module.points.standingbook.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
5 import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook; 5 import com.topdraw.business.module.points.standingbook.service.PointsStandingBookService;
6 import com.topdraw.business.basicdata.points.standingbook.service.PointsStandingBookService; 6 import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
7 import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 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; 9 import org.springframework.validation.annotation.Validated;
13 import org.springframework.web.bind.annotation.*; 10 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*; 11 import io.swagger.annotations.*;
15 import java.io.IOException;
16 import javax.servlet.http.HttpServletResponse;
17 12
18 /** 13 /**
19 * @author XiangHan 14 * @author XiangHan
...@@ -39,7 +34,6 @@ public class PointsStandingBookController { ...@@ -39,7 +34,6 @@ public class PointsStandingBookController {
39 return ResultInfo.success(PointsStandingBookService.queryAll(criteria)); 34 return ResultInfo.success(PointsStandingBookService.queryAll(criteria));
40 } 35 }
41 36
42 @Log
43 @PostMapping 37 @PostMapping
44 @ApiOperation("新增PointsStandingBook") 38 @ApiOperation("新增PointsStandingBook")
45 public ResultInfo create(@Validated @RequestBody PointsStandingBook resources) { 39 public ResultInfo create(@Validated @RequestBody PointsStandingBook resources) {
...@@ -47,7 +41,6 @@ public class PointsStandingBookController { ...@@ -47,7 +41,6 @@ public class PointsStandingBookController {
47 return ResultInfo.success(); 41 return ResultInfo.success();
48 } 42 }
49 43
50 @Log
51 @PutMapping 44 @PutMapping
52 @ApiOperation("修改PointsStandingBook") 45 @ApiOperation("修改PointsStandingBook")
53 public ResultInfo update(@Validated @RequestBody PointsStandingBook resources) { 46 public ResultInfo update(@Validated @RequestBody PointsStandingBook resources) {
...@@ -55,8 +48,6 @@ public class PointsStandingBookController { ...@@ -55,8 +48,6 @@ public class PointsStandingBookController {
55 return ResultInfo.success(); 48 return ResultInfo.success();
56 } 49 }
57 50
58
59 @Log
60 @DeleteMapping(value = "/{id}") 51 @DeleteMapping(value = "/{id}")
61 @ApiOperation("删除PointsStandingBook") 52 @ApiOperation("删除PointsStandingBook")
62 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.points.standingbook.service; 1 package com.topdraw.business.module.points.standingbook.service;
2 2
3 import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook; 3 import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
4 import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookDTO; 4 import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
5 import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookQueryCriteria; 5 import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
9 import java.io.IOException;
10 import javax.servlet.http.HttpServletResponse;
11 9
12 /** 10 /**
13 * @author XiangHan 11 * @author XiangHan
......
1 package com.topdraw.business.basicdata.points.standingbook.service.dto; 1 package com.topdraw.business.module.points.standingbook.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.points.standingbook.service.dto; 1 package com.topdraw.business.module.points.standingbook.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import com.topdraw.annotation.Query;
5 4
6 /** 5 /**
7 * @author XiangHan 6 * @author XiangHan
......
1 package com.topdraw.business.basicdata.points.standingbook.service.impl; 1 package com.topdraw.business.module.points.standingbook.service.impl;
2 2
3 import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook; 3 import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
4 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.utils.FileUtil; 5 import com.topdraw.business.module.points.standingbook.repository.PointsStandingBookRepository;
6 import com.topdraw.business.basicdata.points.standingbook.repository.PointsStandingBookRepository; 6 import com.topdraw.business.module.points.standingbook.service.PointsStandingBookService;
7 import com.topdraw.business.basicdata.points.standingbook.service.PointsStandingBookService; 7 import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
8 import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookDTO; 8 import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
9 import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookQueryCriteria; 9 import com.topdraw.business.module.points.standingbook.service.mapper.PointsStandingBookMapper;
10 import com.topdraw.business.basicdata.points.standingbook.service.mapper.PointsStandingBookMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 12 import org.springframework.transaction.annotation.Propagation;
...@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable; ...@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable;
18 import org.springframework.util.Assert; 17 import org.springframework.util.Assert;
19 import com.topdraw.utils.PageUtil; 18 import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp; 19 import com.topdraw.utils.QueryHelp;
21 import com.topdraw.utils.StringUtils;
22 20
23 import java.util.List; 21 import java.util.List;
24 import java.util.Map; 22 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 23
30 /** 24 /**
31 * @author XiangHan 25 * @author XiangHan
......
1 package com.topdraw.business.basicdata.points.standingbook.service.mapper; 1 package com.topdraw.business.module.points.standingbook.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook; 4 import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
5 import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookDTO; 5 import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.rights.constant; 1 package com.topdraw.business.module.rights.constant;
2 2
3 public class RightsType { 3 public class RightsType {
4 4
......
1 package com.topdraw.business.basicdata.rights.domain; 1 package com.topdraw.business.module.rights.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.rights.history.domain; 1 package com.topdraw.business.module.rights.history.domain;
2 2
3 import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
3 import lombok.Data; 4 import lombok.Data;
4 import lombok.experimental.Accessors; 5 import lombok.experimental.Accessors;
5 import cn.hutool.core.bean.BeanUtil; 6 import cn.hutool.core.bean.BeanUtil;
...@@ -22,7 +23,7 @@ import java.time.LocalDateTime; ...@@ -22,7 +23,7 @@ import java.time.LocalDateTime;
22 @EntityListeners(AuditingEntityListener.class) 23 @EntityListeners(AuditingEntityListener.class)
23 @Accessors(chain = true) 24 @Accessors(chain = true)
24 @Table(name="tr_rights_histroy") 25 @Table(name="tr_rights_histroy")
25 public class RightsHistory implements Serializable { 26 public class RightsHistory extends DefaultAsyncMqModule implements Serializable {
26 27
27 // 主键id 28 // 主键id
28 @Id 29 @Id
......
1 package com.topdraw.business.basicdata.rights.history.repository; 1 package com.topdraw.business.module.rights.history.repository;
2 2
3 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 3 import com.topdraw.business.module.rights.history.domain.RightsHistory;
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
......
1 package com.topdraw.business.basicdata.rights.history.rest; 1 package com.topdraw.business.module.rights.history.rest;
2 2
3 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryType;
4 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
5 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.rights.history.service.RightsHistoryService;
6 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 5 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
7 import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService;
8 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria;
9 import com.topdraw.util.TimestampUtil; 6 import com.topdraw.util.TimestampUtil;
10 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
12 import org.springframework.validation.annotation.Validated;
13 import org.springframework.web.bind.annotation.*; 9 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*; 10 import io.swagger.annotations.*;
15 11
......
1 package com.topdraw.business.basicdata.rights.history.service; 1 package com.topdraw.business.module.rights.history.service;
2 2
3 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 3 import com.topdraw.business.module.rights.history.domain.RightsHistory;
4 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryDTO; 4 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO;
5 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria; 5 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.rights.history.service.dto; 1 package com.topdraw.business.module.rights.history.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
5 import javax.persistence.Column;
6 import java.sql.Timestamp; 5 import java.sql.Timestamp;
7 import java.io.Serializable; 6 import java.io.Serializable;
8 import java.time.LocalDateTime; 7 import java.time.LocalDateTime;
......
1 package com.topdraw.business.basicdata.rights.history.service.dto; 1 package com.topdraw.business.module.rights.history.service.dto;
2 2
3 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data; 4 import lombok.Data;
......
1 package com.topdraw.business.basicdata.rights.history.service.dto; 1 package com.topdraw.business.module.rights.history.service.dto;
2 2
3 public enum RightsHistoryQueryType { 3 public enum RightsHistoryQueryType {
4 4
......
1 package com.topdraw.business.basicdata.rights.history.service.impl; 1 package com.topdraw.business.module.rights.history.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 4 import com.topdraw.business.module.rights.history.domain.RightsHistory;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.rights.history.repository.RightsHistoryRepository; 6 import com.topdraw.business.module.rights.history.repository.RightsHistoryRepository;
7 import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService; 7 import com.topdraw.business.module.rights.history.service.RightsHistoryService;
8 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryDTO; 8 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO;
9 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria; 9 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
10 import com.topdraw.business.basicdata.rights.history.service.mapper.RightsHistoryMapper; 10 import com.topdraw.business.module.rights.history.service.mapper.RightsHistoryMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
...@@ -66,7 +66,7 @@ public class RightsHistoryServiceImpl implements RightsHistoryService { ...@@ -66,7 +66,7 @@ public class RightsHistoryServiceImpl implements RightsHistoryService {
66 @AsyncMqSend() 66 @AsyncMqSend()
67 public void update(RightsHistory resources) { 67 public void update(RightsHistory resources) {
68 RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new); 68 RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new);
69 ValidationUtil.isNull( RightsHistory.getId(),"RightsHistory","id",resources.getId()); 69 ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",resources.getId());
70 RightsHistory.copy(resources); 70 RightsHistory.copy(resources);
71 RightsHistoryRepository.save(RightsHistory); 71 RightsHistoryRepository.save(RightsHistory);
72 } 72 }
......
1 package com.topdraw.business.basicdata.rights.history.service.mapper; 1 package com.topdraw.business.module.rights.history.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 4 import com.topdraw.business.module.rights.history.domain.RightsHistory;
5 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryDTO; 5 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.rights.permanentrights.domain; 1 package com.topdraw.business.module.rights.permanentrights.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.rights.permanentrights.repository; 1 package com.topdraw.business.module.rights.permanentrights.repository;
2 2
3 import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights; 3 import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
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
......
1 package com.topdraw.business.basicdata.rights.permanentrights.rest; 1 package com.topdraw.business.module.rights.permanentrights.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
5 import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights; 5 import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
6 import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService; 6 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
7 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated; 9 import org.springframework.validation.annotation.Validated;
...@@ -35,7 +34,6 @@ public class PermanentRightsController { ...@@ -35,7 +34,6 @@ public class PermanentRightsController {
35 return ResultInfo.success(PermanentRightsService.findById(id)); 34 return ResultInfo.success(PermanentRightsService.findById(id));
36 } 35 }
37 36
38 @Log
39 @PostMapping(value = "/create") 37 @PostMapping(value = "/create")
40 @ApiOperation("新增PermanentRights") 38 @ApiOperation("新增PermanentRights")
41 public ResultInfo create(@Validated @RequestBody PermanentRights resources) { 39 public ResultInfo create(@Validated @RequestBody PermanentRights resources) {
...@@ -43,7 +41,6 @@ public class PermanentRightsController { ...@@ -43,7 +41,6 @@ public class PermanentRightsController {
43 return ResultInfo.success(); 41 return ResultInfo.success();
44 } 42 }
45 43
46 @Log
47 @PutMapping(value = "/update") 44 @PutMapping(value = "/update")
48 @ApiOperation("修改PermanentRights") 45 @ApiOperation("修改PermanentRights")
49 public ResultInfo update(@Validated @RequestBody PermanentRights resources) { 46 public ResultInfo update(@Validated @RequestBody PermanentRights resources) {
...@@ -51,7 +48,6 @@ public class PermanentRightsController { ...@@ -51,7 +48,6 @@ public class PermanentRightsController {
51 return ResultInfo.success(); 48 return ResultInfo.success();
52 } 49 }
53 50
54 @Log
55 @DeleteMapping(value = "/delete/{id}") 51 @DeleteMapping(value = "/delete/{id}")
56 @ApiOperation("删除PermanentRights") 52 @ApiOperation("删除PermanentRights")
57 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.rights.permanentrights.service; 1 package com.topdraw.business.module.rights.permanentrights.service;
2 2
3 import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights; 3 import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
4 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO; 4 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
5 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria; 5 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.rights.permanentrights.service.dto; 1 package com.topdraw.business.module.rights.permanentrights.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.rights.permanentrights.service.dto; 1 package com.topdraw.business.module.rights.permanentrights.service.dto;
2 2
3 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data; 4 import lombok.Data;
......
1 package com.topdraw.business.basicdata.rights.permanentrights.service.impl; 1 package com.topdraw.business.module.rights.permanentrights.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
4 import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights;
5 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.rights.permanentrights.repository.PermanentRightsRepository; 5 import com.topdraw.business.module.rights.permanentrights.repository.PermanentRightsRepository;
7 import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService; 6 import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
8 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO; 7 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
9 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria; 8 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
10 import com.topdraw.business.basicdata.rights.permanentrights.service.mapper.PermanentRightsMapper; 9 import com.topdraw.business.module.rights.permanentrights.service.mapper.PermanentRightsMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 12 import org.springframework.transaction.annotation.Propagation;
......
1 package com.topdraw.business.basicdata.rights.permanentrights.service.mapper; 1 package com.topdraw.business.module.rights.permanentrights.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights; 4 import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
5 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO; 5 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.rights.repository; 1 package com.topdraw.business.module.rights.repository;
2 2
3 import com.topdraw.business.basicdata.rights.domain.Rights; 3 import com.topdraw.business.module.rights.domain.Rights;
4 import com.topdraw.business.basicdata.rights.service.dto.RightsDTO;
5 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7 import org.springframework.data.jpa.repository.Query; 6 import org.springframework.data.jpa.repository.Query;
......
1 package com.topdraw.business.basicdata.rights.rest; 1 package com.topdraw.business.module.rights.rest;
2 2
3 import com.topdraw.business.basicdata.rights.service.RightsService; 3 import com.topdraw.business.module.rights.service.RightsService;
4 import com.topdraw.business.basicdata.rights.service.dto.RightsQueryCriteria;
5 import com.topdraw.common.ResultInfo; 4 import com.topdraw.common.ResultInfo;
6 import io.swagger.annotations.Api; 5 import io.swagger.annotations.Api;
7 import io.swagger.annotations.ApiOperation; 6 import io.swagger.annotations.ApiOperation;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable;
10 import org.springframework.web.bind.annotation.GetMapping; 8 import org.springframework.web.bind.annotation.GetMapping;
11 import org.springframework.web.bind.annotation.PathVariable; 9 import org.springframework.web.bind.annotation.PathVariable;
12 import org.springframework.web.bind.annotation.RequestMapping; 10 import org.springframework.web.bind.annotation.RequestMapping;
......
1 package com.topdraw.business.basicdata.rights.service; 1 package com.topdraw.business.module.rights.service;
2 2
3 import com.topdraw.business.basicdata.rights.domain.Rights; 3 import com.topdraw.business.module.rights.domain.Rights;
4 import com.topdraw.business.basicdata.rights.service.dto.RightsDTO; 4 import com.topdraw.business.module.rights.service.dto.RightsDTO;
5 import com.topdraw.business.basicdata.rights.service.dto.RightsQueryCriteria; 5 import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.rights.service.dto; 1 package com.topdraw.business.module.rights.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.rights.service.dto; 1 package com.topdraw.business.module.rights.service.dto;
2 2
3 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data; 4 import lombok.Data;
......
1 package com.topdraw.business.basicdata.rights.service.dto; 1 package com.topdraw.business.module.rights.service.dto;
2 2
3 public enum RightsQueryType { 3 public enum RightsQueryType {
4 4
......
1 package com.topdraw.business.basicdata.rights.service.impl; 1 package com.topdraw.business.module.rights.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.rights.domain.Rights; 4 import com.topdraw.business.module.rights.domain.Rights;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.rights.repository.RightsRepository; 6 import com.topdraw.business.module.rights.repository.RightsRepository;
7 import com.topdraw.business.basicdata.rights.service.RightsService; 7 import com.topdraw.business.module.rights.service.RightsService;
8 import com.topdraw.business.basicdata.rights.service.dto.RightsDTO; 8 import com.topdraw.business.module.rights.service.dto.RightsDTO;
9 import com.topdraw.business.basicdata.rights.service.dto.RightsQueryCriteria; 9 import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria;
10 import com.topdraw.business.basicdata.rights.service.mapper.RightsMapper; 10 import com.topdraw.business.module.rights.service.mapper.RightsMapper;
11 import org.redisson.api.RLock; 11 import org.redisson.api.RLock;
12 import org.redisson.api.RedissonClient; 12 import org.redisson.api.RedissonClient;
13 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.business.basicdata.rights.service.mapper; 1 package com.topdraw.business.module.rights.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.rights.domain.Rights; 4 import com.topdraw.business.module.rights.domain.Rights;
5 import com.topdraw.business.basicdata.rights.service.dto.RightsDTO; 5 import com.topdraw.business.module.rights.service.dto.RightsDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.module.task.attribute.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
12 import java.io.Serializable;
13
14 /**
15 * @author XiangHan
16 * @date 2022-01-13
17 */
18 @Entity
19 @Data
20 @EntityListeners(AuditingEntityListener.class)
21 @Accessors(chain = true)
22 @Table(name="tr_task_attr")
23 public class TaskAttr implements Serializable {
24
25 @Id
26 @GeneratedValue(strategy = GenerationType.IDENTITY)
27 @Column(name = "id")
28 private Long id;
29
30 // 任务id(关联task主键)
31 @Column(name = "task_id")
32 private Long taskId;
33
34 // 任务属性字符串
35 @Column(name = "attr_str")
36 private String attrStr;
37
38 public void copy(TaskAttr source){
39 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
40 }
41 }
1 package com.topdraw.business.basicdata.user.weixin.repository; 1 package com.topdraw.business.module.task.attribute.repository;
2 2
3 import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; 3 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
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
...@@ -8,8 +8,9 @@ import java.util.Optional; ...@@ -8,8 +8,9 @@ import java.util.Optional;
8 8
9 /** 9 /**
10 * @author XiangHan 10 * @author XiangHan
11 * @date 2021-12-16 11 * @date 2022-01-13
12 */ 12 */
13 public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, JpaSpecificationExecutor<UserWeixin> { 13 public interface TaskAttrRepository extends JpaRepository<TaskAttr, Long>, JpaSpecificationExecutor<TaskAttr> {
14 14
15 Optional<TaskAttr> findByTaskId(Long taskId);
15 } 16 }
......
1 package com.topdraw.business.module.task.attribute.rest;
2
3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
5 import com.topdraw.business.module.task.attribute.service.TaskAttrService;
6 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.data.domain.Pageable;
9 import org.springframework.http.HttpStatus;
10 import org.springframework.http.ResponseEntity;
11 import org.springframework.validation.annotation.Validated;
12 import org.springframework.web.bind.annotation.*;
13 import io.swagger.annotations.*;
14 import java.io.IOException;
15 import javax.servlet.http.HttpServletResponse;
16
17 /**
18 * @author XiangHan
19 * @date 2022-01-13
20 */
21 @Api(tags = "TaskAttr管理")
22 @RestController
23 @RequestMapping("/api/TaskAttr")
24 public class TaskAttrController {
25
26 @Autowired
27 private TaskAttrService TaskAttrService;
28
29 @GetMapping
30 @ApiOperation("查询TaskAttr")
31 public ResultInfo getTaskAttrs(TaskAttrQueryCriteria criteria, Pageable pageable) {
32 return ResultInfo.successPage(TaskAttrService.queryAll(criteria,pageable));
33 }
34
35 @GetMapping(value = "/all")
36 @ApiOperation("查询所有TaskAttr")
37 public ResultInfo getTaskAttrs(TaskAttrQueryCriteria criteria) {
38 return ResultInfo.success(TaskAttrService.queryAll(criteria));
39 }
40
41 @PostMapping
42 @ApiOperation("新增TaskAttr")
43 public ResultInfo create(@Validated @RequestBody TaskAttr resources) {
44 TaskAttrService.create(resources);
45 return ResultInfo.success();
46 }
47
48 @PutMapping
49 @ApiOperation("修改TaskAttr")
50 public ResultInfo update(@Validated @RequestBody TaskAttr resources) {
51 TaskAttrService.update(resources);
52 return ResultInfo.success();
53 }
54
55 @DeleteMapping(value = "/{id}")
56 @ApiOperation("删除TaskAttr")
57 public ResultInfo delete(@PathVariable Long id) {
58 TaskAttrService.delete(id);
59 return ResultInfo.success();
60 }
61
62 }
1 package com.topdraw.business.module.task.attribute.service;
2
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
5 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
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 2022-01-13
15 */
16 public interface TaskAttrService {
17
18 /**
19 * 查询数据分页
20 * @param criteria 条件参数
21 * @param pageable 分页参数
22 * @return Map<String,Object>
23 */
24 Map<String,Object> queryAll(TaskAttrQueryCriteria criteria, Pageable pageable);
25
26 /**
27 * 查询所有数据不分页
28 * @param criteria 条件参数
29 * @return List<TaskAttrDTO>
30 */
31 List<TaskAttrDTO> queryAll(TaskAttrQueryCriteria criteria);
32
33 /**
34 * 根据ID查询
35 * @param id ID
36 * @return TaskAttrDTO
37 */
38 TaskAttrDTO findById(Long id);
39
40 void create(TaskAttr resources);
41
42 void update(TaskAttr resources);
43
44 void delete(Long id);
45
46 TaskAttrDTO findByTaskId(Long taskId);
47 }
1 package com.topdraw.business.module.task.attribute.service.dto;
2
3 import lombok.Data;
4 import java.io.Serializable;
5
6
7 /**
8 * @author XiangHan
9 * @date 2022-01-13
10 */
11 @Data
12 public class TaskAttrDTO implements Serializable {
13
14 private Long id;
15
16 // 任务id(关联task主键)
17 private Long taskId;
18
19 // 任务属性字符串
20 private String attrStr;
21 }
1 package com.topdraw.business.module.task.attribute.service.dto;
2
3 import lombok.Data;
4 import com.topdraw.annotation.Query;
5
6 /**
7 * @author XiangHan
8 * @date 2022-01-13
9 */
10 @Data
11 public class TaskAttrQueryCriteria{
12 }
1 package com.topdraw.business.module.task.attribute.service.impl;
2
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.utils.FileUtil;
6 import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository;
7 import com.topdraw.business.module.task.attribute.service.TaskAttrService;
8 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
9 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
10 import com.topdraw.business.module.task.attribute.service.mapper.TaskAttrMapper;
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 2022-01-13
33 */
34 @Service
35 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
36 public class TaskAttrServiceImpl implements TaskAttrService {
37
38 @Autowired
39 private TaskAttrRepository TaskAttrRepository;
40
41 @Autowired
42 private TaskAttrMapper TaskAttrMapper;
43
44 @Override
45 public Map<String, Object> queryAll(TaskAttrQueryCriteria criteria, Pageable pageable) {
46 Page<TaskAttr> page = TaskAttrRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
47 return PageUtil.toPage(page.map(TaskAttrMapper::toDto));
48 }
49
50 @Override
51 public List<TaskAttrDTO> queryAll(TaskAttrQueryCriteria criteria) {
52 return TaskAttrMapper.toDto(TaskAttrRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
53 }
54
55 @Override
56 public TaskAttrDTO findById(Long id) {
57 TaskAttr TaskAttr = TaskAttrRepository.findById(id).orElseGet(TaskAttr::new);
58 ValidationUtil.isNull(TaskAttr.getId(),"TaskAttr","id",id);
59 return TaskAttrMapper.toDto(TaskAttr);
60 }
61
62 @Override
63 @Transactional(rollbackFor = Exception.class)
64 public void create(TaskAttr resources) {
65 TaskAttrRepository.save(resources);
66 }
67
68 @Override
69 @Transactional(rollbackFor = Exception.class)
70 public void update(TaskAttr resources) {
71 TaskAttr TaskAttr = TaskAttrRepository.findById(resources.getId()).orElseGet(TaskAttr::new);
72 ValidationUtil.isNull( TaskAttr.getId(),"TaskAttr","id",resources.getId());
73 TaskAttr.copy(resources);
74 TaskAttrRepository.save(TaskAttr);
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 TaskAttr TaskAttr = TaskAttrRepository.findById(id).orElseThrow(
82 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", TaskAttr.class, id), 1));
83 TaskAttrRepository.delete(TaskAttr);
84 }
85
86 @Override
87 public TaskAttrDTO findByTaskId(Long taskId) {
88 TaskAttr TaskAttr = TaskAttrRepository.findByTaskId(taskId).orElseGet(TaskAttr::new);
89 return TaskAttrMapper.toDto(TaskAttr);
90 }
91
92
93 }
1 package com.topdraw.business.module.task.attribute.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
5 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author XiangHan
11 * @date 2022-01-13
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface TaskAttrMapper extends BaseMapper<TaskAttrDTO, TaskAttr> {
15
16 }
1 package com.topdraw.business.basicdata.task.domain; 1 package com.topdraw.business.module.task.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.task.progress.domain; 1 package com.topdraw.business.module.task.progress.domain;
2 2
3 import lombok.AllArgsConstructor; 3 import lombok.AllArgsConstructor;
4 import lombok.Data; 4 import lombok.Data;
......
1 package com.topdraw.business.basicdata.task.progress.repository; 1 package com.topdraw.business.module.task.progress.repository;
2 2
3 import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; 3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
4 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO;
5 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7 import org.springframework.data.jpa.repository.Query; 6 import org.springframework.data.jpa.repository.Query;
8 7
9 import java.util.List; 8 import java.util.List;
10 import java.util.Optional;
11 9
12 /** 10 /**
13 * @author XiangHan 11 * @author XiangHan
......
1 package com.topdraw.business.basicdata.task.progress.rest; 1 package com.topdraw.business.module.task.progress.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
5 import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; 5 import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
6 import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService; 6 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
7 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 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; 9 import org.springframework.validation.annotation.Validated;
13 import org.springframework.web.bind.annotation.*; 10 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*; 11 import io.swagger.annotations.*;
15 import java.io.IOException;
16 import javax.servlet.http.HttpServletResponse;
17 12
18 /** 13 /**
19 * @author XiangHan 14 * @author XiangHan
...@@ -39,7 +34,6 @@ public class TrTaskProgressController { ...@@ -39,7 +34,6 @@ public class TrTaskProgressController {
39 return ResultInfo.success(TrTaskProgressService.queryAll(criteria)); 34 return ResultInfo.success(TrTaskProgressService.queryAll(criteria));
40 } 35 }
41 36
42 @Log
43 @PostMapping 37 @PostMapping
44 @ApiOperation("新增TrTaskProgress") 38 @ApiOperation("新增TrTaskProgress")
45 public ResultInfo create(@Validated @RequestBody TrTaskProgress resources) { 39 public ResultInfo create(@Validated @RequestBody TrTaskProgress resources) {
...@@ -47,7 +41,6 @@ public class TrTaskProgressController { ...@@ -47,7 +41,6 @@ public class TrTaskProgressController {
47 return ResultInfo.success(); 41 return ResultInfo.success();
48 } 42 }
49 43
50 @Log
51 @PutMapping 44 @PutMapping
52 @ApiOperation("修改TrTaskProgress") 45 @ApiOperation("修改TrTaskProgress")
53 public ResultInfo update(@Validated @RequestBody TrTaskProgress resources) { 46 public ResultInfo update(@Validated @RequestBody TrTaskProgress resources) {
...@@ -55,8 +48,6 @@ public class TrTaskProgressController { ...@@ -55,8 +48,6 @@ public class TrTaskProgressController {
55 return ResultInfo.success(); 48 return ResultInfo.success();
56 } 49 }
57 50
58
59 @Log
60 @DeleteMapping(value = "/{id}") 51 @DeleteMapping(value = "/{id}")
61 @ApiOperation("删除TrTaskProgress") 52 @ApiOperation("删除TrTaskProgress")
62 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.task.progress.service; 1 package com.topdraw.business.module.task.progress.service;
2 2
3 import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; 3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
4 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO; 4 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
5 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria; 5 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
9 import java.io.IOException;
10 import javax.servlet.http.HttpServletResponse;
11 9
12 /** 10 /**
13 * @author XiangHan 11 * @author XiangHan
......
1 package com.topdraw.business.basicdata.task.progress.service.dto; 1 package com.topdraw.business.module.task.progress.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.task.progress.service.dto; 1 package com.topdraw.business.module.task.progress.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import com.topdraw.annotation.Query; 4 import com.topdraw.annotation.Query;
5 5
6 import java.sql.Timestamp;
7
8 /** 6 /**
9 * @author XiangHan 7 * @author XiangHan
10 * @date 2021-11-02 8 * @date 2021-11-02
......
1 package com.topdraw.business.basicdata.task.progress.service.impl; 1 package com.topdraw.business.module.task.progress.service.impl;
2 2
3 import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; 3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
4 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.utils.FileUtil; 5 import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository;
6 import com.topdraw.business.basicdata.task.progress.repository.TrTaskProgressRepository; 6 import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
7 import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService; 7 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
8 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO; 8 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
9 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria; 9 import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper;
10 import com.topdraw.business.basicdata.task.progress.service.mapper.TrTaskProgressMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 12 import org.springframework.transaction.annotation.Propagation;
...@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable; ...@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable;
18 import org.springframework.util.Assert; 17 import org.springframework.util.Assert;
19 import com.topdraw.utils.PageUtil; 18 import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp; 19 import com.topdraw.utils.QueryHelp;
21 import com.topdraw.utils.StringUtils;
22 20
23 import java.util.List; 21 import java.util.List;
24 import java.util.Map; 22 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 23
30 /** 24 /**
31 * @author XiangHan 25 * @author XiangHan
......
1 package com.topdraw.business.basicdata.task.progress.service.mapper; 1 package com.topdraw.business.module.task.progress.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; 4 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
5 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO; 5 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.task.repository; 1 package com.topdraw.business.module.task.repository;
2 2
3 import com.topdraw.business.basicdata.task.domain.Task; 3 import com.topdraw.business.module.task.domain.Task;
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
......
1 package com.topdraw.business.basicdata.task.rest; 1 package com.topdraw.business.module.task.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.task.domain.Task;
5 import com.topdraw.business.basicdata.task.domain.Task; 5 import com.topdraw.business.module.task.service.TaskService;
6 import com.topdraw.business.basicdata.task.service.TaskService; 6 import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
7 import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated; 9 import org.springframework.validation.annotation.Validated;
...@@ -35,7 +34,6 @@ public class TaskController { ...@@ -35,7 +34,6 @@ public class TaskController {
35 return ResultInfo.success(TaskService.queryAll(criteria)); 34 return ResultInfo.success(TaskService.queryAll(criteria));
36 } 35 }
37 36
38 @Log
39 @PostMapping 37 @PostMapping
40 @ApiOperation("新增Task") 38 @ApiOperation("新增Task")
41 public ResultInfo create(@Validated @RequestBody Task resources) { 39 public ResultInfo create(@Validated @RequestBody Task resources) {
...@@ -43,7 +41,6 @@ public class TaskController { ...@@ -43,7 +41,6 @@ public class TaskController {
43 return ResultInfo.success(); 41 return ResultInfo.success();
44 } 42 }
45 43
46 @Log
47 @PutMapping 44 @PutMapping
48 @ApiOperation("修改Task") 45 @ApiOperation("修改Task")
49 public ResultInfo update(@Validated @RequestBody Task resources) { 46 public ResultInfo update(@Validated @RequestBody Task resources) {
...@@ -51,8 +48,6 @@ public class TaskController { ...@@ -51,8 +48,6 @@ public class TaskController {
51 return ResultInfo.success(); 48 return ResultInfo.success();
52 } 49 }
53 50
54
55 @Log
56 @DeleteMapping(value = "/{id}") 51 @DeleteMapping(value = "/{id}")
57 @ApiOperation("删除Task") 52 @ApiOperation("删除Task")
58 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.task.service; 1 package com.topdraw.business.module.task.service;
2 2
3 import com.topdraw.business.basicdata.task.domain.Task; 3 import com.topdraw.business.module.task.domain.Task;
4 import com.topdraw.business.basicdata.task.service.dto.TaskDTO; 4 import com.topdraw.business.module.task.service.dto.TaskDTO;
5 import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria; 5 import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
......
1 package com.topdraw.business.basicdata.task.service.dto; 1 package com.topdraw.business.module.task.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
5 import javax.persistence.Column;
6 import java.sql.Timestamp; 5 import java.sql.Timestamp;
7 import java.io.Serializable; 6 import java.io.Serializable;
8 import java.time.LocalDateTime; 7 import java.time.LocalDateTime;
......
1 package com.topdraw.business.basicdata.task.service.dto; 1 package com.topdraw.business.module.task.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.task.service.impl; 1 package com.topdraw.business.module.task.service.impl;
2 2
3 import com.topdraw.business.basicdata.task.domain.Task; 3 import com.topdraw.business.module.task.domain.Task;
4 import com.topdraw.utils.StringUtils;
5 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.basicdata.task.repository.TaskRepository; 5 import com.topdraw.business.module.task.repository.TaskRepository;
7 import com.topdraw.business.basicdata.task.service.TaskService; 6 import com.topdraw.business.module.task.service.TaskService;
8 import com.topdraw.business.basicdata.task.service.dto.TaskDTO; 7 import com.topdraw.business.module.task.service.dto.TaskDTO;
9 import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria; 8 import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
10 import com.topdraw.business.basicdata.task.service.mapper.TaskMapper; 9 import com.topdraw.business.module.task.service.mapper.TaskMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.cache.annotation.Cacheable;
13 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
14 import org.springframework.transaction.annotation.Propagation; 12 import org.springframework.transaction.annotation.Propagation;
15 import org.springframework.transaction.annotation.Transactional; 13 import org.springframework.transaction.annotation.Transactional;
......
1 package com.topdraw.business.basicdata.task.service.mapper; 1 package com.topdraw.business.module.task.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.task.domain.Task; 4 import com.topdraw.business.module.task.domain.Task;
5 import com.topdraw.business.basicdata.task.service.dto.TaskDTO; 5 import com.topdraw.business.module.task.service.dto.TaskDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.basicdata.task.template.domain; 1 package com.topdraw.business.module.task.template.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
......
1 package com.topdraw.business.basicdata.task.template.repository; 1 package com.topdraw.business.module.task.template.repository;
2 2
3 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
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.List;
7 import java.util.Optional; 8 import java.util.Optional;
8 9
9 /** 10 /**
...@@ -16,5 +17,5 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long ...@@ -16,5 +17,5 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long
16 17
17 TaskTemplate findByEvent(String event); 18 TaskTemplate findByEvent(String event);
18 19
19 TaskTemplate findByType(Integer event); 20 List<TaskTemplate> findByType(Integer event);
20 } 21 }
......
1 package com.topdraw.business.basicdata.task.template.rest; 1 package com.topdraw.business.module.task.template.rest;
2 2
3 import com.topdraw.common.ResultInfo; 3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 4 import com.topdraw.business.module.task.template.domain.TaskTemplate;
5 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 5 import com.topdraw.business.module.task.template.service.TaskTemplateService;
6 import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; 6 import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
7 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated; 9 import org.springframework.validation.annotation.Validated;
...@@ -35,7 +34,6 @@ public class TaskTemplateController { ...@@ -35,7 +34,6 @@ public class TaskTemplateController {
35 return ResultInfo.success(TaskTemplateService.queryAll(criteria)); 34 return ResultInfo.success(TaskTemplateService.queryAll(criteria));
36 } 35 }
37 36
38 @Log
39 @PostMapping 37 @PostMapping
40 @ApiOperation("新增TaskTemplate") 38 @ApiOperation("新增TaskTemplate")
41 public ResultInfo create(@Validated @RequestBody TaskTemplate resources) { 39 public ResultInfo create(@Validated @RequestBody TaskTemplate resources) {
...@@ -43,7 +41,6 @@ public class TaskTemplateController { ...@@ -43,7 +41,6 @@ public class TaskTemplateController {
43 return ResultInfo.success(); 41 return ResultInfo.success();
44 } 42 }
45 43
46 @Log
47 @PutMapping 44 @PutMapping
48 @ApiOperation("修改TaskTemplate") 45 @ApiOperation("修改TaskTemplate")
49 public ResultInfo update(@Validated @RequestBody TaskTemplate resources) { 46 public ResultInfo update(@Validated @RequestBody TaskTemplate resources) {
...@@ -51,8 +48,6 @@ public class TaskTemplateController { ...@@ -51,8 +48,6 @@ public class TaskTemplateController {
51 return ResultInfo.success(); 48 return ResultInfo.success();
52 } 49 }
53 50
54
55 @Log
56 @DeleteMapping(value = "/{id}") 51 @DeleteMapping(value = "/{id}")
57 @ApiOperation("删除TaskTemplate") 52 @ApiOperation("删除TaskTemplate")
58 public ResultInfo delete(@PathVariable Long id) { 53 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.task.template.service; 1 package com.topdraw.business.module.task.template.service;
2 2
3 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
4 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO; 4 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
5 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria; 5 import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
...@@ -50,5 +50,5 @@ public interface TaskTemplateService { ...@@ -50,5 +50,5 @@ public interface TaskTemplateService {
50 50
51 TaskTemplate findByEvent(String event); 51 TaskTemplate findByEvent(String event);
52 52
53 TaskTemplate findByType(Integer event); 53 List<TaskTemplate> findByType(Integer event);
54 } 54 }
......
1 package com.topdraw.business.basicdata.task.template.service.dto; 1 package com.topdraw.business.module.task.template.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
......
1 package com.topdraw.business.basicdata.task.template.service.dto; 1 package com.topdraw.business.module.task.template.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
......
1 package com.topdraw.business.basicdata.task.template.service.impl; 1 package com.topdraw.business.module.task.template.service.impl;
2 2
3 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
4 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.business.basicdata.task.template.repository.TaskTemplateRepository; 5 import com.topdraw.business.module.task.template.repository.TaskTemplateRepository;
6 import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; 6 import com.topdraw.business.module.task.template.service.TaskTemplateService;
7 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO; 7 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
8 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria; 8 import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
9 import com.topdraw.business.basicdata.task.template.service.mapper.TaskTemplateMapper; 9 import com.topdraw.business.module.task.template.service.mapper.TaskTemplateMapper;
10 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.cache.annotation.Cacheable;
12 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 12 import org.springframework.transaction.annotation.Propagation;
14 import org.springframework.transaction.annotation.Transactional; 13 import org.springframework.transaction.annotation.Transactional;
...@@ -95,7 +94,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { ...@@ -95,7 +94,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService {
95 94
96 // @Cacheable(cacheNames = "uc-admin_taskTemplate" , key = "#event") 95 // @Cacheable(cacheNames = "uc-admin_taskTemplate" , key = "#event")
97 @Override 96 @Override
98 public TaskTemplate findByType(Integer event) { 97 public List<TaskTemplate> findByType(Integer event) {
99 return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null; 98 return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null;
100 } 99 }
101 } 100 }
......
1 package com.topdraw.business.basicdata.task.template.service.mapper; 1 package com.topdraw.business.module.task.template.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 4 import com.topdraw.business.module.task.template.domain.TaskTemplate;
5 import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO; 5 import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.module.user.iptv.domain;
2
3 import java.util.Arrays;
4 import java.util.List;
5
6 public interface UserConstant {
7
8 // 电信
9 List<String> platform_lt = Arrays.asList("SC.CTCC","SC.CTC","CTC.ChongQing","ChongQing.CTC","CQ.CTC","CQ.CTCC");
10 // 移动
11 List<String> platform_yd = Arrays.asList("SC.CMCC","CMCC.SC","ChongQing.CMCC","CMCC.ChongQing");
12 // 联通
13 List<String> platform_dx = Arrays.asList("SC.CUCC","");
14
15 }
1 package com.topdraw.business.basicdata.user.iptv.domain; 1 package com.topdraw.business.module.user.iptv.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
...@@ -23,6 +23,10 @@ import java.io.Serializable; ...@@ -23,6 +23,10 @@ import java.io.Serializable;
23 @Table(name="uc_user_tv") 23 @Table(name="uc_user_tv")
24 public class UserTv implements Serializable { 24 public class UserTv implements Serializable {
25 25
26 /** 绑定的小屏账户会员编码 */
27 @Column(name = "priority_member_code")
28 private String priorityMemberCode;
29
26 @Transient 30 @Transient
27 private String memberCode; 31 private String memberCode;
28 32
...@@ -119,6 +123,6 @@ public class UserTv implements Serializable { ...@@ -119,6 +123,6 @@ public class UserTv implements Serializable {
119 private Long memberId; 123 private Long memberId;
120 124
121 public void copy(UserTv source){ 125 public void copy(UserTv source){
122 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); 126 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
123 } 127 }
124 } 128 }
......
1 package com.topdraw.business.basicdata.user.iptv.repository; 1 package com.topdraw.business.module.user.iptv.repository;
2 2
3 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 3 import com.topdraw.business.module.user.iptv.domain.UserTv;
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
...@@ -13,4 +13,8 @@ import java.util.Optional; ...@@ -13,4 +13,8 @@ import java.util.Optional;
13 public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecificationExecutor<UserTv> { 13 public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecificationExecutor<UserTv> {
14 14
15 Optional<UserTv> findByPlatformAccount(String platformAccount); 15 Optional<UserTv> findByPlatformAccount(String platformAccount);
16
17 Optional<UserTv> findByPriorityMemberCode(String memberCode);
18
19 Optional<UserTv> findByMemberId(Long memberId);
16 } 20 }
......
1 package com.topdraw.business.basicdata.user.iptv.rest; 1 package com.topdraw.business.module.user.iptv.rest;
2 2
3 import com.topdraw.business.basicdata.member.domain.Member; 3 import com.topdraw.annotation.AnonymousAccess;
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; 4 import com.topdraw.common.ResultInfo;
7 import com.topdraw.aop.log.Log; 5 import com.topdraw.business.module.user.iptv.domain.UserTv;
8 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 6 import com.topdraw.business.module.user.iptv.service.UserTvService;
9 import com.topdraw.business.basicdata.user.iptv.service.UserTvService; 7 import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
10 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria;
11 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.data.domain.Pageable; 9 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; 10 import org.springframework.validation.annotation.Validated;
17 import org.springframework.web.bind.annotation.*; 11 import org.springframework.web.bind.annotation.*;
18 import io.swagger.annotations.*; 12 import io.swagger.annotations.*;
19 import java.io.IOException;
20 import java.util.Objects;
21 import javax.servlet.http.HttpServletResponse;
22 13
23 /** 14 /**
24 * @author XiangHan 15 * @author XiangHan
...@@ -26,7 +17,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -26,7 +17,7 @@ import javax.servlet.http.HttpServletResponse;
26 */ 17 */
27 @Api(tags = "UserTv管理") 18 @Api(tags = "UserTv管理")
28 @RestController 19 @RestController
29 @RequestMapping("/api/UserTv") 20 @RequestMapping("/ucEngine/api/userTv")
30 public class UserTvController { 21 public class UserTvController {
31 22
32 @Autowired 23 @Autowired
...@@ -44,23 +35,22 @@ public class UserTvController { ...@@ -44,23 +35,22 @@ public class UserTvController {
44 return ResultInfo.success(UserTvService.queryAll(criteria)); 35 return ResultInfo.success(UserTvService.queryAll(criteria));
45 } 36 }
46 37
47 @Log 38 @PostMapping(value = "/create")
48 @PostMapping
49 @ApiOperation("新增UserTv") 39 @ApiOperation("新增UserTv")
40 @AnonymousAccess
50 public ResultInfo create(@Validated @RequestBody UserTv resources) { 41 public ResultInfo create(@Validated @RequestBody UserTv resources) {
51 UserTvService.create(resources); 42 UserTvService.create(resources);
52 return ResultInfo.success(); 43 return ResultInfo.success();
53 } 44 }
54 45
55 @Log
56 @PutMapping 46 @PutMapping
57 @ApiOperation("修改UserTv") 47 @ApiOperation("修改UserTv")
48 @AnonymousAccess
58 public ResultInfo update(@Validated @RequestBody UserTv resources) { 49 public ResultInfo update(@Validated @RequestBody UserTv resources) {
59 UserTvService.update(resources); 50 UserTvService.update(resources);
60 return ResultInfo.success(); 51 return ResultInfo.success();
61 } 52 }
62 53
63 @Log
64 @DeleteMapping(value = "/{id}") 54 @DeleteMapping(value = "/{id}")
65 @ApiOperation("删除UserTv") 55 @ApiOperation("删除UserTv")
66 public ResultInfo delete(@PathVariable Long id) { 56 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.user.iptv.service; 1 package com.topdraw.business.module.user.iptv.service;
2 2
3 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; 4 import com.topdraw.business.module.user.iptv.domain.UserTv;
5 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria; 5 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
6 import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
6 import org.springframework.data.domain.Pageable; 7 import org.springframework.data.domain.Pageable;
8 import org.springframework.transaction.annotation.Transactional;
9
7 import java.util.Map; 10 import java.util.Map;
8 import java.util.List; 11 import java.util.List;
9 import java.io.IOException;
10 import javax.servlet.http.HttpServletResponse;
11 12
12 /** 13 /**
13 * @author XiangHan 14 * @author XiangHan
...@@ -41,9 +42,13 @@ public interface UserTvService { ...@@ -41,9 +42,13 @@ public interface UserTvService {
41 42
42 void update(UserTv resources); 43 void update(UserTv resources);
43 44
45 void unbindPriorityMemberCode(UserTv resources);
46
44 void delete(Long id); 47 void delete(Long id);
45 48
46 UserTvDTO findByPlatformAccount(String platformAccount); 49 UserTvDTO findByPlatformAccount(String platformAccount);
47 50
51 UserTvDTO findByPriorityMemberCode(String memberCode);
48 52
53 UserTvDTO findByMemberId(Long memberId);
49 } 54 }
......
1 package com.topdraw.business.basicdata.user.iptv.service.dto; 1 package com.topdraw.business.module.user.iptv.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
...@@ -12,6 +12,11 @@ import java.io.Serializable; ...@@ -12,6 +12,11 @@ import java.io.Serializable;
12 @Data 12 @Data
13 public class UserTvDTO implements Serializable { 13 public class UserTvDTO implements Serializable {
14 14
15 private String memberCode;
16
17 /** 绑定的小屏账户会员编码 */
18 private String priorityMemberCode;
19
15 // ID 20 // ID
16 private Long id; 21 private Long id;
17 22
......
1 package com.topdraw.business.basicdata.user.iptv.service.dto; 1 package com.topdraw.business.module.user.iptv.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import com.topdraw.annotation.Query;
5 4
6 /** 5 /**
7 * @author XiangHan 6 * @author XiangHan
......
1 package com.topdraw.business.basicdata.user.iptv.service.impl; 1 package com.topdraw.business.module.user.iptv.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.module.member.service.MemberService;
5 import com.topdraw.business.basicdata.member.service.MemberService; 5 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 6 import com.topdraw.business.module.user.iptv.domain.UserTv;
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; 7 import com.topdraw.utils.ValidationUtil;
14 import com.topdraw.business.basicdata.user.iptv.repository.UserTvRepository; 8 import com.topdraw.business.module.user.iptv.repository.UserTvRepository;
15 import com.topdraw.business.basicdata.user.iptv.service.UserTvService; 9 import com.topdraw.business.module.user.iptv.service.UserTvService;
16 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; 10 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
17 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria; 11 import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
18 import com.topdraw.business.basicdata.user.iptv.service.mapper.UserTvMapper; 12 import com.topdraw.business.module.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; 13 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.stereotype.Service; 14 import org.springframework.stereotype.Service;
24 import org.springframework.transaction.annotation.Propagation; 15 import org.springframework.transaction.annotation.Propagation;
...@@ -97,6 +88,16 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -97,6 +88,16 @@ public class UserTvServiceImpl implements UserTvService {
97 @Override 88 @Override
98 @Transactional(rollbackFor = Exception.class) 89 @Transactional(rollbackFor = Exception.class)
99 @AsyncMqSend 90 @AsyncMqSend
91 public void unbindPriorityMemberCode(UserTv resources) {
92 UserTv UserTv = UserTvRepository.findById(resources.getId()).orElseGet(UserTv::new);
93 ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId());
94 UserTv.copy(resources);
95 UserTvRepository.save(UserTv);
96 }
97
98 @Override
99 @Transactional(rollbackFor = Exception.class)
100 @AsyncMqSend
100 public void delete(Long id) { 101 public void delete(Long id) {
101 Assert.notNull(id, "The given id must not be null!"); 102 Assert.notNull(id, "The given id must not be null!");
102 UserTv UserTv = UserTvRepository.findById(id).orElseThrow( 103 UserTv UserTv = UserTvRepository.findById(id).orElseThrow(
...@@ -114,5 +115,25 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -114,5 +115,25 @@ public class UserTvServiceImpl implements UserTvService {
114 return null; 115 return null;
115 } 116 }
116 117
118 @Override
119 public UserTvDTO findByPriorityMemberCode(String memberCode) {
120 Optional<UserTv> userTv = UserTvRepository.findByPriorityMemberCode(memberCode);
121 if (userTv.isPresent()) {
122 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
123 return UserTvMapper.toDto(userTv.get());
124 }
125 return null;
126 }
127
128 @Override
129 public UserTvDTO findByMemberId(Long memberId) {
130 Optional<UserTv> userTv = UserTvRepository.findByMemberId(memberId);
131 if (userTv.isPresent()) {
132 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
133 return UserTvMapper.toDto(userTv.get());
134 }
135 return null;
136 }
137
117 138
118 } 139 }
......
1 package com.topdraw.business.basicdata.user.iptv.service.mapper; 1 package com.topdraw.business.module.user.iptv.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 4 import com.topdraw.business.module.user.iptv.domain.UserTv;
5 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; 5 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.module.user.weixin.collection.domain;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions;
5 import lombok.Data;
6 import lombok.experimental.Accessors;
7 import org.springframework.data.annotation.CreatedDate;
8 import org.springframework.data.annotation.LastModifiedDate;
9 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
10
11 import javax.persistence.*;
12 import java.io.Serializable;
13 import java.sql.Timestamp;
14
15 /**
16 * @author pengmengqing
17 * @date 2021-04-02
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_user_collection")
24 public class UserCollection 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 = "app_id")
34 private Long appId;
35
36 // 用户ID
37 @Column(name = "user_id")
38 private Long userId;
39
40 // 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
41 @Column(name = "type")
42 private Integer type;
43
44 // 收藏夹名称
45 @Column(name = "name")
46 private String name;
47
48 // 数量
49 @Column(name = "count")
50 private Integer count;
51
52 // 创建时间
53 @CreatedDate
54 @Column(name = "create_time")
55 private Timestamp createTime;
56
57 // 更新时间
58 @LastModifiedDate
59 @Column(name = "update_time")
60 private Timestamp updateTime;
61
62 public void copy(UserCollection source){
63 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
64 }
65 }
1 package com.topdraw.business.module.user.weixin.collection.domain;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions;
5 import lombok.Data;
6 import lombok.experimental.Accessors;
7 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
8
9 import javax.persistence.*;
10 import java.io.Serializable;
11 import java.sql.Timestamp;
12
13 /**
14 * @author pengmengqing
15 * @date 2021-04-02
16 */
17 @Entity
18 @Data
19 @EntityListeners(AuditingEntityListener.class)
20 @Accessors(chain = true)
21 @Table(name="uc_user_collection_detail")
22 public class UserCollectionDetail implements Serializable {
23
24 @ManyToOne(fetch = FetchType.EAGER)
25 @JoinColumn(name = "user_collection_id", insertable = false, updatable = false)
26 private UserCollection userCollection;
27
28 // ID
29 @Id
30 @GeneratedValue(strategy = GenerationType.IDENTITY)
31 @Column(name = "id")
32 private Long id;
33
34 // 收藏夹ID
35 @Column(name = "user_collection_id")
36 private Long userCollectionId;
37
38 // 自定义收藏内容的类型CODE,默认:DEFAULT
39 @Column(name = "detail_folder_code")
40 private String detailFolderCode;
41
42 // 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
43 @Column(name = "detail_type")
44 private String detailType;
45
46 // 收藏内容的ID
47 @Column(name = "detail_id")
48 private Long detailId;
49
50 // 收藏内容的CODE
51 @Column(name = "detail_code")
52 private String detailCode;
53
54 // 收藏内容的剧集ID
55 @Column(name = "detail_episode_id")
56 private Long detailEpisodeId;
57
58 // 收藏内容的剧集CODE
59 @Column(name = "detail_episode_code")
60 private String detailEpisodeCode;
61
62 // 收藏内容的名称
63 @Column(name = "detail_name")
64 private String detailName;
65
66 // 收藏内容的标记
67 @Column(name = "detail_mark")
68 private Integer detailMark;
69
70 // 收藏内容的图片
71 @Column(name = "detail_img")
72 private String detailImg;
73
74 // 收藏内容的剧集序号
75 @Column(name = "detail_index")
76 private Integer detailIndex;
77
78 // 收藏内容的剧集总数
79 @Column(name = "detail_total_index")
80 private Integer detailTotalIndex;
81
82 // 收藏内容的播放时间
83 @Column(name = "detail_play_time")
84 private Integer detailPlayTime;
85
86 // 收藏内容的总时间
87 @Column(name = "detail_total_time")
88 private Integer detailTotalTime;
89
90 // 收藏内容在同一folder中的顺序
91 @Column(name = "detail_sequence")
92 private Integer detailSequence;
93
94 // 收藏内容的评分
95 @Column(name = "detail_score")
96 private Float detailScore;
97
98 // 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
99 @Column(name = "detail_like")
100 private Integer detailLike;
101
102 // 收藏内容的扩展数据
103 @Column(name = "detail_ext_data")
104 private String detailExtData;
105
106 // 创建时间
107 @Column(name = "create_time")
108 private Timestamp createTime;
109
110 // 更新时间
111 @Column(name = "update_time")
112 private Timestamp updateTime;
113
114 public void copy(UserCollectionDetail source){
115 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
116 }
117 }
1 package com.topdraw.business.module.user.weixin.collection.repository;
2
3 import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Modifying;
7
8 import java.util.Optional;
9
10 /**
11 * @author pengmengqing
12 * @date 2021-04-02
13 */
14 public interface UserCollectionDetailRepository extends JpaRepository<UserCollectionDetail, Long>, JpaSpecificationExecutor<UserCollectionDetail> {
15
16 @Modifying
17 void deleteAllByUserCollectionId(Long userCollectionId);
18
19 Optional<UserCollectionDetail> findByDetailIdAndDetailTypeAndUserCollectionId(Long detailId, String detailType, Long userCollectionId);
20 }
1 package com.topdraw.business.module.user.weixin.collection.repository;
2
3
4 import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
5 import org.springframework.data.jpa.repository.JpaRepository;
6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
8 import java.util.List;
9 import java.util.Optional;
10
11 /**
12 * @author pengmengqing
13 * @date 2021-04-02
14 */
15 public interface UserCollectionRepository extends JpaRepository<UserCollection, Long>, JpaSpecificationExecutor<UserCollection> {
16
17 Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long userId, Integer type, String name);
18
19 List<UserCollection> findByUserIdAndType(Long userId, Integer type);
20
21 }
1 package com.topdraw.business.module.user.weixin.collection.service;
2
3 import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
4 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
5 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria;
6 import org.springframework.data.domain.Pageable;
7
8 import java.util.List;
9 import java.util.Map;
10
11 /**
12 * @author pengmengqing
13 * @date 2021-04-02
14 */
15 public interface UserCollectionDetailService {
16
17 /**
18 * 查询数据分页
19 * @param criteria 条件参数
20 * @param pageable 分页参数
21 * @return Map<String,Object>
22 */
23 Map<String,Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable);
24
25 /**
26 * 根据ID查询
27 * @param id ID
28 * @return UserCollectionDetailDTO
29 */
30 UserCollectionDetailDTO findById(Long id);
31
32 UserCollectionDetailDTO create(UserCollectionDetail resources);
33
34 void update(UserCollectionDetail resources);
35
36 void delete(Long id);
37
38 void deleteAllByUserCollectionId(Long id);
39
40 void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional);
41 }
1 package com.topdraw.business.module.user.weixin.collection.service;
2
3 import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
4 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
5 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria;
6 import org.springframework.data.domain.Pageable;
7
8 import javax.servlet.http.HttpServletResponse;
9 import java.io.IOException;
10 import java.util.List;
11 import java.util.Map;
12 import java.util.Optional;
13
14 /**
15 * @author pengmengqing
16 * @date 2021-04-02
17 */
18 public interface UserCollectionService {
19
20 /**
21 * 查询数据分页
22 * @param criteria 条件参数
23 * @param pageable 分页参数
24 * @return Map<String,Object>
25 */
26 Map<String,Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable);
27
28 /**
29 * 查询所有数据不分页
30 * @param criteria 条件参数
31 * @return List<UserCollectionDTO>
32 */
33 List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria);
34
35 /**
36 * 根据ID查询
37 * @param id ID
38 * @return UserCollectionDTO
39 */
40 UserCollectionDTO findById(Long id);
41
42 UserCollectionDTO create(UserCollection resources);
43
44 void update(UserCollection resources);
45
46 void delete(Long id);
47
48 void download(List<UserCollectionDTO> all, HttpServletResponse response) throws IOException;
49
50 List<UserCollection> findByUserIdAndType(Long id, Integer type);
51
52 Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name);
53
54 UserCollection save(UserCollection userCollection);
55 }
1 package com.topdraw.business.module.user.weixin.collection.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6 import java.sql.Timestamp;
7
8
9 /**
10 * @author pengmengqing
11 * @date 2021-04-02
12 */
13 @Data
14 public class UserCollectionDTO implements Serializable {
15
16 // ID
17 private Long id;
18
19 // 应用ID
20 private Long appId;
21
22 // 用户ID
23 private Long userId;
24
25 // 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
26 private Integer type;
27
28 // 收藏夹名称
29 private String name;
30
31 // 数量
32 private Integer count;
33
34 // 创建时间
35 private Timestamp createTime;
36
37 // 更新时间
38 private Timestamp updateTime;
39 }
1 package com.topdraw.business.module.user.weixin.collection.service.dto;
2
3 import com.fasterxml.jackson.annotation.JsonFormat;
4 import lombok.Data;
5
6 import java.io.Serializable;
7 import java.sql.Timestamp;
8
9
10 /**
11 * @author pengmengqing
12 * @date 2021-04-02
13 */
14 @Data
15 public class UserCollectionDetailDTO implements Serializable {
16
17 // ID
18 private Long id;
19
20 // 收藏夹ID
21 private Long userCollectionId;
22
23 // 自定义收藏内容的类型CODE,默认:DEFAULT
24 private String detailFolderCode;
25
26 // 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
27 private String detailType;
28
29 // 收藏内容的ID
30 private Long detailId;
31
32 // 收藏内容的CODE
33 private String detailCode;
34
35 // 收藏内容的剧集ID
36 private Long detailEpisodeId;
37
38 // 收藏内容的剧集CODE
39 private String detailEpisodeCode;
40
41 // 收藏内容的名称
42 private String detailName;
43
44 // 收藏内容的标记
45 private Integer detailMark;
46
47 // 收藏内容的图片
48 private String detailImg;
49
50 // 收藏内容的剧集序号
51 private Integer detailIndex;
52
53 // 收藏内容的剧集总数
54 private Integer detailTotalIndex;
55
56 // 收藏内容的播放时间
57 private Integer detailPlayTime;
58
59 // 收藏内容的总时间
60 private Integer detailTotalTime;
61
62 // 收藏内容在同一folder中的顺序
63 private Integer detailSequence;
64
65 // 收藏内容的评分
66 private Float detailScore;
67
68 // 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
69 private Integer detailLike;
70
71 // 收藏内容的扩展数据
72 private String detailExtData;
73
74 // 创建时间
75 @JsonFormat(
76 pattern = "MM月dd日 HH:mm",
77 timezone = "GMT+8"
78 )
79 private Timestamp createTime;
80
81 // 更新时间
82 @JsonFormat(
83 pattern = "MM月dd日 HH:mm",
84 timezone = "GMT+8"
85 )
86 private Timestamp updateTime;
87 }
1 package com.topdraw.business.module.user.weixin.collection.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 import javax.persistence.criteria.JoinType;
7
8 /**
9 * @author pengmengqing
10 * @date 2021-04-02
11 */
12 @Data
13 public class UserCollectionDetailQueryCriteria{
14
15 private Long userWeixinId;
16
17
18 @Query(joinType = JoinType.INNER, joinName = "userCollection")
19 private Long userId;
20
21 @Query(joinType = JoinType.INNER, joinName = "userCollection")
22 private Integer type;
23
24 private String detailType;
25
26 private String detailFolderCode = "DEFAULT";
27
28 private Long detailId;
29 }
1 package com.topdraw.business.module.user.weixin.collection.service.dto;
2
3 import lombok.Data;
4
5 /**
6 * @author pengmengqing
7 * @date 2021-04-02
8 */
9 @Data
10 public class UserCollectionQueryCriteria{
11 }
1 package com.topdraw.business.module.user.weixin.collection.service.impl;
2
3 import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
4 import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository;
5 import com.topdraw.business.module.user.weixin.collection.service.UserCollectionDetailService;
6 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
7 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria;
8 import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionDetailMapper;
9 import com.topdraw.utils.*;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.dao.EmptyResultDataAccessException;
12 import org.springframework.data.domain.Page;
13 import org.springframework.data.domain.Pageable;
14 import org.springframework.stereotype.Service;
15 import org.springframework.transaction.annotation.Propagation;
16 import org.springframework.transaction.annotation.Transactional;
17 import org.springframework.util.Assert;
18
19 import java.util.*;
20
21 /**
22 * @author pengmengqing
23 * @date 2021-04-02
24 */
25 @Service
26 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
27 public class UserCollectionDetailServiceImpl implements UserCollectionDetailService {
28
29 @Autowired
30 private UserCollectionDetailRepository userCollectionDetailRepository;
31
32 @Autowired
33 private UserCollectionDetailMapper userCollectionDetailMapper;
34
35 @Override
36 public Map<String, Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable) {
37 Page<UserCollectionDetail> page = userCollectionDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
38 return PageUtil.toPage(page.map(userCollectionDetailMapper::toDto));
39 }
40
41 @Override
42 public UserCollectionDetailDTO findById(Long id) {
43 UserCollectionDetail userCollectionDetail = userCollectionDetailRepository.findById(id).orElseGet(UserCollectionDetail::new);
44 ValidationUtil.isNull(userCollectionDetail.getId(),"UserCollectionDetail","id",id);
45 return userCollectionDetailMapper.toDto(userCollectionDetail);
46 }
47
48 @Override
49 @Transactional(rollbackFor = Exception.class)
50 public UserCollectionDetailDTO create(UserCollectionDetail resources) {
51 return userCollectionDetailMapper.toDto(userCollectionDetailRepository.save(resources));
52 }
53
54 @Override
55 @Transactional(rollbackFor = Exception.class)
56 public void update(UserCollectionDetail resources) {
57 UserCollectionDetail userCollectionDetail = userCollectionDetailRepository.findById(resources.getId()).orElseGet(UserCollectionDetail::new);
58 ValidationUtil.isNull( userCollectionDetail.getId(),"UserCollectionDetail","id",resources.getId());
59 userCollectionDetail.copy(resources);
60 userCollectionDetailRepository.save(userCollectionDetail);
61 }
62
63 @Override
64 @Transactional(rollbackFor = Exception.class)
65 public void delete(Long id) {
66 Assert.notNull(id, "The given id must not be null!");
67 UserCollectionDetail userCollectionDetail = userCollectionDetailRepository.findById(id).orElseThrow(
68 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserCollectionDetail.class, id), 1));
69 userCollectionDetailRepository.delete(userCollectionDetail);
70 }
71
72 @Override
73 @Transactional(rollbackFor = Exception.class)
74 public void deleteAllByUserCollectionId(Long id) {
75 this.userCollectionDetailRepository.deleteAllByUserCollectionId(id);
76 }
77
78 @Override
79 @Transactional(rollbackFor = Exception.class)
80 public void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional) {
81 this.userCollectionDetailRepository.deleteAll(userCollectionDetailOptional);
82 }
83
84 }
1 package com.topdraw.business.module.user.weixin.collection.service.impl;
2
3 import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
4 import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionRepository;
5 import com.topdraw.business.module.user.weixin.collection.service.UserCollectionService;
6 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
7 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria;
8 import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionMapper;
9 import com.topdraw.utils.FileUtil;
10 import com.topdraw.utils.PageUtil;
11 import com.topdraw.utils.QueryHelp;
12 import com.topdraw.utils.ValidationUtil;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.dao.EmptyResultDataAccessException;
15 import org.springframework.data.domain.Page;
16 import org.springframework.data.domain.Pageable;
17 import org.springframework.stereotype.Service;
18 import org.springframework.transaction.annotation.Propagation;
19 import org.springframework.transaction.annotation.Transactional;
20 import org.springframework.util.Assert;
21
22 import javax.servlet.http.HttpServletResponse;
23 import java.io.IOException;
24 import java.util.*;
25
26 /**
27 * @author pengmengqing
28 * @date 2021-04-02
29 */
30 @Service
31 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
32 public class UserCollectionServiceImpl implements UserCollectionService {
33
34 @Autowired
35 private UserCollectionRepository userCollectionRepository;
36
37 @Autowired
38 private UserCollectionMapper userCollectionMapper;
39
40
41
42 @Override
43 public Map<String, Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable) {
44 Page<UserCollection> page = userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
45 return PageUtil.toPage(page.map(userCollectionMapper::toDto));
46 }
47
48 @Override
49 public List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria) {
50 return userCollectionMapper.toDto(userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
51 }
52
53 @Override
54 public UserCollectionDTO findById(Long id) {
55 UserCollection userCollection = userCollectionRepository.findById(id).orElseGet(UserCollection::new);
56 ValidationUtil.isNull(userCollection.getId(),"UserCollection","id",id);
57 return userCollectionMapper.toDto(userCollection);
58 }
59
60 @Override
61 @Transactional(rollbackFor = Exception.class)
62 public UserCollectionDTO create(UserCollection resources) {
63 return userCollectionMapper.toDto(userCollectionRepository.save(resources));
64 }
65
66 @Override
67 @Transactional(rollbackFor = Exception.class)
68 public void update(UserCollection resources) {
69 UserCollection userCollection = userCollectionRepository.findById(resources.getId()).orElseGet(UserCollection::new);
70 ValidationUtil.isNull( userCollection.getId(),"UserCollection","id",resources.getId());
71 userCollection.copy(resources);
72 userCollectionRepository.save(userCollection);
73 }
74
75 @Override
76 @Transactional(rollbackFor = Exception.class)
77 public void delete(Long id) {
78 Assert.notNull(id, "The given id must not be null!");
79 UserCollection userCollection = userCollectionRepository.findById(id).orElseThrow(
80 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserCollection.class, id), 1));
81 userCollectionRepository.delete(userCollection);
82 }
83
84
85 @Override
86 public void download(List<UserCollectionDTO> all, HttpServletResponse response) throws IOException {
87 List<Map<String, Object>> list = new ArrayList<>();
88 for (UserCollectionDTO userCollection : all) {
89 Map<String, Object> map = new LinkedHashMap<>();
90 map.put("应用ID", userCollection.getAppId());
91 // map.put("用户ID", userCollection.getSubscriberId());
92 // map.put("platformAccount", userCollection.getPlatformAccount());
93 map.put("收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅", userCollection.getType());
94 map.put("收藏夹名称", userCollection.getName());
95 map.put("数量", userCollection.getCount());
96 map.put("创建时间", userCollection.getCreateTime());
97 map.put("更新时间", userCollection.getUpdateTime());
98 list.add(map);
99 }
100 FileUtil.downloadExcel(list, response);
101 }
102
103 @Override
104 public List<UserCollection> findByUserIdAndType(Long id, Integer type) {
105 return this.userCollectionRepository.findByUserIdAndType(id,type);
106 }
107
108 @Override
109 public Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name) {
110 return Optional.empty();
111 }
112
113 @Override
114 public UserCollection save(UserCollection userCollection) {
115 this.userCollectionRepository.save(userCollection);
116 return userCollection;
117 }
118
119
120 }
1 package com.topdraw.business.module.user.weixin.collection.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
5 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author pengmengqing
11 * @date 2021-04-02
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface UserCollectionDetailMapper extends BaseMapper<UserCollectionDetailDTO, UserCollectionDetail> {
15
16 }
1 package com.topdraw.business.module.user.weixin.collection.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
5 import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author pengmengqing
11 * @date 2021-04-02
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface UserCollectionMapper extends BaseMapper<UserCollectionDTO, UserCollection> {
15
16 }
1 package com.topdraw.business.basicdata.user.weixin.domain; 1 package com.topdraw.business.module.user.weixin.domain;
2 2
3 import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
3 import lombok.Data; 4 import lombok.Data;
4 import lombok.experimental.Accessors; 5 import lombok.experimental.Accessors;
5 import cn.hutool.core.bean.BeanUtil; 6 import cn.hutool.core.bean.BeanUtil;
...@@ -21,7 +22,7 @@ import java.io.Serializable; ...@@ -21,7 +22,7 @@ import java.io.Serializable;
21 @EntityListeners(AuditingEntityListener.class) 22 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true) 23 @Accessors(chain = true)
23 @Table(name="uc_user_weixin") 24 @Table(name="uc_user_weixin")
24 public class UserWeixin implements Serializable { 25 public class UserWeixin extends DefaultAsyncMqModule implements Serializable {
25 26
26 // ID 27 // ID
27 @Id 28 @Id
......
1 package com.topdraw.business.module.user.weixin.repository;
2
3 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Modifying;
7 import org.springframework.data.jpa.repository.Query;
8 import org.springframework.data.repository.query.Param;
9
10 import javax.transaction.Transactional;
11 import java.util.Optional;
12
13 /**
14 * @author XiangHan
15 * @date 2021-12-16
16 */
17 public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, JpaSpecificationExecutor<UserWeixin> {
18
19 Optional<UserWeixin> findFirstByMemberIdAndAppid(Long memberId, String appid);
20
21 Optional<UserWeixin> findFirstByUnionidAndAppidAndOpenid(String unionId, String appId, String openId);
22
23 Optional<UserWeixin> findFirstByAppidAndOpenid(String appId, String openId);
24
25 Optional<UserWeixin> findFirstByUnionid(String unionid);
26
27 Optional<UserWeixin> findFirstByUnionidAndAppid(String unionid, String appId);
28
29 @Modifying
30 @Transactional
31 @Query(value = "update uc_user_weixin set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true)
32 void updateTime(@Param("resources") UserWeixin resources);
33 }
1 package com.topdraw.business.basicdata.user.weixin.rest; 1 package com.topdraw.business.module.user.weixin.rest;
2 2
3 import com.topdraw.annotation.AnonymousAccess;
3 import com.topdraw.common.ResultInfo; 4 import com.topdraw.common.ResultInfo;
4 import com.topdraw.aop.log.Log; 5 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
5 import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; 6 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
6 import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService; 7 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
7 import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 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; 10 import org.springframework.validation.annotation.Validated;
13 import org.springframework.web.bind.annotation.*; 11 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*; 12 import io.swagger.annotations.*;
15 import java.io.IOException;
16 import javax.servlet.http.HttpServletResponse;
17 13
18 /** 14 /**
19 * @author XiangHan 15 * @author XiangHan
...@@ -21,7 +17,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -21,7 +17,7 @@ import javax.servlet.http.HttpServletResponse;
21 */ 17 */
22 @Api(tags = "UserWeixin管理") 18 @Api(tags = "UserWeixin管理")
23 @RestController 19 @RestController
24 @RequestMapping("/api/UserWeixin") 20 @RequestMapping("/ucEngine/api/userWeixin")
25 public class UserWeixinController { 21 public class UserWeixinController {
26 22
27 @Autowired 23 @Autowired
...@@ -39,24 +35,30 @@ public class UserWeixinController { ...@@ -39,24 +35,30 @@ public class UserWeixinController {
39 return ResultInfo.success(UserWeixinService.queryAll(criteria)); 35 return ResultInfo.success(UserWeixinService.queryAll(criteria));
40 } 36 }
41 37
42 @Log 38 @PostMapping(value = "/create")
43 @PostMapping
44 @ApiOperation("新增UserWeixin") 39 @ApiOperation("新增UserWeixin")
40 @AnonymousAccess
45 public ResultInfo create(@Validated @RequestBody UserWeixin resources) { 41 public ResultInfo create(@Validated @RequestBody UserWeixin resources) {
46 UserWeixinService.create(resources); 42 UserWeixinService.create(resources);
47 return ResultInfo.success(); 43 return ResultInfo.success();
48 } 44 }
49 45
50 @Log 46 @PutMapping(value = "/update")
51 @PutMapping
52 @ApiOperation("修改UserWeixin") 47 @ApiOperation("修改UserWeixin")
48 @AnonymousAccess
53 public ResultInfo update(@Validated @RequestBody UserWeixin resources) { 49 public ResultInfo update(@Validated @RequestBody UserWeixin resources) {
54 UserWeixinService.update(resources); 50 UserWeixinService.update(resources);
55 return ResultInfo.success(); 51 return ResultInfo.success();
56 } 52 }
57 53
54 @PutMapping(value = "/updateWeixinMemberProfile")
55 @ApiOperation("修改UserWeixin")
56 @AnonymousAccess
57 public ResultInfo updateWeixinMemberProfile(@Validated @RequestBody UserWeixin resources) {
58 UserWeixinService.update(resources);
59 return ResultInfo.success();
60 }
58 61
59 @Log
60 @DeleteMapping(value = "/{id}") 62 @DeleteMapping(value = "/{id}")
61 @ApiOperation("删除UserWeixin") 63 @ApiOperation("删除UserWeixin")
62 public ResultInfo delete(@PathVariable Long id) { 64 public ResultInfo delete(@PathVariable Long id) {
......
1 package com.topdraw.business.basicdata.user.weixin.service; 1 package com.topdraw.business.module.user.weixin.service;
2 2
3 import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; 3 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
4 import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO; 4 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
5 import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria; 5 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.List; 8 import java.util.List;
9 import java.io.IOException; 9 import java.util.Optional;
10 import javax.servlet.http.HttpServletResponse;
11 10
12 /** 11 /**
13 * @author XiangHan 12 * @author XiangHan
...@@ -37,10 +36,21 @@ public interface UserWeixinService { ...@@ -37,10 +36,21 @@ public interface UserWeixinService {
37 */ 36 */
38 UserWeixinDTO findById(Long id); 37 UserWeixinDTO findById(Long id);
39 38
40 void create(UserWeixin resources); 39 UserWeixin create(UserWeixin resources);
41 40
42 void update(UserWeixin resources); 41 void update(UserWeixin resources);
43 42
43 void updateTime(UserWeixin resources);
44
44 void delete(Long id); 45 void delete(Long id);
45 46
47 UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid);
48
49 UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId);
50
51 UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId);
52
53 UserWeixinDTO findFirstByUnionId(String unionid);
54
55 UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId);
46 } 56 }
......
1 package com.topdraw.business.basicdata.user.weixin.service.dto; 1 package com.topdraw.business.module.user.weixin.service.dto;
2 2
3 import lombok.AllArgsConstructor;
4 import lombok.Builder;
3 import lombok.Data; 5 import lombok.Data;
6 import lombok.NoArgsConstructor;
7
4 import java.sql.Timestamp; 8 import java.sql.Timestamp;
5 import java.io.Serializable; 9 import java.io.Serializable;
6 10
...@@ -90,11 +94,13 @@ public class UserWeixinDTO implements Serializable { ...@@ -90,11 +94,13 @@ public class UserWeixinDTO implements Serializable {
90 // 授权时间 94 // 授权时间
91 private Timestamp authTime; 95 private Timestamp authTime;
92 96
93 private Integer sex; 97 private Integer gender;
94 98
95 private String country; 99 private String country;
96 100
97 private String province; 101 private String province;
98 102
99 private String city; 103 private String city;
104
105 private Integer sex;
100 } 106 }
......
1 package com.topdraw.business.basicdata.user.weixin.service.dto; 1 package com.topdraw.business.module.user.weixin.service.dto;
2 2
3 import lombok.Data;
4 import com.topdraw.annotation.Query; 3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5 5
6 /** 6 /**
7 * @author XiangHan 7 * @author XiangHan
...@@ -9,4 +9,8 @@ import com.topdraw.annotation.Query; ...@@ -9,4 +9,8 @@ import com.topdraw.annotation.Query;
9 */ 9 */
10 @Data 10 @Data
11 public class UserWeixinQueryCriteria{ 11 public class UserWeixinQueryCriteria{
12
13 @Query()
14 private String unionId;
15
12 } 16 }
......
1 package com.topdraw.business.basicdata.user.weixin.service.impl; 1 package com.topdraw.business.module.user.weixin.service.impl;
2 2
3 import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
4 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.utils.FileUtil; 6 import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository;
6 import com.topdraw.business.basicdata.user.weixin.repository.UserWeixinRepository; 7 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
7 import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService; 8 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
8 import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO; 9 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
9 import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria; 10 import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper;
10 import com.topdraw.business.basicdata.user.weixin.service.mapper.UserWeixinMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
...@@ -18,14 +18,9 @@ import org.springframework.data.domain.Pageable; ...@@ -18,14 +18,9 @@ import org.springframework.data.domain.Pageable;
18 import org.springframework.util.Assert; 18 import org.springframework.util.Assert;
19 import com.topdraw.utils.PageUtil; 19 import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp; 20 import com.topdraw.utils.QueryHelp;
21 import com.topdraw.utils.StringUtils;
22 21
23 import java.util.List; 22 import java.util.List;
24 import java.util.Map; 23 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 24
30 /** 25 /**
31 * @author XiangHan 26 * @author XiangHan
...@@ -61,12 +56,15 @@ public class UserWeixinServiceImpl implements UserWeixinService { ...@@ -61,12 +56,15 @@ public class UserWeixinServiceImpl implements UserWeixinService {
61 56
62 @Override 57 @Override
63 @Transactional(rollbackFor = Exception.class) 58 @Transactional(rollbackFor = Exception.class)
64 public void create(UserWeixin resources) { 59 @AsyncMqSend
60 public UserWeixin create(UserWeixin resources) {
65 UserWeixinRepository.save(resources); 61 UserWeixinRepository.save(resources);
62 return resources;
66 } 63 }
67 64
68 @Override 65 @Override
69 @Transactional(rollbackFor = Exception.class) 66 @Transactional(rollbackFor = Exception.class)
67 @AsyncMqSend
70 public void update(UserWeixin resources) { 68 public void update(UserWeixin resources) {
71 UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new); 69 UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new);
72 ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); 70 ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId());
...@@ -75,6 +73,12 @@ public class UserWeixinServiceImpl implements UserWeixinService { ...@@ -75,6 +73,12 @@ public class UserWeixinServiceImpl implements UserWeixinService {
75 } 73 }
76 74
77 @Override 75 @Override
76 @AsyncMqSend
77 public void updateTime(UserWeixin resources) {
78 UserWeixinRepository.updateTime(resources);
79 }
80
81 @Override
78 @Transactional(rollbackFor = Exception.class) 82 @Transactional(rollbackFor = Exception.class)
79 public void delete(Long id) { 83 public void delete(Long id) {
80 Assert.notNull(id, "The given id must not be null!"); 84 Assert.notNull(id, "The given id must not be null!");
...@@ -83,5 +87,35 @@ public class UserWeixinServiceImpl implements UserWeixinService { ...@@ -83,5 +87,35 @@ public class UserWeixinServiceImpl implements UserWeixinService {
83 UserWeixinRepository.delete(UserWeixin); 87 UserWeixinRepository.delete(UserWeixin);
84 } 88 }
85 89
90 @Override
91 public UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid) {
92 UserWeixin userWeixin = this.UserWeixinRepository.findFirstByMemberIdAndAppid(memberId, appid).orElseGet(UserWeixin::new);
93 ValidationUtil.isNull(userWeixin.getId(),"UserWeixin","id",memberId);
94 return UserWeixinMapper.toDto(userWeixin);
95 }
96
97 @Override
98 public UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId) {
99 UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionidAndAppidAndOpenid(unionId, appId,openId).orElseGet(UserWeixin::new);
100 return UserWeixinMapper.toDto(userWeixin);
101 }
102
103 @Override
104 public UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId) {
105 UserWeixin userWeixin = this.UserWeixinRepository.findFirstByAppidAndOpenid(appId,openId).orElseGet(UserWeixin::new);
106 return UserWeixinMapper.toDto(userWeixin);
107 }
108
109 @Override
110 public UserWeixinDTO findFirstByUnionId(String unionid) {
111 UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionid(unionid).orElseGet(UserWeixin::new);
112 return UserWeixinMapper.toDto(userWeixin);
113 }
114
115 @Override
116 public UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId) {
117 UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionidAndAppid(unionid,appId).orElseGet(UserWeixin::new);
118 return UserWeixinMapper.toDto(userWeixin);
119 }
86 120
87 } 121 }
......
1 package com.topdraw.business.basicdata.user.weixin.service.mapper; 1 package com.topdraw.business.module.user.weixin.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin; 4 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
5 import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO; 5 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
......
1 package com.topdraw.business.module.weixin.domain;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions;
5 import lombok.Data;
6 import lombok.experimental.Accessors;
7 import org.springframework.data.annotation.CreatedDate;
8 import org.springframework.data.annotation.LastModifiedDate;
9 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
10
11 import javax.persistence.*;
12 import java.io.Serializable;
13 import java.sql.Timestamp;
14
15 /**
16 * @author pengmengqing
17 * @date 2021-01-28
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_user_weixin__weixin_message_template")
24 public class UserWeixinWeixinMessageTemplate 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 = "user_weixin_id", nullable = false)
34 private Long userWeixinId;
35
36 // 微信消息模板id
37 @Column(name = "weixin_message_template_id", nullable = false)
38 private Long weixinMessageTemplateId;
39
40 // 用户是否订阅: 0-否, 1-是
41 @Column(name = "status", nullable = false)
42 private Integer status;
43
44 // 创建时间
45 @CreatedDate
46 @Column(name = "create_time")
47 private Timestamp createTime;
48
49 // 更新时间
50 @LastModifiedDate
51 @Column(name = "update_time")
52 private Timestamp updateTime;
53
54 public void copy(UserWeixinWeixinMessageTemplate source){
55 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
56 }
57 }
1 package com.topdraw.business.module.weixin.domain;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions;
5 import lombok.Data;
6 import lombok.experimental.Accessors;
7 import org.springframework.data.annotation.CreatedDate;
8 import org.springframework.data.annotation.LastModifiedDate;
9 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
10
11 import javax.persistence.*;
12 import java.io.Serializable;
13 import java.sql.Timestamp;
14
15 /**
16 * @author pengmengqing
17 * @date 2021-01-28
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_weixin_message_template")
24 public class WeixinMessageTemplate implements Serializable {
25
26 // ID
27 @Id
28 @GeneratedValue(strategy = GenerationType.IDENTITY)
29 @Column(name = "id")
30 private Long id;
31
32 // 标识 order-下单成功通知,cancellation-核销成功通知
33 @Column(name = "code", nullable = false)
34 private String code;
35
36 // 微信appid
37 @Column(name = "appid", nullable = false)
38 private String appid;
39
40 // 微信模板id
41 @Column(name = "template_id", nullable = false)
42 private String templateId;
43
44 // 状态:0-无效,1-有效
45 @Column(name = "status", nullable = false)
46 private Integer status;
47
48 // 描述
49 @Column(name = "description")
50 private String description;
51
52 // 创建时间
53 @CreatedDate
54 @Column(name = "create_time")
55 private Timestamp createTime;
56
57 // 更新时间
58 @LastModifiedDate
59 @Column(name = "update_time")
60 private Timestamp updateTime;
61
62 public void copy(WeixinMessageTemplate source){
63 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
64 }
65 }
1 package com.topdraw.business.module.weixin.repository;
2
3 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
7
8 /**
9 * @author pengmengqing
10 * @date 2021-01-28
11 */
12 public interface UserWeixinWeixinMessageTemplateRepository extends JpaRepository<UserWeixinWeixinMessageTemplate, Long>, JpaSpecificationExecutor<UserWeixinWeixinMessageTemplate> {
13
14 }
1 package com.topdraw.business.module.weixin.repository;
2
3
4 import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
5 import org.springframework.data.jpa.repository.JpaRepository;
6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
8 import java.util.Optional;
9
10 /**
11 * @author pengmengqing
12 * @date 2021-01-28
13 */
14 public interface WeixinMessageTemplateRepository extends JpaRepository<WeixinMessageTemplate, Long>, JpaSpecificationExecutor<WeixinMessageTemplate> {
15
16 Optional<WeixinMessageTemplate> findFirstByCode(String code);
17
18 Optional<WeixinMessageTemplate> findFirstByCodeAndAppid(String code, String appid);
19
20 Optional<WeixinMessageTemplate> findFirstByTemplateId(String templateId);
21 }
1 package com.topdraw.business.module.weixin.rest;
2
3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService;
5 import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
6 import com.topdraw.common.ResultInfo;
7 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiOperation;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.web.bind.annotation.PostMapping;
11 import org.springframework.web.bind.annotation.RequestBody;
12 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RestController;
14
15 import java.util.ArrayList;
16
17 /**
18 * @author pengmengqing
19 * @date 2021-01-28
20 */
21 @Api(tags = "UserWeixinWeixinMessageTemplate管理")
22 @RestController
23 @RequestMapping("/ucEngine/api/UserWeixinWeixinMessageTemplate")
24 public class UserWeixinWeixinMessageTemplateController {
25
26 @Autowired
27 private UserWeixinWeixinMessageTemplateService userWeixinWeixinMessageTemplateService;
28
29 @AnonymousAccess
30 @PostMapping
31 @ApiOperation("新增或修改MemberWeixinMessageTemplate")
32 public ResultInfo createOrUpdate(@RequestBody UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) {
33 userWeixinWeixinMessageTemplateService.createOrUpdate(criteria);
34 return ResultInfo.success(new ArrayList<>());
35 }
36
37 }
1 package com.topdraw.business.module.weixin.service;
2
3
4 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
5 import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
6 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
7 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria;
8 import org.springframework.data.domain.Pageable;
9
10 import javax.servlet.http.HttpServletResponse;
11 import java.io.IOException;
12 import java.util.List;
13 import java.util.Map;
14
15 /**
16 * @author pengmengqing
17 * @date 2021-01-28
18 */
19 public interface UserWeixinWeixinMessageTemplateService {
20
21 void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria);
22 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import lombok.Data;
4
5 import java.util.List;
6
7 @Data
8 public class UpdateUserWeixinWeixinMessageTemplateQueryCriteria {
9 private Long memberId;
10
11 private List<UserWeixinWeixinMessageTemplateQueryCriteria> templateList;
12
13 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6 import java.sql.Timestamp;
7
8
9 /**
10 * @author pengmengqing
11 * @date 2021-01-28
12 */
13 @Data
14 public class UserWeixinWeixinMessageTemplateDTO implements Serializable {
15
16 // ID
17 private Long id;
18
19 // 用户id
20 private Long userWeixinId;
21
22 // 微信消息模板id
23 private Long weixinMessageTemplateId;
24
25 // 用户是否订阅: 0-否, 1-是
26 private Integer status;
27
28 // 创建时间
29 private Timestamp createTime;
30
31 // 更新时间
32 private Timestamp updateTime;
33 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 /**
7 * @author pengmengqing
8 * @date 2021-01-28
9 */
10 @Data
11 public class UserWeixinWeixinMessageTemplateQueryCriteria {
12 // 用户id
13 @Query(propName = "userWeixinId")
14 private Long memberId;
15
16 // 微信消息模板id
17 @Query
18 private Long weixinMessageTemplateId;
19
20 // 用户是否订阅: 0-否, 1-是
21 @Query
22 private Integer status = 1;
23
24 private String templateId;
25 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6
7
8 /**
9 * @author pengmengqing
10 * @date 2021-01-28
11 */
12 @Data
13 public class WeixinMessageTemplateDTO implements Serializable {
14
15 // ID
16 private Long id;
17
18 // 标识 order-下单成功通知,cancellation-核销成功通知
19 private String code;
20
21 // 微信模板id
22 private String templateId;
23
24 // 描述
25 private String description;
26 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 import java.util.List;
7
8 /**
9 * @author pengmengqing
10 * @date 2021-01-28
11 */
12 @Data
13 public class WeixinMessageTemplateQueryCriteria{
14
15 private String codes;
16
17 @Query(propName = "code", type = Query.Type.IN)
18 private List<String> codeList;
19
20 @Query
21 private String appid;
22
23 @Query
24 private Integer status = 1;
25 }
1 package com.topdraw.business.module.weixin.service.impl;
2
3
4 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
5 import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
6 import com.topdraw.business.module.weixin.repository.UserWeixinWeixinMessageTemplateRepository;
7 import com.topdraw.business.module.weixin.repository.WeixinMessageTemplateRepository;
8 import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService;
9 import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
10 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
11 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria;
12 import com.topdraw.business.module.weixin.service.mapper.UserWeixinWeixinMessageTemplateMapper;
13 import com.topdraw.utils.FileUtil;
14 import com.topdraw.utils.PageUtil;
15 import com.topdraw.utils.QueryHelp;
16 import com.topdraw.utils.ValidationUtil;
17 import lombok.extern.slf4j.Slf4j;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.dao.EmptyResultDataAccessException;
20 import org.springframework.data.domain.Page;
21 import org.springframework.data.domain.Pageable;
22 import org.springframework.stereotype.Service;
23 import org.springframework.transaction.annotation.Propagation;
24 import org.springframework.transaction.annotation.Transactional;
25 import org.springframework.util.Assert;
26
27 import javax.servlet.http.HttpServletResponse;
28 import java.io.IOException;
29 import java.util.*;
30
31 /**
32 * @author pengmengqing
33 * @date 2021-01-28
34 */
35 @Service
36 @Slf4j
37 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
38 public class UserWeixinWeixinMessageTemplateServiceImpl implements UserWeixinWeixinMessageTemplateService {
39
40 @Autowired
41 private UserWeixinWeixinMessageTemplateRepository userWeixinWeixinMessageTemplateRepository;
42
43 @Autowired
44 private WeixinMessageTemplateRepository weixinMessageTemplateRepository;
45
46 @Override
47 @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
48 public void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) {
49 for (UserWeixinWeixinMessageTemplateQueryCriteria queryCriteria : criteria.getTemplateList()) {
50 queryCriteria.setMemberId(criteria.getMemberId());
51 Integer status = queryCriteria.getStatus();
52 queryCriteria.setStatus(null);
53 String templateId = queryCriteria.getTemplateId();
54 Optional<WeixinMessageTemplate> templateOptional = weixinMessageTemplateRepository.findFirstByTemplateId(templateId);
55 if (!templateOptional.isPresent()) {
56 log.info("template " + templateId + " not exist");
57 continue;
58 }
59 Long id = templateOptional.get().getId();
60 queryCriteria.setWeixinMessageTemplateId(id);
61 Optional<UserWeixinWeixinMessageTemplate> optional = userWeixinWeixinMessageTemplateRepository.findOne(((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, queryCriteria, criteriaBuilder)));
62 if (!optional.isPresent()) {
63 UserWeixinWeixinMessageTemplate userWeixinWeixinMessageTemplate = new UserWeixinWeixinMessageTemplate();
64 userWeixinWeixinMessageTemplate.setUserWeixinId(queryCriteria.getMemberId())
65 .setWeixinMessageTemplateId(queryCriteria.getWeixinMessageTemplateId())
66 .setStatus(status);
67 userWeixinWeixinMessageTemplateRepository.save(userWeixinWeixinMessageTemplate);
68 } else {
69 UserWeixinWeixinMessageTemplate UserWeixinWeixinMessageTemplate = optional.get();
70 if (!status.equals(UserWeixinWeixinMessageTemplate.getStatus())) {
71 UserWeixinWeixinMessageTemplate.setStatus(status);
72 userWeixinWeixinMessageTemplateRepository.save(UserWeixinWeixinMessageTemplate);
73 }
74 }
75 }
76 }
77 }
1 package com.topdraw.business.module.weixin.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
5 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author pengmengqing
11 * @date 2021-01-28
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface UserWeixinWeixinMessageTemplateMapper extends BaseMapper<UserWeixinWeixinMessageTemplateDTO, UserWeixinWeixinMessageTemplate> {
15
16 }
1 package com.topdraw.business.module.weixin.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
5 import com.topdraw.business.module.weixin.service.dto.WeixinMessageTemplateDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author pengmengqing
11 * @date 2021-01-28
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface WeixinMessageTemplateMapper extends BaseMapper<WeixinMessageTemplateDTO, WeixinMessageTemplate> {
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 import javax.validation.constraints.NotNull;
9
10 @Data
11 @AllArgsConstructor
12 @NoArgsConstructor
13 public class TempCustomPointBean extends TempIptvUser {
14
15 /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */
16 @Transient
17 @NotNull(message = "设备类型不得为空")
18 protected Integer deviceType;
19
20 /** 订单id */
21 @Transient
22 protected Long orderId;
23
24 /** 节目id(针对观影操作) */
25 @Transient
26 protected Long mediaId;
27
28 /** 活动id(针对参与活动) */
29 @Transient
30 protected Long activityId;
31
32 /** 商品id */
33 @Transient
34 protected Long itemId;
35
36 /** 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;98:系统操作;99:其他 */
37 @Transient
38 protected Integer evtType;
39
40 }
...@@ -5,12 +5,16 @@ import lombok.Data; ...@@ -5,12 +5,16 @@ import lombok.Data;
5 import lombok.NoArgsConstructor; 5 import lombok.NoArgsConstructor;
6 6
7 import javax.persistence.Transient; 7 import javax.persistence.Transient;
8 import javax.validation.constraints.NotNull;
9 import java.sql.Timestamp;
8 10
9 @Data 11 @Data
10 @AllArgsConstructor 12 @AllArgsConstructor
11 @NoArgsConstructor 13 @NoArgsConstructor
12 public class TempIptvUser { 14 public class TempIptvUser {
13 15
16 private String unionid;
17
14 // 账户 18 // 账户
15 @Transient 19 @Transient
16 private String platformAccount; 20 private String platformAccount;
...@@ -20,5 +24,70 @@ public class TempIptvUser { ...@@ -20,5 +24,70 @@ public class TempIptvUser {
20 private Long points; 24 private Long points;
21 25
22 26
27 // ID
28 private Long id;
29
30 // 人ID
31 private Long personId;
32
33 // 运营商平台
34 private String platform;
35
36 // 手机号
37 private String cellphone;
38
39 // 用户名
40 private String username;
41
42 // 密码 MD5
43 private String password;
44
45 // 昵称 Base64
46 private String nickname;
47
48 // 头像
49 private String image;
50
51 // 登录天数(总天数)
52 private Integer loginDays;
53
54 // 连续登录天数
55 private Integer continueDays;
56
57 // 活跃时间
58 private Timestamp activeTime;
59
60 // 分组 分组ID用逗号分隔
61 private String groups;
62
63 // 标签 标签用逗号分隔
64 private String tags;
65
66 // 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录
67 private Integer loginType;
68
69 // 状态 0-下线 1-上线
70 private Integer status;
71
72 // 描述
73 private String description;
74
75 // 创建者
76 private String createBy;
77
78 // 创建时间
79 private Timestamp createTime;
80
81 // 更新者
82 private String updateBy;
83
84 // 更新时间
85 private Timestamp updateTime;
86
87 // 会员id
88 private Long memberId;
89
90 private String memberCode;
91
23 92
24 } 93 }
......
1 package com.topdraw.business.process.domian;
2
3 public interface UnbindGroup {
4 }
1 package com.topdraw.business.process.domian.result;
2
3 public interface TaskTemplateType {
4
5 int TYPE_1 = 1;
6 int TYPE_2 = 2;
7 int TYPE_3 = 3;
8 int TYPE_4 = 4;
9
10 }
1 package com.topdraw.business.process.domian.weixin;
2
3
4 import com.alibaba.fastjson.JSONObject;
5 import lombok.Data;
6
7 @Data
8 public class BindBean extends WeiXinUserBean {
9
10 private Long platformUserId;
11
12 private String platformAccount;
13 }
1 package com.topdraw.business.process.domian.weixin;
2
3 import com.fasterxml.jackson.annotation.JsonFormat;
4 import lombok.Data;
5
6 import java.time.LocalDateTime;
7
8 /**
9 * 微信账户信息
10 * @author XiangHan
11 * @date 2021-01-18
12 */
13 @Data
14 public class BuyVipBean extends WeiXinUserBean {
15
16 private Integer vip;
17
18 @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
19 private LocalDateTime vipExpireTime;
20
21
22 }
1 package com.topdraw.business.process.domian.weixin;
2
3
4 import com.alibaba.fastjson.JSONObject;
5 import lombok.Data;
6
7 @Data
8 public class SubscribeBean extends WeiXinUserBean {
9
10 private JSONObject userInfoJson;
11
12 private JSONObject iptvUserInfo;
13
14 private String msgType;
15
16 private String event;
17
18
19 /** */
20 private String openId;
21
22 /** */
23 private String appId;
24
25 /** */
26 private String eventKey;
27
28 private String unionid;
29 private String nickname;
30 private String headimgurl;
31
32 }
1 package com.topdraw.business.process.domian.weixin;
2
3 import lombok.AllArgsConstructor;
4 import lombok.Data;
5 import lombok.NoArgsConstructor;
6
7 import javax.validation.constraints.NotNull;
8
9 @Data
10 @AllArgsConstructor
11 @NoArgsConstructor
12 public class SubscribeBeanEvent {
13
14 @NotNull(message = "【content】 not be null !!!")
15 private String content;
16
17 }
1 package com.topdraw.business.process.domian.weixin;
2
3
4 import com.alibaba.fastjson.annotation.JSONField;
5 import com.topdraw.annotation.Query;
6 import lombok.Data;
7
8 import java.sql.Timestamp;
9
10 @Data
11 public class UserCollectionMq {
12
13 // 应用ID
14 @JSONField(name = "app_id")
15 private Long appId;
16
17 @JSONField(name = "userId")
18 private Long userId;
19
20 // 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
21 private Integer type;
22
23 // 收藏夹名称
24 private String name;
25
26 // 数量
27 private Integer count;
28
29 private String images;
30
31 // 收藏夹ID
32 @JSONField(name = "user_collection_id")
33 @Query
34 private Long userCollectionId;
35
36 // 自定义收藏内容的类型CODE,默认:DEFAULT
37 @JSONField(name = "detail_folder_code")
38 @Query
39 private String detailFolderCode;
40
41 // 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
42 @JSONField(name = "detail_type")
43 @Query
44 private String detailType;
45
46 // 收藏内容的ID
47 @JSONField(name = "detail_id")
48 @Query
49 private Long detailId;
50
51 // 收藏内容的CODE
52 @JSONField(name = "detail_code")
53 @Query
54 private String detailCode;
55
56 // 收藏内容的剧集ID
57 @JSONField(name = "detail_episode_id")
58 @Query
59 private Long detailEpisodeId;
60
61 // 收藏内容的剧集CODE
62 @JSONField(name = "detail_episode_code")
63 @Query
64 private String detailEpisodeCode;
65
66 // 收藏内容的名称
67 @JSONField(name = "detail_name")
68 @Query
69 private String detailName;
70
71 // 收藏内容的标记
72 @JSONField(name = "detail_mark")
73 @Query
74 private Integer detailMark;
75
76 // 收藏内容的图片
77 @JSONField(name = "detail_img")
78 private String detailImg;
79
80 // 收藏内容的剧集序号
81 @JSONField(name = "detail_index")
82 @Query
83 private Integer detailIndex;
84
85 // 收藏内容的剧集总数
86 @JSONField(name = "detail_total_index")
87 @Query
88 private Integer detailTotalIndex;
89
90 // 收藏内容的播放时间
91 @JSONField(name = "detail_play_time")
92 @Query
93 private Integer detailPlayTime;
94
95 // 收藏内容的总时间
96 @JSONField(name = "detail_total_time")
97 @Query
98 private Integer detailTotalTime;
99
100 // 收藏内容在同一folder中的顺序
101 @JSONField(name = "detail_sequence")
102 @Query
103 private Integer detailSequence;
104
105 // 收藏内容的评分
106 @JSONField(name = "detail_score")
107 @Query
108 private Float detailScore;
109
110 // 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
111 @JSONField(name = "detail_like")
112 @Query
113 private Integer detailLike;
114
115 // 收藏内容的扩展数据
116 @JSONField(name = "detail_ext_data")
117 @Query
118 private String detailExtData;
119
120 // 创建时间
121 @JSONField(name = "create_time")
122 @Query
123 private Timestamp createTime;
124
125 // 更新时间
126 @JSONField(name = "update_time")
127 private Timestamp updateTime;
128 }
1 package com.topdraw.business.process.domian.weixin;
2
3
4 import lombok.Data;
5
6 /**
7 * 微信账户信息
8 * @author XiangHan
9 * @date 2021-01-18
10 */
11 @Data
12 public class WeiXinUserBean {
13
14 private Long id;
15
16 private String unionid;
17
18 /** */
19 private String openid;
20
21 /** */
22 private String appid;
23
24 /** 加密后的appId,参数 */
25 private String wxAppid;
26
27 /** 加密后的code,参数 */
28 private String wxCode;
29
30 /** */
31 private String userInfo;
32
33 /** 会员id */
34 private Long memberId;
35
36 /** 加密信息 */
37 private String encryptedData;
38
39 /** 解析用户电话号码时使用,参数 */
40 private String iv;
41
42 /** 资源id */
43 private String sourceId;
44
45 /** 资源类型 */
46 private String sourceType;
47
48 /** 资源描述,用来表示从哪个地方链接进来的 */
49 private String sourceDesc;
50
51 /** 资源实例 */
52 private String sourceEntity;
53
54 /** 推荐者id */
55 private Long sourceUser;
56
57 private String nikename;
58
59 private String headimgurl;
60 }
1 package com.topdraw.business.process.rest; 1 package com.topdraw.business.process.rest;
2 2
3 import com.topdraw.aop.log.Log;
4 import com.topdraw.business.process.domian.TempCoupon; 3 import com.topdraw.business.process.domian.TempCoupon;
5 import com.topdraw.business.process.service.CouponOperationService; 4 import com.topdraw.business.process.service.CouponOperationService;
6 import com.topdraw.common.ResultInfo; 5 import com.topdraw.common.ResultInfo;
...@@ -23,7 +22,6 @@ public class CouponOperationController { ...@@ -23,7 +22,6 @@ public class CouponOperationController {
23 @Autowired 22 @Autowired
24 private CouponOperationService couponOperationService; 23 private CouponOperationService couponOperationService;
25 24
26 @Log
27 @PostMapping(value = "/grantCouponByManual") 25 @PostMapping(value = "/grantCouponByManual")
28 @ApiOperation("手动发放优惠券") 26 @ApiOperation("手动发放优惠券")
29 public ResultInfo grantCouponByManual(List<TempCoupon> tempCouponList) { 27 public ResultInfo grantCouponByManual(List<TempCoupon> tempCouponList) {
......
1 package com.topdraw.business.process.rest; 1 package com.topdraw.business.process.rest;
2 2
3 import com.topdraw.aop.log.Log;
4 import com.topdraw.business.process.domian.TempCoupon; 3 import com.topdraw.business.process.domian.TempCoupon;
5 import com.topdraw.business.process.domian.TempExp; 4 import com.topdraw.business.process.domian.TempExp;
6 import com.topdraw.business.process.service.CouponOperationService; 5 import com.topdraw.business.process.service.CouponOperationService;
...@@ -30,7 +29,6 @@ public class ExpOperationController { ...@@ -30,7 +29,6 @@ public class ExpOperationController {
30 @Autowired 29 @Autowired
31 private ExpOperationService expOperationService; 30 private ExpOperationService expOperationService;
32 31
33 @Log
34 @PostMapping(value = "/grantExpByManual") 32 @PostMapping(value = "/grantExpByManual")
35 @ApiOperation("手动发放成长值") 33 @ApiOperation("手动发放成长值")
36 public ResultInfo grantExpByManual(@Validated @RequestBody TempExp tempExp) { 34 public ResultInfo grantExpByManual(@Validated @RequestBody TempExp tempExp) {
......
1 package com.topdraw.business.process.rest;
2
3 import cn.hutool.core.util.ObjectUtil;
4 import com.topdraw.annotation.AnonymousAccess;
5 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
6 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
9 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
10 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
11 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
12 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
13 import com.topdraw.business.process.domian.weixin.BuyVipBean;
14 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
15 import com.topdraw.business.process.service.MemberOperationService;
16 import com.topdraw.common.IResultInfo;
17 import com.topdraw.common.ResultInfo;
18 import com.topdraw.exception.BadRequestException;
19 import com.topdraw.weixin.util.WeChatConstants;
20 import io.swagger.annotations.Api;
21 import io.swagger.annotations.ApiOperation;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.web.bind.annotation.*;
24
25 import java.time.LocalDateTime;
26 import java.util.Objects;
27
28 @Api("会员处理")
29 @RestController
30 @RequestMapping(value = "/ucEngine/api/memberOperation")
31 public class MemberOperationController {
32
33 @Autowired
34 private MemberOperationService memberOperationService;
35 @Autowired
36 private MemberVipHistoryService memberVipHistoryService;
37 @Autowired
38 private UserWeixinService userWeixinService;
39 @Autowired
40 private MemberService memberService;
41
42 @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}")
43 @ApiOperation("获取会员基本信息并且检查vip状态")
44 @AnonymousAccess
45 public IResultInfo getMemberProfileAndCheckVip(@PathVariable(value = "appId") String appId, @PathVariable(value = "memberId") Long memberId) {
46 MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId);
47 return ResultInfo.success(memberProfileDTO);
48 }
49
50 @PutMapping("/buyVip")
51 @ApiOperation("购买vip")
52 @AnonymousAccess
53 public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) {
54
55 // 小程序账户id
56 Long id = buyVipBean.getId();
57 if (Objects.isNull(id))
58 throw new BadRequestException("参数异常: id is null !");
59
60 // vip等级
61 Integer vip = buyVipBean.getVip();
62 if (Objects.isNull(vip) || vip <= 0)
63 throw new BadRequestException("vip 等级有误");
64
65 MemberDTO memberDTO = memberOperationService.buyVip(buyVipBean);
66
67 LocalDateTime vipExpireTime = buyVipBean.getVipExpireTime();
68 this.doInsertVipHistory(id,vip,vipExpireTime);
69 return ResultInfo.success(memberDTO);
70 }
71
72 private void doInsertVipHistory(Long id,Integer vip,LocalDateTime vipExpireTime) {
73
74 UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id);
75 Long memberId = userWeixinDTO.getMemberId();
76
77 MemberDTO member = this.memberService.findById(memberId);
78
79 LocalDateTime now = LocalDateTime.now();
80
81 MemberVipHistory memberVipHistory = new MemberVipHistory();
82 if (ObjectUtil.isNull(vipExpireTime)) {
83 LocalDateTime localDateTime = now.plusYears(1L);
84 member.setVipExpireTime(localDateTime);
85 } else {
86 //购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年
87 //区分是当前vip续费 还是买新的vip
88 if (ObjectUtil.equal(vip, member.getVip())) {
89 if (now.isBefore(vipExpireTime)) {
90 LocalDateTime localDateTime = vipExpireTime.plusYears(1L);
91 member.setVipExpireTime(localDateTime);
92 } else {
93 LocalDateTime localDateTime = now.plusYears(1L);
94 member.setVipExpireTime(localDateTime);
95 }
96 } else {
97 LocalDateTime localDateTime = now.plusYears(1L);
98 member.setVipExpireTime(localDateTime);
99 }
100 }
101
102 memberVipHistory.setVipExpireTime(member.getVipExpireTime());
103 memberVipHistoryService.create(memberVipHistory);
104 }
105 }
106
107
1 package com.topdraw.business.process.rest; 1 package com.topdraw.business.process.rest;
2 2
3 import com.topdraw.aop.log.Log; 3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.module.member.service.MemberService;
5 import com.topdraw.business.basicdata.member.service.MemberService; 5 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 6 import com.topdraw.business.module.points.available.service.PointsAvailableService;
7 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; 7 import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
8 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; 8 import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryType;
9 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryType; 9 import com.topdraw.business.module.points.detail.service.PointsDetailService;
10 import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; 10 import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria;
11 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria; 11 import com.topdraw.business.module.user.iptv.service.UserTvService;
12 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 12 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
13 import com.topdraw.business.basicdata.user.iptv.service.UserTvService; 13 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
14 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; 14 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
15 import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService; 15 import com.topdraw.business.process.domian.TempCustomPointBean;
16 import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO;
17 import com.topdraw.business.process.domian.TempIptvUser;
18 import com.topdraw.business.process.domian.TempPoints; 16 import com.topdraw.business.process.domian.TempPoints;
19 import com.topdraw.business.process.domian.result.CustomPointsResult; 17 import com.topdraw.business.process.domian.result.CustomPointsResult;
20 import com.topdraw.business.process.service.PointsOperationService; 18 import com.topdraw.business.process.service.PointsOperationService;
21 import com.topdraw.business.process.service.UserTvOperationService;
22 import com.topdraw.common.ResultCode;
23 import com.topdraw.common.ResultInfo; 19 import com.topdraw.common.ResultInfo;
24 import com.topdraw.config.LocalConstants; 20 import com.topdraw.config.LocalConstants;
25 import com.topdraw.util.TimestampUtil; 21 import com.topdraw.util.TimestampUtil;
26 import io.swagger.annotations.Api; 22 import io.swagger.annotations.Api;
27 import io.swagger.annotations.ApiOperation; 23 import io.swagger.annotations.ApiOperation;
28 import lombok.Data;
29 import org.redisson.api.RedissonClient;
30 import org.slf4j.Logger; 24 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory; 25 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired; 26 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.data.domain.Pageable; 27 import org.springframework.data.domain.Pageable;
34 import org.springframework.util.Assert; 28 import org.springframework.util.Assert;
35 import org.springframework.util.CollectionUtils;
36 import org.springframework.validation.annotation.Validated; 29 import org.springframework.validation.annotation.Validated;
37 import org.springframework.web.bind.annotation.*; 30 import org.springframework.web.bind.annotation.*;
38 31
39 import java.util.Arrays; 32 import java.util.Arrays;
40 import java.util.List;
41 import java.util.Objects; 33 import java.util.Objects;
42 34
43 /** 35 /**
...@@ -46,7 +38,7 @@ import java.util.Objects; ...@@ -46,7 +38,7 @@ import java.util.Objects;
46 */ 38 */
47 @Api(tags = "PointsOperation管理") 39 @Api(tags = "PointsOperation管理")
48 @RestController 40 @RestController
49 @RequestMapping("/api/pointsOperation") 41 @RequestMapping("/ucEngine/api/pointsOperation")
50 public class PointsOperationController { 42 public class PointsOperationController {
51 43
52 private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class); 44 private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class);
...@@ -67,12 +59,14 @@ public class PointsOperationController { ...@@ -67,12 +59,14 @@ public class PointsOperationController {
67 59
68 @GetMapping(value = "/pagePointsDetails") 60 @GetMapping(value = "/pagePointsDetails")
69 @ApiOperation("查询PointsDetail") 61 @ApiOperation("查询PointsDetail")
62 @AnonymousAccess
70 public ResultInfo pagePointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) { 63 public ResultInfo pagePointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) {
71 return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable)); 64 return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable));
72 } 65 }
73 66
74 @GetMapping(value = "/pageAvailablePoints") 67 @GetMapping(value = "/pageAvailablePoints")
75 @ApiOperation("查询PointsAvailable") 68 @ApiOperation("查询PointsAvailable")
69 @AnonymousAccess
76 public ResultInfo pageAvailablePoints(PointsAvailableQueryCriteria criteria, Pageable pageable) { 70 public ResultInfo pageAvailablePoints(PointsAvailableQueryCriteria criteria, Pageable pageable) {
77 PointsAvailableQueryType queryType = criteria.getQueryType(); 71 PointsAvailableQueryType queryType = criteria.getQueryType();
78 // 可用 72 // 可用
...@@ -82,17 +76,17 @@ public class PointsOperationController { ...@@ -82,17 +76,17 @@ public class PointsOperationController {
82 return ResultInfo.successPage(pointsAvailableService.queryAll(criteria,pageable)); 76 return ResultInfo.successPage(pointsAvailableService.queryAll(criteria,pageable));
83 } 77 }
84 78
85 @Log
86 @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") 79 @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}")
87 @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") 80 @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用")
81 @AnonymousAccess
88 public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) { 82 public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) {
89 Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id); 83 Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id);
90 return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); 84 return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong);
91 } 85 }
92 86
93 @Log
94 @PostMapping(value = "/grantPointsByManual") 87 @PostMapping(value = "/grantPointsByManual")
95 @ApiOperation("手动发放积分") 88 @ApiOperation("手动发放积分")
89 @AnonymousAccess
96 public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) { 90 public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) {
97 Long memberId = tempPoints.getMemberId(); 91 Long memberId = tempPoints.getMemberId();
98 Long points = tempPoints.getPoints(); 92 Long points = tempPoints.getPoints();
...@@ -113,12 +107,18 @@ public class PointsOperationController { ...@@ -113,12 +107,18 @@ public class PointsOperationController {
113 * @param tempIptvUser 107 * @param tempIptvUser
114 * @return 108 * @return
115 */ 109 */
116 @Log
117 @PostMapping(value = "/customPointsByUserTvPlatformAccount") 110 @PostMapping(value = "/customPointsByUserTvPlatformAccount")
118 @ApiOperation("通过大屏账户积分消耗") 111 @ApiOperation("通过大屏账户积分消耗")
119 public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempIptvUser tempIptvUser) { 112 @AnonymousAccess
113 public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempCustomPointBean tempIptvUser) {
120 String platformAccount = tempIptvUser.getPlatformAccount(); 114 String platformAccount = tempIptvUser.getPlatformAccount();
121 Long points = tempIptvUser.getPoints(); 115 Long points = tempIptvUser.getPoints();
116 Long activityId = tempIptvUser.getActivityId();
117 Integer evtType = tempIptvUser.getEvtType();
118 Long mediaId = tempIptvUser.getMediaId();
119 Long orderId = tempIptvUser.getOrderId();
120 Integer deviceType = tempIptvUser.getDeviceType();
121
122 122
123 TempPoints tempPoints = new TempPoints(); 123 TempPoints tempPoints = new TempPoints();
124 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); 124 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
...@@ -132,9 +132,12 @@ public class PointsOperationController { ...@@ -132,9 +132,12 @@ public class PointsOperationController {
132 tempPoints.setMemberId(memberId); 132 tempPoints.setMemberId(memberId);
133 } 133 }
134 tempPoints.setPoints(points); 134 tempPoints.setPoints(points);
135 tempPoints.setDeviceType(LocalConstants.DEVICE_VIS); 135 tempPoints.setDeviceType(deviceType);
136 tempPoints.setAppCode(LocalConstants.APP_CODE_CHONGQING_CHONGSHU_VIS); 136 tempPoints.setAppCode(LocalConstants.APP_CODE_CHONGQING_CHONGSHU_VIS);
137 tempPoints.setEvtType(LocalConstants.EVT_TYPE_ACTIVITY); 137 tempPoints.setEvtType(evtType);
138 tempPoints.setActivityId(activityId);
139 tempPoints.setMediaId(mediaId);
140 tempPoints.setOrderId(orderId);
138 return this.customPoints(tempPoints); 141 return this.customPoints(tempPoints);
139 } 142 }
140 143
...@@ -143,9 +146,9 @@ public class PointsOperationController { ...@@ -143,9 +146,9 @@ public class PointsOperationController {
143 * @param tempPoints 146 * @param tempPoints
144 * @return 147 * @return
145 */ 148 */
146 @Log
147 @PostMapping(value = "/customPointsByUserId") 149 @PostMapping(value = "/customPointsByUserId")
148 @ApiOperation("积分消耗") 150 @ApiOperation("积分消耗")
151 @AnonymousAccess
149 public ResultInfo customPointsByUserId(@Validated @RequestBody TempPoints tempPoints) { 152 public ResultInfo customPointsByUserId(@Validated @RequestBody TempPoints tempPoints) {
150 Long userId = tempPoints.getUserId(); 153 Long userId = tempPoints.getUserId();
151 // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) 154 // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
...@@ -184,9 +187,9 @@ public class PointsOperationController { ...@@ -184,9 +187,9 @@ public class PointsOperationController {
184 return userWeixinDTO.getMemberId(); 187 return userWeixinDTO.getMemberId();
185 } 188 }
186 189
187 @Log
188 @PostMapping(value = "/consumePoints") 190 @PostMapping(value = "/consumePoints")
189 @ApiOperation("积分消耗") 191 @ApiOperation("积分消耗")
192 @AnonymousAccess
190 public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) { 193 public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) {
191 Integer pointsType = tempPoints.getPointsType(); 194 Integer pointsType = tempPoints.getPointsType();
192 if (Objects.isNull(pointsType)) { 195 if (Objects.isNull(pointsType)) {
......
1 package com.topdraw.business.process.rest; 1 package com.topdraw.business.process.rest;
2 2
3 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 3 import com.topdraw.business.module.rights.history.domain.RightsHistory;
4 import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService; 4 import com.topdraw.business.module.rights.history.service.RightsHistoryService;
5 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria; 5 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
6 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryType; 6 import com.topdraw.business.module.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.util.TimestampUtil; 9 import com.topdraw.util.TimestampUtil;
......
1 package com.topdraw.business.process.rest; 1 package com.topdraw.business.process.rest;
2 2
3 import com.topdraw.aop.log.Log; 3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.process.domian.TempIptvUser; 4 import com.topdraw.business.process.domian.TempIptvUser;
5 import com.topdraw.business.process.service.TaskOperationService; 5 import com.topdraw.business.process.service.TaskOperationService;
6 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
...@@ -14,7 +14,7 @@ import java.util.Arrays; ...@@ -14,7 +14,7 @@ import java.util.Arrays;
14 14
15 @Api("任务处理") 15 @Api("任务处理")
16 @RestController 16 @RestController
17 @RequestMapping(value = "/api/TaskOperation") 17 @RequestMapping(value = "/ucEngine/api/taskOperation")
18 public class TaskOperationController { 18 public class TaskOperationController {
19 19
20 @Autowired 20 @Autowired
...@@ -25,9 +25,9 @@ public class TaskOperationController { ...@@ -25,9 +25,9 @@ public class TaskOperationController {
25 * 25 *
26 * @param criteria 消息 26 * @param criteria 消息
27 */ 27 */
28 @Log
29 @PostMapping(value = "/dealTask") 28 @PostMapping(value = "/dealTask")
30 @ApiOperation("事件处理") 29 @ApiOperation("事件处理")
30 @AnonymousAccess
31 public void dealTask(@RequestBody @Validated TaskOperationQueryCriteria criteria) { 31 public void dealTask(@RequestBody @Validated TaskOperationQueryCriteria criteria) {
32 // 任务处理 32 // 任务处理
33 this.taskOperationService.dealTask(criteria.getContent()); 33 this.taskOperationService.dealTask(criteria.getContent());
...@@ -40,9 +40,9 @@ public class TaskOperationController { ...@@ -40,9 +40,9 @@ public class TaskOperationController {
40 * 1.用户每天首次进入活动详情页的时候赠送5个积分 40 * 1.用户每天首次进入活动详情页的时候赠送5个积分
41 * 2.判断任务是否已经做过,没有做过的话,保存任务记录,任务记录通过redis保存即可 41 * 2.判断任务是否已经做过,没有做过的话,保存任务记录,任务记录通过redis保存即可
42 */ 42 */
43 @Log
44 @PostMapping(value = "/createPoint4ChongQing") 43 @PostMapping(value = "/createPoint4ChongQing")
45 @ApiOperation("针对重庆大屏20211220号的积分兑换活动专门定制的接口") 44 @ApiOperation("针对重庆大屏20211220号的积分兑换活动专门定制的接口")
45 @Deprecated
46 public ResultInfo createPoint4ChongQing(@RequestBody TempIptvUser tempIptvUser){ 46 public ResultInfo createPoint4ChongQing(@RequestBody TempIptvUser tempIptvUser){
47 String platformAccount = tempIptvUser.getPlatformAccount(); 47 String platformAccount = tempIptvUser.getPlatformAccount();
48 Long points = tempIptvUser.getPoints(); 48 Long points = tempIptvUser.getPoints();
......
1 package com.topdraw.business.process.rest;
2
3 import cn.hutool.core.util.ObjectUtil;
4 import cn.hutool.core.util.StrUtil;
5
6 import com.alibaba.fastjson.JSONObject;
7 import com.topdraw.annotation.AnonymousAccess;
8 import com.topdraw.business.module.member.profile.domain.MemberProfile;
9 import com.topdraw.business.module.member.service.MemberService;
10 import com.topdraw.business.module.member.service.dto.MemberDTO;
11 import com.topdraw.business.module.user.iptv.domain.UserTv;
12 import com.topdraw.business.module.user.iptv.service.UserTvService;
13 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
14 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
15 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
16 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
17 import com.topdraw.business.process.domian.TempIptvUser;
18 import com.topdraw.business.process.domian.weixin.BindBean;
19 import com.topdraw.business.process.domian.weixin.SubscribeBean;
20 import com.topdraw.business.process.domian.weixin.SubscribeBeanEvent;
21 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
22 import com.topdraw.business.process.service.UserOperationService;
23 import com.topdraw.common.ResultInfo;
24 import com.topdraw.config.RedisKeyUtil;
25 import com.topdraw.exception.BadRequestException;
26 import com.topdraw.exception.EntityNotFoundException;
27 import com.topdraw.util.Base64Util;
28 import com.topdraw.util.JSONUtil;
29 import com.topdraw.utils.RedisUtils;
30 import com.topdraw.utils.StringUtils;
31 import com.topdraw.weixin.util.WeChatConstants;
32 import com.topdraw.weixin.util.WeixinUtil;
33 import io.swagger.annotations.Api;
34 import io.swagger.annotations.ApiOperation;
35 import lombok.extern.slf4j.Slf4j;
36 import org.assertj.core.util.Arrays;
37 import org.springframework.beans.BeanUtils;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.util.Assert;
40 import org.springframework.validation.annotation.Validated;
41 import org.springframework.web.bind.annotation.*;
42
43 import java.io.IOException;
44 import java.net.URLDecoder;
45 import java.time.LocalDateTime;
46 import java.util.*;
47
48 @Api("账户处理")
49 @RestController
50 @RequestMapping(value = "/ucEngine/api/userOperation")
51 @Slf4j
52 public class UserOperationController {
53
54 @Autowired
55 private UserOperationService userTvOperationService;
56 @Autowired
57 private UserWeixinService userWeixinService;
58 @Autowired
59 private UserTvService userTvService;
60 @Autowired
61 private MemberService memberService;
62 @Autowired
63 private RedisUtils redisUtils;
64 @Autowired
65 private UserOperationService userOperationService;
66
67 private static final String SUBSCRIBE = "subscribe";
68 private static final String UNSUBSCRIBE = "unsubscribe";
69 private static final Integer SUBSCRIBE_STATUS = 1;
70
71 @PostMapping(value = "/createUserAndCreateMember")
72 @ApiOperation("新增大屏账户同时创建会员信息")
73 @AnonymousAccess
74 public ResultInfo createUserAndCreateMember(@Validated @RequestBody TempIptvUser resources) {
75
76 log.info("createUserAndCreateMember ==> input ==> [{}]",resources);
77
78 UserTv userTv = new UserTv();
79 BeanUtils.copyProperties(resources,userTv);
80 boolean result = this.userTvOperationService.createMemberByUserTv(userTv);
81 return ResultInfo.success(result);
82 }
83
84 @PostMapping(value = "/createWeixinUserAndCreateMember")
85 @ApiOperation("新增小屏账户同时创建会员信息")
86 @AnonymousAccess
87 public ResultInfo createWeixinUserAndCreateMember(@Validated @RequestBody UserWeixin resources) {
88
89 log.info("createWeixinUserAndCreateMember ==> input ==> [{}]",resources);
90
91 String appId = resources.getAppid();
92 if (StringUtils.isBlank(appId))
93 throw new NullPointerException("appId is null !");
94
95 String openId = resources.getOpenid();
96 if (StringUtils.isBlank(openId))
97 throw new NullPointerException("openId is null !");
98
99 String unionId = resources.getUnionid();
100 if (StringUtils.isBlank(unionId))
101 throw new NullPointerException("unionId is null !");
102
103 UserWeixinDTO result = this.userTvOperationService.createWeixinUserAndCreateMember(resources);
104
105 return ResultInfo.success(result);
106 }
107
108 @GetMapping(value = "/findBindByPlatformAccount/{platformAccount}")
109 @AnonymousAccess
110 public ResultInfo findBindByPlatformAccount(@PathVariable("platformAccount") String platformAccount) {
111 log.info("findBindByPlatformAccount ==> input ==> [{}]",platformAccount);
112
113 List<MemberDTO> result = this.userTvOperationService.findBindByPlatformAccount(platformAccount);
114 return ResultInfo.success(result);
115 }
116
117 @PostMapping(value = "/sendQrCodeMessage")
118 @ApiOperation("带参二维码")
119 @AnonymousAccess
120 public ResultInfo sendQrCodeMessage(@RequestBody String content) {
121 log.info("sendQrCodeMessage ==> input ==> [{}]",content);
122 boolean result = this.userTvOperationService.sendQrCodeMessage(content);
123 return ResultInfo.success(result);
124 }
125
126 @PostMapping(value = "/deleteAllCollection")
127 @ApiOperation("删除全部收藏")
128 @AnonymousAccess
129 public ResultInfo deleteAllCollection(@RequestBody String content) {
130 log.info("deleteAllCollection ==> input ==> [{}]",content);
131 boolean result = this.userTvOperationService.deleteAllCollection(content);
132 return ResultInfo.success(result);
133 }
134
135 @PostMapping(value = "/deleteCollection")
136 @ApiOperation("删除收藏")
137 @AnonymousAccess
138 public ResultInfo deleteCollection(@RequestBody String content) {
139 log.info("deleteCollection ==> input ==> [{}]",content);
140 boolean result = this.userTvOperationService.deleteCollection(content);
141 return ResultInfo.success(result);
142 }
143
144 @PostMapping(value = "/addCollection")
145 @ApiOperation("添加收藏")
146 @AnonymousAccess
147 public ResultInfo addCollection(@RequestBody String content) {
148 log.info("addCollection ==> input ==> [{}]",content);
149 boolean result = this.userTvOperationService.addCollection(content);
150 return ResultInfo.success(result);
151 }
152
153 @RequestMapping(value = "/unbind")
154 @ApiOperation("大屏用户解绑")
155 @AnonymousAccess
156 public ResultInfo unbind(@Validated @RequestBody TempIptvUser resources) {
157
158 log.info("unbind ==> input ==> [{}]",resources);
159
160 UserTv userTv = new UserTv();
161 BeanUtils.copyProperties(resources,userTv);
162 String unionid = resources.getUnionid();
163 String memberCode1 = resources.getMemberCode();
164 if (Objects.nonNull(memberCode1)) {
165
166 MemberDTO memberDTO = this.memberService.getByCode(memberCode1);
167 String memberCode = memberDTO.getCode();
168 if (StringUtils.isNotBlank(memberCode)) {
169 userTv.setMemberCode(memberCode);
170 this.userTvOperationService.unbind(userTv);
171 }
172
173 }
174
175 return ResultInfo.success();
176 }
177
178 @RequestMapping(value = "/changeMainAccount")
179 @ApiOperation("大屏更换主账号")
180 @AnonymousAccess
181 public ResultInfo changeMainAccount(@Validated @RequestBody TempIptvUser resources) {
182
183 log.info("changeMainAccount ==> input ==> [{}]",resources);
184
185 UserTv userTv = new UserTv();
186 BeanUtils.copyProperties(resources,userTv);
187 Long memberId = resources.getMemberId();
188 String memberCode1 = resources.getMemberCode();
189 if (Objects.nonNull(memberCode1)) {
190
191 MemberDTO memberDTO = this.memberService.getByCode(memberCode1);
192
193 String memberCode = memberDTO.getCode();
194 if (StringUtils.isNotBlank(memberCode)) {
195 userTv.setMemberCode(memberCode);
196 this.userTvOperationService.changeMainAccount(userTv);
197 }
198
199 } else {
200 String unionid = resources.getUnionid();
201 this.userTvOperationService.changeMainAccountByUnionId(userTv,unionid);
202 }
203
204 return ResultInfo.success("update success");
205 }
206
207 @PostMapping("/serviceLogin")
208 @ApiOperation("微信服务号(H5)登录")
209 @AnonymousAccess
210 public ResultInfo serviceLogin(@Validated @RequestBody WeiXinUserBean resources) {
211 Object o = this.userTvOperationService.serviceLogin(resources);
212 return ResultInfo.success(o);
213 }
214
215 @PostMapping("/appletLogin")
216 @ApiOperation("微信小程序登录")
217 @AnonymousAccess
218 public ResultInfo appletLogin(@Validated @RequestBody WeiXinUserBean resources) {
219 log.info("appletLogin ==> input ==> [{}]",resources);
220 UserWeixinDTO result = this.userTvOperationService.appletLogin(resources);
221 return ResultInfo.success(result);
222 }
223
224 @PostMapping("/appletBind")
225 @ApiOperation("微信小程序绑定大屏")
226 @AnonymousAccess
227 public ResultInfo appletBind(@Validated @RequestBody BindBean resources) {
228 log.info("appletBind ==> input ==> [{}]",resources);
229 String unionId = resources.getUnionid();
230 if (StringUtils.isBlank(unionId))
231 Assert.state(StrUtil.isNotBlank(unionId), "跨屏绑定,请先进行授权");
232
233 String platformAccount = resources.getPlatformAccount();
234 if (Objects.isNull(platformAccount))
235 Assert.state(StrUtil.isNotBlank(platformAccount), "大屏账户不得为空");
236
237 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
238 resources.setPlatformUserId(userTvDTO.getId());
239 resources.setPlatformAccount(platformAccount);
240
241 boolean result = this.userTvOperationService.appletBind(resources);
242 return ResultInfo.success(result);
243 }
244
245 @PostMapping("/subscribe")
246 @ApiOperation("微信公众号关注")
247 @AnonymousAccess
248 public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws IOException {
249 String content = data.getContent();
250 log.info("subscribe ==> input ==> [{}]",content);
251
252 SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class);
253 this.parseSubscribe(subscribeBean);
254 boolean result = this.userTvOperationService.subscribe(subscribeBean);
255 return ResultInfo.success(result);
256 }
257
258 /**
259 *
260 * @param subscribeBean
261 * @throws IOException
262 */
263 private void parseSubscribe(SubscribeBean subscribeBean) throws IOException {
264 if (Objects.nonNull(subscribeBean)) {
265
266 String appId = subscribeBean.getAppId();
267 // appId不得为空
268 if (StringUtils.isBlank(appId))
269 throw new BadRequestException("appId 不存在!");
270
271 // openId
272 String openId = subscribeBean.getOpenId();
273 if (StringUtils.isBlank(openId))
274 throw new BadRequestException("openId 不存在!");
275
276 // unionId
277 String unionId = subscribeBean.getUnionid();
278 if (StringUtils.isBlank(unionId))
279 throw new BadRequestException("unionId 不存在!");
280
281 // 匹配配置文件中的微信列表信息
282 Map<String, String> wxInfoMap = WeixinUtil.getWeixinInfoByAppid(appId);
283
284 if (Objects.nonNull(wxInfoMap)) {
285 // 程序类型
286 String appType = wxInfoMap.get("appType");
287 // 非订阅号,暂不处理。返回暂不支持
288 if (ObjectUtil.notEqual(appType, WeChatConstants.WX_SUBSCRIPTION))
289 throw new BadRequestException("非订阅号");
290 }
291
292 // 大屏账户信息
293 JSONObject iptvUserInfo = null;
294 // 缓存的大屏信息,使用unionid即可
295 String content = (String) this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionId));
296 if (StringUtils.isNotBlank(content)) {
297 // 大屏信息
298 iptvUserInfo = JSONObject.parseObject(content);
299
300 } else {
301
302 String eventKey = subscribeBean.getEventKey();
303 log.info(" eventKey ==> [{}] ", eventKey);
304
305 if (StringUtils.isNotBlank(eventKey)) {
306 // 用户扫描带参二维码关注。发消息
307 // 去除固定前缀,获取二维码参数
308 eventKey = eventKey.substring(8);
309 iptvUserInfo = JSONObject.parseObject(eventKey);
310 }
311
312 }
313
314 // 用户自己搜索关注就没有大屏信息,否则表示扫码关注
315 if (Objects.nonNull(iptvUserInfo)) {
316
317 subscribeBean.setIptvUserInfo(iptvUserInfo);
318
319 String headimgurl = iptvUserInfo.get("headimgurl").toString();
320 String nickname = iptvUserInfo.get("nickname").toString();
321 if (StringUtils.isNotBlank(nickname)) {
322 String nicknameDecode = URLDecoder.decode(nickname, "UTF-8");
323 String nicknameEncode = Base64Util.encode(nicknameDecode);
324 subscribeBean.setNickname(nicknameEncode);
325 }
326
327 if (StringUtils.isNotBlank(headimgurl)) {
328 String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8");
329 subscribeBean.setHeadimgurl(headimgurlDecode);
330 }
331
332 }
333
334 }
335 }
336
337 @PostMapping("/unsubscribe")
338 @ApiOperation("微信公众号取关")
339 @AnonymousAccess
340 public ResultInfo unsubscribe(@Validated @RequestBody SubscribeBeanEvent data) {
341 String content = data.getContent();
342 log.info("unsubscribe ==> input ==> [{}]",content);
343
344 SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class);
345 boolean result = this.userTvOperationService.unsubscribe(subscribeBean);
346 return ResultInfo.success(result);
347 }
348
349 /**
350 * @param data
351 * @description 通过大屏关注的订阅号,因为订阅号不支持带参二维码,
352 * 所以需要先跳到H5(带大屏参数),
353 * 再做服务号授权(订阅号只能按钮触发获取信息),
354 * 再将服务号信息和大屏参数缓存下来(该接口的功能)
355 * 然后跳转到订阅号关注页
356 * 关注后回调处理时,根据unionid进行相关逻辑
357 *
358 * 业务场景:
359 * 1.未关注-绑定
360 * 新用户
361 * 2.先关注-绑定
362 * 1).未绑定
363 * 2).已绑定
364 * 2.1).已绑定当前大屏账户
365 * 2.2).换绑
366 * 2.2.1).
367 * @author Hongyan Wang
368 * @date 2021/8/24 4:54 下午
369 */
370 @PostMapping(value = "/saveUserInfo")
371 @ApiOperation("保存大屏侧信息")
372 @AnonymousAccess
373 public ResultInfo saveUserInfo(@RequestBody String data) {
374
375 log.info("saveUserInfo ==> input ==> [{}]",data);
376 Assert.notNull(data, "用户数据不可为空");
377
378 JSONObject json = JSONObject.parseObject(data);
379
380 String unionid = json.getString("unionid");
381 Assert.state(StrUtil.isNotBlank(unionid), "unionid不可为空");
382
383 // 大屏侧通过返回值来展示对应的小程序页面
384 String result = SUBSCRIBE;
385
386 // 保存大小屏信息到redis同时返回小屏信息
387 UserWeixinDTO userWeixinDTO = this.userTvOperationService.saveUserInfo(data);
388 // 小屏用户不存在或者关注状态为未关注(0),返回未关注
389 if (Objects.isNull(userWeixinDTO) || Objects.isNull(userWeixinDTO.getId()) || userWeixinDTO.getStatus() != SUBSCRIBE_STATUS) {
390 result = UNSUBSCRIBE;
391 return ResultInfo.success(result);
392 }
393
394 /***************************************************************************************/
395 String platformAccount1 = "";
396 // 关注未绑定
397 if (result.equalsIgnoreCase(SUBSCRIBE)) {
398 // 小屏会员
399 MemberDTO memberDTO = this.memberService.findById(userWeixinDTO.getMemberId());
400
401 // redis中的大小屏信息
402 String content = (String) this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionid));
403 JSONObject iptvUserInfo = JSONObject.parseObject(content);
404 // redis中的大小屏信息
405 log.info("saveUserInfo ==> redis content iptvUserInfo ==> [{}]",iptvUserInfo);
406
407 // 大屏账户
408 String platformAccount = iptvUserInfo.getString("platformAccount");
409
410 try {
411 String headimgurl = iptvUserInfo.get("headimgurl").toString();
412 String nickname = iptvUserInfo.get("nickname").toString();
413 if (StringUtils.isNotBlank(nickname)) {
414 String nicknameDecode = URLDecoder.decode(nickname, "UTF-8");
415 String nicknameEncode = Base64Util.encode(nicknameDecode);
416 memberDTO.setNickname(nicknameEncode);
417 }
418
419 if (StringUtils.isNotBlank(headimgurl)) {
420 String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8");
421 memberDTO.setAvatarUrl(headimgurlDecode);
422 }
423 }catch (Exception e) {
424 log.info("headimgurl , nickname ===>> encode error!");
425 e.printStackTrace();
426 }
427
428 // 大小屏绑定,如果已经绑定了别的大屏,则不进行处理,返回已绑定的大屏信息
429 // 已绑定的大屏信息
430 UserTvDTO userTvDTO = this.userOperationService.bind(memberDTO, platformAccount);
431 if (userTvDTO != null) {
432 platformAccount1 = userTvDTO.getPlatformAccount();
433 }
434
435 }
436 /****************************************************************************************/
437 List<Object> resultList = new ArrayList<>();
438 resultList.add(result);
439 resultList.add(platformAccount1);
440
441 // return ["subscribe","platform_account"]
442 ResultInfo<Object> success = ResultInfo.success(resultList);
443
444 log.info("saveUserInfo ==> ResultInfo ==> [{}]",success);
445 return success;
446 }
447
448 /**
449 *
450 * @param resources
451 * @return
452 */
453 @PostMapping(value = "/saveUserWeixinPhone")
454 @ApiOperation("保存用户手机号信息")
455 @AnonymousAccess
456 public ResultInfo saveUserWeixinPhone(@RequestBody WeiXinUserBean resources) {
457 log.info("saveUserWeixinPhone ==> input ==> [{}]",resources);
458 MemberProfile s = this.userTvOperationService.saveUserWeixinPhone(resources);
459 return ResultInfo.success(s);
460 }
461
462
463 }
464
465
1 package com.topdraw.business.process.service; 1 package com.topdraw.business.process.service;
2 2
3 import com.topdraw.business.basicdata.coupon.domain.Coupon;
4 import com.topdraw.business.process.domian.TempCoupon; 3 import com.topdraw.business.process.domian.TempCoupon;
5 import com.topdraw.business.process.domian.TempRights;
6 4
7 import java.util.List; 5 import java.util.List;
8 6
......
1 package com.topdraw.business.process.service; 1 package com.topdraw.business.process.service;
2 2
3 import com.topdraw.business.basicdata.member.domain.Member; 3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 4 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
5 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
7 import com.topdraw.business.process.domian.weixin.BuyVipBean;
8 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
5 9
6 public interface MemberOperationService { 10 public interface MemberOperationService {
7 11
...@@ -16,4 +20,9 @@ public interface MemberOperationService { ...@@ -16,4 +20,9 @@ public interface MemberOperationService {
16 void doUpdateMemberPoints(Member member); 20 void doUpdateMemberPoints(Member member);
17 21
18 void doUpdateMemberCoupon(Member member); 22 void doUpdateMemberCoupon(Member member);
23
24 MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appid);
25
26 MemberDTO buyVip(BuyVipBean buyVipBean);
27
19 } 28 }
......
1 package com.topdraw.business.process.service; 1 package com.topdraw.business.process.service;
2 2
3 import com.topdraw.business.basicdata.points.domain.Points;
4 import com.topdraw.business.basicdata.task.domain.Task;
5 import com.topdraw.business.process.domian.TempPoints; 3 import com.topdraw.business.process.domian.TempPoints;
6 import com.topdraw.business.process.domian.result.CustomPointsResult; 4 import com.topdraw.business.process.domian.result.CustomPointsResult;
7 5
8 import java.util.List; 6 import java.util.List;
9 import java.util.Map;
10 7
11 /** 8 /**
12 * @description 积分操作接口 9 * @description 积分操作接口
......
1 package com.topdraw.business.process.service; 1 package com.topdraw.business.process.service;
2 2
3 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 3 import com.topdraw.business.module.rights.history.domain.RightsHistory;
4 import com.topdraw.business.process.domian.RightType; 4 import com.topdraw.business.process.domian.RightType;
5 5
6 import java.util.List; 6 import java.util.List;
......
1 package com.topdraw.business.process.service;
2
3 public interface TaskDealService {
4
5 }
1 package com.topdraw.business.process.service;
2
3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.business.module.member.profile.domain.MemberProfile;
5 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.business.module.user.iptv.domain.UserTv;
7 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
8 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
9 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
10 import com.topdraw.business.process.domian.weixin.BindBean;
11 import com.topdraw.business.process.domian.weixin.BuyVipBean;
12 import com.topdraw.business.process.domian.weixin.SubscribeBean;
13 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
14
15 import java.util.List;
16 import java.util.Map;
17
18 public interface UserOperationService {
19
20 /**
21 * 保存大屏账户并创建会员
22 * @param resources
23 * @return
24 */
25 boolean createMemberByUserTv(UserTv resources);
26
27 /**
28 * 大屏解绑
29 * @param userTv
30 */
31 void unbind(UserTv userTv);
32
33 /**
34 *
35 * @param userTv
36 * @param unionId
37 */
38 void unbindByUnionId(UserTv userTv,String unionId);
39
40 /**
41 * 大屏切换主账户(会员)
42 * @param userTv
43 */
44 void changeMainAccount(UserTv userTv);
45
46 /**
47 *
48 * @param userTv
49 * @param unionId
50 */
51 void changeMainAccountByUnionId(UserTv userTv,String unionId);
52
53 /**
54 * 微信小程序登录
55 * @param resources
56 * @return
57 */
58 UserWeixinDTO appletLogin(WeiXinUserBean resources);
59
60 /**
61 * 微信公众号关注
62 * 1.团粉,会员vip=0,则修改为vip=1
63 * 2.判断是否通过扫描大屏的二维码进行关注的,如果是需要绑定大屏账户,将对应会员中iptvUserId绑定大屏对应的id
64 * 3.修改微信账户的status字段为1(已关注)
65 * @param resources
66 * @return
67 */
68 boolean subscribe(SubscribeBean resources);
69
70 /**
71 * 微信公众号取关
72 * @param resources
73 * @return
74 */
75 boolean unsubscribe(SubscribeBean resources);
76
77 /**
78 * 保存账户
79 * @param data
80 * @return
81 */
82 UserWeixinDTO saveUserInfo(String data);
83
84 /**
85 * 获取用户授权并解析、保存用户手机号
86 * @param resources
87 * @return
88 */
89 MemberProfile saveUserWeixinPhone(WeiXinUserBean resources);
90
91 /**
92 *
93 * @param content
94 * @return
95 */
96 boolean sendQrCodeMessage(String content);
97
98 /**
99 * 大屏删除所有收藏
100 * @param content
101 * @return
102 */
103 boolean deleteAllCollection(String content);
104
105 /**
106 * 大屏删除收藏
107 * @param content
108 * @return
109 */
110 boolean deleteCollection(String content);
111
112 /**
113 * 大屏收藏
114 * @param content
115 * @return
116 */
117 boolean addCollection(String content);
118
119 /**
120 * 获取大屏绑定的小屏会员列表
121 * @param platformAccount
122 * @return
123 */
124 List<MemberDTO> findBindByPlatformAccount(String platformAccount);
125
126 /**
127 * 服务号(H5)登录
128 * @param resources
129 * @return
130 */
131 Object serviceLogin(WeiXinUserBean resources);
132
133 /**
134 * 小程序绑定大屏
135 * @param resources
136 * @return
137 */
138 boolean appletBind(BindBean resources);
139
140
141 JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code);
142
143 UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources);
144
145 void bind(String memberCode, String platformAccount);
146
147 void bind(MemberDTO memberDTO, UserTvDTO userTvDTO);
148
149 UserTvDTO bind(MemberDTO memberDTO, String platformAccount);
150
151 }
1 package com.topdraw.business.process.service;
2
3 import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
4
5 public interface UserTvOperationService {
6
7 boolean createMemberByUserTv(UserTv resources);
8
9 }
1 package com.topdraw.business.process.service.builder;
2
3 import com.topdraw.business.process.domian.TempCoupon;
4
5 public class TempCouponBuilder {
6
7
8
9 public TempCoupon build(){
10 TempCoupon tempCoupon = new TempCoupon();
11
12 return tempCoupon;
13 }
14
15 }
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 3 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import com.topdraw.business.basicdata.task.domain.Task; 4 import com.topdraw.business.module.task.domain.Task;
5 import com.topdraw.util.TimestampUtil;
6 import org.springframework.util.CollectionUtils;
7 5
8 import java.util.List; 6 import java.util.List;
9 import java.util.stream.Collectors;
10 7
11 @FunctionalInterface 8 @FunctionalInterface
12 public interface CompareTaskCondition { 9 public interface CompareTaskCondition {
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService; 4 import com.topdraw.business.module.coupon.history.domain.CouponHistory;
5 import com.topdraw.business.basicdata.coupon.service.CouponService; 5 import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
6 import com.topdraw.business.basicdata.member.domain.Member; 6 import com.topdraw.business.module.coupon.service.CouponService;
7 import com.topdraw.business.module.member.domain.Member;
8 import com.topdraw.business.module.member.service.MemberService;
9 import com.topdraw.business.module.member.service.dto.MemberDTO;
7 import com.topdraw.business.process.service.CouponOperationService; 10 import com.topdraw.business.process.service.CouponOperationService;
8 import com.topdraw.business.process.service.MemberOperationService; 11 import com.topdraw.business.process.service.MemberOperationService;
9 import com.topdraw.business.process.domian.TempCoupon; 12 import com.topdraw.business.process.domian.TempCoupon;
...@@ -19,15 +22,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -19,15 +22,10 @@ import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 22 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
20 import org.springframework.stereotype.Service; 23 import org.springframework.stereotype.Service;
21 24
22 import javax.annotation.Resource;
23 import java.sql.Timestamp; 25 import java.sql.Timestamp;
24 import java.time.LocalDateTime; 26 import java.time.LocalDateTime;
25 import java.util.HashMap;
26 import java.util.List; 27 import java.util.List;
27 import java.util.Map;
28 import java.util.Objects; 28 import java.util.Objects;
29 import java.util.concurrent.ConcurrentHashMap;
30 import java.util.concurrent.locks.ReentrantLock;
31 29
32 30
33 @Service 31 @Service
...@@ -44,6 +42,8 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -44,6 +42,8 @@ public class CouponOperationServiceImpl implements CouponOperationService {
44 @Autowired 42 @Autowired
45 RightsOperationService rightsOperationService; 43 RightsOperationService rightsOperationService;
46 @Autowired 44 @Autowired
45 MemberService memberService;
46 @Autowired
47 RedissonClient redissonClient; 47 RedissonClient redissonClient;
48 @Autowired 48 @Autowired
49 ThreadPoolTaskExecutor threadPoolTaskExecutor; 49 ThreadPoolTaskExecutor threadPoolTaskExecutor;
...@@ -52,6 +52,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -52,6 +52,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
52 private static final Integer EXPIRE_FACTOR_DAY = 30; 52 private static final Integer EXPIRE_FACTOR_DAY = 30;
53 53
54 @Override 54 @Override
55 @AsyncMqSend
55 public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { 56 public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) {
56 // 优惠券领取、使用历史记录表 57 // 优惠券领取、使用历史记录表
57 for (TempCoupon tempCoupon : tempCouponList) { 58 for (TempCoupon tempCoupon : tempCouponList) {
...@@ -128,14 +129,23 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -128,14 +129,23 @@ public class CouponOperationServiceImpl implements CouponOperationService {
128 * @param expireSoonCouponCount 129 * @param expireSoonCouponCount
129 */ 130 */
130 private void doUpdateMemberInfo(Long memberId, Long currentCoupon, Long expireSoonCouponCount) { 131 private void doUpdateMemberInfo(Long memberId, Long currentCoupon, Long expireSoonCouponCount) {
132 MemberDTO memberDTO = this.findMemberByMemberId(memberId);
133
131 Member member = new Member(); 134 Member member = new Member();
132 member.setId(memberId); 135 BeanUtils.copyProperties(memberDTO,member);
136
133 member.setCouponAmount(currentCoupon); 137 member.setCouponAmount(currentCoupon);
134 member.setDueCouponAmount(expireSoonCouponCount); 138 member.setDueCouponAmount(expireSoonCouponCount);
135 member.setUpdateTime(TimestampUtil.now()); 139 member.setUpdateTime(LocalDateTime.now());
136 this.memberOperationService.doUpdateMemberInfo(member); 140 this.memberOperationService.doUpdateMemberInfo(member);
137 } 141 }
138 142
143 private MemberDTO findMemberByMemberId(Long memberId) {
144 MemberDTO memberDTO = this.memberService.findById(memberId);
145 return memberDTO;
146 }
147
148
139 149
140 /** 150 /**
141 * 当前优惠券数量 = 总优惠券-已过期的优惠券 151 * 当前优惠券数量 = 总优惠券-已过期的优惠券
...@@ -154,8 +164,8 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -154,8 +164,8 @@ public class CouponOperationServiceImpl implements CouponOperationService {
154 * @return 164 * @return
155 */ 165 */
156 private Long getTotalExpireSoonCoupon(Long userId, Integer expireFactor) { 166 private Long getTotalExpireSoonCoupon(Long userId, Integer expireFactor) {
157 Timestamp expireTime = TimestampUtil.localDateTime2Timestamp(LocalDateTime.now().plusDays(expireFactor)); 167 LocalDateTime expireTime = LocalDateTime.now().plusDays(expireFactor);
158 return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,TimestampUtil.now(),expireTime); 168 return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,LocalDateTime.now(),expireTime);
159 } 169 }
160 170
161 171
...@@ -165,7 +175,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -165,7 +175,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
165 * @return 175 * @return
166 */ 176 */
167 private Long getTotalExpireCoupon(Long userId) { 177 private Long getTotalExpireCoupon(Long userId) {
168 return this.couponHistoryService.countByUserIdAndExpireTimeBefore(userId,TimestampUtil.now()); 178 return this.couponHistoryService.countByUserIdAndExpireTimeBefore(userId,LocalDateTime.now());
169 } 179 }
170 180
171 181
...@@ -192,7 +202,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -192,7 +202,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
192 couponHistory.setCouponCode(tempCoupon.getCode()); 202 couponHistory.setCouponCode(tempCoupon.getCode());
193 couponHistory.setUserNickname(tempCoupon.getUserNickname()); 203 couponHistory.setUserNickname(tempCoupon.getUserNickname());
194 couponHistory.setOrderDetailId(tempCoupon.getOrderId()); 204 couponHistory.setOrderDetailId(tempCoupon.getOrderId());
195 couponHistory.setReceiveTime(TimestampUtil.now()); 205 couponHistory.setReceiveTime(LocalDateTime.now());
196 couponHistory.setUseStatus(Objects.nonNull(couponHistory.getUseStatus()) ? couponHistory.getUseStatus():0); 206 couponHistory.setUseStatus(Objects.nonNull(couponHistory.getUseStatus()) ? couponHistory.getUseStatus():0);
197 this.couponHistoryService.create(couponHistory); 207 this.couponHistoryService.create(couponHistory);
198 } 208 }
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService; 4 import com.topdraw.business.module.exp.detail.domain.ExpDetail;
5 import com.topdraw.business.basicdata.member.domain.Member; 5 import com.topdraw.business.module.exp.detail.service.ExpDetailService;
6 import com.topdraw.business.basicdata.member.level.service.MemberLevelService; 6 import com.topdraw.business.module.member.domain.Member;
7 import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; 7 import com.topdraw.business.module.member.level.service.MemberLevelService;
8 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 8 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
9 import com.topdraw.business.module.member.service.MemberService;
10 import com.topdraw.business.module.member.service.dto.MemberDTO;
9 import com.topdraw.business.process.service.ExpOperationService; 11 import com.topdraw.business.process.service.ExpOperationService;
10 import com.topdraw.business.process.service.MemberOperationService; 12 import com.topdraw.business.process.service.MemberOperationService;
11 import com.topdraw.business.process.domian.TempExp; 13 import com.topdraw.business.process.domian.TempExp;
...@@ -23,7 +25,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; ...@@ -23,7 +25,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
23 import org.springframework.stereotype.Service; 25 import org.springframework.stereotype.Service;
24 import org.springframework.util.CollectionUtils; 26 import org.springframework.util.CollectionUtils;
25 27
26 import javax.annotation.Resource; 28 import java.time.LocalDateTime;
27 import java.util.List; 29 import java.util.List;
28 import java.util.Objects; 30 import java.util.Objects;
29 31
...@@ -42,11 +44,14 @@ public class ExpOperationServiceImpl implements ExpOperationService { ...@@ -42,11 +44,14 @@ public class ExpOperationServiceImpl implements ExpOperationService {
42 @Autowired 44 @Autowired
43 MemberLevelService memberLevelService; 45 MemberLevelService memberLevelService;
44 @Autowired 46 @Autowired
47 MemberService memberService;
48 @Autowired
45 RedissonClient redissonClient; 49 RedissonClient redissonClient;
46 @Autowired 50 @Autowired
47 ThreadPoolTaskExecutor threadPoolTaskExecutor; 51 ThreadPoolTaskExecutor threadPoolTaskExecutor;
48 52
49 @Override 53 @Override
54 @AsyncMqSend
50 public void grantPointsThroughTempExp(List<TempExp> tempExpList) { 55 public void grantPointsThroughTempExp(List<TempExp> tempExpList) {
51 56
52 for (TempExp tempExp : tempExpList) { 57 for (TempExp tempExp : tempExpList) {
...@@ -138,14 +143,22 @@ public class ExpOperationServiceImpl implements ExpOperationService { ...@@ -138,14 +143,22 @@ public class ExpOperationServiceImpl implements ExpOperationService {
138 * @param memberId 会员id 143 * @param memberId 会员id
139 */ 144 */
140 private void updateMemberInfo(Integer level,Long totalExp,Long memberId) { 145 private void updateMemberInfo(Integer level,Long totalExp,Long memberId) {
146 MemberDTO memberDTO = this.findMemberByMemberId(memberId);
147
141 Member member = new Member(); 148 Member member = new Member();
142 member.setId(memberId); 149 BeanUtils.copyProperties(memberDTO,member);
150
143 member.setExp(totalExp); 151 member.setExp(totalExp);
144 member.setLevel(level); 152 member.setLevel(level);
145 member.setUpdateTime(TimestampUtil.now()); 153 member.setUpdateTime(LocalDateTime.now());
146 this.memberOperationService.doUpdateMemberInfo(member); 154 this.memberOperationService.doUpdateMemberInfo(member);
147 } 155 }
148 156
157 private MemberDTO findMemberByMemberId(Long memberId) {
158 MemberDTO memberDTO = this.memberService.findById(memberId);
159 return memberDTO;
160 }
161
149 private Integer compareExp(long newExp, MemberLevelDTO memberLevelDTO,MemberDTO memberDTO) { 162 private Integer compareExp(long newExp, MemberLevelDTO memberLevelDTO,MemberDTO memberDTO) {
150 if (Objects.nonNull(memberLevelDTO)) { 163 if (Objects.nonNull(memberLevelDTO)) {
151 Long nextLevelExp = memberLevelDTO.getExpValue(); 164 Long nextLevelExp = memberLevelDTO.getExpValue();
......
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 cn.hutool.core.util.ObjectUtil;
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.basicdata.member.service.MemberService; 5 import com.topdraw.business.module.member.profile.service.MemberProfileService;
6 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 6 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
7 import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
8 import com.topdraw.business.module.member.service.MemberService;
9 import com.topdraw.business.module.member.service.dto.MemberDTO;
10 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
11 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
12 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
13 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
14 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
15 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
16 import com.topdraw.business.process.domian.weixin.BuyVipBean;
17 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
7 import com.topdraw.business.process.service.MemberOperationService; 18 import com.topdraw.business.process.service.MemberOperationService;
8 import org.redisson.Redisson; 19 import com.topdraw.exception.EntityNotFoundException;
9 import org.redisson.api.RedissonClient; 20 import com.topdraw.util.LocalDateTimeUtil;
21 import com.topdraw.util.TimestampUtil;
22 import com.topdraw.utils.StringUtils;
23 import com.topdraw.utils.ValidationUtil;
24 import org.springframework.beans.BeanUtils;
10 import org.springframework.beans.factory.annotation.Autowired; 25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
11 import org.springframework.stereotype.Service; 27 import org.springframework.stereotype.Service;
12 import org.springframework.util.Assert; 28 import org.springframework.util.Assert;
13 29
30 import java.nio.charset.StandardCharsets;
31 import java.time.LocalDateTime;
32 import java.time.ZoneOffset;
33 import java.util.Base64;
14 import java.util.Objects; 34 import java.util.Objects;
35 import java.util.Optional;
36
37 import static org.bouncycastle.asn1.x500.style.RFC4519Style.member;
15 38
16 @Service 39 @Service
17 public class MemberOperationServiceImpl implements MemberOperationService { 40 public class MemberOperationServiceImpl implements MemberOperationService {
18 41
19 @Autowired 42 @Autowired
20 MemberService memberService; 43 private MemberService memberService;
44 @Autowired
45 private MemberProfileService memberProfileService;
46 @Autowired
47 private MemberVipHistoryService memberVipHistoryService;
48 @Autowired
49 private UserWeixinService userWeixinService;
50 @Autowired
51 private ThreadPoolTaskExecutor threadPoolTaskExecutor;
52
53 @Override
54 public MemberDTO buyVip(BuyVipBean criteria) {
55 // 小程序账户id
56 Long id = criteria.getId();
57
58 // 过期时间
59 LocalDateTime vipExpireTime1 = criteria.getVipExpireTime();
60 Integer vip1 = criteria.getVip();
61
62 // 查询微信账户
63 UserWeixinDTO userWeixin = this.findWeiXinById(id);
64 Long memberId = userWeixin.getMemberId();
65
66 //
67 MemberDTO memberDTO = this.findById(memberId);
68 Integer vip = memberDTO.getVip();
69
70 //
71 LocalDateTime vipExpireTime = memberDTO.getVipExpireTime();
72 if (Objects.nonNull(vipExpireTime1)) {
73 vipExpireTime = vipExpireTime1;
74 }
75
76 //判断之前有没有买过,没买过,失效时间为一年后;
77 if (Objects.isNull(vipExpireTime1)) {
78 if (ObjectUtil.isNull(vipExpireTime)) {
79 LocalDateTime now = LocalDateTime.now();
80 vipExpireTime = now.plusYears(1L);
81 } else {
82 vipExpireTime = vipExpireTime.plusYears(1L);
83 }
84
85 }
86
87 memberDTO.setVip(vip1);
88 memberDTO.setVipExpireTime(vipExpireTime);
89
90 /*if (){
91 //购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年
92 //区分是当前vip续费 还是买新的vip
93 if (ObjectUtil.equal(vip1, memberDTO.getVip())) {
94 if (now.isBefore(vipExpireTime)) {
95 LocalDateTime localDateTime = vipExpireTime.plusYears(1L);
96 memberDTO.setVipExpireTime(localDateTime);
97 } else {
98 LocalDateTime localDateTime = now.plusYears(1L);
99 memberDTO.setVipExpireTime(localDateTime);
100 }
101 } else {
102 LocalDateTime localDateTime = now.plusYears(1L);
103 memberDTO.setVipExpireTime(localDateTime);
104 }
105 }*/
106
107 Member member = new Member();
108 BeanUtils.copyProperties(memberDTO,member);
109 this.memberService.create(member);
110
111 MemberVipHistory memberVipHistory = new MemberVipHistory();
112 memberVipHistory.setMemberId(memberId).setVip(vip1).setBeforeVip(vip);
113 if (ObjectUtil.equal(vip1,vip)) {
114 memberVipHistory.setStatus(1);
115 }
116 memberVipHistory.setVipExpireTime(member.getVipExpireTime());
117 memberVipHistoryService.create(memberVipHistory);
118
119 return memberDTO;
120 }
121
122 private UserWeixinDTO findWeiXinById(Long id) {
123 UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id);
124 if (Objects.isNull(userWeixinDTO)) {
125 throw new EntityNotFoundException(UserWeixin.class, "id", userWeixinDTO.getId().toString());
126 }
127
128 return userWeixinDTO;
129 }
21 130
22 @Override 131 @Override
23 public void doUpdateMemberInfo(Member member) { 132 public void doUpdateMemberInfo(Member member) {
...@@ -50,4 +159,142 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -50,4 +159,142 @@ public class MemberOperationServiceImpl implements MemberOperationService {
50 public void doUpdateMemberCoupon(Member member) { 159 public void doUpdateMemberCoupon(Member member) {
51 this.doUpdateMemberInfo(member); 160 this.doUpdateMemberInfo(member);
52 } 161 }
162
163 @Override
164 public MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appid) {
165
166 // 会员加密信息
167 MemberProfileDTO memberProfileDTO_0 = this.findMemberProfileByMemberId(memberId);
168
169 // 会员信息
170 MemberDTO memberDTO = this.findById(memberId);
171
172 // 初始化会员加密信息
173 MemberProfileDTO memberProfileDTO_1 = this.configMemberProfile(memberProfileDTO_0,memberDTO,appid);
174
175 return memberProfileDTO_1;
176 }
177
178 /**
179 * 配置会员信息
180 * @param memberProfileDTO_0
181 * @param memberDTO
182 * @return
183 */
184 private MemberProfileDTO configMemberProfile(MemberProfileDTO memberProfileDTO_0, MemberDTO memberDTO, String appid) {
185
186 if (Objects.isNull(memberProfileDTO_0)) return memberProfileDTO_0;
187
188 MemberProfileDTO memberProfileDTO = new MemberProfileDTO();
189 BeanUtils.copyProperties(memberProfileDTO_0,memberProfileDTO);
190
191 /*// 真实姓名
192 String realname = memberProfileDTO.getRealname();
193 if (StringUtils.isNotBlank(realname)) {
194 realname = new String(Base64.getEncoder().encode(realname.getBytes(StandardCharsets.UTF_8)));
195 }
196
197 // 昵称
198 String nickname = memberDTO.getNickname();
199 if (StringUtils.isNotBlank(nickname)) {
200 nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8)));
201 }*/
202
203 // vip
204 Integer vip = memberDTO.getVip();
205 // 过期时间
206 LocalDateTime vipExpireTime = memberDTO.getVipExpireTime();
207
208 Long timeLong = 0L;
209 if (ObjectUtil.isNotNull(vipExpireTime)) {
210
211 // 检查vip
212 MemberDTO memberDTO1 = this.checkVipStatus(memberDTO,vipExpireTime,appid);
213
214 // 更新会员信息
215 this.threadPoolTaskExecutor.execute(()->{
216 Member member = new Member();
217 BeanUtils.copyProperties(memberDTO1,member);
218 this.memberService.update(member);
219 });
220
221 vip = memberDTO1.getVip();
222 LocalDateTime vipExpireTime1 = memberDTO1.getVipExpireTime();
223 if (Objects.nonNull(vipExpireTime1)) {
224 timeLong = vipExpireTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
225 }
226 }
227
228 // 过期时间
229 memberProfileDTO.setVipExpireTime(timeLong);
230 // 真实姓名
231 // memberProfileDTO.setRealname(realname);
232 // 头像
233 memberProfileDTO.setAvatarUrl(memberDTO.getAvatarUrl());
234 // 生日
235 memberProfileDTO.setBirthdayStr(memberDTO.getBirthday());
236 // 性别
237 memberProfileDTO.setGender(memberDTO.getGender());
238 // 昵称
239 // memberProfileDTO.setNickname(nickname);
240 // 会员id
241 memberProfileDTO.setMemberId(memberDTO.getId());
242 // vip
243 memberProfileDTO.setVip(vip);
244
245 return memberProfileDTO;
246 }
247
248 /**
249 * 检查vip是否过期
250 * 1.当前vip如果过期则查看是否有vip历史变动
251 * 2.如果vip变动历史有记录则获取vip变动记录
252 * 3.如果vip没有记录则查看是否关注了公众号
253 * @param vipExpireTime
254 * @return
255 */
256 private MemberDTO checkVipStatus(MemberDTO memberDTO,LocalDateTime vipExpireTime, String appid) {
257
258 Long memberId = memberDTO.getId();
259 LocalDateTime nowTime = LocalDateTime.now();
260
261 //vip过期,回退上个vip状态 同时修改member表vip
262 if (nowTime.compareTo(vipExpireTime) >= 0 ) {
263
264 Integer vip = 0;
265 LocalDateTime vipExpireTime1 = memberDTO.getVipExpireTime();
266
267 //查询小于失效时间的那条记录 查不到 取微信表里 关注状态
268 MemberVipHistory memberVipHistory = this.memberVipHistoryService.findByTime(memberId, nowTime);
269
270 if (ObjectUtil.isNull(memberVipHistory.getId())) {
271
272 UserWeixinDTO userWeixin = this.userWeixinService.findFirstByMemberIdAndAppid(memberId, appid);
273 // 微信公众号关注的状态 0:未关注 1:关注
274 Integer status = userWeixin.getStatus();
275
276 if (status != 1) vip = 0; else vip = 1;
277 vipExpireTime1 = null;
278
279 } else {
280
281 vip = memberVipHistory.getVip();
282 vipExpireTime1 = memberVipHistory.getVipExpireTime();
283 }
284
285 memberDTO.setVipExpireTime(vipExpireTime1);
286 memberDTO.setVip(vip);
287 }
288
289 return memberDTO;
290 }
291
292 /**
293 * 查询会员加密信息
294 * @param memberId
295 * @return
296 */
297 private MemberProfileDTO findMemberProfileByMemberId(Long memberId) {
298 return this.memberProfileService.findByMemberId(memberId);
299 }
53 } 300 }
......
...@@ -2,18 +2,16 @@ package com.topdraw.business.process.service.impl; ...@@ -2,18 +2,16 @@ package com.topdraw.business.process.service.impl;
2 2
3 3
4 import com.topdraw.aspect.AsyncMqSend; 4 import com.topdraw.aspect.AsyncMqSend;
5 import com.topdraw.business.basicdata.member.domain.Member; 5 import com.topdraw.business.module.member.domain.Member;
6 import com.topdraw.business.basicdata.member.service.MemberService; 6 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; 8 import com.topdraw.business.module.points.available.domain.PointsAvailable;
9 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; 9 import com.topdraw.business.module.points.available.service.PointsAvailableService;
10 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 10 import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
11 import com.topdraw.business.basicdata.points.detail.detailhistory.service.PointsDetailHistoryService; 11 import com.topdraw.business.module.points.detail.detailhistory.service.PointsDetailHistoryService;
12 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; 12 import com.topdraw.business.module.points.detail.domain.PointsDetail;
13 import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; 13 import com.topdraw.business.module.points.detail.service.PointsDetailService;
14 import com.topdraw.business.basicdata.points.service.PointsService; 14 import com.topdraw.business.module.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; 15 import com.topdraw.business.process.domian.result.CustomPointsResult;
18 import com.topdraw.business.process.service.MemberOperationService; 16 import com.topdraw.business.process.service.MemberOperationService;
19 import com.topdraw.business.process.service.PointsOperationService; 17 import com.topdraw.business.process.service.PointsOperationService;
...@@ -22,7 +20,6 @@ import com.topdraw.util.IdWorker; ...@@ -22,7 +20,6 @@ import com.topdraw.util.IdWorker;
22 import com.topdraw.util.RedissonUtil; 20 import com.topdraw.util.RedissonUtil;
23 import com.topdraw.util.TimestampUtil; 21 import com.topdraw.util.TimestampUtil;
24 import com.topdraw.utils.StringUtils; 22 import com.topdraw.utils.StringUtils;
25 import lombok.Data;
26 import lombok.extern.slf4j.Slf4j; 23 import lombok.extern.slf4j.Slf4j;
27 import org.redisson.api.RLock; 24 import org.redisson.api.RLock;
28 import org.redisson.api.RedissonClient; 25 import org.redisson.api.RedissonClient;
...@@ -30,20 +27,15 @@ import org.slf4j.Logger; ...@@ -30,20 +27,15 @@ import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory; 27 import org.slf4j.LoggerFactory;
31 import org.springframework.beans.BeanUtils; 28 import org.springframework.beans.BeanUtils;
32 import org.springframework.beans.factory.annotation.Autowired; 29 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.data.redis.core.StringRedisTemplate;
34 import org.springframework.data.redis.core.ValueOperations;
35 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 30 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
36 import org.springframework.stereotype.Service; 31 import org.springframework.stereotype.Service;
37 import org.springframework.transaction.annotation.Propagation; 32 import org.springframework.transaction.annotation.Propagation;
38 import org.springframework.transaction.annotation.Transactional; 33 import org.springframework.transaction.annotation.Transactional;
39 import org.springframework.util.CollectionUtils; 34 import org.springframework.util.CollectionUtils;
40 35
41 import javax.annotation.Resource;
42 import java.sql.Timestamp; 36 import java.sql.Timestamp;
43 import java.time.LocalDate;
44 import java.time.LocalDateTime; 37 import java.time.LocalDateTime;
45 import java.util.*; 38 import java.util.*;
46 import java.util.concurrent.TimeUnit;
47 import java.util.stream.Collectors; 39 import java.util.stream.Collectors;
48 40
49 /** 41 /**
...@@ -304,6 +296,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -304,6 +296,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
304 */ 296 */
305 @Override 297 @Override
306 @Transactional(rollbackFor = Exception.class) 298 @Transactional(rollbackFor = Exception.class)
299 @AsyncMqSend()
307 public void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList){ 300 public void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList){
308 log.info("------->>grantPointsThroughTempRightsList start1"); 301 log.info("------->>grantPointsThroughTempRightsList start1");
309 for (TempPoints tempPoints : tempPointsList){ 302 for (TempPoints tempPoints : tempPointsList){
...@@ -505,12 +498,15 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -505,12 +498,15 @@ public class PointsOperationServiceImpl implements PointsOperationService {
505 * @param currentPoints 当前总积分 498 * @param currentPoints 当前总积分
506 */ 499 */
507 private void freshMemberCurrentPoints(Long memberId, Long currentPoints,long duePoints,TempPoints tempPoints) { 500 private void freshMemberCurrentPoints(Long memberId, Long currentPoints,long duePoints,TempPoints tempPoints) {
501
502 MemberDTO memberDTO = this.findMemberByMemberId(memberId);
503
508 Member member = new Member(); 504 Member member = new Member();
509 member.setId(memberId); 505 BeanUtils.copyProperties(memberDTO,member);
506
510 member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0); 507 member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0);
511 member.setDuePoints(duePoints); 508 member.setDuePoints(duePoints);
512 member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now())); 509 member.setUpdateTime(LocalDateTime.now());
513 member.setCode(tempPoints.getMemberCode());
514 try { 510 try {
515 this.memberOperationService.doUpdateMemberPoints(member); 511 this.memberOperationService.doUpdateMemberPoints(member);
516 } catch (Exception e){ 512 } catch (Exception e){
...@@ -518,6 +514,11 @@ public class PointsOperationServiceImpl implements PointsOperationService { ...@@ -518,6 +514,11 @@ public class PointsOperationServiceImpl implements PointsOperationService {
518 } 514 }
519 } 515 }
520 516
517 private MemberDTO findMemberByMemberId(Long memberId) {
518 MemberDTO memberDTO = this.memberService.findById(memberId);
519 return memberDTO;
520 }
521
521 /** 522 /**
522 * 计算当前总积分 523 * 计算当前总积分
523 * @param memberId 会员id 524 * @param memberId 会员id
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.topdraw.business.basicdata.coupon.service.CouponService; 3 import com.topdraw.business.module.coupon.service.CouponService;
4 import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; 4 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
5 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 5 import com.topdraw.business.module.rights.history.domain.RightsHistory;
6 import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService; 6 import com.topdraw.business.module.rights.history.service.RightsHistoryService;
7 import com.topdraw.business.basicdata.rights.service.RightsService; 7 import com.topdraw.business.module.rights.service.RightsService;
8 import com.topdraw.business.basicdata.rights.service.dto.RightsDTO; 8 import com.topdraw.business.module.rights.service.dto.RightsDTO;
9 import com.topdraw.business.process.service.CouponOperationService; 9 import com.topdraw.business.process.service.CouponOperationService;
10 import com.topdraw.business.process.service.ExpOperationService; 10 import com.topdraw.business.process.service.ExpOperationService;
11 import com.topdraw.business.process.service.PointsOperationService; 11 import com.topdraw.business.process.service.PointsOperationService;
...@@ -16,7 +16,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -16,7 +16,6 @@ import lombok.extern.slf4j.Slf4j;
16 import org.slf4j.Logger; 16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 17 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
20 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
21 import org.springframework.util.CollectionUtils; 20 import org.springframework.util.CollectionUtils;
22 import org.springframework.util.StringUtils; 21 import org.springframework.util.StringUtils;
...@@ -103,6 +102,8 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -103,6 +102,8 @@ public class RightsOperationServiceImpl implements RightsOperationService {
103 rightsHistory.setRightsId(value.getId()); 102 rightsHistory.setRightsId(value.getId());
104 rightsHistory.setMemberId(value.getMemberId()); 103 rightsHistory.setMemberId(value.getMemberId());
105 rightsHistory.setExpireTime(value.getExpireTime()); 104 rightsHistory.setExpireTime(value.getExpireTime());
105 String memberCode = value.getMemberCode();
106 rightsHistory.setMemberCode(memberCode);
106 rightsHistoryList.add(rightsHistory); 107 rightsHistoryList.add(rightsHistory);
107 }); 108 });
108 109
...@@ -124,9 +125,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -124,9 +125,7 @@ public class RightsOperationServiceImpl implements RightsOperationService {
124 * @param tempPointsList 权益列表 125 * @param tempPointsList 权益列表
125 */ 126 */
126 private void grantPoint(List<TempPoints> tempPointsList) { 127 private void grantPoint(List<TempPoints> tempPointsList) {
127 log.info(Thread.currentThread().getName() + "=========>>grantPoint start");
128 if (!CollectionUtils.isEmpty(tempPointsList)) 128 if (!CollectionUtils.isEmpty(tempPointsList))
129 log.info("=======>> tempPointsList ======>> " + tempPointsList.toString());
130 this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList); 129 this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList);
131 } 130 }
132 131
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.alibaba.fastjson.JSONArray;
3 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.business.basicdata.coupon.service.CouponService; 5 import com.topdraw.business.module.coupon.service.CouponService;
5 import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; 6 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
6 import com.topdraw.business.basicdata.member.group.service.MemberGroupService; 7 import com.topdraw.business.module.member.group.service.MemberGroupService;
7 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO; 8 import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
8 import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria; 9 import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
9 import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService; 10 import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
10 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO; 11 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
11 import com.topdraw.business.basicdata.rights.service.RightsService; 12 import com.topdraw.business.module.rights.service.RightsService;
12 import com.topdraw.business.basicdata.rights.service.dto.RightsDTO; 13 import com.topdraw.business.module.rights.service.dto.RightsDTO;
13 import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress; 14 import com.topdraw.business.module.task.attribute.service.TaskAttrService;
14 import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService; 15 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
15 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO; 16 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
16 import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria; 17 import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
17 import com.topdraw.business.basicdata.user.iptv.domain.UserTv; 18 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
18 import com.topdraw.business.basicdata.user.iptv.service.UserTvService; 19 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
19 import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO; 20 import com.topdraw.business.module.user.iptv.domain.UserTv;
21 import com.topdraw.business.module.user.iptv.service.UserTvService;
22 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
23 import com.topdraw.business.process.domian.result.TaskTemplateType;
20 import com.topdraw.business.process.service.PointsOperationService; 24 import com.topdraw.business.process.service.PointsOperationService;
21 import com.topdraw.business.process.service.RightsOperationService; 25 import com.topdraw.business.process.service.RightsOperationService;
22 import com.topdraw.business.process.service.TaskOperationService; 26 import com.topdraw.business.process.service.TaskOperationService;
23 import com.topdraw.business.basicdata.member.service.MemberService; 27 import com.topdraw.business.module.member.service.MemberService;
24 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 28 import com.topdraw.business.module.member.service.dto.MemberDTO;
25 import com.topdraw.business.basicdata.task.domain.Task; 29 import com.topdraw.business.module.task.domain.Task;
26 import com.topdraw.business.basicdata.task.service.TaskService; 30 import com.topdraw.business.module.task.service.TaskService;
27 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 31 import com.topdraw.business.module.task.template.domain.TaskTemplate;
28 import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; 32 import com.topdraw.business.module.task.template.service.TaskTemplateService;
29 import com.topdraw.business.process.domian.*; 33 import com.topdraw.business.process.domian.*;
30 import com.topdraw.business.process.service.UserTvOperationService; 34 import com.topdraw.business.process.service.UserOperationService;
31 import com.topdraw.common.ResultInfo; 35 import com.topdraw.common.ResultInfo;
36 import com.topdraw.exception.BadRequestException;
32 import com.topdraw.module.mq.DataSyncMsg; 37 import com.topdraw.module.mq.DataSyncMsg;
33 import com.topdraw.util.*; 38 import com.topdraw.util.*;
34 import lombok.extern.slf4j.Slf4j; 39 import lombok.extern.slf4j.Slf4j;
...@@ -40,6 +45,7 @@ import org.springframework.stereotype.Service; ...@@ -40,6 +45,7 @@ import org.springframework.stereotype.Service;
40 import org.springframework.util.CollectionUtils; 45 import org.springframework.util.CollectionUtils;
41 import org.springframework.util.StringUtils; 46 import org.springframework.util.StringUtils;
42 47
48 import javax.validation.constraints.NotNull;
43 import java.sql.Timestamp; 49 import java.sql.Timestamp;
44 import java.time.LocalDate; 50 import java.time.LocalDate;
45 import java.time.LocalDateTime; 51 import java.time.LocalDateTime;
...@@ -76,6 +82,10 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -76,6 +82,10 @@ public class TaskOperationServiceImpl implements TaskOperationService {
76 CouponService couponService; 82 CouponService couponService;
77 @Autowired 83 @Autowired
78 MemberGroupService memberGroupService; 84 MemberGroupService memberGroupService;
85 @Autowired
86 TaskAttrService taskAttrService;
87 @Autowired
88 UserTvService userTvService;
79 89
80 90
81 private static final Integer TASK_FINISH_STATUS = 1; 91 private static final Integer TASK_FINISH_STATUS = 1;
...@@ -86,12 +96,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -86,12 +96,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
86 @Override 96 @Override
87 public ResultInfo dealTask(String content) { 97 public ResultInfo dealTask(String content) {
88 98
89 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); 99 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
90 DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); 100 DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg();
91 Integer event = msgData.getEvent(); 101 Integer event = msgData.getEvent();
102 String memberCode = msgData.getMemberCode();
92 Long memberId = msgData.getMemberId(); 103 Long memberId = msgData.getMemberId();
93 104 if (StringUtils.hasText(memberCode)) {
94 long l = System.currentTimeMillis(); 105 MemberDTO memberDTO = this.memberService.getByCode(memberCode);
106 memberId = memberDTO.getId();
107 }
95 108
96 // 检查当前会员的黑名单状态 109 // 检查当前会员的黑名单状态
97 boolean b = this.validatedMemberBlackStatus(memberId); 110 boolean b = this.validatedMemberBlackStatus(memberId);
...@@ -100,25 +113,38 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -100,25 +113,38 @@ public class TaskOperationServiceImpl implements TaskOperationService {
100 } 113 }
101 114
102 // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板 115 // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板
103 TaskTemplate taskTemplate = this.getTaskTemplate(event); 116 TaskTemplate taskTemplate = this.getTaskTemplate(event,dataSyncMsg);
104 // 2.通过任务模板获取对应的任务列表 117 // 2.通过任务模板获取对应的任务列表
105 List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate); 118 List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate,dataSyncMsg);
106 // 4.判断当前用户是否满足任务完成条件 119 // 4.判断当前用户是否满足任务完成条件
107 boolean checkResult = this.checkTaskCompletion(memberId,taskList); 120 boolean checkResult = this.checkTaskCompletion(memberId,taskList);
108 if (checkResult) { 121 if (checkResult) {
109
110 // 5.权益区分(积分、权益、成长值) 122 // 5.权益区分(积分、权益、成长值)
111 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId,taskList,msgData); 123 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId,taskList,msgData);
112 // 6.权益发放 124
125 // 6.风控检查
126 boolean result = this.checkRiskManagement(memberId,tempRightsMap);
127
128 if (result) throw new BadRequestException("发放失败,已达风控上限");
129
130 // 7.权益发放
113 this.grantRight(tempRightsMap); 131 this.grantRight(tempRightsMap);
114 132
115 } 133 }
116 134 System.out.println(taskList);
117 long r = System.currentTimeMillis();
118 log.info("总耗时======>>>>>" + (r-l));
119 return ResultInfo.success(); 135 return ResultInfo.success();
120 136
137 }
121 138
139 /**
140 * 风控检查
141 * @param memberId
142 * @param tempRightsMap
143 * @return
144 */
145 private boolean checkRiskManagement(Long memberId , Map<RightType, Object> tempRightsMap) {
146 // TODO 风控
147 return false;
122 } 148 }
123 149
124 /** 150 /**
...@@ -139,40 +165,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -139,40 +165,6 @@ public class TaskOperationServiceImpl implements TaskOperationService {
139 } 165 }
140 166
141 /** 167 /**
142 * 永久权益
143 * @param memberId 会员id
144 * @return PermanentRightsDTO 永久权益
145 */
146 @Deprecated
147 private PermanentRightsDTO getPermanentRights(Long memberId) {
148 PermanentRightsDTO permanentRights = null;
149 MemberDTO memberDTO = this.memberService.findById(memberId);
150 if (Objects.nonNull(memberDTO)) {
151 Integer level = memberDTO.getLevel();
152 // 永久权益
153 permanentRights = this.permanentRightsService.findByLevel(level);
154 }
155 return permanentRights;
156 }
157
158 /**
159 * 解析模板参数
160 * @param taskTemplate 任务模板
161 * @return Map<String, Object> 模板参数解析结果
162 */
163 @Deprecated
164 private Map<String, Object> parseTaskTemplateParam(TaskTemplate taskTemplate) {
165 if (Objects.nonNull(taskTemplate)) {
166 String params = taskTemplate.getParams();
167 if (!StringUtils.isEmpty(params)) {
168 Map paramMap = JSONObject.parseObject(params,Map.class);
169 return paramMap;
170 }
171 }
172 return null;
173 }
174
175 /**
176 * 任务完成情况 168 * 任务完成情况
177 * @param resources 任务完成情况 169 * @param resources 任务完成情况
178 */ 170 */
...@@ -224,6 +216,34 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -224,6 +216,34 @@ public class TaskOperationServiceImpl implements TaskOperationService {
224 216
225 } 217 }
226 218
219 private Long getIptvPriorityMemberId(Long memberId1,DataSyncMsg.MsgData msgData) {
220
221 //
222 if (Objects.nonNull(memberId1)) {
223 return memberId1;
224 }
225
226
227 @NotNull Integer deviceType = msgData.getDeviceType();
228 Long userId = msgData.getUserId();
229 // 大屏
230 if (Objects.nonNull(userId) || deviceType == 1) {
231
232 }
233
234 MemberDTO memberDTO = this.findMemberById(memberId1);
235 if (Objects.nonNull(memberDTO.getId())) {
236 Long userIptvId = memberDTO.getUserIptvId();
237 // 绑定了大屏,直接返回小屏会员id
238 if (Objects.nonNull(userIptvId)) {
239 return memberDTO.getId();
240 } else {
241 //
242 }
243 }
244 return null;
245 }
246
227 /** 247 /**
228 * 验证是否满足永久权益 248 * 验证是否满足永久权益
229 * @param permanentRights 249 * @param permanentRights
...@@ -271,13 +291,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -271,13 +291,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
271 /** 291 /**
272 * 创建权益 292 * 创建权益
273 * @param memberId 293 * @param memberId
294 * @param memberCode
274 * @param rightsAmount 295 * @param rightsAmount
275 * @return 296 * @return
276 */ 297 */
277 private TempRights tmpRightsBuild(Long memberId ,Integer rightsAmount,RightsDTO rightsDTO){ 298 private TempRights tmpRightsBuild(Long memberId ,String memberCode,Integer rightsAmount,RightsDTO rightsDTO){
278 TempRights tempRights = new TempRights(); 299 TempRights tempRights = new TempRights();
279 BeanUtils.copyProperties(rightsDTO,tempRights); 300 BeanUtils.copyProperties(rightsDTO,tempRights);
280 tempRights.setMemberId(memberId); 301 tempRights.setMemberId(memberId);
302 tempRights.setMemberCode(memberCode);
281 tempRights.setRightsAmount(rightsAmount); 303 tempRights.setRightsAmount(rightsAmount);
282 Long expireTime = rightsDTO.getExpireTime(); 304 Long expireTime = rightsDTO.getExpireTime();
283 if (Objects.nonNull(expireTime)) 305 if (Objects.nonNull(expireTime))
...@@ -288,14 +310,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -288,14 +310,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
288 /** 310 /**
289 * 优惠券 311 * 优惠券
290 * @param memberId 312 * @param memberId
291 * @param rightsAmount 313 * @param memberCode
292 * @param rightsSendStrategy 314 * @param rightsSendStrategy
293 * @return 315 * @return
294 */ 316 */
295 private TempCoupon tempCouponBuild(Long memberId ,Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){ 317 private TempCoupon tempCouponBuild(Long memberId ,String memberCode , Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){
296 TempCoupon tempCoupon = new TempCoupon(); 318 TempCoupon tempCoupon = new TempCoupon();
297 BeanUtils.copyProperties(couponDTO,tempCoupon); 319 BeanUtils.copyProperties(couponDTO,tempCoupon);
298 tempCoupon.setCode(couponDTO.getCode()); 320 tempCoupon.setCode(couponDTO.getCode());
321 tempCoupon.setMemberCode(memberCode);
299 tempCoupon.setMemberId(memberId); 322 tempCoupon.setMemberId(memberId);
300 tempCoupon.setRightsAmount(rightsAmount); 323 tempCoupon.setRightsAmount(rightsAmount);
301 tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); 324 tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy);
...@@ -377,12 +400,13 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -377,12 +400,13 @@ public class TaskOperationServiceImpl implements TaskOperationService {
377 400
378 Long memberId = memberDTO.getId(); 401 Long memberId = memberDTO.getId();
379 String nickname = memberDTO.getNickname(); 402 String nickname = memberDTO.getNickname();
403 String memberCode = memberDTO.getCode();
380 // 权益详情 404 // 权益详情
381 RightsDTO rightsDTO = this.getRight(rightsId); 405 RightsDTO rightsDTO = this.getRight(rightsId);
382 406
383 if (Objects.nonNull(rightsDTO)){ 407 if (Objects.nonNull(rightsDTO)){
384 // 用以保存权益历史 408 // 用以保存权益历史
385 TempRights tempRights = this.tmpRightsBuild(memberId,rightsAmount,rightsDTO); 409 TempRights tempRights = this.tmpRightsBuild(memberId,memberCode,rightsAmount,rightsDTO);
386 rightsList.add(tempRights); 410 rightsList.add(tempRights);
387 411
388 // 权益类型 412 // 权益类型
...@@ -394,7 +418,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -394,7 +418,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
394 CouponDTO couponDTO = this.findCouponById(entityId); 418 CouponDTO couponDTO = this.findCouponById(entityId);
395 if (Objects.nonNull(couponDTO)) { 419 if (Objects.nonNull(couponDTO)) {
396 // 优惠券 420 // 优惠券
397 TempCoupon tempCoupon = this.tempCouponBuild(memberId, rightsAmount, rightsSendStrategy, couponDTO, nickname); 421 TempCoupon tempCoupon = this.tempCouponBuild(memberId, memberCode,rightsAmount, rightsSendStrategy, couponDTO, nickname);
398 tempCouponList.add(tempCoupon); 422 tempCouponList.add(tempCoupon);
399 } 423 }
400 } 424 }
...@@ -435,6 +459,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -435,6 +459,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
435 tempExp.setMemberId(memberId); 459 tempExp.setMemberId(memberId);
436 tempExp.setAppCode(msgData.getAppCode()); 460 tempExp.setAppCode(msgData.getAppCode());
437 tempExp.setMemberId(msgData.getMemberId()); 461 tempExp.setMemberId(msgData.getMemberId());
462 tempExp.setMemberCode(msgData.getMemberCode());
438 tempExp.setItemId(msgData.getItemId()); 463 tempExp.setItemId(msgData.getItemId());
439 tempExp.setAccountId(msgData.getAccountId()); 464 tempExp.setAccountId(msgData.getAccountId());
440 tempExp.setRewardExp(task.getRewardExp()); 465 tempExp.setRewardExp(task.getRewardExp());
...@@ -473,6 +498,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -473,6 +498,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
473 } 498 }
474 tempPoints.setRewardPointsExpireTime(rewardPointsExpireTime); 499 tempPoints.setRewardPointsExpireTime(rewardPointsExpireTime);
475 tempPoints.setMemberId(memberId); 500 tempPoints.setMemberId(memberId);
501 tempPoints.setMemberCode(msgData.getMemberCode());
476 tempPoints.setAppCode(msgData.getAppCode()); 502 tempPoints.setAppCode(msgData.getAppCode());
477 tempPoints.setPoints(rewardPoints); 503 tempPoints.setPoints(rewardPoints);
478 tempPoints.setPointsType(pointsType); 504 tempPoints.setPointsType(pointsType);
...@@ -763,17 +789,96 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -763,17 +789,96 @@ public class TaskOperationServiceImpl implements TaskOperationService {
763 * @param taskTemplate 任务模板 789 * @param taskTemplate 任务模板
764 * @return List<task> 任务列表 790 * @return List<task> 任务列表
765 */ 791 */
766 private List<Task> loadListTaskByTaskTemplate(TaskTemplate taskTemplate,Map<String,Object> paramMap) { 792 private List<Task> loadListTaskByTaskTemplate(TaskTemplate taskTemplate,DataSyncMsg dataSyncMsg) {
767 793
768 if (Objects.nonNull(taskTemplate)) { 794 if (Objects.nonNull(taskTemplate)) {
795
769 Long taskTemplateId = taskTemplate.getId(); 796 Long taskTemplateId = taskTemplate.getId();
770 return this.taskService.findByTemplateId(taskTemplateId); 797
798 List<Task> taskList = this.taskService.findByTemplateId(taskTemplateId);
799
800 Integer type = taskTemplate.getType();
801 taskList = this.pickUpTask(taskList,dataSyncMsg,type);
802 return taskList;
803
771 } 804 }
772 805
773 return null; 806 return null;
774 } 807 }
775 808
776 /** 809 /**
810 * 通过参数确定具体任务
811 * @param taskList
812 * @param dataSyncMsg
813 * @return
814 */
815 private List<Task> pickUpTask(List<Task> taskList,DataSyncMsg dataSyncMsg,Integer type) {
816
817 List<Task> taskList1 = new ArrayList<>();
818
819 DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg();
820
821 if (Objects.nonNull(msgData)) {
822
823 String param = msgData.getParam();
824 Map<String,String> jsonObjectMap = JSONObject.parseObject(param,Map.class);
825 Collection<String> values = jsonObjectMap.values();
826
827 for (Task task : taskList) {
828
829 Long taskId = task.getId();
830 TaskAttrDTO taskAttrDTO = this.findTaskAttrByTaskId(taskId);
831 if (Objects.isNull(taskAttrDTO.getId()))
832 continue;
833
834 String attrStr = taskAttrDTO.getAttrStr();
835 if (StringUtils.hasText(attrStr)) {
836 JSONObject jsonObject = JSONObject.parseObject(attrStr);
837 JSONArray values_0 = jsonObject.getJSONArray("value");
838
839 switch (type) {
840 // 登录
841 case TaskTemplateType.TYPE_1:
842
843 Integer o1 = (Integer)values_0.get(0);
844 Integer o2 = (Integer)values_0.get(1);
845 List<Integer> list = Arrays.asList(o1, o2);
846 String s = values.toArray()[0].toString();
847 Integer i = Integer.valueOf(s);
848 boolean b = UcListUtils.compareIntegerList(i, list);
849 if (b)
850 taskList1.add(task);
851 break;
852
853 // 订购
854 case TaskTemplateType.TYPE_4:
855 if (values_0.containsAll(values))
856 taskList1.add(task);
857 break;
858
859 default:
860 break;
861 }
862
863
864 }
865
866 }
867
868 } else {
869 return taskList;
870 }
871
872 return taskList1;
873
874 }
875
876 private TaskAttrDTO findTaskAttrByTaskId(Long taskId) {
877 return this.taskAttrService.findByTaskId(taskId);
878 }
879
880
881 /**
777 * 获取任务模板对应的任务列表 882 * 获取任务模板对应的任务列表
778 * 883 *
779 * @param taskTemplate 任务模板 884 * @param taskTemplate 任务模板
...@@ -794,24 +899,67 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -794,24 +899,67 @@ public class TaskOperationServiceImpl implements TaskOperationService {
794 * @param event 任务 899 * @param event 任务
795 * @return TaskTemplate 任务模板 900 * @return TaskTemplate 任务模板
796 */ 901 */
797 private TaskTemplate getTaskTemplate(Integer event) { 902 private TaskTemplate getTaskTemplate(Integer event,DataSyncMsg msgData) {
798 return this.taskTemplateService.findByType(event); 903 DataSyncMsg.MsgData msg = msgData.getMsg();
904
905 if (Objects.nonNull(msg)) {
906
907 return this.findByTypeAndParam(event,msg);
908
909 } else {
910
911 List<TaskTemplate> taskTemplateList = this.taskTemplateService.findByType(event);
912
913 if (!CollectionUtils.isEmpty(taskTemplateList)) {
914
915 return taskTemplateList.get(0);
916
917 } else {
918
919 return null;
920
921 }
922
923 }
799 } 924 }
800 925
926 private TaskTemplate findByTypeAndParam(Integer event, DataSyncMsg.MsgData taskTemplateParam) {
927 String param = taskTemplateParam.getParam();
928 if (StringUtils.hasText(param)) {
801 929
930 Map<String,String> jsonObject = JSONObject.parseObject(param,Map.class);
802 931
932 List<TaskTemplate> taskTemplateList = this.taskTemplateService.findByType(event);
933 if (!CollectionUtils.isEmpty(taskTemplateList)) {
934
935 for (TaskTemplate taskTemplate : taskTemplateList) {
936
937 String templateParams = taskTemplate.getParams();
938 if(StringUtils.hasText(templateParams)) {
939 String templateParamsUpperCase = templateParams.toUpperCase();
940 boolean b = jsonObject.containsKey(templateParamsUpperCase);
941 if (b)
942 return taskTemplate;
943 }
944 }
945
946 }
947
948 }
949
950
951 return null;
952 }
803 953
804 954
805 //////////////////////////////////////////////////////////////////////////////////////////////////////////// 955 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
806 956
807 @Autowired 957 @Autowired
808 UserTvService userTvService;
809 @Autowired
810 private StringRedisTemplate stringRedisTemplate; 958 private StringRedisTemplate stringRedisTemplate;
811 @Autowired 959 @Autowired
812 private PointsOperationService pointsOperationService; 960 private PointsOperationService pointsOperationService;
813 @Autowired 961 @Autowired
814 private UserTvOperationService userTvOperationService; 962 private UserOperationService userTvOperationService;
815 963
816 private UserTv checkUserTv(String platformAccount){ 964 private UserTv checkUserTv(String platformAccount){
817 UserTv userTv = new UserTv(); 965 UserTv userTv = new UserTv();
...@@ -825,6 +973,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -825,6 +973,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
825 } 973 }
826 974
827 @Override 975 @Override
976 @Deprecated
828 public boolean createPoint2ChongQing(String platformAccount, Long points) { 977 public boolean createPoint2ChongQing(String platformAccount, Long points) {
829 978
830 boolean result = this.verificationActivity(platformAccount); 979 boolean result = this.verificationActivity(platformAccount);
...@@ -847,7 +996,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -847,7 +996,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
847 tempPoints.setMemberId(memberId); 996 tempPoints.setMemberId(memberId);
848 tempPoints.setMemberCode(code); 997 tempPoints.setMemberCode(code);
849 tempPoints.setPoints(points); 998 tempPoints.setPoints(points);
850 tempPoints.setDescription("重庆重数大屏积分兑换活动,时间:202112"); 999 // tempPoints.setDescription("重庆重数大屏积分兑换活动,时间:202112");
851 tempPoints.setDeviceType(1); 1000 tempPoints.setDeviceType(1);
852 tempPoints.setEvtType(3); 1001 tempPoints.setEvtType(3);
853 tempPoints.setPointsType(0); 1002 tempPoints.setPointsType(0);
......
1 package com.topdraw.business.process.service.impl;
2
3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.date.DateUtil;
5 import cn.hutool.core.util.ObjectUtil;
6 import cn.hutool.core.util.StrUtil;
7 import cn.hutool.http.HttpUtil;
8 import com.alibaba.fastjson.JSON;
9 import com.alibaba.fastjson.JSONObject;
10 import com.topdraw.aspect.AsyncMqSend;
11 import com.topdraw.business.module.member.domain.Member;
12 import com.topdraw.business.module.member.domain.MemberBuilder;
13 import com.topdraw.business.module.member.profile.domain.MemberProfile;
14 import com.topdraw.business.module.member.profile.domain.MemberProfileBuild;
15 import com.topdraw.business.module.member.profile.service.MemberProfileService;
16 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
17 import com.topdraw.business.module.member.service.MemberService;
18 import com.topdraw.business.module.member.service.dto.MemberDTO;
19 import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
20 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
21 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
22 import com.topdraw.business.module.user.iptv.domain.UserConstant;
23 import com.topdraw.business.module.user.iptv.domain.UserTv;
24 import com.topdraw.business.module.user.iptv.service.UserTvService;
25 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
26 import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
27 import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
28 import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository;
29 import com.topdraw.business.module.user.weixin.collection.service.UserCollectionDetailService;
30 import com.topdraw.business.module.user.weixin.collection.service.UserCollectionService;
31 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
32 import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository;
33 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
34 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
35 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
36 import com.topdraw.business.process.domian.weixin.*;
37 import com.topdraw.business.process.service.UserOperationService;
38 import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper;
39 import com.topdraw.config.LocalConstants;
40 import com.topdraw.config.RedisKeyUtil;
41 import com.topdraw.exception.BadRequestException;
42 import com.topdraw.exception.EntityNotFoundException;
43 import com.topdraw.security.AESUtil;
44 import com.topdraw.util.IdWorker;
45 import com.topdraw.util.TimestampUtil;
46 import com.topdraw.utils.QueryHelp;
47 import com.topdraw.utils.RedisUtils;
48 import com.topdraw.utils.StringUtils;
49 import com.topdraw.weixin.beans.*;
50 import com.topdraw.weixin.beans.config.WeiXinAppListConfig;
51 import com.topdraw.weixin.util.WeChatConstants;
52 import com.topdraw.weixin.util.WeiXinRequestUtil;
53 import com.topdraw.weixin.util.WeixinUtil;
54 import lombok.extern.slf4j.Slf4j;
55 import org.redisson.api.RedissonClient;
56 import org.springframework.beans.BeanUtils;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.beans.factory.annotation.Value;
59 import org.springframework.context.annotation.Bean;
60 import org.springframework.data.domain.PageRequest;
61 import org.springframework.data.domain.Sort;
62 import org.springframework.stereotype.Service;
63 import org.springframework.transaction.annotation.Propagation;
64 import org.springframework.transaction.annotation.Transactional;
65 import org.springframework.util.CollectionUtils;
66
67 import java.nio.charset.StandardCharsets;
68 import java.sql.Timestamp;
69 import java.time.LocalDateTime;
70 import java.util.*;
71 import java.util.concurrent.TimeUnit;
72 import java.util.stream.Collectors;
73
74 @Service
75 @Slf4j
76 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
77 public class UserOperationServiceImpl implements UserOperationService {
78
79
80 @Autowired
81 private MemberService memberService;
82 @Autowired
83 private UserTvService userTvService;
84 @Autowired
85 private UserWeixinService userWeixinService;
86 @Autowired
87 private RedisUtils redisUtils;
88 @Autowired
89 private WeiXinAppListConfig weiXinAppListConfig;
90 @Autowired
91 private MemberProfileService memberProfileService;
92 @Autowired
93 private WeiXinRequestUtil weixinRequestUtil;
94 @Autowired
95 private UserCollectionService userCollectionService;
96 @Autowired
97 private UserCollectionDetailService userCollectionDetailService;
98 @Autowired
99 private UserCollectionDetailRepository userCollectionDetailRepository;
100 @Autowired
101 private CollectionMq2DetailMapper collectionMq2DetailMapper;
102 @Autowired
103 private UserWeixinRepository userWeixinRepository;
104 @Autowired
105 private MemberVipHistoryService memberVipHistoryService;
106
107
108
109 /** 取消关注 */
110 private static final Integer UNSUBSCRIBE_STATUS = 0;
111 private static final Integer SUBSCRIBE_STATUS = 1;
112 private static final String SUBSCRIBE = "subscribe";
113 private static final String UNSUBSCRIBE = "unsubscribe";
114 private static final Integer[] PLATFORM_LIST = new Integer[]{0,1,2,3};
115 private static final Integer[] IPTV_MAJOR = new Integer[]{0,1};
116
117 private static final String QR_CODE_URL = "QR_CODE_URL_";
118
119 @Value("${uc.service.platform:}")
120 private String platform;
121
122 @Value("${key:}")
123 private String key;
124
125 @Value("${uc.app.subAppId:wx05f35931270014be}")
126 private String subAppId;
127
128 @Value("${uc.app.h5AppId:wxca962918dfeed88c}")
129 private String h5AppId;
130
131 @Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
132 private String appletAppid;
133
134 @Value("${file.upload:upload}")
135 private String filePath;
136
137
138
139 /**
140 * 微信公众号关注
141 * 1.未扫描大屏二维码
142 * 1). 保存、修改小屏账户,创建小屏账户会员
143 * 2.扫描大屏二维码
144 * 1). 从redis中获取大屏信息
145 * 2). 大屏账户保存小屏会员的code
146 * 3). 小屏会员中保存大屏的id
147 * @description 大小屏绑定,大屏账户保存小屏会员编码
148 * @param resources
149 * @return
150 */
151 @Override
152 public boolean subscribe(SubscribeBean resources) {
153 String unionId = resources.getUnionid();
154 String appId = resources.getAppId();
155 String openId = resources.getOpenId();
156 String nickname = resources.getNickname();
157 String headImgUrl = resources.getHeadimgurl();
158
159 // 小屏账户
160 UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId);
161
162 if (Objects.isNull(userWeixinDTO.getId())) {
163
164 DefaultWeiXinBeanDefinition weiXinBeanDefinition = new DefaultWeiXinBeanDefinition();
165 weiXinBeanDefinition.setUnionId(unionId);
166 weiXinBeanDefinition.setAppid(appId);
167 weiXinBeanDefinition.setOpenId(openId);
168 weiXinBeanDefinition.setNickname(nickname);
169 weiXinBeanDefinition.setHeadImgUrl(headImgUrl);
170 // 创建会员和账户
171 this.doCreateUserWeiXinAndMember(weiXinBeanDefinition);
172
173 } else {
174
175 // 修改账户和会员信息
176 this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId,headImgUrl,nickname);
177
178 }
179
180 // 大屏信息
181 JSONObject iptvUserInfo = resources.getIptvUserInfo();
182 if (Objects.nonNull(iptvUserInfo)) {
183
184 // 小屏会员
185 MemberDTO memberDTO = this.findMemberByAppIdAndOpenId(appId,openId);
186
187 // 账户
188 String platformAccount = iptvUserInfo.getString("platformAccount");
189
190 this.bind(memberDTO,platformAccount);
191
192 }
193
194 // 关注历史记录,用于恢复VIP等级(0:普通 1:团粉 其他:会员(过期后vip恢复到最高等级))
195 this.doInsertSubscribeHistory(appId,openId,WeChatConstants.EVENT_SUBSCRIBE);
196
197 return true;
198
199 }
200
201 /**
202 *
203 * @param appId
204 * @param openId
205 */
206 private void doInsertSubscribeHistory(String appId, String openId,String event) {
207 // 小屏会员
208 MemberDTO member = this.findMemberByAppIdAndOpenId(appId,openId);
209
210 MemberVipHistory memberVipHistory = new MemberVipHistory();
211 memberVipHistory.setMemberId(member.getId()).setStatus(1);
212 //小屏侧,理论上大屏不会收到该事件
213 if (WeChatConstants.EVENT_SUBSCRIBE.equals(event)) {//关注
214 memberVipHistory.setVip(1);
215 if (member.getVip() == 0) {
216 member.setVip(1);
217 memberVipHistory.setBeforeVip(0);
218 }
219 } else if (WeChatConstants.EVENT_UNSUBSCRIBE.equals(event)) {// 取消关注
220 memberVipHistory.setVip(0);
221 if (member.getVip() == 1) {
222 member.setVip(0);
223 memberVipHistory.setBeforeVip(1);
224 }
225 }
226 memberVipHistory.setVipExpireTime(LocalDateTime.now());
227 memberVipHistoryService.create(memberVipHistory);
228 }
229
230 /**
231 * 获取小屏账户
232 * @param unionId
233 * @param appId
234 * @param openId
235 * @return
236 */
237 private UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId( String unionId,String appId, String openId) {
238 return this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId,openId);
239 }
240
241 /**
242 *
243 * @param userWeixinDTO
244 * @param appId
245 * @param openId
246 */
247 private void doUpdateUserWeiXinAndMember(UserWeixinDTO userWeixinDTO,String appId,String openId,String headImgUrl,String nickName) {
248
249 userWeixinDTO.setAppid(appId);
250 userWeixinDTO.setOpenid(openId);
251 userWeixinDTO.setNickname(nickName);
252 userWeixinDTO.setHeadimgurl(headImgUrl);
253 // 修改微信账户关注状态
254 this.doUpdateUserWeiXinStatus(userWeixinDTO,SUBSCRIBE_STATUS);
255
256 // 小屏会员
257 MemberDTO memberDTO_0 = this.findMemberByAppIdAndOpenId(appId,openId);
258
259 if (StringUtils.isNotBlank(headImgUrl) && StringUtils.isNotBlank(nickName)) {
260 memberDTO_0.setAvatarUrl(headImgUrl);
261 memberDTO_0.setNickname(nickName);
262 }
263
264 this.doUpdateMemberVip(memberDTO_0,1);
265 }
266
267 /**
268 * 创建会员和账户
269 * @param weiXinBeanDefinition
270 */
271 private void doCreateUserWeiXinAndMember(DefaultWeiXinBeanDefinition weiXinBeanDefinition) {
272
273 // 小屏账户
274 UserWeixin userWeixin = this.generateUserWeiXin(weiXinBeanDefinition,SUBSCRIBE_STATUS);
275
276 // 保存会员
277 // Long memberId = this.doCreateMember(userWeixin,1);
278 Member member = this.doCreateMemberAndReturnMember(userWeixin,1);
279
280 if (Objects.isNull(member.getId())) {
281 throw new BadRequestException("会员创建保存失败");
282 }
283
284 // 保存或者修改,微信账户信息
285 this.doCreateUserWeiXin(userWeixin,member);
286
287 }
288
289 /**
290 * 获取小屏会员
291 * @param appId
292 * @param openId
293 * @return
294 */
295 private MemberDTO findMemberByAppIdAndOpenId(String appId, String openId) {
296 UserWeixinDTO userWeixinDTO = this.findUserWeiXinByOpenIdAndAppId(appId, openId);
297 if (Objects.nonNull(userWeixinDTO)) {
298 Long memberId = userWeixinDTO.getMemberId();
299 return this.findMemberById(memberId);
300 }
301 return null;
302 }
303
304 /**
305 * 微信公众号取消关注
306 * @param resources
307 * @return
308 */
309 @Override
310 public boolean unsubscribe(SubscribeBean resources) {
311
312 String appId = resources.getAppId();
313 String openId = resources.getOpenId();
314
315 // 修改关注状态 0:未关注
316 UserWeixinDTO userWeixinDTO = this.doUpdateUserWeiXinStatus(appId, openId, UNSUBSCRIBE_STATUS);
317
318 // 会员
319 MemberDTO memberDTO = this.findMemberByUserWeixinDTO(userWeixinDTO);
320
321 // 修改会员vip,如果没有购买会员则取消团粉
322 this.doUpdateMemberVip(memberDTO,0);
323
324 // 关注历史记录
325 this.doInsertSubscribeHistory(appId,openId,WeChatConstants.EVENT_UNSUBSCRIBE);
326
327 return true;
328 }
329
330 /**
331 * 更新大屏信息,同时判断是否已经关注,如果关注了则不跳转H5页面
332 * @param data
333 * @return
334 */
335 @Override
336 public UserWeixinDTO saveUserInfo(String data) {
337
338 log.info("result ====>> [{}]",data);
339
340 JSONObject json = JSONObject.parseObject(data);
341 String unionId = json.getString("unionid");
342 // 订阅号appid
343 String appId = json.getString("dyAppid");
344
345 try {
346
347 // 过期时间300S
348 this.redisUtils.set(RedisKeyUtil.genSeSuSubscribeKey(unionId), data, 300);
349 Object o = this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionId));
350 String contentJsonStr = JSON.toJSONString(o);
351 log.info("H5 save in redis contentJsonStr ====>> [{}]",contentJsonStr);
352
353 // 若未传dyAppId。不走下面的流程
354 if (StrUtil.isNotBlank(appId)) {
355 UserWeixinDTO userWeixinDTO = this.findUserWeiXinByUnionIdAndAppId(unionId,appId);
356 return userWeixinDTO;
357 }
358
359 } catch (Exception e) {
360 log.error(" saveUserInfo get an error || data: {} || msg: {} ", data, e.getMessage());
361 }
362
363 return null;
364 }
365
366
367 /**
368 *
369 * @param unionid
370 * @param appId
371 * @return
372 */
373 private UserWeixinDTO findUserWeiXinByUnionIdAndAppId(String unionid, String appId) {
374 return this.userWeixinService.findFirstByUnionidAndAppid(unionid,appId);
375 }
376
377 /**
378 * 修改会员vip状态
379 */
380 private void doUpdateMemberVip(MemberDTO memberDTO,Integer vip1) {
381 if (memberDTO != null) {
382 Integer vip = memberDTO.getVip();
383 vip = (vip == null ? 0 : vip);
384 // 未购买付费会员
385 if (vip <= 1) {
386
387 memberDTO.setVip(vip1);
388
389 Member member = new Member();
390 BeanUtils.copyProperties(memberDTO, member);
391 this.memberService.update(member);
392 }
393 }
394 }
395
396 /**
397 * 获取小屏会员
398 * @param userWeixinDTO
399 * @return
400 */
401 private MemberDTO findMemberByUserWeixinDTO(UserWeixinDTO userWeixinDTO) {
402 Long memberId = userWeixinDTO.getMemberId();
403 if (Objects.nonNull(memberId)) {
404 MemberDTO memberDTO = this.findMemberById(memberId);
405 return memberDTO;
406 }
407 return null;
408 }
409
410 /**
411 * 修改微信公众号关注状态
412 * @param status 0:取消关注 1:关注
413 */
414 private UserWeixinDTO doUpdateUserWeiXinStatus(String appId, String openId, Integer status) {
415
416 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId);
417
418 if (Objects.nonNull(userWeixinDTO.getId())) {
419
420 userWeixinDTO.setStatus(status);
421
422 UserWeixin userWeixin = new UserWeixin();
423 BeanUtils.copyProperties(userWeixinDTO,userWeixin);
424
425 this.userWeixinService.update(userWeixin);
426
427 }
428
429 return userWeixinDTO;
430
431 }
432
433 /**
434 * 修改微信公众号关注状态
435 * @param status 0:取消关注 1:关注
436 */
437 private UserWeixinDTO doUpdateUserWeiXinStatus(UserWeixinDTO userWeixinDTO, Integer status) {
438
439 userWeixinDTO.setStatus(status);
440
441 UserWeixin userWeixin = new UserWeixin();
442 BeanUtils.copyProperties(userWeixinDTO,userWeixin);
443
444 this.userWeixinService.update(userWeixin);
445
446
447 return userWeixinDTO;
448
449 }
450
451 /**
452 * 通过openId和appId获取微信信息
453 * @param appId
454 * @param openId
455 * @return
456 */
457 private UserWeixinDTO findUserWeiXinByOpenIdAndAppId(String appId, String openId) {
458 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId,openId);
459 return userWeixinDTO;
460 }
461
462 /**
463 * 获取会员
464 * @param memberId
465 * @return
466 */
467 private MemberDTO findMemberById(Long memberId) {
468 MemberDTO memberDTO = this.memberService.findById(memberId);
469 return memberDTO;
470 }
471
472 /**
473 * 小程序登录
474 * @param resources
475 * @return
476 */
477 @Override
478 @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class)
479 public UserWeixinDTO appletLogin(WeiXinUserBean resources) {
480 String appid = resources.getAppid();
481 String openid = resources.getOpenid();
482 String headimgurl = resources.getHeadimgurl();
483 String unionid = resources.getUnionid();
484
485
486 // 解析
487 DefaultWeiXinBeanDefinition weiXinBeanDefinition = new DefaultWeiXinBeanDefinition();//this.parseAppletInfo(resources);
488 weiXinBeanDefinition.setAppid(appid);
489 weiXinBeanDefinition.setOpenId(openid);
490 weiXinBeanDefinition.setHeadImgUrl(headimgurl);
491 weiXinBeanDefinition.setUnionId(unionid);
492
493 if (Objects.isNull(weiXinBeanDefinition.getAppId())) {
494 throw new RuntimeException("微信信息解析失败!");
495 }
496
497 // 链接微信服务器获取用户信息,创建UserWeixin
498 UserWeixin userWeixin = this.generateUserWeiXin(weiXinBeanDefinition,UNSUBSCRIBE_STATUS);
499
500 // 保存会员
501 Long memberId = this.doCreateMember(userWeixin,0);
502
503 // 保存或者修改,微信账户信息
504 UserWeixinDTO userWeixinDTO = this.doCreateUserWeiXin(userWeixin, memberId);
505
506 // 为了保证返回的同一用户
507 UserWeixinDTO userWeixinDTO_0 = this.getFirstId(userWeixinDTO);
508 return userWeixinDTO_0;
509 }
510
511 /**
512 *
513 * @param userWeixinDTO
514 * @param vip
515 * @return
516 */
517 private Long doCreateMember(UserWeixinDTO userWeixinDTO,Integer vip) {
518 UserWeixin userWeixin = new UserWeixin();
519 BeanUtils.copyProperties(userWeixinDTO,userWeixin);
520 Long memberId = this.doCreateMember(userWeixin, vip);
521 return memberId;
522 }
523
524 /**
525 *
526 * @param userWeixin
527 * @param vip
528 * @return
529 */
530 private Member doCreateMemberAndReturnMember(UserWeixin userWeixin,Integer vip) {
531 Member memberReturn = null;
532
533 if(Objects.nonNull(userWeixin)) {
534
535 String unionid = userWeixin.getUnionid();
536
537 // 新创建的小屏账户
538 if(Objects.nonNull(unionid)) {
539
540 // 查询第一个账户是否关联了会员
541 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionid);
542
543 // 无账号,没有绑定会员
544 if (Objects.isNull(userWeixinDTO.getMemberId())) {
545 // 默认会员
546 Member member = MemberBuilder.build(LocalConstants.DEVICE_MOBILE,userWeixin.getHeadimgurl(),
547 userWeixin.getNickname(),vip);
548
549 memberReturn = this.memberService.createAndReturnMember(member);
550
551 }
552
553 // 如果绑定了会员
554 if (Objects.nonNull(userWeixinDTO.getMemberId())) {
555 Long memberId = userWeixinDTO.getMemberId();
556 MemberDTO memberDTO = this.findMemberById(memberId);
557 memberReturn = new Member();
558 BeanUtils.copyProperties(memberDTO,memberReturn);
559 }
560
561 }
562
563 }
564
565 return memberReturn;
566 }
567
568 /**
569 * 创建会员
570 * @description 同一用户只有一个会员,通过unionId查询任意账户是否关联了会员,如果关联了就不用再创建
571 * @param userWeixin
572 * @param vip
573 * @return
574 */
575 private Long doCreateMember(UserWeixin userWeixin,Integer vip) {
576
577 Long memberId = null;
578
579 if(Objects.nonNull(userWeixin)) {
580
581 String unionid = userWeixin.getUnionid();
582
583 // 新创建的小屏账户
584 if(Objects.nonNull(unionid)) {
585
586 // 查询第一个账户是否关联了会员
587 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionid);
588
589 // 无账号,没有绑定会员
590 if (Objects.isNull(userWeixinDTO.getMemberId())) {
591 // 默认会员
592 Member member = MemberBuilder.build(LocalConstants.DEVICE_MOBILE,userWeixin.getHeadimgurl(),
593 userWeixin.getNickname(),vip);
594
595 memberId = this.memberService.create(member);
596
597 }
598
599 // 如果绑定了会员
600 if (Objects.nonNull(userWeixinDTO.getMemberId())) {
601 memberId = userWeixinDTO.getMemberId();
602 }
603
604 }
605
606 }
607
608 return memberId;
609 }
610
611 private UserWeixinDTO doCreateUserWeiXin(UserWeixinDTO userWeixin,Long memberId) {
612 if (Objects.isNull(memberId))
613 throw new NullPointerException("memberId is null !");
614
615 UserWeixin userWeixin1 = new UserWeixin();
616 BeanUtils.copyProperties(userWeixin,userWeixin1);
617 UserWeixinDTO userWeixinDTO = this.doCreateUserWeiXin(userWeixin1, memberId);
618 return userWeixinDTO;
619 }
620
621
622 private UserWeixinDTO doCreateUserWeiXin(UserWeixin userWeixin,Member member) {
623 Long memberId = member.getId();
624 String code = member.getCode();
625 UserWeixinDTO userWeixinDTO = new UserWeixinDTO();
626 if(Objects.isNull(userWeixin.getId()) && Objects.nonNull(memberId)) {
627 userWeixin.setMemberId(memberId);
628 userWeixin.setStatus(SUBSCRIBE_STATUS);
629 userWeixin.setSyncStatus(0);
630 userWeixin.setCreateBy("system");
631 userWeixin.setUpdateBy("system");
632 userWeixin.setAuthTime(TimestampUtil.now());
633 userWeixin.setMemberCode(code);
634 userWeixin = this.userWeixinService.create(userWeixin);
635 }
636
637 BeanUtils.copyProperties(userWeixin,userWeixinDTO);
638 return userWeixinDTO;
639 }
640
641 /**
642 * 保存微信账户信息
643 * @param userWeixin
644 * @param memberId
645 */
646 private UserWeixinDTO doCreateUserWeiXin(UserWeixin userWeixin,Long memberId) {
647
648 MemberDTO memberDTO = this.findMemberById(memberId);
649
650 UserWeixinDTO userWeixinDTO = new UserWeixinDTO();
651 if(Objects.isNull(userWeixin.getId()) && Objects.nonNull(memberId)) {
652 userWeixin.setMemberId(memberId);
653 userWeixin.setStatus(SUBSCRIBE_STATUS);
654 userWeixin.setSyncStatus(0);
655 userWeixin.setCreateBy("system");
656 userWeixin.setUpdateBy("system");
657 userWeixin.setAuthTime(TimestampUtil.now());
658 userWeixin.setMemberCode(memberDTO.getCode());
659 userWeixin = this.userWeixinService.create(userWeixin);
660
661 }
662
663 // 避免账户存在但会员不存在的情况
664 if(Objects.nonNull(userWeixin.getId()) && Objects.isNull(userWeixin.getMemberId()) && Objects.nonNull(userWeixin.getUnionid())) {
665
666 userWeixin.setMemberId(memberId);
667 this.userWeixinService.update(userWeixin);
668 }
669
670 BeanUtils.copyProperties(userWeixin,userWeixinDTO);
671 return userWeixinDTO;
672 }
673
674 /**
675 * 链接微信服务器,创建或者修改UserWeiXinDTO
676 * @param weiXinBeanDefinition
677 * @return
678 */
679 private UserWeixin generateUserWeiXin(WeiXinBeanDefinition weiXinBeanDefinition,Integer status) {
680
681 String appId = weiXinBeanDefinition.getAppId();
682 String openId = weiXinBeanDefinition.getOpenId();
683 String unionId = weiXinBeanDefinition.getUnionId();
684 String nickname = weiXinBeanDefinition.getNickname();
685 String headImgUrl = weiXinBeanDefinition.getHeadImgUrl();
686
687 // 微信
688 UserWeixinDTO weixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId,openId);
689
690 if (Objects.isNull(weixinDTO.getId())) {
691
692 UserWeixin userWeixin = new UserWeixin()
693 .setAppid(appId)
694 .setOpenid(openId)
695 .setUnionid(unionId)
696 .setNickname(nickname)
697 .setHeadimgurl(headImgUrl)
698 .setStatus(status)
699 .setAuthTime(TimestampUtil.now());
700
701 return userWeixin;
702
703 }
704
705 UserWeixin userWeixin = new UserWeixin();
706 BeanUtils.copyProperties(weixinDTO,userWeixin);
707
708 return userWeixin;
709
710 }
711
712 /**
713 * 解析小程序
714 * @param resources
715 * @return
716 */
717 private DefaultWeiXinBeanDefinition parseAppletInfo(WeiXinUserBean resources) {
718 return this.parse(resources);
719 }
720
721 /**
722 * 解析微信信息
723 * @param resources
724 * @return
725 */
726 private DefaultWeiXinBeanDefinition parse(WeiXinUserBean resources) {
727 Map<String, String> weixinInfoMap = null;
728 String appId = resources.getWxAppid();
729 String code = resources.getWxCode();
730 String encryptedData = resources.getEncryptedData();
731 String iv = resources.getIv();
732 String userInfo = null;
733
734 if (StringUtils.isNotBlank(appId)) {
735 String decrypt = AESUtil.decrypt(appId, this.key);
736 if (decrypt != null) {
737 appId = decrypt.substring(16);
738 }
739 weixinInfoMap = this.getWeixinInfoByAppid(appId);
740 }
741
742 if (StringUtils.isNotBlank(code)) {
743 String decrypt = AESUtil.decrypt(code, this.key);
744 if (decrypt != null) {
745 code = decrypt.substring(16);
746 }
747 }
748
749 String appId_ = weixinInfoMap.get("appid");
750 String secret = weixinInfoMap.get("secret");
751
752 // 链接微信服务器
753 String url = WeChatConstants.CODE2SESSION.replace("APPID", appId_)
754 .replace("SECRET", secret).replace("JSCODE", code);
755
756 String entityBody = HttpUtil.get(url);
757 log.info("entityBody [{}]",entityBody);
758
759 JSONObject jsonObject = JSONObject.parseObject(entityBody);
760
761 String errCode = jsonObject.getString("errcode");
762
763 if (StringUtils.isNotEmpty(errCode)) {
764 String nameStr = jsonObject.getString("errmsg");
765 throw new BadRequestException(nameStr);
766 }
767
768 String openId = jsonObject.getString("openid");
769 String unionId = jsonObject.getString("unionid");
770 String sessionKey = jsonObject.getString("session_key");
771
772 JSONObject userInfoWxJo = null;
773
774 if (StringUtils.isNotBlank(encryptedData) && StringUtils.isNotBlank(iv) && StringUtils.isNotBlank(sessionKey)) {
775
776 String userInfoWeixin = AESUtil.decryptJsUserInfo(encryptedData, iv, sessionKey);
777 log.info("userInfoWeixin [{}]",userInfoWeixin);
778
779 if (StringUtils.isNotEmpty(userInfoWeixin))
780 userInfoWxJo = JSONObject.parseObject(userInfoWeixin);
781
782 }
783
784 String phoneNumber = "";
785 if (StringUtils.isNotBlank(encryptedData)) {
786
787 JSONObject userInfoJo = JSONObject.parseObject(userInfo);
788 if (Objects.nonNull(userInfoJo)) {
789 encryptedData = userInfoJo.getString("encryptedData");
790 iv = userInfoJo.getString("iv");
791 String sessionkey = jsonObject.getString("session_key");
792 JSONObject userInfoPhone = AESUtil.decryptJsUserPhone(encryptedData, iv, sessionkey);
793 if (ObjectUtil.isNull(userInfoPhone)) {
794 throw new BadRequestException("decrypt phone error...");
795 }
796
797 phoneNumber = userInfoPhone.getString("phoneNumber");
798 if (StringUtils.isBlank(phoneNumber)) {
799 throw new BadRequestException("phoneNumber is null...");
800 }
801
802 }
803 }
804
805 DefaultWeiXinBeanDefinition weiXinBeanDefinition =
806 new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo,phoneNumber);
807
808 return weiXinBeanDefinition;
809 }
810
811 /**
812 *
813 * @param appid
814 * @return
815 */
816 private Map<String, String> getWeixinInfoByAppid(String appid) {
817 if (StringUtils.isBlank(appid)) {
818 throw new RuntimeException("wxAppid can not be null");
819 }
820 List<Map<String, String>> list = this.weiXinAppListConfig.getList();
821 Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
822 if (!weixinInfoOptional.isPresent()) {
823 throw new RuntimeException("wxAppid error, appid is : " + appid);
824 }
825 return weixinInfoOptional.get();
826 }
827
828 /**
829 * 大屏更换主账号
830 * @param resources
831 */
832 @Override
833 public void changeMainAccount(UserTv resources) {
834
835 // 会员编码
836 String memberCode = resources.getMemberCode();
837
838 UserTvDTO userTvDTO_0 = this.findByPriorityMemberCode(memberCode);
839
840 if (Objects.nonNull(userTvDTO_0)) {
841
842 if (userTvDTO_0.getPriorityMemberCode().equalsIgnoreCase(memberCode))
843 throw new BadRequestException("会员已是主账户");
844
845 throw new BadRequestException("该会员已绑定其他账户");
846 }
847
848 // 大屏账户
849 UserTvDTO userTvDTO = this.findByUserTv(resources);
850
851 // 会员
852 MemberDTO memberDTO = this.findMemberByMemberCode(memberCode);
853
854 // 设置主会员
855 this.bondPriorityMember(userTvDTO, memberDTO,"manual");
856
857 }
858
859 @Override
860 public void changeMainAccountByUnionId(UserTv userTv, String unionId) {
861 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionId);
862 Long memberId = userWeixinDTO.getMemberId();
863 MemberDTO memberDTO = this.findMemberById(memberId);
864 String code = memberDTO.getCode();
865 userTv.setMemberCode(code);
866 this.changeMainAccount(userTv);
867 }
868
869 /**
870 *
871 * @param memberCode
872 * @return
873 */
874 private UserTvDTO findByPriorityMemberCode(String memberCode) {
875 UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode);
876 return userTvDTO;
877 }
878
879 /**
880 * 设置主会员
881 * @description 检查大屏账户有没有绑定小屏会员,如果没有绑定就将当前会员的code保存到大屏账户中
882 * @param userTvDTO
883 * @param memberDTO
884 * @param auto manual:手动 auto:自动
885 */
886 private void bondPriorityMember(UserTvDTO userTvDTO, MemberDTO memberDTO,String auto) {
887
888 if (auto.equalsIgnoreCase("auto")) {
889 // 主账户
890 String priorityMemberCode = userTvDTO.getPriorityMemberCode();
891 if (StringUtils.isNotEmpty(priorityMemberCode)) {
892 return;
893 }
894 }
895
896 String memberCode = memberDTO.getCode();
897
898 // 绑定了小屏,结束
899 if (StringUtils.isNotEmpty(memberCode)) {
900 userTvDTO.setPriorityMemberCode(memberCode);
901 }
902
903 UserTv userTv = new UserTv();
904 BeanUtils.copyProperties(userTvDTO,userTv);
905 this.userTvService.update(userTv);
906
907 }
908
909 /**
910 * 通过编码获取会员
911 * @param memberCode
912 * @return
913 */
914 private MemberDTO findMemberByMemberCode(String memberCode) {
915 return this.memberService.getByCode(memberCode);
916 }
917
918 /**
919 * 大屏解绑
920 * @param resources
921 */
922 @Override
923 public void unbind(UserTv resources) {
924 // 大屏账户
925 UserTvDTO userTvDTO = this.findByUserTv(resources);
926
927 Long id = userTvDTO.getId();
928
929 String memberCode = resources.getMemberCode();
930
931 // 大屏会员
932 List<MemberDTO> memberDTOS = this.findMemberByCodeAndUserIptvId(id,memberCode);
933
934 // 解绑(置空大屏信息)
935 this.resetIptvColumn(memberDTOS);
936
937 // 置空主账号
938 this.resetMainAccount(memberCode);
939 }
940
941 @Override
942 public void unbindByUnionId(UserTv userTv, String unionId) {
943 UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionId);
944 Long memberId = userWeixinDTO.getMemberId();
945 MemberDTO memberDTO = this.findMemberById(memberId);
946 String code = memberDTO.getCode();
947 userTv.setMemberCode(code);
948 this.unbind(userTv);
949 }
950
951 /**
952 * 置空主账号
953 * @param memberCode
954 */
955 private void resetMainAccount(String memberCode) {
956 UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode);
957 if (Objects.nonNull(userTvDTO)) {
958 userTvDTO.setPriorityMemberCode(null);
959
960 UserTv userTv = new UserTv();
961 BeanUtils.copyProperties(userTvDTO,userTv);
962
963 this.userTvService.unbindPriorityMemberCode(userTv);
964 }
965 }
966
967 /**
968 * 解绑(置空大屏信息)
969 * @param memberDTOS
970 */
971 private void resetIptvColumn(List<MemberDTO> memberDTOS) {
972 // 若无关系,不做处理
973 if (CollUtil.isEmpty(memberDTOS))
974 return;
975
976
977 Member member = new Member();
978 memberDTOS.get(0).setBindIptvTime(null);
979 memberDTOS.get(0).setUserIptvId(null);
980 memberDTOS.get(0).setBindIptvPlatformType(null);
981 BeanUtils.copyProperties(memberDTOS.get(0), member);
982
983 this.memberService.unbind(member);
984 }
985
986 /**
987 *
988 * @param tvUserId 大屏ic
989 * @param memberCode 会员编码
990 * @return
991 */
992 private List<MemberDTO> findMemberByCodeAndUserIptvId(Long tvUserId,String memberCode) {
993 MemberQueryCriteria memberQueryCriteria = new MemberQueryCriteria();
994 memberQueryCriteria.setCode(memberCode);
995 memberQueryCriteria.setUserIptvId(tvUserId);
996 List<MemberDTO> memberDTOS = memberService.queryAll(memberQueryCriteria);
997 return memberDTOS;
998 }
999
1000 /**
1001 * 通过大屏账户查询大屏信息
1002 * @param resources
1003 * @return
1004 */
1005 private UserTvDTO findByUserTv(UserTv resources) {
1006 String platformAccount = resources.getPlatformAccount();
1007 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
1008 return userTvDTO;
1009 }
1010
1011 /**
1012 * 创建大屏会员
1013 * @param resources
1014 * @return
1015 */
1016 @Override
1017 @Transactional
1018 public boolean createMemberByUserTv(UserTv resources) {
1019 String platformAccount = resources.getPlatformAccount();
1020 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
1021
1022 if (Objects.isNull(userTvDTO)) {
1023
1024 Member member = new Member();
1025 // 大屏
1026 member.setType(LocalConstants.MEMBER_PLATFORM_TYPE_VIS);
1027 String code = member.getCode();
1028 member.setCode(StringUtils.isEmpty(code)?String.valueOf(IdWorker.generator()):code);
1029 member.setNickname(platformAccount);
1030 member.setType(1);
1031 Long memberId = this.memberService.create(member);
1032
1033 UserTv userTv = new UserTv();
1034
1035 if (Objects.nonNull(memberId)) {
1036
1037 BeanUtils.copyProperties(resources,userTv);
1038 userTv.setPlatformAccount(platformAccount);
1039 userTv.setMemberCode(member.getCode());
1040 userTv.setNickname(platformAccount);
1041 userTv.setUsername(platformAccount);
1042 userTv.setLoginDays(1);
1043 userTv.setStatus(1);
1044 userTv.setActiveTime(TimestampUtil.now());
1045 userTv.setContinueDays(1);
1046 userTv.setCreateBy("system");
1047 userTv.setUpdateBy("system");
1048 this.userTvService.create(userTv);
1049 return true;
1050 }
1051
1052 return false;
1053
1054 } else {
1055
1056 UserTv userTv = new UserTv();
1057 BeanUtils.copyProperties(userTvDTO,userTv);
1058 return true;
1059
1060 }
1061
1062 }
1063
1064 /**
1065 * 绑定会员中的userIptvId字段
1066 * @param memberDTO
1067 * @param userTvDTO
1068 */
1069 private MemberDTO bindIptvId(MemberDTO memberDTO,UserTvDTO userTvDTO) {
1070 String platform = userTvDTO.getPlatform();
1071 // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通
1072 Integer bindIptvPlatformType = 0;
1073
1074 // 联通
1075 if (UserConstant.platform_lt.contains(platform)) {
1076 bindIptvPlatformType = PLATFORM_LIST[3];
1077 }
1078
1079 // 移动
1080 if (UserConstant.platform_yd.contains(platform)) {
1081 bindIptvPlatformType = PLATFORM_LIST[2];
1082 }
1083
1084 // 电信
1085 if (UserConstant.platform_dx.contains(platform)) {
1086 bindIptvPlatformType = PLATFORM_LIST[1];
1087 }
1088
1089 memberDTO.setUserIptvId(userTvDTO.getId());
1090 memberDTO.setBindIptvTime(LocalDateTime.now());
1091 memberDTO.setBindIptvPlatformType(bindIptvPlatformType);
1092
1093 return memberDTO;
1094 }
1095
1096 /**
1097 * 修改会员
1098 * @param memberDTO
1099 */
1100 private void doUpdateMemberByMemberDTO(MemberDTO memberDTO){
1101 Member member = new Member();
1102 BeanUtils.copyProperties(memberDTO,member);
1103 member.setUpdateTime(LocalDateTime.now());
1104 log.info("doUpdateMemberByMemberDTO=====?>>member ==>> [{}]",member);
1105 this.doUpdateMember(member);
1106 }
1107
1108 /**
1109 * 修改会员
1110 * @param member
1111 */
1112 private void doUpdateMember(Member member){
1113 this.memberService.update(member);
1114 }
1115
1116 /**
1117 * 解析微信信息
1118 * @param resources
1119 * @return
1120 */
1121 @Override
1122 public MemberProfile saveUserWeixinPhone(WeiXinUserBean resources) {
1123 DefaultWeiXinBeanDefinition weiXinBeanDefinition = this.parseAppletInfo(resources);
1124
1125 if (Objects.nonNull(weiXinBeanDefinition.getOpenId())) {
1126 throw new RuntimeException("微信信息解析失败!");
1127 }
1128
1129 // 保存、修改会员加密信息
1130 return this.doSaveOrUpdateMemberProfile(weiXinBeanDefinition,resources);
1131
1132 }
1133
1134 @Override
1135 public boolean sendQrCodeMessage(String content) {
1136 try {
1137 log.info("receive get qrCode message, content {}", content);
1138 JSONObject jsonObject = JSONObject.parseObject(content);
1139 String appid = jsonObject.getString("appid");
1140 String IPTVappid = jsonObject.getString("IPTVappid");
1141 String platformAccount = jsonObject.getString("platformAccount");
1142 String sessionId = jsonObject.getString("sessionId");
1143 String key = QR_CODE_URL + appid + "_" + platformAccount + "_" + sessionId;
1144 String url = (String) this.redisUtils.get(key);
1145 if (StringUtils.isBlank(url)) {
1146 Map<String, String> wxInfo = WeixinUtil.getWeixinInfoByAppid(appid);
1147 String appType = wxInfo.get("appType");
1148 // 订阅号不支持带参二维码,直接返回
1149 if (StrUtil.isNotEmpty(appType) && ObjectUtil.equals(appType, WeChatConstants.WX_SUBSCRIPTION)) {
1150 log.error("订阅号不支持带参二维码 || {} || {}", appid, content);
1151 return false;
1152 }
1153 QrCode qrCode = new QrCode();
1154 qrCode.setActionName(WeChatConstants.QR_STR_SCENE);
1155 if (StringUtils.isNotBlank(wxInfo.get("qrCodeExpireSeconds"))) {
1156 qrCode.setExpireSeconds(Integer.valueOf(wxInfo.get("qrCodeExpireSeconds")));
1157 }
1158 ActionInfo actionInfo = new ActionInfo();
1159 Scene scene = new Scene();
1160 scene.setSceneStr(content);
1161 actionInfo.setScene(scene);
1162 qrCode.setActionInfo(actionInfo);
1163 JSONObject jsonQrCode = this.weixinRequestUtil.getQrCode(wxInfo, qrCode);
1164 url = jsonQrCode.getString("url");
1165 Integer expireSeconds = jsonQrCode.getInteger("expire_seconds");
1166 this.redisUtils.set(key, url, expireSeconds, TimeUnit.SECONDS);
1167 }
1168 } catch (Exception e) {
1169 log.error("GetQrCodeConsumer || get qrCode error || {}", e.toString(), e);
1170 }
1171 return true;
1172 }
1173
1174 @Override
1175 @AsyncMqSend
1176 public boolean deleteAllCollection(String content) {
1177 try {
1178
1179 JSONObject jsonObject = JSONObject.parseObject(content);
1180 String platformAccount = jsonObject.getString("platformAccount");
1181 Integer type = jsonObject.getInteger("collectionType");
1182 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
1183
1184 Long id = userTvDTO.getId();
1185 List<UserCollection> userCollections = this.userCollectionService.findByUserIdAndType(id, type);
1186
1187 if (userCollections == null || userCollections.isEmpty()) {
1188 return false;
1189 }
1190
1191 for (UserCollection userCollection : userCollections) {
1192 this.userCollectionDetailService.deleteAllByUserCollectionId(userCollection.getId());
1193 }
1194
1195 } catch (Exception e) {
1196 log.error("CollectionDeleteConsumer || UserCollection delete all error || {}", e.toString(), e);
1197 }
1198 return true;
1199 }
1200
1201 @Override
1202 @AsyncMqSend
1203 public boolean deleteCollection(String content) {
1204 try {
1205
1206 log.info("receive UserCollection delete message, content [{}]", content);
1207
1208 JSONObject jsonObject = JSONObject.parseObject(content);
1209 String platformAccount = jsonObject.getString("platformAccount");
1210 String data = jsonObject.getString("data");
1211 if (StringUtils.isBlank(data) || !data.startsWith("[")) {
1212 return false;
1213 }
1214
1215 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
1216
1217 Long id = userTvDTO.getId();
1218
1219 List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class);
1220 if (userCollectionMqList == null || userCollectionMqList.isEmpty()) {
1221 return false;
1222 }
1223 Map<Long, List<UserCollectionMq>> collect = userCollectionMqList.stream()
1224 .collect(Collectors.groupingBy(UserCollectionMq::getUserCollectionId));
1225 for (Map.Entry<Long, List<UserCollectionMq>> entry : collect.entrySet()) {
1226 List<UserCollectionMq> value = entry.getValue();
1227 UserCollectionMq userCollectionMq = value.get(0);
1228
1229 if (StringUtils.isBlank(userCollectionMq.getName())) {
1230 userCollectionMq.setName("DEFAULT");
1231 }
1232
1233 Optional<UserCollection> userCollectionOptional =
1234 this.userCollectionService.findFirstByUserIdAndTypeAndName(id, userCollectionMq.getType(),
1235 userCollectionMq.getName());
1236 UserCollection userCollection = userCollectionOptional.orElseGet(UserCollection::new);
1237
1238 int count = 0;
1239 for (UserCollectionMq collectionMq : value) {
1240
1241 collectionMq.setUserCollectionId(userCollection.getId());
1242 List<UserCollectionDetail> userCollectionDetailOptional =
1243 this.userCollectionDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
1244 QueryHelp.getPredicate(root, collectionMq, criteriaBuilder));
1245 if (!userCollectionDetailOptional.isEmpty()) {
1246 this.userCollectionDetailService.deleteAll(userCollectionDetailOptional);
1247 count++;
1248 }
1249
1250 }
1251
1252 userCollection.setAppId(userCollectionMq.getAppId())
1253 .setUserId(id)
1254 .setName(userCollectionMq.getName())
1255 .setType(userCollectionMq.getType())
1256 .setCount(userCollection.getCount() - count);
1257 this.userCollectionService.save(userCollection);
1258 }
1259 } catch (Exception e) {
1260 log.error("CollectionDeleteConsumer || UserCollection delete error || {}", e.toString(), e);
1261 }
1262
1263 return true;
1264 }
1265
1266 @Override
1267 @AsyncMqSend
1268 public boolean addCollection(String content) {
1269 try {
1270 //处理接口调用 中文不显示问题
1271 content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8)));
1272
1273 log.info("receive UserCollection add message, content {}", content);
1274
1275 JSONObject jsonObject = JSONObject.parseObject(content);
1276 String platformAccount = jsonObject.getString("platformAccount");
1277 String data = jsonObject.getString("data");
1278
1279 if (StringUtils.isBlank(data) || !data.startsWith("["))
1280 return false;
1281
1282
1283 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
1284
1285 Long tvUserId = userTvDTO.getId();
1286 List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class);
1287
1288 if (userCollectionMqList == null || userCollectionMqList.isEmpty())
1289 return false;
1290
1291
1292 Map<Long, List<UserCollectionMq>> collect = userCollectionMqList.stream().collect(Collectors.groupingBy(UserCollectionMq::getUserCollectionId));
1293
1294 for (Map.Entry<Long, List<UserCollectionMq>> entry : collect.entrySet()) {
1295
1296 List<UserCollectionMq> value = entry.getValue();
1297 UserCollectionMq userCollectionMq = value.get(0);
1298 if (StringUtils.isBlank(userCollectionMq.getName()))
1299 userCollectionMq.setName("DEFAULT");
1300
1301
1302 UserCollection userCollection = this.userCollectionService
1303 .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()).orElseGet(UserCollection::new);
1304
1305 userCollection.setAppId(userCollectionMq.getAppId())
1306 .setUserId(tvUserId)
1307 .setName(userCollectionMq.getName())
1308 .setType(userCollectionMq.getType())
1309 .setCount(userCollection.getCount() == null ? value.size() : userCollection.getCount() + value.size());
1310 log.info("userCollection ==>> [{}]",userCollection);
1311 UserCollection userCollectionSave = this.userCollectionService.save(userCollection);
1312
1313 for (UserCollectionMq collectionMq : value) {
1314
1315 UserCollectionDetail userCollectionDetail = collectionMq2DetailMapper.toEntity(collectionMq);
1316 Optional<UserCollectionDetail> userCollectionDetailOptional = userCollectionDetailRepository
1317 .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), userCollectionDetail.getDetailType(), userCollectionSave.getId());
1318 //观影记录同一天只存一条记录
1319 if (userCollectionDetailOptional.isPresent() &&
1320 DateUtil.isSameDay(new Date(userCollectionDetailOptional.get().getCreateTime().getTime()), new Date())) {
1321
1322 userCollectionDetail.setId(userCollectionDetailOptional.get().getId());
1323
1324 } else {
1325
1326 userCollectionDetail.setId(null)
1327 .setUserCollectionId(userCollectionSave.getId());
1328
1329 }
1330
1331 userCollectionDetailRepository.save(userCollectionDetail);
1332
1333 }
1334 }
1335
1336 } catch (Exception e) {
1337 log.error("CollectionAddConsumer || UserCollection add error || {}", e.toString(), e);
1338 }
1339 return true;
1340 }
1341
1342 @Override
1343 public List<MemberDTO> findBindByPlatformAccount(String platformAccount) {
1344
1345 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
1346
1347 if (Objects.nonNull(userTvDTO.getId())) {
1348
1349 Long id = userTvDTO.getId();
1350 String priorityMemberCode = userTvDTO.getPriorityMemberCode();
1351 List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id);
1352
1353 if (!CollectionUtils.isEmpty(memberDTOList)) {
1354
1355 for (MemberDTO memberDTO : memberDTOList) {
1356
1357 String code = memberDTO.getCode();
1358 if (code.equalsIgnoreCase(priorityMemberCode)) {
1359 memberDTO.setIptvMajor(IPTV_MAJOR[1]);
1360 } else {
1361 memberDTO.setIptvMajor(IPTV_MAJOR[0]);
1362 }
1363
1364 }
1365
1366 }
1367
1368 return memberDTOList;
1369
1370 }
1371
1372 return null;
1373 }
1374
1375 @Override
1376 public Object serviceLogin(WeiXinUserBean resources) {
1377 String unionId = resources.getUnionid();
1378 String appId = resources.getAppid();
1379 String openId = resources.getOpenid();
1380
1381 // if (org.apache.commons.lang3.StringUtils.isBlank(unionId)) {
1382
1383 // TODO 需要商量是否需要创建微信账户
1384 /*UserWeixinDTO userWeixinDTO = this.findUserWeiXinByOpenIdAndAppId(appId, openId);
1385 if (ObjectUtil.isNotEmpty(userWeixinDTO))
1386 return userWeixinDTO;*/
1387
1388 // }
1389
1390 // 小屏账户
1391 UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId);
1392
1393 if (Objects.isNull(userWeixinDTO.getId())) {
1394
1395 DefaultWeiXinBeanDefinition weiXinBeanDefinition = new DefaultWeiXinBeanDefinition();
1396 weiXinBeanDefinition.setUnionId(unionId);
1397 weiXinBeanDefinition.setAppid(appId);
1398 weiXinBeanDefinition.setOpenId(openId);
1399
1400 // 创建会员和账户
1401 this.doCreateUserWeiXinAndMember(weiXinBeanDefinition);
1402
1403 } else {
1404
1405 // 修改账户和会员信息
1406 this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId,"","");
1407
1408 }
1409
1410 // 为了保证返回的同一用户
1411 UserWeixinDTO userWeixinDTO_0 = this.getFirstId(userWeixinDTO);
1412 return userWeixinDTO_0;
1413 }
1414
1415 @Override
1416 public boolean appletBind(BindBean resources) {
1417
1418 Long id = resources.getId();
1419 Long platformUserId = resources.getPlatformUserId();
1420 String unionid = resources.getUnionid();
1421 String platformAccount = resources.getPlatformAccount();
1422
1423 // 大屏账户
1424 UserTvDTO userTvDTO = this.findUserIptvById(platformUserId);
1425
1426 // 账户是否存在
1427 if (Objects.isNull(userTvDTO.getId())){
1428 log.error("Param ==> platformUserId ==> [{}]",platformUserId);
1429 throw new EntityNotFoundException(UserTvDTO.class,"id","大屏账户不存在!");
1430 }
1431
1432 UserWeixinDTO userWeixinDTO = null;
1433 // 微信账户
1434 if (Objects.nonNull(id)) {
1435 userWeixinDTO = this.userWeixinService.findById(id);
1436 } else {
1437 userWeixinDTO = this.findFirstByUnionId(unionid);
1438 }
1439
1440 // 账户是否存在
1441 if (Objects.isNull(userWeixinDTO.getId())) {
1442 log.error("param ==> id ==> [{}]",id);
1443 throw new EntityNotFoundException(UserWeixinDTO.class, "id", userWeixinDTO.getId().toString());
1444 }
1445
1446 // 会员
1447 Long memberId = userWeixinDTO.getMemberId();
1448 if (Objects.isNull(memberId)) {
1449 log.error("param ==> memberId ==> [{}]",id);
1450 throw new EntityNotFoundException(UserWeixinDTO.class, "id", id.toString());
1451 }
1452
1453 MemberDTO memberDTO = this.findMemberById(memberId);
1454 if (Objects.isNull(memberId)) {
1455 log.error("param ==> memberId ==> [{}]",id);
1456 throw new EntityNotFoundException(MemberDTO.class, "id", memberId.toString());
1457 }
1458
1459 // 主账户
1460 String priorityMemberCode = userTvDTO.getPriorityMemberCode();
1461
1462 if (StringUtils.isBlank(priorityMemberCode)) {
1463 // 主账户会员
1464 String code = memberDTO.getCode();
1465 userTvDTO.setPriorityMemberCode(code);
1466 }
1467
1468 // 更新小屏账户更新时间,epg需要根据修改时间来让绑定的二维码消失
1469 this.doUpdateUserWeiXinUpdateTime(userWeixinDTO);
1470
1471
1472 // 更新大屏信息
1473 userTvDTO.setMemberCode(memberDTO.getCode());
1474 this.doUpdateUserTv(userTvDTO);
1475
1476
1477 memberDTO.setPlatformAccount(platformAccount);
1478 // 会员绑定大屏
1479 this.bindIptvId(memberDTO,userTvDTO);
1480
1481 this.doUpdateMemberByMemberDTO(memberDTO);
1482 return true;
1483 }
1484
1485 /**
1486 * 更新微信用户修改的时间
1487 * @param userWeixinDTO
1488 */
1489 private void doUpdateUserWeiXinUpdateTime(UserWeixinDTO userWeixinDTO) {
1490 UserWeixin userWeixin = new UserWeixin();
1491 userWeixin.setAppid(userWeixinDTO.getAppid());
1492 userWeixin.setOpenid(userWeixinDTO.getOpenid());
1493 userWeixin.setUpdateTime(TimestampUtil.now());
1494 this.userWeixinService.updateTime(userWeixin);
1495 }
1496
1497 @Override
1498 public JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code) {
1499 // 链接微信服务器
1500 String url = WeChatConstants.CODE2SESSION.replace("APPID", appId)
1501 .replace("SECRET", secret).replace("JSCODE", code);
1502
1503 String entityBody = HttpUtil.get(url);
1504
1505 JSONObject jsonObject = JSONObject.parseObject(entityBody);
1506
1507 String errCode = jsonObject.getString("errcode");
1508
1509 if (StringUtils.isNotEmpty(errCode)) {
1510 String nameStr = jsonObject.getString("errmsg");
1511 throw new BadRequestException(nameStr);
1512 }
1513
1514 return jsonObject;
1515 }
1516
1517 @Override
1518 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
1519 public UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources) {
1520
1521 String appId = resources.getAppid();
1522 String openId = resources.getOpenid();
1523 String unionId = resources.getUnionid();
1524
1525 // 检查账户是否存在
1526 UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId);
1527 if (Objects.nonNull(userWeixinDTO.getId()))
1528 return userWeixinDTO;
1529
1530 // 当前用户的任意微信app
1531 UserWeixinDTO userWeixinDTO1 = this.findFirstByUnionId(unionId);
1532
1533 Long memberId = null;
1534 Integer vip = 0;
1535 if (Objects.nonNull(userWeixinDTO1.getId()) && Objects.nonNull(userWeixinDTO1.getMemberId())) {
1536
1537 memberId = userWeixinDTO1.getMemberId();
1538
1539 } else {
1540
1541 userWeixinDTO1 = new UserWeixinDTO();
1542 BeanUtils.copyProperties(resources,userWeixinDTO1);
1543
1544 // 创建会员
1545 memberId = this.doCreateMember(userWeixinDTO1,vip);
1546
1547 }
1548
1549 userWeixinDTO1.setId(null);
1550 userWeixinDTO1.setAppid(appId);
1551 userWeixinDTO1.setOpenid(openId);
1552 userWeixinDTO1.setUnionid(unionId);
1553 log.info("createWeixinUserAndCreateMember ==>> [{}]",userWeixinDTO1);
1554 // 保存微信账户
1555 userWeixinDTO1 = this.doCreateUserWeiXin(userWeixinDTO1,memberId);
1556
1557 log.info("userWeixinDTO1 ==>> [{}]",userWeixinDTO1);
1558
1559 MemberProfileDTO memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
1560 if (Objects.isNull(memberProfileDTO))
1561 // 创建会员属性信息
1562 this.createMemberProfile(userWeixinDTO1);
1563
1564 return userWeixinDTO1;
1565 }
1566
1567 @Override
1568 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
1569 public void bind(String memberCode, String platformAccount) {
1570 MemberDTO memberDTO = this.memberService.getByCode(memberCode);
1571 this.bind(memberDTO,platformAccount);
1572 }
1573
1574 @Override
1575 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
1576 public void bind(MemberDTO memberDTO, UserTvDTO userTvDTO) {
1577 String platformAccount = userTvDTO.getPlatformAccount();
1578 // 绑定
1579 this.bind(memberDTO,platformAccount);
1580 }
1581
1582 @Override
1583 public UserTvDTO bind(MemberDTO memberDTO, String platformAccount) {
1584
1585 MemberDTO memberDTO1 = this.memberService.getByCode(memberDTO.getCode());
1586 if (Objects.nonNull(memberDTO1.getUserIptvId())) {
1587 UserTvDTO userTvDTO = this.userTvService.findById(memberDTO1.getUserIptvId());
1588 return userTvDTO;
1589 }
1590
1591 // 大屏账户
1592 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
1593 if (Objects.isNull(userTvDTO)) {
1594 throw new BadRequestException("大屏信息不存在!");
1595 }
1596
1597 // mq同步数据时使用
1598 memberDTO.setPlatformAccount(platformAccount);
1599
1600 // 大屏是否绑定主账号,如果绑定了主账户则不操作大屏账户表
1601 this.bondPriorityMember(userTvDTO,memberDTO,"auto");
1602
1603 // 构建小屏会员对象,绑定user_iptv_id字段
1604 MemberDTO memberDTO0 = this.bindIptvId(memberDTO,userTvDTO);
1605
1606 // 修改会员
1607 this.doUpdateMemberByMemberDTO(memberDTO0);
1608
1609 return null;
1610 }
1611
1612 /**
1613 *
1614 * @param userWeixinDTO1
1615 */
1616 private void createMemberProfile(UserWeixinDTO userWeixinDTO1) {
1617 Long memberId = userWeixinDTO1.getMemberId();
1618 String nickname = userWeixinDTO1.getNickname();
1619 Integer sex = userWeixinDTO1.getGender();
1620 MemberProfile memberProfile = MemberProfileBuild.build(memberId, nickname, sex, null);
1621 this.memberProfileService.create(memberProfile);
1622 }
1623
1624 private UserWeixinDTO findFirstByUnionId(String unionId) {
1625 return this.userWeixinService.findFirstByUnionId(unionId);
1626 }
1627
1628 /**
1629 * 通过id检索大屏信息
1630 * @param userIptvId
1631 * @return
1632 */
1633 private UserTvDTO findUserIptvById(Long userIptvId) {
1634 UserTvDTO userTvDTO = this.userTvService.findById(userIptvId);
1635 return userTvDTO;
1636 }
1637
1638 /**
1639 * 更新大屏
1640 * @param userTvDTO
1641 */
1642 private void doUpdateUserTv(UserTvDTO userTvDTO) {
1643 UserTv userTv = new UserTv();
1644 BeanUtils.copyProperties(userTvDTO,userTv);
1645 userTv.setUpdateTime(TimestampUtil.now());
1646 this.userTvService.update(userTv);
1647 }
1648
1649 /**
1650 * 同一用户有多个微信APP的情况下展示同一个账户信息
1651 * 原则:那个先创建就用那个id
1652 * @param userWeixinDTO
1653 */
1654 private UserWeixinDTO getFirstId(UserWeixinDTO userWeixinDTO) {
1655 String unionid = userWeixinDTO.getUnionid();
1656
1657 if (StringUtils.isNotBlank(unionid)) {
1658
1659 UserWeixinQueryCriteria criteria = new UserWeixinQueryCriteria();
1660 PageRequest pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.ASC, "createTime"));
1661 criteria.setUnionId(unionid);
1662
1663 List<UserWeixin> userWeixinList = this.userWeixinRepository.findAll((root, criteriaQuery, criteriaBuilder)
1664 -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable).getContent();
1665
1666 List<UserWeixin> h5AppIdList = userWeixinList.stream().filter(e -> ObjectUtil.equal(e.getAppid(), h5AppId)).collect(Collectors.toList());
1667 List<UserWeixin> appletAppIdList = userWeixinList.stream().filter(e -> ObjectUtil.equal(e.getAppid(), appletAppid)).collect(Collectors.toList());
1668
1669 //没创建h5账号 返回小程序id
1670 if (h5AppIdList.isEmpty()) {
1671 userWeixinDTO.setId(appletAppIdList.get(0).getId());
1672 userWeixinDTO.setAuthTime(appletAppIdList.get(0).getAuthTime());
1673 }
1674
1675 //没创建小程序账号 返回h5id
1676 if (appletAppIdList.isEmpty()) {
1677 userWeixinDTO.setId(h5AppIdList.get(0).getId());
1678 userWeixinDTO.setAuthTime(h5AppIdList.get(0).getAuthTime());
1679 }
1680
1681 //都创建 那个先创建 用那个
1682 if (!appletAppIdList.isEmpty() && !h5AppIdList.isEmpty()) {
1683 if (appletAppIdList.get(0).getCreateTime().before(h5AppIdList.get(0).getCreateTime())) {
1684 userWeixinDTO.setId(appletAppIdList.get(0).getId());
1685 userWeixinDTO.setAuthTime(appletAppIdList.get(0).getAuthTime());
1686 } else {
1687 userWeixinDTO.setId(h5AppIdList.get(0).getId());
1688 userWeixinDTO.setAuthTime(h5AppIdList.get(0).getAuthTime());
1689 }
1690 }
1691
1692 }
1693
1694 return userWeixinDTO;
1695 }
1696
1697 /**
1698 * 保存、修改会员加密信息
1699 * @param resources
1700 * @return
1701 */
1702 private MemberProfile doSaveOrUpdateMemberProfile(DefaultWeiXinBeanDefinition resources,WeiXinUserBean weiXinUserBean) {
1703
1704 // 会员
1705 MemberDTO memberDTO = this.findMemberById(weiXinUserBean.getMemberId());
1706
1707 if (Objects.nonNull(memberDTO)) {
1708
1709 Long memberId = memberDTO.getId();
1710
1711 // 会员加密信息
1712 MemberProfileDTO memberProfileDTO = this.findMemberProfileByMemberId(memberId);
1713
1714 MemberProfile memberProfile = new MemberProfile();
1715 if (Objects.nonNull(memberProfileDTO)) {
1716 BeanUtils.copyProperties(memberProfileDTO , memberProfile);
1717 }
1718
1719 memberProfile.setMemberId(memberId);
1720 memberProfile.setPhone(resources.getPhoneNumber());
1721
1722 // 保存、更新会员加密信息
1723 MemberProfile memberProfile1 = this.saveMemberProfile(memberProfile);
1724
1725 return memberProfile1;
1726
1727 }
1728
1729 return null;
1730
1731 }
1732
1733 private MemberProfileDTO findMemberProfileByMemberId(Long memberId) {
1734 MemberProfileDTO memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
1735 return memberProfileDTO;
1736 }
1737
1738 private MemberProfile saveMemberProfile(MemberProfile memberProfile) {
1739 return this.memberProfileService.create(memberProfile);
1740 }
1741
1742
1743
1744
1745
1746 }
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 }
1 package com.topdraw.business.process.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
5 import com.topdraw.business.process.domian.weixin.UserCollectionMq;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.Mapping;
8 import org.mapstruct.Mappings;
9 import org.mapstruct.ReportingPolicy;
10
11 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
12 public interface CollectionMq2DetailMapper extends BaseMapper<UserCollectionMq, UserCollectionDetail> {
13 @Override
14 @Mappings({
15 @Mapping(target = "detailImg", source = "images")
16 })
17 UserCollectionDetail toEntity(UserCollectionMq dto);
18 }
1 package com.topdraw.config;
2
3 import cn.hutool.core.util.StrUtil;
4
5 public class RedisKeyUtil {
6
7
8 /**
9 * @return java.lang.String
10 * @description 订阅号大屏扫码关注
11 * @author Hongyan Wang
12 * @date 2021/8/24 1:36 下午
13 */
14 public static String genSeSuSubscribeKey(String unionid) {
15 return StrUtil.format("BMSubscribe_unionid_{}", unionid);
16 }
17
18 }
1 package com.topdraw.config;
2
3 import lombok.Data;
4 import org.springframework.boot.context.properties.ConfigurationProperties;
5 import org.springframework.context.annotation.Configuration;
6
7 import java.util.List;
8 import java.util.Map;
9
10 @Configuration
11 @Data
12 @ConfigurationProperties(prefix = "weixin")
13 public class WeixinInfoConfig {
14
15 private List<Map<String, String>> list;
16 }
...@@ -19,7 +19,7 @@ public class MessageProducer { ...@@ -19,7 +19,7 @@ public class MessageProducer {
19 private AmqpTemplate amqpTemplate; 19 private AmqpTemplate amqpTemplate;
20 20
21 21
22 @Value("${service.platform}") 22 @Value("${uc.service.platform}")
23 private String platformType; 23 private String platformType;
24 24
25 public void sendMessage(String msg,String exchangeName){ 25 public void sendMessage(String msg,String exchangeName){
......
1 package com.topdraw.resttemplate; 1 package com.topdraw.resttemplate;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.business.basicdata.member.address.domain.MemberAddress; 4 import com.topdraw.business.module.member.address.domain.MemberAddress;
5 import com.topdraw.business.basicdata.member.domain.Member; 5 import com.topdraw.business.module.member.domain.Member;
6 import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; 6 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
7 import lombok.extern.slf4j.Slf4j; 7 import lombok.extern.slf4j.Slf4j;
8 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.core.env.Environment; 9 import org.springframework.core.env.Environment;
...@@ -17,7 +17,7 @@ import java.util.Map; ...@@ -17,7 +17,7 @@ import java.util.Map;
17 17
18 @Slf4j 18 @Slf4j
19 @Component 19 @Component
20 public class ApiUtil { 20 public class RestTemplateClient {
21 21
22 private static RestTemplate restTemplate; 22 private static RestTemplate restTemplate;
23 23
......
1 package com.topdraw.schedule; 1 package com.topdraw.schedule;
2 2
3 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
4 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
5 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
6 import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook;
7 import com.topdraw.business.basicdata.points.standingbook.service.PointsStandingBookService;
8 import com.topdraw.business.process.service.PointsOperationService; 3 import com.topdraw.business.process.service.PointsOperationService;
9 import com.topdraw.util.DateUtil;
10 import lombok.extern.slf4j.Slf4j;
11 import org.aspectj.lang.annotation.After;
12 import org.springframework.beans.factory.annotation.Autowired; 4 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.scheduling.annotation.EnableScheduling;
14 import org.springframework.scheduling.annotation.Scheduled;
15 import org.springframework.stereotype.Component;
16 import org.springframework.util.CollectionUtils;
17
18 import java.sql.Timestamp;
19 import java.time.LocalDate;
20 import java.util.List;
21 5
22 /** 6 /**
23 * 积分台账 7 * 积分台账
......
1 package com.topdraw.security;
2
3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.utils.StringUtils;
5 import lombok.extern.slf4j.Slf4j;
6 import org.bouncycastle.jce.provider.BouncyCastleProvider;
7
8 import javax.crypto.Cipher;
9 import javax.crypto.SecretKey;
10 import javax.crypto.spec.IvParameterSpec;
11 import javax.crypto.spec.SecretKeySpec;
12 import java.security.AlgorithmParameters;
13 import java.security.Key;
14 import java.security.Security;
15 import java.security.spec.AlgorithmParameterSpec;
16 import java.util.Arrays;
17
18 @Slf4j
19 public class AESUtil {
20
21 public static String encrypt(String data, String key) {
22 String strResult = null;
23 try {
24 SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
25 Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
26 AlgorithmParameterSpec aps = new IvParameterSpec("0123456789ABCDEF".getBytes("UTF-8"));
27 cipher.init(Cipher.ENCRYPT_MODE, secretKey, aps);
28 byte[] result = cipher.doFinal(data.getBytes("UTF-8"));
29 StringBuilder sb_hex = new StringBuilder();
30 for (byte b : result) {
31 sb_hex.append(String.format("%02x", b));
32 }
33 strResult = sb_hex.toString();
34 } catch (Exception e) {
35
36 }
37 return strResult;
38 }
39
40 public static String decrypt(String encryptedData, String key) {
41 String strResult = null;
42 try {
43 int len = encryptedData.length() / 2;
44 byte[] data = new byte[len];
45 for (int i = 0; i < len; i++) {
46 String str = encryptedData.substring(i * 2, i * 2 + 2);
47 data[i] = Integer.valueOf(str, 16).byteValue();
48 }
49 SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
50 Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
51 AlgorithmParameterSpec aps = new IvParameterSpec("0123456789ABCDEF".getBytes("UTF-8"));
52 cipher.init(Cipher.DECRYPT_MODE, secretKey, aps);
53 byte[] result = cipher.doFinal(data);
54 strResult = new String(result, "UTF-8");
55 } catch (Exception e) {
56
57 }
58 return strResult;
59 }
60
61 private static final String AES ="AES";
62 private static final String AES_CBC_PKCS7 ="AES/CBC/PKCS7Padding";
63 public static String decryptJsUserInfo(String encryptedData,String iv,String sessionKey) {
64 try {
65 byte[] data = java.util.Base64.getDecoder().decode(encryptedData);
66 byte[] aseKey = java.util.Base64.getDecoder().decode(sessionKey);
67 byte[] ivData = java.util.Base64.getDecoder().decode(iv);
68 Security.addProvider(new BouncyCastleProvider());
69 Cipher cipher = Cipher.getInstance(AES_CBC_PKCS7);
70
71 Key sKeySpec = new SecretKeySpec(aseKey, AES);
72 AlgorithmParameterSpec aps = new IvParameterSpec(ivData);
73 cipher.init(Cipher.DECRYPT_MODE, sKeySpec, aps);// 初始化
74 byte[] result = cipher.doFinal(data);
75 return new String(result);
76 } catch (Exception e) {
77 log.error("decryptJsUserInfo:"+ e);
78 return null;
79 }
80 }
81
82 public static JSONObject decryptJsUserPhone(String encryptedData, String iv, String key) {
83 byte[] dataByte = java.util.Base64.getDecoder().decode(encryptedData);
84 // 加密秘钥
85 byte[] keyByte = java.util.Base64.getDecoder().decode(key);
86 // 偏移量
87 byte[] ivByte = java.util.Base64.getDecoder().decode(iv);
88 try {
89 // 如果密钥不足16位,那么就补足. 这个if 中的内容很重要
90 int base = 16;
91 if (keyByte.length % base != 0) {
92 int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0);
93 byte[] temp = new byte[groups * base];
94 Arrays.fill(temp, (byte) 0);
95 System.arraycopy(keyByte, 0, temp, 0, keyByte.length);
96 keyByte = temp;
97 }
98 // 初始化
99 Security.addProvider(new BouncyCastleProvider());
100 Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding","BC");
101 SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
102 AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
103 parameters.init(new IvParameterSpec(ivByte));
104 cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化
105 byte[] resultByte = cipher.doFinal(dataByte);
106 if (null != resultByte && resultByte.length > 0) {
107 String result = new String(resultByte, "UTF-8");
108 return JSONObject.parseObject(result);
109 }
110 } catch (Exception e) {
111 e.printStackTrace();
112 }
113 return null;
114 }
115 }
1 package com.topdraw.util;
2
3 import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject;
5
6 import java.util.Arrays;
7 import java.util.Collection;
8 import java.util.List;
9 import java.util.Map;
10
11 public class UcListUtils {
12
13 public static boolean compareIntegerList(Integer obj , List<Integer> originList){
14 Integer o = originList.get(0);
15 Integer o1 = originList.get(1);
16
17 if (o >= 0 && o1 > o && obj >= o && obj <= o1)
18 return true;
19
20 if (o > 0 && o1 < 0 && obj >= o)
21 return true;
22
23 return false;
24 }
25
26 public static void main(String[] args) {
27 String param = "{CONTINUE_LOGIN:30}";
28 Map<String,String> jsonObjectMap = JSONObject.parseObject(param,Map.class);
29 Collection<String> values = jsonObjectMap.values();
30 Object o = values.toArray()[0];
31
32 String attrStr = "{\"value\":[31,-99]}";
33 JSONObject jsonObject = JSONObject.parseObject(attrStr);
34 JSONArray values_0 = jsonObject.getJSONArray("value");
35 Integer o1 = (Integer)values_0.get(0);
36 Integer o2 = (Integer)values_0.get(1);
37 List<Integer> list = Arrays.asList(o1, o2);
38 Integer i = (Integer) o;
39 boolean b = compareIntegerList(i, list);
40 System.out.println(b);
41 }
42
43 }
1 package com.topdraw.weixin.applet;
2
3 import cn.hutool.http.HttpUtil;
4 import com.alibaba.fastjson.JSONObject;
5 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
6 import com.topdraw.security.AESUtil;
7 import com.topdraw.utils.StringUtils;
8 import com.topdraw.weixin.beans.DefaultWeiXinBeanDefinition;
9 import com.topdraw.weixin.beans.WeiXinUserParser;
10 import com.topdraw.weixin.beans.config.WeiXinAppListConfig;
11 import com.topdraw.weixin.util.WeChatConstants;
12 import com.topdraw.weixin.util.WeiXinRequestUtil;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.beans.factory.annotation.Value;
15 import org.springframework.http.HttpMethod;
16 import org.springframework.http.ResponseEntity;
17 import org.springframework.stereotype.Component;
18 import org.springframework.web.client.RestTemplate;
19
20 import java.util.List;
21 import java.util.Map;
22 import java.util.Optional;
23
24 @Component
25 public class WeiXinAppletUserParser implements WeiXinUserParser {
26
27 @Autowired
28 private WeiXinAppListConfig weiXinAppListConfig;
29
30 @Autowired
31 private WeiXinRequestUtil weixinRequestUtil;
32
33 @Value("${uc.service.platform:}")
34 private String platform;
35
36 @Value("${key:}")
37 private String key;
38
39 @Value("${uc.app.subAppId:wx05f35931270014be}")
40 private String subAppId;
41
42 @Value("${uc.app.h5AppId:wxca962918dfeed88c}")
43 private String h5AppId;
44
45 @Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
46 private String appletAppid;
47
48 @Value("${file.upload:upload}")
49 private String filePath;
50
51 @Override
52 public DefaultWeiXinBeanDefinition parse(WeiXinUserBean resources) {
53 String key = this.key;
54 Map<String, String> weixinInfoMap = null;
55 String appId = resources.getWxAppid();
56 String code = resources.getWxCode();
57 String userInfo = null;
58
59 if (StringUtils.isNotBlank(appId)) {
60
61 String decrypt = AESUtil.decrypt(appId, key);
62
63 if (decrypt != null) {
64 appId = decrypt.substring(16);
65 }
66
67 weixinInfoMap = getWeixinInfoByAppid(appId);
68 }
69
70 if (StringUtils.isNotBlank(code)) {
71 String decrypt = AESUtil.decrypt(code, key);
72 if (decrypt != null) {
73 code = decrypt.substring(16);
74 }
75 }
76
77 if (StringUtils.isNotBlank(userInfo)) {
78 String decrypt = AESUtil.decrypt(userInfo, key);
79 if (decrypt != null) {
80 userInfo = decrypt.substring(16);
81 }
82 }
83
84 return this.generateWeiXinBeanDefinition(code,userInfo,weixinInfoMap);
85 }
86
87 /**
88 *
89 * @param code
90 * @param userInfo
91 * @param weixinInfoMap
92 * @return
93 */
94 private DefaultWeiXinBeanDefinition generateWeiXinBeanDefinition(String code, String userInfo, Map<String, String> weixinInfoMap) {
95 String appId = weixinInfoMap.get("appid");
96 String secret = weixinInfoMap.get("secret");
97 JSONObject userInfoWxJo = null;
98
99 // 链接微信服务器
100 /*ResponseEntity<String> responseEntity1 = null;*//*restTemplate.exchange(WeChatConstants.CODE2SESSION.replace("APPID", appId)
101 .replace("SECRET", secret).replace("JSCODE", code),
102 HttpMethod.GET, null, String.class);*//*
103
104 String entityBody1 = responseEntity1.getBody();*/
105
106 String url = WeChatConstants.CODE2SESSION.replace("APPID", appId)
107 .replace("SECRET", secret).replace("JSCODE", code);
108 String entityBody = HttpUtil.get(url);
109
110 JSONObject jsonObject = JSONObject.parseObject(entityBody);
111
112 String openId = jsonObject.getString("openid");
113 String unionId = jsonObject.getString("unionid");
114
115 if (StringUtils.isEmpty(unionId)) {
116 try {
117 userInfoWxJo = this.weixinRequestUtil.getUserInfo(weixinInfoMap, openId,code);
118 } catch (Exception e) {
119 e.printStackTrace();
120 }
121 }
122
123 if (StringUtils.isNotBlank(userInfo)) {
124
125 JSONObject userInfoJo = JSONObject.parseObject(userInfo);
126 String encryptedData = userInfoJo.getString("encryptedData");
127 String iv = userInfoJo.getString("iv");
128 String key = jsonObject.getString("session_key");
129 String userInfoWeixin = AESUtil.decryptJsUserInfo(encryptedData, iv, key);
130 if (StringUtils.isNotEmpty(userInfoWeixin))
131 userInfoWxJo = JSONObject.parseObject(userInfoWeixin);
132 }
133
134 DefaultWeiXinBeanDefinition weiXinBeanDefinition =
135 new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo,null);
136 return weiXinBeanDefinition;
137 }
138
139 /**
140 *
141 * @param appid
142 * @return
143 */
144 private Map<String, String> getWeixinInfoByAppid(String appid) {
145 if (StringUtils.isBlank(appid)) {
146 throw new RuntimeException("wxAppid can not be null");
147 }
148 List<Map<String, String>> list = this.weiXinAppListConfig.getList();
149 Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
150 if (!weixinInfoOptional.isPresent()) {
151 throw new RuntimeException("wxAppid error, appid is : " + appid);
152 }
153 return weixinInfoOptional.get();
154 }
155
156 }
1 package com.topdraw.weixin.beans;
2
3 import lombok.Data;
4
5 @Data
6 public class ActionInfo {
7 private Scene scene;
8 }
1 package com.topdraw.weixin.beans;
2
3 import cn.hutool.core.date.DateUtil;
4 import cn.hutool.http.HttpUtil;
5 import com.alibaba.fastjson.JSONObject;
6 import com.topdraw.exception.BadRequestException;
7 import com.topdraw.utils.StringUtils;
8 import lombok.Data;
9 import org.springframework.beans.factory.annotation.Value;
10 import org.springframework.stereotype.Component;
11
12 import java.io.File;
13 import java.nio.charset.StandardCharsets;
14 import java.util.Base64;
15 import java.util.Date;
16 import java.util.UUID;
17
18 @Data
19 @Component
20 public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition {
21
22 //
23 private String appid;
24
25 private String openId;
26
27 private String code;
28
29 private String token;
30
31 private String secret;
32
33 private String unionId;
34
35 private String nickname;
36
37 private String headImgUrl;
38
39 private JSONObject userInfo;
40
41 private String phoneNumber;
42
43 @Value("${file.upload:upload}")
44 private String filePath;
45
46 public DefaultWeiXinBeanDefinition() {
47 }
48
49 public DefaultWeiXinBeanDefinition(String appId, String code,String unionId,String openId, JSONObject userInfoWxJo,String phone) {
50
51 this.userInfo = userInfoWxJo;
52 if (userInfo != null) {
53
54 if (StringUtils.isNotBlank(userInfoWxJo.getString("unionId"))) {
55 unionId = userInfoWxJo.getString("unionId");
56 }
57
58 if (StringUtils.isNotBlank(userInfoWxJo.getString("openId"))) {
59 openId = userInfoWxJo.getString("openId");
60 }
61
62 headImgUrl = userInfoWxJo.getString("avatarUrl");
63
64 if (StringUtils.isNotBlank(userInfoWxJo.getString("nickName"))) {
65 nickname = Base64.getEncoder().encodeToString(userInfoWxJo.getString("nickName").getBytes(StandardCharsets.UTF_8));
66 }
67
68 String phoneNumber = userInfoWxJo.getString("phoneNumber");
69 if (StringUtils.isBlank(phoneNumber)) {
70 throw new BadRequestException("phoneNumber is null...");
71 }
72
73 this.phoneNumber = phoneNumber;
74
75 if (StringUtils.isNotBlank(headImgUrl)) {
76
77 new Thread(() -> {
78 String s = UUID.randomUUID().toString();
79 File file = new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd"));
80 if (!file.exists()) {
81 file.mkdirs();
82 }
83
84 HttpUtil.downloadFile(headImgUrl, new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg"));
85
86 headImgUrl = filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg";
87 }).start();
88
89 }
90
91 }
92
93 this.unionId = unionId;
94 this.phoneNumber = phone;
95 this.openId = openId;
96 this.appid = appId;
97 this.code = code;
98 }
99
100 @Override
101 public String getAppId() {
102 return this.appid;
103 }
104
105 @Override
106 public String getCode() {
107 return this.code;
108 }
109
110 @Override
111 public String getToken() {
112 return this.token;
113 }
114
115 @Override
116 public String getSecret() {
117 return this.secret;
118 }
119
120 @Override
121 public String getOpenId() {
122 return this.openId;
123 }
124
125 @Override
126 public String getUnionId() {
127 return this.unionId;
128 }
129
130 @Override
131 public String getNickname() {
132 return this.nickname;
133 }
134
135 @Override
136 public String getHeadImgUrl() {
137 return this.headImgUrl;
138 }
139
140 @Override
141 public JSONObject getUserInfo() {
142 return this.userInfo;
143 }
144 }
1 package com.topdraw.weixin.beans;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import lombok.Data;
5
6 @Data
7 public class QrCode {
8
9 @JSONField(name = "action_name")
10 private String actionName;
11
12 @JSONField(name = "expire_seconds")
13 private Integer expireSeconds;
14
15 @JSONField(name = "action_info")
16 private ActionInfo actionInfo;
17
18
19
20 }
1 package com.topdraw.weixin.beans;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import lombok.Data;
5
6 @Data
7 public class Scene {
8 @JSONField(name = "scene_id")
9 private Long sceneId;
10
11 @JSONField(name = "scene_str")
12 private String sceneStr;
13 }
1 package com.topdraw.weixin.beans;
2
3
4 import lombok.AllArgsConstructor;
5 import lombok.Data;
6 import lombok.NoArgsConstructor;
7
8 @Data
9 @NoArgsConstructor
10 @AllArgsConstructor
11 public class WeiXinBean {
12
13 //
14 private String appid;
15
16 private String openId;
17
18 private String code;
19
20 private String token;
21
22 private String secret;
23
24 private String unionId;
25
26 private String nickname;
27
28 private String headImgUrl;
29
30 }
1 package com.topdraw.weixin.beans;
2
3 import com.alibaba.fastjson.JSONObject;
4
5 public interface WeiXinBeanDefinition {
6
7 String getAppId();
8
9 String getCode();
10
11 String getToken();
12
13 String getSecret();
14
15 String getOpenId();
16
17 String getUnionId();
18
19 String getNickname();
20
21 String getHeadImgUrl();
22
23 JSONObject getUserInfo();
24 }
1 package com.topdraw.weixin.beans;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import lombok.Data;
5
6 import java.util.Map;
7
8 @Data
9 public class WeiXinNotice {
10
11 @JSONField(serialize=false)
12 private String appid;
13
14 @JSONField(serialize=false)
15 private Long userId;
16
17 //目标用户
18 @JSONField(name = "touser")
19 private String toUser;
20
21 // 模板code
22 @JSONField(serialize=false)
23 private String code;
24
25 // 模板id
26 @JSONField(name = "template_id")
27 private String templateId;
28
29 // 点击通知跳转页面
30 private String page;
31
32 // 小程序版本
33 @JSONField(name = "miniprogram_state")
34 private String miniprogramState;
35
36 // 填充数据
37 private Map<String, Object> data;
38 }
1 package com.topdraw.weixin.beans;
2
3 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
4
5 public interface WeiXinUserParser {
6
7 DefaultWeiXinBeanDefinition parse(WeiXinUserBean appletUserLoginInfo);
8
9 }
1 package com.topdraw.weixin.beans.config;
2
3 import lombok.Data;
4 import org.springframework.beans.factory.annotation.Value;
5 import org.springframework.boot.context.properties.ConfigurationProperties;
6 import org.springframework.context.annotation.Configuration;
7 import org.springframework.stereotype.Component;
8
9 import java.util.List;
10 import java.util.Map;
11
12 @Data
13 @Configuration
14 @ConfigurationProperties(prefix = "weixin")
15 public class WeiXinAppListConfig {
16
17 private List<Map<String, String>> list;
18
19 /*@Value("${uc.service.platform:}")
20 private String platform;
21
22 @Value("${key:}")
23 private String key;
24
25 @Value("${uc.app.subAppId:wx05f35931270014be}")
26 private String subAppId;
27
28 @Value("${uc.app.h5AppId:wxca962918dfeed88c}")
29 private String h5AppId;
30
31 @Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
32 private String appletAppid;
33
34 @Value("${file.upload:upload}")
35 private String filePath;*/
36
37 }
38
39
1 package com.topdraw.weixin.util;
2
3 public class WeChatConstants {
4
5 public static String HTTPS_AUTHORIZE_WITH_SNSAPI_USERINFO = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
6
7 public static final String HTTPS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token";
8
9 public static final String HTTPS_TICKET_GETTICKET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
10
11 public static final String HTTPS_SNS_OAUTH2_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token";
12
13 public static final String HTTPS_SNS_USERINFO = "https://api.weixin.qq.com/sns/userinfo";
14
15 public static final String CODE2SESSION = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
16
17 /**
18 * 把媒体文件上传到微信服务器。目前仅支持图片。用于发送客服消息或被动回复用户消息。
19 */
20 public static String UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type=image";
21
22 /**
23 * 获取客服消息内的临时素材。即下载临时的多媒体文件。
24 */
25 public static String GET_MEDIA = "https://api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}";
26
27 /**
28 * 用于向微信服务端申请二维码的url
29 */
30 public static String URL_QR_CODE = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}";
31
32 /**
33 * 用于聊天时向用户发送消息的url
34 */
35 public static String CUSTOM_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";
36
37 /**
38 * 发送小程序订阅消息
39 */
40 public static final String SUBSCRIBE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={0}";
41
42 /**
43 * 生成带参数二维码
44 */
45 public static final String QR_CODE_URL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}";
46
47 /**
48 * 获取用户基本信息
49 */
50 public static final String GET_USER_INFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN";
51
52
53 // 批量获取关注者列表
54 public static final String GET_USER_LIST = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}";
55
56 /**
57 * 成功
58 */
59 public static String SUCCESS = "SUCCESS";
60
61 /**
62 * 微信系统错误
63 */
64 public static String SYSTEMERROR = "SYSTEMERROR";
65
66 /**
67 * 失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
68 */
69 public static String FAIL = "FAIL";
70
71 /**
72 * 微信企业付款到个人失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
73 */
74 public static String FAILED = "FAILED";
75
76 public static String ACCESS_TOKEN = "access_token";
77
78 public static String ERR_CODE = "errcode";
79
80 /**
81 * 微信请求时,返回ACCESS_TOKEN错误码
82 */
83 public static final String ACCESS_TOKEN_INVALID_CODE = "40001";
84
85
86 /**
87 * 文本消息
88 */
89 public static String MSG_TYPE_TEXT = "text";
90
91 public static String MSG_TYPE_MINIPROGRAMPAGE = "miniprogrampage";
92
93 public static String MSG_TYPE_LINK = "link";
94
95 public static String MSG_TYPE_IMAGE = "image";
96
97 /**
98 * 事件消息
99 */
100 public static String MSG_TYPE_EVENT = "event";
101
102
103 /**
104 * 二维码类型,临时的整型参数值
105 */
106 public static String QR_SCENE = "QR_SCENE";
107
108 /**
109 * 二维码类型,临时的字符串参数值
110 */
111 public static String QR_STR_SCENE = "QR_STR_SCENE";
112
113 /**
114 * 二维码类型,永久的整型参数值
115 */
116 public static String QR_LIMIT_SCENE = "QR_LIMIT_SCENE";
117
118 /**
119 * 二维码类型,永久的字符串参数值
120 */
121 public static String QR_LIMIT_STR_SCENE = "QR_LIMIT_STR_SCENE";
122
123
124 /******** 事件推送事件类型BEGIN********/
125
126 /**
127 * 取消订阅
128 */
129 public static final String EVENT_UNSUBSCRIBE = "unsubscribe";
130
131
132 /**
133 * 订阅
134 */
135 public static final String EVENT_SUBSCRIBE = "subscribe";
136
137 /**
138 * 扫描带参数二维码事件,用户已关注时的事件推送
139 */
140 public static final String EVENT_SCAN = "SCAN";
141
142 /**
143 * 上报地理位置事件
144 */
145 public static final String EVENT_LOCATION = "LOCATION";
146
147 /**
148 * 自定义菜单事件
149 */
150 public static final String EVENT_CLICK = "CLICK";
151
152 /******** 事件推送事件类型END********/
153
154
155 /**
156 * 微信ACCESS_TOKEN缓存KEY
157 */
158 public static final String TOKEN_KEY = "GLOBAL_WX_ACCESS_TOKEN_";
159
160
161 /**
162 * 微信临时素材缓存KEY
163 */
164 public static final String WEIXIN_MEDIA_KEY = "WEIXIN_MEDIA_KEY_";
165
166 // 微信应用类型 小程序 服务号 订阅号
167 // 小程序
168 public static final String WX_APPLET = "applet";
169 // 服务号
170 public static final String WX_SERVICE = "service";
171 // 订阅号
172 public static final String WX_SUBSCRIPTION = "subscription";
173
174
175 }
1 package com.topdraw.weixin.util;
2
3 import cn.hutool.core.util.StrUtil;
4 import cn.hutool.http.HttpRequest;
5 import cn.hutool.http.HttpResponse;
6 import com.alibaba.fastjson.JSON;
7 import com.alibaba.fastjson.JSONObject;
8 import com.topdraw.utils.RedisUtils;
9 import com.topdraw.utils.StringUtils;
10 import com.topdraw.weixin.beans.QrCode;
11 import com.topdraw.weixin.beans.WeiXinNotice;
12 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.retry.annotation.Backoff;
15 import org.springframework.retry.annotation.Retryable;
16 import org.springframework.stereotype.Component;
17
18 import java.io.File;
19 import java.io.IOException;
20 import java.net.URLEncoder;
21 import java.text.MessageFormat;
22 import java.util.HashMap;
23 import java.util.Map;
24 import java.util.concurrent.TimeUnit;
25
26 @Component
27 @Slf4j
28 public class WeiXinRequestUtil {
29
30 @Autowired
31 private RedisUtils redisUtils;
32
33 /**
34 *
35 * */
36 private static String doGet(String url, Map<String, String> param) {
37 String result = null;
38 try {
39 String queryString = "";
40 if (null != param) {
41 for (Map.Entry<String, String> entry : param.entrySet()) {
42 queryString += entry.getKey() + "=" + URLEncoder.encode("" + entry.getValue(), "UTF-8") + "&";
43 }
44 if (queryString.length() > 0) {
45 queryString = queryString.substring(0, queryString.length() - 1);
46 }
47 }
48 log.info("weixin request: " + url + "?" + queryString);
49 HttpResponse response = HttpRequest.get(url + "?" + queryString).execute();
50 if (response.isOk()) {
51 result = response.body();
52 log.info("weixin response: " + result);
53 }
54 } catch (Exception e) {
55 e.printStackTrace();
56 }
57 return result;
58 }
59
60 private String wx_token(String appid, String secret) {
61 Map<String, String> param = new HashMap<>();
62 param.put("grant_type", "client_credential");
63 param.put("appid", appid);
64 param.put("secret", secret);
65 return this.doGet(WeChatConstants.HTTPS_TOKEN, param);
66 }
67
68 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
69 public String wx_ticket_getticket(String appid, String secret) {
70 String token = getToken(appid, secret,null);
71 Map<String, String> param = new HashMap<>();
72 param.put("access_token", token);
73 param.put("type", "jsapi");
74 return doGet(WeChatConstants.HTTPS_TICKET_GETTICKET, param);
75 }
76
77 public String wx_sns_oauth2_access_token(String appid, String secret, String code) {
78 Map<String, String> param = new HashMap<>();
79 param.put("appid", appid);
80 param.put("secret", secret);
81 param.put("code", code);
82 param.put("grant_type", "authorization_code");
83 return doGet(WeChatConstants.HTTPS_SNS_OAUTH2_ACCESS_TOKEN, param);
84 }
85
86
87 public String wx_sns_userinfo(String oauth2_access_token, String openid) {
88 Map<String, String> param = new HashMap<>();
89 param.put("access_token", oauth2_access_token);
90 param.put("openid", openid);
91 param.put("lang", "zh_CN");
92 return doGet(WeChatConstants.HTTPS_SNS_USERINFO, param);
93 }
94
95 public String wx_get_userinfo(String oauth2_access_token, String openid) {
96 Map<String, String> param = new HashMap<>();
97 param.put("access_token", oauth2_access_token);
98 param.put("openid", openid);
99 param.put("lang", "zh_CN");
100 return doGet(WeChatConstants.GET_USER_INFO, param);
101 }
102
103
104 public String getToken(String appid, String secret,String code) {
105 String token = (String) redisUtils.get(WeChatConstants.TOKEN_KEY + appid);
106 if (StringUtils.isNotBlank(token)) {
107 return token;
108 }
109 token = this.getTokenNoRedis(appid, secret,code);
110 return token;
111 }
112
113 public String getToken(String appid, String secret) {
114 String token = (String) redisUtils.get(WeChatConstants.TOKEN_KEY + appid);
115 if (StringUtils.isNotBlank(token)) {
116 return token;
117 }
118 token = this.getTokenNoRedis(appid, secret,null);
119 return token;
120 }
121
122 public String getTokenNoRedis(String appid, String secret,String code) {
123 String token = null;
124 String response = this.wx_token(appid, secret);
125 // String response = this.wx_sns_oauth2_access_token(appid, secret,code);
126 try {
127 JSONObject joToken = JSON.parseObject(response);
128 if (null != joToken && null != joToken.getString("access_token")) {
129 token = joToken.getString("access_token");
130 Integer expiresIn = joToken.getInteger("expires_in");
131 redisUtils.set(WeChatConstants.TOKEN_KEY + appid, token, expiresIn, TimeUnit.SECONDS);
132 }
133 } catch (Exception e) {
134 e.printStackTrace();
135 }
136 return token;
137 }
138
139 public String getTokenNoRedis(String appid, String secret) {
140 String token = null;
141 // String response = this.wx_token(appid, secret);
142 String response = this.wx_sns_oauth2_access_token(appid, secret,null);
143 try {
144 JSONObject joToken = JSON.parseObject(response);
145 if (null != joToken && null != joToken.getString("access_token")) {
146 token = joToken.getString("access_token");
147 Integer expiresIn = joToken.getInteger("expires_in");
148 redisUtils.set(WeChatConstants.TOKEN_KEY + appid, token, expiresIn, TimeUnit.SECONDS);
149 }
150 } catch (Exception e) {
151 e.printStackTrace();
152 }
153 return token;
154 }
155
156 /**
157 * 发送订阅消息,access_token错误时,重新获取进行重试
158 *
159 * @param weixinInfo 微信参数
160 * @param request 订阅消息内容
161 */
162 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
163 public void sendNotice(Map<String, String> weixinInfo, WeiXinNotice request) {
164 String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
165 String url = MessageFormat.format(WeChatConstants.SUBSCRIBE_SEND_URL, accessToken);
166 log.info("send notice request : " + JSONObject.toJSONString(request));
167 HttpResponse response = HttpRequest.post(url).body(JSONObject.toJSONString(request), "application/json;charset=utf-8").execute();
168 if (!response.isOk()) {
169 log.error("send notice error || {}", response);
170 throw new RuntimeException("send notice error");
171 }
172 JSONObject jsonObject = JSONObject.parseObject(response.body());
173 Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
174 if (errCode != null && errCode != 0) {
175 if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
176 getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
177 }
178
179 // 返回errCode时,也输出返回的结果信息
180 log.error("send notice error || {}", response.body());
181 throw new RuntimeException("send notice error");
182 }
183 log.info("send notice response : " + response.body());
184 }
185
186
187 /**
188 * 微信小程序客服发送消息,access_token错误时,重新获取进行重试
189 *
190 * @param weixinInfo 微信参数
191 * @param body 消息内容
192 */
193 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
194 public void sendMessage(Map<String, String> weixinInfo, String body) {
195 String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
196 String url = MessageFormat.format(WeChatConstants.CUSTOM_SEND_URL, accessToken);
197 HttpResponse response = HttpRequest.post(url).body(body, "application/json;charset=utf-8").execute();
198 if (!response.isOk()) {
199 log.error("send message error || {}", response);
200 throw new RuntimeException("send message error");
201 }
202 log.info("send message response || {}", response.body());
203 JSONObject jsonObject = JSONObject.parseObject(response.body());
204 Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
205 if (errCode != null && errCode != 0) {
206 if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
207 getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
208 }
209 throw new RuntimeException("send message error");
210 }
211 }
212
213 /**
214 * 上传临时素材返回mediaId,access_token错误时,重新获取进行重试
215 *
216 * @param weixinInfo 微信参数
217 * @param imagePath 素材路径
218 */
219 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
220 public String getMediaId(Map<String, String> weixinInfo, String imagePath) throws IOException {
221 String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
222 String mediaId = (String) redisUtils.get(WeChatConstants.WEIXIN_MEDIA_KEY + weixinInfo.get("appid"));
223 if (StringUtils.isNotBlank(mediaId)) {
224 return mediaId;
225 }
226 String url = MessageFormat.format(WeChatConstants.UPLOAD_URL, accessToken);
227 HttpResponse response = HttpRequest.post(url).form("file", new File(imagePath)).execute();
228 if (!response.isOk()) {
229 log.error("upload image error || {}", response);
230 throw new RuntimeException("upload image error");
231 }
232 log.info("upload image response || {}", response.body());
233 JSONObject jsonObject = JSONObject.parseObject(response.body());
234 Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
235 if (errCode != null && errCode != 0) {
236 if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
237 getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
238 }
239 throw new RuntimeException("upload image error");
240 }
241 mediaId = jsonObject.getString("media_id");
242 redisUtils.set(WeChatConstants.WEIXIN_MEDIA_KEY + weixinInfo.get("appid"), mediaId, 60, TimeUnit.HOURS);
243 return mediaId;
244 }
245
246 /**
247 * 公众号获取带参数二维码,access_token错误时,重新获取进行重试
248 *
249 * @param weixinInfo 微信参数
250 * @param qrCode 二维码信息
251 */
252 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
253 public JSONObject getQrCode(Map<String, String> weixinInfo, QrCode qrCode) throws IOException {
254 String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
255 String url = MessageFormat.format(WeChatConstants.QR_CODE_URL, accessToken);
256 HttpResponse response = HttpRequest.post(url).body(JSONObject.toJSONString(qrCode), "application/json;charset=utf-8").execute();
257 if (!response.isOk()) {
258 log.error("get qrCode error || {}", response);
259 throw new RuntimeException("get qrCode error");
260 }
261 log.info("get qrCode response || {}", response.body());
262 JSONObject jsonObject = JSONObject.parseObject(response.body());
263 Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
264 if (errCode != null && errCode != 0) {
265 if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
266 getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
267 }
268 throw new RuntimeException("get qrCode error");
269 }
270 return jsonObject;
271 }
272
273 /**
274 * 公众号获取用户信息,access_token错误时,重新获取进行重试
275 *
276 * @param weixinInfo 微信参数
277 * @param openid 用户openid
278 */
279 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
280 public JSONObject getUserInfo(Map<String, String> weixinInfo, String openid,String code) throws IOException {
281 String accessToken = this.getToken(weixinInfo.get("appid"), weixinInfo.get("secret"),code);
282 String url = MessageFormat.format(WeChatConstants.GET_USER_INFO, accessToken, openid);
283 // String url = MessageFormat.format(WeChatConstants.HTTPS_SNS_USERINFO, accessToken, openid);
284 // String url = MessageFormat.format(WeChatConstants.HTTPS_AUTHORIZE_WITH_SNSAPI_USERINFO, accessToken, openid);
285 HttpResponse response = HttpRequest.get(url).execute();
286 if (!response.isOk()) {
287 log.error("get userInfo error || {}", response);
288 throw new RuntimeException("get userInfo error");
289 }
290 log.info("get userInfo response || {}", response.body());
291 JSONObject jsonObject = JSONObject.parseObject(response.body());
292 Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
293 if (errCode != null && errCode != 0) {
294 if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
295 this.getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
296 }
297 throw new RuntimeException("get userInfo error");
298 }
299 return jsonObject;
300 }
301
302 /**
303 * 公众号获取用户信息,access_token错误时,重新获取进行重试
304 *
305 * @param weixinInfo 微信参数
306 * @param openid 用户openid
307 */
308 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
309 public JSONObject getUserInfo(Map<String, String> weixinInfo, String openid) throws IOException {
310 return this.getUserInfo(weixinInfo,openid,"");
311 }
312
313 /**
314 * @param weixinInfo
315 * @param nextOpenId
316 * @return com.alibaba.fastjson.JSONObject
317 * @description 公众号批量获取关注者列表,不传nextOpenId默认从头开始拉取,引用重试机制
318 * @author Hongyan Wang
319 * @date 2021/9/2 9:42 上午
320 */
321 @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
322 public JSONObject getUserList(Map<String, String> weixinInfo, String nextOpenId) {
323 String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
324 // 不传next_openid,默认从头开始拉取
325 if (StrUtil.isBlank(nextOpenId))
326 nextOpenId = "";
327 String url = MessageFormat.format(WeChatConstants.GET_USER_LIST, accessToken, nextOpenId);
328 HttpResponse response = HttpRequest.get(url).execute();
329 if (!response.isOk()) {
330 log.error("get userList error || {}", response);
331 throw new RuntimeException("get userList error");
332 }
333 log.info("get userList response || {}", response.body());
334 //返回Json样例
335 // {
336 // "total":2,
337 // "count":2,
338 // "data":{
339 // "openid":["OPENID1","OPENID2"]},
340 // "next_openid":"NEXT_OPENID"
341 //}
342 JSONObject jsonObject = JSONObject.parseObject(response.body());
343 Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
344 if (errCode != null && errCode != 0) {
345 if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
346 getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
347 }
348 throw new RuntimeException("get userList error");
349 }
350 return jsonObject;
351 }
352
353 }
1 package com.topdraw.weixin.util;
2
3 import com.topdraw.config.WeixinInfoConfig;
4 import com.topdraw.utils.StringUtils;
5 import lombok.extern.slf4j.Slf4j;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Component;
8
9 import javax.servlet.ServletOutputStream;
10 import javax.servlet.http.HttpServletRequest;
11 import javax.servlet.http.HttpServletResponse;
12 import java.io.IOException;
13 import java.io.UnsupportedEncodingException;
14 import java.security.MessageDigest;
15 import java.security.NoSuchAlgorithmException;
16 import java.util.Arrays;
17 import java.util.List;
18 import java.util.Map;
19 import java.util.Optional;
20
21
22 @Component
23 @Slf4j
24 public class WeixinUtil {
25
26
27 private static WeixinInfoConfig WEIXININFOCONFIG;
28
29 @Autowired
30 public void setWeixinInfoConfig(WeixinInfoConfig weixinInfoConfig) {
31 WEIXININFOCONFIG = weixinInfoConfig;
32 }
33
34 public static Map<String, String> getWeixinInfoByAppid(String appid) {
35 if (StringUtils.isBlank(appid)) {
36 throw new RuntimeException("wxAppid can not be null");
37 }
38 List<Map<String, String>> list = WEIXININFOCONFIG.getList();
39 Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
40 if (!weixinInfoOptional.isPresent()) {
41 throw new RuntimeException("wxAppid error, appid is : " + appid);
42 }
43 return weixinInfoOptional.get();
44 }
45
46
47 public static Map<String, String> getWeixinInfoByIndex(Integer index) {
48 List<Map<String, String>> list = WEIXININFOCONFIG.getList();
49 if (list.size() < index + 1) {
50 throw new RuntimeException("wxinfo error, index out of range : {}" + index);
51 }
52 return list.get(index);
53 }
54 /**
55 * 使用SHA1算法对字符串数组进行加密
56 *
57 * @param strList
58 * @return
59 */
60 public static String encodeUsingSHA1(String... strList) {
61 //将strList的值进行字典排序
62 Arrays.sort(strList);
63 StringBuilder content = new StringBuilder();
64 for (int i = 0; i < strList.length; i++) {
65 content.append(strList[i]);
66 }
67
68 return doEncodeUsingSHA1(content.toString());
69 }
70
71
72 /**
73 * SHA1实现
74 *
75 * @return sha1加密后的字符串
76 */
77 private static String doEncodeUsingSHA1(String inStr) {
78 byte[] byteArray ;
79
80 try {
81 MessageDigest sha = MessageDigest.getInstance("SHA-1");
82 byteArray = sha.digest(inStr.getBytes("UTF-8"));
83 } catch (NoSuchAlgorithmException e) {
84 throw new RuntimeException("no sha-1 algorithm");
85 } catch (UnsupportedEncodingException e) {
86 throw new RuntimeException("unsupported utf-8 encoding");
87 }
88
89 StringBuilder sb = new StringBuilder();
90 for (int i = 0; i < byteArray.length; i++) {
91 sb.append(Integer.toString((byteArray[i] & 0xff) + 0x100, 16).substring(1));
92 }
93 return sb.toString();
94 }
95
96 /**
97 * 公众号,小程序后台配置服务器,初次检验时使用
98 * @throws IOException
99 */
100 public static void doGet(HttpServletRequest request, HttpServletResponse response, Map<String, String> weixinInfo) throws IOException {
101 log.info("doGet receive WeChat server request parameters:{}", request.getParameterMap());
102 String signature = request.getParameter("signature");
103 String timestamp = request.getParameter("timestamp");
104 String nonce = request.getParameter("nonce");
105 String echoStr = request.getParameter("echostr");
106 String[] arr = new String[]{weixinInfo.get("token"), timestamp, nonce};
107 String encrypt = WeixinUtil.encodeUsingSHA1(arr);
108 if (encrypt.equals(signature)) {
109 ServletOutputStream outputStream = response.getOutputStream();
110 outputStream.write(echoStr.getBytes());
111 outputStream.flush();
112 }
113 }
114
115
116 }
...@@ -6,14 +6,6 @@ spring: ...@@ -6,14 +6,6 @@ spring:
6 username: root 6 username: root
7 password: Tjlh@2017 7 password: Tjlh@2017
8 8
9
10 # url: jdbc:log4jdbc:mysql://47.100.212.170:3306/ucs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
11 # username: root
12 # password: Tjlh@2021
13
14 # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
15 # username: root
16 # password: root
17 driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy 9 driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
18 #Druid 10 #Druid
19 type: com.alibaba.druid.pool.DruidDataSource 11 type: com.alibaba.druid.pool.DruidDataSource
...@@ -107,5 +99,3 @@ generator: ...@@ -107,5 +99,3 @@ generator:
107 swagger: 99 swagger:
108 enabled: true 100 enabled: true
109 101
110 service:
111 platform: management
...\ No newline at end of file ...\ No newline at end of file
......
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4 This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
5 Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
6 -->
7 <application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
8
9 <id>member-service-impl</id>
10
11 <classpath>
12 <dir name="C:/Users/lenovo/Documents/workspace/member-service/member-service-impl/target/classes">
13 </dir>
14 </classpath>
15
16 </application>
1 package com.topdraw; 1 package com.topdraw;
2 2
3 3
4 import com.alibaba.fastjson.JSONObject;
5 import com.topdraw.module.mq.DataSyncMsg;
4 import org.junit.runner.RunWith; 6 import org.junit.runner.RunWith;
5 import org.slf4j.Logger; 7 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
7 import org.springframework.boot.test.context.SpringBootTest; 9 import org.springframework.boot.test.context.SpringBootTest;
8 import org.springframework.test.context.junit4.SpringRunner; 10 import org.springframework.test.context.junit4.SpringRunner;
9 11
12 import java.sql.Timestamp;
13 import java.time.LocalDateTime;
14 import java.util.Collection;
15 import java.util.HashMap;
16 import java.util.Map;
17
10 @SpringBootTest(classes= MemberServiceApplication.class) 18 @SpringBootTest(classes= MemberServiceApplication.class)
11 @RunWith(SpringRunner.class) 19 @RunWith(SpringRunner.class)
12 public class BaseTest { 20 public class BaseTest {
13 21
14 public Logger LOG = LoggerFactory.getLogger(BaseTest.class); 22 public Logger LOG = LoggerFactory.getLogger(BaseTest.class);
23
15 private static String replaceUrl(String body, String ftpPath) { 24 private static String replaceUrl(String body, String ftpPath) {
16 boolean contains = body.contains("<source src="); 25 boolean contains = body.contains("<source src=");
17 if (contains) { 26 if (contains) {
18 body = body.replaceAll( "(<source src=(.*?)/>)","<source src="+"\""+ftpPath+"\"/>"); 27 body = body.replaceAll("(<source src=(.*?)/>)", "<source src=" + "\"" + ftpPath + "\"/>");
19 } 28 }
20 return body; 29 return body;
21 } 30 }
22 31
23 public static void main(String[] args) { 32 public static void main(String[] args) {
24 String a = "<p>gfdsgf <video controls=\"controls\" width=\"300\" height=\"150\">\n" + 33 /* Map<String,Integer> map = new HashMap<>();
25 "<source src=\"dddd\" /></video></p>"; 34 map.put("1",1);
35 map.put("2",15);
26 36
27 String c = "<p>测试正文<br /><br /><video controls=\"controls\" width=\"360\" height=\"180\">\n" + 37 int i = 5;
28 "<source src=\"test\" /></video></p>";
29 38
39 Object[] objects = map.values().toArray();
40 Integer object0 = (Integer) objects[0];
41 Integer object1 = (Integer) objects[1];
30 42
43 if (i > object0 && i < object1)
44 System.out.println(true);*/
31 45
32 String b = "{{nas-base-url.cms-upload}}/upload/commonFile/theme_activity/2021-12-15/aebd8dbb-87bb-4523-921f-4354c3298fdd.mp4"; 46
33 String s = replaceUrl(c, b); 47 String param = "{\"GOODS\":\"aabbccddeeff\"}";
34 System.out.println(s); 48 Map<String,String> jsonObject = JSONObject.parseObject(param,Map.class);
49 System.out.println(jsonObject);
35 } 50 }
51
52
53
54
36 } 55 }
......
...@@ -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_user_weixin"; 42 var dbName = "tr_task_attr";
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.user."; 49 var preRoute = "com.topdraw.business.module.task.";
50 StringBuilder builder = new StringBuilder(preRoute); 50 StringBuilder builder = new StringBuilder(preRoute);
51 builder.append("weixin"); 51 builder.append("attribute");
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.module.member.rest.MemberController;
4 import com.topdraw.business.basicdata.member.service.MemberService; 4 import com.topdraw.business.module.member.service.MemberService;
5 import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
6 import com.topdraw.BaseTest; 5 import com.topdraw.BaseTest;
7 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
8 import org.junit.Test; 7 import org.junit.Test;
......
...@@ -2,10 +2,8 @@ package com.topdraw.test.business.basicdata.member.profile; ...@@ -2,10 +2,8 @@ package com.topdraw.test.business.basicdata.member.profile;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.BaseTest; 4 import com.topdraw.BaseTest;
5 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; 5 import com.topdraw.business.module.member.profile.domain.MemberProfile;
6 import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; 6 import com.topdraw.business.module.member.profile.service.MemberProfileService;
7 import com.topdraw.business.basicdata.member.service.MemberService;
8 import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
9 import com.topdraw.util.TimestampUtil; 7 import com.topdraw.util.TimestampUtil;
10 import org.junit.Test; 8 import org.junit.Test;
11 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.member.rest; 1 package com.topdraw.test.business.basicdata.member.rest;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.business.basicdata.member.address.domain.MemberAddress; 4 import com.topdraw.business.module.member.address.domain.MemberAddress;
5 import com.topdraw.business.basicdata.member.address.rest.MemberAddressController; 5 import com.topdraw.business.module.member.address.rest.MemberAddressController;
6 import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; 6 import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
7 import com.topdraw.common.ResultInfo; 7 import com.topdraw.common.ResultInfo;
8 import com.topdraw.BaseTest; 8 import com.topdraw.BaseTest;
9 import org.junit.Test; 9 import org.junit.Test;
......
1 package com.topdraw.test.business.basicdata.member.rest; 1 package com.topdraw.test.business.basicdata.member.rest;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.basicdata.member.rest.MemberController; 5 import com.topdraw.business.module.member.rest.MemberController;
6 import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria;
7 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
8 import com.topdraw.BaseTest; 7 import com.topdraw.BaseTest;
9 import com.topdraw.util.IdWorker; 8 import com.topdraw.util.IdWorker;
10 import com.topdraw.util.TimestampUtil; 9 import com.topdraw.util.TimestampUtil;
11 import org.junit.Test; 10 import org.junit.Test;
12 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.data.domain.PageRequest; 12
14 import org.springframework.data.domain.Pageable; 13 import java.time.LocalDateTime;
15 14
16 public class MemberControllerTest extends BaseTest { 15 public class MemberControllerTest extends BaseTest {
17 16
...@@ -78,7 +77,7 @@ public class MemberControllerTest extends BaseTest { ...@@ -78,7 +77,7 @@ public class MemberControllerTest extends BaseTest {
78 member.setDueCouponAmount(0L); 77 member.setDueCouponAmount(0L);
79 member.setUserIptvId(1L); 78 member.setUserIptvId(1L);
80 member.setBindIptvPlatformType(0); 79 member.setBindIptvPlatformType(0);
81 member.setUpdateTime(TimestampUtil.now()); 80 member.setUpdateTime(LocalDateTime.now());
82 String s = JSON.toJSONString(member); 81 String s = JSON.toJSONString(member);
83 ResultInfo byId = this.memberController.create(member); 82 ResultInfo byId = this.memberController.create(member);
84 LOG.info("===>>>"+byId); 83 LOG.info("===>>>"+byId);
......
...@@ -2,9 +2,8 @@ package com.topdraw.test.business.basicdata.member.rest; ...@@ -2,9 +2,8 @@ package com.topdraw.test.business.basicdata.member.rest;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.BaseTest; 4 import com.topdraw.BaseTest;
5 import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; 5 import com.topdraw.business.module.member.profile.domain.MemberProfile;
6 import com.topdraw.business.basicdata.member.profile.rest.MemberProfileController; 6 import com.topdraw.business.module.member.profile.rest.MemberProfileController;
7 import com.topdraw.business.basicdata.member.profile.service.MemberProfileService;
8 import com.topdraw.util.TimestampUtil; 7 import com.topdraw.util.TimestampUtil;
9 import org.junit.Test; 8 import org.junit.Test;
10 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.member.rest; 1 package com.topdraw.test.business.basicdata.member.rest;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; 4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
5 import com.topdraw.business.basicdata.member.relatedinfo.rest.MemberRelatedInfoController; 5 import com.topdraw.business.module.member.relatedinfo.rest.MemberRelatedInfoController;
6 import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; 6 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
7 import com.topdraw.common.ResultInfo; 7 import com.topdraw.common.ResultInfo;
8 import com.topdraw.BaseTest; 8 import com.topdraw.BaseTest;
9 import org.junit.Test; 9 import org.junit.Test;
......
1 package com.topdraw.test.business.basicdata.points; 1 package com.topdraw.test.business.basicdata.points;
2 2
3 import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; 3 import com.topdraw.business.module.points.available.domain.PointsAvailable;
4 import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; 4 import com.topdraw.business.module.points.available.service.PointsAvailableService;
5 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; 5 import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
6 import com.topdraw.business.process.domian.TempPoints; 6 import com.topdraw.business.process.domian.TempPoints;
7 import com.topdraw.BaseTest; 7 import com.topdraw.BaseTest;
8 import com.topdraw.util.DateUtil;
9 import com.topdraw.util.IdWorker; 8 import com.topdraw.util.IdWorker;
10 import com.topdraw.util.TimestampUtil;
11 import org.junit.Test; 9 import org.junit.Test;
12 import org.springframework.beans.BeanUtils; 10 import org.springframework.beans.BeanUtils;
13 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.points; 1 package com.topdraw.test.business.basicdata.points;
2 2
3 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 3 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; 4 import com.topdraw.business.module.points.detail.domain.PointsDetail;
5 import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; 5 import com.topdraw.business.module.points.detail.service.PointsDetailService;
6 import com.topdraw.business.process.service.MemberOperationService; 6 import com.topdraw.business.process.service.MemberOperationService;
7 import com.topdraw.business.process.domian.TempPoints; 7 import com.topdraw.business.process.domian.TempPoints;
8 import com.topdraw.BaseTest; 8 import com.topdraw.BaseTest;
9 import com.topdraw.util.IdWorker; 9 import com.topdraw.util.IdWorker;
10 import com.topdraw.util.TimestampUtil;
11 import org.junit.Test; 10 import org.junit.Test;
12 import org.springframework.beans.BeanUtils; 11 import org.springframework.beans.BeanUtils;
13 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.rights; 1 package com.topdraw.test.business.basicdata.rights;
2 2
3 import com.topdraw.BaseTest; 3 import com.topdraw.BaseTest;
4 import com.topdraw.business.basicdata.member.service.dto.MemberDTO; 4 import com.topdraw.business.module.member.service.dto.MemberDTO;
5 import com.topdraw.business.basicdata.points.detail.domain.PointsDetail; 5 import com.topdraw.business.module.points.detail.domain.PointsDetail;
6 import com.topdraw.business.basicdata.points.detail.service.PointsDetailService; 6 import com.topdraw.business.module.points.detail.service.PointsDetailService;
7 import com.topdraw.business.process.domian.TempPoints; 7 import com.topdraw.business.process.domian.TempPoints;
8 import com.topdraw.business.process.service.MemberOperationService; 8 import com.topdraw.business.process.service.MemberOperationService;
9 import com.topdraw.util.IdWorker; 9 import com.topdraw.util.IdWorker;
10 import com.topdraw.util.TimestampUtil;
11 import org.junit.Test; 10 import org.junit.Test;
12 import org.springframework.beans.BeanUtils; 11 import org.springframework.beans.BeanUtils;
13 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.rights.history; 1 package com.topdraw.test.business.basicdata.rights.history;
2 2
3 import com.topdraw.BaseTest; 3 import com.topdraw.BaseTest;
4 import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; 4 import com.topdraw.business.module.rights.history.rest.RightsHistoryController;
5 import com.topdraw.business.basicdata.rights.history.rest.RightsHistoryController; 5 import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
6 import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria;
7 import com.topdraw.business.basicdata.rights.rest.RightsController;
8 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
9 import org.junit.Test; 7 import org.junit.Test;
10 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.rights.permanentrights; 1 package com.topdraw.test.business.basicdata.rights.permanentrights;
2 2
3 import com.topdraw.BaseTest; 3 import com.topdraw.BaseTest;
4 import com.topdraw.business.basicdata.rights.permanentrights.rest.PermanentRightsController; 4 import com.topdraw.business.module.rights.permanentrights.rest.PermanentRightsController;
5 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria; 5 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
6 import com.topdraw.business.basicdata.rights.rest.RightsController;
7 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
8 import org.junit.Test; 7 import org.junit.Test;
9 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.rights.rest; 1 package com.topdraw.test.business.basicdata.rights.rest;
2 2
3 import com.topdraw.BaseTest; 3 import com.topdraw.BaseTest;
4 import com.topdraw.business.basicdata.rights.rest.RightsController; 4 import com.topdraw.business.module.rights.rest.RightsController;
5 import com.topdraw.common.ResultInfo; 5 import com.topdraw.common.ResultInfo;
6 import org.junit.Test; 6 import org.junit.Test;
7 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.basicdata.task; 1 package com.topdraw.test.business.basicdata.task;
2 2
3 import com.topdraw.business.basicdata.task.template.domain.TaskTemplate; 3 import com.topdraw.business.module.task.template.domain.TaskTemplate;
4 import com.topdraw.business.basicdata.task.template.service.TaskTemplateService; 4 import com.topdraw.business.module.task.template.service.TaskTemplateService;
5 import com.topdraw.BaseTest; 5 import com.topdraw.BaseTest;
6 import org.junit.Test; 6 import org.junit.Test;
7 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
......
1 package com.topdraw.test.business.process.rest; 1 package com.topdraw.test.business.process.rest;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
5 import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryType;
6 import com.topdraw.business.basicdata.points.detail.rest.PointsDetailController;
7 import com.topdraw.BaseTest; 4 import com.topdraw.BaseTest;
8 import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
9 import com.topdraw.business.process.domian.TempPoints; 5 import com.topdraw.business.process.domian.TempPoints;
10 import com.topdraw.business.process.rest.PointsOperationController; 6 import com.topdraw.business.process.rest.PointsOperationController;
11 import com.topdraw.common.ResultInfo; 7 import com.topdraw.common.ResultInfo;
12 import org.junit.Test; 8 import org.junit.Test;
13 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.data.domain.PageRequest;
15 import org.springframework.data.domain.Pageable;
16 10
17 import java.sql.Timestamp;
18 import java.time.LocalDateTime; 11 import java.time.LocalDateTime;
19 12
20 public class PointsOperationControllerTest extends BaseTest { 13 public class PointsOperationControllerTest extends BaseTest {
......
...@@ -2,10 +2,9 @@ package com.topdraw.test.business.process.rest; ...@@ -2,10 +2,9 @@ package com.topdraw.test.business.process.rest;
2 2
3 3
4 import com.topdraw.BaseTest; 4 import com.topdraw.BaseTest;
5 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 5 import com.topdraw.business.module.rights.history.domain.RightsHistory;
6 import com.topdraw.business.process.rest.RightsOperationController; 6 import com.topdraw.business.process.rest.RightsOperationController;
7 import com.topdraw.common.ResultInfo; 7 import com.topdraw.common.ResultInfo;
8 import com.topdraw.util.TimestampUtil;
9 import org.junit.Test; 8 import org.junit.Test;
10 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
11 10
......
1 package com.topdraw.test.business.process.rest; 1 package com.topdraw.test.business.process.rest;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria;
5 import com.topdraw.business.process.rest.TaskOperationController; 4 import com.topdraw.business.process.rest.TaskOperationController;
6 import com.topdraw.business.process.rest.TaskOperationQueryCriteria; 5 import com.topdraw.business.process.rest.TaskOperationQueryCriteria;
7 import com.topdraw.module.mq.DataSyncMsg; 6 import com.topdraw.module.mq.DataSyncMsg;
8 import com.topdraw.module.mq.EntityType;
9 import com.topdraw.module.mq.EventType; 7 import com.topdraw.module.mq.EventType;
10 import com.topdraw.BaseTest; 8 import com.topdraw.BaseTest;
11 import com.topdraw.utils.StringUtils;
12 import org.junit.Test; 9 import org.junit.Test;
13 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 11 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
15 12
16 import javax.annotation.Resource;
17 import java.util.List;
18 import java.util.concurrent.ArrayBlockingQueue;
19 import java.util.concurrent.FutureTask; 13 import java.util.concurrent.FutureTask;
20 import java.util.concurrent.ThreadPoolExecutor;
21 import java.util.concurrent.TimeUnit;
22 14
23 public class TaskOperationControllerTest extends BaseTest { 15 public class TaskOperationControllerTest extends BaseTest {
24 16
......
1 package com.topdraw.test.business.process.service; 1 package com.topdraw.test.business.process.service;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.business.basicdata.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.process.service.MemberOperationService; 5 import com.topdraw.business.process.service.MemberOperationService;
6 import com.topdraw.BaseTest; 6 import com.topdraw.BaseTest;
7 import com.topdraw.util.IdWorker; 7 import com.topdraw.util.IdWorker;
...@@ -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 MemberOperationServiceTest extends BaseTest { 14 public class MemberOperationServiceTest extends BaseTest {
13 15
14 @Autowired 16 @Autowired
...@@ -43,7 +45,7 @@ public class MemberOperationServiceTest extends BaseTest { ...@@ -43,7 +45,7 @@ public class MemberOperationServiceTest extends BaseTest {
43 member.setDueCouponAmount(0L); 45 member.setDueCouponAmount(0L);
44 member.setUserIptvId(1L); 46 member.setUserIptvId(1L);
45 member.setBindIptvPlatformType(0); 47 member.setBindIptvPlatformType(0);
46 member.setUpdateTime(TimestampUtil.now()); 48 member.setUpdateTime(LocalDateTime.now());
47 String s = JSONObject.toJSONString(member); 49 String s = JSONObject.toJSONString(member);
48 50
49 this.memberOperationService.doUpdateMemberInfo(member); 51 this.memberOperationService.doUpdateMemberInfo(member);
...@@ -71,9 +73,9 @@ public class MemberOperationServiceTest extends BaseTest { ...@@ -71,9 +73,9 @@ public class MemberOperationServiceTest extends BaseTest {
71 member.setDueCouponAmount(0L); 73 member.setDueCouponAmount(0L);
72 member.setUserIptvId(1L); 74 member.setUserIptvId(1L);
73 member.setBindIptvPlatformType(0); 75 member.setBindIptvPlatformType(0);
74 member.setBindIptvTime(TimestampUtil.now()); 76 member.setBindIptvTime(LocalDateTime.now());
75 member.setCreateTime(TimestampUtil.now()); 77 member.setCreateTime(LocalDateTime.now());
76 member.setUpdateTime(TimestampUtil.now()); 78 member.setUpdateTime(LocalDateTime.now());
77 // member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now())); 79 // member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now()));
78 this.memberOperationService.doInsertMember(member); 80 this.memberOperationService.doInsertMember(member);
79 } 81 }
......
1 package com.topdraw.test.business.process.service;
2
3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.BaseTest;
5 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
6 import com.topdraw.business.process.service.UserOperationService;
7 import com.topdraw.module.mq.DataSyncMsg;
8 import com.topdraw.module.mq.EventType;
9 import org.junit.Test;
10 import org.springframework.beans.factory.annotation.Autowired;
11
12 public class UserOperationServiceTest extends BaseTest {
13
14 @Autowired
15 UserOperationService taskOperationService;
16
17 @Test
18 public void appletLogin() {
19 /* Long memberId = 3L;
20 DataSyncMsg dataSyncMsg = new DataSyncMsg();
21 // dataSyncMsg.setEntityType(EntityType.MEMBER);
22 dataSyncMsg.setEventType(EventType.LOGIN.name());
23 DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData();
24 msgData.setEvent(1);
25 msgData.setRemarks("remark");
26 msgData.setMemberId(memberId);
27 msgData.setDeviceType(2);
28
29 msgData.setAppCode("WEI_XIN_GOLD_PANDA");
30 dataSyncMsg.setMsg(msgData);
31
32 String s = JSON.toJSONString(dataSyncMsg);*/
33
34 WeiXinUserBean weiXinUserBean = new WeiXinUserBean();
35 weiXinUserBean.setWxAppid("1");
36 weiXinUserBean.setWxCode("1");
37 weiXinUserBean.setSourceType("1");
38 weiXinUserBean.setSourceId("1");
39 weiXinUserBean.setIv("1");
40 weiXinUserBean.setEncryptedData("1");
41 weiXinUserBean.setSourceEntity("1");
42 weiXinUserBean.setSourceDesc("1");
43 weiXinUserBean.setSourceUser(1L);
44 weiXinUserBean.setUserInfo("1");
45 this.taskOperationService.appletLogin(weiXinUserBean);
46 }
47
48 }
1 <?xml version="1.0" encoding="UTF-8"?>
2 <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3 <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
4 <output url="file://$MODULE_DIR$/target/classes" />
5 <output-test url="file://$MODULE_DIR$/target/test-classes" />
6 <content url="file://$MODULE_DIR$">
7 <excludeFolder url="file://$MODULE_DIR$/target" />
8 </content>
9 <orderEntry type="inheritedJdk" />
10 <orderEntry type="sourceFolder" forTests="false" />
11 </component>
12 </module>
...\ No newline at end of file ...\ No newline at end of file