1.同步master,优化任务处理过程
Showing
22 changed files
with
363 additions
and
110 deletions
| ... | @@ -5,7 +5,9 @@ import org.springframework.data.jpa.repository.JpaRepository; | ... | @@ -5,7 +5,9 @@ import org.springframework.data.jpa.repository.JpaRepository; |
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| 6 | 6 | ||
| 7 | import java.sql.Timestamp; | 7 | import java.sql.Timestamp; |
| 8 | import java.time.LocalDate; | ||
| 8 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
| 10 | import java.util.Date; | ||
| 9 | 11 | ||
| 10 | /** | 12 | /** |
| 11 | * @author XiangHan | 13 | * @author XiangHan |
| ... | @@ -15,7 +17,7 @@ public interface CouponHistoryRepository extends JpaRepository<CouponHistory, Lo | ... | @@ -15,7 +17,7 @@ public interface CouponHistoryRepository extends JpaRepository<CouponHistory, Lo |
| 15 | 17 | ||
| 16 | Long countByUserId(Long userId); | 18 | Long countByUserId(Long userId); |
| 17 | 19 | ||
| 18 | Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now); | 20 | Long countByUserIdAndExpireTimeBefore(Long userId, Date now); |
| 19 | 21 | ||
| 20 | Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime); | 22 | Long countByUserIdAndExpireTimeBetween(Long userId, Date now, Date expireTime); |
| 21 | } | 23 | } | ... | ... |
| ... | @@ -3,6 +3,7 @@ package com.topdraw.business.module.coupon.history.service; | ... | @@ -3,6 +3,7 @@ package com.topdraw.business.module.coupon.history.service; |
| 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; | 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
| 4 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; | 4 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; |
| 5 | 5 | ||
| 6 | import java.time.LocalDate; | ||
| 6 | import java.time.LocalDateTime; | 7 | import java.time.LocalDateTime; |
| 7 | 8 | ||
| 8 | /** | 9 | /** | ... | ... |
| ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.coupon.history.service.impl; | ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.coupon.history.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; | 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
| 4 | import com.topdraw.business.module.coupon.history.domain.CouponHistoryBuilder; | 4 | import com.topdraw.business.module.coupon.history.domain.CouponHistoryBuilder; |
| 5 | import com.topdraw.util.LocalDateTimeUtil; | ||
| 5 | import com.topdraw.utils.ValidationUtil; | 6 | import com.topdraw.utils.ValidationUtil; |
| 6 | import com.topdraw.business.module.coupon.history.repository.CouponHistoryRepository; | 7 | import com.topdraw.business.module.coupon.history.repository.CouponHistoryRepository; |
| 7 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; | 8 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; |
| ... | @@ -12,7 +13,11 @@ import org.springframework.stereotype.Service; | ... | @@ -12,7 +13,11 @@ 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; |
| 14 | 15 | ||
| 16 | import java.sql.Date; | ||
| 17 | import java.time.LocalDate; | ||
| 15 | import java.time.LocalDateTime; | 18 | import java.time.LocalDateTime; |
| 19 | import java.time.ZoneId; | ||
| 20 | import java.time.ZonedDateTime; | ||
| 16 | 21 | ||
| 17 | /** | 22 | /** |
| 18 | * @author XiangHan | 23 | * @author XiangHan |
| ... | @@ -49,12 +54,13 @@ public class CouponHistoryServiceImpl implements CouponHistoryService { | ... | @@ -49,12 +54,13 @@ public class CouponHistoryServiceImpl implements CouponHistoryService { |
| 49 | 54 | ||
| 50 | @Override | 55 | @Override |
| 51 | public Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now) { | 56 | public Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now) { |
| 52 | return this.couponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now); | 57 | return this.couponHistoryRepository.countByUserIdAndExpireTimeBefore(userId, LocalDateTimeUtil.LocalDateTime2Date(now)); |
| 53 | } | 58 | } |
| 54 | 59 | ||
| 55 | @Override | 60 | @Override |
| 56 | public Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime) { | 61 | public Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime) { |
| 57 | return this.couponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime); | 62 | return this.couponHistoryRepository.countByUserIdAndExpireTimeBetween(userId, LocalDateTimeUtil.LocalDateTime2Date(now) |
| 63 | , LocalDateTimeUtil.LocalDateTime2Date(expireTime)); | ||
| 58 | } | 64 | } |
| 59 | 65 | ||
| 60 | } | 66 | } | ... | ... |
| ... | @@ -34,7 +34,7 @@ public class CouponServiceImpl implements CouponService { | ... | @@ -34,7 +34,7 @@ public class CouponServiceImpl implements CouponService { |
| 34 | Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL); | 34 | Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL); |
| 35 | 35 | ||
| 36 | Coupon coupon = this.couponRepository.findById(id).orElseGet(Coupon::new); | 36 | Coupon coupon = this.couponRepository.findById(id).orElseGet(Coupon::new); |
| 37 | ValidationUtil.isNull(coupon.getId(),"Coupon","id",id); | 37 | // ValidationUtil.isNull(coupon.getId(),"Coupon","id",id); |
| 38 | return this.couponMapper.toDto(coupon); | 38 | return this.couponMapper.toDto(coupon); |
| 39 | } | 39 | } |
| 40 | 40 | ... | ... |
| ... | @@ -30,7 +30,7 @@ public class Member implements Serializable { | ... | @@ -30,7 +30,7 @@ public class Member implements Serializable { |
| 30 | private String platformAccount; | 30 | private String platformAccount; |
| 31 | 31 | ||
| 32 | /** 会员过期时间 */ | 32 | /** 会员过期时间 */ |
| 33 | @Column(name = "vip_expire_time", nullable = false) | 33 | @Column(name = "vip_expire_time") |
| 34 | private Timestamp vipExpireTime; | 34 | private Timestamp vipExpireTime; |
| 35 | 35 | ||
| 36 | /** 主键 */ | 36 | /** 主键 */ |
| ... | @@ -41,15 +41,15 @@ public class Member implements Serializable { | ... | @@ -41,15 +41,15 @@ public class Member implements Serializable { |
| 41 | private Long id; | 41 | private Long id; |
| 42 | 42 | ||
| 43 | /** 标识 */ | 43 | /** 标识 */ |
| 44 | @Column(name = "code", nullable = false) | 44 | @Column(name = "code") |
| 45 | private String code; | 45 | private String code; |
| 46 | 46 | ||
| 47 | /** 类型 1:大屏;2:小屏 */ | 47 | /** 类型 1:大屏;2:小屏 */ |
| 48 | @Column(name = "`type`", nullable = false) | 48 | @Column(name = "`type`") |
| 49 | private Integer type; | 49 | private Integer type; |
| 50 | 50 | ||
| 51 | /** 状态 0:不可用;1:可用 */ | 51 | /** 状态 0:不可用;1:可用 */ |
| 52 | @Column(name = "`status`", nullable = false) | 52 | @Column(name = "`status`") |
| 53 | private Integer status; | 53 | private Integer status; |
| 54 | 54 | ||
| 55 | /** 昵称 base64 */ | 55 | /** 昵称 base64 */ |
| ... | @@ -61,7 +61,7 @@ public class Member implements Serializable { | ... | @@ -61,7 +61,7 @@ public class Member implements Serializable { |
| 61 | private String description; | 61 | private String description; |
| 62 | 62 | ||
| 63 | /** 性别 0:女;1:男;-1:未知 */ | 63 | /** 性别 0:女;1:男;-1:未知 */ |
| 64 | @Column(name = "gender", nullable = false) | 64 | @Column(name = "gender") |
| 65 | private Integer gender; | 65 | private Integer gender; |
| 66 | 66 | ||
| 67 | /** 生日 */ | 67 | /** 生日 */ |
| ... | @@ -81,11 +81,11 @@ public class Member implements Serializable { | ... | @@ -81,11 +81,11 @@ public class Member implements Serializable { |
| 81 | private String tags; | 81 | private String tags; |
| 82 | 82 | ||
| 83 | /** 是否会员 0:非会员;1:会员 */ | 83 | /** 是否会员 0:非会员;1:会员 */ |
| 84 | @Column(name = "vip", nullable = false) | 84 | @Column(name = "vip") |
| 85 | private Integer vip; | 85 | private Integer vip; |
| 86 | 86 | ||
| 87 | /** 会员等级(对应level表的level字段,非id) */ | 87 | /** 会员等级(对应level表的level字段,非id) */ |
| 88 | @Column(name = "`level`", nullable = false) | 88 | @Column(name = "`level`") |
| 89 | private Integer level; | 89 | private Integer level; |
| 90 | 90 | ||
| 91 | /** 成长值 */ | 91 | /** 成长值 */ | ... | ... |
| ... | @@ -3,7 +3,11 @@ package com.topdraw.business.module.member.repository; | ... | @@ -3,7 +3,11 @@ package com.topdraw.business.module.member.repository; |
| 3 | import com.topdraw.business.module.member.domain.Member; | 3 | import com.topdraw.business.module.member.domain.Member; |
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| 6 | 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 | ||
| 10 | import java.time.LocalDateTime; | ||
| 7 | import java.util.List; | 11 | import java.util.List; |
| 8 | import java.util.Optional; | 12 | import java.util.Optional; |
| 9 | 13 | ||
| ... | @@ -18,4 +22,25 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif | ... | @@ -18,4 +22,25 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif |
| 18 | List<Member> findByUserIptvId(Long id); | 22 | List<Member> findByUserIptvId(Long id); |
| 19 | 23 | ||
| 20 | Optional<Member> findByIdOrCode(Long id,String code); | 24 | Optional<Member> findByIdOrCode(Long id,String code); |
| 25 | |||
| 26 | |||
| 27 | @Modifying | ||
| 28 | @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 | void updateUserIptvIdById(Long id, Long userIptvId, LocalDateTime now); | ||
| 31 | |||
| 32 | @Modifying | ||
| 33 | @Query(value = "UPDATE `uc_member` SET `exp` = :#{#resources.exp}, `level` = :#{#resources.level} , `update_time`= now() " + | ||
| 34 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) | ||
| 35 | void updateExpAndLevel(@Param("resources") Member member); | ||
| 36 | |||
| 37 | @Modifying | ||
| 38 | @Query(value = "UPDATE `uc_member` SET `points` = :#{#resources.points}, `due_points` = :#{#resources.duePoints} , `update_time`= now() " + | ||
| 39 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) | ||
| 40 | void updatePointAndDuePoint(@Param("resources") Member resources); | ||
| 41 | |||
| 42 | @Modifying | ||
| 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) | ||
| 45 | void doUpdateMemberCoupon(@Param("resources") Member member); | ||
| 21 | } | 46 | } | ... | ... |
| ... | @@ -115,15 +115,40 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -115,15 +115,40 @@ public class MemberServiceImpl implements MemberService { |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | @Override | 117 | @Override |
| 118 | @Transactional(rollbackFor = Exception.class) | ||
| 118 | public MemberDTO doUpdateMemberExpAndLevel(Member resources) { | 119 | public MemberDTO doUpdateMemberExpAndLevel(Member resources) { |
| 119 | MemberDTO memberDTO = this.update(resources); | 120 | this.redisUtils.doLock("member::code" + resources.getCode()); |
| 120 | return memberDTO; | 121 | try { |
| 122 | MemberDTO memberDTO = this.findById(resources.getId()); | ||
| 123 | if (Objects.nonNull(memberDTO)) { | ||
| 124 | this.memberRepository.updateExpAndLevel(resources); | ||
| 125 | } | ||
| 126 | return memberDTO; | ||
| 127 | } catch (Exception e) { | ||
| 128 | e.printStackTrace(); | ||
| 129 | throw e; | ||
| 130 | } finally { | ||
| 131 | this.redisUtils.doUnLock("member::code" + resources.getCode()); | ||
| 132 | } | ||
| 121 | } | 133 | } |
| 122 | 134 | ||
| 123 | @Override | 135 | @Override |
| 136 | @Transactional(rollbackFor = Exception.class) | ||
| 124 | public MemberDTO doUpdateMemberCoupon(Member member) { | 137 | public MemberDTO doUpdateMemberCoupon(Member member) { |
| 125 | MemberDTO memberDTO = this.update(member); | 138 | // MemberDTO memberDTO = this.update(member); |
| 126 | return memberDTO; | 139 | this.redisUtils.doLock("member::code" + member.getCode()); |
| 140 | try { | ||
| 141 | MemberDTO memberDTO = this.findById(member.getId()); | ||
| 142 | if (Objects.nonNull(memberDTO)) { | ||
| 143 | this.memberRepository.doUpdateMemberCoupon(member); | ||
| 144 | } | ||
| 145 | return memberDTO; | ||
| 146 | } catch (Exception e) { | ||
| 147 | e.printStackTrace(); | ||
| 148 | throw e; | ||
| 149 | } finally { | ||
| 150 | this.redisUtils.doUnLock("member::code" + member.getCode()); | ||
| 151 | } | ||
| 127 | } | 152 | } |
| 128 | 153 | ||
| 129 | @Override | 154 | @Override |
| ... | @@ -188,21 +213,24 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -188,21 +213,24 @@ public class MemberServiceImpl implements MemberService { |
| 188 | @Transactional(rollbackFor = Exception.class) | 213 | @Transactional(rollbackFor = Exception.class) |
| 189 | public MemberDTO doUpdateMemberPoints(Member resources) { | 214 | public MemberDTO doUpdateMemberPoints(Member resources) { |
| 190 | try { | 215 | try { |
| 191 | this.redisUtils.doLock("member::update::code" + resources.getCode()); | 216 | this.redisUtils.doLock("member::code" + resources.getCode()); |
| 192 | 217 | ||
| 193 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); | 218 | /*ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); |
| 194 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | ||
| 195 | member.copy(resources); | 219 | member.copy(resources); |
| 196 | 220 | ||
| 197 | Member _member = this.save(member); | 221 | Member _member = this.save(member);*/ |
| 222 | MemberDTO memberDTO = this.findById(resources.getId()); | ||
| 223 | if (Objects.nonNull(memberDTO)) { | ||
| 224 | this.memberRepository.updatePointAndDuePoint(resources); | ||
| 225 | } | ||
| 198 | 226 | ||
| 199 | return this.memberMapper.toDto(_member); | 227 | return memberDTO; |
| 200 | 228 | ||
| 201 | } catch (Exception e) { | 229 | } catch (Exception e) { |
| 202 | e.printStackTrace(); | 230 | e.printStackTrace(); |
| 203 | throw e; | 231 | throw e; |
| 204 | } finally { | 232 | } finally { |
| 205 | this.redisUtils.doUnLock("member::update::code" + resources.getCode()); | 233 | this.redisUtils.doUnLock("member::code" + resources.getCode()); |
| 206 | } | 234 | } |
| 207 | } | 235 | } |
| 208 | 236 | ... | ... |
| ... | @@ -5,8 +5,16 @@ public enum RightType { | ... | @@ -5,8 +5,16 @@ public enum RightType { |
| 5 | POINTS, | 5 | POINTS, |
| 6 | /**成长值*/ | 6 | /**成长值*/ |
| 7 | EXP, | 7 | EXP, |
| 8 | /**优惠券券*/ | 8 | /**优惠券*/ |
| 9 | COUPON, | 9 | COUPON, |
| 10 | /**活动机会*/ | ||
| 11 | ACTIVITYCHANCE, | ||
| 12 | /**积分商品*/ | ||
| 13 | POINTGOODS, | ||
| 14 | /**IPTV产品包*/ | ||
| 15 | IPTVPRODUCT, | ||
| 16 | /**IPTV观影权益 */ | ||
| 17 | IPTVVIEW, | ||
| 10 | /**权益统称*/ | 18 | /**权益统称*/ |
| 11 | RIGHTS | 19 | RIGHTS |
| 12 | 20 | ... | ... |
| ... | @@ -7,6 +7,7 @@ import com.topdraw.business.module.task.service.dto.TaskDTO; | ... | @@ -7,6 +7,7 @@ import com.topdraw.business.module.task.service.dto.TaskDTO; |
| 7 | import com.topdraw.business.process.domian.TempIptvUser; | 7 | import com.topdraw.business.process.domian.TempIptvUser; |
| 8 | import com.topdraw.business.process.service.TaskOperationService; | 8 | import com.topdraw.business.process.service.TaskOperationService; |
| 9 | import com.topdraw.business.process.service.dto.TaskOperationQueryCriteria; | 9 | import com.topdraw.business.process.service.dto.TaskOperationQueryCriteria; |
| 10 | import com.topdraw.common.IResultInfo; | ||
| 10 | import com.topdraw.common.ResultInfo; | 11 | import com.topdraw.common.ResultInfo; |
| 11 | import io.swagger.annotations.Api; | 12 | import io.swagger.annotations.Api; |
| 12 | import io.swagger.annotations.ApiOperation; | 13 | import io.swagger.annotations.ApiOperation; |
| ... | @@ -36,9 +37,16 @@ public class TaskOperationController { | ... | @@ -36,9 +37,16 @@ public class TaskOperationController { |
| 36 | @PostMapping(value = "/dealTask") | 37 | @PostMapping(value = "/dealTask") |
| 37 | @ApiOperation("事件处理") | 38 | @ApiOperation("事件处理") |
| 38 | @AnonymousAccess | 39 | @AnonymousAccess |
| 39 | public void dealTask(@RequestBody @Validated TaskOperationQueryCriteria criteria) { | 40 | public IResultInfo dealTask(@RequestBody @Validated TaskOperationQueryCriteria criteria) { |
| 41 | log.info("事件处理,开始,参数 ==>> {}", criteria); | ||
| 42 | long l = System.currentTimeMillis(); | ||
| 43 | |||
| 40 | // 任务处理 | 44 | // 任务处理 |
| 41 | this.taskOperationService.dealTask(criteria.getContent()); | 45 | this.taskOperationService.dealTask(criteria.getContent()); |
| 46 | long l2 = System.currentTimeMillis(); | ||
| 47 | log.info("事件处理,结束,总耗时 ==>> {}", (l2-l)); | ||
| 48 | |||
| 49 | return ResultInfo.success(); | ||
| 42 | } | 50 | } |
| 43 | 51 | ||
| 44 | /** | 52 | /** | ... | ... |
| ... | @@ -459,6 +459,18 @@ public class UserOperationController { | ... | @@ -459,6 +459,18 @@ public class UserOperationController { |
| 459 | public ResultInfo tvUnbind(@Validated(value = {UpdateGroup.class}) @RequestBody TvUnBindBean resources) { | 459 | public ResultInfo tvUnbind(@Validated(value = {UpdateGroup.class}) @RequestBody TvUnBindBean resources) { |
| 460 | log.info("UserOperationController ==> unbind ==>> param ==> [{}]",resources); | 460 | log.info("UserOperationController ==> unbind ==>> param ==> [{}]",resources); |
| 461 | 461 | ||
| 462 | String memberCode = resources.getMemberCode(); | ||
| 463 | log.info("大屏解绑,前端参数,需要解绑的会员code,memberCode ==>> {}", memberCode); | ||
| 464 | if (StringUtils.isBlank(memberCode)) { | ||
| 465 | throw new BadRequestException(GlobeExceptionMsg.MEMBER_CODE_IS_NULL); | ||
| 466 | } | ||
| 467 | |||
| 468 | String platformAccount = resources.getPlatformAccount(); | ||
| 469 | log.info("大屏解绑,前端参数,大屏账号,platformAccount ==>> {}", platformAccount); | ||
| 470 | if (StringUtils.isBlank(platformAccount)) { | ||
| 471 | throw new BadRequestException(GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); | ||
| 472 | } | ||
| 473 | |||
| 462 | this.userOperationService.tvUnbind(resources); | 474 | this.userOperationService.tvUnbind(resources); |
| 463 | return ResultInfo.success(); | 475 | return ResultInfo.success(); |
| 464 | } | 476 | } | ... | ... |
| ... | @@ -14,18 +14,20 @@ import com.topdraw.business.process.domian.TempCoupon; | ... | @@ -14,18 +14,20 @@ import com.topdraw.business.process.domian.TempCoupon; |
| 14 | import com.topdraw.business.process.service.RightsOperationService; | 14 | import com.topdraw.business.process.service.RightsOperationService; |
| 15 | import com.topdraw.util.TimestampUtil; | 15 | import com.topdraw.util.TimestampUtil; |
| 16 | import com.topdraw.utils.RedisUtils; | 16 | import com.topdraw.utils.RedisUtils; |
| 17 | import lombok.extern.slf4j.Slf4j; | ||
| 17 | import org.springframework.aop.framework.AopContext; | 18 | import org.springframework.aop.framework.AopContext; |
| 18 | import org.springframework.beans.BeanUtils; | 19 | import org.springframework.beans.BeanUtils; |
| 19 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| 20 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
| 21 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 22 | 22 | ||
| 23 | import java.time.LocalDate; | ||
| 23 | import java.time.LocalDateTime; | 24 | import java.time.LocalDateTime; |
| 24 | import java.util.List; | 25 | import java.util.List; |
| 25 | import java.util.Objects; | 26 | import java.util.Objects; |
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | @Service | 29 | @Service |
| 30 | @Slf4j | ||
| 29 | public class CouponOperationServiceImpl implements CouponOperationService { | 31 | public class CouponOperationServiceImpl implements CouponOperationService { |
| 30 | 32 | ||
| 31 | @Autowired | 33 | @Autowired |
| ... | @@ -40,9 +42,6 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -40,9 +42,6 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 40 | MemberService memberService; | 42 | MemberService memberService; |
| 41 | 43 | ||
| 42 | @Autowired | 44 | @Autowired |
| 43 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
| 44 | |||
| 45 | @Autowired | ||
| 46 | private RedisUtils redisUtils; | 45 | private RedisUtils redisUtils; |
| 47 | 46 | ||
| 48 | // 过期阀值(默认一个月) | 47 | // 过期阀值(默认一个月) |
| ... | @@ -97,24 +96,26 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -97,24 +96,26 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 97 | Long memberId = tempCoupon.getMemberId(); | 96 | Long memberId = tempCoupon.getMemberId(); |
| 98 | Integer rightsAmount = tempCoupon.getRightsAmount(); | 97 | Integer rightsAmount = tempCoupon.getRightsAmount(); |
| 99 | try { | 98 | try { |
| 100 | this.redisUtils.doLock("refreshMemberCoupon:" + memberId.toString()); | 99 | |
| 101 | // 1.历史总优惠券数量 | 100 | // 1.历史总优惠券数量 |
| 102 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); | 101 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); |
| 103 | // 1.当前总优惠券数量 | 102 | // 1.当前总优惠券数量 |
| 104 | Long totalCouponCount = this.getTotalCoupon(historyCouponCount,rightsAmount); | 103 | Long totalCouponCount = this.getTotalCoupon(historyCouponCount, rightsAmount); |
| 105 | // 2.获取已过期的优惠券数量 | 104 | // 2.获取已过期的优惠券数量 |
| 106 | Long expireCouponCount = this.getTotalExpireCoupon(memberId); | 105 | Long expireCouponCount = this.getTotalExpireCoupon(memberId); |
| 107 | // 3.即将过期的优惠券数量 | 106 | // 3.即将过期的优惠券数量 |
| 108 | Long expireSoonCouponCount = this.getTotalExpireSoonCoupon(memberId,EXPIRE_FACTOR_DAY); | 107 | Long expireSoonCouponCount = this.getTotalExpireSoonCoupon(memberId, EXPIRE_FACTOR_DAY); |
| 109 | // 4.当前优惠券数量 = 总优惠券-已过期的优惠券 | 108 | // 4.当前优惠券数量 = 总优惠券-已过期的优惠券 |
| 110 | Long currentCoupon = this.getCurrentCoupon(totalCouponCount,expireCouponCount); | 109 | Long currentCoupon = this.getCurrentCoupon(totalCouponCount, expireCouponCount); |
| 110 | |||
| 111 | this.redisUtils.doLock("right::member::id::" + memberId.toString()); | ||
| 111 | // 5.更新用户信息(优惠券数量、即将过期的优惠券数量) | 112 | // 5.更新用户信息(优惠券数量、即将过期的优惠券数量) |
| 112 | this.doUpdateMemberInfo(memberId,currentCoupon,expireSoonCouponCount); | 113 | this.doUpdateMemberInfo(memberId,currentCoupon,expireSoonCouponCount); |
| 113 | } catch (Exception e) { | 114 | } catch (Exception e) { |
| 114 | e.printStackTrace(); | 115 | e.printStackTrace(); |
| 115 | throw e; | 116 | throw e; |
| 116 | } finally { | 117 | } finally { |
| 117 | this.redisUtils.doUnLock("refreshMemberCoupon:" + memberId.toString()); | 118 | this.redisUtils.doUnLock("right::member::id::" + memberId.toString()); |
| 118 | } | 119 | } |
| 119 | } | 120 | } |
| 120 | 121 | ||
| ... | @@ -133,8 +134,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -133,8 +134,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 133 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 134 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
| 134 | 135 | ||
| 135 | Member member = new Member(); | 136 | Member member = new Member(); |
| 136 | BeanUtils.copyProperties(memberDTO,member); | 137 | // BeanUtils.copyProperties(memberDTO,member); |
| 137 | 138 | member.setId(memberDTO.getId()); | |
| 139 | member.setCode(memberDTO.getCode()); | ||
| 138 | member.setCouponAmount(currentCoupon); | 140 | member.setCouponAmount(currentCoupon); |
| 139 | member.setDueCouponAmount(expireSoonCouponCount); | 141 | member.setDueCouponAmount(expireSoonCouponCount); |
| 140 | member.setUpdateTime(TimestampUtil.now()); | 142 | member.setUpdateTime(TimestampUtil.now()); |
| ... | @@ -178,7 +180,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -178,7 +180,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 178 | * @return | 180 | * @return |
| 179 | */ | 181 | */ |
| 180 | private Long getTotalExpireCoupon(Long userId) { | 182 | private Long getTotalExpireCoupon(Long userId) { |
| 181 | return this.couponHistoryService.countByUserIdAndExpireTimeBefore(userId,LocalDateTime.now()); | 183 | return this.couponHistoryService.countByUserIdAndExpireTimeBefore(userId, LocalDateTime.now()); |
| 182 | } | 184 | } |
| 183 | 185 | ||
| 184 | 186 | ... | ... |
| ... | @@ -8,8 +8,6 @@ import com.topdraw.business.module.member.level.service.MemberLevelService; | ... | @@ -8,8 +8,6 @@ import com.topdraw.business.module.member.level.service.MemberLevelService; |
| 8 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; | 8 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; |
| 9 | import com.topdraw.business.module.member.service.MemberService; | 9 | import com.topdraw.business.module.member.service.MemberService; |
| 10 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 10 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 11 | import com.topdraw.business.module.points.available.domain.PointsAvailable; | ||
| 12 | import com.topdraw.business.module.points.detail.domain.PointsDetail; | ||
| 13 | import com.topdraw.business.process.service.ExpOperationService; | 11 | import com.topdraw.business.process.service.ExpOperationService; |
| 14 | import com.topdraw.business.process.service.member.MemberOperationService; | 12 | import com.topdraw.business.process.service.member.MemberOperationService; |
| 15 | import com.topdraw.business.process.domian.TempExp; | 13 | import com.topdraw.business.process.domian.TempExp; |
| ... | @@ -17,16 +15,13 @@ import com.topdraw.util.IdWorker; | ... | @@ -17,16 +15,13 @@ import com.topdraw.util.IdWorker; |
| 17 | import com.topdraw.util.TimestampUtil; | 15 | import com.topdraw.util.TimestampUtil; |
| 18 | import com.topdraw.utils.RedisUtils; | 16 | import com.topdraw.utils.RedisUtils; |
| 19 | import com.topdraw.utils.StringUtils; | 17 | import com.topdraw.utils.StringUtils; |
| 20 | import org.slf4j.Logger; | 18 | import lombok.extern.slf4j.Slf4j; |
| 21 | import org.slf4j.LoggerFactory; | ||
| 22 | import org.springframework.aop.framework.AopContext; | 19 | import org.springframework.aop.framework.AopContext; |
| 23 | import org.springframework.beans.BeanUtils; | 20 | import org.springframework.beans.BeanUtils; |
| 24 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
| 26 | import org.springframework.stereotype.Service; | 22 | import org.springframework.stereotype.Service; |
| 27 | import org.springframework.util.CollectionUtils; | 23 | import org.springframework.util.CollectionUtils; |
| 28 | 24 | ||
| 29 | import java.time.LocalDateTime; | ||
| 30 | import java.util.List; | 25 | import java.util.List; |
| 31 | import java.util.Objects; | 26 | import java.util.Objects; |
| 32 | 27 | ||
| ... | @@ -34,6 +29,7 @@ import java.util.Objects; | ... | @@ -34,6 +29,7 @@ import java.util.Objects; |
| 34 | * | 29 | * |
| 35 | */ | 30 | */ |
| 36 | @Service | 31 | @Service |
| 32 | @Slf4j | ||
| 37 | public class ExpOperationServiceImpl implements ExpOperationService { | 33 | public class ExpOperationServiceImpl implements ExpOperationService { |
| 38 | 34 | ||
| 39 | @Autowired | 35 | @Autowired |
| ... | @@ -46,9 +42,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -46,9 +42,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 46 | MemberService memberService; | 42 | MemberService memberService; |
| 47 | 43 | ||
| 48 | @Autowired | 44 | @Autowired |
| 49 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
| 50 | |||
| 51 | @Autowired | ||
| 52 | private RedisUtils redisUtils; | 45 | private RedisUtils redisUtils; |
| 53 | 46 | ||
| 54 | @AsyncMqSend | 47 | @AsyncMqSend |
| ... | @@ -83,23 +76,27 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -83,23 +76,27 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 83 | */ | 76 | */ |
| 84 | private void refresh(TempExp tempExp) { | 77 | private void refresh(TempExp tempExp) { |
| 85 | try { | 78 | try { |
| 86 | this.redisUtils.doLock("uc-refresh-exp:" + tempExp.getMemberId()); | 79 | |
| 87 | // 原始积分 | 80 | // 原始经验值 |
| 88 | long originExp = this.getExpByMemberId(tempExp); | 81 | long originExp = this.getExpByMemberId(tempExp); |
| 89 | // 总积分 | 82 | log.info("----获取会员当前原始经验值 ==>> {}", originExp); |
| 83 | // 总经验值 | ||
| 90 | long totalExp = this.calculateTotalExp(originExp, tempExp); | 84 | long totalExp = this.calculateTotalExp(originExp, tempExp); |
| 91 | // 1.添加成长值记录 | 85 | log.info("----计算总经验值 ==>> {}", totalExp); |
| 92 | // this.threadPoolTaskExecutor.execute(() -> this.doInsertExpDetail(tempExp, originExp, totalExp)); | 86 | |
| 87 | this.redisUtils.doLock("right::member::id::" + tempExp.getMemberId()); | ||
| 93 | // 2.更新成长值与等级 | 88 | // 2.更新成长值与等级 |
| 89 | log.info("----更新会员经验值与对应等级 ==>> {}", totalExp); | ||
| 94 | this.refreshMemberExpAndLevel(tempExp, totalExp); | 90 | this.refreshMemberExpAndLevel(tempExp, totalExp); |
| 95 | 91 | ||
| 92 | log.info("----保存经验值历史 "); | ||
| 96 | this.doInsertExpDetail(tempExp, originExp, totalExp); | 93 | this.doInsertExpDetail(tempExp, originExp, totalExp); |
| 97 | 94 | ||
| 98 | } catch (Exception e) { | 95 | } catch (Exception e) { |
| 99 | e.printStackTrace(); | 96 | e.printStackTrace(); |
| 100 | throw e; | 97 | throw e; |
| 101 | } finally { | 98 | } finally { |
| 102 | this.redisUtils.doUnLock("uc-refresh-exp:" + tempExp.getMemberId()); | 99 | this.redisUtils.doUnLock("right::member::id::" + tempExp.getMemberId()); |
| 103 | } | 100 | } |
| 104 | } | 101 | } |
| 105 | 102 | ||
| ... | @@ -151,8 +148,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -151,8 +148,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 151 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 148 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
| 152 | 149 | ||
| 153 | Member member = new Member(); | 150 | Member member = new Member(); |
| 154 | BeanUtils.copyProperties(memberDTO, member); | 151 | // BeanUtils.copyProperties(memberDTO, member); |
| 155 | 152 | member.setId(memberDTO.getId()); | |
| 153 | member.setCode(memberDTO.getCode()); | ||
| 156 | member.setExp(totalExp); | 154 | member.setExp(totalExp); |
| 157 | member.setLevel(level); | 155 | member.setLevel(level); |
| 158 | member.setUpdateTime(TimestampUtil.now()); | 156 | member.setUpdateTime(TimestampUtil.now()); | ... | ... |
| ... | @@ -139,6 +139,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -139,6 +139,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 139 | long totalPoints = this.doFreshTrPointsAvailableByAvailablePointsMap(customAvailablePointsMap, currentPoints); | 139 | long totalPoints = this.doFreshTrPointsAvailableByAvailablePointsMap(customAvailablePointsMap, currentPoints); |
| 140 | // 5.即将过期的积分 | 140 | // 5.即将过期的积分 |
| 141 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 141 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
| 142 | |||
| 143 | |||
| 142 | // 6.更新会员积分信息 | 144 | // 6.更新会员积分信息 |
| 143 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); | 145 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); |
| 144 | 146 | ||
| ... | @@ -319,9 +321,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -319,9 +321,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 319 | @Override | 321 | @Override |
| 320 | @Transactional(rollbackFor = Exception.class) | 322 | @Transactional(rollbackFor = Exception.class) |
| 321 | public void grantPointsThroughTempPoint(List<TempPoints> tempPointsList){ | 323 | public void grantPointsThroughTempPoint(List<TempPoints> tempPointsList){ |
| 322 | log.info("------->>grantPointsThroughTempRightsList start1"); | ||
| 323 | for (TempPoints tempPoints : tempPointsList){ | 324 | for (TempPoints tempPoints : tempPointsList){ |
| 324 | log.info("------->>grantPointsThroughTempRightsList start"); | ||
| 325 | this.refresh(tempPoints); | 325 | this.refresh(tempPoints); |
| 326 | } | 326 | } |
| 327 | } | 327 | } |
| ... | @@ -445,10 +445,10 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -445,10 +445,10 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 445 | Long memberId = tempPoints.getMemberId(); | 445 | Long memberId = tempPoints.getMemberId(); |
| 446 | log.info("----------->> 会员id ===>>>>" + memberId); | 446 | log.info("----------->> 会员id ===>>>>" + memberId); |
| 447 | try { | 447 | try { |
| 448 | this.redisUtils.doLock("member::id::" + memberId.toString()); | 448 | |
| 449 | // 1.可用总积分 | 449 | // 1.可用总积分 |
| 450 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); | 450 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); |
| 451 | log.info("----------->> 可用总积分 --->>>> {}", currentPoints); | 451 | log.info("----------->> 获取会员当前可用总积分 --->>>> {}", currentPoints); |
| 452 | 452 | ||
| 453 | // 2.计算总积分 | 453 | // 2.计算总积分 |
| 454 | Long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); | 454 | Long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); |
| ... | @@ -466,6 +466,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -466,6 +466,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 466 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 466 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
| 467 | log.info("----------->> 即将过期的积分 ------->>>>> {}", soonExpirePoints); | 467 | log.info("----------->> 即将过期的积分 ------->>>>> {}", soonExpirePoints); |
| 468 | 468 | ||
| 469 | this.redisUtils.doLock("right::member::id::" + memberId.toString()); | ||
| 470 | |||
| 469 | // 6.更新会员的总积分 | 471 | // 6.更新会员的总积分 |
| 470 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>> {}", totalPoints); | 472 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>> {}", totalPoints); |
| 471 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); | 473 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); |
| ... | @@ -474,7 +476,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -474,7 +476,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 474 | e.printStackTrace(); | 476 | e.printStackTrace(); |
| 475 | throw e; | 477 | throw e; |
| 476 | } finally { | 478 | } finally { |
| 477 | this.redisUtils.doUnLock("member::id::" + memberId.toString()); | 479 | this.redisUtils.doUnLock("right::member::id::" + memberId.toString()); |
| 478 | } | 480 | } |
| 479 | } | 481 | } |
| 480 | 482 | ||
| ... | @@ -528,9 +530,10 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -528,9 +530,10 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 528 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 530 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
| 529 | 531 | ||
| 530 | Member member = new Member(); | 532 | Member member = new Member(); |
| 531 | BeanUtils.copyProperties(memberDTO,member); | 533 | // BeanUtils.copyProperties(memberDTO, member); |
| 532 | 534 | member.setId(memberDTO.getId()); | |
| 533 | member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0); | 535 | member.setCode(memberDTO.getCode()); |
| 536 | member.setPoints(Objects.nonNull(currentPoints) ? currentPoints:0); | ||
| 534 | member.setDuePoints(duePoints); | 537 | member.setDuePoints(duePoints); |
| 535 | member.setUpdateTime(TimestampUtil.now()); | 538 | member.setUpdateTime(TimestampUtil.now()); |
| 536 | try { | 539 | try { | ... | ... |
| ... | @@ -79,6 +79,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -79,6 +79,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
| 79 | // 2.创建权益历史对象 | 79 | // 2.创建权益历史对象 |
| 80 | List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap); | 80 | List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap); |
| 81 | if (!CollectionUtils.isEmpty(rightsList)) { | 81 | if (!CollectionUtils.isEmpty(rightsList)) { |
| 82 | log.info("异步保存权益领取历史开始 ==>> [{}]", rightsList); | ||
| 82 | // 3.保存权益历史 | 83 | // 3.保存权益历史 |
| 83 | this.doInsertTrRightHistory(rightsList); | 84 | this.doInsertTrRightHistory(rightsList); |
| 84 | } | 85 | } |
| ... | @@ -195,23 +196,85 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -195,23 +196,85 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
| 195 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | 196 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); |
| 196 | log.info(Thread.currentThread().getName() + "=========>> end"); | 197 | log.info(Thread.currentThread().getName() + "=========>> end"); |
| 197 | });*/ | 198 | });*/ |
| 199 | this.threadPoolTaskExecutor.execute(() -> { | ||
| 200 | List<TempPoints> tempPointsList = (List<TempPoints>) tempRightsMap.get(RightType.POINTS); | ||
| 201 | if (!CollectionUtils.isEmpty(tempPointsList)) { | ||
| 202 | log.info("发放积分开始 ==>> [{}]", tempPointsList); | ||
| 203 | long l = System.currentTimeMillis(); | ||
| 204 | // 积分 | ||
| 205 | this.grantPoint(tempPointsList); | ||
| 206 | long l2 = System.currentTimeMillis(); | ||
| 207 | log.info("发放积分结束,总耗时 ==>> {}", (l2 - l)); | ||
| 208 | } | ||
| 209 | }); | ||
| 198 | 210 | ||
| 199 | List<TempPoints> tempPointsList = (List<TempPoints>) tempRightsMap.get(RightType.POINTS); | 211 | this.threadPoolTaskExecutor.execute(()-> { |
| 200 | if (!CollectionUtils.isEmpty(tempPointsList)) { | ||
| 201 | // 积分 | ||
| 202 | this.grantPoint(tempPointsList); | ||
| 203 | } | ||
| 204 | |||
| 205 | List<TempExp> tempExpList = (List<TempExp>) tempRightsMap.get(RightType.EXP); | 212 | List<TempExp> tempExpList = (List<TempExp>) tempRightsMap.get(RightType.EXP); |
| 206 | if (!CollectionUtils.isEmpty(tempExpList)) { | 213 | if (!CollectionUtils.isEmpty(tempExpList)) { |
| 214 | log.info("发放成长值开始 ==>> [{}]", tempExpList); | ||
| 215 | long l = System.currentTimeMillis(); | ||
| 207 | // 成长值 | 216 | // 成长值 |
| 208 | this.grantExp(tempExpList); | 217 | this.grantExp(tempExpList); |
| 218 | long l2 = System.currentTimeMillis(); | ||
| 219 | log.info("发放成长值结束,总耗时 ==>> {}", (l2 - l)); | ||
| 209 | } | 220 | } |
| 221 | }); | ||
| 210 | 222 | ||
| 211 | List<TempCoupon> tempCouponList = (List<TempCoupon>) tempRightsMap.get(RightType.COUPON); | 223 | this.threadPoolTaskExecutor.execute(()-> { |
| 212 | if (!CollectionUtils.isEmpty(tempCouponList)) { | 224 | List<TempCoupon> tempCouponList = (List<TempCoupon>) tempRightsMap.get(RightType.COUPON); |
| 213 | // 优惠券 | 225 | if (!CollectionUtils.isEmpty(tempCouponList)) { |
| 214 | this.grantCoupon(tempCouponList); | 226 | log.info("发放优惠券开始 ==>> [{}]", tempCouponList); |
| 227 | long l = System.currentTimeMillis(); | ||
| 228 | // 优惠券 | ||
| 229 | this.grantCoupon(tempCouponList); | ||
| 230 | long l2 = System.currentTimeMillis(); | ||
| 231 | log.info("发放优惠券结束,总耗时 ==>> {}", (l2 - l)); | ||
| 232 | } | ||
| 233 | }); | ||
| 234 | |||
| 235 | |||
| 236 | // 其他权益 | ||
| 237 | this.threadPoolTaskExecutor.execute(()-> { | ||
| 238 | log.info("发放其他权益开始 ==>> [{}]", tempRightsMap); | ||
| 239 | this.grantOtherRight(tempRightsMap); | ||
| 240 | log.info("发放其他权益结束 ==>> [{}]", tempRightsMap); | ||
| 241 | }); | ||
| 242 | |||
| 243 | } | ||
| 244 | |||
| 245 | private void grantOtherRight(Map<RightType, Object> tempRightsMap) { | ||
| 246 | Set<RightType> rightTypes = tempRightsMap.keySet(); | ||
| 247 | if (Objects.nonNull(rightTypes) && CollectionUtils.isEmpty(rightTypes)) { | ||
| 248 | |||
| 249 | for (RightType rightType : rightTypes) { | ||
| 250 | |||
| 251 | switch (rightType) { | ||
| 252 | |||
| 253 | // 活动机会 | ||
| 254 | case ACTIVITYCHANCE: | ||
| 255 | |||
| 256 | break; | ||
| 257 | |||
| 258 | // 积分商品 | ||
| 259 | case POINTGOODS: | ||
| 260 | |||
| 261 | break; | ||
| 262 | |||
| 263 | // IPTV产品包 | ||
| 264 | case IPTVPRODUCT: | ||
| 265 | |||
| 266 | break; | ||
| 267 | |||
| 268 | // IPTV观影权益 | ||
| 269 | case IPTVVIEW: | ||
| 270 | |||
| 271 | break; | ||
| 272 | |||
| 273 | default: | ||
| 274 | break; | ||
| 275 | } | ||
| 276 | |||
| 277 | } | ||
| 215 | } | 278 | } |
| 216 | 279 | ||
| 217 | } | 280 | } | ... | ... |
| ... | @@ -212,37 +212,59 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -212,37 +212,59 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 212 | 212 | ||
| 213 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); | 213 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); |
| 214 | Integer event = dataSyncMsg.getEvent(); | 214 | Integer event = dataSyncMsg.getEvent(); |
| 215 | DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); | 215 | String msgData1 = dataSyncMsg.getMsgData(); |
| 216 | DataSyncMsg.MsgData msgData = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); | ||
| 217 | |||
| 216 | String memberCode = msgData.getMemberCode(); | 218 | String memberCode = msgData.getMemberCode(); |
| 217 | Long memberId = msgData.getMemberId(); | 219 | Long memberId = msgData.getMemberId(); |
| 220 | |||
| 221 | long l = System.currentTimeMillis(); | ||
| 218 | if (StringUtils.isNotBlank(memberCode)) { | 222 | if (StringUtils.isNotBlank(memberCode)) { |
| 223 | |||
| 219 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | 224 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); |
| 220 | memberId = memberDTO.getId(); | 225 | log.info("获取会员信息 ==>> {}", memberDTO); |
| 221 | } | 226 | |
| 227 | // 检查当前会员的黑名单状态 | ||
| 228 | boolean b = this.validatedMemberBlackStatus(memberDTO); | ||
| 229 | log.info("会员信息 ==>> {} || 会员id ==>> {} || 黑名单状态 ==>> {}", memberDTO, memberDTO.getId(), memberDTO.getBlackStatus()); | ||
| 230 | if (!b) { | ||
| 231 | return ResultInfo.forbidden("会员已被加入黑名单"); | ||
| 232 | } | ||
| 222 | 233 | ||
| 223 | // 检查当前会员的黑名单状态 | 234 | memberId = memberDTO.getId(); |
| 224 | boolean b = this.validatedMemberBlackStatus(memberId); | ||
| 225 | if (!b) { | ||
| 226 | return ResultInfo.forbidden("会员已被加入黑名单"); | ||
| 227 | } | 235 | } |
| 228 | 236 | ||
| 229 | // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板 | 237 | // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板 |
| 230 | TaskTemplate taskTemplate = this.getTaskTemplate(event, dataSyncMsg); | 238 | TaskTemplate taskTemplate = this.getTaskTemplate(event, dataSyncMsg); |
| 239 | log.info("获取任务模板 taskTemplate ==>> {} ", taskTemplate); | ||
| 240 | |||
| 231 | // 2.通过任务模板获取对应的任务列表 | 241 | // 2.通过任务模板获取对应的任务列表 |
| 232 | List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate, dataSyncMsg); | 242 | List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate, dataSyncMsg); |
| 243 | log.info("获取任务 taskList ==>> [{}] ", taskList); | ||
| 244 | |||
| 233 | // 4.判断当前用户是否满足任务完成条件 | 245 | // 4.判断当前用户是否满足任务完成条件 |
| 234 | boolean checkResult = this.checkTaskCompletion(memberId, taskList, event, msgData); | 246 | boolean checkResult = this.checkTaskCompletion(memberId, taskList, event, msgData); |
| 247 | log.info("检查当前会员的任务完成情况 ==>> {} , true:未完成", checkResult); | ||
| 235 | if (checkResult) { | 248 | if (checkResult) { |
| 236 | // 5.权益区分(积分、权益、成长值) | 249 | // 5.权益区分(积分、权益、成长值) |
| 237 | Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId, taskList, msgData, dataSyncMsg); | 250 | Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId, taskList, msgData, dataSyncMsg); |
| 251 | log.info("获取当前任务对应的权益 tempRightsMap ==>> {} ", tempRightsMap); | ||
| 238 | 252 | ||
| 239 | // 6.风控检查 | 253 | // 6.风控检查 |
| 240 | boolean result = this.checkRiskManagement(memberId,tempRightsMap); | 254 | boolean result = this.checkRiskManagement(memberId, tempRightsMap); |
| 255 | log.info("针对各项权益检查当前会员是否达到风控值 ==>> {},true:已达到风控指标 ", result); | ||
| 241 | 256 | ||
| 242 | if (result) throw new BadRequestException("发放失败,已达风控上限"); | 257 | if (result) throw new BadRequestException("发放失败,已达风控上限"); |
| 243 | 258 | ||
| 259 | long l1 = System.currentTimeMillis(); | ||
| 260 | log.info("各项检查总耗时 ==>> {}", (l1-l)); | ||
| 261 | |||
| 244 | // 7.权益发放 | 262 | // 7.权益发放 |
| 263 | log.info("下发开始 ==>> {}", tempRightsMap); | ||
| 264 | long l2 = System.currentTimeMillis(); | ||
| 245 | this.grantRight(tempRightsMap); | 265 | this.grantRight(tempRightsMap); |
| 266 | long l3 = System.currentTimeMillis(); | ||
| 267 | log.info("下发结束,总耗时 ==>> {}", (l3-l2)); | ||
| 246 | 268 | ||
| 247 | } | 269 | } |
| 248 | return ResultInfo.success(); | 270 | return ResultInfo.success(); |
| ... | @@ -264,12 +286,10 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -264,12 +286,10 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 264 | 286 | ||
| 265 | /** | 287 | /** |
| 266 | * 验证会员信息 | 288 | * 验证会员信息 |
| 267 | * @param memberId | 289 | * @param memberDTO |
| 268 | * @return | 290 | * @return |
| 269 | */ | 291 | */ |
| 270 | private boolean validatedMemberBlackStatus(Long memberId) { | 292 | private boolean validatedMemberBlackStatus(MemberDTO memberDTO) { |
| 271 | log.info("validatedMember -->>【memberId】 -->> " + memberId); | ||
| 272 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
| 273 | Long blackStatus = memberDTO.getBlackStatus(); | 293 | Long blackStatus = memberDTO.getBlackStatus(); |
| 274 | if (Objects.nonNull(blackStatus) && blackStatus == 1) { | 294 | if (Objects.nonNull(blackStatus) && blackStatus == 1) { |
| 275 | log.error("validatedMember -->> 会员已被加入黑名单 【blackStatus】 -->> " + blackStatus); | 295 | log.error("validatedMember -->> 会员已被加入黑名单 【blackStatus】 -->> " + blackStatus); |
| ... | @@ -395,7 +415,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -395,7 +415,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 395 | // TODO 权益1发放的策略 | 415 | // TODO 权益1发放的策略 |
| 396 | Integer rightsSendStrategy = task.getRightsSendStrategy(); | 416 | Integer rightsSendStrategy = task.getRightsSendStrategy(); |
| 397 | // 权益分类 | 417 | // 权益分类 |
| 398 | this.getTempRightType(memberDTO,rights1Id,rights1Amount,rightsSendStrategy,tempCouponList,rightsList); | 418 | this.getTempRightType(memberDTO,rights1Id,rights1Amount,rightsSendStrategy,tempCouponList,rightsList,map); |
| 399 | } | 419 | } |
| 400 | 420 | ||
| 401 | // 权益2 | 421 | // 权益2 |
| ... | @@ -405,7 +425,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -405,7 +425,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 405 | // TODO 权益2发放的策略 | 425 | // TODO 权益2发放的策略 |
| 406 | Integer rightsSendStrategy = task.getRightsSendStrategy(); | 426 | Integer rightsSendStrategy = task.getRightsSendStrategy(); |
| 407 | // 权权益分类 | 427 | // 权权益分类 |
| 408 | this.getTempRightType(memberDTO,rights2Id,rights2Amount,rightsSendStrategy,tempCouponList,rightsList); | 428 | this.getTempRightType(memberDTO,rights2Id,rights2Amount,rightsSendStrategy,tempCouponList,rightsList,map); |
| 409 | } | 429 | } |
| 410 | 430 | ||
| 411 | // 权益3 | 431 | // 权益3 |
| ... | @@ -415,16 +435,16 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -415,16 +435,16 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 415 | // TODO 权益3发放的策略 | 435 | // TODO 权益3发放的策略 |
| 416 | Integer rightsSendStrategy = task.getRightsSendStrategy(); | 436 | Integer rightsSendStrategy = task.getRightsSendStrategy(); |
| 417 | // 权益分类 | 437 | // 权益分类 |
| 418 | this.getTempRightType(memberDTO,rights3Id,rights3Amount,rightsSendStrategy,tempCouponList,rightsList); | 438 | this.getTempRightType(memberDTO,rights3Id,rights3Amount,rightsSendStrategy,tempCouponList,rightsList,map); |
| 419 | } | 439 | } |
| 420 | // 优惠券 | 440 | // 优惠券 |
| 421 | if (!CollectionUtils.isEmpty(tempCouponList)) { | 441 | /*if (!CollectionUtils.isEmpty(tempCouponList)) { |
| 422 | map.put(RightType.COUPON,tempCouponList); | 442 | map.put(RightType.COUPON,tempCouponList); |
| 423 | } | 443 | }*/ |
| 424 | // 权益 | 444 | // 权益 |
| 425 | if (!CollectionUtils.isEmpty(rightsList)) { | 445 | /*if (!CollectionUtils.isEmpty(rightsList)) { |
| 426 | map.put(RightType.RIGHTS,rightsList); | 446 | map.put(RightType.RIGHTS,rightsList); |
| 427 | } | 447 | }*/ |
| 428 | return map; | 448 | return map; |
| 429 | } | 449 | } |
| 430 | 450 | ||
| ... | @@ -448,7 +468,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -448,7 +468,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 448 | * @param rightsList | 468 | * @param rightsList |
| 449 | */ | 469 | */ |
| 450 | private void getTempRightType(MemberDTO memberDTO , Long rightsId, Integer rightsAmount,Integer rightsSendStrategy,List<TempCoupon> tempCouponList, | 470 | private void getTempRightType(MemberDTO memberDTO , Long rightsId, Integer rightsAmount,Integer rightsSendStrategy,List<TempCoupon> tempCouponList, |
| 451 | List<TempRights> rightsList) { | 471 | List<TempRights> rightsList,Map<RightType,Object> map) { |
| 452 | 472 | ||
| 453 | Long memberId = memberDTO.getId(); | 473 | Long memberId = memberDTO.getId(); |
| 454 | String nickname = memberDTO.getNickname(); | 474 | String nickname = memberDTO.getNickname(); |
| ... | @@ -461,20 +481,61 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -461,20 +481,61 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 461 | TempRights tempRights = this.tmpRightsBuild(memberId,memberCode,rightsAmount,rightsDTO); | 481 | TempRights tempRights = this.tmpRightsBuild(memberId,memberCode,rightsAmount,rightsDTO); |
| 462 | rightsList.add(tempRights); | 482 | rightsList.add(tempRights); |
| 463 | 483 | ||
| 484 | if (!CollectionUtils.isEmpty(rightsList)) { | ||
| 485 | map.put(RightType.RIGHTS,rightsList); | ||
| 486 | } | ||
| 487 | |||
| 464 | // 权益类型 | 488 | // 权益类型 |
| 465 | String type = rightsDTO.getEntityType(); | 489 | String type = rightsDTO.getEntityType(); |
| 466 | switch (type) { | 490 | switch (type) { |
| 491 | // 优惠券 | ||
| 467 | case "1": | 492 | case "1": |
| 468 | Long entityId = rightsDTO.getEntityId(); | 493 | Long entityId1 = rightsDTO.getEntityId(); |
| 469 | if (Objects.nonNull(entityId)) { | 494 | if (Objects.nonNull(entityId1)) { |
| 470 | CouponDTO couponDTO = this.findCouponById(entityId); | 495 | CouponDTO couponDTO = this.findCouponById(entityId1); |
| 471 | if (Objects.nonNull(couponDTO)) { | 496 | if (Objects.nonNull(couponDTO.getId())) { |
| 497 | // 优惠券 | ||
| 498 | TempCoupon tempCoupon = this.tempCouponBuild(memberId, memberCode,rightsAmount, rightsSendStrategy, couponDTO, nickname); | ||
| 499 | tempCouponList.add(tempCoupon); | ||
| 500 | if (!CollectionUtils.isEmpty(tempCouponList)) { | ||
| 501 | map.put(RightType.COUPON,tempCouponList); | ||
| 502 | } | ||
| 503 | |||
| 504 | } | ||
| 505 | } | ||
| 506 | break; | ||
| 507 | // 观影券 | ||
| 508 | case "2": | ||
| 509 | Long entityId2 = rightsDTO.getEntityId(); | ||
| 510 | if (Objects.nonNull(entityId2)) { | ||
| 511 | CouponDTO couponDTO = this.findCouponById(entityId2); | ||
| 512 | if (Objects.nonNull(couponDTO.getId())) { | ||
| 472 | // 优惠券 | 513 | // 优惠券 |
| 473 | TempCoupon tempCoupon = this.tempCouponBuild(memberId, memberCode,rightsAmount, rightsSendStrategy, couponDTO, nickname); | 514 | TempCoupon tempCoupon = this.tempCouponBuild(memberId, memberCode,rightsAmount, rightsSendStrategy, couponDTO, nickname); |
| 474 | tempCouponList.add(tempCoupon); | 515 | tempCouponList.add(tempCoupon); |
| 516 | |||
| 517 | if (!CollectionUtils.isEmpty(tempCouponList)) { | ||
| 518 | map.put(RightType.COUPON,tempCouponList); | ||
| 519 | } | ||
| 475 | } | 520 | } |
| 476 | } | 521 | } |
| 477 | break; | 522 | break; |
| 523 | // 活动参与机会 | ||
| 524 | case "3": | ||
| 525 | map.put(RightType.ACTIVITYCHANCE, tempRights); | ||
| 526 | break; | ||
| 527 | // 积分商品 | ||
| 528 | case "4": | ||
| 529 | map.put(RightType.POINTGOODS, tempRights); | ||
| 530 | break; | ||
| 531 | // IPTV产品包 | ||
| 532 | case "5": | ||
| 533 | map.put(RightType.IPTVPRODUCT, tempRights); | ||
| 534 | break; | ||
| 535 | // IPTV观影权益 | ||
| 536 | case "6": | ||
| 537 | map.put(RightType.IPTVVIEW, tempRights); | ||
| 538 | break; | ||
| 478 | default: | 539 | default: |
| 479 | break; | 540 | break; |
| 480 | } | 541 | } |
| ... | @@ -911,8 +972,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -911,8 +972,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 911 | private List<Task> pickUpTask(List<Task> taskList,DataSyncMsg dataSyncMsg,Integer type) { | 972 | private List<Task> pickUpTask(List<Task> taskList,DataSyncMsg dataSyncMsg,Integer type) { |
| 912 | 973 | ||
| 913 | List<Task> taskList1 = new ArrayList<>(); | 974 | List<Task> taskList1 = new ArrayList<>(); |
| 914 | 975 | String msgData1 = dataSyncMsg.getMsgData(); | |
| 915 | DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); | 976 | DataSyncMsg.MsgData msgData = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); |
| 916 | 977 | ||
| 917 | if (Objects.nonNull(msgData.getParam())) { | 978 | if (Objects.nonNull(msgData.getParam())) { |
| 918 | 979 | ||
| ... | @@ -1042,8 +1103,9 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -1042,8 +1103,9 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 1042 | * @param event 任务 | 1103 | * @param event 任务 |
| 1043 | * @return TaskTemplate 任务模板 | 1104 | * @return TaskTemplate 任务模板 |
| 1044 | */ | 1105 | */ |
| 1045 | private TaskTemplate getTaskTemplate(Integer event, DataSyncMsg msgData) { | 1106 | private TaskTemplate getTaskTemplate(Integer event, DataSyncMsg dataSyncMsg) { |
| 1046 | DataSyncMsg.MsgData msg = msgData.getMsg(); | 1107 | String msgData1 = dataSyncMsg.getMsgData(); |
| 1108 | DataSyncMsg.MsgData msg = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); | ||
| 1047 | 1109 | ||
| 1048 | if (Objects.nonNull(msg.getParam())) { | 1110 | if (Objects.nonNull(msg.getParam())) { |
| 1049 | 1111 | ... | ... |
| ... | @@ -28,7 +28,7 @@ public class DataSyncMsg implements Serializable { | ... | @@ -28,7 +28,7 @@ public class DataSyncMsg implements Serializable { |
| 28 | // 发送时间 | 28 | // 发送时间 |
| 29 | private LocalDateTime time; | 29 | private LocalDateTime time; |
| 30 | // 消息体 | 30 | // 消息体 |
| 31 | private MsgData msg; | 31 | private String msgData; |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * 消息体 | 34 | * 消息体 | ... | ... |
| 1 | package com.topdraw.util; | 1 | package com.topdraw.util; |
| 2 | 2 | ||
| 3 | import java.time.LocalDate; | 3 | import java.time.LocalDate; |
| 4 | import java.time.LocalDateTime; | ||
| 5 | import java.time.ZoneId; | ||
| 6 | import java.util.Date; | ||
| 4 | 7 | ||
| 5 | public class LocalDateTimeUtil { | 8 | public class LocalDateTimeUtil { |
| 6 | 9 | ||
| ... | @@ -16,6 +19,11 @@ public class LocalDateTimeUtil { | ... | @@ -16,6 +19,11 @@ public class LocalDateTimeUtil { |
| 16 | return now+" 23:59:59"; | 19 | return now+" 23:59:59"; |
| 17 | } | 20 | } |
| 18 | 21 | ||
| 22 | public static Date LocalDateTime2Date(LocalDateTime now){ | ||
| 23 | Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant()); | ||
| 24 | return date; | ||
| 25 | } | ||
| 26 | |||
| 19 | public static void main(String[] args) { | 27 | public static void main(String[] args) { |
| 20 | String end = todayEnd(); | 28 | String end = todayEnd(); |
| 21 | System.out.println("end ==>> "+end); | 29 | System.out.println("end ==>> "+end); | ... | ... |
| ... | @@ -45,7 +45,7 @@ spring: | ... | @@ -45,7 +45,7 @@ spring: |
| 45 | hibernate: | 45 | hibernate: |
| 46 | # 生产环境设置成 none,避免程序运行时自动更新数据库结构 | 46 | # 生产环境设置成 none,避免程序运行时自动更新数据库结构 |
| 47 | ddl-auto: none | 47 | ddl-auto: none |
| 48 | show-sql: true | 48 | show-sql: false |
| 49 | servlet: | 49 | servlet: |
| 50 | multipart: | 50 | multipart: |
| 51 | file-size-threshold: 2KB | 51 | file-size-threshold: 2KB | ... | ... |
| ... | @@ -10,6 +10,9 @@ import com.topdraw.business.module.member.service.MemberService; | ... | @@ -10,6 +10,9 @@ import com.topdraw.business.module.member.service.MemberService; |
| 10 | import org.junit.Test; | 10 | import org.junit.Test; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 12 | ||
| 13 | import java.time.LocalDate; | ||
| 14 | import java.time.LocalDateTime; | ||
| 15 | |||
| 13 | public class CouponServiceTest extends BaseTest { | 16 | public class CouponServiceTest extends BaseTest { |
| 14 | 17 | ||
| 15 | @Autowired | 18 | @Autowired |
| ... | @@ -28,6 +31,18 @@ public class CouponServiceTest extends BaseTest { | ... | @@ -28,6 +31,18 @@ public class CouponServiceTest extends BaseTest { |
| 28 | System.out.println(couponHistoryDTO); | 31 | System.out.println(couponHistoryDTO); |
| 29 | } | 32 | } |
| 30 | 33 | ||
| 34 | |||
| 35 | @Test | ||
| 36 | public void countByUserIdAndExpireTimeBefore(){ | ||
| 37 | CouponDTO couponDTO = this.couponService.findById(1L); | ||
| 38 | System.out.println(couponDTO); | ||
| 39 | CouponDTO testvxv = this.couponService.getByCode("testvxv"); | ||
| 40 | System.out.println(testvxv); | ||
| 41 | |||
| 42 | Long l = this.couponHistoryService.countByUserIdAndExpireTimeBefore(1L, LocalDateTime.now()); | ||
| 43 | System.out.println(l); | ||
| 44 | } | ||
| 45 | |||
| 31 | @Test | 46 | @Test |
| 32 | public void findHistoryBy(){ | 47 | public void findHistoryBy(){ |
| 33 | CouponHistoryDTO couponHistoryDTO = this.couponHistoryService.findById(130L); | 48 | CouponHistoryDTO couponHistoryDTO = this.couponHistoryService.findById(130L); | ... | ... |
| ... | @@ -26,7 +26,7 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -26,7 +26,7 @@ public class TaskOperationControllerTest extends BaseTest { |
| 26 | public void wechatShare() { | 26 | public void wechatShare() { |
| 27 | try { | 27 | try { |
| 28 | String s = "{\"evt\":\"WECHATSHARE\",\"event\":8,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + | 28 | String s = "{\"evt\":\"WECHATSHARE\",\"event\":8,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + |
| 29 | "\"msg\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"shareCount\\\":2}\"}}"; | 29 | "\"msgData\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"shareCount\\\":2}\"}}"; |
| 30 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 30 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
| 31 | pointsQueryCriteria.setContent(s); | 31 | pointsQueryCriteria.setContent(s); |
| 32 | String s1 = JSON.toJSONString(pointsQueryCriteria); | 32 | String s1 = JSON.toJSONString(pointsQueryCriteria); |
| ... | @@ -40,7 +40,7 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -40,7 +40,7 @@ public class TaskOperationControllerTest extends BaseTest { |
| 40 | public void completeMemberInfo() { | 40 | public void completeMemberInfo() { |
| 41 | try { | 41 | try { |
| 42 | String s = "{\"evt\":\"completeMemberInfo\",\"event\":7,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1, " + | 42 | String s = "{\"evt\":\"completeMemberInfo\",\"event\":7,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1, " + |
| 43 | "\"msg\":{\"memberCode\":\"1530105170425733120\"}}"; | 43 | "\"msgData\":{\"memberCode\":\"1530105170425733120\"}}"; |
| 44 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 44 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
| 45 | pointsQueryCriteria.setContent(s); | 45 | pointsQueryCriteria.setContent(s); |
| 46 | String s1 = JSON.toJSONString(pointsQueryCriteria); | 46 | String s1 = JSON.toJSONString(pointsQueryCriteria); |
| ... | @@ -54,7 +54,7 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -54,7 +54,7 @@ public class TaskOperationControllerTest extends BaseTest { |
| 54 | public void activity() { | 54 | public void activity() { |
| 55 | try { | 55 | try { |
| 56 | String s = "{\"evt\":\"ACTIVITY\",\"event\":3,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + | 56 | String s = "{\"evt\":\"ACTIVITY\",\"event\":3,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + |
| 57 | "\"msg\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"ACTIVITY\\\":3}\"}}"; | 57 | "\"msgData\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"ACTIVITY\\\":3}\"}}"; |
| 58 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 58 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
| 59 | pointsQueryCriteria.setContent(s); | 59 | pointsQueryCriteria.setContent(s); |
| 60 | String s1 = JSON.toJSONString(pointsQueryCriteria); | 60 | String s1 = JSON.toJSONString(pointsQueryCriteria); |
| ... | @@ -68,7 +68,7 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -68,7 +68,7 @@ public class TaskOperationControllerTest extends BaseTest { |
| 68 | public void order() { | 68 | public void order() { |
| 69 | try { | 69 | try { |
| 70 | String s = "{\"evt\":\"order\",\"event\":4,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":2," + | 70 | String s = "{\"evt\":\"order\",\"event\":4,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":2," + |
| 71 | "\"msg\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"GOODS\\\":3}\"}}"; | 71 | "\"msgData\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"GOODS\\\":3}\"}}"; |
| 72 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 72 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
| 73 | pointsQueryCriteria.setContent(s); | 73 | pointsQueryCriteria.setContent(s); |
| 74 | String s1 = JSON.toJSONString(pointsQueryCriteria); | 74 | String s1 = JSON.toJSONString(pointsQueryCriteria); |
| ... | @@ -82,7 +82,7 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -82,7 +82,7 @@ public class TaskOperationControllerTest extends BaseTest { |
| 82 | public void viewing() { | 82 | public void viewing() { |
| 83 | try { | 83 | try { |
| 84 | String s = "{\"evt\":\"VIEWING\",\"event\":2,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + | 84 | String s = "{\"evt\":\"VIEWING\",\"event\":2,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + |
| 85 | "\"msg\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"playDuration\\\":10}\"}}"; | 85 | "\"msgData\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"playDuration\\\":10}\"}}"; |
| 86 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 86 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
| 87 | pointsQueryCriteria.setContent(s); | 87 | pointsQueryCriteria.setContent(s); |
| 88 | String s1 = JSON.toJSONString(pointsQueryCriteria); | 88 | String s1 = JSON.toJSONString(pointsQueryCriteria); |
| ... | @@ -96,7 +96,7 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -96,7 +96,7 @@ public class TaskOperationControllerTest extends BaseTest { |
| 96 | public void play() { | 96 | public void play() { |
| 97 | try { | 97 | try { |
| 98 | String s = "{\"evt\":\"PLAY\",\"event\":8,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + | 98 | String s = "{\"evt\":\"PLAY\",\"event\":8,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + |
| 99 | "\"msg\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"playDuration\\\":60}\"}}"; | 99 | "\"msgData\":{\"memberCode\":\"1537253277861699584\",\"param\":\"{\\\"playDuration\\\":60}\"}}"; |
| 100 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 100 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
| 101 | pointsQueryCriteria.setContent(s); | 101 | pointsQueryCriteria.setContent(s); |
| 102 | String s1 = JSON.toJSONString(pointsQueryCriteria); | 102 | String s1 = JSON.toJSONString(pointsQueryCriteria); |
| ... | @@ -110,7 +110,7 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -110,7 +110,7 @@ public class TaskOperationControllerTest extends BaseTest { |
| 110 | public void sign() { | 110 | public void sign() { |
| 111 | try { | 111 | try { |
| 112 | String s = "{\"evt\":\"SIGN\",\"event\":6,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + | 112 | String s = "{\"evt\":\"SIGN\",\"event\":6,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + |
| 113 | "\"msg\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"SIGN\\\":11}\"}}"; | 113 | "\"msgData\":{\"memberCode\":\"1530105170425733120\",\"param\":\"{\\\"SIGN\\\":11}\"}}"; |
| 114 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 114 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
| 115 | pointsQueryCriteria.setContent(s); | 115 | pointsQueryCriteria.setContent(s); |
| 116 | this.taskOperationController.dealTask(pointsQueryCriteria); | 116 | this.taskOperationController.dealTask(pointsQueryCriteria); |
| ... | @@ -119,6 +119,18 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -119,6 +119,18 @@ public class TaskOperationControllerTest extends BaseTest { |
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | @Test | ||
| 123 | public void login() { | ||
| 124 | try { | ||
| 125 | String s = "{\"evt\":\"LOGIN\",\"event\":1,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + | ||
| 126 | "\"msgData\":{\"memberCode\":\"1537253315610435584\",\"param\":\"{\\\"CONTINUE_LOGIN\\\":2}\"}}"; | ||
| 127 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | ||
| 128 | pointsQueryCriteria.setContent(s); | ||
| 129 | this.taskOperationController.dealTask(pointsQueryCriteria); | ||
| 130 | } catch (Exception e) { | ||
| 131 | e.printStackTrace(); | ||
| 132 | } | ||
| 133 | } | ||
| 122 | 134 | ||
| 123 | 135 | ||
| 124 | 136 | ... | ... |
| ... | @@ -24,7 +24,7 @@ public class TaskOperationServiceTest extends BaseTest { | ... | @@ -24,7 +24,7 @@ public class TaskOperationServiceTest extends BaseTest { |
| 24 | msgData.setMemberId(memberId); | 24 | msgData.setMemberId(memberId); |
| 25 | 25 | ||
| 26 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); | 26 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); |
| 27 | dataSyncMsg.setMsg(msgData); | 27 | // dataSyncMsg.setMsgData(msgData); |
| 28 | 28 | ||
| 29 | String s = JSON.toJSONString(dataSyncMsg); | 29 | String s = JSON.toJSONString(dataSyncMsg); |
| 30 | this.taskOperationService.dealTask(s); | 30 | this.taskOperationService.dealTask(s); | ... | ... |
| ... | @@ -26,7 +26,7 @@ public class MqTest extends BaseTest { | ... | @@ -26,7 +26,7 @@ public class MqTest extends BaseTest { |
| 26 | msgData.setRemarks("remark"); | 26 | msgData.setRemarks("remark"); |
| 27 | msgData.setMemberId(1L); | 27 | msgData.setMemberId(1L); |
| 28 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); | 28 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); |
| 29 | dataSyncMsg.setMsg(msgData); | 29 | // dataSyncMsg.setMsgData(msgData); |
| 30 | String s = JSON.toJSONString(dataSyncMsg); | 30 | String s = JSON.toJSONString(dataSyncMsg); |
| 31 | amqpTemplate.convertAndSend( "uc.route.key.direct.event.aaa", s); | 31 | amqpTemplate.convertAndSend( "uc.route.key.direct.event.aaa", s); |
| 32 | } | 32 | } | ... | ... |
-
Please register or sign in to post a comment