Commit 8189259a 8189259af592c47545929f81786d211967df96e0 by xianghan

Merge branch '2.2.0-release'

# Conflicts:
#	.gitignore
#	member-service-impl/src/main/java/com/topdraw/business/module/member/domain/Member.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/repository/MemberRepository.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/service/impl/MemberServiceImpl.java
#	member-service-impl/src/main/java/com/topdraw/business/process/domian/constant/RightType.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/TaskOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/UserOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/service/impl/CouponOperationServiceImpl.java
#	member-service-impl/src/main/java/com/topdraw/business/process/service/impl/ExpOperationServiceImpl.java
#	member-service-impl/src/main/java/com/topdraw/business/process/service/impl/PointsOperationServiceImpl.java
#	member-service-impl/src/main/java/com/topdraw/business/process/service/impl/RightsOperationServiceImpl.java
#	member-service-impl/src/main/java/com/topdraw/business/process/service/impl/TaskOperationServiceImpl.java
#	member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
#	member-service-impl/src/main/java/com/topdraw/mq/module/mq/DataSyncMsg.java
#	member-service-impl/src/main/resources/config/application-dev.yml
#	member-service-impl/src/test/java/com/topdraw/test/business/process/rest/TaskOperationControllerTest.java
#	member-service-impl/src/test/java/com/topdraw/test/business/process/service/TaskOperationServiceTest.java
#	member-service-impl/src/test/java/com/topdraw/test/mq/MqTest.java
2 parents 7d0ef571 4fb34343
Showing 200 changed files with 2670 additions and 209 deletions
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
3 /logs/ 3 /logs/
4 /member-service-impl/target/ 4 /member-service-impl/target/
5 /member-service-api/target/ 5 /member-service-api/target/
6 member-service.iml 6 /.member-service.iml
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.topdraw.config; 1 package com.topdraw.business;
2 2
3 public class LocalConstants { 3 public class LocalConstants {
4 4
...@@ -28,4 +28,10 @@ public class LocalConstants { ...@@ -28,4 +28,10 @@ public class LocalConstants {
28 28
29 // 事件类型 3:参加活动 29 // 事件类型 3:参加活动
30 public static final Integer EVT_TYPE_ACTIVITY = 3; 30 public static final Integer EVT_TYPE_ACTIVITY = 3;
31
32
33
34
35 // 会员黑名单状态
36 public static final Long BLACK_STATUS = 1L;
31 } 37 }
......
1 package com.topdraw.business;
2
3 /**
4 * @author :
5 * @description:\
6 * @function :
7 * @date :Created in 2022/6/18 13:25
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/18 13:25
11 */
12 public interface RedisKeyConstants {
13 // 全量会员信息
14 String cacheMemberById = "uce::member::id";
15 // 任务处理时会员信息
16 String cacheMemberSimpleById = "uce::memberSimple::id";
17 String cacheMemberSimpleByCode = "uce::memberSimple::code";
18 // 会员全量信息
19 String cacheMemberByCode = "uce::member::code";
20
21 // 修改会员积分时的分布式锁
22 String updateCachePointsByMemberId = "uce::updatePoints::memberId";
23 // 修改会员成长值时的分布式锁
24 String updateCacheExpByMemberId = "uce::updateExp::memberId";
25 // 修改会员优惠券时的分布式锁
26 String updateCacheCouponByMemberId = "uce::updateCoupon::memberId";
27
28 // 全量大屏信息
29 String cacheUserTvByPlatformAccount = "uce::userTv::platformAccount";
30 String cacheVisUserByPlatformAccount = "uus::visUser";
31 // 会员已完成的任务进度
32 String cacheTaskProcessByMemberId = "uce::taskProcess::memberId";
33 // 任务模板类型对应的全量任务
34 String cacheTaskByEvent = "uce::task::event";
35 // 全量优惠券信息
36 String cacheCouponById = "uce::coupon::id";
37
38 // 权益全量信息
39 String cacheRightById = "uce::right::id";
40
41 // 会员可以做的任务
42 String cacheTaskByEventAndMemberLevelAndVip = "uce::task::eventAndMemberLevelAndVip";
43
44 // 全量会员等级
45 String cacheMemberLevelByLevel = "uce::memberLevel::level";
46
47 // 今天处理完成任务数量
48 String cacheTodayFinishTaskCount = "uce::todayCount::memberId";
49 // 历史完成的任务数量
50 String cacheTotalFinishTaskCount = "uce::totalCount::memberId";
51
52
53
54 String CACHE_PLATFROMACCOUNT_PLAYDURATION = "uce::eventPlay::playduration";
55
56
57 String CACHE_TODAY_FINISH_COUNT = "todayFinishCount";
58 String CACHE_TOTAL_FINISH_COUNT = "totalFinishCount";
59 }
1 package com.topdraw.business.module.coupon.service.impl; 1 package com.topdraw.business.module.coupon.service.impl;
2 2
3 import com.topdraw.business.module.coupon.domain.Coupon; 3 import com.topdraw.business.module.coupon.domain.Coupon;
4 import com.topdraw.business.RedisKeyConstants;
4 import com.topdraw.exception.GlobeExceptionMsg; 5 import com.topdraw.exception.GlobeExceptionMsg;
5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.module.coupon.repository.CouponRepository; 6 import com.topdraw.business.module.coupon.repository.CouponRepository;
7 import com.topdraw.business.module.coupon.service.CouponService; 7 import com.topdraw.business.module.coupon.service.CouponService;
8 import com.topdraw.business.module.coupon.service.dto.CouponDTO; 8 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
9 import com.topdraw.business.module.coupon.service.mapper.CouponMapper; 9 import com.topdraw.business.module.coupon.service.mapper.CouponMapper;
10 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.cache.annotation.Cacheable;
11 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
12 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
13 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
...@@ -30,9 +31,9 @@ public class CouponServiceImpl implements CouponService { ...@@ -30,9 +31,9 @@ public class CouponServiceImpl implements CouponService {
30 private CouponRepository couponRepository; 31 private CouponRepository couponRepository;
31 32
32 @Override 33 @Override
34 @Cacheable(cacheNames = RedisKeyConstants.cacheCouponById, key = "#id", unless = "#result.id == null")
33 public CouponDTO findById(Long id) { 35 public CouponDTO findById(Long id) {
34 Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL); 36 Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL);
35
36 Coupon coupon = this.couponRepository.findById(id).orElseGet(Coupon::new); 37 Coupon coupon = this.couponRepository.findById(id).orElseGet(Coupon::new);
37 // ValidationUtil.isNull(coupon.getId(),"Coupon","id",id); 38 // ValidationUtil.isNull(coupon.getId(),"Coupon","id",id);
38 return this.couponMapper.toDto(coupon); 39 return this.couponMapper.toDto(coupon);
......
...@@ -3,6 +3,9 @@ package com.topdraw.business.module.exp.detail.repository; ...@@ -3,6 +3,9 @@ package com.topdraw.business.module.exp.detail.repository;
3 import com.topdraw.business.module.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 import org.springframework.data.jpa.repository.Modifying;
7 import org.springframework.data.jpa.repository.Query;
8 import org.springframework.data.repository.query.Param;
6 9
7 import java.util.Optional; 10 import java.util.Optional;
8 11
...@@ -13,4 +16,15 @@ import java.util.Optional; ...@@ -13,4 +16,15 @@ import java.util.Optional;
13 public interface ExpDetailRepository extends JpaRepository<ExpDetail, Long>, JpaSpecificationExecutor<ExpDetail> { 16 public interface ExpDetailRepository extends JpaRepository<ExpDetail, Long>, JpaSpecificationExecutor<ExpDetail> {
14 17
15 Optional<ExpDetail> findFirstByCode(String code); 18 Optional<ExpDetail> findFirstByCode(String code);
19
20
21
22
23 @Modifying
24 @Query(value = "INSERT INTO `uc_exp_detail`(`code`, `member_id`, `account_id`, `original_exp`, `result_exp`, `exp`, " +
25 "`device_type`, `evt_type`, `order_id`, `media_id`, `activity_id`, `description`, `app_code`, `create_time`, `update_time`)\n" +
26 " VALUES (:#{#resources.code}, :#{#resources.memberId}, :#{#resources.accountId}, :#{#resources.originalExp}, " +
27 " :#{#resources.resultExp}, :#{#resources.exp}, :#{#resources.deviceType}, :#{#resources.evtType}, " +
28 " :#{#resources.orderId}, :#{#resources.mediaId}, :#{#resources.activityId}, '#', NULL, now(), now())", nativeQuery = true)
29 void insertIntoExpDetail(@Param("resources") ExpDetail expDetail);
16 } 30 }
......
...@@ -44,7 +44,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { ...@@ -44,7 +44,7 @@ public class ExpDetailServiceImpl implements ExpDetailService {
44 @Transactional(rollbackFor = Exception.class) 44 @Transactional(rollbackFor = Exception.class)
45 public void create(ExpDetail resources) { 45 public void create(ExpDetail resources) {
46 ExpDetail expDetail = ExpDetailBuilder.build(resources); 46 ExpDetail expDetail = ExpDetailBuilder.build(resources);
47 this.expDetailRepository.save(expDetail); 47 this.expDetailRepository.insertIntoExpDetail(expDetail);
48 } 48 }
49 49
50 @Override 50 @Override
......
...@@ -3,6 +3,7 @@ package com.topdraw.business.module.member.address.repository; ...@@ -3,6 +3,7 @@ package com.topdraw.business.module.member.address.repository;
3 import com.topdraw.business.module.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 import org.springframework.data.jpa.repository.Modifying;
6 import org.springframework.data.jpa.repository.Query; 7 import org.springframework.data.jpa.repository.Query;
7 8
8 /** 9 /**
...@@ -14,4 +15,12 @@ public interface MemberAddressRepository extends JpaRepository<MemberAddress, Lo ...@@ -14,4 +15,12 @@ public interface MemberAddressRepository extends JpaRepository<MemberAddress, Lo
14 @Query(value = "select IFNULL(max(sequence),0) from uc_member_address where member_id = ?1" , nativeQuery = true) 15 @Query(value = "select IFNULL(max(sequence),0) from uc_member_address where member_id = ?1" , nativeQuery = true)
15 int findMaxSequenceByMemberId(Long memberId); 16 int findMaxSequenceByMemberId(Long memberId);
16 17
18 @Modifying
19 @Query(value = "UPDATE `uc_member_address` SET `is_default` = 1, `update_time` = now() WHERE `id` = ?1", nativeQuery = true)
20 Integer updateDefaultMemberAddressById(Long id);
21
22 @Modifying
23 @Query(value = "UPDATE `uc_member_address` SET `is_default` = 0, `update_time` = now() WHERE `member_id` = ?1", nativeQuery = true)
24 Integer updateUnDefaultMemberAddressByMemberId(Long memberId);
25
17 } 26 }
......
...@@ -40,4 +40,8 @@ public interface MemberAddressService { ...@@ -40,4 +40,8 @@ public interface MemberAddressService {
40 * @return 40 * @return
41 */ 41 */
42 int findMaxSequenceByMemberId(Long memberId); 42 int findMaxSequenceByMemberId(Long memberId);
43
44 Integer updateDefaultMemberAddressById(Long id);
45
46 Integer updateUnDefaultMemberAddressByMemberId(Long memberId);
43 } 47 }
......
...@@ -105,6 +105,18 @@ public class MemberAddressServiceImpl implements MemberAddressService { ...@@ -105,6 +105,18 @@ public class MemberAddressServiceImpl implements MemberAddressService {
105 return this.memberAddressRepository.findMaxSequenceByMemberId(memberId); 105 return this.memberAddressRepository.findMaxSequenceByMemberId(memberId);
106 } 106 }
107 107
108 @Override
109 @Transactional(rollbackFor = Exception.class)
110 public Integer updateDefaultMemberAddressById(Long id) {
111 return this.memberAddressRepository.updateDefaultMemberAddressById(id);
112 }
113
114 @Override
115 @Transactional(rollbackFor = Exception.class)
116 public Integer updateUnDefaultMemberAddressByMemberId(Long memberId) {
117 return this.memberAddressRepository.updateUnDefaultMemberAddressByMemberId(memberId);
118 }
119
108 /** 120 /**
109 * 检查会员 121 * 检查会员
110 * @param memberAddress 122 * @param memberAddress
......
...@@ -44,7 +44,7 @@ public class Member implements Serializable { ...@@ -44,7 +44,7 @@ public class Member implements Serializable {
44 @Column(name = "code") 44 @Column(name = "code")
45 private String code; 45 private String code;
46 46
47 /** 类型 1:大屏;2:小屏 */ 47 /** 类型 1:大屏;2:小屏 3:app;*/
48 @Column(name = "`type`") 48 @Column(name = "`type`")
49 private Integer type; 49 private Integer type;
50 50
......
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.business.module.common.validated.UpdateGroup;
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 javax.validation.constraints.NotNull;
14 import java.io.Serializable;
15 import java.sql.Timestamp;
16
17 /**
18 * @author XiangHan
19 * @date 2021-10-22
20 */
21 @Entity
22 @Data
23 @EntityListeners(AuditingEntityListener.class)
24 @Accessors(chain = true)
25 @Table(name="uc_member")
26 public class MemberSimple implements Serializable {
27
28 /** 主键 */
29 @Id
30 @GeneratedValue(strategy = GenerationType.IDENTITY)
31 @Column(name = "id")
32 @NotNull(message = "id can't be null!!",groups = {UpdateGroup.class})
33 private Long id;
34
35 /** 标识 */
36 @Column(name = "code")
37 private String code;
38
39 /** 状态 0:不可用;1:可用 */
40 @Column(name = "`status`")
41 private Integer status;
42
43 /** 分组信息 */
44 @Column(name = "`groups`")
45 private String groups;
46
47 /** 是否会员 0:非会员;1:会员 */
48 @Column(name = "vip")
49 private Integer vip;
50
51 /** 会员等级(对应level表的level字段,非id) */
52 @Column(name = "`level`")
53 private Integer level;
54
55 /** iptv账号id */
56 @Column(name = "user_iptv_id")
57 private Long userIptvId;
58
59 /** 是否在黑名单 1:是;0否 */
60 @Column(name = "black_status")
61 private Long blackStatus;
62
63 public void copy(MemberSimple source){
64 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
65 }
66 }
1 package com.topdraw.business.module.member.domain;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/27 15:38
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/27 15:38
11 */
12 public interface MemberTypeConstant {
13
14 // 大屏
15 Integer vis = 1;
16 // 微信
17 Integer weixin = 2;
18 // app
19 Integer app = 3;
20 }
...@@ -15,5 +15,5 @@ public interface MemberLevelRepository extends JpaRepository<MemberLevel, Long>, ...@@ -15,5 +15,5 @@ public interface MemberLevelRepository extends JpaRepository<MemberLevel, Long>,
15 15
16 Optional<MemberLevel> findFirstByCode(String code); 16 Optional<MemberLevel> findFirstByCode(String code);
17 17
18 List<MemberLevel> findByLevelAndStatus(Integer level, Integer status); 18 Optional<MemberLevel> findByLevelAndStatus(Integer level, Integer status);
19 } 19 }
......
...@@ -25,12 +25,9 @@ public interface MemberLevelService { ...@@ -25,12 +25,9 @@ public interface MemberLevelService {
25 MemberLevelDTO getByCode(String code); 25 MemberLevelDTO getByCode(String code);
26 26
27 /** 27 /**
28 * 通过等级和状态检索 28 *
29 * @param i 29 * @param i
30 * @param status
31 * @return 30 * @return
32 */ 31 */
33 List<MemberLevelDTO> findLevelAndStatus(Integer i, Integer status); 32 MemberLevelDTO findByLevel(int i);
34
35
36 } 33 }
......
1 package com.topdraw.business.module.member.level.service.impl; 1 package com.topdraw.business.module.member.level.service.impl;
2 2
3 import com.topdraw.business.module.member.level.domain.MemberLevel; 3 import com.topdraw.business.module.member.level.domain.MemberLevel;
4 import com.topdraw.business.RedisKeyConstants;
4 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.business.module.member.level.repository.MemberLevelRepository; 6 import com.topdraw.business.module.member.level.repository.MemberLevelRepository;
6 import com.topdraw.business.module.member.level.service.MemberLevelService; 7 import com.topdraw.business.module.member.level.service.MemberLevelService;
7 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; 8 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
8 import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper; 9 import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper;
9 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.cache.annotation.Cacheable;
10 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
11 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
12 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
13 import com.topdraw.utils.StringUtils; 15 import com.topdraw.utils.StringUtils;
14 16
15 import java.util.List;
16
17 /** 17 /**
18 * @author XiangHan 18 * @author XiangHan
19 * @date 2021-10-22 19 * @date 2021-10-22
...@@ -29,6 +29,7 @@ public class MemberLevelServiceImpl implements MemberLevelService { ...@@ -29,6 +29,7 @@ public class MemberLevelServiceImpl implements MemberLevelService {
29 private MemberLevelMapper memberLevelMapper; 29 private MemberLevelMapper memberLevelMapper;
30 30
31 @Override 31 @Override
32 @Transactional(readOnly = true)
32 public MemberLevelDTO findById(Long id) { 33 public MemberLevelDTO findById(Long id) {
33 MemberLevel MemberLevel = this.memberLevelRepository.findById(id).orElseGet(MemberLevel::new); 34 MemberLevel MemberLevel = this.memberLevelRepository.findById(id).orElseGet(MemberLevel::new);
34 ValidationUtil.isNull(MemberLevel.getId(),"MemberLevel","id",id); 35 ValidationUtil.isNull(MemberLevel.getId(),"MemberLevel","id",id);
...@@ -36,14 +37,18 @@ public class MemberLevelServiceImpl implements MemberLevelService { ...@@ -36,14 +37,18 @@ public class MemberLevelServiceImpl implements MemberLevelService {
36 } 37 }
37 38
38 @Override 39 @Override
40 @Transactional(readOnly = true)
39 public MemberLevelDTO getByCode(String code) { 41 public MemberLevelDTO getByCode(String code) {
40 return StringUtils.isNotEmpty(code) ? this.memberLevelMapper.toDto(this.memberLevelRepository.findFirstByCode(code).orElseGet(MemberLevel::new)) 42 return StringUtils.isNotEmpty(code) ? this.memberLevelMapper.toDto(this.memberLevelRepository.findFirstByCode(code).orElseGet(MemberLevel::new))
41 : new MemberLevelDTO(); 43 : new MemberLevelDTO();
42 } 44 }
43 45
44 @Override 46 @Override
45 public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) { 47 @Transactional(readOnly = true)
46 return this.memberLevelMapper.toDto(this.memberLevelRepository.findByLevelAndStatus(level,status)); 48 @Cacheable(cacheNames = RedisKeyConstants.cacheMemberLevelByLevel, key = "#level", unless = "#result.id == null")
49 public MemberLevelDTO findByLevel(int level) {
50 MemberLevel memberLevel = this.memberLevelRepository.findByLevelAndStatus(level, 1).orElseGet(MemberLevel::new);
51 return this.memberLevelMapper.toDto(memberLevel);
47 } 52 }
48 53
49 } 54 }
......
...@@ -7,7 +7,6 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; ...@@ -7,7 +7,6 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
7 import com.topdraw.business.process.service.member.MemberProfileOperationService; 7 import com.topdraw.business.process.service.member.MemberProfileOperationService;
8 import com.topdraw.common.ResultInfo; 8 import com.topdraw.common.ResultInfo;
9 import com.topdraw.business.module.member.profile.domain.MemberProfile; 9 import com.topdraw.business.module.member.profile.domain.MemberProfile;
10 import com.topdraw.business.module.member.profile.service.MemberProfileService;
11 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
12 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.validation.annotation.Validated; 12 import org.springframework.validation.annotation.Validated;
...@@ -32,10 +31,8 @@ public class MemberProfileController { ...@@ -32,10 +31,8 @@ public class MemberProfileController {
32 @RequestMapping(value = "/update") 31 @RequestMapping(value = "/update")
33 @ApiOperation("修改会员属性") 32 @ApiOperation("修改会员属性")
34 @AnonymousAccess 33 @AnonymousAccess
35 @Deprecated
36 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberProfile resources) { 34 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberProfile resources) {
37 35 log.info("memberProfile ==>> update ==>> resources ===>> {}",resources);
38 log.info("memberProfile ==>> update ==>> resources ===>> [{}]",resources);
39 MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); 36 MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources);
40 return ResultInfo.success(memberProfileDTO); 37 return ResultInfo.success(memberProfileDTO);
41 } 38 }
...@@ -44,8 +41,7 @@ public class MemberProfileController { ...@@ -44,8 +41,7 @@ public class MemberProfileController {
44 @ApiOperation("修改会员属性并同步会员信息") 41 @ApiOperation("修改会员属性并同步会员信息")
45 @AnonymousAccess 42 @AnonymousAccess
46 public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) { 43 public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) {
47 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); 44 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> {}",resources);
48
49 MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); 45 MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources);
50 return ResultInfo.success(memberProfileDTO); 46 return ResultInfo.success(memberProfileDTO);
51 } 47 }
...@@ -55,9 +51,7 @@ public class MemberProfileController { ...@@ -55,9 +51,7 @@ public class MemberProfileController {
55 @AnonymousAccess 51 @AnonymousAccess
56 @Deprecated 52 @Deprecated
57 public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberProfile resources) { 53 public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberProfile resources) {
58 54 log.info("memberProfile ==>> update ==>> resources ===>> {}",resources);
59 log.info("memberProfile ==>> update ==>> resources ===>> [{}]",resources);
60
61 MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.createMemberProfileAndSyncMember(resources); 55 MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.createMemberProfileAndSyncMember(resources);
62 return ResultInfo.success(memberProfileDTO); 56 return ResultInfo.success(memberProfileDTO);
63 } 57 }
......
...@@ -6,6 +6,7 @@ import com.topdraw.business.module.member.profile.domain.MemberProfileBuilder; ...@@ -6,6 +6,7 @@ import com.topdraw.business.module.member.profile.domain.MemberProfileBuilder;
6 import com.topdraw.business.module.member.service.MemberService; 6 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.module.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.util.Base64Util; 8 import com.topdraw.util.Base64Util;
9 import com.topdraw.util.RegexUtil;
9 import com.topdraw.utils.RedisUtils; 10 import com.topdraw.utils.RedisUtils;
10 import com.topdraw.utils.ValidationUtil; 11 import com.topdraw.utils.ValidationUtil;
11 import com.topdraw.business.module.member.profile.repository.MemberProfileRepository; 12 import com.topdraw.business.module.member.profile.repository.MemberProfileRepository;
...@@ -141,6 +142,13 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -141,6 +142,13 @@ public class MemberProfileServiceImpl implements MemberProfileService {
141 memberProfile.setGender(_memberProfileDTO1.getGender()); 142 memberProfile.setGender(_memberProfileDTO1.getGender());
142 } 143 }
143 144
145 String phone = resources.getPhone();
146 if (StringUtils.isNotBlank(phone) && RegexUtil.mobileRegex(phone)) {
147 memberProfile.setPhone(phone);
148 } else {
149 memberProfile.setPhone(_memberProfileDTO1.getPhone());
150 }
151
144 MemberProfile _memberProfile = this.memberProfileRepository.save(memberProfile); 152 MemberProfile _memberProfile = this.memberProfileRepository.save(memberProfile);
145 153
146 MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); 154 MemberProfileDTO memberProfileDTO = new MemberProfileDTO();
...@@ -171,31 +179,35 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -171,31 +179,35 @@ public class MemberProfileServiceImpl implements MemberProfileService {
171 log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources); 179 log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources);
172 MemberProfileDTO memberProfileDTO = this.update(resources); 180 MemberProfileDTO memberProfileDTO = this.update(resources);
173 // 同步会员信息 181 // 同步会员信息
174 this.synchronizedMemberData(resources, memberDTO);
175 return memberProfileDTO;
176 }
177
178 private void synchronizedMemberData(MemberProfile resources, MemberDTO memberDTO) {
179 182
180 log.info("updateMemberProfileAndMember ==>> resources ==>> [{}]",resources); 183 log.info("updateMemberProfileAndMember ==>> resources ==>> [{}]",memberProfileDTO);
181 184
182 memberDTO.setId(resources.getMemberId()); 185 Member member = new Member();
183 if(StringUtils.isNotBlank(resources.getRealname())) { 186 member.setId(memberDTO.getId());
184 memberDTO.setNickname(resources.getRealname()); 187 member.setCode(memberDTO.getCode());
188 if(StringUtils.isNotBlank(memberProfileDTO.getRealname())) {
189 member.setNickname(memberProfileDTO.getRealname());
190 } else {
191 member.setNickname(memberDTO.getNickname());
185 } 192 }
186 if(Objects.nonNull(resources.getGender()) && resources.getGender() != -1) { 193 if(Objects.nonNull(memberProfileDTO.getGender()) && memberProfileDTO.getGender() != -1) {
187 memberDTO.setGender(resources.getGender()); 194 member.setGender(memberProfileDTO.getGender());
195 } else {
196 member.setGender(memberDTO.getGender());
188 } 197 }
189 if(StringUtils.isNotBlank(resources.getBirthday())) { 198 if(StringUtils.isNotBlank(memberProfileDTO.getBirthday())) {
190 memberDTO.setBirthday(resources.getBirthday()); 199 member.setBirthday(memberProfileDTO.getBirthday());
200 } else {
201 member.setBirthday(memberDTO.getBirthday());
191 } 202 }
192 if(StringUtils.isNotBlank(resources.getAvatarUrl())) { 203 if(StringUtils.isNotBlank(resources.getAvatarUrl())) {
193 memberDTO.setAvatarUrl(resources.getAvatarUrl()); 204 member.setAvatarUrl(resources.getAvatarUrl());
205 } else {
206 member.setAvatarUrl(memberDTO.getAvatarUrl());
194 } 207 }
208 this.memberService.doUpdateMemberAvatarUrlAndNicknameAndGender(member);
195 209
196 Member member = new Member(); 210 return memberProfileDTO;
197 BeanUtils.copyProperties(memberDTO,member);
198
199 this.memberService.update(member);
200 } 211 }
212
201 } 213 }
......
1 package com.topdraw.business.module.member.repository; 1 package com.topdraw.business.module.member.repository;
2 2
3 import com.topdraw.business.module.member.domain.Member; 3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.domain.MemberSimple;
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 import org.springframework.data.jpa.repository.Modifying; 7 import org.springframework.data.jpa.repository.Modifying;
...@@ -10,6 +11,7 @@ import org.springframework.data.repository.query.Param; ...@@ -10,6 +11,7 @@ import org.springframework.data.repository.query.Param;
10 import java.time.LocalDateTime; 11 import java.time.LocalDateTime;
11 import java.util.List; 12 import java.util.List;
12 import java.util.Optional; 13 import java.util.Optional;
14 import java.util.Set;
13 15
14 /** 16 /**
15 * @author XiangHan 17 * @author XiangHan
...@@ -23,7 +25,6 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif ...@@ -23,7 +25,6 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif
23 25
24 Optional<Member> findByIdOrCode(Long id,String code); 26 Optional<Member> findByIdOrCode(Long id,String code);
25 27
26
27 @Modifying 28 @Modifying
28 @Query(value = "UPDATE `uc_member` SET `user_iptv_id` = ?2, `update_time` = ?3 , `bind_iptv_platform_type`= 0, " + 29 @Query(value = "UPDATE `uc_member` SET `user_iptv_id` = ?2, `update_time` = ?3 , `bind_iptv_platform_type`= 0, " +
29 "`bind_iptv_time`=?3 WHERE `id` = ?1", nativeQuery = true) 30 "`bind_iptv_time`=?3 WHERE `id` = ?1", nativeQuery = true)
...@@ -32,15 +33,40 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif ...@@ -32,15 +33,40 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif
32 @Modifying 33 @Modifying
33 @Query(value = "UPDATE `uc_member` SET `exp` = :#{#resources.exp}, `level` = :#{#resources.level} , `update_time`= now() " + 34 @Query(value = "UPDATE `uc_member` SET `exp` = :#{#resources.exp}, `level` = :#{#resources.level} , `update_time`= now() " +
34 " WHERE `id` = :#{#resources.id}", nativeQuery = true) 35 " WHERE `id` = :#{#resources.id}", nativeQuery = true)
35 void updateExpAndLevel(@Param("resources") Member member); 36 Integer updateExpAndLevel(@Param("resources") Member member);
36 37
37 @Modifying 38 @Modifying
38 @Query(value = "UPDATE `uc_member` SET `points` = :#{#resources.points}, `due_points` = :#{#resources.duePoints} , `update_time`= now() " + 39 @Query(value = "UPDATE `uc_member` SET `points` = :#{#resources.points}, `update_time`= now() WHERE `id` = :#{#resources.id}", nativeQuery = true)
39 " WHERE `id` = :#{#resources.id}", nativeQuery = true) 40 Integer updatePointAndDuePoint(@Param("resources") Member resources);
40 void updatePointAndDuePoint(@Param("resources") Member resources);
41 41
42 @Modifying 42 @Modifying
43 @Query(value = "UPDATE `uc_member` SET `coupon_amount` = :#{#resources.couponAmount}, `due_coupon_amount` = :#{#resources.dueCouponAmount} , `update_time`= now() " + 43 @Query(value = "UPDATE `uc_member` SET `coupon_amount` = :#{#resources.couponAmount}, `due_coupon_amount` = :#{#resources.dueCouponAmount} , `update_time`= now() " +
44 " WHERE `id` = :#{#resources.id}", nativeQuery = true) 44 " WHERE `id` = :#{#resources.id}", nativeQuery = true)
45 void doUpdateMemberCoupon(@Param("resources") Member member); 45 Integer doUpdateMemberCoupon(@Param("resources") Member member);
46
47 @Query(value = "SELECT um.* FROM uc_member um LEFT JOIN uc_user_tv tv ON um.id = tv.member_id " +
48 " WHERE tv.platform_account = ?1 ", nativeQuery = true)
49 Optional<Member> findByPlatformAccount(String platformAccount);
50
51 @Modifying
52 @Query(value = "UPDATE `uc_member` SET `vip` = :#{#resources.vip}, `vip_expire_time` = :#{#resources.vipExpireTime} , `update_time`= now() " +
53 " WHERE `id` = :#{#resources.id}", nativeQuery = true)
54 Integer updateMemberVipAndVipExpireTime(@Param("resources") Member member);
55
56 @Modifying
57 @Query(value = "UPDATE `uc_member` SET `user_iptv_id` = :#{#resources.userIptvId}, `update_time` = now() , `bind_iptv_platform_type`= :#{#resources.bindIptvPlatformType}, " +
58 " `bind_iptv_time`=:#{#resources.bindIptvTime} WHERE `id` = :#{#resources.id}", nativeQuery = true)
59 Integer updateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(@Param("resources") Member member);
60
61 @Modifying
62 @Query(value = "UPDATE `uc_member` SET `avatar_url` = :#{#resources.avatarUrl}, `update_time` = now() , `nickname`= :#{#resources.nickname}, " +
63 " `gender`=:#{#resources.gender} WHERE `id` = :#{#resources.id}", nativeQuery = true)
64 Integer updateMemberAvatarUrlAndNicknameAndGender(@Param("resources") Member resource);
65
66 @Query(value = "SELECT IFNULL(`exp`,0) AS exp FROM uc_member WHERE `id` = ?1 ", nativeQuery = true)
67 Long findExpByMemberId(Long memberId);
68
69 @Modifying
70 @Query(value = "UPDATE `uc_member` SET `groups` = ?1, `update_time` = now() WHERE `code` IN ?2 ", nativeQuery = true)
71 Integer doUpdateGroupsBatch(String groups, Set<String> codes);
46 } 72 }
......
1 package com.topdraw.business.module.member.repository;
2
3 import com.topdraw.business.module.member.domain.MemberSimple;
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.util.Optional;
9
10 /**
11 * @author XiangHan
12 * @date 2021-10-22
13 */
14 public interface MemberSimpleRepository extends JpaRepository<MemberSimple, Long>, JpaSpecificationExecutor<MemberSimple> {
15
16 @Query(value = "SELECT `id`, `code`, `status`, `groups`, `vip`, `level`,`user_iptv_id`, `black_status` FROM `uc_member` WHERE `id` = ?1", nativeQuery = true)
17 Optional<MemberSimple> findSimpleById(Long id);
18
19 @Query(value = "SELECT `id`, `code`, `status`, `groups`, `vip`, `level`,`user_iptv_id`, `black_status` FROM `uc_member` WHERE `code` = ?1", nativeQuery = true)
20 Optional<MemberSimple> findSimpleByCode(String code);
21 }
...@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.validation.annotation.Validated; 18 import org.springframework.validation.annotation.Validated;
19 import org.springframework.web.bind.annotation.*; 19 import org.springframework.web.bind.annotation.*;
20 20
21 import java.util.List;
21 import java.util.Objects; 22 import java.util.Objects;
22 23
23 /** 24 /**
...@@ -52,11 +53,22 @@ public class MemberController { ...@@ -52,11 +53,22 @@ public class MemberController {
52 @AnonymousAccess 53 @AnonymousAccess
53 @ApiOperation("手动修改vip") 54 @ApiOperation("手动修改vip")
54 public ResultInfo doUpdateVipByCode(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) { 55 public ResultInfo doUpdateVipByCode(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) {
55 log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); 56 log.info("member ==>> doUpdateVipByCode ==>> param ==>> {}",resources);
56 this.memberOperationService.updateMemberVip(resources); 57 this.memberOperationService.doUpdateMemberVipAndVipExpireTime(resources);
57 return ResultInfo.success(); 58 return ResultInfo.success();
58 } 59 }
59 60
61
62 @RequestMapping(value = "/doUpdateGroupsBatch")
63 @AnonymousAccess
64 @ApiOperation("批量手动修改会员分组")
65 public ResultInfo doUpdateGroupsBatch(@Validated(value = {UpdateGroup.class}) @RequestBody List<Member> resources) {
66 log.info("doUpdateGroupsBatch ==>> param ==>> {}",resources);
67 Integer count = this.memberOperationService.doUpdateGroupsBatch(resources);
68 return ResultInfo.success(count);
69 }
70
71
60 @PutMapping(value = "/update") 72 @PutMapping(value = "/update")
61 @ApiOperation("修改会员信息") 73 @ApiOperation("修改会员信息")
62 @AnonymousAccess 74 @AnonymousAccess
...@@ -67,7 +79,6 @@ public class MemberController { ...@@ -67,7 +79,6 @@ public class MemberController {
67 if (StringUtils.isNotBlank(code)) { 79 if (StringUtils.isNotBlank(code)) {
68 MemberDTO memberDTO = this.memberOperationService.findByCode(code); 80 MemberDTO memberDTO = this.memberOperationService.findByCode(code);
69 resources.setId(memberDTO.getId()); 81 resources.setId(memberDTO.getId());
70 // BeanUtils.copyProperties(resources, memberDTO);
71 } 82 }
72 83
73 MemberDTO memberDTO = this.memberOperationService.update(resources); 84 MemberDTO memberDTO = this.memberOperationService.update(resources);
......
...@@ -2,6 +2,8 @@ package com.topdraw.business.module.member.service; ...@@ -2,6 +2,8 @@ package com.topdraw.business.module.member.service;
2 2
3 import com.topdraw.business.module.member.domain.Member; 3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.service.dto.MemberDTO; 4 import com.topdraw.business.module.member.service.dto.MemberDTO;
5 import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
6 import org.springframework.transaction.annotation.Transactional;
5 7
6 import java.util.List; 8 import java.util.List;
7 9
...@@ -26,6 +28,13 @@ public interface MemberService { ...@@ -26,6 +28,13 @@ public interface MemberService {
26 MemberDTO findById(Long id); 28 MemberDTO findById(Long id);
27 29
28 /** 30 /**
31 *
32 * @param id
33 * @return
34 */
35 MemberSimpleDTO findSimpleById(Long id);
36
37 /**
29 * 通过code查询会员 38 * 通过code查询会员
30 * @param code 会员编码 39 * @param code 会员编码
31 * @return MemberDTO 40 * @return MemberDTO
...@@ -33,6 +42,13 @@ public interface MemberService { ...@@ -33,6 +42,13 @@ public interface MemberService {
33 MemberDTO findByCode(String code); 42 MemberDTO findByCode(String code);
34 43
35 /** 44 /**
45 *
46 * @param code
47 * @return
48 */
49 MemberSimpleDTO findSimpleByCode(String code);
50
51 /**
36 * 保存 52 * 保存
37 * @param resources 53 * @param resources
38 * @return Long id 54 * @return Long id
...@@ -40,13 +56,6 @@ public interface MemberService { ...@@ -40,13 +56,6 @@ public interface MemberService {
40 MemberDTO create(Member resources); 56 MemberDTO create(Member resources);
41 57
42 /** 58 /**
43 * 创建并返回会员
44 * @param resources 会员
45 * @return Member
46 */
47 MemberDTO createAndReturnMember(Member resources);
48
49 /**
50 * 修改会员 59 * 修改会员
51 * @param resources 60 * @param resources
52 */ 61 */
...@@ -56,7 +65,7 @@ public interface MemberService { ...@@ -56,7 +65,7 @@ public interface MemberService {
56 * 修改会员积分 65 * 修改会员积分
57 * @param member 会员 66 * @param member 会员
58 */ 67 */
59 MemberDTO doUpdateMemberPoints(Member member); 68 Integer doUpdateMemberPoints(Member member);
60 69
61 /** 70 /**
62 * 查询绑定了大屏会员列表 71 * 查询绑定了大屏会员列表
...@@ -83,12 +92,53 @@ public interface MemberService { ...@@ -83,12 +92,53 @@ public interface MemberService {
83 * @param resources 92 * @param resources
84 * @return 93 * @return
85 */ 94 */
86 MemberDTO doUpdateMemberExpAndLevel(Member resources); 95 Integer doUpdateMemberExpAndLevel(Member resources);
87 96
88 /** 97 /**
89 * 98 *
90 * @param member 99 * @param member
91 * @return 100 * @return
92 */ 101 */
93 MemberDTO doUpdateMemberCoupon(Member member); 102 Integer doUpdateMemberCoupon(Member member);
103
104 /**
105 *
106 * @param platformAccount
107 * @return
108 */
109 MemberDTO findByPlatformAccount(String platformAccount);
110
111 /**
112 *
113 * @param member
114 * @return
115 */
116 MemberDTO doUpdateMemberVipAndVipExpireTime(Member member);
117
118 /**
119 *
120 * @param member
121 * @return
122 */
123 MemberDTO doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(Member member);
124
125 /**
126 *
127 * @param member
128 */
129 MemberDTO doUpdateMemberAvatarUrlAndNicknameAndGender(Member member);
130
131 /**
132 *
133 * @param memberId
134 * @return
135 */
136 Long findExpByMemberId(Long memberId);
137
138 /**
139 *
140 * @param resources
141 * @return
142 */
143 Integer doUpdateGroupsBatch(List<Member> resources);
94 } 144 }
......
1 package com.topdraw.business.module.member.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6 import java.sql.Timestamp;
7
8
9 /**
10 * @author XiangHan
11 * @date 2021-10-22
12 */
13 @Data
14 public class MemberSimpleDTO implements Serializable {
15
16 /** 主键 */
17 private Long id;
18
19 /** 标识 */
20 private String code;
21
22 /** 昵称 */
23 private String nickname;
24
25 /** 状态 0:不可用;1:可用 */
26 private Integer status;
27
28 /** 分组信息 */
29 private String groups;
30
31 /** 是否会员 0:非会员;1:会员 */
32 private Integer vip;
33
34 /** vip过期时间 */
35 private Timestamp vipExpireTime;
36
37 /** 会员等级(对应level表的level字段,非id) */
38 private Integer level;
39
40 /** iptv账号id */
41 private Long userIptvId;
42
43 /** 是否在黑名单 1:是;0否 */
44 private Long blackStatus;
45
46 }
1 package com.topdraw.business.module.member.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.member.domain.MemberSimple;
5 import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author XiangHan
11 * @date 2021-10-22
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface MemberSimpleMapper extends BaseMapper<MemberSimpleDTO, MemberSimple> {
15
16 }
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.process.service.member.MemberOperationService;
5 import com.topdraw.common.ResultInfo;
6 import io.swagger.annotations.Api;
7 import io.swagger.annotations.ApiOperation;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.validation.annotation.Validated;
10 import org.springframework.web.bind.annotation.*;
11
12 /**
13 * @author luerlong
14 * @date 2021-12-10
15 */
16 @Api(tags = "会员vip历史管理")
17 @RestController
18 @RequestMapping("/uce/memberVipHistory")
19 public class MemberVipHistoryController {
20
21 @Autowired
22 private MemberOperationService memberOperationService;
23
24 @PostMapping
25 @ApiOperation("新增MemberVipHistory")
26 public ResultInfo create(@Validated @RequestBody MemberVipHistory resources) {
27 this.memberOperationService.createVipHistory(resources);
28 return ResultInfo.success();
29 }
30
31 }
...@@ -24,7 +24,7 @@ public interface MemberVipHistoryService { ...@@ -24,7 +24,7 @@ public interface MemberVipHistoryService {
24 * 24 *
25 * @param resources 25 * @param resources
26 */ 26 */
27 void create(MemberVipHistory resources); 27 MemberVipHistoryDTO create(MemberVipHistory resources);
28 28
29 /** 29 /**
30 * 30 *
......
...@@ -52,15 +52,14 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService { ...@@ -52,15 +52,14 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
52 52
53 @Override 53 @Override
54 @Transactional(rollbackFor = Exception.class) 54 @Transactional(rollbackFor = Exception.class)
55 @AsyncMqSend 55 public MemberVipHistoryDTO create(MemberVipHistory resources) {
56 public void create(MemberVipHistory resources) {
57 log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources); 56 log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources);
58 MemberDTO memberDTO = this.checkMember(resources); 57 MemberDTO memberDTO = this.checkMember(resources);
59 58
60 MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(resources); 59 MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(resources);
61 MemberVipHistory vipHistory = this.memberVipHistoryRepository.save(memberVipHistory); 60 MemberVipHistory vipHistory = this.memberVipHistoryRepository.save(memberVipHistory);
62 vipHistory.setMemberCode(memberDTO.getCode()); 61 vipHistory.setMemberCode(memberDTO.getCode());
63 62 return this.memberVipHistoryMapper.toDto(vipHistory);
64 } 63 }
65 64
66 @Override 65 @Override
......
...@@ -101,5 +101,5 @@ public interface PointsAvailableService { ...@@ -101,5 +101,5 @@ public interface PointsAvailableService {
101 * 101 *
102 * @param pointsAvailable 102 * @param pointsAvailable
103 */ 103 */
104 PointsAvailableDTO create4Custom(PointsAvailable pointsAvailable); 104 void create4Custom(PointsAvailable pointsAvailable);
105 } 105 }
......
...@@ -160,17 +160,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { ...@@ -160,17 +160,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
160 } 160 }
161 161
162 @Override 162 @Override
163 public PointsAvailableDTO create4Custom(PointsAvailable resources) { 163 public void create4Custom(PointsAvailable resources) {
164 this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); 164 this.pointsAvailableRepository.save(resources);
165 try {
166 PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources);
167 return this.pointsAvailableMapper.toDto(pointsAvailable);
168 } catch (Exception e) {
169 e.printStackTrace();
170 throw e;
171 } finally {
172 this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString());
173 }
174 } 165 }
175 166
176 } 167 }
......
...@@ -88,6 +88,10 @@ public class PointsDetail implements Serializable { ...@@ -88,6 +88,10 @@ public class PointsDetail implements Serializable {
88 @Column(name = "item_id") 88 @Column(name = "item_id")
89 private Long itemId; 89 private Long itemId;
90 90
91 // 状态:0:异常;1:正常
92 @Column(name = "status")
93 private Long status;
94
91 // 创建时间 95 // 创建时间
92 @CreatedDate 96 @CreatedDate
93 @Column(name = "create_time") 97 @Column(name = "create_time")
......
...@@ -3,6 +3,9 @@ package com.topdraw.business.module.points.detail.repository; ...@@ -3,6 +3,9 @@ package com.topdraw.business.module.points.detail.repository;
3 import com.topdraw.business.module.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 import org.springframework.data.jpa.repository.Modifying;
7 import org.springframework.data.jpa.repository.Query;
8 import org.springframework.data.repository.query.Param;
6 9
7 import java.util.List; 10 import java.util.List;
8 import java.util.Optional; 11 import java.util.Optional;
...@@ -16,4 +19,14 @@ public interface PointsDetailRepository extends JpaRepository<PointsDetail, Long ...@@ -16,4 +19,14 @@ public interface PointsDetailRepository extends JpaRepository<PointsDetail, Long
16 Optional<PointsDetail> findFirstByCode(String code); 19 Optional<PointsDetail> findFirstByCode(String code);
17 20
18 List<PointsDetail> findByMemberId(Long memberId); 21 List<PointsDetail> findByMemberId(Long memberId);
22
23
24 @Modifying
25 @Query(value = "INSERT INTO `uc_points_detail`(`code`, `app_code`, `member_id`, `account_id`, `original_points`, `result_points`, " +
26 " `points`, `device_type`, `evt_type`, `order_id`, `media_id`, `activity_id`, `item_id`, `status`, `description`, `create_time`, `update_time`)" +
27 " VALUES (:#{#resources.code}, :#{#resources.appCode}, :#{#resources.memberId}, :#{#resources.accountId}," +
28 " :#{#resources.originalPoints}, :#{#resources.resultPoints}, :#{#resources.points}, :#{#resources.deviceType}," +
29 " :#{#resources.evtType}, :#{#resources.orderId}, :#{#resources.mediaId}, :#{#resources.activityId}, " +
30 " :#{#resources.itemId}, :#{#resources.status}, :#{#resources.description}, now(), now())", nativeQuery = true)
31 Integer insertPointsDetail(@Param("resources") PointsDetail pointsDetail);
19 } 32 }
......
...@@ -46,13 +46,6 @@ public interface PointsDetailService { ...@@ -46,13 +46,6 @@ public interface PointsDetailService {
46 PointsDetailDTO getByCode(String code); 46 PointsDetailDTO getByCode(String code);
47 47
48 /** 48 /**
49 *
50 * @param memberId
51 * @return
52 */
53 List<PointsDetailDTO> loadListExpirePointsByMemberId(Long memberId);
54
55 /**
56 * 已过期的积分 49 * 已过期的积分
57 * @param memberId 50 * @param memberId
58 * @return 51 * @return
...@@ -63,5 +56,5 @@ public interface PointsDetailService { ...@@ -63,5 +56,5 @@ public interface PointsDetailService {
63 * 56 *
64 * @param pointsDetail 57 * @param pointsDetail
65 */ 58 */
66 void create4Custom(PointsDetail pointsDetail); 59 void insertPointsDetail(PointsDetail pointsDetail);
67 } 60 }
......
...@@ -54,6 +54,9 @@ public class PointsDetailDTO implements Serializable { ...@@ -54,6 +54,9 @@ public class PointsDetailDTO implements Serializable {
54 // 积分变化描述,用于管理侧显示 54 // 积分变化描述,用于管理侧显示
55 private String description; 55 private String description;
56 56
57 // 状态:0:异常;1:正常
58 private Long status;
59
57 // 商品id 60 // 商品id
58 private Long itemId; 61 private Long itemId;
59 62
......
...@@ -31,6 +31,7 @@ public class PointsDetailServiceImpl implements PointsDetailService { ...@@ -31,6 +31,7 @@ public class PointsDetailServiceImpl implements PointsDetailService {
31 private PointsDetailMapper pointsDetailMapper; 31 private PointsDetailMapper pointsDetailMapper;
32 32
33 @Override 33 @Override
34 @Transactional(readOnly = true)
34 public PointsDetailDTO findById(Long id) { 35 public PointsDetailDTO findById(Long id) {
35 PointsDetail pointsDetail = this.pointsDetailRepository.findById(id).orElseGet(PointsDetail::new); 36 PointsDetail pointsDetail = this.pointsDetailRepository.findById(id).orElseGet(PointsDetail::new);
36 ValidationUtil.isNull(pointsDetail.getId(),"PointsDetail","id",id); 37 ValidationUtil.isNull(pointsDetail.getId(),"PointsDetail","id",id);
...@@ -40,8 +41,7 @@ public class PointsDetailServiceImpl implements PointsDetailService { ...@@ -40,8 +41,7 @@ public class PointsDetailServiceImpl implements PointsDetailService {
40 @Override 41 @Override
41 @Transactional(rollbackFor = Exception.class) 42 @Transactional(rollbackFor = Exception.class)
42 public PointsDetailDTO create(PointsDetail resources) { 43 public PointsDetailDTO create(PointsDetail resources) {
43 PointsDetail pointsDetail = this.pointsDetailRepository.save(resources); 44 return this.pointsDetailMapper.toDto(this.pointsDetailRepository.save(resources));
44 return this.pointsDetailMapper.toDto(pointsDetail);
45 } 45 }
46 46
47 @Override 47 @Override
...@@ -65,17 +65,14 @@ public class PointsDetailServiceImpl implements PointsDetailService { ...@@ -65,17 +65,14 @@ public class PointsDetailServiceImpl implements PointsDetailService {
65 65
66 66
67 @Override 67 @Override
68 @Transactional(readOnly = true)
68 public PointsDetailDTO getByCode(String code) { 69 public PointsDetailDTO getByCode(String code) {
69 return StringUtils.isNotEmpty(code) ? this.pointsDetailMapper.toDto(this.pointsDetailRepository.findFirstByCode(code).orElseGet(PointsDetail::new)) 70 return StringUtils.isNotEmpty(code) ? this.pointsDetailMapper.toDto(this.pointsDetailRepository.findFirstByCode(code).orElseGet(PointsDetail::new))
70 : new PointsDetailDTO(); 71 : new PointsDetailDTO();
71 } 72 }
72 73
73 @Override 74 @Override
74 public List<PointsDetailDTO> loadListExpirePointsByMemberId(Long memberId) { 75 @Transactional(readOnly = true)
75 return null;
76 }
77
78 @Override
79 public List<PointsDetailDTO> findByMemberId(Long memberId) { 76 public List<PointsDetailDTO> findByMemberId(Long memberId) {
80 return Objects.nonNull(memberId)? 77 return Objects.nonNull(memberId)?
81 this.pointsDetailMapper.toDto(this.pointsDetailRepository.findByMemberId(memberId)) 78 this.pointsDetailMapper.toDto(this.pointsDetailRepository.findByMemberId(memberId))
...@@ -83,7 +80,8 @@ public class PointsDetailServiceImpl implements PointsDetailService { ...@@ -83,7 +80,8 @@ public class PointsDetailServiceImpl implements PointsDetailService {
83 } 80 }
84 81
85 @Override 82 @Override
86 public void create4Custom(PointsDetail pointsDetail) { 83 @Transactional(rollbackFor = Exception.class)
87 this.pointsDetailRepository.save(pointsDetail); 84 public void insertPointsDetail(PointsDetail pointsDetail) {
85 this.pointsDetailRepository.insertPointsDetail(pointsDetail);
88 } 86 }
89 } 87 }
......
1 package com.topdraw.business.process.domian.constant; 1 package com.topdraw.business.module.rights.constant;
2 2
3 public enum RightType { 3 public enum RightType {
4 /**积分*/ 4 /**积分*/
......
1 package com.topdraw.business.module.rights.constant;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/18 16:06
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/18 16:06
11 */
12 public interface RightTypeConstants {
13
14 // 优惠券
15 int DISCOUNT_COUPON = 1;
16 // 观影券
17 int VIEW_COUPON= 2;
18 // 参加活动
19 int JOIN_ACTIVITY = 3;
20 // 积分商品
21 int POINTS_GOODS = 4;
22 // IPTV产品包
23 int IPTV_PRODUCT = 5;
24 // IPTV观影权益
25 int IPTV_VIEW = 6;
26
27 }
1 package com.topdraw.business.module.rights.constant;
2
3 public class RightsType {
4
5 public static String TYPE_1 = "1";
6 Integer TYPE_2 = 2;
7 Integer TYPE_3 = 3;
8
9 }
...@@ -47,7 +47,7 @@ public class Rights implements Serializable { ...@@ -47,7 +47,7 @@ public class Rights implements Serializable {
47 47
48 /** 权益的实体类型 1:积分;2成长值;3优惠券 */ 48 /** 权益的实体类型 1:积分;2成长值;3优惠券 */
49 @Column(name = "entity_type", nullable = false) 49 @Column(name = "entity_type", nullable = false)
50 private String entityType; 50 private Integer entityType;
51 51
52 /** 实体id */ 52 /** 实体id */
53 @Column(name = "entity_id", nullable = false) 53 @Column(name = "entity_id", nullable = false)
......
...@@ -28,7 +28,7 @@ public class RightsDTO implements Serializable { ...@@ -28,7 +28,7 @@ public class RightsDTO implements Serializable {
28 private Integer type; 28 private Integer type;
29 29
30 /** 权益的实体类型 1:积分;2成长值;3优惠券 */ 30 /** 权益的实体类型 1:积分;2成长值;3优惠券 */
31 private String entityType; 31 private Integer entityType;
32 32
33 /** 实体id */ 33 /** 实体id */
34 private Long entityId; 34 private Long entityId;
......
1 package com.topdraw.business.module.rights.service.impl; 1 package com.topdraw.business.module.rights.service.impl;
2 2
3 import com.topdraw.business.module.rights.domain.Rights; 3 import com.topdraw.business.module.rights.domain.Rights;
4 import com.topdraw.business.RedisKeyConstants;
4 import com.topdraw.utils.*; 5 import com.topdraw.utils.*;
5 import com.topdraw.business.module.rights.repository.RightsRepository; 6 import com.topdraw.business.module.rights.repository.RightsRepository;
6 import com.topdraw.business.module.rights.service.RightsService; 7 import com.topdraw.business.module.rights.service.RightsService;
7 import com.topdraw.business.module.rights.service.dto.RightsDTO; 8 import com.topdraw.business.module.rights.service.dto.RightsDTO;
8 import com.topdraw.business.module.rights.service.mapper.RightsMapper; 9 import com.topdraw.business.module.rights.service.mapper.RightsMapper;
9 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.cache.annotation.Cacheable;
10 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
11 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
12 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
...@@ -25,9 +27,9 @@ public class RightsServiceImpl implements RightsService { ...@@ -25,9 +27,9 @@ public class RightsServiceImpl implements RightsService {
25 private RightsMapper rightsMapper; 27 private RightsMapper rightsMapper;
26 28
27 @Override 29 @Override
30 @Cacheable(cacheNames = RedisKeyConstants.cacheRightById, key = "#id", unless = "#result.id == null")
28 public RightsDTO findById(Long id) { 31 public RightsDTO findById(Long id) {
29 Rights Rights = this.rightsRepository.findById(id).orElseGet(Rights::new); 32 Rights Rights = this.rightsRepository.findById(id).orElseGet(Rights::new);
30 ValidationUtil.isNull(Rights.getId(),"Rights","id",id);
31 return this.rightsMapper.toDto(Rights); 33 return this.rightsMapper.toDto(Rights);
32 } 34 }
33 35
......
...@@ -3,8 +3,12 @@ package com.topdraw.business.module.task.attribute.repository; ...@@ -3,8 +3,12 @@ package com.topdraw.business.module.task.attribute.repository;
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr; 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 import org.springframework.data.jpa.repository.Query;
6 7
8 import java.util.List;
9 import java.util.Map;
7 import java.util.Optional; 10 import java.util.Optional;
11 import java.util.Set;
8 12
9 /** 13 /**
10 * @author XiangHan 14 * @author XiangHan
...@@ -13,4 +17,7 @@ import java.util.Optional; ...@@ -13,4 +17,7 @@ import java.util.Optional;
13 public interface TaskAttrRepository extends JpaRepository<TaskAttr, Long>, JpaSpecificationExecutor<TaskAttr> { 17 public interface TaskAttrRepository extends JpaRepository<TaskAttr, Long>, JpaSpecificationExecutor<TaskAttr> {
14 18
15 Optional<TaskAttr> findByTaskId(Long taskId); 19 Optional<TaskAttr> findByTaskId(Long taskId);
20
21 @Query(value = "SELECT * FROM `tr_task_attr` WHERE task_id IN(?1)", nativeQuery = true)
22 List<Map<String, Object>> findTasksByTaskIds(Set<Object> taskIds);
16 } 23 }
......
...@@ -3,6 +3,9 @@ package com.topdraw.business.module.task.attribute.service; ...@@ -3,6 +3,9 @@ package com.topdraw.business.module.task.attribute.service;
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr; 3 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO; 4 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
5 5
6 import java.util.List;
7 import java.util.Set;
8
6 /** 9 /**
7 * @author XiangHan 10 * @author XiangHan
8 * @date 2022-01-13 11 * @date 2022-01-13
...@@ -39,4 +42,6 @@ public interface TaskAttrService { ...@@ -39,4 +42,6 @@ public interface TaskAttrService {
39 * @return 42 * @return
40 */ 43 */
41 TaskAttrDTO findByTaskId(Long taskId); 44 TaskAttrDTO findByTaskId(Long taskId);
45
46 List<TaskAttrDTO> findTasksByTaskIds(Set<Object> id);
42 } 47 }
......
1 package com.topdraw.business.module.task.attribute.service.impl; 1 package com.topdraw.business.module.task.attribute.service.impl;
2 2
3 import com.alibaba.fastjson.JSON;
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr; 4 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository; 6 import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository;
...@@ -12,6 +13,12 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -12,6 +13,12 @@ import org.springframework.transaction.annotation.Propagation;
12 import org.springframework.transaction.annotation.Transactional; 13 import org.springframework.transaction.annotation.Transactional;
13 import org.springframework.dao.EmptyResultDataAccessException; 14 import org.springframework.dao.EmptyResultDataAccessException;
14 import org.springframework.util.Assert; 15 import org.springframework.util.Assert;
16 import org.springframework.util.CollectionUtils;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21 import java.util.Set;
15 22
16 /** 23 /**
17 * @author XiangHan 24 * @author XiangHan
...@@ -64,5 +71,20 @@ public class TaskAttrServiceImpl implements TaskAttrService { ...@@ -64,5 +71,20 @@ public class TaskAttrServiceImpl implements TaskAttrService {
64 return this.taskAttrMapper.toDto(taskAttr); 71 return this.taskAttrMapper.toDto(taskAttr);
65 } 72 }
66 73
74 @Override
75 public List<TaskAttrDTO> findTasksByTaskIds(Set<Object> taskIds) {
76 List<Map<String,Object>> maps = this.taskAttrRepository.findTasksByTaskIds(taskIds);
77 if (!CollectionUtils.isEmpty(maps)) {
78 List<TaskAttr> taskAttrs = new ArrayList<>();
79 for (Map<String, Object> map : maps) {
80 TaskAttr taskAttr = JSON.parseObject(JSON.toJSONString(map), TaskAttr.class);
81 taskAttrs.add(taskAttr);
82 }
83
84 return this.taskAttrMapper.toDto(taskAttrs);
85 }
86 return new ArrayList<>();
87 }
88
67 89
68 } 90 }
......
...@@ -15,6 +15,7 @@ import java.sql.Timestamp; ...@@ -15,6 +15,7 @@ import java.sql.Timestamp;
15 15
16 import java.io.Serializable; 16 import java.io.Serializable;
17 import java.time.LocalDateTime; 17 import java.time.LocalDateTime;
18 import java.util.List;
18 19
19 /** 20 /**
20 * @author XiangHan 21 * @author XiangHan
...@@ -151,6 +152,9 @@ public class Task implements Serializable { ...@@ -151,6 +152,9 @@ public class Task implements Serializable {
151 @Transient 152 @Transient
152 private String attr; 153 private String attr;
153 154
155 @Transient
156 private Integer event;
157
154 /** 创建时间 */ 158 /** 创建时间 */
155 @CreatedDate 159 @CreatedDate
156 @Column(name = "create_time") 160 @Column(name = "create_time")
......
...@@ -61,7 +61,7 @@ public class TaskBuilder { ...@@ -61,7 +61,7 @@ public class TaskBuilder {
61 61
62 task_.setDeleteMark(Objects.isNull(task.getDeleteMark()) ? 0 : task.getDeleteMark()); 62 task_.setDeleteMark(Objects.isNull(task.getDeleteMark()) ? 0 : task.getDeleteMark());
63 63
64 task_.setAttr(StringUtils.isBlank(task.getAttr()) ? null : task.getAttr()); 64 // task_.setAttr(StringUtils.isBlank(task.getAttr()) ? null : task.getAttr());
65 return task_; 65 return task_;
66 } 66 }
67 67
......
...@@ -27,6 +27,9 @@ import java.io.Serializable; ...@@ -27,6 +27,9 @@ import java.io.Serializable;
27 @NoArgsConstructor 27 @NoArgsConstructor
28 public class TrTaskProgress implements Serializable { 28 public class TrTaskProgress implements Serializable {
29 29
30 @Transient
31 private String memberCode;
32
30 @Id 33 @Id
31 @GeneratedValue(strategy = GenerationType.IDENTITY) 34 @GeneratedValue(strategy = GenerationType.IDENTITY)
32 @Column(name = "id") 35 @Column(name = "id")
......
...@@ -5,7 +5,10 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -5,7 +5,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Query; 6 import org.springframework.data.jpa.repository.Query;
7 7
8 import java.util.HashMap;
8 import java.util.List; 9 import java.util.List;
10 import java.util.Map;
11 import java.util.Optional;
9 12
10 /** 13 /**
11 * @author XiangHan 14 * @author XiangHan
...@@ -13,8 +16,17 @@ import java.util.List; ...@@ -13,8 +16,17 @@ import java.util.List;
13 */ 16 */
14 public interface TrTaskProgressRepository extends JpaRepository<TrTaskProgress, Long>, JpaSpecificationExecutor<TrTaskProgress> { 17 public interface TrTaskProgressRepository extends JpaRepository<TrTaskProgress, Long>, JpaSpecificationExecutor<TrTaskProgress> {
15 18
16 @Query(value = "select id, member_id, task_id , current_action_amount , \n" + 19 @Query(value = "select id, member_id, task_id, current_action_amount," +
17 " target_action_amount , `status` , completion_time,create_time,update_time from uc_tr_task_progress where member_id = ?1 \n" + 20 " target_action_amount, `status`, completion_time, create_time, update_time from uc_tr_task_progress where member_id = ?1 " +
18 " and task_id = ?2 and Date(completion_time) = ?3 ",nativeQuery = true) 21 " and task_id = ?2 and Date(completion_time) = ?3 ",nativeQuery = true)
19 List<TrTaskProgress> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); 22 Optional<TrTaskProgress> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1);
23
24
25 Integer countByMemberIdAndTaskId(Long memberId, Long taskId);
26
27 @Query(value = "select `task_id` AS taskId, count(*) AS finishCount from uc_tr_task_progress where member_id = ?1 and `status` = 1 GROUP BY `task_id` ", nativeQuery = true)
28 List<Map<String, Object>> countFinishTaskGroupByMemberId(Long memberId);
29
30 @Query(value = "select `task_id` AS taskId, count(*) AS finishCount from uc_tr_task_progress where member_id = ?1 and Date(completion_time) = ?2 and `status` = 1 GROUP BY `task_id`", nativeQuery = true)
31 List<Map<String, Object>> countFinishTaskGroupByMemberIdAndToday(Long memberId, String todayStart);
20 } 32 }
......
...@@ -2,7 +2,11 @@ package com.topdraw.business.module.task.progress.service; ...@@ -2,7 +2,11 @@ package com.topdraw.business.module.task.progress.service;
2 2
3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress; 3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
4 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; 4 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
5
6 import java.time.LocalDateTime;
7 import java.util.HashMap;
5 import java.util.List; 8 import java.util.List;
9 import java.util.Map;
6 10
7 /** 11 /**
8 * @author XiangHan 12 * @author XiangHan
...@@ -21,13 +25,13 @@ public interface TrTaskProgressService { ...@@ -21,13 +25,13 @@ public interface TrTaskProgressService {
21 * 25 *
22 * @param resources 26 * @param resources
23 */ 27 */
24 void create(TrTaskProgress resources); 28 TrTaskProgress create(TrTaskProgress resources, String date);
25 29
26 /** 30 /**
27 * 31 *
28 * @param resources 32 * @param resources
29 */ 33 */
30 void update(TrTaskProgress resources); 34 TrTaskProgress update(TrTaskProgress resources, String date);
31 35
32 /** 36 /**
33 * 37 *
...@@ -42,5 +46,28 @@ public interface TrTaskProgressService { ...@@ -42,5 +46,28 @@ public interface TrTaskProgressService {
42 * @param time1 46 * @param time1
43 * @return 47 * @return
44 */ 48 */
45 List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); 49 TrTaskProgress findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1);
50
51 /**
52 *
53 * @param memberId
54 * @param taskId
55 * @return
56 */
57 Integer countByMemberIdAndTaskId(Long memberId, Long taskId);
58
59 /**
60 *
61 * @param id
62 * @return
63 */
64 Map<Object, Object> countTotalFinishTaskByMemberId(Long id);
65
66 /**
67 *
68 * @param id
69 * @param todayStart
70 * @return
71 */
72 Map<Object, Object> countTodayFinishTaskByMemberId(Long id, String todayStart);
46 } 73 }
......
1 package com.topdraw.business.module.task.progress.service.impl; 1 package com.topdraw.business.module.task.progress.service.impl;
2 2
3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress; 3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
4 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.business.RedisKeyConstants;
5 import com.topdraw.utils.RedisUtils;
5 import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository; 6 import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository;
6 import com.topdraw.business.module.task.progress.service.TrTaskProgressService; 7 import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
7 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; 8 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
8 import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper; 9 import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper;
10 import lombok.extern.slf4j.Slf4j;
9 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
11 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
12 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
13 import org.springframework.dao.EmptyResultDataAccessException; 15 import org.springframework.dao.EmptyResultDataAccessException;
14 import org.springframework.util.Assert; 16 import org.springframework.util.Assert;
17 import org.springframework.util.CollectionUtils;
15 18
16 import java.util.List; 19 import java.time.LocalDate;
20 import java.util.*;
17 21
18 /** 22 /**
19 * @author XiangHan 23 * @author XiangHan
...@@ -21,34 +25,35 @@ import java.util.List; ...@@ -21,34 +25,35 @@ import java.util.List;
21 */ 25 */
22 @Service 26 @Service
23 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 27 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
28 @Slf4j
24 public class TrTaskProgressServiceImpl implements TrTaskProgressService { 29 public class TrTaskProgressServiceImpl implements TrTaskProgressService {
25 30
26 @Autowired 31 @Autowired
27 private TrTaskProgressRepository trTaskProgressRepository; 32 private TrTaskProgressRepository trTaskProgressRepository;
28
29 @Autowired 33 @Autowired
30 private TrTaskProgressMapper trTaskProgressMapper; 34 private TrTaskProgressMapper trTaskProgressMapper;
31 35
36 @Autowired
37 private RedisUtils redisUtils;
38
32 @Override 39 @Override
33 public TrTaskProgressDTO findById(Long id) { 40 public TrTaskProgressDTO findById(Long id) {
34 TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseGet(TrTaskProgress::new); 41 TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseGet(TrTaskProgress::new);
35 ValidationUtil.isNull(TrTaskProgress.getId(),"TrTaskProgress","id",id);
36 return this.trTaskProgressMapper.toDto(TrTaskProgress); 42 return this.trTaskProgressMapper.toDto(TrTaskProgress);
37 } 43 }
38 44
39 @Override 45 @Override
40 @Transactional(rollbackFor = Exception.class) 46 @Transactional(rollbackFor = Exception.class)
41 public void create(TrTaskProgress resources) { 47 // @CachePut(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ")
42 this.trTaskProgressRepository.save(resources); 48 public TrTaskProgress create(TrTaskProgress resources, String date) {
49 return this.trTaskProgressRepository.save(resources);
43 } 50 }
44 51
45 @Override 52 @Override
46 @Transactional(rollbackFor = Exception.class) 53 @Transactional(rollbackFor = Exception.class)
47 public void update(TrTaskProgress resources) { 54 // @CachePut(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ")
48 TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(resources.getId()).orElseGet(TrTaskProgress::new); 55 public TrTaskProgress update(TrTaskProgress resources, String date) {
49 ValidationUtil.isNull( TrTaskProgress.getId(),"TrTaskProgress","id",resources.getId()); 56 return this.trTaskProgressRepository.save(resources);
50 TrTaskProgress.copy(resources);
51 this.trTaskProgressRepository.save(TrTaskProgress);
52 } 57 }
53 58
54 @Override 59 @Override
...@@ -61,8 +66,73 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { ...@@ -61,8 +66,73 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService {
61 } 66 }
62 67
63 @Override 68 @Override
64 public List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) { 69 // @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#memberId+':'+#taskId+':'+#time1", unless = "#result.id == null")
65 return this.trTaskProgressMapper.toDto(this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1)); 70 public TrTaskProgress findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) {
71 log.info("从数据库查询当前会员今天是否完成了此任务, memberId ==>> {} || taskId ==>> {}", memberId, taskId);
72 return this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId, taskId, time1).orElseGet(TrTaskProgress::new);
73 }
74
75 @Override
76 public Integer countByMemberIdAndTaskId(Long memberId, Long taskId) {
77 return this.trTaskProgressRepository.countByMemberIdAndTaskId(memberId, taskId);
78 }
79
80 @Override
81 public Map<Object, Object> countTotalFinishTaskByMemberId(Long memberId) {
82 Map<Object, Object> hmget = this.redisUtils.hmget(RedisKeyConstants.cacheTotalFinishTaskCount + "::" + memberId);
83 if (Objects.isNull(hmget)) {
84 List<Map<String, Object>> maps = this.trTaskProgressRepository.countFinishTaskGroupByMemberId(memberId);
85 if (!CollectionUtils.isEmpty(maps)) {
86 Map<Object, Object> finishTasks = new HashMap<>();
87 for (Map<String, Object> map : maps) {
88 Object taskId = map.get("taskId");
89 if (Objects.isNull(taskId)) {
90 continue;
91 }
92 finishTasks.put(taskId, Integer.valueOf(map.get("finishCount").toString()));
93
94 }
95 if (finishTasks.size() > 0) {
96 // 总记录一直存储
97 this.redisUtils.hmset(RedisKeyConstants.cacheTotalFinishTaskCount + "::" + memberId, finishTasks);
98 }
99
100 return finishTasks;
101 }
102 }
103
104 return hmget;
105 }
106
107 @Override
108 public Map<Object, Object> countTodayFinishTaskByMemberId(Long memberId, String todayStart) {
109
110 Map<Object, Object> hmget = this.redisUtils.hmget(RedisKeyConstants.cacheTodayFinishTaskCount + "::" + memberId + ":" + todayStart);
111 if (Objects.isNull(hmget)) {
112 List<Map<String, Object>> maps = this.trTaskProgressRepository.countFinishTaskGroupByMemberIdAndToday(memberId, todayStart);
113 if (!CollectionUtils.isEmpty(maps)){
114 Map<Object, Object> finishTasks = new HashMap<>();
115 for (Map<String, Object> map : maps) {
116 Object taskId = map.get("taskId");
117 if (Objects.isNull(taskId)) {
118 continue;
119 }
120
121 finishTasks.put(taskId, Integer.valueOf(map.get("finishCount").toString()));
122
123 }
124
125 if (finishTasks.size() > 0) {
126 // 单天的记录只存储一天
127 this.redisUtils.hmset(RedisKeyConstants.cacheTodayFinishTaskCount + "::" + memberId + ":" + LocalDate.now(), finishTasks, 24*60*60);
128 }
129
130 return finishTasks;
131
132 }
133 }
134
135 return hmget;
66 } 136 }
67 137
68 138
......
...@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query; ...@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query;
8 import org.springframework.transaction.annotation.Transactional; 8 import org.springframework.transaction.annotation.Transactional;
9 9
10 import java.util.List; 10 import java.util.List;
11 import java.util.Map;
11 import java.util.Optional; 12 import java.util.Optional;
12 13
13 /** 14 /**
...@@ -21,7 +22,12 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat ...@@ -21,7 +22,12 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
21 @Modifying 22 @Modifying
22 @Transactional 23 @Transactional
23 @Query(value = "UPDATE `tr_task` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true) 24 @Query(value = "UPDATE `tr_task` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true)
24 void updateDeleteMark(Long id); 25 Integer updateDeleteMark(Long id);
25 26
26 Optional<Task> findByCode(String code); 27 Optional<Task> findByCode(String code);
28
29 @Query(value = "SELECT ta.* FROM tr_task ta LEFT JOIN tr_task_template tm ON ta.task_template_id = tm.id " +
30 " WHERE ta.`status` = 1 AND ta.valid_time <= now() and ta.expire_time >= now() AND ta.delete_mark = 0 AND " +
31 " tm.type = ?1 AND ta.`member_level` <= ?2 and ta.`member_vip` <= ?3", nativeQuery = true)
32 List<Map<String,Object>> findByEventAndLevelAndVip(Integer event, Integer level, Integer vip);
27 } 33 }
......
1 package com.topdraw.business.module.task.service; 1 package com.topdraw.business.module.task.service;
2 2
3 import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
3 import com.topdraw.business.module.task.domain.Task; 4 import com.topdraw.business.module.task.domain.Task;
5 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
4 import com.topdraw.business.module.task.service.dto.TaskDTO; 6 import com.topdraw.business.module.task.service.dto.TaskDTO;
7
8 import java.time.LocalDateTime;
5 import java.util.List; 9 import java.util.List;
6 10
7 /** 11 /**
...@@ -47,11 +51,19 @@ public interface TaskService { ...@@ -47,11 +51,19 @@ public interface TaskService {
47 * 51 *
48 * @param task 52 * @param task
49 */ 53 */
50 void delete(Task task); 54 Integer delete(Task task);
51 55
52 /** 56 /**
53 * 57 *
54 * @param id 58 * @param id
55 */ 59 */
56 void delete(Long id); 60 Integer delete(Long id);
61
62 /**
63 *
64 * @param event
65 * @return
66 */
67 List<Task> findByEventAndMemberLevelAndVip(Integer event, Integer level, Integer vip);
68
57 } 69 }
......
1 package com.topdraw.business.module.task.service.impl; 1 package com.topdraw.business.module.task.service.impl;
2 2
3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject;
6 import com.topdraw.business.module.task.attribute.service.TaskAttrService;
7 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
3 import com.topdraw.business.module.task.domain.Task; 8 import com.topdraw.business.module.task.domain.Task;
4 import com.topdraw.business.module.task.repository.TaskRepository; 9 import com.topdraw.business.module.task.repository.TaskRepository;
5 import com.topdraw.business.module.task.service.TaskService; 10 import com.topdraw.business.module.task.service.TaskService;
6 import com.topdraw.business.module.task.service.dto.TaskDTO; 11 import com.topdraw.business.module.task.service.dto.TaskDTO;
7 import com.topdraw.business.module.task.service.mapper.TaskMapper; 12 import com.topdraw.business.module.task.service.mapper.TaskMapper;
13 import com.topdraw.business.RedisKeyConstants;
14 import com.topdraw.utils.RedisUtils;
15 import lombok.extern.slf4j.Slf4j;
8 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
10 import org.springframework.transaction.annotation.Propagation; 18 import org.springframework.transaction.annotation.Propagation;
11 import org.springframework.transaction.annotation.Transactional; 19 import org.springframework.transaction.annotation.Transactional;
20 import org.springframework.util.CollectionUtils;
12 21
22 import java.util.ArrayList;
13 import java.util.List; 23 import java.util.List;
24 import java.util.Map;
14 import java.util.Objects; 25 import java.util.Objects;
26 import java.util.stream.Collectors;
15 27
16 /** 28 /**
17 * @author XiangHan 29 * @author XiangHan
...@@ -19,12 +31,18 @@ import java.util.Objects; ...@@ -19,12 +31,18 @@ import java.util.Objects;
19 */ 31 */
20 @Service 32 @Service
21 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 33 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
34 @Slf4j
22 public class TaskServiceImpl implements TaskService { 35 public class TaskServiceImpl implements TaskService {
23 36
24 @Autowired 37 @Autowired
38 private TaskAttrService taskAttrService;
39
40 @Autowired
25 private TaskMapper taskMapper; 41 private TaskMapper taskMapper;
26 @Autowired 42 @Autowired
27 private TaskRepository taskRepository; 43 private TaskRepository taskRepository;
44 @Autowired
45 private RedisUtils redisUtils;
28 46
29 @Override 47 @Override
30 public TaskDTO findById(Long id) { 48 public TaskDTO findById(Long id) {
...@@ -56,14 +74,70 @@ public class TaskServiceImpl implements TaskService { ...@@ -56,14 +74,70 @@ public class TaskServiceImpl implements TaskService {
56 } 74 }
57 75
58 @Override 76 @Override
59 public void delete(Task task) { 77 public Integer delete(Task task) {
60 Long id = task.getId(); 78 Long id = task.getId();
61 this.delete(id); 79 return this.delete(id);
62 } 80 }
63 81
64 @Override 82 @Override
65 public void delete(Long id) { 83 public Integer delete(Long id) {
66 this.taskRepository.updateDeleteMark(id); 84 return this.taskRepository.updateDeleteMark(id);
85 }
86
87 @Override
88 @Transactional(readOnly = true)
89 public List<Task> findByEventAndMemberLevelAndVip(Integer event, Integer level, Integer vip) {
90 try {
91 boolean b = this.redisUtils.hasKey(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip);
92
93 if (b) {
94 List<Object> tasksObjs = redisUtils.lGet(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip, 0, -1);
95 return JSONArray.parseArray(tasksObjs.get(0).toString(), Task.class);
96 }
97
98 List<Map<String, Object>> maps = this.taskRepository.findByEventAndLevelAndVip(event, level, vip);
99
100 List<Task> tasks = new ArrayList<>();
101 if (CollectionUtils.isEmpty(maps)) {
102 return tasks;
103 }
104
105 List<TaskAttrDTO> taskAttrDTOS = this.taskAttrService.findTasksByTaskIds(maps.stream().map(t -> t.get("id")).collect(Collectors.toSet()));
106
107 if (!CollectionUtils.isEmpty(taskAttrDTOS)) {
108
109 for (Map<String, Object> map : maps) {
110 Task task = JSONObject.parseObject(JSON.toJSONString(map), Task.class);
111
112 List<String> taskAttrs = taskAttrDTOS.stream().filter(taskAttrDTO -> taskAttrDTO.getTaskId().equals(task.getId())).
113 map(TaskAttrDTO::getAttrStr).collect(Collectors.toList());
114 log.info("任务属性值, dealTask# taskAttrs ==>> {}", taskAttrs);
115 if (!CollectionUtils.isEmpty(taskAttrs)) {
116 task.setAttr(String.join(",", taskAttrs));
117 }
118
119 tasks.add(task);
120 }
121
122 } else {
123
124 for (Map<String, Object> map : maps) {
125 Task task = JSONObject.parseObject(JSON.toJSONString(map), Task.class);
126 tasks.add(task);
127 }
128
129 }
130
131 if (!CollectionUtils.isEmpty(tasks)) {
132 this.redisUtils.lSet(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip, tasks, 45 * 60);
67 } 133 }
68 134
135 return tasks;
136
137 } catch (Exception e) {
138 log.error(e.getMessage());
139 }
140
141 return new ArrayList<>();
142 }
69 } 143 }
......
1 package com.topdraw.business.module.task.template.constant;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/18 14:30
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/18 14:30
11 */
12 public interface TaskEventType {
13 //类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置;
14 // 8:播放记录;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他
15 int LOGIN = 1;
16 int VIEW = 2;
17 int ACTIVITY = 3;
18 int ORDER = 4;
19 int MEMBER_PRIORITY = 5;
20 int SIGN = 6;
21 int COMPLETE_INFO = 7;
22 int PLAY = 8;
23 int BINDING = 10;
24 int POINTS_TRANS = 11;
25 int POINTS_EXCHANGE_GOODS = 30;
26 int SYSTEM_OPERATE = 98;
27 int OHHER = 99;
28
29 }
...@@ -26,4 +26,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long ...@@ -26,4 +26,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long
26 @Transactional 26 @Transactional
27 @Query(value = "UPDATE `tr_task_template` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true) 27 @Query(value = "UPDATE `tr_task_template` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true)
28 void updateDeleteMark(Long id); 28 void updateDeleteMark(Long id);
29
30 Long countByCodeAndType(String code, Integer type);
29 } 31 }
......
...@@ -61,4 +61,11 @@ public interface TaskTemplateService { ...@@ -61,4 +61,11 @@ public interface TaskTemplateService {
61 * @return 61 * @return
62 */ 62 */
63 TaskTemplateDTO findByType(Integer event); 63 TaskTemplateDTO findByType(Integer event);
64
65 /**
66 *
67 * @param taskTemplate
68 * @return
69 */
70 Long countByCodeAndType(TaskTemplate taskTemplate);
64 } 71 }
......
...@@ -83,4 +83,10 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { ...@@ -83,4 +83,10 @@ public class TaskTemplateServiceImpl implements TaskTemplateService {
83 return Objects.nonNull(event) ? this.taskTemplateMapper.toDto(this.taskTemplateRepository.findByType(event).orElseGet(TaskTemplate::new)) : new TaskTemplateDTO(); 83 return Objects.nonNull(event) ? this.taskTemplateMapper.toDto(this.taskTemplateRepository.findByType(event).orElseGet(TaskTemplate::new)) : new TaskTemplateDTO();
84 } 84 }
85 85
86 @Override
87 public Long countByCodeAndType(TaskTemplate taskTemplate) {
88 Long count = this.taskTemplateRepository.countByCodeAndType(taskTemplate.getCode(), taskTemplate.getType());
89 return count;
90 }
91
86 } 92 }
......
1 package com.topdraw.business.module.user.app.domain;
2
3 import lombok.Data;
4 import lombok.experimental.Accessors;
5 import cn.hutool.core.bean.BeanUtil;
6 import cn.hutool.core.bean.copier.CopyOptions;
7 import javax.persistence.*;
8 import org.springframework.data.annotation.CreatedDate;
9 import org.springframework.data.annotation.LastModifiedDate;
10 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
11 import java.sql.Timestamp;
12
13 import java.io.Serializable;
14
15 /**
16 * @author XiangHan
17 * @date 2022-06-27
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_user_app")
24 public class UserApp implements Serializable {
25
26 // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
27 @Transient
28 private Integer accountType;
29
30 // 第三方账号
31 @Transient
32 private String account;
33
34 // ID
35 @Id
36 @GeneratedValue(strategy = GenerationType.IDENTITY)
37 @Column(name = "id")
38 private Long id;
39
40 // 会员id
41 @Column(name = "member_id")
42 private Long memberId;
43
44 // 用户名(一般为手机号)
45 @Column(name = "username", nullable = false)
46 private String username;
47
48 // 密码
49 @Column(name = "password")
50 private String password;
51
52 // 类型 0:苹果;1:安卓;-1:未知
53 @Column(name = "type", nullable = false)
54 private Integer type;
55
56 // 状态 0:禁用;1:生效;-1:注销
57 @Column(name = "status", nullable = false)
58 private Integer status;
59
60 // 昵称
61 @Column(name = "nickname")
62 private String nickname;
63
64 // 头像地址
65 @Column(name = "headimgurl")
66 private String headimgurl;
67
68 // 邮箱
69 @Column(name = "email")
70 private String email;
71
72 // 手机号
73 @Column(name = "cellphone")
74 private String cellphone;
75
76 // 性别 0:女;1:男;-1:其他
77 @Column(name = "gender")
78 private Integer gender;
79
80 // 生日
81 @Column(name = "birthday")
82 private String birthday;
83
84 // 最近活跃时间
85 @Column(name = "last_active_time")
86 private Timestamp lastActiveTime;
87
88 // 注销时间
89 @Column(name = "delete_time")
90 private Timestamp deleteTime;
91
92 // 标签
93 @Column(name = "tags")
94 private String tags;
95
96 // 描述
97 @Column(name = "description")
98 private String description;
99
100 // 创建时间
101 @CreatedDate
102 @Column(name = "create_time")
103 private Timestamp createTime;
104
105 // 更新时间
106 @LastModifiedDate
107 @Column(name = "update_time")
108 private Timestamp updateTime;
109
110 public void copy(UserApp source){
111 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
112 }
113 }
1 package com.topdraw.business.module.user.app.domain;
2
3 import lombok.Data;
4 import lombok.experimental.Accessors;
5 import cn.hutool.core.bean.BeanUtil;
6 import cn.hutool.core.bean.copier.CopyOptions;
7 import javax.persistence.*;
8 import org.springframework.data.annotation.CreatedDate;
9 import org.springframework.data.annotation.LastModifiedDate;
10 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
11 import java.sql.Timestamp;
12
13 import java.io.Serializable;
14
15 /**
16 * @author XiangHan
17 * @date 2022-06-27
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_user_app_bind")
24 public class UserAppBind implements Serializable {
25
26 @Transient
27 private String username;
28
29 @Transient
30 private String password;
31 @Transient
32 private String headimgurl;
33
34 // 主键
35 @Id
36 @GeneratedValue(strategy = GenerationType.IDENTITY)
37 @Column(name = "id")
38 private Long id;
39
40 // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
41 @Column(name = "account_type", nullable = false)
42 private Integer accountType;
43
44 // 第三方账号
45 @Column(name = "account", nullable = false)
46 private String account;
47
48 // app账号id
49 @Column(name = "user_app_id", nullable = false)
50 private Long userAppId;
51
52 // 绑定状态 0:解绑;1 绑定
53 @Column(name = "status", nullable = false)
54 private Integer status;
55
56 // 昵称
57 @Column(name = "nickname", nullable = false)
58 private String nickname;
59
60 // 创建时间
61 @CreatedDate
62 @Column(name = "create_time")
63 private Timestamp createTime;
64
65 // 更新时间
66 @LastModifiedDate
67 @Column(name = "update_time")
68 private Timestamp updateTime;
69
70 public void copy(UserAppBind source){
71 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
72 }
73 }
1 package com.topdraw.business.module.user.app.domain;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/30 13:18
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/30 13:18
11 */
12 public class UserAppBindBuilder {
13
14 public static UserAppBind build(Long userAppId, String account, Integer accountType){
15 UserAppBind userAppBind = new UserAppBind();
16 userAppBind.setAccount(account);
17 userAppBind.setUserAppId(userAppId);
18 userAppBind.setAccountType(accountType);
19 userAppBind.setStatus(UserAppStatusConstant.VALID_STATUS);
20 return userAppBind;
21 }
22
23 }
1 package com.topdraw.business.module.user.app.domain;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/30 11:42
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/30 11:42
11 */
12 public interface UserAppBindStatusConstant {
13 // 绑定状态 0:解绑;1 绑定
14 Integer VALID_STATUS = 1;
15 Integer INVALID_STATUS = 0;
16
17 }
1 package com.topdraw.business.module.user.app.domain;
2
3 import com.topdraw.util.TimestampUtil;
4 import org.apache.commons.lang3.StringUtils;
5 import org.springframework.beans.BeanUtils;
6
7 import java.util.Objects;
8
9 /**
10 * @author :
11 * @description:
12 * @function :
13 * @date :Created in 2022/6/30 11:35
14 * @version: :
15 * @modified By:
16 * @since : modified in 2022/6/30 11:35
17 */
18 public class UserAppBuilder {
19
20
21
22 public static UserApp build(Long memberId, UserApp resource){
23
24 UserApp userApp = new UserApp();
25 userApp.setId(null);
26 userApp.setMemberId(memberId);
27 userApp.setUsername(resource.getUsername());
28 userApp.setTags(resource.getTags());
29 userApp.setLastActiveTime(TimestampUtil.now());
30 userApp.setEmail(resource.getEmail());
31 userApp.setType(Objects.isNull(resource.getType()) ? -1 : resource.getType());
32 userApp.setNickname(StringUtils.isNotBlank(resource.getNickname()) ? resource.getNickname() : resource.getUsername());
33 userApp.setHeadimgurl(resource.getHeadimgurl());
34 userApp.setPassword(resource.getPassword());
35 userApp.setCellphone(StringUtils.isNotBlank(resource.getCellphone()) ? resource.getCellphone() : resource.getUsername());
36 userApp.setBirthday(StringUtils.isNotBlank(resource.getBirthday()) ? resource.getBirthday() : null);
37 userApp.setGender(Objects.nonNull(resource.getGender()) ? resource.getGender() : -1);
38 userApp.setStatus(UserAppStatusConstant.VALID_STATUS);
39 userApp.setCreateTime(null);
40 userApp.setUpdateTime(null);
41 return userApp;
42 }
43
44
45 }
1 package com.topdraw.business.module.user.app.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 XiangHan
17 * @date 2022-06-27
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_user_app")
24 public class UserAppIdManual implements Serializable {
25
26 // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
27 @Transient
28 private Integer accountType;
29
30 // 第三方账号
31 @Transient
32 private String account;
33
34 @Transient
35 private String memberCode;
36
37 // ID
38 @Id
39 @GeneratedValue(strategy = GenerationType.SEQUENCE)
40 @Column(name = "id")
41 private Long id;
42
43 // 会员id
44 @Column(name = "member_id")
45 private Long memberId;
46
47 // 用户名(一般为手机号)
48 @Column(name = "username", nullable = false)
49 private String username;
50
51 // 密码
52 @Column(name = "password")
53 private String password;
54
55 // 类型 0:苹果;1:安卓;-1:未知
56 @Column(name = "type", nullable = false)
57 private Integer type;
58
59 // 状态 0:禁用;1:生效;-1:注销
60 @Column(name = "status", nullable = false)
61 private Integer status;
62
63 // 昵称
64 @Column(name = "nickname")
65 private String nickname;
66
67 // 头像地址
68 @Column(name = "headimgurl")
69 private String headimgurl;
70
71 // 邮箱
72 @Column(name = "email")
73 private String email;
74
75 // 手机号
76 @Column(name = "cellphone")
77 private String cellphone;
78
79 // 性别 0:女;1:男;-1:其他
80 @Column(name = "gender")
81 private Integer gender;
82
83 // 生日
84 @Column(name = "birthday")
85 private String birthday;
86
87 // 最近活跃时间
88 @Column(name = "last_active_time")
89 private Timestamp lastActiveTime;
90
91 // 注销时间
92 @Column(name = "delete_time")
93 private Timestamp deleteTime;
94
95 // 标签
96 @Column(name = "tags")
97 private String tags;
98
99 // 描述
100 @Column(name = "description")
101 private String description;
102
103 // 创建时间
104 @CreatedDate
105 @Column(name = "create_time")
106 private Timestamp createTime;
107
108 // 更新时间
109 @LastModifiedDate
110 @Column(name = "update_time")
111 private Timestamp updateTime;
112
113 public void copy(UserAppIdManual source){
114 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
115 }
116 }
1 package com.topdraw.business.module.user.app.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
12 /**
13 * @author XiangHan
14 * @date 2022-06-27
15 */
16 @Entity
17 @Data
18 @EntityListeners(AuditingEntityListener.class)
19 @Accessors(chain = true)
20 @Table(name="uc_user_app")
21 public class UserAppSimple implements Serializable {
22
23 // ID
24 @Id
25 @GeneratedValue(strategy = GenerationType.IDENTITY)
26 @Column(name = "id")
27 private Long id;
28
29 // 会员id
30 @Column(name = "member_id")
31 private Long memberId;
32
33 // 用户名(一般为手机号)
34 @Column(name = "username", nullable = false)
35 private String username;
36
37 // 状态 0:禁用;1:生效;-1:注销
38 @Column(name = "status", nullable = false)
39 private Integer status;
40
41 // 昵称
42 @Column(name = "nickname")
43 private String nickname;
44
45 // 头像地址
46 @Column(name = "headimgurl")
47 private String headimgurl;
48
49 // 邮箱
50 @Column(name = "email")
51 private String email;
52
53 // 手机号
54 @Column(name = "cellphone")
55 private String cellphone;
56
57 // 性别 0:女;1:男;-1:其他
58 @Column(name = "gender")
59 private Integer gender;
60
61 // 生日
62 @Column(name = "birthday")
63 private String birthday;
64
65 // 标签
66 @Column(name = "tags")
67 private String tags;
68
69 // 描述
70 @Column(name = "description")
71 private String description;
72
73 public void copy(UserAppSimple source){
74 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
75 }
76 }
1 package com.topdraw.business.module.user.app.domain;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/6/30 11:42
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/6/30 11:42
11 */
12 public interface UserAppStatusConstant {
13 // 状态 0:禁用;1:生效;-1:注销
14 Integer VALID_STATUS = 1;
15 Integer FORBID_STATUS = 0;
16 Integer INVALID_STATUS = -1;
17
18 }
1 package com.topdraw.business.module.user.app.repository;
2
3 import com.topdraw.business.module.user.app.domain.UserAppBind;
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 import org.springframework.transaction.annotation.Transactional;
10
11 import java.util.List;
12 import java.util.Optional;
13
14 /**
15 * @author XiangHan
16 * @date 2022-06-27
17 */
18 public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, JpaSpecificationExecutor<UserAppBind> {
19
20 Optional<UserAppBind> findFirstByAccount(String account);
21
22 @Modifying
23 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 0 , `update_time` = now() WHERE `account` = ?1 AND `account_type` = ?2", nativeQuery = true)
24 Integer cancelUserAppBind(String account, Integer accountType);
25
26 Optional<UserAppBind> findFirstByAccountAndAccountType(String account, Integer accountType);
27
28 @Modifying
29 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = :#{#resources.status}, `update_time` = now(), " +
30 " `user_app_id` = :#{#resources.userAppId}, `nickname` = :#{#resources.nickname} " +
31 " WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}", nativeQuery = true)
32 Integer updateThirdAccount(@Param("resources") UserAppBind resources);
33
34 @Modifying
35 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = :#{#resources.status}, `update_time` = now(), " +
36 " `user_app_id` = :#{#resources.userAppId} WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}",
37 nativeQuery = true)
38 Integer updateThirdAccountStatusAndUserAppId(@Param("resources") UserAppBind resources);
39
40 @Modifying
41 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 1, `update_time` = now(), " +
42 " `user_app_id` = :#{#resources.userAppId} WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}",
43 nativeQuery = true)
44 Integer updateValidStatusAndUserAppId(@Param("resources") UserAppBind resources);
45
46
47 @Modifying
48 @Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `nickname` = :#{#resources.nickname} " +
49 " WHERE `account` = :#{#resources.account} AND `account_type` = :#{#resources.accountType}", nativeQuery = true)
50 Integer updateThirdAccountNickname(@Param("resources") UserAppBind resources);
51
52 @Modifying
53 @Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `nickname` = :#{#resources.nickname}, `status` = 1, `user_app_id` = :#{#resources.userAppId} " +
54 " WHERE `account` = :#{#resources.account} AND `account_type` = :#{#resources.accountType}", nativeQuery = true)
55 Integer updateValidStatusAndUserAppIdAndNickname(@Param("resources") UserAppBind resources);
56
57 @Modifying
58 @Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `status` = 0 WHERE `id` IN ?1", nativeQuery = true)
59 Integer appCancellation(List<Long> ids);
60
61 List<UserAppBind> findByUserAppId(Long id);
62 }
63
1 package com.topdraw.business.module.user.app.repository;
2
3 import com.topdraw.business.module.user.app.domain.UserApp;
4 import com.topdraw.business.module.user.app.domain.UserAppIdManual;
5 import org.springframework.data.jpa.repository.JpaRepository;
6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7 import org.springframework.data.jpa.repository.Modifying;
8 import org.springframework.data.jpa.repository.Query;
9 import org.springframework.data.repository.query.Param;
10
11 import java.util.Optional;
12
13 /**
14 * @author XiangHan
15 * @date 2022-06-27
16 */
17 public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpecificationExecutor<UserApp> {
18
19 @Query(value = "SELECT ua.* FROM uc_user_app ua WHERE ua.`username` = ?1 and ua.`status` IN (0 , 1)", nativeQuery = true)
20 Optional<UserApp> findByUsername(String username);
21
22 Optional<UserApp> findByUsernameAndPassword(String username, String password);
23
24 @Modifying
25 @Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `last_active_time` = now() WHERE `username` = ?1 AND `status` = 1 ", nativeQuery = true)
26 Integer updateLastActiveTime(String username);
27
28 @Modifying
29 @Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `username` = ?1 AND `status` = 1", nativeQuery = true)
30 Integer updatePasswordByUsername(String username, String password);
31
32 @Modifying
33 @Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `nickname` = :#{#resources.nickname}, " +
34 " `headimgurl` = :#{#resources.headimgurl}, `email` = :#{#resources.email}, `cellphone` = :#{#resources.cellphone}, " +
35 " `gender` = :#{#resources.gender}, `birthday` = :#{#resources.birthday}, `tags` = :#{#resources.tags}, `description` = :#{#resources.description}" +
36 " WHERE `id` = :#{#resources.id}", nativeQuery = true)
37 Integer updateAppInfo(@Param("resources") UserApp resources);
38
39 @Modifying
40 @Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `id` = ?1", nativeQuery = true)
41 Integer updatePasswordById(Long id, String password);
42
43 @Modifying
44 @Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `delete_time` = now(), `status` = -1 WHERE `id` = ?1", nativeQuery = true)
45 Integer appCancellation(Long id);
46
47 @Modifying
48 @Query(value = "UPDATE `uc_user_app` SET `last_active_time` = now(), `nickname` = ?2, `headimgurl` = ?3 " +
49 " WHERE `username` = ?1 and `status` = 1 ", nativeQuery = true)
50 Integer updateAppLastActiveTimeAndNicknameAndHeadImg(String username, String nickname, String headimgurl);
51
52 @Modifying
53 @Query(value = "UPDATE `uc_user_app` SET `cellphone`= :#{#resources.cellphone}, `username`= :#{#resources.username},`last_active_time` = now(), `nickname` = :#{#resources.nickname}, `headimgurl` = :#{#resources.headimgurl} " +
54 " WHERE `id` = :#{#resources.id} and `status` = 1 ", nativeQuery = true)
55 Integer updateAppLastActiveTimeAndNicknameAndHeadImgById(@Param("resources") UserApp userApp);
56
57 @Modifying
58 @Query(value = "INSERT INTO `uc_user_app`(`id`, `member_id`, `username`, `password`, `type`, `status`, `nickname`, `headimgurl`, `email`, `cellphone`, `gender`, `birthday`, `last_active_time`, `delete_time`, `tags`, `description`, `create_time`, `update_time`) " +
59 " VALUES (:#{#resources.id}, :#{#resources.memberId}, :#{#resources.username}, :#{#resources.password}, :#{#resources.type}," +
60 " 1, :#{#resources.nickname}, :#{#resources.headimgurl}, :#{#resources.email}, :#{#resources.cellphone}, " +
61 " :#{#resources.gender}, NULL, now(), NULL, :#{#resources.tags}, " +
62 " :#{#resources.description}, :#{#resources.createTime}, now());", nativeQuery = true)
63 void saveByIdManual(@Param("resources") UserAppIdManual userAppIdManual);
64 }
1 package com.topdraw.business.module.user.app.repository;
2
3 import com.topdraw.business.module.user.app.domain.UserAppSimple;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
7 /**
8 * @author XiangHan
9 * @date 2022-06-27
10 */
11 public interface UserAppSimpleRepository extends JpaRepository<UserAppSimple, Long>, JpaSpecificationExecutor<UserAppSimple> {
12
13 }
1 package com.topdraw.business.module.user.app.service;
2
3 import com.topdraw.business.module.user.app.domain.UserAppBind;
4 import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
5
6 import java.util.List;
7
8 /**
9 * @author XiangHan
10 * @date 2022-06-27
11 */
12 public interface UserAppBindService {
13
14 /**
15 * 根据ID查询
16 * @param id ID
17 * @return UserAppBindDTO
18 */
19 UserAppBindDTO findById(Long id);
20
21 /**
22 *
23 * @param resources
24 */
25 UserAppBindDTO create(UserAppBind resources);
26
27 /**
28 *
29 * @param resources
30 */
31 void update(UserAppBind resources);
32
33 /**
34 *
35 * @param id
36 */
37 void delete(Long id);
38
39 /**
40 *
41 * @param account
42 * @return
43 */
44 UserAppBindDTO findFirstByAccount(String account);
45
46 /**
47 *
48 * @param account
49 * @return
50 */
51 boolean cancelUserAppBind(String account, Integer accountType);
52
53 /**
54 *
55 * @param account
56 * @param accountType
57 * @return
58 */
59 UserAppBindDTO findFirstByAccountAndAccountType(String account, Integer accountType);
60
61 /**
62 *
63 * @param resources
64 * @return
65 */
66 boolean updateThirdAccount(UserAppBind resources);
67
68 /**
69 *
70 * @param resources
71 * @return
72 */
73 boolean updateThirdAccountNickname(UserAppBind resources);
74
75 /**
76 *
77 * @param resources
78 * @return
79 */
80 boolean updateValidStatusAndUserAppIdAndNickname(UserAppBind resources);
81
82 boolean appCancellation(List<Long> ids);
83
84 List<UserAppBindDTO> findByUserAppId(Long id);
85 }
1 package com.topdraw.business.module.user.app.service;
2
3 import com.topdraw.business.module.user.app.domain.UserApp;
4 import com.topdraw.business.module.user.app.domain.UserAppBind;
5 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
6 import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
7 import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
8 import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
9 import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
10 import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
11 import com.topdraw.common.ResultInfo;
12
13 /**
14 * @author XiangHan
15 * @date 2022-06-27
16 */
17 public interface UserAppService {
18
19 /**
20 * 根据ID查询
21 * @param id ID
22 * @return UserAppDTO
23 */
24 UserAppDTO findById(Long id);
25
26 /**
27 * 检查账号和秘密
28 * @param username
29 * @return
30 */
31 UserAppDTO findByUsername(String username);
32
33
34 /**
35 *
36 * @param resources
37 */
38 UserAppDTO create(UserApp resources);
39
40 /**
41 *
42 * @param resources
43 */
44 UserAppDTO update(UserApp resources);
45
46 /**
47 *
48 * @param id
49 */
50 void delete(Long id);
51
52 /**
53 *
54 * @param resources
55 * @return
56 */
57 boolean updateLastActiveTime(UserAppBind resources);
58
59 /**
60 *
61 * @param resources
62 * @return
63 */
64 boolean updatePasswordByUsername(UserApp resources);
65
66 /**
67 *
68 * @param resources
69 * @return
70 */
71 boolean updatePasswordById(UserApp resources);
72
73 /**
74 *
75 * @param resources
76 * @return
77 */
78 UserAppSimpleDTO updateAppInfo(UserApp resources);
79
80
81 boolean appCancellation(Long id);
82
83
84 boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources);
85
86 boolean updateAppLastActiveTimeAndNicknameAndHeadImgById(UserApp resources);
87
88 ResultInfo saveAppAndBindApple4Vis(VisUserApple resources);
89
90 ResultInfo saveAppAndBindWeibo4Vis(VisUserWeibo resources);
91
92 ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources);
93
94 ResultInfo saveAppAndBindQq4Vis(VisUserQq resources);
95 }
1 package com.topdraw.business.module.user.app.service.dto;
2
3 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import lombok.Data;
5
6 import java.io.Serializable;
7
8 /**
9 * @author :
10 * @description:
11 * @function :
12 * @date :Created in 2022/7/11 21:21
13 * @version: :
14 * @modified By:
15 * @since : modified in 2022/7/11 21:21
16 */
17 @Data
18 public class AppRegisterDTO implements Serializable {
19
20 private UserAppDTO userAppDTO;
21
22 private MemberDTO memberDTO;
23
24 }
1 package com.topdraw.business.module.user.app.service.dto;
2
3 import lombok.Data;
4 import java.sql.Timestamp;
5 import java.io.Serializable;
6
7
8 /**
9 * @author XiangHan
10 * @date 2022-06-27
11 */
12 @Data
13 public class UserAppBindDTO implements Serializable {
14
15 // 主键
16 private Long id;
17
18 // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
19 private Integer accountType;
20
21 // 第三方账号
22 private String account;
23
24 // app账号id
25 private Long userAppId;
26
27 // 绑定状态 0:解绑;1 绑定
28 private Integer status;
29
30 // 昵称
31 private String nickname;
32
33 // 创建时间
34 private Timestamp createTime;
35
36 // 更新时间
37 private Timestamp updateTime;
38 }
1 package com.topdraw.business.module.user.app.service.dto;
2
3 import lombok.Data;
4
5 import javax.persistence.Transient;
6 import java.sql.Timestamp;
7 import java.io.Serializable;
8
9
10 /**
11 * @author XiangHan
12 * @date 2022-06-27
13 */
14 @Data
15 public class UserAppDTO implements Serializable {
16
17 private Integer accountType;
18
19 // 第三方账号
20 private String account;
21
22 // ID
23 private Long id;
24
25 // 会员id
26 private Long memberId;
27
28 // 用户名(一般为手机号)
29 private String username;
30
31 // 密码
32 private String password;
33
34 // 类型 0:苹果;1:安卓;-1:未知
35 private Integer type;
36
37 // 状态 0:禁用;1:生效;-1:注销
38 private Integer status;
39
40 // 昵称
41 private String nickname;
42
43 // 头像地址
44 private String headimgurl;
45
46 // 邮箱
47 private String email;
48
49 // 手机号
50 private String cellphone;
51
52 // 性别 0:女;1:男;-1:其他
53 private Integer gender;
54
55 // 生日
56 private String birthday;
57
58 // 最近活跃时间
59 private Timestamp lastActiveTime;
60
61 // 注销时间
62 private Timestamp deleteTime;
63
64 // 标签
65 private String tags;
66
67 // 描述
68 private String description;
69
70 // 创建时间
71 private Timestamp createTime;
72
73 // 更新时间
74 private Timestamp updateTime;
75 }
1 package com.topdraw.business.module.user.app.service.dto;
2
3 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
5 import lombok.Data;
6
7 import java.io.Serializable;
8 import java.sql.Timestamp;
9
10 /**
11 * @author XiangHan
12 * @date 2022-06-27
13 */
14 @Data
15 public class UserAppSimpleDTO implements Serializable {
16
17 // ID
18 private Long id;
19
20 // 会员id
21 private Long memberId;
22
23 // 用户名(一般为手机号)
24 private String username;
25
26 // 状态 0:禁用;1:生效;-1:注销
27 private Integer status;
28
29 // 昵称
30 private String nickname;
31
32 // 头像地址
33 private String headimgurl;
34
35 // 邮箱
36 private String email;
37
38 // 手机号
39 private String cellphone;
40
41 // 性别 0:女;1:男;-1:其他
42 private Integer gender;
43
44 // 生日
45 private String birthday;
46
47 // 标签
48 private String tags;
49
50 // 描述
51 private String description;
52
53 private MemberSimpleDTO member;
54
55 }
1 package com.topdraw.business.module.user.app.service.impl;
2
3 import com.topdraw.business.module.user.app.domain.UserAppBind;
4 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.business.module.user.app.repository.UserAppBindRepository;
6 import com.topdraw.business.module.user.app.service.UserAppBindService;
7 import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
8 import com.topdraw.business.module.user.app.service.mapper.UserAppBindMapper;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Service;
11 import org.springframework.transaction.annotation.Propagation;
12 import org.springframework.transaction.annotation.Transactional;
13 import org.springframework.dao.EmptyResultDataAccessException;
14 import org.springframework.util.Assert;
15
16 import java.util.List;
17
18 /**
19 * @author XiangHan
20 * @date 2022-06-27
21 */
22 @Service
23 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
24 public class UserAppBindServiceImpl implements UserAppBindService {
25
26 @Autowired
27 private UserAppBindRepository userAppBindRepository;
28
29 @Autowired
30 private UserAppBindMapper userAppBindMapper;
31
32 @Override
33 public UserAppBindDTO findById(Long id) {
34 UserAppBind userAppBind = this.userAppBindRepository.findById(id).orElseGet(UserAppBind::new);
35 ValidationUtil.isNull(userAppBind.getId(),"UserAppBind","id",id);
36 return this.userAppBindMapper.toDto(userAppBind);
37 }
38
39 @Override
40 @Transactional(rollbackFor = Exception.class)
41 public UserAppBindDTO create(UserAppBind resources) {
42 UserAppBind userAppBind = this.userAppBindRepository.save(resources);
43 return this.userAppBindMapper.toDto(userAppBind);
44 }
45
46 @Override
47 @Transactional(rollbackFor = Exception.class)
48 public void update(UserAppBind resources) {
49 UserAppBind userAppBind = this.userAppBindRepository.findById(resources.getId()).orElseGet(UserAppBind::new);
50 ValidationUtil.isNull( userAppBind.getId(),"UserAppBind","id",resources.getId());
51 userAppBind.copy(resources);
52 this.userAppBindRepository.save(userAppBind);
53 }
54
55 @Override
56 @Transactional(rollbackFor = Exception.class)
57 public void delete(Long id) {
58 Assert.notNull(id, "The given id must not be null!");
59 UserAppBind UserAppBind = this.userAppBindRepository.findById(id).orElseThrow(
60 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserAppBind.class, id), 1));
61 this.userAppBindRepository.delete(UserAppBind);
62 }
63
64 @Override
65 public UserAppBindDTO findFirstByAccount(String account) {
66 UserAppBind userAppBind = this.userAppBindRepository.findFirstByAccount(account).orElseGet(UserAppBind::new);
67 return this.userAppBindMapper.toDto(userAppBind);
68 }
69
70 @Override
71 @Transactional(rollbackFor = Exception.class)
72 public boolean cancelUserAppBind(String account, Integer accountType) {
73 return this.userAppBindRepository.cancelUserAppBind(account, accountType) > 0;
74 }
75
76 @Override
77 @Transactional(readOnly = true)
78 public UserAppBindDTO findFirstByAccountAndAccountType(String account, Integer accountType) {
79 UserAppBind userAppBind = this.userAppBindRepository.findFirstByAccountAndAccountType(account, accountType).orElseGet(UserAppBind::new);
80 return this.userAppBindMapper.toDto(userAppBind);
81 }
82
83 @Override
84 @Transactional(rollbackFor = Exception.class)
85 public boolean updateThirdAccount(UserAppBind resources) {
86 return this.userAppBindRepository.updateThirdAccount(resources) > 0;
87 }
88
89 @Override
90 @Transactional(rollbackFor = Exception.class)
91 public boolean updateThirdAccountNickname(UserAppBind resources) {
92 return this.userAppBindRepository.updateThirdAccountNickname(resources) > 0;
93 }
94
95 @Override
96 @Transactional(rollbackFor = Exception.class)
97 public boolean updateValidStatusAndUserAppIdAndNickname(UserAppBind resources) {
98 return this.userAppBindRepository.updateValidStatusAndUserAppIdAndNickname(resources) > 0;
99 }
100
101 @Override
102 @Transactional(rollbackFor = Exception.class)
103 public boolean appCancellation(List<Long> ids) {
104 return this.userAppBindRepository.appCancellation(ids) > 0;
105 }
106
107 @Override
108 @Transactional(readOnly = true)
109 public List<UserAppBindDTO> findByUserAppId(Long id) {
110 List<UserAppBind> userAppBinds = this.userAppBindRepository.findByUserAppId(id);
111 return this.userAppBindMapper.toDto(userAppBinds);
112 }
113
114
115 }
1 package com.topdraw.business.module.user.app.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.app.domain.UserAppBind;
5 import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author XiangHan
11 * @date 2022-06-27
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface UserAppBindMapper extends BaseMapper<UserAppBindDTO, UserAppBind> {
15
16 }
1 package com.topdraw.business.module.user.app.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.app.domain.UserApp;
5 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author XiangHan
11 * @date 2022-06-27
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface UserAppMapper extends BaseMapper<UserAppDTO, UserApp> {
15
16 }
1 package com.topdraw.business.module.user.app.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.app.domain.UserApp;
5 import com.topdraw.business.module.user.app.domain.UserAppSimple;
6 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
7 import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
8 import org.mapstruct.Mapper;
9 import org.mapstruct.ReportingPolicy;
10
11 /**
12 * @author XiangHan
13 * @date 2022-06-27
14 */
15 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
16 public interface UserAppSimpleMapper extends BaseMapper<UserAppSimpleDTO, UserAppSimple> {
17
18 }
...@@ -24,28 +24,17 @@ public class UserTvBuilder { ...@@ -24,28 +24,17 @@ public class UserTvBuilder {
24 private static final String DEFAULT_CREATE_BY = "system"; 24 private static final String DEFAULT_CREATE_BY = "system";
25 private static final String DEFAULT_UPDATE_BY = "system"; 25 private static final String DEFAULT_UPDATE_BY = "system";
26 26
27 public static UserTv build(UserTv userTv){ 27
28 return build(userTv.getMemberId(),userTv.getMemberCode(),userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(),
29 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy(), userTv.getVisUserId());
30 }
31 28
32 public static UserTv build(Long memberId, String memberCode , UserTv userTv){ 29 public static UserTv build(Long memberId, String memberCode , UserTv userTv){
33 return build(memberId,memberCode,userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(), 30 return build(memberId,memberCode,userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(),
34 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy(), userTv.getVisUserId()); 31 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy(), userTv.getVisUserId(),
35 } 32 userTv.getPlatform(), userTv.getPassword(), userTv.getGroups());
36
37 public static UserTv build(String memberCode, UserTv userTv){
38 return build(null,memberCode,userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(),
39 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy(), userTv.getVisUserId());
40 }
41
42 public static UserTv build(Member member, UserTv userTv){
43 return build(member.getId() , member.getCode(),userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(),
44 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy(), userTv.getVisUserId());
45 } 33 }
46 34
47 public static UserTv build(Long memberId , String memberCode , Long id , String platformAccount , String nickname , String username, 35 public static UserTv build(Long memberId , String memberCode , Long id , String platformAccount , String nickname , String username,
48 Integer loginDays , Integer status ,Integer continueDays , String createBy , String updateBy,Long visUserId){ 36 Integer loginDays , Integer status ,Integer continueDays , String createBy , String updateBy,Long visUserId,
37 String platform, String password, String groups){
49 Assert.notNull(memberId,GlobeExceptionMsg.MEMBER_ID_IS_NULL); 38 Assert.notNull(memberId,GlobeExceptionMsg.MEMBER_ID_IS_NULL);
50 Assert.notNull(memberCode,GlobeExceptionMsg.MEMBER_CODE_IS_NULL); 39 Assert.notNull(memberCode,GlobeExceptionMsg.MEMBER_CODE_IS_NULL);
51 Assert.notNull(platformAccount,GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); 40 Assert.notNull(platformAccount,GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL);
...@@ -55,10 +44,13 @@ public class UserTvBuilder { ...@@ -55,10 +44,13 @@ public class UserTvBuilder {
55 UserTv userTv = new UserTv(); 44 UserTv userTv = new UserTv();
56 userTv.setId(id); 45 userTv.setId(id);
57 userTv.setPlatformAccount(platformAccount); 46 userTv.setPlatformAccount(platformAccount);
47 userTv.setPlatform(platform);
58 userTv.setMemberCode(memberCode); 48 userTv.setMemberCode(memberCode);
59 userTv.setMemberId(memberId); 49 userTv.setMemberId(memberId);
60 userTv.setNickname(StringUtils.isBlank(nickname)?platformAccount:nickname); 50 userTv.setNickname(StringUtils.isBlank(nickname)?platformAccount:nickname);
61 userTv.setUsername(StringUtils.isBlank(username)?platformAccount:username); 51 userTv.setUsername(StringUtils.isBlank(username)?platformAccount:username);
52 userTv.setPassword(password);
53 userTv.setGroups(groups);
62 userTv.setLoginDays(Objects.nonNull(loginDays)?loginDays:DEFAULT_VALUE); 54 userTv.setLoginDays(Objects.nonNull(loginDays)?loginDays:DEFAULT_VALUE);
63 userTv.setLoginType(DEFAULT_VALUE); 55 userTv.setLoginType(DEFAULT_VALUE);
64 userTv.setStatus(Objects.nonNull(status)?status:DEFAULT_VALUE); 56 userTv.setStatus(Objects.nonNull(status)?status:DEFAULT_VALUE);
......
1 package com.topdraw.business.module.user.iptv.domain;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions;
5 import com.topdraw.business.module.common.domain.AsyncMqModule;
6 import com.topdraw.business.module.common.validated.CreateGroup;
7 import com.topdraw.business.module.common.validated.UpdateGroup;
8 import lombok.Data;
9 import lombok.experimental.Accessors;
10 import org.springframework.data.annotation.CreatedDate;
11 import org.springframework.data.annotation.LastModifiedDate;
12 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
13
14 import javax.persistence.*;
15 import javax.validation.constraints.NotNull;
16 import java.io.Serializable;
17 import java.sql.Timestamp;
18
19 /**
20 * @author XiangHan
21 * @date 2021-12-16
22 */
23 @Entity
24 @Data
25 @EntityListeners(AuditingEntityListener.class)
26 @Accessors(chain = true)
27 @Table(name="uc_user_tv")
28 public class UserTvSimple extends AsyncMqModule implements Serializable {
29
30 /** ID */
31 @Id
32 @GeneratedValue(strategy = GenerationType.IDENTITY)
33 @Column(name = "id")
34 private Long id;
35
36 /** 会员id */
37 @Column(name = "member_id")
38 private Long memberId;
39
40 /** 原vis_user_id */
41 @Column(name = "vis_user_id")
42 private Long visUserId;
43
44 /** 绑定的小屏账户会员编码 */
45 @Column(name = "priority_member_code")
46 private String priorityMemberCode;
47
48 /** 绑定的小屏账户会员编码 */
49 @Column(name = "platform_account")
50 private String platformAccount;
51
52 public void copy(UserTvSimple source){
53 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
54 }
55 }
1 package com.topdraw.business.module.user.iptv.growreport.domain;
2
3 import lombok.Data;
4 import lombok.experimental.Accessors;
5 import cn.hutool.core.bean.BeanUtil;
6 import cn.hutool.core.bean.copier.CopyOptions;
7 import javax.persistence.*;
8 import org.springframework.data.annotation.CreatedDate;
9 import org.springframework.data.annotation.LastModifiedDate;
10 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
11 import java.sql.Timestamp;
12
13 import java.io.Serializable;
14
15 /**
16 * @author XiangHan
17 * @date 2022-07-07
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_growth_report")
24 public class GrowthReport implements Serializable {
25
26 @Id
27 @Column(name = "id")
28 private Long id;
29
30 // 用户id
31 @Column(name = "user_id")
32 private Long userId;
33
34 // 会员id
35 @Column(name = "member_id")
36 private Long memberId;
37
38 // 会员code
39 @Column(name = "member_code")
40 private String memberCode;
41
42 // 大屏账号
43 @Column(name = "platform_account")
44 private String platformAccount;
45
46 // 开始日期
47 @Column(name = "start_date")
48 private String startDate;
49
50 // 结束时间
51 @Column(name = "end_date")
52 private String endDate;
53
54 // 栏目播放时长数据
55 @Column(name = "data")
56 private String data;
57
58 // 创建时间
59 @CreatedDate
60 @Column(name = "create_time")
61 private Timestamp createTime;
62
63 // 修改时间
64 @LastModifiedDate
65 @Column(name = "update_time")
66 private Timestamp updateTime;
67
68 public void copy(GrowthReport source){
69 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
70 }
71 }
1 package com.topdraw.business.module.user.iptv.growreport.repository;
2
3 import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
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
9 import java.util.Optional;
10
11 /**
12 * @author XiangHan
13 * @date 2022-07-07
14 */
15 public interface GrowthReportRepository extends JpaRepository<GrowthReport, Long>, JpaSpecificationExecutor<GrowthReport> {
16
17
18 Optional<GrowthReport> findByPlatformAccountAndStartDateAndEndDate(String platformAccount, String weekFirstDay, String weekLastDay);
19
20
21 @Modifying
22 @Query(value = "UPDATE `uc_growth_report` SET `data` = ?2, `update_time` = now() WHERE `id` =?1", nativeQuery = true)
23 Integer updateGrowthReportData(Long id, String data);
24
25 }
1 package com.topdraw.business.module.user.iptv.growreport.rest;
2
3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.annotation.Log;
5 import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
6 import com.topdraw.business.module.user.iptv.growreport.service.GrowthReportService;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.data.domain.Pageable;
9 import org.springframework.validation.annotation.Validated;
10 import org.springframework.web.bind.annotation.*;
11 import io.swagger.annotations.*;
12
13 /**
14 * @author XiangHan
15 * @date 2022-07-07
16 */
17 @Api(tags = "GrowthReport管理")
18 @RestController
19 @RequestMapping("/api/GrowthReport")
20 public class GrowthReportController {
21
22 @Autowired
23 private GrowthReportService GrowthReportService;
24
25 @Log
26 @PostMapping
27 @ApiOperation("新增GrowthReport")
28 public ResultInfo create(@Validated @RequestBody GrowthReport resources) {
29 GrowthReportService.create(resources);
30 return ResultInfo.success();
31 }
32
33 @Log
34 @PutMapping
35 @ApiOperation("修改GrowthReport")
36 public ResultInfo update(@Validated @RequestBody GrowthReport resources) {
37 GrowthReportService.update(resources);
38 return ResultInfo.success();
39 }
40
41
42 @Log
43 @DeleteMapping(value = "/{id}")
44 @ApiOperation("删除GrowthReport")
45 public ResultInfo delete(@PathVariable Long id) {
46 GrowthReportService.delete(id);
47 return ResultInfo.success();
48 }
49
50 }
1 package com.topdraw.business.module.user.iptv.growreport.service;
2
3 import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
4 import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
5
6 /**
7 * @author XiangHan
8 * @date 2022-07-07
9 */
10 public interface GrowthReportService {
11
12 /**
13 * 根据ID查询
14 * @param id ID
15 * @return GrowthReportDTO
16 */
17 GrowthReportDTO findById(Long id);
18
19 void create(GrowthReport resources);
20
21 void update(GrowthReport resources);
22
23 void delete(Long id);
24
25 /**
26 *
27 * @param platformAccount
28 * @param weekFirstDay
29 * @param weekLastDay
30 * @return
31 */
32 GrowthReportDTO findByPlatformAccountAndStartDateAndEndDate(String platformAccount, String weekFirstDay, String weekLastDay);
33
34
35 Integer updateGrowthReportData(Long id, String data);
36 }
1 package com.topdraw.business.module.user.iptv.growreport.service.dto;
2
3 import lombok.Data;
4 import java.sql.Timestamp;
5 import java.io.Serializable;
6 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
7 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
8
9
10 /**
11 * @author XiangHan
12 * @date 2022-07-07
13 */
14 @Data
15 public class GrowthReportDTO implements Serializable {
16
17 // 处理精度丢失问题
18 @JsonSerialize(using= ToStringSerializer.class)
19 private Long id;
20
21 // 用户id
22 private Long userId;
23
24 // 会员id
25 private Long memberId;
26
27 // 会员code
28 private String memberCode;
29
30 // 大屏账号
31 private String platformAccount;
32
33 // 开始日期
34 private String startDate;
35
36 // 结束时间
37 private String endDate;
38
39 // 栏目播放时长数据
40 private String data;
41
42 // 创建时间
43 private Timestamp createTime;
44
45 // 修改时间
46 private Timestamp updateTime;
47 }
1 package com.topdraw.business.module.user.iptv.growreport.service.dto;
2
3 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
4 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
5 import lombok.Data;
6
7 import java.io.Serializable;
8 import java.sql.Timestamp;
9 import java.util.List;
10
11
12 /**
13 * @author XiangHan
14 * @date 2022-07-07
15 */
16 @Data
17 public class GrowthReportRequest implements Serializable {
18
19 private String platformAccount;
20
21 private List<CategoryContent> playDurationWithCategory;
22
23 @Data
24 public static class CategoryContent{
25 private String categoryName;
26 private Long playDuration;
27 private String categoryCode;
28 }
29
30 }
1 package com.topdraw.business.module.user.iptv.growreport.service.impl;
2
3 import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
4 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.business.module.user.iptv.growreport.repository.GrowthReportRepository;
6 import com.topdraw.business.module.user.iptv.growreport.service.GrowthReportService;
7 import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
8 import com.topdraw.business.module.user.iptv.growreport.service.mapper.GrowthReportMapper;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Service;
11 import org.springframework.transaction.annotation.Propagation;
12 import org.springframework.transaction.annotation.Transactional;
13 import org.springframework.dao.EmptyResultDataAccessException;
14 import cn.hutool.core.lang.Snowflake;
15 import cn.hutool.core.util.IdUtil;
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
22 import java.util.List;
23 import java.util.Map;
24
25 /**
26 * @author XiangHan
27 * @date 2022-07-07
28 */
29 @Service
30 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
31 public class GrowthReportServiceImpl implements GrowthReportService {
32
33 @Autowired
34 private GrowthReportRepository growthReportRepository;
35
36 @Autowired
37 private GrowthReportMapper growthReportMapper;
38
39 @Override
40 @Transactional(readOnly = true)
41 public GrowthReportDTO findById(Long id) {
42 GrowthReport growthReport = this.growthReportRepository.findById(id).orElseGet(GrowthReport::new);
43 ValidationUtil.isNull(growthReport.getId(),"GrowthReport","id",id);
44 return this.growthReportMapper.toDto(growthReport);
45 }
46
47 @Override
48 @Transactional(rollbackFor = Exception.class)
49 public void create(GrowthReport resources) {
50 Snowflake snowflake = IdUtil.createSnowflake(1, 1);
51 resources.setId(snowflake.nextId());
52 this.growthReportRepository.save(resources);
53 }
54
55 @Override
56 @Transactional(rollbackFor = Exception.class)
57 public void update(GrowthReport resources) {
58 GrowthReport growthReport = this.growthReportRepository.findById(resources.getId()).orElseGet(GrowthReport::new);
59 ValidationUtil.isNull( growthReport.getId(),"GrowthReport","id",resources.getId());
60 growthReport.copy(resources);
61 this.growthReportRepository.save(growthReport);
62 }
63
64 @Override
65 @Transactional(rollbackFor = Exception.class)
66 public void delete(Long id) {
67 Assert.notNull(id, "The given id must not be null!");
68 GrowthReport growthReport = this.growthReportRepository.findById(id).orElseThrow(
69 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", GrowthReport.class, id), 1));
70 this.growthReportRepository.delete(growthReport);
71 }
72
73 @Override
74 @Transactional(readOnly = true)
75 public GrowthReportDTO findByPlatformAccountAndStartDateAndEndDate(String platformAccount, String weekFirstDay, String weekLastDay) {
76 GrowthReport growthReport = this.growthReportRepository.findByPlatformAccountAndStartDateAndEndDate(platformAccount, weekFirstDay, weekLastDay).orElseGet(GrowthReport::new);
77 return this.growthReportMapper.toDto(growthReport);
78 }
79
80 @Override
81 @Transactional(rollbackFor = Exception.class)
82 public Integer updateGrowthReportData(Long id, String data) {
83 return this.growthReportRepository.updateGrowthReportData(id, data);
84 }
85
86
87 }
1 package com.topdraw.business.module.user.iptv.growreport.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
5 import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author XiangHan
11 * @date 2022-07-07
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface GrowthReportMapper extends BaseMapper<GrowthReportDTO, GrowthReport> {
15
16 }
1 package com.topdraw.business.module.user.iptv.repository; 1 package com.topdraw.business.module.user.iptv.repository;
2 2
3 import com.topdraw.business.module.user.iptv.domain.UserTv; 3 import com.topdraw.business.module.user.iptv.domain.UserTv;
4 import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
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;
7 import org.springframework.data.jpa.repository.Modifying;
8 import org.springframework.data.jpa.repository.Query;
9 import org.springframework.data.repository.query.Param;
10 import org.springframework.transaction.annotation.Transactional;
6 11
12 import java.time.LocalDateTime;
7 import java.util.Optional; 13 import java.util.Optional;
8 14
9 /** 15 /**
...@@ -17,4 +23,13 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif ...@@ -17,4 +23,13 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif
17 Optional<UserTv> findByPriorityMemberCode(String memberCode); 23 Optional<UserTv> findByPriorityMemberCode(String memberCode);
18 24
19 Optional<UserTv> findByMemberId(Long memberId); 25 Optional<UserTv> findByMemberId(Long memberId);
26
27 @Modifying
28 @Query(value = "UPDATE `uc_user_tv` SET `vis_user_id` = ?2, `update_time` = ?3 WHERE `id` = ?1", nativeQuery = true)
29 Integer updateUserTvVisUserId(Long id, Long visUserId, LocalDateTime now);
30
31 @Modifying
32 @Query(value = "UPDATE `uc_user_tv` SET `priority_member_code` = :#{#resources.priorityMemberCode}, `update_time` = now()" +
33 " WHERE `id` = :#{#resources.id}", nativeQuery = true)
34 Integer updatePriorityMemberCode(@Param("resources") UserTv resources);
20 } 35 }
......
1 package com.topdraw.business.module.user.iptv.repository;
2
3 import com.topdraw.business.module.user.iptv.domain.UserTvSimple;
4 import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
5 import org.springframework.data.jpa.repository.JpaRepository;
6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7 import org.springframework.data.jpa.repository.Query;
8
9 /**
10 * @author XiangHan
11 * @date 2021-12-16
12 */
13 public interface UserTvSimpleRepository extends JpaRepository<UserTvSimple, Long>, JpaSpecificationExecutor<UserTvSimple> {
14
15 @Query(value = "SELECT `id`, `vis_user_id` , `member_id` , `platform_account`, `priority_member_code` FROM `uc_user_tv` WHERE `platform_account` = ?1", nativeQuery = true)
16 UserTvSimple findSimpleByPlatformAccount(String platformAccount);
17 }
1 package com.topdraw.business.module.user.iptv.rest;
2
3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.user.iptv.domain.UserTv;
5 import com.topdraw.business.module.user.iptv.service.UserTvService;
6 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
7 import com.topdraw.common.ResultInfo;
8 import com.topdraw.exception.BadRequestException;
9 import com.topdraw.exception.GlobeExceptionMsg;
10 import io.swagger.annotations.Api;
11 import io.swagger.annotations.ApiOperation;
12 import lombok.extern.slf4j.Slf4j;
13 import org.apache.commons.lang3.StringUtils;
14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.validation.annotation.Validated;
16 import org.springframework.web.bind.annotation.*;
17
18 import java.util.Objects;
19
20 /**
21 * @author XiangHan
22 * @date 2021-12-16
23 */
24 @Api(tags = "微信管理")
25 @RestController
26 @RequestMapping("/uce/userTv")
27 @Slf4j
28 public class UserTvController {
29
30 @Autowired
31 private UserTvService userTvService;
32
33 @PostMapping(value = "/updateUserTvVisUserId")
34 @ApiOperation("新增UserWeixin")
35 @AnonymousAccess
36 public ResultInfo updateUserTvVisUserId(@Validated @RequestBody UserTv resources) {
37
38 log.info("UserOperationController ==> updateUserTvVisUserId ==>> param ==> {}",resources);
39
40 if (StringUtils.isBlank(resources.getPlatformAccount())){
41 throw new BadRequestException(GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL);
42 }
43
44 if (Objects.isNull(resources.getVisUserId())){
45 throw new BadRequestException(GlobeExceptionMsg.VIS_USER_ID_IS_NULL);
46 }
47
48 UserTvDTO userTvDTO = this.userTvService.updateUserTvVisUserId(resources);
49 if (Objects.nonNull(userTvDTO.getId()))
50 return ResultInfo.success(userTvDTO);
51 else return ResultInfo.failure("操作失败,请检查 ==>> /uce/userTv/updateUserTvVisUserId");
52 }
53
54 }
...@@ -3,6 +3,7 @@ package com.topdraw.business.module.user.iptv.service; ...@@ -3,6 +3,7 @@ package com.topdraw.business.module.user.iptv.service;
3 import com.topdraw.business.module.member.service.dto.MemberDTO; 3 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import com.topdraw.business.module.user.iptv.domain.UserTv; 4 import com.topdraw.business.module.user.iptv.domain.UserTv;
5 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 5 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
6 import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
6 7
7 /** 8 /**
8 * @author XiangHan 9 * @author XiangHan
...@@ -51,6 +52,13 @@ public interface UserTvService { ...@@ -51,6 +52,13 @@ public interface UserTvService {
51 52
52 /** 53 /**
53 * 54 *
55 * @param platformAccount
56 * @return
57 */
58 UserTvSimpleDTO findSimpleByPlatformAccount(String platformAccount);
59
60 /**
61 *
54 * @param memberCode 62 * @param memberCode
55 * @return 63 * @return
56 */ 64 */
...@@ -69,7 +77,7 @@ public interface UserTvService { ...@@ -69,7 +77,7 @@ public interface UserTvService {
69 * @param memberCode 77 * @param memberCode
70 * @return 78 * @return
71 */ 79 */
72 boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId,String memberCode); 80 boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode);
73 81
74 /** 82 /**
75 * 83 *
...@@ -77,4 +85,18 @@ public interface UserTvService { ...@@ -77,4 +85,18 @@ public interface UserTvService {
77 * @return 85 * @return
78 */ 86 */
79 MemberDTO findMemberByPlatformAccount(String platformAccount); 87 MemberDTO findMemberByPlatformAccount(String platformAccount);
88
89 /**
90 *
91 * @param resources
92 * @return
93 */
94 UserTvDTO updateUserTvVisUserId(UserTv resources);
95
96 /**
97 *
98 * @param resources
99 * @return
100 */
101 UserTvDTO doUpdatePriorityMemberCode(UserTv resources);
80 } 102 }
......
1 package com.topdraw.business.module.user.iptv.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6
7
8 /**
9 * @author XiangHan
10 * @date 2021-12-16
11 */
12 @Data
13 public class UserTvSimpleDTO implements Serializable {
14
15 private Long visUserId;
16 /** 绑定的小屏账户会员编码 */
17 private String priorityMemberCode;
18 /** 会员id */
19 private Long memberId;
20
21 private String platformAccount;
22 }
23
24
1 package com.topdraw.business.module.user.iptv.service.impl; 1 package com.topdraw.business.module.user.iptv.service.impl;
2 2
3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONObject;
5 import com.topdraw.aspect.AsyncMqSend;
3 import com.topdraw.business.module.member.service.MemberService; 6 import com.topdraw.business.module.member.service.MemberService;
4 import com.topdraw.business.module.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.member.service.dto.MemberDTO;
5 import com.topdraw.business.module.user.iptv.domain.UserTv; 8 import com.topdraw.business.module.user.iptv.domain.UserTv;
9 import com.topdraw.business.module.user.iptv.domain.UserTvSimple;
10 import com.topdraw.business.module.user.iptv.repository.UserTvSimpleRepository;
11 import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
12 import com.topdraw.business.module.user.iptv.service.mapper.UserTvSimpleMapper;
13 import com.topdraw.business.RedisKeyConstants;
6 import com.topdraw.exception.EntityNotFoundException; 14 import com.topdraw.exception.EntityNotFoundException;
7 import com.topdraw.exception.GlobeExceptionMsg; 15 import com.topdraw.exception.GlobeExceptionMsg;
16 import com.topdraw.utils.RedisUtils;
8 import com.topdraw.utils.ValidationUtil; 17 import com.topdraw.utils.ValidationUtil;
9 import com.topdraw.business.module.user.iptv.repository.UserTvRepository; 18 import com.topdraw.business.module.user.iptv.repository.UserTvRepository;
10 import com.topdraw.business.module.user.iptv.service.UserTvService; 19 import com.topdraw.business.module.user.iptv.service.UserTvService;
11 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 20 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
12 import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper; 21 import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper;
22 import lombok.extern.slf4j.Slf4j;
13 import org.apache.commons.lang3.StringUtils; 23 import org.apache.commons.lang3.StringUtils;
24 import org.springframework.aop.framework.AopContext;
14 import org.springframework.beans.factory.annotation.Autowired; 25 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
16 import org.springframework.transaction.annotation.Propagation; 27 import org.springframework.transaction.annotation.Propagation;
...@@ -18,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -18,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional;
18 import org.springframework.dao.EmptyResultDataAccessException; 29 import org.springframework.dao.EmptyResultDataAccessException;
19 import org.springframework.util.Assert; 30 import org.springframework.util.Assert;
20 31
32 import java.time.LocalDateTime;
33 import java.util.Map;
21 import java.util.Objects; 34 import java.util.Objects;
22 import java.util.Optional; 35 import java.util.Optional;
23 36
...@@ -27,15 +40,26 @@ import java.util.Optional; ...@@ -27,15 +40,26 @@ import java.util.Optional;
27 */ 40 */
28 @Service 41 @Service
29 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 42 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
43 @Slf4j
30 public class UserTvServiceImpl implements UserTvService { 44 public class UserTvServiceImpl implements UserTvService {
31 45
32 46
33 @Autowired 47 @Autowired
34 private UserTvMapper userTvMapper; 48 private UserTvMapper userTvMapper;
35 @Autowired 49 @Autowired
50 private UserTvSimpleMapper userTvSimpleMapper;
51 @Autowired
36 private MemberService memberService; 52 private MemberService memberService;
37 @Autowired 53 @Autowired
38 private UserTvRepository userTvRepository; 54 private UserTvRepository userTvRepository;
55 @Autowired
56 private UserTvSimpleRepository userTvSimpleRepository;
57
58 @Autowired
59 private RedisUtils redisUtils;
60
61 @AsyncMqSend
62 public void asyncUpdateUserTvVisUserId(UserTvDTO userTvDTO) {}
39 63
40 /** 64 /**
41 * 获取大屏账户对应的会员 65 * 获取大屏账户对应的会员
...@@ -46,6 +70,7 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -46,6 +70,7 @@ public class UserTvServiceImpl implements UserTvService {
46 * @return 70 * @return
47 */ 71 */
48 @Override 72 @Override
73 @Transactional(readOnly = true)
49 public MemberDTO findMemberByPlatformAccount(String platformAccount){ 74 public MemberDTO findMemberByPlatformAccount(String platformAccount){
50 // 大屏账户 75 // 大屏账户
51 UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); 76 UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount);
...@@ -64,6 +89,41 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -64,6 +89,41 @@ public class UserTvServiceImpl implements UserTvService {
64 throw new EntityNotFoundException(UserTvDTO.class,"platformAccount", GlobeExceptionMsg.IPTV_IS_NULL); 89 throw new EntityNotFoundException(UserTvDTO.class,"platformAccount", GlobeExceptionMsg.IPTV_IS_NULL);
65 } 90 }
66 91
92 @Override
93 @Transactional(rollbackFor = Exception.class)
94 public UserTvDTO updateUserTvVisUserId(UserTv resources) {
95
96 String platformAccount = resources.getPlatformAccount();
97
98 UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount);
99
100 if (Objects.nonNull(userTvDTO.getId())) {
101
102 Integer integer = this.userTvRepository.updateUserTvVisUserId(userTvDTO.getId(), resources.getVisUserId(), LocalDateTime.now());
103
104 if (integer == 1) {
105 log.info("修改大屏vis_user id成功,同步至大屏侧数据库, userTvDTO ==>> {}", userTvDTO);
106 ((UserTvServiceImpl) AopContext.currentProxy()).asyncUpdateUserTvVisUserId(userTvDTO);
107 }
108
109 return this.findById(userTvDTO.getId());
110 }
111
112 return null;
113 }
114
115 @Override
116 @Transactional(rollbackFor = Exception.class)
117 public UserTvDTO doUpdatePriorityMemberCode(UserTv resources) {
118 Integer count = this.userTvRepository.updatePriorityMemberCode(resources);
119 if (Objects.nonNull(count) && count > 0) {
120 UserTv userTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new);
121 return this.userTvMapper.toDto(userTv);
122 }
123 return this.userTvMapper.toDto(resources);
124 }
125
126
67 private MemberDTO findMemberByMemberCode(String memberCode) { 127 private MemberDTO findMemberByMemberCode(String memberCode) {
68 return this.memberService.findByCode(memberCode); 128 return this.memberService.findByCode(memberCode);
69 } 129 }
...@@ -73,6 +133,7 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -73,6 +133,7 @@ public class UserTvServiceImpl implements UserTvService {
73 } 133 }
74 134
75 @Override 135 @Override
136 @Transactional(readOnly = true)
76 public UserTvDTO findById(Long id) { 137 public UserTvDTO findById(Long id) {
77 UserTv UserTv = this.userTvRepository.findById(id).orElseGet(UserTv::new); 138 UserTv UserTv = this.userTvRepository.findById(id).orElseGet(UserTv::new);
78 ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id); 139 ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id);
...@@ -123,16 +184,38 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -123,16 +184,38 @@ public class UserTvServiceImpl implements UserTvService {
123 } 184 }
124 185
125 @Override 186 @Override
187 @Transactional(readOnly = true)
126 public UserTvDTO findByPlatformAccount(String platformAccount) { 188 public UserTvDTO findByPlatformAccount(String platformAccount) {
127 Optional<UserTv> userTv = this.userTvRepository.findByPlatformAccount(platformAccount); 189 UserTv userTv = this.userTvRepository.findByPlatformAccount(platformAccount).orElseGet(UserTv::new);
128 if (userTv.isPresent()) { 190 return this.userTvMapper.toDto(userTv);
129 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
130 return this.userTvMapper.toDto(userTv.get());
131 } 191 }
132 return null; 192
193 @Override
194 // @Cacheable(cacheNames = RedisKeyConstants.cacheUserTvByPlatformAccount, key = "#platformAccount")
195 public UserTvSimpleDTO findSimpleByPlatformAccount(String platformAccount) {
196
197 Object userTvSimpleObj = this.redisUtils.get(RedisKeyConstants.cacheVisUserByPlatformAccount + "::" + platformAccount);
198 if (Objects.nonNull(userTvSimpleObj)) {
199 Map<String, Object> map = (Map<String, Object>)userTvSimpleObj;
200 UserTvSimpleDTO userTvSimpleDTO = new UserTvSimpleDTO();
201 userTvSimpleDTO.setPlatformAccount(map.get("platformAccount").toString());
202 userTvSimpleDTO.setMemberId(Long.valueOf(map.get("memberId").toString()));
203 userTvSimpleDTO.setPriorityMemberCode(map.get("priorityMemberCode") == null ? "" : map.get("priorityMemberCode").toString());
204 return userTvSimpleDTO;
205 }
206
207 UserTvSimple userTvSimple = this.userTvSimpleRepository.findSimpleByPlatformAccount(platformAccount);
208 if (Objects.nonNull(userTvSimple)) {
209 JSONObject userTvSimpleJSON = JSONObject.parseObject(JSON.toJSONString(userTvSimple), JSONObject.class);
210 this.redisUtils.set(RedisKeyConstants.cacheVisUserByPlatformAccount + "::" + platformAccount, userTvSimpleJSON);
211 return this.userTvSimpleMapper.toDto(userTvSimple);
212 }
213
214 return this.userTvSimpleMapper.toDto(userTvSimple);
133 } 215 }
134 216
135 @Override 217 @Override
218 @Transactional(readOnly = true)
136 public UserTvDTO findByPriorityMemberCode(String memberCode) { 219 public UserTvDTO findByPriorityMemberCode(String memberCode) {
137 Optional<UserTv> userTv = this.userTvRepository.findByPriorityMemberCode(memberCode); 220 Optional<UserTv> userTv = this.userTvRepository.findByPriorityMemberCode(memberCode);
138 if (userTv.isPresent()) { 221 if (userTv.isPresent()) {
...@@ -143,6 +226,7 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -143,6 +226,7 @@ public class UserTvServiceImpl implements UserTvService {
143 } 226 }
144 227
145 @Override 228 @Override
229 @Transactional(readOnly = true)
146 public UserTvDTO findByMemberId(Long memberId) { 230 public UserTvDTO findByMemberId(Long memberId) {
147 Optional<UserTv> userTv = this.userTvRepository.findByMemberId(memberId); 231 Optional<UserTv> userTv = this.userTvRepository.findByMemberId(memberId);
148 if (userTv.isPresent()) { 232 if (userTv.isPresent()) {
...@@ -153,6 +237,7 @@ public class UserTvServiceImpl implements UserTvService { ...@@ -153,6 +237,7 @@ public class UserTvServiceImpl implements UserTvService {
153 } 237 }
154 238
155 @Override 239 @Override
240 @Transactional(readOnly = true)
156 public boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode) { 241 public boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode) {
157 // 检查会员是否存在 242 // 检查会员是否存在
158 this.checkMember(memberId, memberCode); 243 this.checkMember(memberId, memberCode);
......
1 package com.topdraw.business.module.user.iptv.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.user.iptv.domain.UserTv;
5 import com.topdraw.business.module.user.iptv.domain.UserTvSimple;
6 import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
7 import org.mapstruct.Mapper;
8 import org.mapstruct.ReportingPolicy;
9
10 /**
11 * @author XiangHan
12 * @date 2021-12-16
13 */
14 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
15 public interface UserTvSimpleMapper extends BaseMapper<UserTvSimpleDTO, UserTvSimple> {
16
17 }
...@@ -29,9 +29,7 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J ...@@ -29,9 +29,7 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J
29 Optional<UserWeixin> findFirstByMemberId(Long memberId); 29 Optional<UserWeixin> findFirstByMemberId(Long memberId);
30 30
31 @Modifying 31 @Modifying
32 @Transactional 32 @Query(value = "UPDATE `uc_user_weixin` SET update_time = now(), `status` = :#{#resources.status}" +
33 @Query(value = "update `uc_user_weixin` set update_time = :#{#resources.updateTime} " + 33 " WHERE `id` = :#{#resources.id}", nativeQuery = true)
34 "where appid = :#{#resources.appid} and openid = :#{#resources.openid}", nativeQuery = true) 34 Integer updateWeixinStatus(@Param("resources") UserWeixin resource);
35 void updateTime(@Param("resources") UserWeixin resources);
36
37 } 35 }
......
...@@ -31,12 +31,6 @@ public interface UserWeixinService { ...@@ -31,12 +31,6 @@ public interface UserWeixinService {
31 31
32 /** 32 /**
33 * 33 *
34 * @param resources
35 */
36 void updateTime(UserWeixin resources);
37
38 /**
39 *
40 * @param id 34 * @param id
41 */ 35 */
42 void delete(Long id); 36 void delete(Long id);
...@@ -87,4 +81,11 @@ public interface UserWeixinService { ...@@ -87,4 +81,11 @@ public interface UserWeixinService {
87 * @return 81 * @return
88 */ 82 */
89 UserWeixinDTO findFirstByMemberId(Long memberId); 83 UserWeixinDTO findFirstByMemberId(Long memberId);
84
85 /**
86 *
87 * @param userWeixin
88 * @return
89 */
90 UserWeixinDTO doUpdateWeixinStatus(UserWeixin userWeixin);
90 } 91 }
......
...@@ -14,6 +14,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -14,6 +14,8 @@ import org.springframework.transaction.annotation.Transactional;
14 import org.springframework.dao.EmptyResultDataAccessException; 14 import org.springframework.dao.EmptyResultDataAccessException;
15 import org.springframework.util.Assert; 15 import org.springframework.util.Assert;
16 16
17 import java.util.Objects;
18
17 /** 19 /**
18 * @author XiangHan 20 * @author XiangHan
19 * @date 2021-12-16 21 * @date 2021-12-16
...@@ -54,11 +56,6 @@ public class UserWeixinServiceImpl implements UserWeixinService { ...@@ -54,11 +56,6 @@ public class UserWeixinServiceImpl implements UserWeixinService {
54 } 56 }
55 57
56 @Override 58 @Override
57 public void updateTime(UserWeixin resources) {
58 this.userWeixinRepository.updateTime(resources);
59 }
60
61 @Override
62 @Transactional(rollbackFor = Exception.class) 59 @Transactional(rollbackFor = Exception.class)
63 public void delete(Long id) { 60 public void delete(Long id) {
64 Assert.notNull(id, "The given id must not be null!"); 61 Assert.notNull(id, "The given id must not be null!");
...@@ -104,4 +101,15 @@ public class UserWeixinServiceImpl implements UserWeixinService { ...@@ -104,4 +101,15 @@ public class UserWeixinServiceImpl implements UserWeixinService {
104 return this.userWeixinMapper.toDto(userWeixin); 101 return this.userWeixinMapper.toDto(userWeixin);
105 } 102 }
106 103
104 @Override
105 @Transactional(rollbackFor = Exception.class)
106 public UserWeixinDTO doUpdateWeixinStatus(UserWeixin resource) {
107 Integer count = this.userWeixinRepository.updateWeixinStatus(resource);
108 if (Objects.nonNull(count) && count > 0) {
109 UserWeixin userWeixin = this.userWeixinRepository.findById(resource.getId()).orElseGet(UserWeixin::new);
110 return this.userWeixinMapper.toDto(userWeixin);
111 }
112 return this.userWeixinMapper.toDto(resource);
113 }
114
107 } 115 }
......
1 package com.topdraw.weixin.subscribe.domain; 1 package com.topdraw.business.module.user.weixin.subscribe.domain;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import lombok.experimental.Accessors; 4 import lombok.experimental.Accessors;
...@@ -54,14 +54,22 @@ public class WechatSubscribeRecord implements Serializable { ...@@ -54,14 +54,22 @@ public class WechatSubscribeRecord implements Serializable {
54 @Column(name = "entity_type") 54 @Column(name = "entity_type")
55 private Integer entityType; 55 private Integer entityType;
56 56
57 // 来源类型 1:大屏;2:营销活动;3:其他; 57 // 业务场景 0:分享;1:大屏扫码免费看;2:大屏线上活动扫码引导关注;3:小屏线上活动长按二维码引导关注;4:线下活动海报;5:线下机构/渠道引流;99:其他;
58 @Column(name = "source_type") 58 @Column(name = "source_scence")
59 private Integer sourceType; 59 private Integer sourceScence;
60 60
61 // 来源描述 61 // 来源描述,前端参数源
62 @Column(name = "source_info") 62 @Column(name = "source_info")
63 private String sourceInfo; 63 private String sourceInfo;
64 64
65 // 来源描述,系统/运营手动维护
66 @Column(name = "source_desc")
67 private String sourceDesc;
68
69 // 微信场景值 1007:单人聊天会话中的小程序消息卡片;1047:扫描小程序码;详见:https://developers.weixin.qq.com/miniprogram/dev/reference/scene-list.html
70 @Column(name = "wx_scence")
71 private Integer wxScence;
72
65 // 创建时间 73 // 创建时间
66 @CreatedDate 74 @CreatedDate
67 @Column(name = "create_time") 75 @Column(name = "create_time")
......