Commit 75d127a8 75d127a833a2c784c89ed5b9c0da62ab03fdc1ba by xianghan

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

# Conflicts:
#	member-service-api/pom.xml
#	member-service-impl/.gitignore
#	member-service-impl/src/main/java/com/topdraw/business/basicdata/member/relatedinfo/rest/MemberRelatedInfoController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/coupon/history/rest/CouponHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/coupon/rest/CouponController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/exp/detail/rest/ExpDetailController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/exp/history/rest/ExpHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/address/rest/MemberAddressController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/group/rest/MemberGroupController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/level/rest/MemberLevelController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/profile/rest/MemberProfileController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/member/rest/MemberController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/available/rest/PointsAvailableController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/detail/detailhistory/rest/PointsDetailHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/detail/rest/PointsDetailController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/rest/PointsController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/points/standingbook/rest/PointsStandingBookController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/rights/history/rest/RightsHistoryController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/rights/permanentrights/rest/PermanentRightsController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/task/progress/rest/TrTaskProgressController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/task/rest/TaskController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/task/template/rest/TaskTemplateController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/user/iptv/rest/UserTvController.java
#	member-service-impl/src/main/java/com/topdraw/business/module/user/weixin/rest/UserWeixinController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/CouponOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/ExpOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/PointsOperationController.java
#	member-service-impl/src/main/java/com/topdraw/business/process/rest/TaskOperationController.java
#	member-service-impl/src/main/resources/config/application-dev.yml
2 parents 9ba9a1c0 3e7c3d3f
Showing 323 changed files with 8014 additions and 1335 deletions
......@@ -12,15 +12,21 @@
<artifactId>member-service-api</artifactId>
<properties>
<cronos.version>1.1.0</cronos.version>
</properties>
<dependencies>
<!--代码生成器-->
<!--系统-->
<dependency>
<groupId>com.topdraw</groupId>
<artifactId>cronos-system</artifactId>
<version>1.1.0</version>
<version>${cronos.version}</version>
</dependency>
<!--代码生成器-->
<dependency>
<groupId>com.topdraw</groupId>
<artifactId>cronos-generator</artifactId>
<version>${cronos.version}</version>
</dependency>
</dependencies>
......
......@@ -25,6 +25,8 @@ public class DataSyncMsg implements Serializable {
// 其他属性
private String extraData;
/** 模板参数 */
private TaskTemplateParam param;
/**
* 消息体
......@@ -38,15 +40,29 @@ public class DataSyncMsg implements Serializable {
private Integer event; // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他
@NotNull
private Long memberId; // 会员id
private Long userId; // 账户id
@NotNull
private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
@NotNull
private String appCode; //用户对应的应用code
private String memberCode;
private Long accountId; // 账号id
private Long orderId;
private Long activityId;
private Long mediaId;
private Long itemId;
private String param;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class TaskTemplateParam {
/** 类别 */
private String category;
/** 编码 */
private String code;
}
}
......
package com.topdraw.module.mq;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/2/3 22:46
* @version: :
* @modified By:
* @since : modified in 2022/2/3 22:46
*/
public enum DeviceType {
IPTV(),
weixin();
}
......@@ -2,4 +2,4 @@
/logs/
/member-service-impl.iml
/src/main/resources/rebel.xml
*.iml
\ No newline at end of file
/src/test/
\ No newline at end of file
......
package com.topdraw;
import com.topdraw.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -12,7 +13,6 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.CrossOrigin;
/**
* @author XiangHan
......@@ -20,10 +20,10 @@ import org.springframework.web.bind.annotation.CrossOrigin;
*/
@EnableJpaAuditing
@EnableAsync
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
@EnableTransactionManagement
@EnableRetry
@EnableCaching
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class MemberServiceApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
......@@ -39,4 +39,7 @@ public class MemberServiceApplication extends SpringBootServletInitializer {
public SpringContextHolder springContextHolder() {
return new SpringContextHolder();
}
}
......
package com.topdraw.business.module.common.domain;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Transient;
import java.io.Serializable;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/2/10 10:12
* @version: :
* @modified By:
* @since : modified in 2022/2/10 10:12
*/
@Data
@Accessors(chain = true)
public class DefaultAsyncMqModule {
@Transient
private String memberCode;
}
package com.topdraw.business.basicdata.coupon.domain;
package com.topdraw.business.module.coupon.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.coupon.history.domain;
package com.topdraw.business.module.coupon.history.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......@@ -48,7 +48,7 @@ public class CouponHistory implements Serializable {
// 领取时间
@Column(name = "receive_time")
private Timestamp receiveTime;
private LocalDateTime receiveTime;
// 失效时间
@Column(name = "expire_time")
......@@ -60,7 +60,7 @@ public class CouponHistory implements Serializable {
// 使用时间
@Column(name = "use_time")
private Timestamp useTime;
private LocalDateTime useTime;
// 订单详情id
@Column(name = "order_detail_id")
......@@ -69,12 +69,12 @@ public class CouponHistory implements Serializable {
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
private LocalDateTime createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
private LocalDateTime updateTime;
public void copy(CouponHistory source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
......
package com.topdraw.business.basicdata.coupon.history.repository;
package com.topdraw.business.module.coupon.history.repository;
import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.sql.Timestamp;
import java.util.Optional;
import java.time.LocalDateTime;
/**
* @author XiangHan
......@@ -15,7 +15,7 @@ public interface CouponHistoryRepository extends JpaRepository<CouponHistory, Lo
Long countByUserId(Long userId);
Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now);
Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now);
Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime);
Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime);
}
......
package com.topdraw.business.basicdata.coupon.history.rest;
package com.topdraw.business.module.coupon.history.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory;
import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService;
import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -39,7 +34,6 @@ public class CouponHistoryController {
return ResultInfo.success(CouponHistoryService.queryAll(criteria));
}
@Log
@PostMapping(value = "/create")
@ApiOperation("新增CouponHistory")
public ResultInfo create(@Validated @RequestBody CouponHistory resources) {
......@@ -47,7 +41,6 @@ public class CouponHistoryController {
return ResultInfo.success();
}
@Log
@PutMapping(value = "/update")
@ApiOperation("修改CouponHistory")
public ResultInfo update(@Validated @RequestBody CouponHistory resources) {
......@@ -56,7 +49,6 @@ public class CouponHistoryController {
}
@Log
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除CouponHistory")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.coupon.history.service;
package com.topdraw.business.module.coupon.history.service;
import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory;
import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -47,7 +46,7 @@ public interface CouponHistoryService {
Long countByUserId(Long userId);
Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now);
Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now);
Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime);
Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime);
}
......
package com.topdraw.business.basicdata.coupon.history.service.dto;
package com.topdraw.business.module.coupon.history.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;
......@@ -29,7 +28,7 @@ public class CouponHistoryDTO implements Serializable {
private String userNickname;
// 领取时间
private Timestamp receiveTime;
private LocalDateTime receiveTime;
// 失效时间
private LocalDateTime expireTime;
......@@ -38,14 +37,14 @@ public class CouponHistoryDTO implements Serializable {
private Integer useStatus;
// 使用时间
private Timestamp useTime;
private LocalDateTime useTime;
// 订单详情id
private Long orderDetailId;
// 创建时间
private Timestamp createTime;
private LocalDateTime createTime;
// 更新时间
private Timestamp updateTime;
private LocalDateTime updateTime;
}
......
package com.topdraw.business.basicdata.coupon.history.service.dto;
package com.topdraw.business.module.coupon.history.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.coupon.history.service.impl;
package com.topdraw.business.module.coupon.history.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.coupon.history.repository.CouponHistoryRepository;
import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService;
import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria;
import com.topdraw.business.basicdata.coupon.history.service.mapper.CouponHistoryMapper;
import com.topdraw.business.module.coupon.history.repository.CouponHistoryRepository;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
import com.topdraw.business.module.coupon.history.service.mapper.CouponHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -20,6 +20,7 @@ import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
......@@ -87,12 +88,12 @@ public class CouponHistoryServiceImpl implements CouponHistoryService {
}
@Override
public Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now) {
public Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now) {
return this.CouponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now);
}
@Override
public Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime) {
public Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime) {
return this.CouponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime);
}
......
package com.topdraw.business.basicdata.coupon.history.service.mapper;
package com.topdraw.business.module.coupon.history.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory;
import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.coupon.repository;
package com.topdraw.business.module.coupon.repository;
import com.topdraw.business.basicdata.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.domain.Coupon;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.coupon.rest;
package com.topdraw.business.module.coupon.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.coupon.domain.Coupon;
import com.topdraw.business.basicdata.coupon.service.CouponService;
import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
......@@ -35,7 +34,6 @@ public class CouponController {
return ResultInfo.success(CouponService.queryAll(criteria));
}
@Log
@PostMapping(value = "/create")
@ApiOperation("新增Coupon")
public ResultInfo create(@Validated @RequestBody Coupon resources) {
......@@ -43,7 +41,6 @@ public class CouponController {
return ResultInfo.success();
}
@Log
@PutMapping(value = "/update")
@ApiOperation("修改Coupon")
public ResultInfo update(@Validated @RequestBody Coupon resources) {
......@@ -51,8 +48,6 @@ public class CouponController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除Coupon")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.coupon.service;
package com.topdraw.business.module.coupon.service;
import com.topdraw.business.basicdata.coupon.domain.Coupon;
import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO;
import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.coupon.service.dto;
package com.topdraw.business.module.coupon.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.coupon.service.impl;
package com.topdraw.business.module.coupon.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.util.RedissonUtil;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.coupon.repository.CouponRepository;
import com.topdraw.business.basicdata.coupon.service.CouponService;
import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO;
import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria;
import com.topdraw.business.basicdata.coupon.service.mapper.CouponMapper;
import com.topdraw.business.module.coupon.repository.CouponRepository;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
import com.topdraw.business.module.coupon.service.mapper.CouponMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.business.basicdata.coupon.service.mapper;
package com.topdraw.business.module.coupon.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.coupon.domain.Coupon;
import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.exp.detail.domain;
package com.topdraw.business.module.exp.detail.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.exp.detail.repository;
package com.topdraw.business.module.exp.detail.repository;
import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.exp.detail.rest;
package com.topdraw.business.module.exp.detail.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail;
import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService;
import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.ExpDetailService;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
......@@ -35,7 +34,6 @@ public class ExpDetailController {
return ResultInfo.success(ExpDetailService.queryAll(criteria));
}
@Log
@PostMapping(value = "/create")
@ApiOperation("新增ExpDetail")
public ResultInfo create(@Validated @RequestBody ExpDetail resources) {
......@@ -43,7 +41,6 @@ public class ExpDetailController {
return ResultInfo.success();
}
@Log
@PutMapping(value = "/update")
@ApiOperation("修改ExpDetail")
public ResultInfo update(@Validated @RequestBody ExpDetail resources) {
......@@ -51,8 +48,6 @@ public class ExpDetailController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除ExpDetail")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.exp.detail.service;
package com.topdraw.business.module.exp.detail.service;
import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail;
import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO;
import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.exp.detail.service.dto;
package com.topdraw.business.module.exp.detail.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.exp.detail.service.impl;
package com.topdraw.business.module.exp.detail.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.exp.detail.repository.ExpDetailRepository;
import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService;
import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO;
import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria;
import com.topdraw.business.basicdata.exp.detail.service.mapper.ExpDetailMapper;
import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository;
import com.topdraw.business.module.exp.detail.service.ExpDetailService;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.business.basicdata.exp.detail.service.mapper;
package com.topdraw.business.module.exp.detail.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail;
import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.exp.history.domain;
package com.topdraw.business.module.exp.history.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.exp.history.repository;
package com.topdraw.business.module.exp.history.repository;
import com.topdraw.business.basicdata.exp.history.domain.ExpHistory;
import com.topdraw.business.module.exp.history.domain.ExpHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.exp.history.rest;
package com.topdraw.business.module.exp.history.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.exp.history.domain.ExpHistory;
import com.topdraw.business.basicdata.exp.history.service.ExpHistoryService;
import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria;
import com.topdraw.business.module.exp.history.service.ExpHistoryService;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
......
package com.topdraw.business.basicdata.exp.history.service;
package com.topdraw.business.module.exp.history.service;
import com.topdraw.business.basicdata.exp.history.domain.ExpHistory;
import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO;
import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria;
import com.topdraw.business.module.exp.history.domain.ExpHistory;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.exp.history.service.dto;
package com.topdraw.business.module.exp.history.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.exp.history.service.impl;
package com.topdraw.business.module.exp.history.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.exp.history.domain.ExpHistory;
import com.topdraw.business.module.exp.history.domain.ExpHistory;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.exp.history.repository.ExpHistoryRepository;
import com.topdraw.business.basicdata.exp.history.service.ExpHistoryService;
import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO;
import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria;
import com.topdraw.business.basicdata.exp.history.service.mapper.ExpHistoryMapper;
import com.topdraw.business.module.exp.history.repository.ExpHistoryRepository;
import com.topdraw.business.module.exp.history.service.ExpHistoryService;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria;
import com.topdraw.business.module.exp.history.service.mapper.ExpHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......
package com.topdraw.business.basicdata.exp.history.service.mapper;
package com.topdraw.business.module.exp.history.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.exp.history.domain.ExpHistory;
import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO;
import com.topdraw.business.module.exp.history.domain.ExpHistory;
import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.member.address.domain;
package com.topdraw.business.module.member.address.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......@@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author XiangHan
......@@ -90,12 +91,12 @@ public class MemberAddress implements Serializable {
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
private LocalDateTime createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
private LocalDateTime updateTime;
public void copy(MemberAddress source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
......
package com.topdraw.business.basicdata.member.address.repository;
package com.topdraw.business.module.member.address.repository;
import com.topdraw.business.basicdata.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.member.address.rest;
package com.topdraw.business.module.member.address.rest;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.member.address.domain.MemberAddress;
import com.topdraw.business.basicdata.member.address.service.MemberAddressService;
import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.service.MemberAddressService;
import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import org.springframework.util.Base64Utils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Objects;
/**
......@@ -29,16 +23,15 @@ import java.util.Objects;
*/
@Api(tags = "MemberAddress管理")
@RestController
@RequestMapping("/api/MemberAddress")
@RequestMapping("/ucEngine/api/memberAddress")
@CrossOrigin
@Slf4j
public class MemberAddressController {
@Autowired
private MemberAddressService MemberAddressService;
@Autowired
private MemberService memberService;
@Autowired
private UserTvService userTvService;
@GetMapping(value = "/pageMemberAddress")
@ApiOperation("查询MemberAddress")
......@@ -52,50 +45,27 @@ public class MemberAddressController {
return ResultInfo.success(MemberAddressService.findById(id));
}
@Log
@PostMapping(value = "/create")
@ApiOperation("新增MemberAddress")
public ResultInfo create(@Validated @RequestBody MemberAddress resources) {
MemberAddressService.create(resources);
return ResultInfo.success();
}
@Log
@PostMapping(value = "/createByPlatformAccount")
@ApiOperation("通过大屏账户创建会员地址")
@AnonymousAccess
public ResultInfo createByPlatformAccount(@RequestBody String contentDecode) {
byte[] bytes = contentDecode.getBytes(StandardCharsets.UTF_8);
byte[] decode = Base64Utils.decode(bytes);
String content = new String(decode);
MemberAddress resources = JSONObject.parseObject(content,MemberAddress.class);
String platformAccount = resources.getPlatformAccount();
Assert.notNull(platformAccount,"platformAccount can't be null!");
public ResultInfo create(@Validated @RequestBody MemberAddress resources) {
log.info("MemberAddressController ==>> create ===>>[{}]",resources);
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.nonNull(userTvDTO) && Objects.nonNull(userTvDTO.getId())) {
Long memberId = userTvDTO.getMemberId();
Long memberId = resources.getMemberId();
MemberDTO memberDTO = this.memberService.findById(memberId);
String code = memberDTO.getCode();
resources.setMemberCode(code);
resources.setMemberId(memberId);
resources.setCity("");
resources.setStatus(1);
resources.setContactor("");
resources.setCountry("cn");
resources.setDistrict("");
resources.setType(1);
resources.setIsDefault(2);
resources.setProvince("");
this.create(resources);
}
MemberAddressService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping(value = "/update")
@ApiOperation("修改MemberAddress")
@AnonymousAccess
public ResultInfo update(@Validated @RequestBody MemberAddress resources) {
log.info("MemberAddressController ==>> update ===>>[{}]",resources);
Long memberId = resources.getMemberId();
Integer sequence = resources.getSequence();
Assert.notNull(memberId,"memberId can't be null");
......@@ -110,9 +80,9 @@ public class MemberAddressController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除MemberAddress")
@AnonymousAccess
public ResultInfo delete(@PathVariable Long id) {
MemberAddressService.delete(id);
return ResultInfo.success();
......
package com.topdraw.business.basicdata.member.address.service;
package com.topdraw.business.module.member.address.service;
import com.topdraw.business.basicdata.member.address.domain.MemberAddress;
import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......@@ -40,5 +40,4 @@ public interface MemberAddressService {
void update(MemberAddress resources);
void delete(Long id);
}
......
package com.topdraw.business.basicdata.member.address.service.dto;
package com.topdraw.business.module.member.address.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
......@@ -55,8 +56,8 @@ public class MemberAddressDTO implements Serializable {
private String zipCode;
// 创建时间
private Timestamp createTime;
private LocalDateTime createTime;
// 更新时间
private Timestamp updateTime;
private LocalDateTime updateTime;
}
......
package com.topdraw.business.basicdata.member.address.service.dto;
package com.topdraw.business.module.member.address.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
......
package com.topdraw.business.basicdata.member.address.service.impl;
package com.topdraw.business.module.member.address.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.member.address.repository.MemberAddressRepository;
import com.topdraw.business.basicdata.member.address.service.MemberAddressService;
import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria;
import com.topdraw.business.basicdata.member.address.service.mapper.MemberAddressMapper;
import com.topdraw.business.module.member.address.repository.MemberAddressRepository;
import com.topdraw.business.module.member.address.service.MemberAddressService;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......
package com.topdraw.business.basicdata.member.address.service.mapper;
package com.topdraw.business.module.member.address.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.member.address.domain.MemberAddress;
import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.member.domain;
package com.topdraw.business.module.member.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
......@@ -118,23 +116,23 @@ public class Member implements Serializable {
/** iptv账号绑定时间 */
@Column(name = "bind_iptv_time")
private Timestamp bindIptvTime;
private LocalDateTime bindIptvTime;
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
private LocalDateTime createTime;
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
private LocalDateTime updateTime;
/** 是否在黑名单 1:是;0否 */
@Column(name = "black_status")
private Long blackStatus;
public void copy(Member source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
}
}
......
package com.topdraw.business.module.member.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.topdraw.util.IdWorker;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
/**
* @author XiangHan
* @date 2021-10-22
*/
public class MemberBuilder {
public static Member build(Integer type,String avatarUrl,String nickname,Integer vip){
Member member = new Member();
member.setType(type);
member.setBlackStatus(0L);
member.setGender(-1);
member.setVip(vip==null?0:vip);
member.setLevel(1);
member.setStatus(1);
member.setPoints(0L);
member.setDuePoints(0L);
member.setExp(0L);
member.setCouponAmount(0L);
member.setDueCouponAmount(0L);
member.setAvatarUrl(avatarUrl);
member.setCode(IdWorker.generator() + "");
member.setNickname(nickname);
return member;
}
}
package com.topdraw.business.module.member.domain;
public interface MemberConstant {
// vip等级
Integer vip[] = new Integer[]{0,1,2,3,4,5,6,7,8};
}
package com.topdraw.business.basicdata.member.group.domain;
package com.topdraw.business.module.member.group.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.member.group.repository;
package com.topdraw.business.module.member.group.repository;
import com.topdraw.business.basicdata.member.group.domain.MemberGroup;
import com.topdraw.business.module.member.group.domain.MemberGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Optional;
/**
* @author XiangHan
* @date 2021-11-17
......
package com.topdraw.business.basicdata.member.group.rest;
package com.topdraw.business.module.member.group.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.member.group.domain.MemberGroup;
import com.topdraw.business.basicdata.member.group.service.MemberGroupService;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria;
import com.topdraw.business.module.member.group.domain.MemberGroup;
import com.topdraw.business.module.member.group.service.MemberGroupService;
import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -39,7 +34,6 @@ public class MemberGroupController {
return ResultInfo.success(MemberGroupService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增MemberGroup")
public ResultInfo create(@Validated @RequestBody MemberGroup resources) {
......@@ -47,7 +41,6 @@ public class MemberGroupController {
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改MemberGroup")
public ResultInfo update(@Validated @RequestBody MemberGroup resources) {
......@@ -55,8 +48,6 @@ public class MemberGroupController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除MemberGroup")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.member.group.service;
package com.topdraw.business.module.member.group.service;
import com.topdraw.business.basicdata.member.group.domain.MemberGroup;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria;
import com.topdraw.business.module.member.group.domain.MemberGroup;
import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.member.group.service.dto;
package com.topdraw.business.module.member.group.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.member.group.service.dto;
package com.topdraw.business.module.member.group.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
......
package com.topdraw.business.basicdata.member.group.service.impl;
package com.topdraw.business.module.member.group.service.impl;
import com.topdraw.business.basicdata.member.group.domain.MemberGroup;
import com.topdraw.business.module.member.group.domain.MemberGroup;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.utils.FileUtil;
import com.topdraw.business.basicdata.member.group.repository.MemberGroupRepository;
import com.topdraw.business.basicdata.member.group.service.MemberGroupService;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria;
import com.topdraw.business.basicdata.member.group.service.mapper.MemberGroupMapper;
import com.topdraw.business.module.member.group.repository.MemberGroupRepository;
import com.topdraw.business.module.member.group.service.MemberGroupService;
import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
import com.topdraw.business.module.member.group.service.mapper.MemberGroupMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.member.group.service.mapper;
package com.topdraw.business.module.member.group.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.member.group.domain.MemberGroup;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO;
import com.topdraw.business.module.member.group.domain.MemberGroup;
import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.member.level.domain;
package com.topdraw.business.module.member.level.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.member.level.repository;
package com.topdraw.business.module.member.level.repository;
import com.topdraw.business.basicdata.member.level.domain.MemberLevel;
import com.topdraw.business.module.member.level.domain.MemberLevel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.member.level.rest;
package com.topdraw.business.module.member.level.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.member.level.domain.MemberLevel;
import com.topdraw.business.basicdata.member.level.service.MemberLevelService;
import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria;
import com.topdraw.business.module.member.level.service.MemberLevelService;
import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
......
package com.topdraw.business.basicdata.member.level.service;
package com.topdraw.business.module.member.level.service;
import com.topdraw.business.basicdata.member.level.domain.MemberLevel;
import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO;
import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria;
import com.topdraw.business.module.member.level.domain.MemberLevel;
import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.member.level.service.dto;
package com.topdraw.business.module.member.level.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.member.level.service.impl;
package com.topdraw.business.module.member.level.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.level.domain.MemberLevel;
import com.topdraw.business.module.member.level.domain.MemberLevel;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.member.level.repository.MemberLevelRepository;
import com.topdraw.business.basicdata.member.level.service.MemberLevelService;
import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO;
import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria;
import com.topdraw.business.basicdata.member.level.service.mapper.MemberLevelMapper;
import com.topdraw.business.module.member.level.repository.MemberLevelRepository;
import com.topdraw.business.module.member.level.service.MemberLevelService;
import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......
package com.topdraw.business.basicdata.member.level.service.mapper;
package com.topdraw.business.module.member.level.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.member.level.domain.MemberLevel;
import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO;
import com.topdraw.business.module.member.level.domain.MemberLevel;
import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.member.profile.domain;
package com.topdraw.business.module.member.profile.domain;
import com.topdraw.business.basicdata.member.profile.DoSaveMemberProfileGroup;
import com.topdraw.business.basicdata.member.profile.DoUpdateMemberProfileGroup;
import com.topdraw.business.module.member.profile.DoSaveMemberProfileGroup;
import com.topdraw.business.module.member.profile.DoUpdateMemberProfileGroup;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
......@@ -89,6 +89,10 @@ public class MemberProfile implements Serializable {
@Column(name = "district")
private String district;
//头像
@Transient
private String avatarUrl;
// 描述
@Column(name = "description")
private String description;
......
package com.topdraw.business.module.member.profile.domain;
import com.topdraw.utils.StringUtils;
import java.sql.Timestamp;
import java.util.Objects;
public class MemberProfileBuild {
public static MemberProfile build(Long memberId , String realname , Integer gender, Timestamp birthday){
MemberProfile memberProfile = build(memberId,realname,gender,"","","","","","",
"","","",birthday);
return memberProfile;
}
public static MemberProfile build(){
MemberProfile memberProfile = build(null,"",null,"","","","","","",
"","","",null);
return memberProfile;
}
public static MemberProfile build(Long memberId, String realName, Integer sex,
String contry, String district, String city, String idCard, String province,
String email, String description, String phone, String constellation,
Timestamp timestamp) {
if (memberId == null)
throw new NullPointerException("memberId is null");
MemberProfile memberProfile = new MemberProfile();
memberProfile.setMemberId(memberId);
memberProfile.setRealname(stringIsNull(realName));
memberProfile.setGender(sex == null ? 0 : sex);
memberProfile.setCountry(stringIsNull(contry));
memberProfile.setDistrict(stringIsNull(district));
memberProfile.setCity(stringIsNull(city));
memberProfile.setIdCard(stringIsNull(idCard));
memberProfile.setProvince(stringIsNull(province));
memberProfile.setEmail(stringIsNull(email));
memberProfile.setDescription(stringIsNull(description));
memberProfile.setPhone(stringIsNull(phone));
memberProfile.setConstellation(stringIsNull(constellation));
memberProfile.setBirthday(timestamp);
return memberProfile;
}
private static String stringIsNull(String s){
return StringUtils.isBlank(s)?"":s;
}
private static Object objectIsNull(Object s){
return Objects.nonNull(s)?null:s;
}
}
package com.topdraw.business.basicdata.member.profile.repository;
package com.topdraw.business.module.member.profile.repository;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......@@ -13,4 +14,6 @@ import java.util.Optional;
public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> {
Optional<MemberProfile> findByMemberId(Long memberId);
Optional<MemberProfile> findFirstByMemberId(Long memberId);
}
......
package com.topdraw.business.basicdata.member.profile.rest;
package com.topdraw.business.module.member.profile.rest;
import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import com.topdraw.business.basicdata.member.profile.service.MemberProfileService;
import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.util.Base64Util;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -24,8 +24,9 @@ import java.util.Objects;
*/
@Api(tags = "MemberProfile管理")
@RestController
@RequestMapping("/api/MemberProfile")
@RequestMapping("/ucEngine/api/memberProfile")
@CrossOrigin
@Slf4j
public class MemberProfileController {
@Autowired
......@@ -45,18 +46,23 @@ public class MemberProfileController {
return ResultInfo.success(MemberProfileService.queryAll(criteria));
}*/
@Log
@PostMapping(value = "/create")
@ApiOperation("新增MemberProfile")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> create ==>> resources ===>> [{}]",resources);
String realname = resources.getRealname();
MemberProfileService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping(value = "/update")
@ApiOperation("修改MemberProfile")
@AnonymousAccess
public ResultInfo update(@Validated @RequestBody MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
Long memberId = resources.getMemberId();
Assert.notNull(memberId,"memberId can't be null");
MemberDTO memberDTO = this.memberService.findById(memberId);
......@@ -77,8 +83,15 @@ public class MemberProfileController {
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改MemberProfile")
@AnonymousAccess
public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
this.MemberProfileService.updateMemberProfileAndMember(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除MemberProfile")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.member.profile.service;
package com.topdraw.business.module.member.profile.service;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......@@ -35,11 +35,15 @@ public interface MemberProfileService {
*/
MemberProfileDTO findById(Long id);
void create(MemberProfile resources);
MemberProfile create(MemberProfile resources);
MemberProfile createDefault(MemberProfile resources);
void update(MemberProfile resources);
void delete(Long id);
MemberProfileDTO findByMemberId(Long memberId);
void updateMemberProfileAndMember(MemberProfile resources);
}
......
package com.topdraw.business.basicdata.member.profile.service.dto;
package com.topdraw.business.module.member.profile.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......@@ -21,21 +21,30 @@ public class MemberProfileDTO implements Serializable {
// 姓名
private String realname;
private String nickname;
// 性别 0:女; 1:男 -1:未知
private Integer gender;
// 生日
private Timestamp birthday;
// 生日字符串
private String birthdayStr;
// vip
private Integer vip;
// 星座
private String constellation;
// 身份证
private String idCard;
private Long vipExpireTime;
// 电话
private String phone;
// 身份证
private String idCard;
// 电子邮件
private String email;
......@@ -48,6 +57,9 @@ public class MemberProfileDTO implements Serializable {
// 城市
private String city;
// 头像
private String avatarUrl;
// 区县
private String district;
......
package com.topdraw.business.basicdata.member.profile.service.impl;
package com.topdraw.business.module.member.profile.service.impl;
import cn.hutool.core.date.DateUtil;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.domain.MemberProfileBuild;
import com.topdraw.business.module.member.repository.MemberRepository;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.utils.StringUtils;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.member.profile.repository.MemberProfileRepository;
import com.topdraw.business.basicdata.member.profile.service.MemberProfileService;
import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria;
import com.topdraw.business.basicdata.member.profile.service.mapper.MemberProfileMapper;
import com.topdraw.business.module.member.profile.repository.MemberProfileRepository;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -21,6 +26,8 @@ import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.Optional;
......@@ -31,13 +38,19 @@ import java.util.Optional;
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@Slf4j
public class MemberProfileServiceImpl implements MemberProfileService {
@Autowired
private MemberProfileRepository MemberProfileRepository;
@Autowired
private MemberRepository memberRepository;
@Autowired
private MemberProfileMapper MemberProfileMapper;
@Autowired
private MemberService memberService;
@Override
......@@ -61,17 +74,35 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void create(MemberProfile resources) {
public MemberProfile create(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
MemberProfileRepository.save(resources);
return resources;
}
@Override
public MemberProfile createDefault(MemberProfile resources) {
Long memberId = resources.getMemberId();
String realname = resources.getRealname();
Integer gender = resources.getGender();
MemberProfile memberProfile = MemberProfileBuild.build();
MemberProfile memberProfile1 = this.MemberProfileRepository.save(memberProfile);
return memberProfile1;
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
MemberProfile MemberProfile = MemberProfileRepository.findById(resources.getId()).orElseGet(MemberProfile::new);
ValidationUtil.isNull( MemberProfile.getId(),"MemberProfile","id",resources.getId());
MemberProfile.copy(resources);
log.info("MemberProfileServiceImpl ==>> update ==>> copy ===>> resources ===>> [{}]",resources);
MemberProfileRepository.save(MemberProfile);
}
......@@ -95,5 +126,37 @@ public class MemberProfileServiceImpl implements MemberProfileService {
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMemberProfileAndMember(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources);
String realname = resources.getRealname();
String nickNameStr = "";
if (StringUtils.isNotBlank(realname)) {
byte[] encode = Base64.getEncoder().encode(realname.getBytes(StandardCharsets.UTF_8));
nickNameStr = new String(encode);
resources.setRealname(nickNameStr);
}
if (StringUtils.isNotBlank(resources.getIdCard())) {
resources.setIdCard("000000000000000000");
}
this.MemberProfileRepository.save(resources);
//修改member相关信息
Long memberId = resources.getMemberId();
Member member = memberRepository.findById(memberId).orElseGet(Member::new);
ValidationUtil.isNull(member.getId(),"member","id", memberId);
member.setNickname(nickNameStr);
member.setGender(resources.getGender());
member.setBirthday(DateUtil.format(resources.getBirthday(), "yyyy-MM-dd"));
member.setAvatarUrl(resources.getAvatarUrl());
// memberRepository.save(member);
log.info("updateMemberProfileAndMember ==>> member ==>> [{}]",member);
memberService.update(member);
}
}
......
package com.topdraw.business.basicdata.member.profile.service.mapper;
package com.topdraw.business.module.member.profile.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.member.relatedinfo.domain;
package com.topdraw.business.module.member.relatedinfo.domain;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
......@@ -28,6 +30,7 @@ public class MemberRelatedInfo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@NotNull(groups = {UpdateGroup.class})
private Long id;
// 会员id
......
package com.topdraw.business.module.member.relatedinfo.domain;
public interface UpdateGroup {
}
package com.topdraw.business.basicdata.member.relatedinfo.repository;
package com.topdraw.business.module.member.relatedinfo.repository;
import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.module.member.relatedinfo.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.relatedinfo.domain.UpdateGroup;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import com.topdraw.exception.BadRequestException;
import com.topdraw.util.Base64Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.util.Base64;
import java.util.Objects;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Slf4j
@Api(tags = "MemberRelatedInfo管理")
@RestController
@RequestMapping("/ucEngine/api/memberRelatedInfo")
@CrossOrigin
public class MemberRelatedInfoController {
@Autowired
private MemberRelatedInfoService MemberRelatedInfoService;
@Autowired
private MemberService memberService;
@GetMapping(value = "/pageMemberRelatedInfos")
@ApiOperation("查询MemberRelatedInfo")
public ResultInfo pageMemberRelatedInfos(@Validated MemberRelatedInfoQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(MemberRelatedInfoService.queryAll(criteria,pageable));
}
@PostMapping(value = "/create")
@ApiOperation("新增MemberRelatedInfo")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody MemberRelatedInfo resources) {
String name = resources.getName();
if (StringUtils.hasText(name)) {
String nickNameEncode = Base64Util.encode(name);
resources.setName(nickNameEncode);
}
MemberRelatedInfoService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改MemberRelatedInfo")
@AnonymousAccess
public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberRelatedInfo resources) {
log.info("Param ===> resources ===> [{}]",resources);
String name = resources.getName();
if (StringUtils.hasText(name)) {
String nickNameEncode = Base64Util.encode(name);
resources.setName(nickNameEncode);
}
Long id = resources.getId();
MemberRelatedInfoDTO memberRelatedInfoDTO = this.MemberRelatedInfoService.findById(id);
if (memberRelatedInfoDTO.getId() != null) {
Long memberId = memberRelatedInfoDTO.getMemberId();
if (Objects.isNull(memberId)) {
log.info("id ==>> [{}]",id);
throw new BadRequestException("memberId is null! please check member info");
}
MemberDTO memberDTO = this.memberService.findById(memberId);
if (Objects.nonNull(memberDTO)) {
String code = memberDTO.getCode();
Assert.notNull(code,"code can't be null");
resources.setMemberCode(code);
MemberRelatedInfoService.update(resources);
}
}
return ResultInfo.success();
}
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询指定MemberRelatedInfo")
public ResultInfo findById(@PathVariable("id") Long id) {
return ResultInfo.success(MemberRelatedInfoService.findById(id));
}
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除MemberRelatedInfo")
@AnonymousAccess
public ResultInfo delete(@PathVariable Long id) {
MemberRelatedInfoService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.basicdata.member.relatedinfo.service;
package com.topdraw.business.module.member.relatedinfo.service;
import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.member.relatedinfo.service.dto;
package com.topdraw.business.module.member.relatedinfo.service.dto;
import lombok.Data;
import javax.persistence.Column;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDate;
......
package com.topdraw.business.basicdata.member.relatedinfo.service.dto;
package com.topdraw.business.module.member.relatedinfo.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author XiangHan
* @date 2021-10-22
......
package com.topdraw.business.basicdata.member.relatedinfo.service.impl;
package com.topdraw.business.module.member.relatedinfo.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.member.relatedinfo.repository.MemberRelatedInfoRepository;
import com.topdraw.business.basicdata.member.relatedinfo.service.MemberRelatedInfoService;
import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import com.topdraw.business.basicdata.member.relatedinfo.service.mapper.MemberRelatedInfoMapper;
import com.topdraw.business.module.member.relatedinfo.repository.MemberRelatedInfoRepository;
import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import com.topdraw.business.module.member.relatedinfo.service.mapper.MemberRelatedInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......
package com.topdraw.business.basicdata.member.relatedinfo.service.mapper;
package com.topdraw.business.module.member.relatedinfo.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.member.repository;
package com.topdraw.business.module.member.repository;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.module.member.domain.Member;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
import java.util.Optional;
/**
......@@ -13,4 +14,6 @@ import java.util.Optional;
public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecificationExecutor<Member> {
Optional<Member> findFirstByCode(String code);
List<Member> findByUserIptvId(Long id);
}
......
package com.topdraw.business.basicdata.member.rest;
package com.topdraw.business.module.member.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.process.service.UserTvOperationService;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.util.Base64Util;
import io.swagger.annotations.Api;
......@@ -27,7 +25,7 @@ import java.util.Objects;
*/
@Api(tags = "Member管理")
@RestController
@RequestMapping("/api/member")
@RequestMapping("/ucEngine/api/member")
@CrossOrigin
public class MemberController {
......@@ -35,9 +33,8 @@ public class MemberController {
private MemberService memberService;
@Autowired
private UserTvOperationService userTvOperationService;
private UserOperationService userTvOperationService;
@Log
@GetMapping(value = "/findById/{id}")
@ApiOperation("新增UserTv会员")
public ResultInfo findById(@PathVariable Long id) {
......@@ -45,10 +42,8 @@ public class MemberController {
return ResultInfo.success(memberDTO);
}
@Log
@PostMapping(value = "/createMemberByUserTv")
@ApiOperation("新增UserTv会员")
@AnonymousAccess
public ResultInfo createMemberByUserTv(@Validated @RequestBody UserTv resources) {
String platformAccount = resources.getPlatformAccount();
Assert.notNull(platformAccount, "The given platformAccount must not be null!");
......@@ -56,15 +51,14 @@ public class MemberController {
return ResultInfo.success(result);
}
@Log
@PostMapping(value = "/create")
@ApiOperation("新增Member")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody Member resources) {
Long id = memberService.create(resources);
return ResultInfo.success(id);
}
@Log
@PostMapping(value = "/doUpdateVip")
@ApiOperation("修改Member等级")
public ResultInfo doUpdateVip(@RequestBody Member member) {
......@@ -72,9 +66,9 @@ public class MemberController {
return ResultInfo.success();
}
@Log
@PutMapping(value = "/update")
@ApiOperation("修改Member")
@AnonymousAccess
public ResultInfo update(@Validated @RequestBody Member resources) {
Long memberId = resources.getId();
Assert.notNull(memberId,"memberId can't be null");
......@@ -83,10 +77,6 @@ public class MemberController {
String code = memberDTO.getCode();
Assert.notNull(code, "code can't be null");
resources.setCode(code);
String nickname = resources.getNickname();
if (!StringUtils.isEmpty(nickname)) {
resources.setNickname(Base64Util.encode(nickname));
}
memberService.update(resources);
}
return ResultInfo.success();
......
package com.topdraw.business.basicdata.member.service;
package com.topdraw.business.module.member.service;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
......@@ -37,10 +39,28 @@ public interface MemberService {
*/
MemberDTO findById(Long id);
/**
*
* @param resources
* @return
*/
Long create(Member resources);
Member createAndReturnMember(Member resources);
/**
*
* @param resources
*/
void update(Member resources);
void unbind(Member resources);
/**
*
* @param id
*/
void delete(Long id);
/**
......@@ -50,5 +70,11 @@ public interface MemberService {
*/
MemberDTO getByCode(String code);
/**
*
* @param member
*/
void doUpdateMemberPoints(Member member);
List<MemberDTO> findByUserIptvId(Long id);
}
......
package com.topdraw.business.basicdata.member.service.dto;
package com.topdraw.business.module.member.service.dto;
import lombok.Data;
......@@ -14,6 +14,11 @@ import java.time.LocalDateTime;
@Data
public class MemberDTO implements Serializable {
private String platformAccount;
// iptv绑定的主会员 0:否 1:是
private Integer iptvMajor;
// vip过期时间
private LocalDateTime vipExpireTime;
......@@ -78,13 +83,13 @@ public class MemberDTO implements Serializable {
private Integer bindIptvPlatformType;
// iptv账号绑定时间
private Timestamp bindIptvTime;
private LocalDateTime bindIptvTime;
// 创建时间
private Timestamp createTime;
private LocalDateTime createTime;
// 更新时间
private Timestamp updateTime;
private LocalDateTime updateTime;
// 是否在黑名单 1:是;0否
private Long blackStatus;
......
package com.topdraw.business.basicdata.member.service.dto;
package com.topdraw.business.module.member.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
......
package com.topdraw.business.basicdata.member.service.impl;
package com.topdraw.business.module.member.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.repository.MemberRepository;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria;
import com.topdraw.business.basicdata.member.service.mapper.MemberMapper;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.LocalConstants;
import com.topdraw.mq.config.RabbitMqConfig;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.repository.MemberRepository;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
import com.topdraw.business.module.member.service.mapper.MemberMapper;
import com.topdraw.util.IdWorker;
import com.topdraw.util.RedissonUtil;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
......@@ -23,21 +16,15 @@ import com.topdraw.utils.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.util.Assert;
import java.nio.charset.StandardCharsets;
......@@ -65,7 +52,7 @@ public class MemberServiceImpl implements MemberService {
PlatformTransactionManager platformTransactionManager;
@Autowired
private com.topdraw.business.basicdata.user.iptv.service.UserTvService UserTvService;
private com.topdraw.business.module.user.iptv.service.UserTvService UserTvService;
@Override
public Map<String, Object> queryAll(MemberQueryCriteria criteria, Pageable pageable) {
......@@ -80,7 +67,6 @@ public class MemberServiceImpl implements MemberService {
}
@Override
// @Cacheable(value = "member::memberId",key = "#p0")
public MemberDTO findById(Long id) {
Member member = memberRepository.findById(id).orElseGet(Member::new);
ValidationUtil.isNull(member.getId(),"Member","id",id);
......@@ -92,12 +78,20 @@ public class MemberServiceImpl implements MemberService {
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public Long create(Member resources) {
log.info("start=====>>>>>resources======>>>>接收到的数据 --->>>> " + resources);
Member member = this.checkMemberData(resources);
memberRepository.save(member);
return member.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public Member createAndReturnMember(Member resources) {
Member member = this.checkMemberData(resources);
memberRepository.save(member);
return resources;
}
private Member checkMemberData(Member member) {
Long defaultValue = 0L;
String code = member.getCode();
......@@ -119,18 +113,16 @@ public class MemberServiceImpl implements MemberService {
member.setDueCouponAmount(defaultValue);
member.setBlackStatus(0L);
String nickname = member.getNickname();
if (StringUtils.isEmpty(nickname)) {
nickname = "未设置";
}
if (StringUtils.isNotEmpty(nickname)) {
String base64Nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8)));
member.setNickname(base64Nickname);
}
return member;
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
@CacheEvict(value = "member::memberId",key = "#p0.id")
public void update(Member resources) {
RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
try {
......@@ -147,6 +139,25 @@ public class MemberServiceImpl implements MemberService {
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void unbind(Member resources) {
RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
try {
RedissonUtil.lock(rLock);
Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new);
ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId());
member.copy(resources);
this.save(member);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
private void save(Member member){
memberRepository.save(member);
}
......@@ -178,6 +189,7 @@ public class MemberServiceImpl implements MemberService {
}
@Override
@AsyncMqSend()
public void doUpdateMemberPoints(Member resources) {
RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
try {
......@@ -194,5 +206,11 @@ public class MemberServiceImpl implements MemberService {
}
}
@Override
public List<MemberDTO> findByUserIptvId(Long id) {
List<Member> memberList = this.memberRepository.findByUserIptvId(id);
return memberMapper.toDto(memberList);
}
}
......
package com.topdraw.business.basicdata.member.service.mapper;
package com.topdraw.business.module.member.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.module.member.viphistory.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
/**
* @author luerlong
* @date 2021-12-10
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_member_vip_history")
public class MemberVipHistory implements Serializable {
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 会员id
@Column(name = "member_id")
private Long memberId;
// 会员vip等级
@Column(name = "vip")
private Integer vip;
// 修改之前vip等级
@Column(name = "before_vip")
private Integer beforeVip;
// vip失效时间
@Column(name = "vip_expire_time")
private LocalDateTime vipExpireTime;
// 状态 1正常 0已过期
@Column(name = "status")
private Integer status;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 修改时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(MemberVipHistory source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.member.viphistory.repository;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.time.LocalDateTime;
import java.util.Optional;
/**
* @author luerlong
* @date 2021-12-10
*/
public interface MemberVipHistoryRepository extends JpaRepository<MemberVipHistory, Long>, JpaSpecificationExecutor<MemberVipHistory> {
@Query(value = "SELECT * FROM uc_member_vip_history " +
" WHERE vip_expire_time >= ?2 AND member_id = ?1 order by create_time desc limit 1 ", nativeQuery = true)
Optional<MemberVipHistory> findByTime(Long memberId, LocalDateTime nowTime);
}
package com.topdraw.business.module.member.viphistory.rest;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author luerlong
* @date 2021-12-10
*/
@Api(tags = "MemberVipHistory管理")
@RestController
@RequestMapping("/api/memberVipHistory")
public class MemberVipHistoryController {
@Autowired
private MemberVipHistoryService memberVipHistoryService;
@GetMapping
@ApiOperation("查询MemberVipHistory")
public ResultInfo getMemberVipHistorys(MemberVipHistoryQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(memberVipHistoryService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有MemberVipHistory")
public ResultInfo getMemberVipHistorys(MemberVipHistoryQueryCriteria criteria) {
return ResultInfo.success(memberVipHistoryService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增MemberVipHistory")
public ResultInfo create(@Validated @RequestBody MemberVipHistory resources) {
memberVipHistoryService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改MemberVipHistory")
public ResultInfo update(@Validated @RequestBody MemberVipHistory resources) {
memberVipHistoryService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除MemberVipHistory")
public ResultInfo delete(@PathVariable Long id) {
memberVipHistoryService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.member.viphistory.service;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @author luerlong
* @date 2021-12-10
*/
public interface MemberVipHistoryService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(MemberVipHistoryQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<MemberVipHistoryDTO>
*/
List<MemberVipHistoryDTO> queryAll(MemberVipHistoryQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return MemberVipHistoryDTO
*/
MemberVipHistoryDTO findById(Long id);
void create(MemberVipHistory resources);
void update(MemberVipHistory resources);
void delete(Long id);
MemberVipHistory findByTime(Long id, LocalDateTime nowTime);
}
package com.topdraw.business.module.member.viphistory.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
/**
* @author luerlong
* @date 2021-12-10
*/
@Data
public class MemberVipHistoryDTO implements Serializable {
// 主键
private Long id;
// 会员id
private Long memberId;
// 会员vip等级
private Integer vip;
// 修改之前vip等级
private Integer beforeVip;
// vip失效时间
private LocalDateTime vipExpireTime;
// 状态 1正常 0已过期
private Integer status;
// 创建时间
private Timestamp createTime;
// 修改时间
private Timestamp updateTime;
}
package com.topdraw.business.module.member.viphistory.service.dto;
import lombok.Data;
/**
* @author luerlong
* @date 2021-12-10
*/
@Data
public class MemberVipHistoryQueryCriteria {
}
package com.topdraw.business.module.member.viphistory.service.impl;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
import com.topdraw.business.module.member.viphistory.service.mapper.MemberVipHistoryMapper;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @author luerlong
* @date 2021-12-10
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
@Autowired
private MemberVipHistoryRepository memberVipHistoryRepository;
@Autowired
private MemberVipHistoryMapper memberVipHistoryMapper;
@Override
public Map<String, Object> queryAll(MemberVipHistoryQueryCriteria criteria, Pageable pageable) {
Page<MemberVipHistory> page = memberVipHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(memberVipHistoryMapper::toDto));
}
@Override
public List<MemberVipHistoryDTO> queryAll(MemberVipHistoryQueryCriteria criteria) {
return memberVipHistoryMapper.toDto(memberVipHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public MemberVipHistoryDTO findById(Long id) {
MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseGet(MemberVipHistory::new);
ValidationUtil.isNull(memberVipHistory.getId(),"MemberVipHistory","id",id);
return memberVipHistoryMapper.toDto(memberVipHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(MemberVipHistory resources) {
memberVipHistoryRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(MemberVipHistory resources) {
MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(resources.getId()).orElseGet(MemberVipHistory::new);
ValidationUtil.isNull( memberVipHistory.getId(),"MemberVipHistory","id",resources.getId());
memberVipHistory.copy(resources);
memberVipHistoryRepository.save(memberVipHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberVipHistory.class, id), 1));
memberVipHistoryRepository.delete(memberVipHistory);
}
@Override
public MemberVipHistory findByTime(Long memberId, LocalDateTime nowTime) {
MemberVipHistory memberVipHistory = this.memberVipHistoryRepository.findByTime(memberId, nowTime).orElseGet(MemberVipHistory::new);
return memberVipHistory;
}
}
package com.topdraw.business.module.member.viphistory.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author luerlong
* @date 2021-12-10
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MemberVipHistoryMapper extends BaseMapper<MemberVipHistoryDTO, MemberVipHistory> {
}
package com.topdraw.business.basicdata.points.available.domain;
package com.topdraw.business.module.points.available.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
......@@ -11,7 +11,6 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.UUID;
import java.io.Serializable;
......@@ -26,11 +25,7 @@ import java.io.Serializable;
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_points_available")
public class PointsAvailable implements Serializable {
/** 会员编号 */
@Transient
private String memberCode;
public class PointsAvailable extends DefaultAsyncMqModule implements Serializable {
// 主键
@Id
......
package com.topdraw.business.basicdata.points.available.repository;
package com.topdraw.business.module.points.available.repository;
import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
......
package com.topdraw.business.basicdata.points.available.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
package com.topdraw.business.module.points.available.rest;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.points.available.service;
package com.topdraw.business.module.points.available.service;
import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.points.available.service.dto;
package com.topdraw.business.module.points.available.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.points.available.service.dto;
package com.topdraw.business.module.points.available.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
......
package com.topdraw.business.basicdata.points.available.service.dto;
package com.topdraw.business.module.points.available.service.dto;
public enum PointsAvailableQueryType {
......
package com.topdraw.business.basicdata.points.available.service.impl;
package com.topdraw.business.module.points.available.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.util.RedissonUtil;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.points.available.repository.PointsAvailableRepository;
import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.basicdata.points.available.service.mapper.PointsAvailableMapper;
import com.topdraw.business.module.points.available.repository.PointsAvailableRepository;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.module.points.available.service.mapper.PointsAvailableMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,11 +23,8 @@ import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.points.available.service.mapper;
package com.topdraw.business.module.points.available.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.points.detail.detailhistory.domain;
package com.topdraw.business.module.points.detail.detailhistory.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.points.detail.detailhistory.repository;
package com.topdraw.business.module.points.detail.detailhistory.repository;
import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.points.detail.detailhistory.rest;
package com.topdraw.business.module.points.detail.detailhistory.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.PointsDetailHistoryService;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
......
package com.topdraw.business.basicdata.points.detail.detailhistory.service;
package com.topdraw.business.module.points.detail.detailhistory.service;
import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.points.detail.detailhistory.service.dto;
package com.topdraw.business.module.points.detail.detailhistory.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.points.detail.detailhistory.service.impl;
package com.topdraw.business.module.points.detail.detailhistory.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.points.detail.detailhistory.repository.PointsDetailHistoryRepository;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.PointsDetailHistoryService;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.mapper.PointsDetailHistoryMapper;
import com.topdraw.business.module.points.detail.detailhistory.repository.PointsDetailHistoryRepository;
import com.topdraw.business.module.points.detail.detailhistory.service.PointsDetailHistoryService;
import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria;
import com.topdraw.business.module.points.detail.detailhistory.service.mapper.PointsDetailHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......
package com.topdraw.business.basicdata.points.detail.detailhistory.service.mapper;
package com.topdraw.business.module.points.detail.detailhistory.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory;
import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.points.detail.domain;
package com.topdraw.business.module.points.detail.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.points.detail.repository;
package com.topdraw.business.module.points.detail.repository;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Date;
import java.util.List;
import java.util.Optional;
......
package com.topdraw.business.basicdata.points.detail.rest;
package com.topdraw.business.module.points.detail.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.basicdata.points.detail.service.PointsDetailService;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
......
package com.topdraw.business.basicdata.points.detail.service;
package com.topdraw.business.module.points.detail.service;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailDTO;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO;
import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Date;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.points.detail.service.dto;
package com.topdraw.business.module.points.detail.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.points.detail.service.dto;
package com.topdraw.business.module.points.detail.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
......
package com.topdraw.business.basicdata.points.detail.service.impl;
package com.topdraw.business.module.points.detail.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.points.detail.repository.PointsDetailRepository;
import com.topdraw.business.basicdata.points.detail.service.PointsDetailService;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailDTO;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
import com.topdraw.business.basicdata.points.detail.service.mapper.PointsDetailMapper;
import com.topdraw.business.module.points.detail.repository.PointsDetailRepository;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO;
import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria;
import com.topdraw.business.module.points.detail.service.mapper.PointsDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -20,7 +20,6 @@ import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......
package com.topdraw.business.basicdata.points.detail.service.mapper;
package com.topdraw.business.module.points.detail.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailDTO;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.points.domain;
package com.topdraw.business.module.points.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.points.repository;
package com.topdraw.business.module.points.repository;
import com.topdraw.business.basicdata.points.domain.Points;
import com.topdraw.business.module.points.domain.Points;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.points.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.points.domain.Points;
import com.topdraw.business.basicdata.points.service.PointsService;
import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
package com.topdraw.business.module.points.rest;
import io.swagger.annotations.*;
/**
......
package com.topdraw.business.basicdata.points.service;
package com.topdraw.business.module.points.service;
import com.topdraw.business.basicdata.points.domain.Points;
import com.topdraw.business.basicdata.points.service.dto.PointsDTO;
import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria;
import com.topdraw.business.module.points.domain.Points;
import com.topdraw.business.module.points.service.dto.PointsDTO;
import com.topdraw.business.module.points.service.dto.PointsQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.points.service.dto;
package com.topdraw.business.module.points.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.points.service.impl;
package com.topdraw.business.module.points.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.points.domain.Points;
import com.topdraw.business.module.points.domain.Points;
import com.topdraw.util.RedissonUtil;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.points.repository.PointsRepository;
import com.topdraw.business.basicdata.points.service.PointsService;
import com.topdraw.business.basicdata.points.service.dto.PointsDTO;
import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria;
import com.topdraw.business.basicdata.points.service.mapper.PointsMapper;
import com.topdraw.business.module.points.repository.PointsRepository;
import com.topdraw.business.module.points.service.PointsService;
import com.topdraw.business.module.points.service.dto.PointsDTO;
import com.topdraw.business.module.points.service.dto.PointsQueryCriteria;
import com.topdraw.business.module.points.service.mapper.PointsMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.business.basicdata.points.service.mapper;
package com.topdraw.business.module.points.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.points.domain.Points;
import com.topdraw.business.basicdata.points.service.dto.PointsDTO;
import com.topdraw.business.module.points.domain.Points;
import com.topdraw.business.module.points.service.dto.PointsDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.points.standingbook.domain;
package com.topdraw.business.module.points.standingbook.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.points.standingbook.repository;
package com.topdraw.business.module.points.standingbook.repository;
import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Optional;
/**
* @author XiangHan
* @date 2021-10-29
......
package com.topdraw.business.basicdata.points.standingbook.rest;
package com.topdraw.business.module.points.standingbook.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.basicdata.points.standingbook.service.PointsStandingBookService;
import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.service.PointsStandingBookService;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -39,7 +34,6 @@ public class PointsStandingBookController {
return ResultInfo.success(PointsStandingBookService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增PointsStandingBook")
public ResultInfo create(@Validated @RequestBody PointsStandingBook resources) {
......@@ -47,7 +41,6 @@ public class PointsStandingBookController {
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改PointsStandingBook")
public ResultInfo update(@Validated @RequestBody PointsStandingBook resources) {
......@@ -55,8 +48,6 @@ public class PointsStandingBookController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除PointsStandingBook")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.points.standingbook.service;
package com.topdraw.business.module.points.standingbook.service;
import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookDTO;
import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.points.standingbook.service.dto;
package com.topdraw.business.module.points.standingbook.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.points.standingbook.service.dto;
package com.topdraw.business.module.points.standingbook.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.points.standingbook.service.impl;
package com.topdraw.business.module.points.standingbook.service.impl;
import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.utils.FileUtil;
import com.topdraw.business.basicdata.points.standingbook.repository.PointsStandingBookRepository;
import com.topdraw.business.basicdata.points.standingbook.service.PointsStandingBookService;
import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookDTO;
import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import com.topdraw.business.basicdata.points.standingbook.service.mapper.PointsStandingBookMapper;
import com.topdraw.business.module.points.standingbook.repository.PointsStandingBookRepository;
import com.topdraw.business.module.points.standingbook.service.PointsStandingBookService;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria;
import com.topdraw.business.module.points.standingbook.service.mapper.PointsStandingBookMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.points.standingbook.service.mapper;
package com.topdraw.business.module.points.standingbook.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.basicdata.points.standingbook.service.dto.PointsStandingBookDTO;
import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.rights.domain;
package com.topdraw.business.module.rights.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.rights.history.domain;
package com.topdraw.business.module.rights.history.domain;
import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
......@@ -22,7 +23,7 @@ import java.time.LocalDateTime;
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="tr_rights_histroy")
public class RightsHistory implements Serializable {
public class RightsHistory extends DefaultAsyncMqModule implements Serializable {
// 主键id
@Id
......
package com.topdraw.business.basicdata.rights.history.repository;
package com.topdraw.business.module.rights.history.repository;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.rights.history.rest;
package com.topdraw.business.module.rights.history.rest;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryType;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.business.module.rights.history.service.RightsHistoryService;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.util.TimestampUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
......
package com.topdraw.business.basicdata.rights.history.service;
package com.topdraw.business.module.rights.history.service;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryDTO;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.rights.history.service.dto;
package com.topdraw.business.module.rights.history.service.dto;
import lombok.Data;
import javax.persistence.Column;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;
......
package com.topdraw.business.basicdata.rights.history.service.dto;
package com.topdraw.business.module.rights.history.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
......
package com.topdraw.business.basicdata.rights.history.service.dto;
package com.topdraw.business.module.rights.history.service.dto;
public enum RightsHistoryQueryType {
......
package com.topdraw.business.basicdata.rights.history.service.impl;
package com.topdraw.business.module.rights.history.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.rights.history.repository.RightsHistoryRepository;
import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryDTO;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.business.basicdata.rights.history.service.mapper.RightsHistoryMapper;
import com.topdraw.business.module.rights.history.repository.RightsHistoryRepository;
import com.topdraw.business.module.rights.history.service.RightsHistoryService;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.business.module.rights.history.service.mapper.RightsHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -66,7 +66,7 @@ public class RightsHistoryServiceImpl implements RightsHistoryService {
@AsyncMqSend()
public void update(RightsHistory resources) {
RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new);
ValidationUtil.isNull( RightsHistory.getId(),"RightsHistory","id",resources.getId());
ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",resources.getId());
RightsHistory.copy(resources);
RightsHistoryRepository.save(RightsHistory);
}
......
package com.topdraw.business.basicdata.rights.history.service.mapper;
package com.topdraw.business.module.rights.history.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryDTO;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.rights.permanentrights.domain;
package com.topdraw.business.module.rights.permanentrights.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.rights.permanentrights.repository;
package com.topdraw.business.module.rights.permanentrights.repository;
import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.rights.permanentrights.rest;
package com.topdraw.business.module.rights.permanentrights.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
......@@ -35,7 +34,6 @@ public class PermanentRightsController {
return ResultInfo.success(PermanentRightsService.findById(id));
}
@Log
@PostMapping(value = "/create")
@ApiOperation("新增PermanentRights")
public ResultInfo create(@Validated @RequestBody PermanentRights resources) {
......@@ -43,7 +41,6 @@ public class PermanentRightsController {
return ResultInfo.success();
}
@Log
@PutMapping(value = "/update")
@ApiOperation("修改PermanentRights")
public ResultInfo update(@Validated @RequestBody PermanentRights resources) {
......@@ -51,7 +48,6 @@ public class PermanentRightsController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除PermanentRights")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.rights.permanentrights.service;
package com.topdraw.business.module.rights.permanentrights.service;
import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.rights.permanentrights.service.dto;
package com.topdraw.business.module.rights.permanentrights.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.rights.permanentrights.service.dto;
package com.topdraw.business.module.rights.permanentrights.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
......
package com.topdraw.business.basicdata.rights.permanentrights.service.impl;
package com.topdraw.business.module.rights.permanentrights.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.rights.permanentrights.repository.PermanentRightsRepository;
import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.business.basicdata.rights.permanentrights.service.mapper.PermanentRightsMapper;
import com.topdraw.business.module.rights.permanentrights.repository.PermanentRightsRepository;
import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.business.module.rights.permanentrights.service.mapper.PermanentRightsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......
package com.topdraw.business.basicdata.rights.permanentrights.service.mapper;
package com.topdraw.business.module.rights.permanentrights.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.rights.repository;
package com.topdraw.business.module.rights.repository;
import com.topdraw.business.basicdata.rights.domain.Rights;
import com.topdraw.business.basicdata.rights.service.dto.RightsDTO;
import com.topdraw.business.module.rights.domain.Rights;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
......
package com.topdraw.business.basicdata.rights.rest;
package com.topdraw.business.module.rights.rest;
import com.topdraw.business.basicdata.rights.service.RightsService;
import com.topdraw.business.basicdata.rights.service.dto.RightsQueryCriteria;
import com.topdraw.business.module.rights.service.RightsService;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
......
package com.topdraw.business.basicdata.rights.service;
package com.topdraw.business.module.rights.service;
import com.topdraw.business.basicdata.rights.domain.Rights;
import com.topdraw.business.basicdata.rights.service.dto.RightsDTO;
import com.topdraw.business.basicdata.rights.service.dto.RightsQueryCriteria;
import com.topdraw.business.module.rights.domain.Rights;
import com.topdraw.business.module.rights.service.dto.RightsDTO;
import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.rights.service.dto;
package com.topdraw.business.module.rights.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.rights.service.dto;
package com.topdraw.business.module.rights.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
......
package com.topdraw.business.basicdata.rights.service.impl;
package com.topdraw.business.module.rights.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.rights.domain.Rights;
import com.topdraw.business.module.rights.domain.Rights;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.rights.repository.RightsRepository;
import com.topdraw.business.basicdata.rights.service.RightsService;
import com.topdraw.business.basicdata.rights.service.dto.RightsDTO;
import com.topdraw.business.basicdata.rights.service.dto.RightsQueryCriteria;
import com.topdraw.business.basicdata.rights.service.mapper.RightsMapper;
import com.topdraw.business.module.rights.repository.RightsRepository;
import com.topdraw.business.module.rights.service.RightsService;
import com.topdraw.business.module.rights.service.dto.RightsDTO;
import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria;
import com.topdraw.business.module.rights.service.mapper.RightsMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.business.basicdata.rights.service.mapper;
package com.topdraw.business.module.rights.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.rights.domain.Rights;
import com.topdraw.business.basicdata.rights.service.dto.RightsDTO;
import com.topdraw.business.module.rights.domain.Rights;
import com.topdraw.business.module.rights.service.dto.RightsDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.module.task.attribute.domain;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="tr_task_attr")
public class TaskAttr implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 任务id(关联task主键)
@Column(name = "task_id")
private Long taskId;
// 任务属性字符串
@Column(name = "attr_str")
private String attrStr;
public void copy(TaskAttr source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.basicdata.user.weixin.repository;
package com.topdraw.business.module.task.attribute.repository;
import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......@@ -8,8 +8,9 @@ import java.util.Optional;
/**
* @author XiangHan
* @date 2021-12-16
* @date 2022-01-13
*/
public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, JpaSpecificationExecutor<UserWeixin> {
public interface TaskAttrRepository extends JpaRepository<TaskAttr, Long>, JpaSpecificationExecutor<TaskAttr> {
Optional<TaskAttr> findByTaskId(Long taskId);
}
......
package com.topdraw.business.module.task.attribute.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.business.module.task.attribute.service.TaskAttrService;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Api(tags = "TaskAttr管理")
@RestController
@RequestMapping("/api/TaskAttr")
public class TaskAttrController {
@Autowired
private TaskAttrService TaskAttrService;
@GetMapping
@ApiOperation("查询TaskAttr")
public ResultInfo getTaskAttrs(TaskAttrQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(TaskAttrService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有TaskAttr")
public ResultInfo getTaskAttrs(TaskAttrQueryCriteria criteria) {
return ResultInfo.success(TaskAttrService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增TaskAttr")
public ResultInfo create(@Validated @RequestBody TaskAttr resources) {
TaskAttrService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改TaskAttr")
public ResultInfo update(@Validated @RequestBody TaskAttr resources) {
TaskAttrService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除TaskAttr")
public ResultInfo delete(@PathVariable Long id) {
TaskAttrService.delete(id);
return ResultInfo.success();
}
}
package com.topdraw.business.module.task.attribute.service;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
* @date 2022-01-13
*/
public interface TaskAttrService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TaskAttrQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TaskAttrDTO>
*/
List<TaskAttrDTO> queryAll(TaskAttrQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TaskAttrDTO
*/
TaskAttrDTO findById(Long id);
void create(TaskAttr resources);
void update(TaskAttr resources);
void delete(Long id);
TaskAttrDTO findByTaskId(Long taskId);
}
package com.topdraw.business.module.task.attribute.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Data
public class TaskAttrDTO implements Serializable {
private Long id;
// 任务id(关联task主键)
private Long taskId;
// 任务属性字符串
private String attrStr;
}
package com.topdraw.business.module.task.attribute.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Data
public class TaskAttrQueryCriteria{
}
package com.topdraw.business.module.task.attribute.service.impl;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.utils.FileUtil;
import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository;
import com.topdraw.business.module.task.attribute.service.TaskAttrService;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrQueryCriteria;
import com.topdraw.business.module.task.attribute.service.mapper.TaskAttrMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class TaskAttrServiceImpl implements TaskAttrService {
@Autowired
private TaskAttrRepository TaskAttrRepository;
@Autowired
private TaskAttrMapper TaskAttrMapper;
@Override
public Map<String, Object> queryAll(TaskAttrQueryCriteria criteria, Pageable pageable) {
Page<TaskAttr> page = TaskAttrRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(TaskAttrMapper::toDto));
}
@Override
public List<TaskAttrDTO> queryAll(TaskAttrQueryCriteria criteria) {
return TaskAttrMapper.toDto(TaskAttrRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public TaskAttrDTO findById(Long id) {
TaskAttr TaskAttr = TaskAttrRepository.findById(id).orElseGet(TaskAttr::new);
ValidationUtil.isNull(TaskAttr.getId(),"TaskAttr","id",id);
return TaskAttrMapper.toDto(TaskAttr);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(TaskAttr resources) {
TaskAttrRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TaskAttr resources) {
TaskAttr TaskAttr = TaskAttrRepository.findById(resources.getId()).orElseGet(TaskAttr::new);
ValidationUtil.isNull( TaskAttr.getId(),"TaskAttr","id",resources.getId());
TaskAttr.copy(resources);
TaskAttrRepository.save(TaskAttr);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
TaskAttr TaskAttr = TaskAttrRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", TaskAttr.class, id), 1));
TaskAttrRepository.delete(TaskAttr);
}
@Override
public TaskAttrDTO findByTaskId(Long taskId) {
TaskAttr TaskAttr = TaskAttrRepository.findByTaskId(taskId).orElseGet(TaskAttr::new);
return TaskAttrMapper.toDto(TaskAttr);
}
}
package com.topdraw.business.module.task.attribute.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TaskAttrMapper extends BaseMapper<TaskAttrDTO, TaskAttr> {
}
package com.topdraw.business.basicdata.task.domain;
package com.topdraw.business.module.task.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.task.progress.domain;
package com.topdraw.business.module.task.progress.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
......
package com.topdraw.business.basicdata.task.progress.repository;
package com.topdraw.business.module.task.progress.repository;
import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Optional;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.task.progress.rest;
package com.topdraw.business.module.task.progress.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress;
import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -39,7 +34,6 @@ public class TrTaskProgressController {
return ResultInfo.success(TrTaskProgressService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增TrTaskProgress")
public ResultInfo create(@Validated @RequestBody TrTaskProgress resources) {
......@@ -47,7 +41,6 @@ public class TrTaskProgressController {
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改TrTaskProgress")
public ResultInfo update(@Validated @RequestBody TrTaskProgress resources) {
......@@ -55,8 +48,6 @@ public class TrTaskProgressController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除TrTaskProgress")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.task.progress.service;
package com.topdraw.business.module.task.progress.service;
import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.task.progress.service.dto;
package com.topdraw.business.module.task.progress.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.task.progress.service.dto;
package com.topdraw.business.module.task.progress.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2021-11-02
......
package com.topdraw.business.basicdata.task.progress.service.impl;
package com.topdraw.business.module.task.progress.service.impl;
import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.utils.FileUtil;
import com.topdraw.business.basicdata.task.progress.repository.TrTaskProgressRepository;
import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.basicdata.task.progress.service.mapper.TrTaskProgressMapper;
import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository;
import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -18,14 +17,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.task.progress.service.mapper;
package com.topdraw.business.module.task.progress.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.task.repository;
package com.topdraw.business.module.task.repository;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.business.module.task.domain.Task;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......
package com.topdraw.business.basicdata.task.rest;
package com.topdraw.business.module.task.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.business.basicdata.task.service.TaskService;
import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
......@@ -35,7 +34,6 @@ public class TaskController {
return ResultInfo.success(TaskService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增Task")
public ResultInfo create(@Validated @RequestBody Task resources) {
......@@ -43,7 +41,6 @@ public class TaskController {
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改Task")
public ResultInfo update(@Validated @RequestBody Task resources) {
......@@ -51,8 +48,6 @@ public class TaskController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除Task")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.task.service;
package com.topdraw.business.module.task.service;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.business.basicdata.task.service.dto.TaskDTO;
import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.dto.TaskDTO;
import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......
package com.topdraw.business.basicdata.task.service.dto;
package com.topdraw.business.module.task.service.dto;
import lombok.Data;
import javax.persistence.Column;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;
......
package com.topdraw.business.basicdata.task.service.impl;
package com.topdraw.business.module.task.service.impl;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.utils.StringUtils;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.task.repository.TaskRepository;
import com.topdraw.business.basicdata.task.service.TaskService;
import com.topdraw.business.basicdata.task.service.dto.TaskDTO;
import com.topdraw.business.basicdata.task.service.dto.TaskQueryCriteria;
import com.topdraw.business.basicdata.task.service.mapper.TaskMapper;
import com.topdraw.business.module.task.repository.TaskRepository;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.service.dto.TaskDTO;
import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
import com.topdraw.business.module.task.service.mapper.TaskMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......
package com.topdraw.business.basicdata.task.service.mapper;
package com.topdraw.business.module.task.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.business.basicdata.task.service.dto.TaskDTO;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.dto.TaskDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.basicdata.task.template.domain;
package com.topdraw.business.module.task.template.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......
package com.topdraw.business.basicdata.task.template.repository;
package com.topdraw.business.module.task.template.repository;
import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
import java.util.Optional;
/**
......@@ -16,5 +17,5 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long
TaskTemplate findByEvent(String event);
TaskTemplate findByType(Integer event);
List<TaskTemplate> findByType(Integer event);
}
......
package com.topdraw.business.basicdata.task.template.rest;
package com.topdraw.business.module.task.template.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
import com.topdraw.business.basicdata.task.template.service.TaskTemplateService;
import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.service.TaskTemplateService;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
......@@ -35,7 +34,6 @@ public class TaskTemplateController {
return ResultInfo.success(TaskTemplateService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增TaskTemplate")
public ResultInfo create(@Validated @RequestBody TaskTemplate resources) {
......@@ -43,7 +41,6 @@ public class TaskTemplateController {
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改TaskTemplate")
public ResultInfo update(@Validated @RequestBody TaskTemplate resources) {
......@@ -51,8 +48,6 @@ public class TaskTemplateController {
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除TaskTemplate")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.task.template.service;
package com.topdraw.business.module.task.template.service;
import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO;
import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
......@@ -50,5 +50,5 @@ public interface TaskTemplateService {
TaskTemplate findByEvent(String event);
TaskTemplate findByType(Integer event);
List<TaskTemplate> findByType(Integer event);
}
......
package com.topdraw.business.basicdata.task.template.service.dto;
package com.topdraw.business.module.task.template.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......
package com.topdraw.business.basicdata.task.template.service.impl;
package com.topdraw.business.module.task.template.service.impl;
import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.task.template.repository.TaskTemplateRepository;
import com.topdraw.business.basicdata.task.template.service.TaskTemplateService;
import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO;
import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateQueryCriteria;
import com.topdraw.business.basicdata.task.template.service.mapper.TaskTemplateMapper;
import com.topdraw.business.module.task.template.repository.TaskTemplateRepository;
import com.topdraw.business.module.task.template.service.TaskTemplateService;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria;
import com.topdraw.business.module.task.template.service.mapper.TaskTemplateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -95,7 +94,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService {
// @Cacheable(cacheNames = "uc-admin_taskTemplate" , key = "#event")
@Override
public TaskTemplate findByType(Integer event) {
public List<TaskTemplate> findByType(Integer event) {
return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null;
}
}
......
package com.topdraw.business.basicdata.task.template.service.mapper;
package com.topdraw.business.module.task.template.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
import com.topdraw.business.basicdata.task.template.service.dto.TaskTemplateDTO;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.module.user.iptv.domain;
import java.util.Arrays;
import java.util.List;
public interface UserConstant {
// 电信
List<String> platform_lt = Arrays.asList("SC.CTCC","SC.CTC","CTC.ChongQing","ChongQing.CTC","CQ.CTC","CQ.CTCC");
// 移动
List<String> platform_yd = Arrays.asList("SC.CMCC","CMCC.SC","ChongQing.CMCC","CMCC.ChongQing");
// 联通
List<String> platform_dx = Arrays.asList("SC.CUCC","");
}
package com.topdraw.business.basicdata.user.iptv.domain;
package com.topdraw.business.module.user.iptv.domain;
import lombok.Data;
import lombok.experimental.Accessors;
......@@ -23,6 +23,10 @@ import java.io.Serializable;
@Table(name="uc_user_tv")
public class UserTv implements Serializable {
/** 绑定的小屏账户会员编码 */
@Column(name = "priority_member_code")
private String priorityMemberCode;
@Transient
private String memberCode;
......@@ -119,6 +123,6 @@ public class UserTv implements Serializable {
private Long memberId;
public void copy(UserTv source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
}
}
......
package com.topdraw.business.basicdata.user.iptv.repository;
package com.topdraw.business.module.user.iptv.repository;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......@@ -13,4 +13,8 @@ import java.util.Optional;
public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecificationExecutor<UserTv> {
Optional<UserTv> findByPlatformAccount(String platformAccount);
Optional<UserTv> findByPriorityMemberCode(String memberCode);
Optional<UserTv> findByMemberId(Long memberId);
}
......
package com.topdraw.business.basicdata.user.iptv.rest;
package com.topdraw.business.module.user.iptv.rest;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -26,7 +17,7 @@ import javax.servlet.http.HttpServletResponse;
*/
@Api(tags = "UserTv管理")
@RestController
@RequestMapping("/api/UserTv")
@RequestMapping("/ucEngine/api/userTv")
public class UserTvController {
@Autowired
......@@ -44,23 +35,22 @@ public class UserTvController {
return ResultInfo.success(UserTvService.queryAll(criteria));
}
@Log
@PostMapping
@PostMapping(value = "/create")
@ApiOperation("新增UserTv")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody UserTv resources) {
UserTvService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改UserTv")
@AnonymousAccess
public ResultInfo update(@Validated @RequestBody UserTv resources) {
UserTvService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除UserTv")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.user.iptv.service;
package com.topdraw.business.module.user.iptv.service;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -41,9 +42,13 @@ public interface UserTvService {
void update(UserTv resources);
void unbindPriorityMemberCode(UserTv resources);
void delete(Long id);
UserTvDTO findByPlatformAccount(String platformAccount);
UserTvDTO findByPriorityMemberCode(String memberCode);
UserTvDTO findByMemberId(Long memberId);
}
......
package com.topdraw.business.basicdata.user.iptv.service.dto;
package com.topdraw.business.module.user.iptv.service.dto;
import lombok.Data;
import java.sql.Timestamp;
......@@ -12,6 +12,11 @@ import java.io.Serializable;
@Data
public class UserTvDTO implements Serializable {
private String memberCode;
/** 绑定的小屏账户会员编码 */
private String priorityMemberCode;
// ID
private Long id;
......
package com.topdraw.business.basicdata.user.iptv.service.dto;
package com.topdraw.business.module.user.iptv.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
/**
* @author XiangHan
......
package com.topdraw.business.basicdata.user.iptv.service.impl;
package com.topdraw.business.module.user.iptv.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.config.LocalConstants;
import com.topdraw.util.IdWorker;
import com.topdraw.util.RedissonUtil;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.StringUtils;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.basicdata.user.iptv.repository.UserTvRepository;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvQueryCriteria;
import com.topdraw.business.basicdata.user.iptv.service.mapper.UserTvMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils;
import com.topdraw.business.module.user.iptv.repository.UserTvRepository;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -97,6 +88,16 @@ public class UserTvServiceImpl implements UserTvService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void unbindPriorityMemberCode(UserTv resources) {
UserTv UserTv = UserTvRepository.findById(resources.getId()).orElseGet(UserTv::new);
ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId());
UserTv.copy(resources);
UserTvRepository.save(UserTv);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
UserTv UserTv = UserTvRepository.findById(id).orElseThrow(
......@@ -114,5 +115,25 @@ public class UserTvServiceImpl implements UserTvService {
return null;
}
@Override
public UserTvDTO findByPriorityMemberCode(String memberCode) {
Optional<UserTv> userTv = UserTvRepository.findByPriorityMemberCode(memberCode);
if (userTv.isPresent()) {
ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
return UserTvMapper.toDto(userTv.get());
}
return null;
}
@Override
public UserTvDTO findByMemberId(Long memberId) {
Optional<UserTv> userTv = UserTvRepository.findByMemberId(memberId);
if (userTv.isPresent()) {
ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
return UserTvMapper.toDto(userTv.get());
}
return null;
}
}
......
package com.topdraw.business.basicdata.user.iptv.service.mapper;
package com.topdraw.business.module.user.iptv.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.module.user.weixin.collection.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_collection")
public class UserCollection implements Serializable {
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 应用ID
@Column(name = "app_id")
private Long appId;
// 用户ID
@Column(name = "user_id")
private Long userId;
// 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
@Column(name = "type")
private Integer type;
// 收藏夹名称
@Column(name = "name")
private String name;
// 数量
@Column(name = "count")
private Integer count;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(UserCollection source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.user.weixin.collection.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_collection_detail")
public class UserCollectionDetail implements Serializable {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_collection_id", insertable = false, updatable = false)
private UserCollection userCollection;
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 收藏夹ID
@Column(name = "user_collection_id")
private Long userCollectionId;
// 自定义收藏内容的类型CODE,默认:DEFAULT
@Column(name = "detail_folder_code")
private String detailFolderCode;
// 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
@Column(name = "detail_type")
private String detailType;
// 收藏内容的ID
@Column(name = "detail_id")
private Long detailId;
// 收藏内容的CODE
@Column(name = "detail_code")
private String detailCode;
// 收藏内容的剧集ID
@Column(name = "detail_episode_id")
private Long detailEpisodeId;
// 收藏内容的剧集CODE
@Column(name = "detail_episode_code")
private String detailEpisodeCode;
// 收藏内容的名称
@Column(name = "detail_name")
private String detailName;
// 收藏内容的标记
@Column(name = "detail_mark")
private Integer detailMark;
// 收藏内容的图片
@Column(name = "detail_img")
private String detailImg;
// 收藏内容的剧集序号
@Column(name = "detail_index")
private Integer detailIndex;
// 收藏内容的剧集总数
@Column(name = "detail_total_index")
private Integer detailTotalIndex;
// 收藏内容的播放时间
@Column(name = "detail_play_time")
private Integer detailPlayTime;
// 收藏内容的总时间
@Column(name = "detail_total_time")
private Integer detailTotalTime;
// 收藏内容在同一folder中的顺序
@Column(name = "detail_sequence")
private Integer detailSequence;
// 收藏内容的评分
@Column(name = "detail_score")
private Float detailScore;
// 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
@Column(name = "detail_like")
private Integer detailLike;
// 收藏内容的扩展数据
@Column(name = "detail_ext_data")
private String detailExtData;
// 创建时间
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(UserCollectionDetail source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.user.weixin.collection.repository;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import java.util.Optional;
/**
* @author pengmengqing
* @date 2021-04-02
*/
public interface UserCollectionDetailRepository extends JpaRepository<UserCollectionDetail, Long>, JpaSpecificationExecutor<UserCollectionDetail> {
@Modifying
void deleteAllByUserCollectionId(Long userCollectionId);
Optional<UserCollectionDetail> findByDetailIdAndDetailTypeAndUserCollectionId(Long detailId, String detailType, Long userCollectionId);
}
package com.topdraw.business.module.user.weixin.collection.repository;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
import java.util.Optional;
/**
* @author pengmengqing
* @date 2021-04-02
*/
public interface UserCollectionRepository extends JpaRepository<UserCollection, Long>, JpaSpecificationExecutor<UserCollection> {
Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long userId, Integer type, String name);
List<UserCollection> findByUserIdAndType(Long userId, Integer type);
}
package com.topdraw.business.module.user.weixin.collection.service;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* @author pengmengqing
* @date 2021-04-02
*/
public interface UserCollectionDetailService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable);
/**
* 根据ID查询
* @param id ID
* @return UserCollectionDetailDTO
*/
UserCollectionDetailDTO findById(Long id);
UserCollectionDetailDTO create(UserCollectionDetail resources);
void update(UserCollectionDetail resources);
void delete(Long id);
void deleteAllByUserCollectionId(Long id);
void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional);
}
package com.topdraw.business.module.user.weixin.collection.service;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @author pengmengqing
* @date 2021-04-02
*/
public interface UserCollectionService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<UserCollectionDTO>
*/
List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return UserCollectionDTO
*/
UserCollectionDTO findById(Long id);
UserCollectionDTO create(UserCollection resources);
void update(UserCollection resources);
void delete(Long id);
void download(List<UserCollectionDTO> all, HttpServletResponse response) throws IOException;
List<UserCollection> findByUserIdAndType(Long id, Integer type);
Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name);
UserCollection save(UserCollection userCollection);
}
package com.topdraw.business.module.user.weixin.collection.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Data
public class UserCollectionDTO implements Serializable {
// ID
private Long id;
// 应用ID
private Long appId;
// 用户ID
private Long userId;
// 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
private Integer type;
// 收藏夹名称
private String name;
// 数量
private Integer count;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.user.weixin.collection.service.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Data
public class UserCollectionDetailDTO implements Serializable {
// ID
private Long id;
// 收藏夹ID
private Long userCollectionId;
// 自定义收藏内容的类型CODE,默认:DEFAULT
private String detailFolderCode;
// 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
private String detailType;
// 收藏内容的ID
private Long detailId;
// 收藏内容的CODE
private String detailCode;
// 收藏内容的剧集ID
private Long detailEpisodeId;
// 收藏内容的剧集CODE
private String detailEpisodeCode;
// 收藏内容的名称
private String detailName;
// 收藏内容的标记
private Integer detailMark;
// 收藏内容的图片
private String detailImg;
// 收藏内容的剧集序号
private Integer detailIndex;
// 收藏内容的剧集总数
private Integer detailTotalIndex;
// 收藏内容的播放时间
private Integer detailPlayTime;
// 收藏内容的总时间
private Integer detailTotalTime;
// 收藏内容在同一folder中的顺序
private Integer detailSequence;
// 收藏内容的评分
private Float detailScore;
// 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
private Integer detailLike;
// 收藏内容的扩展数据
private String detailExtData;
// 创建时间
@JsonFormat(
pattern = "MM月dd日 HH:mm",
timezone = "GMT+8"
)
private Timestamp createTime;
// 更新时间
@JsonFormat(
pattern = "MM月dd日 HH:mm",
timezone = "GMT+8"
)
private Timestamp updateTime;
}
package com.topdraw.business.module.user.weixin.collection.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
import javax.persistence.criteria.JoinType;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Data
public class UserCollectionDetailQueryCriteria{
private Long userWeixinId;
@Query(joinType = JoinType.INNER, joinName = "userCollection")
private Long userId;
@Query(joinType = JoinType.INNER, joinName = "userCollection")
private Integer type;
private String detailType;
private String detailFolderCode = "DEFAULT";
private Long detailId;
}
package com.topdraw.business.module.user.weixin.collection.service.dto;
import lombok.Data;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Data
public class UserCollectionQueryCriteria{
}
package com.topdraw.business.module.user.weixin.collection.service.impl;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository;
import com.topdraw.business.module.user.weixin.collection.service.UserCollectionDetailService;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria;
import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionDetailMapper;
import com.topdraw.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.*;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserCollectionDetailServiceImpl implements UserCollectionDetailService {
@Autowired
private UserCollectionDetailRepository userCollectionDetailRepository;
@Autowired
private UserCollectionDetailMapper userCollectionDetailMapper;
@Override
public Map<String, Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable) {
Page<UserCollectionDetail> page = userCollectionDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(userCollectionDetailMapper::toDto));
}
@Override
public UserCollectionDetailDTO findById(Long id) {
UserCollectionDetail userCollectionDetail = userCollectionDetailRepository.findById(id).orElseGet(UserCollectionDetail::new);
ValidationUtil.isNull(userCollectionDetail.getId(),"UserCollectionDetail","id",id);
return userCollectionDetailMapper.toDto(userCollectionDetail);
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserCollectionDetailDTO create(UserCollectionDetail resources) {
return userCollectionDetailMapper.toDto(userCollectionDetailRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(UserCollectionDetail resources) {
UserCollectionDetail userCollectionDetail = userCollectionDetailRepository.findById(resources.getId()).orElseGet(UserCollectionDetail::new);
ValidationUtil.isNull( userCollectionDetail.getId(),"UserCollectionDetail","id",resources.getId());
userCollectionDetail.copy(resources);
userCollectionDetailRepository.save(userCollectionDetail);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
UserCollectionDetail userCollectionDetail = userCollectionDetailRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserCollectionDetail.class, id), 1));
userCollectionDetailRepository.delete(userCollectionDetail);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAllByUserCollectionId(Long id) {
this.userCollectionDetailRepository.deleteAllByUserCollectionId(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional) {
this.userCollectionDetailRepository.deleteAll(userCollectionDetailOptional);
}
}
package com.topdraw.business.module.user.weixin.collection.service.impl;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionRepository;
import com.topdraw.business.module.user.weixin.collection.service.UserCollectionService;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria;
import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionMapper;
import com.topdraw.utils.FileUtil;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserCollectionServiceImpl implements UserCollectionService {
@Autowired
private UserCollectionRepository userCollectionRepository;
@Autowired
private UserCollectionMapper userCollectionMapper;
@Override
public Map<String, Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable) {
Page<UserCollection> page = userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(userCollectionMapper::toDto));
}
@Override
public List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria) {
return userCollectionMapper.toDto(userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public UserCollectionDTO findById(Long id) {
UserCollection userCollection = userCollectionRepository.findById(id).orElseGet(UserCollection::new);
ValidationUtil.isNull(userCollection.getId(),"UserCollection","id",id);
return userCollectionMapper.toDto(userCollection);
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserCollectionDTO create(UserCollection resources) {
return userCollectionMapper.toDto(userCollectionRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(UserCollection resources) {
UserCollection userCollection = userCollectionRepository.findById(resources.getId()).orElseGet(UserCollection::new);
ValidationUtil.isNull( userCollection.getId(),"UserCollection","id",resources.getId());
userCollection.copy(resources);
userCollectionRepository.save(userCollection);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
UserCollection userCollection = userCollectionRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserCollection.class, id), 1));
userCollectionRepository.delete(userCollection);
}
@Override
public void download(List<UserCollectionDTO> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (UserCollectionDTO userCollection : all) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("应用ID", userCollection.getAppId());
// map.put("用户ID", userCollection.getSubscriberId());
// map.put("platformAccount", userCollection.getPlatformAccount());
map.put("收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅", userCollection.getType());
map.put("收藏夹名称", userCollection.getName());
map.put("数量", userCollection.getCount());
map.put("创建时间", userCollection.getCreateTime());
map.put("更新时间", userCollection.getUpdateTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
public List<UserCollection> findByUserIdAndType(Long id, Integer type) {
return this.userCollectionRepository.findByUserIdAndType(id,type);
}
@Override
public Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name) {
return Optional.empty();
}
@Override
public UserCollection save(UserCollection userCollection) {
this.userCollectionRepository.save(userCollection);
return userCollection;
}
}
package com.topdraw.business.module.user.weixin.collection.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserCollectionDetailMapper extends BaseMapper<UserCollectionDetailDTO, UserCollectionDetail> {
}
package com.topdraw.business.module.user.weixin.collection.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserCollectionMapper extends BaseMapper<UserCollectionDTO, UserCollection> {
}
package com.topdraw.business.basicdata.user.weixin.domain;
package com.topdraw.business.module.user.weixin.domain;
import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
......@@ -21,7 +22,7 @@ import java.io.Serializable;
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_weixin")
public class UserWeixin implements Serializable {
public class UserWeixin extends DefaultAsyncMqModule implements Serializable {
// ID
@Id
......
package com.topdraw.business.module.user.weixin.repository;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import javax.transaction.Transactional;
import java.util.Optional;
/**
* @author XiangHan
* @date 2021-12-16
*/
public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, JpaSpecificationExecutor<UserWeixin> {
Optional<UserWeixin> findFirstByMemberIdAndAppid(Long memberId, String appid);
Optional<UserWeixin> findFirstByUnionidAndAppidAndOpenid(String unionId, String appId, String openId);
Optional<UserWeixin> findFirstByAppidAndOpenid(String appId, String openId);
Optional<UserWeixin> findFirstByUnionid(String unionid);
Optional<UserWeixin> findFirstByUnionidAndAppid(String unionid, String appId);
@Modifying
@Transactional
@Query(value = "update uc_user_weixin set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true)
void updateTime(@Param("resources") UserWeixin resources);
}
package com.topdraw.business.basicdata.user.weixin.rest;
package com.topdraw.business.module.user.weixin.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.common.ResultInfo;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin;
import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService;
import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author XiangHan
......@@ -21,7 +17,7 @@ import javax.servlet.http.HttpServletResponse;
*/
@Api(tags = "UserWeixin管理")
@RestController
@RequestMapping("/api/UserWeixin")
@RequestMapping("/ucEngine/api/userWeixin")
public class UserWeixinController {
@Autowired
......@@ -39,24 +35,30 @@ public class UserWeixinController {
return ResultInfo.success(UserWeixinService.queryAll(criteria));
}
@Log
@PostMapping
@PostMapping(value = "/create")
@ApiOperation("新增UserWeixin")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody UserWeixin resources) {
UserWeixinService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@PutMapping(value = "/update")
@ApiOperation("修改UserWeixin")
@AnonymousAccess
public ResultInfo update(@Validated @RequestBody UserWeixin resources) {
UserWeixinService.update(resources);
return ResultInfo.success();
}
@PutMapping(value = "/updateWeixinMemberProfile")
@ApiOperation("修改UserWeixin")
@AnonymousAccess
public ResultInfo updateWeixinMemberProfile(@Validated @RequestBody UserWeixin resources) {
UserWeixinService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除UserWeixin")
public ResultInfo delete(@PathVariable Long id) {
......
package com.topdraw.business.basicdata.user.weixin.service;
package com.topdraw.business.module.user.weixin.service;
import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin;
import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.Optional;
/**
* @author XiangHan
......@@ -37,10 +36,21 @@ public interface UserWeixinService {
*/
UserWeixinDTO findById(Long id);
void create(UserWeixin resources);
UserWeixin create(UserWeixin resources);
void update(UserWeixin resources);
void updateTime(UserWeixin resources);
void delete(Long id);
UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid);
UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId);
UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId);
UserWeixinDTO findFirstByUnionId(String unionid);
UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId);
}
......
package com.topdraw.business.basicdata.user.weixin.service.dto;
package com.topdraw.business.module.user.weixin.service.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.sql.Timestamp;
import java.io.Serializable;
......@@ -90,11 +94,13 @@ public class UserWeixinDTO implements Serializable {
// 授权时间
private Timestamp authTime;
private Integer sex;
private Integer gender;
private String country;
private String province;
private String city;
private Integer sex;
}
......
package com.topdraw.business.basicdata.user.weixin.service.dto;
package com.topdraw.business.module.user.weixin.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
import lombok.Data;
/**
* @author XiangHan
......@@ -9,4 +9,8 @@ import com.topdraw.annotation.Query;
*/
@Data
public class UserWeixinQueryCriteria{
@Query()
private String unionId;
}
......
package com.topdraw.business.basicdata.user.weixin.service.impl;
package com.topdraw.business.module.user.weixin.service.impl;
import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.utils.FileUtil;
import com.topdraw.business.basicdata.user.weixin.repository.UserWeixinRepository;
import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService;
import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.basicdata.user.weixin.service.mapper.UserWeixinMapper;
import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -18,14 +18,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author XiangHan
......@@ -61,12 +56,15 @@ public class UserWeixinServiceImpl implements UserWeixinService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(UserWeixin resources) {
@AsyncMqSend
public UserWeixin create(UserWeixin resources) {
UserWeixinRepository.save(resources);
return resources;
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void update(UserWeixin resources) {
UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new);
ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId());
......@@ -75,6 +73,12 @@ public class UserWeixinServiceImpl implements UserWeixinService {
}
@Override
@AsyncMqSend
public void updateTime(UserWeixin resources) {
UserWeixinRepository.updateTime(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
......@@ -83,5 +87,35 @@ public class UserWeixinServiceImpl implements UserWeixinService {
UserWeixinRepository.delete(UserWeixin);
}
@Override
public UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByMemberIdAndAppid(memberId, appid).orElseGet(UserWeixin::new);
ValidationUtil.isNull(userWeixin.getId(),"UserWeixin","id",memberId);
return UserWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionidAndAppidAndOpenid(unionId, appId,openId).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByAppidAndOpenid(appId,openId).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByUnionId(String unionid) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionid(unionid).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionidAndAppid(unionid,appId).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
}
}
......
package com.topdraw.business.basicdata.user.weixin.service.mapper;
package com.topdraw.business.module.user.weixin.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.basicdata.user.weixin.domain.UserWeixin;
import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
......
package com.topdraw.business.module.weixin.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_weixin__weixin_message_template")
public class UserWeixinWeixinMessageTemplate implements Serializable {
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 用户id
@Column(name = "user_weixin_id", nullable = false)
private Long userWeixinId;
// 微信消息模板id
@Column(name = "weixin_message_template_id", nullable = false)
private Long weixinMessageTemplateId;
// 用户是否订阅: 0-否, 1-是
@Column(name = "status", nullable = false)
private Integer status;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(UserWeixinWeixinMessageTemplate source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.weixin.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_weixin_message_template")
public class WeixinMessageTemplate implements Serializable {
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 标识 order-下单成功通知,cancellation-核销成功通知
@Column(name = "code", nullable = false)
private String code;
// 微信appid
@Column(name = "appid", nullable = false)
private String appid;
// 微信模板id
@Column(name = "template_id", nullable = false)
private String templateId;
// 状态:0-无效,1-有效
@Column(name = "status", nullable = false)
private Integer status;
// 描述
@Column(name = "description")
private String description;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(WeixinMessageTemplate source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.weixin.repository;
import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author pengmengqing
* @date 2021-01-28
*/
public interface UserWeixinWeixinMessageTemplateRepository extends JpaRepository<UserWeixinWeixinMessageTemplate, Long>, JpaSpecificationExecutor<UserWeixinWeixinMessageTemplate> {
}
package com.topdraw.business.module.weixin.repository;
import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Optional;
/**
* @author pengmengqing
* @date 2021-01-28
*/
public interface WeixinMessageTemplateRepository extends JpaRepository<WeixinMessageTemplate, Long>, JpaSpecificationExecutor<WeixinMessageTemplate> {
Optional<WeixinMessageTemplate> findFirstByCode(String code);
Optional<WeixinMessageTemplate> findFirstByCodeAndAppid(String code, String appid);
Optional<WeixinMessageTemplate> findFirstByTemplateId(String templateId);
}
package com.topdraw.business.module.weixin.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService;
import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Api(tags = "UserWeixinWeixinMessageTemplate管理")
@RestController
@RequestMapping("/ucEngine/api/UserWeixinWeixinMessageTemplate")
public class UserWeixinWeixinMessageTemplateController {
@Autowired
private UserWeixinWeixinMessageTemplateService userWeixinWeixinMessageTemplateService;
@AnonymousAccess
@PostMapping
@ApiOperation("新增或修改MemberWeixinMessageTemplate")
public ResultInfo createOrUpdate(@RequestBody UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) {
userWeixinWeixinMessageTemplateService.createOrUpdate(criteria);
return ResultInfo.success(new ArrayList<>());
}
}
package com.topdraw.business.module.weixin.service;
import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author pengmengqing
* @date 2021-01-28
*/
public interface UserWeixinWeixinMessageTemplateService {
void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria);
}
package com.topdraw.business.module.weixin.service.dto;
import lombok.Data;
import java.util.List;
@Data
public class UpdateUserWeixinWeixinMessageTemplateQueryCriteria {
private Long memberId;
private List<UserWeixinWeixinMessageTemplateQueryCriteria> templateList;
}
package com.topdraw.business.module.weixin.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Data
public class UserWeixinWeixinMessageTemplateDTO implements Serializable {
// ID
private Long id;
// 用户id
private Long userWeixinId;
// 微信消息模板id
private Long weixinMessageTemplateId;
// 用户是否订阅: 0-否, 1-是
private Integer status;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.weixin.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Data
public class UserWeixinWeixinMessageTemplateQueryCriteria {
// 用户id
@Query(propName = "userWeixinId")
private Long memberId;
// 微信消息模板id
@Query
private Long weixinMessageTemplateId;
// 用户是否订阅: 0-否, 1-是
@Query
private Integer status = 1;
private String templateId;
}
package com.topdraw.business.module.weixin.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Data
public class WeixinMessageTemplateDTO implements Serializable {
// ID
private Long id;
// 标识 order-下单成功通知,cancellation-核销成功通知
private String code;
// 微信模板id
private String templateId;
// 描述
private String description;
}
package com.topdraw.business.module.weixin.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
import java.util.List;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Data
public class WeixinMessageTemplateQueryCriteria{
private String codes;
@Query(propName = "code", type = Query.Type.IN)
private List<String> codeList;
@Query
private String appid;
@Query
private Integer status = 1;
}
package com.topdraw.business.module.weixin.service.impl;
import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
import com.topdraw.business.module.weixin.repository.UserWeixinWeixinMessageTemplateRepository;
import com.topdraw.business.module.weixin.repository.WeixinMessageTemplateRepository;
import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService;
import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria;
import com.topdraw.business.module.weixin.service.mapper.UserWeixinWeixinMessageTemplateMapper;
import com.topdraw.utils.FileUtil;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Service
@Slf4j
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserWeixinWeixinMessageTemplateServiceImpl implements UserWeixinWeixinMessageTemplateService {
@Autowired
private UserWeixinWeixinMessageTemplateRepository userWeixinWeixinMessageTemplateRepository;
@Autowired
private WeixinMessageTemplateRepository weixinMessageTemplateRepository;
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
public void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) {
for (UserWeixinWeixinMessageTemplateQueryCriteria queryCriteria : criteria.getTemplateList()) {
queryCriteria.setMemberId(criteria.getMemberId());
Integer status = queryCriteria.getStatus();
queryCriteria.setStatus(null);
String templateId = queryCriteria.getTemplateId();
Optional<WeixinMessageTemplate> templateOptional = weixinMessageTemplateRepository.findFirstByTemplateId(templateId);
if (!templateOptional.isPresent()) {
log.info("template " + templateId + " not exist");
continue;
}
Long id = templateOptional.get().getId();
queryCriteria.setWeixinMessageTemplateId(id);
Optional<UserWeixinWeixinMessageTemplate> optional = userWeixinWeixinMessageTemplateRepository.findOne(((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, queryCriteria, criteriaBuilder)));
if (!optional.isPresent()) {
UserWeixinWeixinMessageTemplate userWeixinWeixinMessageTemplate = new UserWeixinWeixinMessageTemplate();
userWeixinWeixinMessageTemplate.setUserWeixinId(queryCriteria.getMemberId())
.setWeixinMessageTemplateId(queryCriteria.getWeixinMessageTemplateId())
.setStatus(status);
userWeixinWeixinMessageTemplateRepository.save(userWeixinWeixinMessageTemplate);
} else {
UserWeixinWeixinMessageTemplate UserWeixinWeixinMessageTemplate = optional.get();
if (!status.equals(UserWeixinWeixinMessageTemplate.getStatus())) {
UserWeixinWeixinMessageTemplate.setStatus(status);
userWeixinWeixinMessageTemplateRepository.save(UserWeixinWeixinMessageTemplate);
}
}
}
}
}
package com.topdraw.business.module.weixin.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserWeixinWeixinMessageTemplateMapper extends BaseMapper<UserWeixinWeixinMessageTemplateDTO, UserWeixinWeixinMessageTemplate> {
}
package com.topdraw.business.module.weixin.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
import com.topdraw.business.module.weixin.service.dto.WeixinMessageTemplateDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author pengmengqing
* @date 2021-01-28
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface WeixinMessageTemplateMapper extends BaseMapper<WeixinMessageTemplateDTO, WeixinMessageTemplate> {
}
package com.topdraw.business.process.domian;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TempCustomPointBean extends TempIptvUser {
/** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */
@Transient
@NotNull(message = "设备类型不得为空")
protected Integer deviceType;
/** 订单id */
@Transient
protected Long orderId;
/** 节目id(针对观影操作) */
@Transient
protected Long mediaId;
/** 活动id(针对参与活动) */
@Transient
protected Long activityId;
/** 商品id */
@Transient
protected Long itemId;
/** 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;98:系统操作;99:其他 */
@Transient
protected Integer evtType;
}
......@@ -5,12 +5,16 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TempIptvUser {
private String unionid;
// 账户
@Transient
private String platformAccount;
......@@ -20,5 +24,70 @@ public class TempIptvUser {
private Long points;
// ID
private Long id;
// 人ID
private Long personId;
// 运营商平台
private String platform;
// 手机号
private String cellphone;
// 用户名
private String username;
// 密码 MD5
private String password;
// 昵称 Base64
private String nickname;
// 头像
private String image;
// 登录天数(总天数)
private Integer loginDays;
// 连续登录天数
private Integer continueDays;
// 活跃时间
private Timestamp activeTime;
// 分组 分组ID用逗号分隔
private String groups;
// 标签 标签用逗号分隔
private String tags;
// 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录
private Integer loginType;
// 状态 0-下线 1-上线
private Integer status;
// 描述
private String description;
// 创建者
private String createBy;
// 创建时间
private Timestamp createTime;
// 更新者
private String updateBy;
// 更新时间
private Timestamp updateTime;
// 会员id
private Long memberId;
private String memberCode;
}
......
package com.topdraw.business.process.domian;
public interface UnbindGroup {
}
package com.topdraw.business.process.domian.result;
public interface TaskTemplateType {
int TYPE_1 = 1;
int TYPE_2 = 2;
int TYPE_3 = 3;
int TYPE_4 = 4;
}
package com.topdraw.business.process.domian.weixin;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
@Data
public class BindBean extends WeiXinUserBean {
private Long platformUserId;
private String platformAccount;
}
package com.topdraw.business.process.domian.weixin;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 微信账户信息
* @author XiangHan
* @date 2021-01-18
*/
@Data
public class BuyVipBean extends WeiXinUserBean {
private Integer vip;
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime vipExpireTime;
}
package com.topdraw.business.process.domian.weixin;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
@Data
public class SubscribeBean extends WeiXinUserBean {
private JSONObject userInfoJson;
private JSONObject iptvUserInfo;
private String msgType;
private String event;
/** */
private String openId;
/** */
private String appId;
/** */
private String eventKey;
private String unionid;
private String nickname;
private String headimgurl;
}
package com.topdraw.business.process.domian.weixin;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SubscribeBeanEvent {
@NotNull(message = "【content】 not be null !!!")
private String content;
}
package com.topdraw.business.process.domian.weixin;
import com.alibaba.fastjson.annotation.JSONField;
import com.topdraw.annotation.Query;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class UserCollectionMq {
// 应用ID
@JSONField(name = "app_id")
private Long appId;
@JSONField(name = "userId")
private Long userId;
// 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
private Integer type;
// 收藏夹名称
private String name;
// 数量
private Integer count;
private String images;
// 收藏夹ID
@JSONField(name = "user_collection_id")
@Query
private Long userCollectionId;
// 自定义收藏内容的类型CODE,默认:DEFAULT
@JSONField(name = "detail_folder_code")
@Query
private String detailFolderCode;
// 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
@JSONField(name = "detail_type")
@Query
private String detailType;
// 收藏内容的ID
@JSONField(name = "detail_id")
@Query
private Long detailId;
// 收藏内容的CODE
@JSONField(name = "detail_code")
@Query
private String detailCode;
// 收藏内容的剧集ID
@JSONField(name = "detail_episode_id")
@Query
private Long detailEpisodeId;
// 收藏内容的剧集CODE
@JSONField(name = "detail_episode_code")
@Query
private String detailEpisodeCode;
// 收藏内容的名称
@JSONField(name = "detail_name")
@Query
private String detailName;
// 收藏内容的标记
@JSONField(name = "detail_mark")
@Query
private Integer detailMark;
// 收藏内容的图片
@JSONField(name = "detail_img")
private String detailImg;
// 收藏内容的剧集序号
@JSONField(name = "detail_index")
@Query
private Integer detailIndex;
// 收藏内容的剧集总数
@JSONField(name = "detail_total_index")
@Query
private Integer detailTotalIndex;
// 收藏内容的播放时间
@JSONField(name = "detail_play_time")
@Query
private Integer detailPlayTime;
// 收藏内容的总时间
@JSONField(name = "detail_total_time")
@Query
private Integer detailTotalTime;
// 收藏内容在同一folder中的顺序
@JSONField(name = "detail_sequence")
@Query
private Integer detailSequence;
// 收藏内容的评分
@JSONField(name = "detail_score")
@Query
private Float detailScore;
// 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
@JSONField(name = "detail_like")
@Query
private Integer detailLike;
// 收藏内容的扩展数据
@JSONField(name = "detail_ext_data")
@Query
private String detailExtData;
// 创建时间
@JSONField(name = "create_time")
@Query
private Timestamp createTime;
// 更新时间
@JSONField(name = "update_time")
private Timestamp updateTime;
}
package com.topdraw.business.process.domian.weixin;
import lombok.Data;
/**
* 微信账户信息
* @author XiangHan
* @date 2021-01-18
*/
@Data
public class WeiXinUserBean {
private Long id;
private String unionid;
/** */
private String openid;
/** */
private String appid;
/** 加密后的appId,参数 */
private String wxAppid;
/** 加密后的code,参数 */
private String wxCode;
/** */
private String userInfo;
/** 会员id */
private Long memberId;
/** 加密信息 */
private String encryptedData;
/** 解析用户电话号码时使用,参数 */
private String iv;
/** 资源id */
private String sourceId;
/** 资源类型 */
private String sourceType;
/** 资源描述,用来表示从哪个地方链接进来的 */
private String sourceDesc;
/** 资源实例 */
private String sourceEntity;
/** 推荐者id */
private Long sourceUser;
private String nikename;
private String headimgurl;
}
package com.topdraw.business.process.rest;
import com.topdraw.aop.log.Log;
import com.topdraw.business.process.domian.TempCoupon;
import com.topdraw.business.process.service.CouponOperationService;
import com.topdraw.common.ResultInfo;
......@@ -23,7 +22,6 @@ public class CouponOperationController {
@Autowired
private CouponOperationService couponOperationService;
@Log
@PostMapping(value = "/grantCouponByManual")
@ApiOperation("手动发放优惠券")
public ResultInfo grantCouponByManual(List<TempCoupon> tempCouponList) {
......
package com.topdraw.business.process.rest;
import com.topdraw.aop.log.Log;
import com.topdraw.business.process.domian.TempCoupon;
import com.topdraw.business.process.domian.TempExp;
import com.topdraw.business.process.service.CouponOperationService;
......@@ -30,7 +29,6 @@ public class ExpOperationController {
@Autowired
private ExpOperationService expOperationService;
@Log
@PostMapping(value = "/grantExpByManual")
@ApiOperation("手动发放成长值")
public ResultInfo grantExpByManual(@Validated @RequestBody TempExp tempExp) {
......
package com.topdraw.business.process.rest;
import cn.hutool.core.util.ObjectUtil;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.process.domian.weixin.BuyVipBean;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.common.IResultInfo;
import com.topdraw.common.ResultInfo;
import com.topdraw.exception.BadRequestException;
import com.topdraw.weixin.util.WeChatConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.Objects;
@Api("会员处理")
@RestController
@RequestMapping(value = "/ucEngine/api/memberOperation")
public class MemberOperationController {
@Autowired
private MemberOperationService memberOperationService;
@Autowired
private MemberVipHistoryService memberVipHistoryService;
@Autowired
private UserWeixinService userWeixinService;
@Autowired
private MemberService memberService;
@GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}")
@ApiOperation("获取会员基本信息并且检查vip状态")
@AnonymousAccess
public IResultInfo getMemberProfileAndCheckVip(@PathVariable(value = "appId") String appId, @PathVariable(value = "memberId") Long memberId) {
MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId);
return ResultInfo.success(memberProfileDTO);
}
@PutMapping("/buyVip")
@ApiOperation("购买vip")
@AnonymousAccess
public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) {
// 小程序账户id
Long id = buyVipBean.getId();
if (Objects.isNull(id))
throw new BadRequestException("参数异常: id is null !");
// vip等级
Integer vip = buyVipBean.getVip();
if (Objects.isNull(vip) || vip <= 0)
throw new BadRequestException("vip 等级有误");
MemberDTO memberDTO = memberOperationService.buyVip(buyVipBean);
LocalDateTime vipExpireTime = buyVipBean.getVipExpireTime();
this.doInsertVipHistory(id,vip,vipExpireTime);
return ResultInfo.success(memberDTO);
}
private void doInsertVipHistory(Long id,Integer vip,LocalDateTime vipExpireTime) {
UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id);
Long memberId = userWeixinDTO.getMemberId();
MemberDTO member = this.memberService.findById(memberId);
LocalDateTime now = LocalDateTime.now();
MemberVipHistory memberVipHistory = new MemberVipHistory();
if (ObjectUtil.isNull(vipExpireTime)) {
LocalDateTime localDateTime = now.plusYears(1L);
member.setVipExpireTime(localDateTime);
} else {
//购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年
//区分是当前vip续费 还是买新的vip
if (ObjectUtil.equal(vip, member.getVip())) {
if (now.isBefore(vipExpireTime)) {
LocalDateTime localDateTime = vipExpireTime.plusYears(1L);
member.setVipExpireTime(localDateTime);
} else {
LocalDateTime localDateTime = now.plusYears(1L);
member.setVipExpireTime(localDateTime);
}
} else {
LocalDateTime localDateTime = now.plusYears(1L);
member.setVipExpireTime(localDateTime);
}
}
memberVipHistory.setVipExpireTime(member.getVipExpireTime());
memberVipHistoryService.create(memberVipHistory);
}
}
package com.topdraw.business.process.rest;
import com.topdraw.aop.log.Log;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryType;
import com.topdraw.business.basicdata.points.detail.service.PointsDetailService;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.basicdata.user.weixin.service.UserWeixinService;
import com.topdraw.business.basicdata.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.process.domian.TempIptvUser;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryType;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.process.domian.TempCustomPointBean;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.business.process.domian.result.CustomPointsResult;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.business.process.service.UserTvOperationService;
import com.topdraw.common.ResultCode;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.LocalConstants;
import com.topdraw.util.TimestampUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
......@@ -46,7 +38,7 @@ import java.util.Objects;
*/
@Api(tags = "PointsOperation管理")
@RestController
@RequestMapping("/api/pointsOperation")
@RequestMapping("/ucEngine/api/pointsOperation")
public class PointsOperationController {
private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class);
......@@ -67,12 +59,14 @@ public class PointsOperationController {
@GetMapping(value = "/pagePointsDetails")
@ApiOperation("查询PointsDetail")
@AnonymousAccess
public ResultInfo pagePointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable));
}
@GetMapping(value = "/pageAvailablePoints")
@ApiOperation("查询PointsAvailable")
@AnonymousAccess
public ResultInfo pageAvailablePoints(PointsAvailableQueryCriteria criteria, Pageable pageable) {
PointsAvailableQueryType queryType = criteria.getQueryType();
// 可用
......@@ -82,17 +76,17 @@ public class PointsOperationController {
return ResultInfo.successPage(pointsAvailableService.queryAll(criteria,pageable));
}
@Log
@GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}")
@ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用")
@AnonymousAccess
public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) {
Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id);
return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong);
}
@Log
@PostMapping(value = "/grantPointsByManual")
@ApiOperation("手动发放积分")
@AnonymousAccess
public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) {
Long memberId = tempPoints.getMemberId();
Long points = tempPoints.getPoints();
......@@ -113,12 +107,18 @@ public class PointsOperationController {
* @param tempIptvUser
* @return
*/
@Log
@PostMapping(value = "/customPointsByUserTvPlatformAccount")
@ApiOperation("通过大屏账户积分消耗")
public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempIptvUser tempIptvUser) {
@AnonymousAccess
public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempCustomPointBean tempIptvUser) {
String platformAccount = tempIptvUser.getPlatformAccount();
Long points = tempIptvUser.getPoints();
Long activityId = tempIptvUser.getActivityId();
Integer evtType = tempIptvUser.getEvtType();
Long mediaId = tempIptvUser.getMediaId();
Long orderId = tempIptvUser.getOrderId();
Integer deviceType = tempIptvUser.getDeviceType();
TempPoints tempPoints = new TempPoints();
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
......@@ -132,9 +132,12 @@ public class PointsOperationController {
tempPoints.setMemberId(memberId);
}
tempPoints.setPoints(points);
tempPoints.setDeviceType(LocalConstants.DEVICE_VIS);
tempPoints.setDeviceType(deviceType);
tempPoints.setAppCode(LocalConstants.APP_CODE_CHONGQING_CHONGSHU_VIS);
tempPoints.setEvtType(LocalConstants.EVT_TYPE_ACTIVITY);
tempPoints.setEvtType(evtType);
tempPoints.setActivityId(activityId);
tempPoints.setMediaId(mediaId);
tempPoints.setOrderId(orderId);
return this.customPoints(tempPoints);
}
......@@ -143,9 +146,9 @@ public class PointsOperationController {
* @param tempPoints
* @return
*/
@Log
@PostMapping(value = "/customPointsByUserId")
@ApiOperation("积分消耗")
@AnonymousAccess
public ResultInfo customPointsByUserId(@Validated @RequestBody TempPoints tempPoints) {
Long userId = tempPoints.getUserId();
// 设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
......@@ -184,9 +187,9 @@ public class PointsOperationController {
return userWeixinDTO.getMemberId();
}
@Log
@PostMapping(value = "/consumePoints")
@ApiOperation("积分消耗")
@AnonymousAccess
public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) {
Integer pointsType = tempPoints.getPointsType();
if (Objects.isNull(pointsType)) {
......
package com.topdraw.business.process.rest;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryType;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.service.RightsHistoryService;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryType;
import com.topdraw.business.process.service.RightsOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.util.TimestampUtil;
......
package com.topdraw.business.process.rest;
import com.topdraw.aop.log.Log;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.process.domian.TempIptvUser;
import com.topdraw.business.process.service.TaskOperationService;
import com.topdraw.common.ResultInfo;
......@@ -14,7 +14,7 @@ import java.util.Arrays;
@Api("任务处理")
@RestController
@RequestMapping(value = "/api/TaskOperation")
@RequestMapping(value = "/ucEngine/api/taskOperation")
public class TaskOperationController {
@Autowired
......@@ -25,9 +25,9 @@ public class TaskOperationController {
*
* @param criteria 消息
*/
@Log
@PostMapping(value = "/dealTask")
@ApiOperation("事件处理")
@AnonymousAccess
public void dealTask(@RequestBody @Validated TaskOperationQueryCriteria criteria) {
// 任务处理
this.taskOperationService.dealTask(criteria.getContent());
......@@ -40,9 +40,9 @@ public class TaskOperationController {
* 1.用户每天首次进入活动详情页的时候赠送5个积分
* 2.判断任务是否已经做过,没有做过的话,保存任务记录,任务记录通过redis保存即可
*/
@Log
@PostMapping(value = "/createPoint4ChongQing")
@ApiOperation("针对重庆大屏20211220号的积分兑换活动专门定制的接口")
@Deprecated
public ResultInfo createPoint4ChongQing(@RequestBody TempIptvUser tempIptvUser){
String platformAccount = tempIptvUser.getPlatformAccount();
Long points = tempIptvUser.getPoints();
......
package com.topdraw.business.process.rest;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.process.domian.TempIptvUser;
import com.topdraw.business.process.domian.weixin.BindBean;
import com.topdraw.business.process.domian.weixin.SubscribeBean;
import com.topdraw.business.process.domian.weixin.SubscribeBeanEvent;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.RedisKeyUtil;
import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.util.Base64Util;
import com.topdraw.util.JSONUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.StringUtils;
import com.topdraw.weixin.util.WeChatConstants;
import com.topdraw.weixin.util.WeixinUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Arrays;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.net.URLDecoder;
import java.time.LocalDateTime;
import java.util.*;
@Api("账户处理")
@RestController
@RequestMapping(value = "/ucEngine/api/userOperation")
@Slf4j
public class UserOperationController {
@Autowired
private UserOperationService userTvOperationService;
@Autowired
private UserWeixinService userWeixinService;
@Autowired
private UserTvService userTvService;
@Autowired
private MemberService memberService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private UserOperationService userOperationService;
private static final String SUBSCRIBE = "subscribe";
private static final String UNSUBSCRIBE = "unsubscribe";
private static final Integer SUBSCRIBE_STATUS = 1;
@PostMapping(value = "/createUserAndCreateMember")
@ApiOperation("新增大屏账户同时创建会员信息")
@AnonymousAccess
public ResultInfo createUserAndCreateMember(@Validated @RequestBody TempIptvUser resources) {
log.info("createUserAndCreateMember ==> input ==> [{}]",resources);
UserTv userTv = new UserTv();
BeanUtils.copyProperties(resources,userTv);
boolean result = this.userTvOperationService.createMemberByUserTv(userTv);
return ResultInfo.success(result);
}
@PostMapping(value = "/createWeixinUserAndCreateMember")
@ApiOperation("新增小屏账户同时创建会员信息")
@AnonymousAccess
public ResultInfo createWeixinUserAndCreateMember(@Validated @RequestBody UserWeixin resources) {
log.info("createWeixinUserAndCreateMember ==> input ==> [{}]",resources);
String appId = resources.getAppid();
if (StringUtils.isBlank(appId))
throw new NullPointerException("appId is null !");
String openId = resources.getOpenid();
if (StringUtils.isBlank(openId))
throw new NullPointerException("openId is null !");
String unionId = resources.getUnionid();
if (StringUtils.isBlank(unionId))
throw new NullPointerException("unionId is null !");
UserWeixinDTO result = this.userTvOperationService.createWeixinUserAndCreateMember(resources);
return ResultInfo.success(result);
}
@GetMapping(value = "/findBindByPlatformAccount/{platformAccount}")
@AnonymousAccess
public ResultInfo findBindByPlatformAccount(@PathVariable("platformAccount") String platformAccount) {
log.info("findBindByPlatformAccount ==> input ==> [{}]",platformAccount);
List<MemberDTO> result = this.userTvOperationService.findBindByPlatformAccount(platformAccount);
return ResultInfo.success(result);
}
@PostMapping(value = "/sendQrCodeMessage")
@ApiOperation("带参二维码")
@AnonymousAccess
public ResultInfo sendQrCodeMessage(@RequestBody String content) {
log.info("sendQrCodeMessage ==> input ==> [{}]",content);
boolean result = this.userTvOperationService.sendQrCodeMessage(content);
return ResultInfo.success(result);
}
@PostMapping(value = "/deleteAllCollection")
@ApiOperation("删除全部收藏")
@AnonymousAccess
public ResultInfo deleteAllCollection(@RequestBody String content) {
log.info("deleteAllCollection ==> input ==> [{}]",content);
boolean result = this.userTvOperationService.deleteAllCollection(content);
return ResultInfo.success(result);
}
@PostMapping(value = "/deleteCollection")
@ApiOperation("删除收藏")
@AnonymousAccess
public ResultInfo deleteCollection(@RequestBody String content) {
log.info("deleteCollection ==> input ==> [{}]",content);
boolean result = this.userTvOperationService.deleteCollection(content);
return ResultInfo.success(result);
}
@PostMapping(value = "/addCollection")
@ApiOperation("添加收藏")
@AnonymousAccess
public ResultInfo addCollection(@RequestBody String content) {
log.info("addCollection ==> input ==> [{}]",content);
boolean result = this.userTvOperationService.addCollection(content);
return ResultInfo.success(result);
}
@RequestMapping(value = "/unbind")
@ApiOperation("大屏用户解绑")
@AnonymousAccess
public ResultInfo unbind(@Validated @RequestBody TempIptvUser resources) {
log.info("unbind ==> input ==> [{}]",resources);
UserTv userTv = new UserTv();
BeanUtils.copyProperties(resources,userTv);
String unionid = resources.getUnionid();
String memberCode1 = resources.getMemberCode();
if (Objects.nonNull(memberCode1)) {
MemberDTO memberDTO = this.memberService.getByCode(memberCode1);
String memberCode = memberDTO.getCode();
if (StringUtils.isNotBlank(memberCode)) {
userTv.setMemberCode(memberCode);
this.userTvOperationService.unbind(userTv);
}
}
return ResultInfo.success();
}
@RequestMapping(value = "/changeMainAccount")
@ApiOperation("大屏更换主账号")
@AnonymousAccess
public ResultInfo changeMainAccount(@Validated @RequestBody TempIptvUser resources) {
log.info("changeMainAccount ==> input ==> [{}]",resources);
UserTv userTv = new UserTv();
BeanUtils.copyProperties(resources,userTv);
Long memberId = resources.getMemberId();
String memberCode1 = resources.getMemberCode();
if (Objects.nonNull(memberCode1)) {
MemberDTO memberDTO = this.memberService.getByCode(memberCode1);
String memberCode = memberDTO.getCode();
if (StringUtils.isNotBlank(memberCode)) {
userTv.setMemberCode(memberCode);
this.userTvOperationService.changeMainAccount(userTv);
}
} else {
String unionid = resources.getUnionid();
this.userTvOperationService.changeMainAccountByUnionId(userTv,unionid);
}
return ResultInfo.success("update success");
}
@PostMapping("/serviceLogin")
@ApiOperation("微信服务号(H5)登录")
@AnonymousAccess
public ResultInfo serviceLogin(@Validated @RequestBody WeiXinUserBean resources) {
Object o = this.userTvOperationService.serviceLogin(resources);
return ResultInfo.success(o);
}
@PostMapping("/appletLogin")
@ApiOperation("微信小程序登录")
@AnonymousAccess
public ResultInfo appletLogin(@Validated @RequestBody WeiXinUserBean resources) {
log.info("appletLogin ==> input ==> [{}]",resources);
UserWeixinDTO result = this.userTvOperationService.appletLogin(resources);
return ResultInfo.success(result);
}
@PostMapping("/appletBind")
@ApiOperation("微信小程序绑定大屏")
@AnonymousAccess
public ResultInfo appletBind(@Validated @RequestBody BindBean resources) {
log.info("appletBind ==> input ==> [{}]",resources);
String unionId = resources.getUnionid();
if (StringUtils.isBlank(unionId))
Assert.state(StrUtil.isNotBlank(unionId), "跨屏绑定,请先进行授权");
String platformAccount = resources.getPlatformAccount();
if (Objects.isNull(platformAccount))
Assert.state(StrUtil.isNotBlank(platformAccount), "大屏账户不得为空");
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
resources.setPlatformUserId(userTvDTO.getId());
resources.setPlatformAccount(platformAccount);
boolean result = this.userTvOperationService.appletBind(resources);
return ResultInfo.success(result);
}
@PostMapping("/subscribe")
@ApiOperation("微信公众号关注")
@AnonymousAccess
public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws IOException {
String content = data.getContent();
log.info("subscribe ==> input ==> [{}]",content);
SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class);
this.parseSubscribe(subscribeBean);
boolean result = this.userTvOperationService.subscribe(subscribeBean);
return ResultInfo.success(result);
}
/**
*
* @param subscribeBean
* @throws IOException
*/
private void parseSubscribe(SubscribeBean subscribeBean) throws IOException {
if (Objects.nonNull(subscribeBean)) {
String appId = subscribeBean.getAppId();
// appId不得为空
if (StringUtils.isBlank(appId))
throw new BadRequestException("appId 不存在!");
// openId
String openId = subscribeBean.getOpenId();
if (StringUtils.isBlank(openId))
throw new BadRequestException("openId 不存在!");
// unionId
String unionId = subscribeBean.getUnionid();
if (StringUtils.isBlank(unionId))
throw new BadRequestException("unionId 不存在!");
// 匹配配置文件中的微信列表信息
Map<String, String> wxInfoMap = WeixinUtil.getWeixinInfoByAppid(appId);
if (Objects.nonNull(wxInfoMap)) {
// 程序类型
String appType = wxInfoMap.get("appType");
// 非订阅号,暂不处理。返回暂不支持
if (ObjectUtil.notEqual(appType, WeChatConstants.WX_SUBSCRIPTION))
throw new BadRequestException("非订阅号");
}
// 大屏账户信息
JSONObject iptvUserInfo = null;
// 缓存的大屏信息,使用unionid即可
String content = (String) this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionId));
if (StringUtils.isNotBlank(content)) {
// 大屏信息
iptvUserInfo = JSONObject.parseObject(content);
} else {
String eventKey = subscribeBean.getEventKey();
log.info(" eventKey ==> [{}] ", eventKey);
if (StringUtils.isNotBlank(eventKey)) {
// 用户扫描带参二维码关注。发消息
// 去除固定前缀,获取二维码参数
eventKey = eventKey.substring(8);
iptvUserInfo = JSONObject.parseObject(eventKey);
}
}
// 用户自己搜索关注就没有大屏信息,否则表示扫码关注
if (Objects.nonNull(iptvUserInfo)) {
subscribeBean.setIptvUserInfo(iptvUserInfo);
String headimgurl = iptvUserInfo.get("headimgurl").toString();
String nickname = iptvUserInfo.get("nickname").toString();
if (StringUtils.isNotBlank(nickname)) {
String nicknameDecode = URLDecoder.decode(nickname, "UTF-8");
String nicknameEncode = Base64Util.encode(nicknameDecode);
subscribeBean.setNickname(nicknameEncode);
}
if (StringUtils.isNotBlank(headimgurl)) {
String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8");
subscribeBean.setHeadimgurl(headimgurlDecode);
}
}
}
}
@PostMapping("/unsubscribe")
@ApiOperation("微信公众号取关")
@AnonymousAccess
public ResultInfo unsubscribe(@Validated @RequestBody SubscribeBeanEvent data) {
String content = data.getContent();
log.info("unsubscribe ==> input ==> [{}]",content);
SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class);
boolean result = this.userTvOperationService.unsubscribe(subscribeBean);
return ResultInfo.success(result);
}
/**
* @param data
* @description 通过大屏关注的订阅号,因为订阅号不支持带参二维码,
* 所以需要先跳到H5(带大屏参数),
* 再做服务号授权(订阅号只能按钮触发获取信息),
* 再将服务号信息和大屏参数缓存下来(该接口的功能)
* 然后跳转到订阅号关注页
* 关注后回调处理时,根据unionid进行相关逻辑
*
* 业务场景:
* 1.未关注-绑定
* 新用户
* 2.先关注-绑定
* 1).未绑定
* 2).已绑定
* 2.1).已绑定当前大屏账户
* 2.2).换绑
* 2.2.1).
* @author Hongyan Wang
* @date 2021/8/24 4:54 下午
*/
@PostMapping(value = "/saveUserInfo")
@ApiOperation("保存大屏侧信息")
@AnonymousAccess
public ResultInfo saveUserInfo(@RequestBody String data) {
log.info("saveUserInfo ==> input ==> [{}]",data);
Assert.notNull(data, "用户数据不可为空");
JSONObject json = JSONObject.parseObject(data);
String unionid = json.getString("unionid");
Assert.state(StrUtil.isNotBlank(unionid), "unionid不可为空");
// 大屏侧通过返回值来展示对应的小程序页面
String result = SUBSCRIBE;
// 保存大小屏信息到redis同时返回小屏信息
UserWeixinDTO userWeixinDTO = this.userTvOperationService.saveUserInfo(data);
// 小屏用户不存在或者关注状态为未关注(0),返回未关注
if (Objects.isNull(userWeixinDTO) || Objects.isNull(userWeixinDTO.getId()) || userWeixinDTO.getStatus() != SUBSCRIBE_STATUS) {
result = UNSUBSCRIBE;
return ResultInfo.success(result);
}
/***************************************************************************************/
String platformAccount1 = "";
// 关注未绑定
if (result.equalsIgnoreCase(SUBSCRIBE)) {
// 小屏会员
MemberDTO memberDTO = this.memberService.findById(userWeixinDTO.getMemberId());
// redis中的大小屏信息
String content = (String) this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionid));
JSONObject iptvUserInfo = JSONObject.parseObject(content);
// redis中的大小屏信息
log.info("saveUserInfo ==> redis content iptvUserInfo ==> [{}]",iptvUserInfo);
// 大屏账户
String platformAccount = iptvUserInfo.getString("platformAccount");
try {
String headimgurl = iptvUserInfo.get("headimgurl").toString();
String nickname = iptvUserInfo.get("nickname").toString();
if (StringUtils.isNotBlank(nickname)) {
String nicknameDecode = URLDecoder.decode(nickname, "UTF-8");
String nicknameEncode = Base64Util.encode(nicknameDecode);
memberDTO.setNickname(nicknameEncode);
}
if (StringUtils.isNotBlank(headimgurl)) {
String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8");
memberDTO.setAvatarUrl(headimgurlDecode);
}
}catch (Exception e) {
log.info("headimgurl , nickname ===>> encode error!");
e.printStackTrace();
}
// 大小屏绑定,如果已经绑定了别的大屏,则不进行处理,返回已绑定的大屏信息
// 已绑定的大屏信息
UserTvDTO userTvDTO = this.userOperationService.bind(memberDTO, platformAccount);
if (userTvDTO != null) {
platformAccount1 = userTvDTO.getPlatformAccount();
}
}
/****************************************************************************************/
List<Object> resultList = new ArrayList<>();
resultList.add(result);
resultList.add(platformAccount1);
// return ["subscribe","platform_account"]
ResultInfo<Object> success = ResultInfo.success(resultList);
log.info("saveUserInfo ==> ResultInfo ==> [{}]",success);
return success;
}
/**
*
* @param resources
* @return
*/
@PostMapping(value = "/saveUserWeixinPhone")
@ApiOperation("保存用户手机号信息")
@AnonymousAccess
public ResultInfo saveUserWeixinPhone(@RequestBody WeiXinUserBean resources) {
log.info("saveUserWeixinPhone ==> input ==> [{}]",resources);
MemberProfile s = this.userTvOperationService.saveUserWeixinPhone(resources);
return ResultInfo.success(s);
}
}
package com.topdraw.business.process.service;
import com.topdraw.business.basicdata.coupon.domain.Coupon;
import com.topdraw.business.process.domian.TempCoupon;
import com.topdraw.business.process.domian.TempRights;
import java.util.List;
......
package com.topdraw.business.process.service;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.process.domian.weixin.BuyVipBean;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
public interface MemberOperationService {
......@@ -16,4 +20,9 @@ public interface MemberOperationService {
void doUpdateMemberPoints(Member member);
void doUpdateMemberCoupon(Member member);
MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appid);
MemberDTO buyVip(BuyVipBean buyVipBean);
}
......
package com.topdraw.business.process.service;
import com.topdraw.business.basicdata.points.domain.Points;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.business.process.domian.result.CustomPointsResult;
import java.util.List;
import java.util.Map;
/**
* @description 积分操作接口
......
package com.topdraw.business.process.service;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.business.process.domian.RightType;
import java.util.List;
......
package com.topdraw.business.process.service;
public interface TaskDealService {
}
package com.topdraw.business.process.service;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.process.domian.weixin.BindBean;
import com.topdraw.business.process.domian.weixin.BuyVipBean;
import com.topdraw.business.process.domian.weixin.SubscribeBean;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import java.util.List;
import java.util.Map;
public interface UserOperationService {
/**
* 保存大屏账户并创建会员
* @param resources
* @return
*/
boolean createMemberByUserTv(UserTv resources);
/**
* 大屏解绑
* @param userTv
*/
void unbind(UserTv userTv);
/**
*
* @param userTv
* @param unionId
*/
void unbindByUnionId(UserTv userTv,String unionId);
/**
* 大屏切换主账户(会员)
* @param userTv
*/
void changeMainAccount(UserTv userTv);
/**
*
* @param userTv
* @param unionId
*/
void changeMainAccountByUnionId(UserTv userTv,String unionId);
/**
* 微信小程序登录
* @param resources
* @return
*/
UserWeixinDTO appletLogin(WeiXinUserBean resources);
/**
* 微信公众号关注
* 1.团粉,会员vip=0,则修改为vip=1
* 2.判断是否通过扫描大屏的二维码进行关注的,如果是需要绑定大屏账户,将对应会员中iptvUserId绑定大屏对应的id
* 3.修改微信账户的status字段为1(已关注)
* @param resources
* @return
*/
boolean subscribe(SubscribeBean resources);
/**
* 微信公众号取关
* @param resources
* @return
*/
boolean unsubscribe(SubscribeBean resources);
/**
* 保存账户
* @param data
* @return
*/
UserWeixinDTO saveUserInfo(String data);
/**
* 获取用户授权并解析、保存用户手机号
* @param resources
* @return
*/
MemberProfile saveUserWeixinPhone(WeiXinUserBean resources);
/**
*
* @param content
* @return
*/
boolean sendQrCodeMessage(String content);
/**
* 大屏删除所有收藏
* @param content
* @return
*/
boolean deleteAllCollection(String content);
/**
* 大屏删除收藏
* @param content
* @return
*/
boolean deleteCollection(String content);
/**
* 大屏收藏
* @param content
* @return
*/
boolean addCollection(String content);
/**
* 获取大屏绑定的小屏会员列表
* @param platformAccount
* @return
*/
List<MemberDTO> findBindByPlatformAccount(String platformAccount);
/**
* 服务号(H5)登录
* @param resources
* @return
*/
Object serviceLogin(WeiXinUserBean resources);
/**
* 小程序绑定大屏
* @param resources
* @return
*/
boolean appletBind(BindBean resources);
JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code);
UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources);
void bind(String memberCode, String platformAccount);
void bind(MemberDTO memberDTO, UserTvDTO userTvDTO);
UserTvDTO bind(MemberDTO memberDTO, String platformAccount);
}
package com.topdraw.business.process.service;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
public interface UserTvOperationService {
boolean createMemberByUserTv(UserTv resources);
}
package com.topdraw.business.process.service.builder;
import com.topdraw.business.process.domian.TempCoupon;
public class TempCouponBuilder {
public TempCoupon build(){
TempCoupon tempCoupon = new TempCoupon();
return tempCoupon;
}
}
package com.topdraw.business.process.service.impl;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.util.TimestampUtil;
import org.springframework.util.CollectionUtils;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.task.domain.Task;
import java.util.List;
import java.util.stream.Collectors;
@FunctionalInterface
public interface CompareTaskCondition {
......
package com.topdraw.business.process.service.impl;
import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory;
import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService;
import com.topdraw.business.basicdata.coupon.service.CouponService;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.process.service.CouponOperationService;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.business.process.domian.TempCoupon;
......@@ -19,15 +22,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
@Service
......@@ -44,6 +42,8 @@ public class CouponOperationServiceImpl implements CouponOperationService {
@Autowired
RightsOperationService rightsOperationService;
@Autowired
MemberService memberService;
@Autowired
RedissonClient redissonClient;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
......@@ -52,6 +52,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
private static final Integer EXPIRE_FACTOR_DAY = 30;
@Override
@AsyncMqSend
public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) {
// 优惠券领取、使用历史记录表
for (TempCoupon tempCoupon : tempCouponList) {
......@@ -128,14 +129,23 @@ public class CouponOperationServiceImpl implements CouponOperationService {
* @param expireSoonCouponCount
*/
private void doUpdateMemberInfo(Long memberId, Long currentCoupon, Long expireSoonCouponCount) {
MemberDTO memberDTO = this.findMemberByMemberId(memberId);
Member member = new Member();
member.setId(memberId);
BeanUtils.copyProperties(memberDTO,member);
member.setCouponAmount(currentCoupon);
member.setDueCouponAmount(expireSoonCouponCount);
member.setUpdateTime(TimestampUtil.now());
member.setUpdateTime(LocalDateTime.now());
this.memberOperationService.doUpdateMemberInfo(member);
}
private MemberDTO findMemberByMemberId(Long memberId) {
MemberDTO memberDTO = this.memberService.findById(memberId);
return memberDTO;
}
/**
* 当前优惠券数量 = 总优惠券-已过期的优惠券
......@@ -154,8 +164,8 @@ public class CouponOperationServiceImpl implements CouponOperationService {
* @return
*/
private Long getTotalExpireSoonCoupon(Long userId, Integer expireFactor) {
Timestamp expireTime = TimestampUtil.localDateTime2Timestamp(LocalDateTime.now().plusDays(expireFactor));
return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,TimestampUtil.now(),expireTime);
LocalDateTime expireTime = LocalDateTime.now().plusDays(expireFactor);
return this.couponHistoryService.countByUserIdAndExpireTimeBetween(userId,LocalDateTime.now(),expireTime);
}
......@@ -165,7 +175,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
* @return
*/
private Long getTotalExpireCoupon(Long userId) {
return this.couponHistoryService.countByUserIdAndExpireTimeBefore(userId,TimestampUtil.now());
return this.couponHistoryService.countByUserIdAndExpireTimeBefore(userId,LocalDateTime.now());
}
......@@ -192,7 +202,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
couponHistory.setCouponCode(tempCoupon.getCode());
couponHistory.setUserNickname(tempCoupon.getUserNickname());
couponHistory.setOrderDetailId(tempCoupon.getOrderId());
couponHistory.setReceiveTime(TimestampUtil.now());
couponHistory.setReceiveTime(LocalDateTime.now());
couponHistory.setUseStatus(Objects.nonNull(couponHistory.getUseStatus()) ? couponHistory.getUseStatus():0);
this.couponHistoryService.create(couponHistory);
}
......
package com.topdraw.business.process.service.impl;
import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail;
import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.level.service.MemberLevelService;
import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.ExpDetailService;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.level.service.MemberLevelService;
import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.process.service.ExpOperationService;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.business.process.domian.TempExp;
......@@ -23,7 +25,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
......@@ -42,11 +44,14 @@ public class ExpOperationServiceImpl implements ExpOperationService {
@Autowired
MemberLevelService memberLevelService;
@Autowired
MemberService memberService;
@Autowired
RedissonClient redissonClient;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
@AsyncMqSend
public void grantPointsThroughTempExp(List<TempExp> tempExpList) {
for (TempExp tempExp : tempExpList) {
......@@ -138,14 +143,22 @@ public class ExpOperationServiceImpl implements ExpOperationService {
* @param memberId 会员id
*/
private void updateMemberInfo(Integer level,Long totalExp,Long memberId) {
MemberDTO memberDTO = this.findMemberByMemberId(memberId);
Member member = new Member();
member.setId(memberId);
BeanUtils.copyProperties(memberDTO,member);
member.setExp(totalExp);
member.setLevel(level);
member.setUpdateTime(TimestampUtil.now());
member.setUpdateTime(LocalDateTime.now());
this.memberOperationService.doUpdateMemberInfo(member);
}
private MemberDTO findMemberByMemberId(Long memberId) {
MemberDTO memberDTO = this.memberService.findById(memberId);
return memberDTO;
}
private Integer compareExp(long newExp, MemberLevelDTO memberLevelDTO,MemberDTO memberDTO) {
if (Objects.nonNull(memberLevelDTO)) {
Long nextLevelExp = memberLevelDTO.getExpValue();
......
package com.topdraw.business.process.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import cn.hutool.core.util.ObjectUtil;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.process.domian.weixin.BuyVipBean;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import com.topdraw.business.process.service.MemberOperationService;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.util.LocalDateTimeUtil;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.StringUtils;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Base64;
import java.util.Objects;
import java.util.Optional;
import static org.bouncycastle.asn1.x500.style.RFC4519Style.member;
@Service
public class MemberOperationServiceImpl implements MemberOperationService {
@Autowired
MemberService memberService;
private MemberService memberService;
@Autowired
private MemberProfileService memberProfileService;
@Autowired
private MemberVipHistoryService memberVipHistoryService;
@Autowired
private UserWeixinService userWeixinService;
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
public MemberDTO buyVip(BuyVipBean criteria) {
// 小程序账户id
Long id = criteria.getId();
// 过期时间
LocalDateTime vipExpireTime1 = criteria.getVipExpireTime();
Integer vip1 = criteria.getVip();
// 查询微信账户
UserWeixinDTO userWeixin = this.findWeiXinById(id);
Long memberId = userWeixin.getMemberId();
//
MemberDTO memberDTO = this.findById(memberId);
Integer vip = memberDTO.getVip();
//
LocalDateTime vipExpireTime = memberDTO.getVipExpireTime();
if (Objects.nonNull(vipExpireTime1)) {
vipExpireTime = vipExpireTime1;
}
//判断之前有没有买过,没买过,失效时间为一年后;
if (Objects.isNull(vipExpireTime1)) {
if (ObjectUtil.isNull(vipExpireTime)) {
LocalDateTime now = LocalDateTime.now();
vipExpireTime = now.plusYears(1L);
} else {
vipExpireTime = vipExpireTime.plusYears(1L);
}
}
memberDTO.setVip(vip1);
memberDTO.setVipExpireTime(vipExpireTime);
/*if (){
//购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年
//区分是当前vip续费 还是买新的vip
if (ObjectUtil.equal(vip1, memberDTO.getVip())) {
if (now.isBefore(vipExpireTime)) {
LocalDateTime localDateTime = vipExpireTime.plusYears(1L);
memberDTO.setVipExpireTime(localDateTime);
} else {
LocalDateTime localDateTime = now.plusYears(1L);
memberDTO.setVipExpireTime(localDateTime);
}
} else {
LocalDateTime localDateTime = now.plusYears(1L);
memberDTO.setVipExpireTime(localDateTime);
}
}*/
Member member = new Member();
BeanUtils.copyProperties(memberDTO,member);
this.memberService.create(member);
MemberVipHistory memberVipHistory = new MemberVipHistory();
memberVipHistory.setMemberId(memberId).setVip(vip1).setBeforeVip(vip);
if (ObjectUtil.equal(vip1,vip)) {
memberVipHistory.setStatus(1);
}
memberVipHistory.setVipExpireTime(member.getVipExpireTime());
memberVipHistoryService.create(memberVipHistory);
return memberDTO;
}
private UserWeixinDTO findWeiXinById(Long id) {
UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id);
if (Objects.isNull(userWeixinDTO)) {
throw new EntityNotFoundException(UserWeixin.class, "id", userWeixinDTO.getId().toString());
}
return userWeixinDTO;
}
@Override
public void doUpdateMemberInfo(Member member) {
......@@ -50,4 +159,142 @@ public class MemberOperationServiceImpl implements MemberOperationService {
public void doUpdateMemberCoupon(Member member) {
this.doUpdateMemberInfo(member);
}
@Override
public MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appid) {
// 会员加密信息
MemberProfileDTO memberProfileDTO_0 = this.findMemberProfileByMemberId(memberId);
// 会员信息
MemberDTO memberDTO = this.findById(memberId);
// 初始化会员加密信息
MemberProfileDTO memberProfileDTO_1 = this.configMemberProfile(memberProfileDTO_0,memberDTO,appid);
return memberProfileDTO_1;
}
/**
* 配置会员信息
* @param memberProfileDTO_0
* @param memberDTO
* @return
*/
private MemberProfileDTO configMemberProfile(MemberProfileDTO memberProfileDTO_0, MemberDTO memberDTO, String appid) {
if (Objects.isNull(memberProfileDTO_0)) return memberProfileDTO_0;
MemberProfileDTO memberProfileDTO = new MemberProfileDTO();
BeanUtils.copyProperties(memberProfileDTO_0,memberProfileDTO);
/*// 真实姓名
String realname = memberProfileDTO.getRealname();
if (StringUtils.isNotBlank(realname)) {
realname = new String(Base64.getEncoder().encode(realname.getBytes(StandardCharsets.UTF_8)));
}
// 昵称
String nickname = memberDTO.getNickname();
if (StringUtils.isNotBlank(nickname)) {
nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8)));
}*/
// vip
Integer vip = memberDTO.getVip();
// 过期时间
LocalDateTime vipExpireTime = memberDTO.getVipExpireTime();
Long timeLong = 0L;
if (ObjectUtil.isNotNull(vipExpireTime)) {
// 检查vip
MemberDTO memberDTO1 = this.checkVipStatus(memberDTO,vipExpireTime,appid);
// 更新会员信息
this.threadPoolTaskExecutor.execute(()->{
Member member = new Member();
BeanUtils.copyProperties(memberDTO1,member);
this.memberService.update(member);
});
vip = memberDTO1.getVip();
LocalDateTime vipExpireTime1 = memberDTO1.getVipExpireTime();
if (Objects.nonNull(vipExpireTime1)) {
timeLong = vipExpireTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
}
}
// 过期时间
memberProfileDTO.setVipExpireTime(timeLong);
// 真实姓名
// memberProfileDTO.setRealname(realname);
// 头像
memberProfileDTO.setAvatarUrl(memberDTO.getAvatarUrl());
// 生日
memberProfileDTO.setBirthdayStr(memberDTO.getBirthday());
// 性别
memberProfileDTO.setGender(memberDTO.getGender());
// 昵称
// memberProfileDTO.setNickname(nickname);
// 会员id
memberProfileDTO.setMemberId(memberDTO.getId());
// vip
memberProfileDTO.setVip(vip);
return memberProfileDTO;
}
/**
* 检查vip是否过期
* 1.当前vip如果过期则查看是否有vip历史变动
* 2.如果vip变动历史有记录则获取vip变动记录
* 3.如果vip没有记录则查看是否关注了公众号
* @param vipExpireTime
* @return
*/
private MemberDTO checkVipStatus(MemberDTO memberDTO,LocalDateTime vipExpireTime, String appid) {
Long memberId = memberDTO.getId();
LocalDateTime nowTime = LocalDateTime.now();
//vip过期,回退上个vip状态 同时修改member表vip
if (nowTime.compareTo(vipExpireTime) >= 0 ) {
Integer vip = 0;
LocalDateTime vipExpireTime1 = memberDTO.getVipExpireTime();
//查询小于失效时间的那条记录 查不到 取微信表里 关注状态
MemberVipHistory memberVipHistory = this.memberVipHistoryService.findByTime(memberId, nowTime);
if (ObjectUtil.isNull(memberVipHistory.getId())) {
UserWeixinDTO userWeixin = this.userWeixinService.findFirstByMemberIdAndAppid(memberId, appid);
// 微信公众号关注的状态 0:未关注 1:关注
Integer status = userWeixin.getStatus();
if (status != 1) vip = 0; else vip = 1;
vipExpireTime1 = null;
} else {
vip = memberVipHistory.getVip();
vipExpireTime1 = memberVipHistory.getVipExpireTime();
}
memberDTO.setVipExpireTime(vipExpireTime1);
memberDTO.setVip(vip);
}
return memberDTO;
}
/**
* 查询会员加密信息
* @param memberId
* @return
*/
private MemberProfileDTO findMemberProfileByMemberId(Long memberId) {
return this.memberProfileService.findByMemberId(memberId);
}
}
......
......@@ -2,18 +2,16 @@ package com.topdraw.business.process.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.basicdata.points.detail.detailhistory.service.PointsDetailHistoryService;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.basicdata.points.detail.service.PointsDetailService;
import com.topdraw.business.basicdata.points.service.PointsService;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.detail.detailhistory.service.PointsDetailHistoryService;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.module.points.service.PointsService;
import com.topdraw.business.process.domian.result.CustomPointsResult;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.business.process.service.PointsOperationService;
......@@ -22,7 +20,6 @@ import com.topdraw.util.IdWorker;
import com.topdraw.util.RedissonUtil;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.StringUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
......@@ -30,20 +27,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
......@@ -304,6 +296,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList){
log.info("------->>grantPointsThroughTempRightsList start1");
for (TempPoints tempPoints : tempPointsList){
......@@ -505,12 +498,15 @@ public class PointsOperationServiceImpl implements PointsOperationService {
* @param currentPoints 当前总积分
*/
private void freshMemberCurrentPoints(Long memberId, Long currentPoints,long duePoints,TempPoints tempPoints) {
MemberDTO memberDTO = this.findMemberByMemberId(memberId);
Member member = new Member();
member.setId(memberId);
BeanUtils.copyProperties(memberDTO,member);
member.setPoints(Objects.nonNull(currentPoints)?currentPoints:0);
member.setDuePoints(duePoints);
member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now()));
member.setCode(tempPoints.getMemberCode());
member.setUpdateTime(LocalDateTime.now());
try {
this.memberOperationService.doUpdateMemberPoints(member);
} catch (Exception e){
......@@ -518,6 +514,11 @@ public class PointsOperationServiceImpl implements PointsOperationService {
}
}
private MemberDTO findMemberByMemberId(Long memberId) {
MemberDTO memberDTO = this.memberService.findById(memberId);
return memberDTO;
}
/**
* 计算当前总积分
* @param memberId 会员id
......
package com.topdraw.business.process.service.impl;
import com.topdraw.business.basicdata.coupon.service.CouponService;
import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService;
import com.topdraw.business.basicdata.rights.service.RightsService;
import com.topdraw.business.basicdata.rights.service.dto.RightsDTO;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.service.RightsHistoryService;
import com.topdraw.business.module.rights.service.RightsService;
import com.topdraw.business.module.rights.service.dto.RightsDTO;
import com.topdraw.business.process.service.CouponOperationService;
import com.topdraw.business.process.service.ExpOperationService;
import com.topdraw.business.process.service.PointsOperationService;
......@@ -16,7 +16,6 @@ import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
......@@ -103,6 +102,8 @@ public class RightsOperationServiceImpl implements RightsOperationService {
rightsHistory.setRightsId(value.getId());
rightsHistory.setMemberId(value.getMemberId());
rightsHistory.setExpireTime(value.getExpireTime());
String memberCode = value.getMemberCode();
rightsHistory.setMemberCode(memberCode);
rightsHistoryList.add(rightsHistory);
});
......@@ -124,9 +125,7 @@ public class RightsOperationServiceImpl implements RightsOperationService {
* @param tempPointsList 权益列表
*/
private void grantPoint(List<TempPoints> tempPointsList) {
log.info(Thread.currentThread().getName() + "=========>>grantPoint start");
if (!CollectionUtils.isEmpty(tempPointsList))
log.info("=======>> tempPointsList ======>> " + tempPointsList.toString());
this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList);
}
......
package com.topdraw.business.process.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.business.basicdata.coupon.service.CouponService;
import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO;
import com.topdraw.business.basicdata.member.group.service.MemberGroupService;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupDTO;
import com.topdraw.business.basicdata.member.group.service.dto.MemberGroupQueryCriteria;
import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.basicdata.rights.service.RightsService;
import com.topdraw.business.basicdata.rights.service.dto.RightsDTO;
import com.topdraw.business.basicdata.task.progress.domain.TrTaskProgress;
import com.topdraw.business.basicdata.task.progress.service.TrTaskProgressService;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.basicdata.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.member.group.service.MemberGroupService;
import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.module.rights.service.RightsService;
import com.topdraw.business.module.rights.service.dto.RightsDTO;
import com.topdraw.business.module.task.attribute.service.TaskAttrService;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.process.domian.result.TaskTemplateType;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.business.process.service.RightsOperationService;
import com.topdraw.business.process.service.TaskOperationService;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.task.domain.Task;
import com.topdraw.business.basicdata.task.service.TaskService;
import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
import com.topdraw.business.basicdata.task.template.service.TaskTemplateService;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.service.TaskTemplateService;
import com.topdraw.business.process.domian.*;
import com.topdraw.business.process.service.UserTvOperationService;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.exception.BadRequestException;
import com.topdraw.module.mq.DataSyncMsg;
import com.topdraw.util.*;
import lombok.extern.slf4j.Slf4j;
......@@ -40,6 +45,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
......@@ -76,6 +82,10 @@ public class TaskOperationServiceImpl implements TaskOperationService {
CouponService couponService;
@Autowired
MemberGroupService memberGroupService;
@Autowired
TaskAttrService taskAttrService;
@Autowired
UserTvService userTvService;
private static final Integer TASK_FINISH_STATUS = 1;
......@@ -89,9 +99,12 @@ public class TaskOperationServiceImpl implements TaskOperationService {
DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg();
Integer event = msgData.getEvent();
String memberCode = msgData.getMemberCode();
Long memberId = msgData.getMemberId();
long l = System.currentTimeMillis();
if (StringUtils.hasText(memberCode)) {
MemberDTO memberDTO = this.memberService.getByCode(memberCode);
memberId = memberDTO.getId();
}
// 检查当前会员的黑名单状态
boolean b = this.validatedMemberBlackStatus(memberId);
......@@ -100,25 +113,38 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
// 1.通过任务标识获取任务模板,通过模板参数获取具体的模板
TaskTemplate taskTemplate = this.getTaskTemplate(event);
TaskTemplate taskTemplate = this.getTaskTemplate(event,dataSyncMsg);
// 2.通过任务模板获取对应的任务列表
List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate);
List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate,dataSyncMsg);
// 4.判断当前用户是否满足任务完成条件
boolean checkResult = this.checkTaskCompletion(memberId,taskList);
if (checkResult) {
// 5.权益区分(积分、权益、成长值)
Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId,taskList,msgData);
// 6.权益发放
// 6.风控检查
boolean result = this.checkRiskManagement(memberId,tempRightsMap);
if (result) throw new BadRequestException("发放失败,已达风控上限");
// 7.权益发放
this.grantRight(tempRightsMap);
}
long r = System.currentTimeMillis();
log.info("总耗时======>>>>>" + (r-l));
System.out.println(taskList);
return ResultInfo.success();
}
/**
* 风控检查
* @param memberId
* @param tempRightsMap
* @return
*/
private boolean checkRiskManagement(Long memberId , Map<RightType, Object> tempRightsMap) {
// TODO 风控
return false;
}
/**
......@@ -139,40 +165,6 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
/**
* 永久权益
* @param memberId 会员id
* @return PermanentRightsDTO 永久权益
*/
@Deprecated
private PermanentRightsDTO getPermanentRights(Long memberId) {
PermanentRightsDTO permanentRights = null;
MemberDTO memberDTO = this.memberService.findById(memberId);
if (Objects.nonNull(memberDTO)) {
Integer level = memberDTO.getLevel();
// 永久权益
permanentRights = this.permanentRightsService.findByLevel(level);
}
return permanentRights;
}
/**
* 解析模板参数
* @param taskTemplate 任务模板
* @return Map<String, Object> 模板参数解析结果
*/
@Deprecated
private Map<String, Object> parseTaskTemplateParam(TaskTemplate taskTemplate) {
if (Objects.nonNull(taskTemplate)) {
String params = taskTemplate.getParams();
if (!StringUtils.isEmpty(params)) {
Map paramMap = JSONObject.parseObject(params,Map.class);
return paramMap;
}
}
return null;
}
/**
* 任务完成情况
* @param resources 任务完成情况
*/
......@@ -224,6 +216,34 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
private Long getIptvPriorityMemberId(Long memberId1,DataSyncMsg.MsgData msgData) {
//
if (Objects.nonNull(memberId1)) {
return memberId1;
}
@NotNull Integer deviceType = msgData.getDeviceType();
Long userId = msgData.getUserId();
// 大屏
if (Objects.nonNull(userId) || deviceType == 1) {
}
MemberDTO memberDTO = this.findMemberById(memberId1);
if (Objects.nonNull(memberDTO.getId())) {
Long userIptvId = memberDTO.getUserIptvId();
// 绑定了大屏,直接返回小屏会员id
if (Objects.nonNull(userIptvId)) {
return memberDTO.getId();
} else {
//
}
}
return null;
}
/**
* 验证是否满足永久权益
* @param permanentRights
......@@ -271,13 +291,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
/**
* 创建权益
* @param memberId
* @param memberCode
* @param rightsAmount
* @return
*/
private TempRights tmpRightsBuild(Long memberId ,Integer rightsAmount,RightsDTO rightsDTO){
private TempRights tmpRightsBuild(Long memberId ,String memberCode,Integer rightsAmount,RightsDTO rightsDTO){
TempRights tempRights = new TempRights();
BeanUtils.copyProperties(rightsDTO,tempRights);
tempRights.setMemberId(memberId);
tempRights.setMemberCode(memberCode);
tempRights.setRightsAmount(rightsAmount);
Long expireTime = rightsDTO.getExpireTime();
if (Objects.nonNull(expireTime))
......@@ -288,14 +310,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
/**
* 优惠券
* @param memberId
* @param rightsAmount
* @param memberCode
* @param rightsSendStrategy
* @return
*/
private TempCoupon tempCouponBuild(Long memberId ,Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){
private TempCoupon tempCouponBuild(Long memberId ,String memberCode , Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){
TempCoupon tempCoupon = new TempCoupon();
BeanUtils.copyProperties(couponDTO,tempCoupon);
tempCoupon.setCode(couponDTO.getCode());
tempCoupon.setMemberCode(memberCode);
tempCoupon.setMemberId(memberId);
tempCoupon.setRightsAmount(rightsAmount);
tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy);
......@@ -377,12 +400,13 @@ public class TaskOperationServiceImpl implements TaskOperationService {
Long memberId = memberDTO.getId();
String nickname = memberDTO.getNickname();
String memberCode = memberDTO.getCode();
// 权益详情
RightsDTO rightsDTO = this.getRight(rightsId);
if (Objects.nonNull(rightsDTO)){
// 用以保存权益历史
TempRights tempRights = this.tmpRightsBuild(memberId,rightsAmount,rightsDTO);
TempRights tempRights = this.tmpRightsBuild(memberId,memberCode,rightsAmount,rightsDTO);
rightsList.add(tempRights);
// 权益类型
......@@ -394,7 +418,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
CouponDTO couponDTO = this.findCouponById(entityId);
if (Objects.nonNull(couponDTO)) {
// 优惠券
TempCoupon tempCoupon = this.tempCouponBuild(memberId, rightsAmount, rightsSendStrategy, couponDTO, nickname);
TempCoupon tempCoupon = this.tempCouponBuild(memberId, memberCode,rightsAmount, rightsSendStrategy, couponDTO, nickname);
tempCouponList.add(tempCoupon);
}
}
......@@ -435,6 +459,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
tempExp.setMemberId(memberId);
tempExp.setAppCode(msgData.getAppCode());
tempExp.setMemberId(msgData.getMemberId());
tempExp.setMemberCode(msgData.getMemberCode());
tempExp.setItemId(msgData.getItemId());
tempExp.setAccountId(msgData.getAccountId());
tempExp.setRewardExp(task.getRewardExp());
......@@ -473,6 +498,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
tempPoints.setRewardPointsExpireTime(rewardPointsExpireTime);
tempPoints.setMemberId(memberId);
tempPoints.setMemberCode(msgData.getMemberCode());
tempPoints.setAppCode(msgData.getAppCode());
tempPoints.setPoints(rewardPoints);
tempPoints.setPointsType(pointsType);
......@@ -763,17 +789,96 @@ public class TaskOperationServiceImpl implements TaskOperationService {
* @param taskTemplate 任务模板
* @return List<task> 任务列表
*/
private List<Task> loadListTaskByTaskTemplate(TaskTemplate taskTemplate,Map<String,Object> paramMap) {
private List<Task> loadListTaskByTaskTemplate(TaskTemplate taskTemplate,DataSyncMsg dataSyncMsg) {
if (Objects.nonNull(taskTemplate)) {
Long taskTemplateId = taskTemplate.getId();
return this.taskService.findByTemplateId(taskTemplateId);
List<Task> taskList = this.taskService.findByTemplateId(taskTemplateId);
Integer type = taskTemplate.getType();
taskList = this.pickUpTask(taskList,dataSyncMsg,type);
return taskList;
}
return null;
}
/**
* 通过参数确定具体任务
* @param taskList
* @param dataSyncMsg
* @return
*/
private List<Task> pickUpTask(List<Task> taskList,DataSyncMsg dataSyncMsg,Integer type) {
List<Task> taskList1 = new ArrayList<>();
DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg();
if (Objects.nonNull(msgData)) {
String param = msgData.getParam();
Map<String,String> jsonObjectMap = JSONObject.parseObject(param,Map.class);
Collection<String> values = jsonObjectMap.values();
for (Task task : taskList) {
Long taskId = task.getId();
TaskAttrDTO taskAttrDTO = this.findTaskAttrByTaskId(taskId);
if (Objects.isNull(taskAttrDTO.getId()))
continue;
String attrStr = taskAttrDTO.getAttrStr();
if (StringUtils.hasText(attrStr)) {
JSONObject jsonObject = JSONObject.parseObject(attrStr);
JSONArray values_0 = jsonObject.getJSONArray("value");
switch (type) {
// 登录
case TaskTemplateType.TYPE_1:
Integer o1 = (Integer)values_0.get(0);
Integer o2 = (Integer)values_0.get(1);
List<Integer> list = Arrays.asList(o1, o2);
String s = values.toArray()[0].toString();
Integer i = Integer.valueOf(s);
boolean b = UcListUtils.compareIntegerList(i, list);
if (b)
taskList1.add(task);
break;
// 订购
case TaskTemplateType.TYPE_4:
if (values_0.containsAll(values))
taskList1.add(task);
break;
default:
break;
}
}
}
} else {
return taskList;
}
return taskList1;
}
private TaskAttrDTO findTaskAttrByTaskId(Long taskId) {
return this.taskAttrService.findByTaskId(taskId);
}
/**
* 获取任务模板对应的任务列表
*
* @param taskTemplate 任务模板
......@@ -794,24 +899,67 @@ public class TaskOperationServiceImpl implements TaskOperationService {
* @param event 任务
* @return TaskTemplate 任务模板
*/
private TaskTemplate getTaskTemplate(Integer event) {
return this.taskTemplateService.findByType(event);
private TaskTemplate getTaskTemplate(Integer event,DataSyncMsg msgData) {
DataSyncMsg.MsgData msg = msgData.getMsg();
if (Objects.nonNull(msg)) {
return this.findByTypeAndParam(event,msg);
} else {
List<TaskTemplate> taskTemplateList = this.taskTemplateService.findByType(event);
if (!CollectionUtils.isEmpty(taskTemplateList)) {
return taskTemplateList.get(0);
} else {
return null;
}
}
}
private TaskTemplate findByTypeAndParam(Integer event, DataSyncMsg.MsgData taskTemplateParam) {
String param = taskTemplateParam.getParam();
if (StringUtils.hasText(param)) {
Map<String,String> jsonObject = JSONObject.parseObject(param,Map.class);
List<TaskTemplate> taskTemplateList = this.taskTemplateService.findByType(event);
if (!CollectionUtils.isEmpty(taskTemplateList)) {
for (TaskTemplate taskTemplate : taskTemplateList) {
String templateParams = taskTemplate.getParams();
if(StringUtils.hasText(templateParams)) {
String templateParamsUpperCase = templateParams.toUpperCase();
boolean b = jsonObject.containsKey(templateParamsUpperCase);
if (b)
return taskTemplate;
}
}
}
}
return null;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Autowired
UserTvService userTvService;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private PointsOperationService pointsOperationService;
@Autowired
private UserTvOperationService userTvOperationService;
private UserOperationService userTvOperationService;
private UserTv checkUserTv(String platformAccount){
UserTv userTv = new UserTv();
......@@ -825,6 +973,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
@Override
@Deprecated
public boolean createPoint2ChongQing(String platformAccount, Long points) {
boolean result = this.verificationActivity(platformAccount);
......@@ -847,7 +996,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
tempPoints.setMemberId(memberId);
tempPoints.setMemberCode(code);
tempPoints.setPoints(points);
tempPoints.setDescription("重庆重数大屏积分兑换活动,时间:202112");
// tempPoints.setDescription("重庆重数大屏积分兑换活动,时间:202112");
tempPoints.setDeviceType(1);
tempPoints.setEvtType(3);
tempPoints.setPointsType(0);
......
package com.topdraw.business.process.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.domain.MemberBuilder;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.domain.MemberProfileBuild;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.user.iptv.domain.UserConstant;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository;
import com.topdraw.business.module.user.weixin.collection.service.UserCollectionDetailService;
import com.topdraw.business.module.user.weixin.collection.service.UserCollectionService;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.process.domian.weixin.*;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper;
import com.topdraw.config.LocalConstants;
import com.topdraw.config.RedisKeyUtil;
import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.security.AESUtil;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.StringUtils;
import com.topdraw.weixin.beans.*;
import com.topdraw.weixin.beans.config.WeiXinAppListConfig;
import com.topdraw.weixin.util.WeChatConstants;
import com.topdraw.weixin.util.WeiXinRequestUtil;
import com.topdraw.weixin.util.WeixinUtil;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
@Slf4j
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserOperationServiceImpl implements UserOperationService {
@Autowired
private MemberService memberService;
@Autowired
private UserTvService userTvService;
@Autowired
private UserWeixinService userWeixinService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private WeiXinAppListConfig weiXinAppListConfig;
@Autowired
private MemberProfileService memberProfileService;
@Autowired
private WeiXinRequestUtil weixinRequestUtil;
@Autowired
private UserCollectionService userCollectionService;
@Autowired
private UserCollectionDetailService userCollectionDetailService;
@Autowired
private UserCollectionDetailRepository userCollectionDetailRepository;
@Autowired
private CollectionMq2DetailMapper collectionMq2DetailMapper;
@Autowired
private UserWeixinRepository userWeixinRepository;
@Autowired
private MemberVipHistoryService memberVipHistoryService;
/** 取消关注 */
private static final Integer UNSUBSCRIBE_STATUS = 0;
private static final Integer SUBSCRIBE_STATUS = 1;
private static final String SUBSCRIBE = "subscribe";
private static final String UNSUBSCRIBE = "unsubscribe";
private static final Integer[] PLATFORM_LIST = new Integer[]{0,1,2,3};
private static final Integer[] IPTV_MAJOR = new Integer[]{0,1};
private static final String QR_CODE_URL = "QR_CODE_URL_";
@Value("${uc.service.platform:}")
private String platform;
@Value("${key:}")
private String key;
@Value("${uc.app.subAppId:wx05f35931270014be}")
private String subAppId;
@Value("${uc.app.h5AppId:wxca962918dfeed88c}")
private String h5AppId;
@Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
private String appletAppid;
@Value("${file.upload:upload}")
private String filePath;
/**
* 微信公众号关注
* 1.未扫描大屏二维码
* 1). 保存、修改小屏账户,创建小屏账户会员
* 2.扫描大屏二维码
* 1). 从redis中获取大屏信息
* 2). 大屏账户保存小屏会员的code
* 3). 小屏会员中保存大屏的id
* @description 大小屏绑定,大屏账户保存小屏会员编码
* @param resources
* @return
*/
@Override
public boolean subscribe(SubscribeBean resources) {
String unionId = resources.getUnionid();
String appId = resources.getAppId();
String openId = resources.getOpenId();
String nickname = resources.getNickname();
String headImgUrl = resources.getHeadimgurl();
// 小屏账户
UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId);
if (Objects.isNull(userWeixinDTO.getId())) {
DefaultWeiXinBeanDefinition weiXinBeanDefinition = new DefaultWeiXinBeanDefinition();
weiXinBeanDefinition.setUnionId(unionId);
weiXinBeanDefinition.setAppid(appId);
weiXinBeanDefinition.setOpenId(openId);
weiXinBeanDefinition.setNickname(nickname);
weiXinBeanDefinition.setHeadImgUrl(headImgUrl);
// 创建会员和账户
this.doCreateUserWeiXinAndMember(weiXinBeanDefinition);
} else {
// 修改账户和会员信息
this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId,headImgUrl,nickname);
}
// 大屏信息
JSONObject iptvUserInfo = resources.getIptvUserInfo();
if (Objects.nonNull(iptvUserInfo)) {
// 小屏会员
MemberDTO memberDTO = this.findMemberByAppIdAndOpenId(appId,openId);
// 账户
String platformAccount = iptvUserInfo.getString("platformAccount");
this.bind(memberDTO,platformAccount);
}
// 关注历史记录,用于恢复VIP等级(0:普通 1:团粉 其他:会员(过期后vip恢复到最高等级))
this.doInsertSubscribeHistory(appId,openId,WeChatConstants.EVENT_SUBSCRIBE);
return true;
}
/**
*
* @param appId
* @param openId
*/
private void doInsertSubscribeHistory(String appId, String openId,String event) {
// 小屏会员
MemberDTO member = this.findMemberByAppIdAndOpenId(appId,openId);
MemberVipHistory memberVipHistory = new MemberVipHistory();
memberVipHistory.setMemberId(member.getId()).setStatus(1);
//小屏侧,理论上大屏不会收到该事件
if (WeChatConstants.EVENT_SUBSCRIBE.equals(event)) {//关注
memberVipHistory.setVip(1);
if (member.getVip() == 0) {
member.setVip(1);
memberVipHistory.setBeforeVip(0);
}
} else if (WeChatConstants.EVENT_UNSUBSCRIBE.equals(event)) {// 取消关注
memberVipHistory.setVip(0);
if (member.getVip() == 1) {
member.setVip(0);
memberVipHistory.setBeforeVip(1);
}
}
memberVipHistory.setVipExpireTime(LocalDateTime.now());
memberVipHistoryService.create(memberVipHistory);
}
/**
* 获取小屏账户
* @param unionId
* @param appId
* @param openId
* @return
*/
private UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId( String unionId,String appId, String openId) {
return this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId,openId);
}
/**
*
* @param userWeixinDTO
* @param appId
* @param openId
*/
private void doUpdateUserWeiXinAndMember(UserWeixinDTO userWeixinDTO,String appId,String openId,String headImgUrl,String nickName) {
userWeixinDTO.setAppid(appId);
userWeixinDTO.setOpenid(openId);
userWeixinDTO.setNickname(nickName);
userWeixinDTO.setHeadimgurl(headImgUrl);
// 修改微信账户关注状态
this.doUpdateUserWeiXinStatus(userWeixinDTO,SUBSCRIBE_STATUS);
// 小屏会员
MemberDTO memberDTO_0 = this.findMemberByAppIdAndOpenId(appId,openId);
if (StringUtils.isNotBlank(headImgUrl) && StringUtils.isNotBlank(nickName)) {
memberDTO_0.setAvatarUrl(headImgUrl);
memberDTO_0.setNickname(nickName);
}
this.doUpdateMemberVip(memberDTO_0,1);
}
/**
* 创建会员和账户
* @param weiXinBeanDefinition
*/
private void doCreateUserWeiXinAndMember(DefaultWeiXinBeanDefinition weiXinBeanDefinition) {
// 小屏账户
UserWeixin userWeixin = this.generateUserWeiXin(weiXinBeanDefinition,SUBSCRIBE_STATUS);
// 保存会员
// Long memberId = this.doCreateMember(userWeixin,1);
Member member = this.doCreateMemberAndReturnMember(userWeixin,1);
if (Objects.isNull(member.getId())) {
throw new BadRequestException("会员创建保存失败");
}
// 保存或者修改,微信账户信息
this.doCreateUserWeiXin(userWeixin,member);
}
/**
* 获取小屏会员
* @param appId
* @param openId
* @return
*/
private MemberDTO findMemberByAppIdAndOpenId(String appId, String openId) {
UserWeixinDTO userWeixinDTO = this.findUserWeiXinByOpenIdAndAppId(appId, openId);
if (Objects.nonNull(userWeixinDTO)) {
Long memberId = userWeixinDTO.getMemberId();
return this.findMemberById(memberId);
}
return null;
}
/**
* 微信公众号取消关注
* @param resources
* @return
*/
@Override
public boolean unsubscribe(SubscribeBean resources) {
String appId = resources.getAppId();
String openId = resources.getOpenId();
// 修改关注状态 0:未关注
UserWeixinDTO userWeixinDTO = this.doUpdateUserWeiXinStatus(appId, openId, UNSUBSCRIBE_STATUS);
// 会员
MemberDTO memberDTO = this.findMemberByUserWeixinDTO(userWeixinDTO);
// 修改会员vip,如果没有购买会员则取消团粉
this.doUpdateMemberVip(memberDTO,0);
// 关注历史记录
this.doInsertSubscribeHistory(appId,openId,WeChatConstants.EVENT_UNSUBSCRIBE);
return true;
}
/**
* 更新大屏信息,同时判断是否已经关注,如果关注了则不跳转H5页面
* @param data
* @return
*/
@Override
public UserWeixinDTO saveUserInfo(String data) {
log.info("result ====>> [{}]",data);
JSONObject json = JSONObject.parseObject(data);
String unionId = json.getString("unionid");
// 订阅号appid
String appId = json.getString("dyAppid");
try {
// 过期时间300S
this.redisUtils.set(RedisKeyUtil.genSeSuSubscribeKey(unionId), data, 300);
Object o = this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionId));
String contentJsonStr = JSON.toJSONString(o);
log.info("H5 save in redis contentJsonStr ====>> [{}]",contentJsonStr);
// 若未传dyAppId。不走下面的流程
if (StrUtil.isNotBlank(appId)) {
UserWeixinDTO userWeixinDTO = this.findUserWeiXinByUnionIdAndAppId(unionId,appId);
return userWeixinDTO;
}
} catch (Exception e) {
log.error(" saveUserInfo get an error || data: {} || msg: {} ", data, e.getMessage());
}
return null;
}
/**
*
* @param unionid
* @param appId
* @return
*/
private UserWeixinDTO findUserWeiXinByUnionIdAndAppId(String unionid, String appId) {
return this.userWeixinService.findFirstByUnionidAndAppid(unionid,appId);
}
/**
* 修改会员vip状态
*/
private void doUpdateMemberVip(MemberDTO memberDTO,Integer vip1) {
if (memberDTO != null) {
Integer vip = memberDTO.getVip();
vip = (vip == null ? 0 : vip);
// 未购买付费会员
if (vip <= 1) {
memberDTO.setVip(vip1);
Member member = new Member();
BeanUtils.copyProperties(memberDTO, member);
this.memberService.update(member);
}
}
}
/**
* 获取小屏会员
* @param userWeixinDTO
* @return
*/
private MemberDTO findMemberByUserWeixinDTO(UserWeixinDTO userWeixinDTO) {
Long memberId = userWeixinDTO.getMemberId();
if (Objects.nonNull(memberId)) {
MemberDTO memberDTO = this.findMemberById(memberId);
return memberDTO;
}
return null;
}
/**
* 修改微信公众号关注状态
* @param status 0:取消关注 1:关注
*/
private UserWeixinDTO doUpdateUserWeiXinStatus(String appId, String openId, Integer status) {
UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId);
if (Objects.nonNull(userWeixinDTO.getId())) {
userWeixinDTO.setStatus(status);
UserWeixin userWeixin = new UserWeixin();
BeanUtils.copyProperties(userWeixinDTO,userWeixin);
this.userWeixinService.update(userWeixin);
}
return userWeixinDTO;
}
/**
* 修改微信公众号关注状态
* @param status 0:取消关注 1:关注
*/
private UserWeixinDTO doUpdateUserWeiXinStatus(UserWeixinDTO userWeixinDTO, Integer status) {
userWeixinDTO.setStatus(status);
UserWeixin userWeixin = new UserWeixin();
BeanUtils.copyProperties(userWeixinDTO,userWeixin);
this.userWeixinService.update(userWeixin);
return userWeixinDTO;
}
/**
* 通过openId和appId获取微信信息
* @param appId
* @param openId
* @return
*/
private UserWeixinDTO findUserWeiXinByOpenIdAndAppId(String appId, String openId) {
UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId,openId);
return userWeixinDTO;
}
/**
* 获取会员
* @param memberId
* @return
*/
private MemberDTO findMemberById(Long memberId) {
MemberDTO memberDTO = this.memberService.findById(memberId);
return memberDTO;
}
/**
* 小程序登录
* @param resources
* @return
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class)
public UserWeixinDTO appletLogin(WeiXinUserBean resources) {
String appid = resources.getAppid();
String openid = resources.getOpenid();
String headimgurl = resources.getHeadimgurl();
String unionid = resources.getUnionid();
// 解析
DefaultWeiXinBeanDefinition weiXinBeanDefinition = new DefaultWeiXinBeanDefinition();//this.parseAppletInfo(resources);
weiXinBeanDefinition.setAppid(appid);
weiXinBeanDefinition.setOpenId(openid);
weiXinBeanDefinition.setHeadImgUrl(headimgurl);
weiXinBeanDefinition.setUnionId(unionid);
if (Objects.isNull(weiXinBeanDefinition.getAppId())) {
throw new RuntimeException("微信信息解析失败!");
}
// 链接微信服务器获取用户信息,创建UserWeixin
UserWeixin userWeixin = this.generateUserWeiXin(weiXinBeanDefinition,UNSUBSCRIBE_STATUS);
// 保存会员
Long memberId = this.doCreateMember(userWeixin,0);
// 保存或者修改,微信账户信息
UserWeixinDTO userWeixinDTO = this.doCreateUserWeiXin(userWeixin, memberId);
// 为了保证返回的同一用户
UserWeixinDTO userWeixinDTO_0 = this.getFirstId(userWeixinDTO);
return userWeixinDTO_0;
}
/**
*
* @param userWeixinDTO
* @param vip
* @return
*/
private Long doCreateMember(UserWeixinDTO userWeixinDTO,Integer vip) {
UserWeixin userWeixin = new UserWeixin();
BeanUtils.copyProperties(userWeixinDTO,userWeixin);
Long memberId = this.doCreateMember(userWeixin, vip);
return memberId;
}
/**
*
* @param userWeixin
* @param vip
* @return
*/
private Member doCreateMemberAndReturnMember(UserWeixin userWeixin,Integer vip) {
Member memberReturn = null;
if(Objects.nonNull(userWeixin)) {
String unionid = userWeixin.getUnionid();
// 新创建的小屏账户
if(Objects.nonNull(unionid)) {
// 查询第一个账户是否关联了会员
UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionid);
// 无账号,没有绑定会员
if (Objects.isNull(userWeixinDTO.getMemberId())) {
// 默认会员
Member member = MemberBuilder.build(LocalConstants.DEVICE_MOBILE,userWeixin.getHeadimgurl(),
userWeixin.getNickname(),vip);
memberReturn = this.memberService.createAndReturnMember(member);
}
// 如果绑定了会员
if (Objects.nonNull(userWeixinDTO.getMemberId())) {
Long memberId = userWeixinDTO.getMemberId();
MemberDTO memberDTO = this.findMemberById(memberId);
memberReturn = new Member();
BeanUtils.copyProperties(memberDTO,memberReturn);
}
}
}
return memberReturn;
}
/**
* 创建会员
* @description 同一用户只有一个会员,通过unionId查询任意账户是否关联了会员,如果关联了就不用再创建
* @param userWeixin
* @param vip
* @return
*/
private Long doCreateMember(UserWeixin userWeixin,Integer vip) {
Long memberId = null;
if(Objects.nonNull(userWeixin)) {
String unionid = userWeixin.getUnionid();
// 新创建的小屏账户
if(Objects.nonNull(unionid)) {
// 查询第一个账户是否关联了会员
UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionid);
// 无账号,没有绑定会员
if (Objects.isNull(userWeixinDTO.getMemberId())) {
// 默认会员
Member member = MemberBuilder.build(LocalConstants.DEVICE_MOBILE,userWeixin.getHeadimgurl(),
userWeixin.getNickname(),vip);
memberId = this.memberService.create(member);
}
// 如果绑定了会员
if (Objects.nonNull(userWeixinDTO.getMemberId())) {
memberId = userWeixinDTO.getMemberId();
}
}
}
return memberId;
}
private UserWeixinDTO doCreateUserWeiXin(UserWeixinDTO userWeixin,Long memberId) {
if (Objects.isNull(memberId))
throw new NullPointerException("memberId is null !");
UserWeixin userWeixin1 = new UserWeixin();
BeanUtils.copyProperties(userWeixin,userWeixin1);
UserWeixinDTO userWeixinDTO = this.doCreateUserWeiXin(userWeixin1, memberId);
return userWeixinDTO;
}
private UserWeixinDTO doCreateUserWeiXin(UserWeixin userWeixin,Member member) {
Long memberId = member.getId();
String code = member.getCode();
UserWeixinDTO userWeixinDTO = new UserWeixinDTO();
if(Objects.isNull(userWeixin.getId()) && Objects.nonNull(memberId)) {
userWeixin.setMemberId(memberId);
userWeixin.setStatus(SUBSCRIBE_STATUS);
userWeixin.setSyncStatus(0);
userWeixin.setCreateBy("system");
userWeixin.setUpdateBy("system");
userWeixin.setAuthTime(TimestampUtil.now());
userWeixin.setMemberCode(code);
userWeixin = this.userWeixinService.create(userWeixin);
}
BeanUtils.copyProperties(userWeixin,userWeixinDTO);
return userWeixinDTO;
}
/**
* 保存微信账户信息
* @param userWeixin
* @param memberId
*/
private UserWeixinDTO doCreateUserWeiXin(UserWeixin userWeixin,Long memberId) {
MemberDTO memberDTO = this.findMemberById(memberId);
UserWeixinDTO userWeixinDTO = new UserWeixinDTO();
if(Objects.isNull(userWeixin.getId()) && Objects.nonNull(memberId)) {
userWeixin.setMemberId(memberId);
userWeixin.setStatus(SUBSCRIBE_STATUS);
userWeixin.setSyncStatus(0);
userWeixin.setCreateBy("system");
userWeixin.setUpdateBy("system");
userWeixin.setAuthTime(TimestampUtil.now());
userWeixin.setMemberCode(memberDTO.getCode());
userWeixin = this.userWeixinService.create(userWeixin);
}
// 避免账户存在但会员不存在的情况
if(Objects.nonNull(userWeixin.getId()) && Objects.isNull(userWeixin.getMemberId()) && Objects.nonNull(userWeixin.getUnionid())) {
userWeixin.setMemberId(memberId);
this.userWeixinService.update(userWeixin);
}
BeanUtils.copyProperties(userWeixin,userWeixinDTO);
return userWeixinDTO;
}
/**
* 链接微信服务器,创建或者修改UserWeiXinDTO
* @param weiXinBeanDefinition
* @return
*/
private UserWeixin generateUserWeiXin(WeiXinBeanDefinition weiXinBeanDefinition,Integer status) {
String appId = weiXinBeanDefinition.getAppId();
String openId = weiXinBeanDefinition.getOpenId();
String unionId = weiXinBeanDefinition.getUnionId();
String nickname = weiXinBeanDefinition.getNickname();
String headImgUrl = weiXinBeanDefinition.getHeadImgUrl();
// 微信
UserWeixinDTO weixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId,openId);
if (Objects.isNull(weixinDTO.getId())) {
UserWeixin userWeixin = new UserWeixin()
.setAppid(appId)
.setOpenid(openId)
.setUnionid(unionId)
.setNickname(nickname)
.setHeadimgurl(headImgUrl)
.setStatus(status)
.setAuthTime(TimestampUtil.now());
return userWeixin;
}
UserWeixin userWeixin = new UserWeixin();
BeanUtils.copyProperties(weixinDTO,userWeixin);
return userWeixin;
}
/**
* 解析小程序
* @param resources
* @return
*/
private DefaultWeiXinBeanDefinition parseAppletInfo(WeiXinUserBean resources) {
return this.parse(resources);
}
/**
* 解析微信信息
* @param resources
* @return
*/
private DefaultWeiXinBeanDefinition parse(WeiXinUserBean resources) {
Map<String, String> weixinInfoMap = null;
String appId = resources.getWxAppid();
String code = resources.getWxCode();
String encryptedData = resources.getEncryptedData();
String iv = resources.getIv();
String userInfo = null;
if (StringUtils.isNotBlank(appId)) {
String decrypt = AESUtil.decrypt(appId, this.key);
if (decrypt != null) {
appId = decrypt.substring(16);
}
weixinInfoMap = this.getWeixinInfoByAppid(appId);
}
if (StringUtils.isNotBlank(code)) {
String decrypt = AESUtil.decrypt(code, this.key);
if (decrypt != null) {
code = decrypt.substring(16);
}
}
String appId_ = weixinInfoMap.get("appid");
String secret = weixinInfoMap.get("secret");
// 链接微信服务器
String url = WeChatConstants.CODE2SESSION.replace("APPID", appId_)
.replace("SECRET", secret).replace("JSCODE", code);
String entityBody = HttpUtil.get(url);
log.info("entityBody [{}]",entityBody);
JSONObject jsonObject = JSONObject.parseObject(entityBody);
String errCode = jsonObject.getString("errcode");
if (StringUtils.isNotEmpty(errCode)) {
String nameStr = jsonObject.getString("errmsg");
throw new BadRequestException(nameStr);
}
String openId = jsonObject.getString("openid");
String unionId = jsonObject.getString("unionid");
String sessionKey = jsonObject.getString("session_key");
JSONObject userInfoWxJo = null;
if (StringUtils.isNotBlank(encryptedData) && StringUtils.isNotBlank(iv) && StringUtils.isNotBlank(sessionKey)) {
String userInfoWeixin = AESUtil.decryptJsUserInfo(encryptedData, iv, sessionKey);
log.info("userInfoWeixin [{}]",userInfoWeixin);
if (StringUtils.isNotEmpty(userInfoWeixin))
userInfoWxJo = JSONObject.parseObject(userInfoWeixin);
}
String phoneNumber = "";
if (StringUtils.isNotBlank(encryptedData)) {
JSONObject userInfoJo = JSONObject.parseObject(userInfo);
if (Objects.nonNull(userInfoJo)) {
encryptedData = userInfoJo.getString("encryptedData");
iv = userInfoJo.getString("iv");
String sessionkey = jsonObject.getString("session_key");
JSONObject userInfoPhone = AESUtil.decryptJsUserPhone(encryptedData, iv, sessionkey);
if (ObjectUtil.isNull(userInfoPhone)) {
throw new BadRequestException("decrypt phone error...");
}
phoneNumber = userInfoPhone.getString("phoneNumber");
if (StringUtils.isBlank(phoneNumber)) {
throw new BadRequestException("phoneNumber is null...");
}
}
}
DefaultWeiXinBeanDefinition weiXinBeanDefinition =
new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo,phoneNumber);
return weiXinBeanDefinition;
}
/**
*
* @param appid
* @return
*/
private Map<String, String> getWeixinInfoByAppid(String appid) {
if (StringUtils.isBlank(appid)) {
throw new RuntimeException("wxAppid can not be null");
}
List<Map<String, String>> list = this.weiXinAppListConfig.getList();
Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
if (!weixinInfoOptional.isPresent()) {
throw new RuntimeException("wxAppid error, appid is : " + appid);
}
return weixinInfoOptional.get();
}
/**
* 大屏更换主账号
* @param resources
*/
@Override
public void changeMainAccount(UserTv resources) {
// 会员编码
String memberCode = resources.getMemberCode();
UserTvDTO userTvDTO_0 = this.findByPriorityMemberCode(memberCode);
if (Objects.nonNull(userTvDTO_0)) {
if (userTvDTO_0.getPriorityMemberCode().equalsIgnoreCase(memberCode))
throw new BadRequestException("会员已是主账户");
throw new BadRequestException("该会员已绑定其他账户");
}
// 大屏账户
UserTvDTO userTvDTO = this.findByUserTv(resources);
// 会员
MemberDTO memberDTO = this.findMemberByMemberCode(memberCode);
// 设置主会员
this.bondPriorityMember(userTvDTO, memberDTO,"manual");
}
@Override
public void changeMainAccountByUnionId(UserTv userTv, String unionId) {
UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionId);
Long memberId = userWeixinDTO.getMemberId();
MemberDTO memberDTO = this.findMemberById(memberId);
String code = memberDTO.getCode();
userTv.setMemberCode(code);
this.changeMainAccount(userTv);
}
/**
*
* @param memberCode
* @return
*/
private UserTvDTO findByPriorityMemberCode(String memberCode) {
UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode);
return userTvDTO;
}
/**
* 设置主会员
* @description 检查大屏账户有没有绑定小屏会员,如果没有绑定就将当前会员的code保存到大屏账户中
* @param userTvDTO
* @param memberDTO
* @param auto manual:手动 auto:自动
*/
private void bondPriorityMember(UserTvDTO userTvDTO, MemberDTO memberDTO,String auto) {
if (auto.equalsIgnoreCase("auto")) {
// 主账户
String priorityMemberCode = userTvDTO.getPriorityMemberCode();
if (StringUtils.isNotEmpty(priorityMemberCode)) {
return;
}
}
String memberCode = memberDTO.getCode();
// 绑定了小屏,结束
if (StringUtils.isNotEmpty(memberCode)) {
userTvDTO.setPriorityMemberCode(memberCode);
}
UserTv userTv = new UserTv();
BeanUtils.copyProperties(userTvDTO,userTv);
this.userTvService.update(userTv);
}
/**
* 通过编码获取会员
* @param memberCode
* @return
*/
private MemberDTO findMemberByMemberCode(String memberCode) {
return this.memberService.getByCode(memberCode);
}
/**
* 大屏解绑
* @param resources
*/
@Override
public void unbind(UserTv resources) {
// 大屏账户
UserTvDTO userTvDTO = this.findByUserTv(resources);
Long id = userTvDTO.getId();
String memberCode = resources.getMemberCode();
// 大屏会员
List<MemberDTO> memberDTOS = this.findMemberByCodeAndUserIptvId(id,memberCode);
// 解绑(置空大屏信息)
this.resetIptvColumn(memberDTOS);
// 置空主账号
this.resetMainAccount(memberCode);
}
@Override
public void unbindByUnionId(UserTv userTv, String unionId) {
UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionId);
Long memberId = userWeixinDTO.getMemberId();
MemberDTO memberDTO = this.findMemberById(memberId);
String code = memberDTO.getCode();
userTv.setMemberCode(code);
this.unbind(userTv);
}
/**
* 置空主账号
* @param memberCode
*/
private void resetMainAccount(String memberCode) {
UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode);
if (Objects.nonNull(userTvDTO)) {
userTvDTO.setPriorityMemberCode(null);
UserTv userTv = new UserTv();
BeanUtils.copyProperties(userTvDTO,userTv);
this.userTvService.unbindPriorityMemberCode(userTv);
}
}
/**
* 解绑(置空大屏信息)
* @param memberDTOS
*/
private void resetIptvColumn(List<MemberDTO> memberDTOS) {
// 若无关系,不做处理
if (CollUtil.isEmpty(memberDTOS))
return;
Member member = new Member();
memberDTOS.get(0).setBindIptvTime(null);
memberDTOS.get(0).setUserIptvId(null);
memberDTOS.get(0).setBindIptvPlatformType(null);
BeanUtils.copyProperties(memberDTOS.get(0), member);
this.memberService.unbind(member);
}
/**
*
* @param tvUserId 大屏ic
* @param memberCode 会员编码
* @return
*/
private List<MemberDTO> findMemberByCodeAndUserIptvId(Long tvUserId,String memberCode) {
MemberQueryCriteria memberQueryCriteria = new MemberQueryCriteria();
memberQueryCriteria.setCode(memberCode);
memberQueryCriteria.setUserIptvId(tvUserId);
List<MemberDTO> memberDTOS = memberService.queryAll(memberQueryCriteria);
return memberDTOS;
}
/**
* 通过大屏账户查询大屏信息
* @param resources
* @return
*/
private UserTvDTO findByUserTv(UserTv resources) {
String platformAccount = resources.getPlatformAccount();
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
return userTvDTO;
}
/**
* 创建大屏会员
* @param resources
* @return
*/
@Override
@Transactional
public boolean createMemberByUserTv(UserTv resources) {
String platformAccount = resources.getPlatformAccount();
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.isNull(userTvDTO)) {
Member member = new Member();
// 大屏
member.setType(LocalConstants.MEMBER_PLATFORM_TYPE_VIS);
String code = member.getCode();
member.setCode(StringUtils.isEmpty(code)?String.valueOf(IdWorker.generator()):code);
member.setNickname(platformAccount);
member.setType(1);
Long memberId = this.memberService.create(member);
UserTv userTv = new UserTv();
if (Objects.nonNull(memberId)) {
BeanUtils.copyProperties(resources,userTv);
userTv.setPlatformAccount(platformAccount);
userTv.setMemberCode(member.getCode());
userTv.setNickname(platformAccount);
userTv.setUsername(platformAccount);
userTv.setLoginDays(1);
userTv.setStatus(1);
userTv.setActiveTime(TimestampUtil.now());
userTv.setContinueDays(1);
userTv.setCreateBy("system");
userTv.setUpdateBy("system");
this.userTvService.create(userTv);
return true;
}
return false;
} else {
UserTv userTv = new UserTv();
BeanUtils.copyProperties(userTvDTO,userTv);
return true;
}
}
/**
* 绑定会员中的userIptvId字段
* @param memberDTO
* @param userTvDTO
*/
private MemberDTO bindIptvId(MemberDTO memberDTO,UserTvDTO userTvDTO) {
String platform = userTvDTO.getPlatform();
// 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通
Integer bindIptvPlatformType = 0;
// 联通
if (UserConstant.platform_lt.contains(platform)) {
bindIptvPlatformType = PLATFORM_LIST[3];
}
// 移动
if (UserConstant.platform_yd.contains(platform)) {
bindIptvPlatformType = PLATFORM_LIST[2];
}
// 电信
if (UserConstant.platform_dx.contains(platform)) {
bindIptvPlatformType = PLATFORM_LIST[1];
}
memberDTO.setUserIptvId(userTvDTO.getId());
memberDTO.setBindIptvTime(LocalDateTime.now());
memberDTO.setBindIptvPlatformType(bindIptvPlatformType);
return memberDTO;
}
/**
* 修改会员
* @param memberDTO
*/
private void doUpdateMemberByMemberDTO(MemberDTO memberDTO){
Member member = new Member();
BeanUtils.copyProperties(memberDTO,member);
member.setUpdateTime(LocalDateTime.now());
log.info("doUpdateMemberByMemberDTO=====?>>member ==>> [{}]",member);
this.doUpdateMember(member);
}
/**
* 修改会员
* @param member
*/
private void doUpdateMember(Member member){
this.memberService.update(member);
}
/**
* 解析微信信息
* @param resources
* @return
*/
@Override
public MemberProfile saveUserWeixinPhone(WeiXinUserBean resources) {
DefaultWeiXinBeanDefinition weiXinBeanDefinition = this.parseAppletInfo(resources);
if (Objects.nonNull(weiXinBeanDefinition.getOpenId())) {
throw new RuntimeException("微信信息解析失败!");
}
// 保存、修改会员加密信息
return this.doSaveOrUpdateMemberProfile(weiXinBeanDefinition,resources);
}
@Override
public boolean sendQrCodeMessage(String content) {
try {
log.info("receive get qrCode message, content {}", content);
JSONObject jsonObject = JSONObject.parseObject(content);
String appid = jsonObject.getString("appid");
String IPTVappid = jsonObject.getString("IPTVappid");
String platformAccount = jsonObject.getString("platformAccount");
String sessionId = jsonObject.getString("sessionId");
String key = QR_CODE_URL + appid + "_" + platformAccount + "_" + sessionId;
String url = (String) this.redisUtils.get(key);
if (StringUtils.isBlank(url)) {
Map<String, String> wxInfo = WeixinUtil.getWeixinInfoByAppid(appid);
String appType = wxInfo.get("appType");
// 订阅号不支持带参二维码,直接返回
if (StrUtil.isNotEmpty(appType) && ObjectUtil.equals(appType, WeChatConstants.WX_SUBSCRIPTION)) {
log.error("订阅号不支持带参二维码 || {} || {}", appid, content);
return false;
}
QrCode qrCode = new QrCode();
qrCode.setActionName(WeChatConstants.QR_STR_SCENE);
if (StringUtils.isNotBlank(wxInfo.get("qrCodeExpireSeconds"))) {
qrCode.setExpireSeconds(Integer.valueOf(wxInfo.get("qrCodeExpireSeconds")));
}
ActionInfo actionInfo = new ActionInfo();
Scene scene = new Scene();
scene.setSceneStr(content);
actionInfo.setScene(scene);
qrCode.setActionInfo(actionInfo);
JSONObject jsonQrCode = this.weixinRequestUtil.getQrCode(wxInfo, qrCode);
url = jsonQrCode.getString("url");
Integer expireSeconds = jsonQrCode.getInteger("expire_seconds");
this.redisUtils.set(key, url, expireSeconds, TimeUnit.SECONDS);
}
} catch (Exception e) {
log.error("GetQrCodeConsumer || get qrCode error || {}", e.toString(), e);
}
return true;
}
@Override
@AsyncMqSend
public boolean deleteAllCollection(String content) {
try {
JSONObject jsonObject = JSONObject.parseObject(content);
String platformAccount = jsonObject.getString("platformAccount");
Integer type = jsonObject.getInteger("collectionType");
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
Long id = userTvDTO.getId();
List<UserCollection> userCollections = this.userCollectionService.findByUserIdAndType(id, type);
if (userCollections == null || userCollections.isEmpty()) {
return false;
}
for (UserCollection userCollection : userCollections) {
this.userCollectionDetailService.deleteAllByUserCollectionId(userCollection.getId());
}
} catch (Exception e) {
log.error("CollectionDeleteConsumer || UserCollection delete all error || {}", e.toString(), e);
}
return true;
}
@Override
@AsyncMqSend
public boolean deleteCollection(String content) {
try {
log.info("receive UserCollection delete message, content [{}]", content);
JSONObject jsonObject = JSONObject.parseObject(content);
String platformAccount = jsonObject.getString("platformAccount");
String data = jsonObject.getString("data");
if (StringUtils.isBlank(data) || !data.startsWith("[")) {
return false;
}
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
Long id = userTvDTO.getId();
List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class);
if (userCollectionMqList == null || userCollectionMqList.isEmpty()) {
return false;
}
Map<Long, List<UserCollectionMq>> collect = userCollectionMqList.stream()
.collect(Collectors.groupingBy(UserCollectionMq::getUserCollectionId));
for (Map.Entry<Long, List<UserCollectionMq>> entry : collect.entrySet()) {
List<UserCollectionMq> value = entry.getValue();
UserCollectionMq userCollectionMq = value.get(0);
if (StringUtils.isBlank(userCollectionMq.getName())) {
userCollectionMq.setName("DEFAULT");
}
Optional<UserCollection> userCollectionOptional =
this.userCollectionService.findFirstByUserIdAndTypeAndName(id, userCollectionMq.getType(),
userCollectionMq.getName());
UserCollection userCollection = userCollectionOptional.orElseGet(UserCollection::new);
int count = 0;
for (UserCollectionMq collectionMq : value) {
collectionMq.setUserCollectionId(userCollection.getId());
List<UserCollectionDetail> userCollectionDetailOptional =
this.userCollectionDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
QueryHelp.getPredicate(root, collectionMq, criteriaBuilder));
if (!userCollectionDetailOptional.isEmpty()) {
this.userCollectionDetailService.deleteAll(userCollectionDetailOptional);
count++;
}
}
userCollection.setAppId(userCollectionMq.getAppId())
.setUserId(id)
.setName(userCollectionMq.getName())
.setType(userCollectionMq.getType())
.setCount(userCollection.getCount() - count);
this.userCollectionService.save(userCollection);
}
} catch (Exception e) {
log.error("CollectionDeleteConsumer || UserCollection delete error || {}", e.toString(), e);
}
return true;
}
@Override
@AsyncMqSend
public boolean addCollection(String content) {
try {
//处理接口调用 中文不显示问题
content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8)));
log.info("receive UserCollection add message, content {}", content);
JSONObject jsonObject = JSONObject.parseObject(content);
String platformAccount = jsonObject.getString("platformAccount");
String data = jsonObject.getString("data");
if (StringUtils.isBlank(data) || !data.startsWith("["))
return false;
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
Long tvUserId = userTvDTO.getId();
List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class);
if (userCollectionMqList == null || userCollectionMqList.isEmpty())
return false;
Map<Long, List<UserCollectionMq>> collect = userCollectionMqList.stream().collect(Collectors.groupingBy(UserCollectionMq::getUserCollectionId));
for (Map.Entry<Long, List<UserCollectionMq>> entry : collect.entrySet()) {
List<UserCollectionMq> value = entry.getValue();
UserCollectionMq userCollectionMq = value.get(0);
if (StringUtils.isBlank(userCollectionMq.getName()))
userCollectionMq.setName("DEFAULT");
UserCollection userCollection = this.userCollectionService
.findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()).orElseGet(UserCollection::new);
userCollection.setAppId(userCollectionMq.getAppId())
.setUserId(tvUserId)
.setName(userCollectionMq.getName())
.setType(userCollectionMq.getType())
.setCount(userCollection.getCount() == null ? value.size() : userCollection.getCount() + value.size());
log.info("userCollection ==>> [{}]",userCollection);
UserCollection userCollectionSave = this.userCollectionService.save(userCollection);
for (UserCollectionMq collectionMq : value) {
UserCollectionDetail userCollectionDetail = collectionMq2DetailMapper.toEntity(collectionMq);
Optional<UserCollectionDetail> userCollectionDetailOptional = userCollectionDetailRepository
.findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), userCollectionDetail.getDetailType(), userCollectionSave.getId());
//观影记录同一天只存一条记录
if (userCollectionDetailOptional.isPresent() &&
DateUtil.isSameDay(new Date(userCollectionDetailOptional.get().getCreateTime().getTime()), new Date())) {
userCollectionDetail.setId(userCollectionDetailOptional.get().getId());
} else {
userCollectionDetail.setId(null)
.setUserCollectionId(userCollectionSave.getId());
}
userCollectionDetailRepository.save(userCollectionDetail);
}
}
} catch (Exception e) {
log.error("CollectionAddConsumer || UserCollection add error || {}", e.toString(), e);
}
return true;
}
@Override
public List<MemberDTO> findBindByPlatformAccount(String platformAccount) {
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.nonNull(userTvDTO.getId())) {
Long id = userTvDTO.getId();
String priorityMemberCode = userTvDTO.getPriorityMemberCode();
List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id);
if (!CollectionUtils.isEmpty(memberDTOList)) {
for (MemberDTO memberDTO : memberDTOList) {
String code = memberDTO.getCode();
if (code.equalsIgnoreCase(priorityMemberCode)) {
memberDTO.setIptvMajor(IPTV_MAJOR[1]);
} else {
memberDTO.setIptvMajor(IPTV_MAJOR[0]);
}
}
}
return memberDTOList;
}
return null;
}
@Override
public Object serviceLogin(WeiXinUserBean resources) {
String unionId = resources.getUnionid();
String appId = resources.getAppid();
String openId = resources.getOpenid();
// if (org.apache.commons.lang3.StringUtils.isBlank(unionId)) {
// TODO 需要商量是否需要创建微信账户
/*UserWeixinDTO userWeixinDTO = this.findUserWeiXinByOpenIdAndAppId(appId, openId);
if (ObjectUtil.isNotEmpty(userWeixinDTO))
return userWeixinDTO;*/
// }
// 小屏账户
UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId);
if (Objects.isNull(userWeixinDTO.getId())) {
DefaultWeiXinBeanDefinition weiXinBeanDefinition = new DefaultWeiXinBeanDefinition();
weiXinBeanDefinition.setUnionId(unionId);
weiXinBeanDefinition.setAppid(appId);
weiXinBeanDefinition.setOpenId(openId);
// 创建会员和账户
this.doCreateUserWeiXinAndMember(weiXinBeanDefinition);
} else {
// 修改账户和会员信息
this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId,"","");
}
// 为了保证返回的同一用户
UserWeixinDTO userWeixinDTO_0 = this.getFirstId(userWeixinDTO);
return userWeixinDTO_0;
}
@Override
public boolean appletBind(BindBean resources) {
Long id = resources.getId();
Long platformUserId = resources.getPlatformUserId();
String unionid = resources.getUnionid();
String platformAccount = resources.getPlatformAccount();
// 大屏账户
UserTvDTO userTvDTO = this.findUserIptvById(platformUserId);
// 账户是否存在
if (Objects.isNull(userTvDTO.getId())){
log.error("Param ==> platformUserId ==> [{}]",platformUserId);
throw new EntityNotFoundException(UserTvDTO.class,"id","大屏账户不存在!");
}
UserWeixinDTO userWeixinDTO = null;
// 微信账户
if (Objects.nonNull(id)) {
userWeixinDTO = this.userWeixinService.findById(id);
} else {
userWeixinDTO = this.findFirstByUnionId(unionid);
}
// 账户是否存在
if (Objects.isNull(userWeixinDTO.getId())) {
log.error("param ==> id ==> [{}]",id);
throw new EntityNotFoundException(UserWeixinDTO.class, "id", userWeixinDTO.getId().toString());
}
// 会员
Long memberId = userWeixinDTO.getMemberId();
if (Objects.isNull(memberId)) {
log.error("param ==> memberId ==> [{}]",id);
throw new EntityNotFoundException(UserWeixinDTO.class, "id", id.toString());
}
MemberDTO memberDTO = this.findMemberById(memberId);
if (Objects.isNull(memberId)) {
log.error("param ==> memberId ==> [{}]",id);
throw new EntityNotFoundException(MemberDTO.class, "id", memberId.toString());
}
// 主账户
String priorityMemberCode = userTvDTO.getPriorityMemberCode();
if (StringUtils.isBlank(priorityMemberCode)) {
// 主账户会员
String code = memberDTO.getCode();
userTvDTO.setPriorityMemberCode(code);
}
// 更新小屏账户更新时间,epg需要根据修改时间来让绑定的二维码消失
this.doUpdateUserWeiXinUpdateTime(userWeixinDTO);
// 更新大屏信息
userTvDTO.setMemberCode(memberDTO.getCode());
this.doUpdateUserTv(userTvDTO);
memberDTO.setPlatformAccount(platformAccount);
// 会员绑定大屏
this.bindIptvId(memberDTO,userTvDTO);
this.doUpdateMemberByMemberDTO(memberDTO);
return true;
}
/**
* 更新微信用户修改的时间
* @param userWeixinDTO
*/
private void doUpdateUserWeiXinUpdateTime(UserWeixinDTO userWeixinDTO) {
UserWeixin userWeixin = new UserWeixin();
userWeixin.setAppid(userWeixinDTO.getAppid());
userWeixin.setOpenid(userWeixinDTO.getOpenid());
userWeixin.setUpdateTime(TimestampUtil.now());
this.userWeixinService.updateTime(userWeixin);
}
@Override
public JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code) {
// 链接微信服务器
String url = WeChatConstants.CODE2SESSION.replace("APPID", appId)
.replace("SECRET", secret).replace("JSCODE", code);
String entityBody = HttpUtil.get(url);
JSONObject jsonObject = JSONObject.parseObject(entityBody);
String errCode = jsonObject.getString("errcode");
if (StringUtils.isNotEmpty(errCode)) {
String nameStr = jsonObject.getString("errmsg");
throw new BadRequestException(nameStr);
}
return jsonObject;
}
@Override
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources) {
String appId = resources.getAppid();
String openId = resources.getOpenid();
String unionId = resources.getUnionid();
// 检查账户是否存在
UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId);
if (Objects.nonNull(userWeixinDTO.getId()))
return userWeixinDTO;
// 当前用户的任意微信app
UserWeixinDTO userWeixinDTO1 = this.findFirstByUnionId(unionId);
Long memberId = null;
Integer vip = 0;
if (Objects.nonNull(userWeixinDTO1.getId()) && Objects.nonNull(userWeixinDTO1.getMemberId())) {
memberId = userWeixinDTO1.getMemberId();
} else {
userWeixinDTO1 = new UserWeixinDTO();
BeanUtils.copyProperties(resources,userWeixinDTO1);
// 创建会员
memberId = this.doCreateMember(userWeixinDTO1,vip);
}
userWeixinDTO1.setId(null);
userWeixinDTO1.setAppid(appId);
userWeixinDTO1.setOpenid(openId);
userWeixinDTO1.setUnionid(unionId);
log.info("createWeixinUserAndCreateMember ==>> [{}]",userWeixinDTO1);
// 保存微信账户
userWeixinDTO1 = this.doCreateUserWeiXin(userWeixinDTO1,memberId);
log.info("userWeixinDTO1 ==>> [{}]",userWeixinDTO1);
MemberProfileDTO memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
if (Objects.isNull(memberProfileDTO))
// 创建会员属性信息
this.createMemberProfile(userWeixinDTO1);
return userWeixinDTO1;
}
@Override
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public void bind(String memberCode, String platformAccount) {
MemberDTO memberDTO = this.memberService.getByCode(memberCode);
this.bind(memberDTO,platformAccount);
}
@Override
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public void bind(MemberDTO memberDTO, UserTvDTO userTvDTO) {
String platformAccount = userTvDTO.getPlatformAccount();
// 绑定
this.bind(memberDTO,platformAccount);
}
@Override
public UserTvDTO bind(MemberDTO memberDTO, String platformAccount) {
MemberDTO memberDTO1 = this.memberService.getByCode(memberDTO.getCode());
if (Objects.nonNull(memberDTO1.getUserIptvId())) {
UserTvDTO userTvDTO = this.userTvService.findById(memberDTO1.getUserIptvId());
return userTvDTO;
}
// 大屏账户
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.isNull(userTvDTO)) {
throw new BadRequestException("大屏信息不存在!");
}
// mq同步数据时使用
memberDTO.setPlatformAccount(platformAccount);
// 大屏是否绑定主账号,如果绑定了主账户则不操作大屏账户表
this.bondPriorityMember(userTvDTO,memberDTO,"auto");
// 构建小屏会员对象,绑定user_iptv_id字段
MemberDTO memberDTO0 = this.bindIptvId(memberDTO,userTvDTO);
// 修改会员
this.doUpdateMemberByMemberDTO(memberDTO0);
return null;
}
/**
*
* @param userWeixinDTO1
*/
private void createMemberProfile(UserWeixinDTO userWeixinDTO1) {
Long memberId = userWeixinDTO1.getMemberId();
String nickname = userWeixinDTO1.getNickname();
Integer sex = userWeixinDTO1.getGender();
MemberProfile memberProfile = MemberProfileBuild.build(memberId, nickname, sex, null);
this.memberProfileService.create(memberProfile);
}
private UserWeixinDTO findFirstByUnionId(String unionId) {
return this.userWeixinService.findFirstByUnionId(unionId);
}
/**
* 通过id检索大屏信息
* @param userIptvId
* @return
*/
private UserTvDTO findUserIptvById(Long userIptvId) {
UserTvDTO userTvDTO = this.userTvService.findById(userIptvId);
return userTvDTO;
}
/**
* 更新大屏
* @param userTvDTO
*/
private void doUpdateUserTv(UserTvDTO userTvDTO) {
UserTv userTv = new UserTv();
BeanUtils.copyProperties(userTvDTO,userTv);
userTv.setUpdateTime(TimestampUtil.now());
this.userTvService.update(userTv);
}
/**
* 同一用户有多个微信APP的情况下展示同一个账户信息
* 原则:那个先创建就用那个id
* @param userWeixinDTO
*/
private UserWeixinDTO getFirstId(UserWeixinDTO userWeixinDTO) {
String unionid = userWeixinDTO.getUnionid();
if (StringUtils.isNotBlank(unionid)) {
UserWeixinQueryCriteria criteria = new UserWeixinQueryCriteria();
PageRequest pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.ASC, "createTime"));
criteria.setUnionId(unionid);
List<UserWeixin> userWeixinList = this.userWeixinRepository.findAll((root, criteriaQuery, criteriaBuilder)
-> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable).getContent();
List<UserWeixin> h5AppIdList = userWeixinList.stream().filter(e -> ObjectUtil.equal(e.getAppid(), h5AppId)).collect(Collectors.toList());
List<UserWeixin> appletAppIdList = userWeixinList.stream().filter(e -> ObjectUtil.equal(e.getAppid(), appletAppid)).collect(Collectors.toList());
//没创建h5账号 返回小程序id
if (h5AppIdList.isEmpty()) {
userWeixinDTO.setId(appletAppIdList.get(0).getId());
userWeixinDTO.setAuthTime(appletAppIdList.get(0).getAuthTime());
}
//没创建小程序账号 返回h5id
if (appletAppIdList.isEmpty()) {
userWeixinDTO.setId(h5AppIdList.get(0).getId());
userWeixinDTO.setAuthTime(h5AppIdList.get(0).getAuthTime());
}
//都创建 那个先创建 用那个
if (!appletAppIdList.isEmpty() && !h5AppIdList.isEmpty()) {
if (appletAppIdList.get(0).getCreateTime().before(h5AppIdList.get(0).getCreateTime())) {
userWeixinDTO.setId(appletAppIdList.get(0).getId());
userWeixinDTO.setAuthTime(appletAppIdList.get(0).getAuthTime());
} else {
userWeixinDTO.setId(h5AppIdList.get(0).getId());
userWeixinDTO.setAuthTime(h5AppIdList.get(0).getAuthTime());
}
}
}
return userWeixinDTO;
}
/**
* 保存、修改会员加密信息
* @param resources
* @return
*/
private MemberProfile doSaveOrUpdateMemberProfile(DefaultWeiXinBeanDefinition resources,WeiXinUserBean weiXinUserBean) {
// 会员
MemberDTO memberDTO = this.findMemberById(weiXinUserBean.getMemberId());
if (Objects.nonNull(memberDTO)) {
Long memberId = memberDTO.getId();
// 会员加密信息
MemberProfileDTO memberProfileDTO = this.findMemberProfileByMemberId(memberId);
MemberProfile memberProfile = new MemberProfile();
if (Objects.nonNull(memberProfileDTO)) {
BeanUtils.copyProperties(memberProfileDTO , memberProfile);
}
memberProfile.setMemberId(memberId);
memberProfile.setPhone(resources.getPhoneNumber());
// 保存、更新会员加密信息
MemberProfile memberProfile1 = this.saveMemberProfile(memberProfile);
return memberProfile1;
}
return null;
}
private MemberProfileDTO findMemberProfileByMemberId(Long memberId) {
MemberProfileDTO memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
return memberProfileDTO;
}
private MemberProfile saveMemberProfile(MemberProfile memberProfile) {
return this.memberProfileService.create(memberProfile);
}
}
package com.topdraw.business.process.service.impl;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.user.iptv.domain.UserTv;
import com.topdraw.business.basicdata.user.iptv.repository.UserTvRepository;
import com.topdraw.business.basicdata.user.iptv.service.UserTvService;
import com.topdraw.business.basicdata.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.basicdata.user.iptv.service.mapper.UserTvMapper;
import com.topdraw.business.process.service.UserTvOperationService;
import com.topdraw.config.LocalConstants;
import com.topdraw.util.Base64Util;
import com.topdraw.util.IdWorker;
import com.topdraw.util.RedissonUtil;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
@Service
@Slf4j
public class UserTvOperationServiceImpl implements UserTvOperationService {
@Autowired
private RedissonClient redissonClient;
@Autowired
private MemberService memberService;
@Autowired
private UserTvService userTvService;
@Override
@Transactional
public boolean createMemberByUserTv(UserTv resources) {
String platformAccount = resources.getPlatformAccount();
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.isNull(userTvDTO)) {
Member member = new Member();
// 大屏
member.setType(LocalConstants.MEMBER_PLATFORM_TYPE_VIS);
String code = member.getCode();
member.setCode(StringUtils.isEmpty(code)?String.valueOf(IdWorker.generator()):code);
String platformAccount1 = resources.getPlatformAccount();
member.setNickname(Base64Util.encode(platformAccount1));
member.setBindIptvPlatformType(1);
member.setType(1);
Long memberId = this.memberService.create(member);
if (Objects.nonNull(memberId)) {
UserTv userTv = new UserTv();
BeanUtils.copyProperties(resources,userTv);
userTv.setPlatformAccount(platformAccount);
userTv.setMemberCode(member.getCode());
Long userIptvId = this.userTvService.create(userTv);
if (Objects.nonNull(userIptvId)) {
member.setId(memberId);
member.setUserIptvId(userIptvId);
member.setBindIptvTime(TimestampUtil.now());
member.setPlatformAccount(platformAccount);
this.bindIptvId(member);
}
}
} else {
return false;
}
return true;
}
private void bindIptvId(Member resources) {
RLock rLock = this.redissonClient.getLock("Member::update::code" + resources.getCode());
try {
RedissonUtil.lock(rLock);
MemberDTO member = this.memberService.getByCode(resources.getCode());
if (member!=null) {
this.memberService.update(resources);
}
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
}
package com.topdraw.business.process.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
import com.topdraw.business.process.domian.weixin.UserCollectionMq;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface CollectionMq2DetailMapper extends BaseMapper<UserCollectionMq, UserCollectionDetail> {
@Override
@Mappings({
@Mapping(target = "detailImg", source = "images")
})
UserCollectionDetail toEntity(UserCollectionMq dto);
}
package com.topdraw.config;
import cn.hutool.core.util.StrUtil;
public class RedisKeyUtil {
/**
* @return java.lang.String
* @description 订阅号大屏扫码关注
* @author Hongyan Wang
* @date 2021/8/24 1:36 下午
*/
public static String genSeSuSubscribeKey(String unionid) {
return StrUtil.format("BMSubscribe_unionid_{}", unionid);
}
}
package com.topdraw.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.List;
import java.util.Map;
@Configuration
@Data
@ConfigurationProperties(prefix = "weixin")
public class WeixinInfoConfig {
private List<Map<String, String>> list;
}
......@@ -19,7 +19,7 @@ public class MessageProducer {
private AmqpTemplate amqpTemplate;
@Value("${service.platform}")
@Value("${uc.service.platform}")
private String platformType;
public void sendMessage(String msg,String exchangeName){
......
package com.topdraw.resttemplate;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.business.basicdata.member.address.domain.MemberAddress;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
......@@ -17,7 +17,7 @@ import java.util.Map;
@Slf4j
@Component
public class ApiUtil {
public class RestTemplateClient {
private static RestTemplate restTemplate;
......
package com.topdraw.schedule;
import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.basicdata.points.standingbook.domain.PointsStandingBook;
import com.topdraw.business.basicdata.points.standingbook.service.PointsStandingBookService;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.After;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.List;
/**
* 积分台账
......
package com.topdraw.security;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.AlgorithmParameters;
import java.security.Key;
import java.security.Security;
import java.security.spec.AlgorithmParameterSpec;
import java.util.Arrays;
@Slf4j
public class AESUtil {
public static String encrypt(String data, String key) {
String strResult = null;
try {
SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
AlgorithmParameterSpec aps = new IvParameterSpec("0123456789ABCDEF".getBytes("UTF-8"));
cipher.init(Cipher.ENCRYPT_MODE, secretKey, aps);
byte[] result = cipher.doFinal(data.getBytes("UTF-8"));
StringBuilder sb_hex = new StringBuilder();
for (byte b : result) {
sb_hex.append(String.format("%02x", b));
}
strResult = sb_hex.toString();
} catch (Exception e) {
}
return strResult;
}
public static String decrypt(String encryptedData, String key) {
String strResult = null;
try {
int len = encryptedData.length() / 2;
byte[] data = new byte[len];
for (int i = 0; i < len; i++) {
String str = encryptedData.substring(i * 2, i * 2 + 2);
data[i] = Integer.valueOf(str, 16).byteValue();
}
SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
AlgorithmParameterSpec aps = new IvParameterSpec("0123456789ABCDEF".getBytes("UTF-8"));
cipher.init(Cipher.DECRYPT_MODE, secretKey, aps);
byte[] result = cipher.doFinal(data);
strResult = new String(result, "UTF-8");
} catch (Exception e) {
}
return strResult;
}
private static final String AES ="AES";
private static final String AES_CBC_PKCS7 ="AES/CBC/PKCS7Padding";
public static String decryptJsUserInfo(String encryptedData,String iv,String sessionKey) {
try {
byte[] data = java.util.Base64.getDecoder().decode(encryptedData);
byte[] aseKey = java.util.Base64.getDecoder().decode(sessionKey);
byte[] ivData = java.util.Base64.getDecoder().decode(iv);
Security.addProvider(new BouncyCastleProvider());
Cipher cipher = Cipher.getInstance(AES_CBC_PKCS7);
Key sKeySpec = new SecretKeySpec(aseKey, AES);
AlgorithmParameterSpec aps = new IvParameterSpec(ivData);
cipher.init(Cipher.DECRYPT_MODE, sKeySpec, aps);// 初始化
byte[] result = cipher.doFinal(data);
return new String(result);
} catch (Exception e) {
log.error("decryptJsUserInfo:"+ e);
return null;
}
}
public static JSONObject decryptJsUserPhone(String encryptedData, String iv, String key) {
byte[] dataByte = java.util.Base64.getDecoder().decode(encryptedData);
// 加密秘钥
byte[] keyByte = java.util.Base64.getDecoder().decode(key);
// 偏移量
byte[] ivByte = java.util.Base64.getDecoder().decode(iv);
try {
// 如果密钥不足16位,那么就补足. 这个if 中的内容很重要
int base = 16;
if (keyByte.length % base != 0) {
int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0);
byte[] temp = new byte[groups * base];
Arrays.fill(temp, (byte) 0);
System.arraycopy(keyByte, 0, temp, 0, keyByte.length);
keyByte = temp;
}
// 初始化
Security.addProvider(new BouncyCastleProvider());
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding","BC");
SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
parameters.init(new IvParameterSpec(ivByte));
cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化
byte[] resultByte = cipher.doFinal(dataByte);
if (null != resultByte && resultByte.length > 0) {
String result = new String(resultByte, "UTF-8");
return JSONObject.parseObject(result);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
package com.topdraw.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public class UcListUtils {
public static boolean compareIntegerList(Integer obj , List<Integer> originList){
Integer o = originList.get(0);
Integer o1 = originList.get(1);
if (o >= 0 && o1 > o && obj >= o && obj <= o1)
return true;
if (o > 0 && o1 < 0 && obj >= o)
return true;
return false;
}
public static void main(String[] args) {
String param = "{CONTINUE_LOGIN:30}";
Map<String,String> jsonObjectMap = JSONObject.parseObject(param,Map.class);
Collection<String> values = jsonObjectMap.values();
Object o = values.toArray()[0];
String attrStr = "{\"value\":[31,-99]}";
JSONObject jsonObject = JSONObject.parseObject(attrStr);
JSONArray values_0 = jsonObject.getJSONArray("value");
Integer o1 = (Integer)values_0.get(0);
Integer o2 = (Integer)values_0.get(1);
List<Integer> list = Arrays.asList(o1, o2);
Integer i = (Integer) o;
boolean b = compareIntegerList(i, list);
System.out.println(b);
}
}
package com.topdraw.weixin.applet;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import com.topdraw.security.AESUtil;
import com.topdraw.utils.StringUtils;
import com.topdraw.weixin.beans.DefaultWeiXinBeanDefinition;
import com.topdraw.weixin.beans.WeiXinUserParser;
import com.topdraw.weixin.beans.config.WeiXinAppListConfig;
import com.topdraw.weixin.util.WeChatConstants;
import com.topdraw.weixin.util.WeiXinRequestUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Component
public class WeiXinAppletUserParser implements WeiXinUserParser {
@Autowired
private WeiXinAppListConfig weiXinAppListConfig;
@Autowired
private WeiXinRequestUtil weixinRequestUtil;
@Value("${uc.service.platform:}")
private String platform;
@Value("${key:}")
private String key;
@Value("${uc.app.subAppId:wx05f35931270014be}")
private String subAppId;
@Value("${uc.app.h5AppId:wxca962918dfeed88c}")
private String h5AppId;
@Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
private String appletAppid;
@Value("${file.upload:upload}")
private String filePath;
@Override
public DefaultWeiXinBeanDefinition parse(WeiXinUserBean resources) {
String key = this.key;
Map<String, String> weixinInfoMap = null;
String appId = resources.getWxAppid();
String code = resources.getWxCode();
String userInfo = null;
if (StringUtils.isNotBlank(appId)) {
String decrypt = AESUtil.decrypt(appId, key);
if (decrypt != null) {
appId = decrypt.substring(16);
}
weixinInfoMap = getWeixinInfoByAppid(appId);
}
if (StringUtils.isNotBlank(code)) {
String decrypt = AESUtil.decrypt(code, key);
if (decrypt != null) {
code = decrypt.substring(16);
}
}
if (StringUtils.isNotBlank(userInfo)) {
String decrypt = AESUtil.decrypt(userInfo, key);
if (decrypt != null) {
userInfo = decrypt.substring(16);
}
}
return this.generateWeiXinBeanDefinition(code,userInfo,weixinInfoMap);
}
/**
*
* @param code
* @param userInfo
* @param weixinInfoMap
* @return
*/
private DefaultWeiXinBeanDefinition generateWeiXinBeanDefinition(String code, String userInfo, Map<String, String> weixinInfoMap) {
String appId = weixinInfoMap.get("appid");
String secret = weixinInfoMap.get("secret");
JSONObject userInfoWxJo = null;
// 链接微信服务器
/*ResponseEntity<String> responseEntity1 = null;*//*restTemplate.exchange(WeChatConstants.CODE2SESSION.replace("APPID", appId)
.replace("SECRET", secret).replace("JSCODE", code),
HttpMethod.GET, null, String.class);*//*
String entityBody1 = responseEntity1.getBody();*/
String url = WeChatConstants.CODE2SESSION.replace("APPID", appId)
.replace("SECRET", secret).replace("JSCODE", code);
String entityBody = HttpUtil.get(url);
JSONObject jsonObject = JSONObject.parseObject(entityBody);
String openId = jsonObject.getString("openid");
String unionId = jsonObject.getString("unionid");
if (StringUtils.isEmpty(unionId)) {
try {
userInfoWxJo = this.weixinRequestUtil.getUserInfo(weixinInfoMap, openId,code);
} catch (Exception e) {
e.printStackTrace();
}
}
if (StringUtils.isNotBlank(userInfo)) {
JSONObject userInfoJo = JSONObject.parseObject(userInfo);
String encryptedData = userInfoJo.getString("encryptedData");
String iv = userInfoJo.getString("iv");
String key = jsonObject.getString("session_key");
String userInfoWeixin = AESUtil.decryptJsUserInfo(encryptedData, iv, key);
if (StringUtils.isNotEmpty(userInfoWeixin))
userInfoWxJo = JSONObject.parseObject(userInfoWeixin);
}
DefaultWeiXinBeanDefinition weiXinBeanDefinition =
new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo,null);
return weiXinBeanDefinition;
}
/**
*
* @param appid
* @return
*/
private Map<String, String> getWeixinInfoByAppid(String appid) {
if (StringUtils.isBlank(appid)) {
throw new RuntimeException("wxAppid can not be null");
}
List<Map<String, String>> list = this.weiXinAppListConfig.getList();
Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
if (!weixinInfoOptional.isPresent()) {
throw new RuntimeException("wxAppid error, appid is : " + appid);
}
return weixinInfoOptional.get();
}
}
package com.topdraw.weixin.beans;
import lombok.Data;
@Data
public class ActionInfo {
private Scene scene;
}
package com.topdraw.weixin.beans;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.exception.BadRequestException;
import com.topdraw.utils.StringUtils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Date;
import java.util.UUID;
@Data
@Component
public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition {
//
private String appid;
private String openId;
private String code;
private String token;
private String secret;
private String unionId;
private String nickname;
private String headImgUrl;
private JSONObject userInfo;
private String phoneNumber;
@Value("${file.upload:upload}")
private String filePath;
public DefaultWeiXinBeanDefinition() {
}
public DefaultWeiXinBeanDefinition(String appId, String code,String unionId,String openId, JSONObject userInfoWxJo,String phone) {
this.userInfo = userInfoWxJo;
if (userInfo != null) {
if (StringUtils.isNotBlank(userInfoWxJo.getString("unionId"))) {
unionId = userInfoWxJo.getString("unionId");
}
if (StringUtils.isNotBlank(userInfoWxJo.getString("openId"))) {
openId = userInfoWxJo.getString("openId");
}
headImgUrl = userInfoWxJo.getString("avatarUrl");
if (StringUtils.isNotBlank(userInfoWxJo.getString("nickName"))) {
nickname = Base64.getEncoder().encodeToString(userInfoWxJo.getString("nickName").getBytes(StandardCharsets.UTF_8));
}
String phoneNumber = userInfoWxJo.getString("phoneNumber");
if (StringUtils.isBlank(phoneNumber)) {
throw new BadRequestException("phoneNumber is null...");
}
this.phoneNumber = phoneNumber;
if (StringUtils.isNotBlank(headImgUrl)) {
new Thread(() -> {
String s = UUID.randomUUID().toString();
File file = new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd"));
if (!file.exists()) {
file.mkdirs();
}
HttpUtil.downloadFile(headImgUrl, new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg"));
headImgUrl = filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg";
}).start();
}
}
this.unionId = unionId;
this.phoneNumber = phone;
this.openId = openId;
this.appid = appId;
this.code = code;
}
@Override
public String getAppId() {
return this.appid;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getToken() {
return this.token;
}
@Override
public String getSecret() {
return this.secret;
}
@Override
public String getOpenId() {
return this.openId;
}
@Override
public String getUnionId() {
return this.unionId;
}
@Override
public String getNickname() {
return this.nickname;
}
@Override
public String getHeadImgUrl() {
return this.headImgUrl;
}
@Override
public JSONObject getUserInfo() {
return this.userInfo;
}
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class QrCode {
@JSONField(name = "action_name")
private String actionName;
@JSONField(name = "expire_seconds")
private Integer expireSeconds;
@JSONField(name = "action_info")
private ActionInfo actionInfo;
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class Scene {
@JSONField(name = "scene_id")
private Long sceneId;
@JSONField(name = "scene_str")
private String sceneStr;
}
package com.topdraw.weixin.beans;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WeiXinBean {
//
private String appid;
private String openId;
private String code;
private String token;
private String secret;
private String unionId;
private String nickname;
private String headImgUrl;
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.JSONObject;
public interface WeiXinBeanDefinition {
String getAppId();
String getCode();
String getToken();
String getSecret();
String getOpenId();
String getUnionId();
String getNickname();
String getHeadImgUrl();
JSONObject getUserInfo();
}
package com.topdraw.weixin.beans;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Map;
@Data
public class WeiXinNotice {
@JSONField(serialize=false)
private String appid;
@JSONField(serialize=false)
private Long userId;
//目标用户
@JSONField(name = "touser")
private String toUser;
// 模板code
@JSONField(serialize=false)
private String code;
// 模板id
@JSONField(name = "template_id")
private String templateId;
// 点击通知跳转页面
private String page;
// 小程序版本
@JSONField(name = "miniprogram_state")
private String miniprogramState;
// 填充数据
private Map<String, Object> data;
}
package com.topdraw.weixin.beans;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
public interface WeiXinUserParser {
DefaultWeiXinBeanDefinition parse(WeiXinUserBean appletUserLoginInfo);
}
package com.topdraw.weixin.beans.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Data
@Configuration
@ConfigurationProperties(prefix = "weixin")
public class WeiXinAppListConfig {
private List<Map<String, String>> list;
/*@Value("${uc.service.platform:}")
private String platform;
@Value("${key:}")
private String key;
@Value("${uc.app.subAppId:wx05f35931270014be}")
private String subAppId;
@Value("${uc.app.h5AppId:wxca962918dfeed88c}")
private String h5AppId;
@Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
private String appletAppid;
@Value("${file.upload:upload}")
private String filePath;*/
}
package com.topdraw.weixin.util;
public class WeChatConstants {
public static String HTTPS_AUTHORIZE_WITH_SNSAPI_USERINFO = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
public static final String HTTPS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token";
public static final String HTTPS_TICKET_GETTICKET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
public static final String HTTPS_SNS_OAUTH2_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token";
public static final String HTTPS_SNS_USERINFO = "https://api.weixin.qq.com/sns/userinfo";
public static final String CODE2SESSION = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
/**
* 把媒体文件上传到微信服务器。目前仅支持图片。用于发送客服消息或被动回复用户消息。
*/
public static String UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type=image";
/**
* 获取客服消息内的临时素材。即下载临时的多媒体文件。
*/
public static String GET_MEDIA = "https://api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}";
/**
* 用于向微信服务端申请二维码的url
*/
public static String URL_QR_CODE = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}";
/**
* 用于聊天时向用户发送消息的url
*/
public static String CUSTOM_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";
/**
* 发送小程序订阅消息
*/
public static final String SUBSCRIBE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={0}";
/**
* 生成带参数二维码
*/
public static final String QR_CODE_URL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}";
/**
* 获取用户基本信息
*/
public static final String GET_USER_INFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN";
// 批量获取关注者列表
public static final String GET_USER_LIST = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}";
/**
* 成功
*/
public static String SUCCESS = "SUCCESS";
/**
* 微信系统错误
*/
public static String SYSTEMERROR = "SYSTEMERROR";
/**
* 失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
*/
public static String FAIL = "FAIL";
/**
* 微信企业付款到个人失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
*/
public static String FAILED = "FAILED";
public static String ACCESS_TOKEN = "access_token";
public static String ERR_CODE = "errcode";
/**
* 微信请求时,返回ACCESS_TOKEN错误码
*/
public static final String ACCESS_TOKEN_INVALID_CODE = "40001";
/**
* 文本消息
*/
public static String MSG_TYPE_TEXT = "text";
public static String MSG_TYPE_MINIPROGRAMPAGE = "miniprogrampage";
public static String MSG_TYPE_LINK = "link";
public static String MSG_TYPE_IMAGE = "image";
/**
* 事件消息
*/
public static String MSG_TYPE_EVENT = "event";
/**
* 二维码类型,临时的整型参数值
*/
public static String QR_SCENE = "QR_SCENE";
/**
* 二维码类型,临时的字符串参数值
*/
public static String QR_STR_SCENE = "QR_STR_SCENE";
/**
* 二维码类型,永久的整型参数值
*/
public static String QR_LIMIT_SCENE = "QR_LIMIT_SCENE";
/**
* 二维码类型,永久的字符串参数值
*/
public static String QR_LIMIT_STR_SCENE = "QR_LIMIT_STR_SCENE";
/******** 事件推送事件类型BEGIN********/
/**
* 取消订阅
*/
public static final String EVENT_UNSUBSCRIBE = "unsubscribe";
/**
* 订阅
*/
public static final String EVENT_SUBSCRIBE = "subscribe";
/**
* 扫描带参数二维码事件,用户已关注时的事件推送
*/
public static final String EVENT_SCAN = "SCAN";
/**
* 上报地理位置事件
*/
public static final String EVENT_LOCATION = "LOCATION";
/**
* 自定义菜单事件
*/
public static final String EVENT_CLICK = "CLICK";
/******** 事件推送事件类型END********/
/**
* 微信ACCESS_TOKEN缓存KEY
*/
public static final String TOKEN_KEY = "GLOBAL_WX_ACCESS_TOKEN_";
/**
* 微信临时素材缓存KEY
*/
public static final String WEIXIN_MEDIA_KEY = "WEIXIN_MEDIA_KEY_";
// 微信应用类型 小程序 服务号 订阅号
// 小程序
public static final String WX_APPLET = "applet";
// 服务号
public static final String WX_SERVICE = "service";
// 订阅号
public static final String WX_SUBSCRIPTION = "subscription";
}
package com.topdraw.weixin.util;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.StringUtils;
import com.topdraw.weixin.beans.QrCode;
import com.topdraw.weixin.beans.WeiXinNotice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Component
@Slf4j
public class WeiXinRequestUtil {
@Autowired
private RedisUtils redisUtils;
/**
*
* */
private static String doGet(String url, Map<String, String> param) {
String result = null;
try {
String queryString = "";
if (null != param) {
for (Map.Entry<String, String> entry : param.entrySet()) {
queryString += entry.getKey() + "=" + URLEncoder.encode("" + entry.getValue(), "UTF-8") + "&";
}
if (queryString.length() > 0) {
queryString = queryString.substring(0, queryString.length() - 1);
}
}
log.info("weixin request: " + url + "?" + queryString);
HttpResponse response = HttpRequest.get(url + "?" + queryString).execute();
if (response.isOk()) {
result = response.body();
log.info("weixin response: " + result);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private String wx_token(String appid, String secret) {
Map<String, String> param = new HashMap<>();
param.put("grant_type", "client_credential");
param.put("appid", appid);
param.put("secret", secret);
return this.doGet(WeChatConstants.HTTPS_TOKEN, param);
}
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public String wx_ticket_getticket(String appid, String secret) {
String token = getToken(appid, secret,null);
Map<String, String> param = new HashMap<>();
param.put("access_token", token);
param.put("type", "jsapi");
return doGet(WeChatConstants.HTTPS_TICKET_GETTICKET, param);
}
public String wx_sns_oauth2_access_token(String appid, String secret, String code) {
Map<String, String> param = new HashMap<>();
param.put("appid", appid);
param.put("secret", secret);
param.put("code", code);
param.put("grant_type", "authorization_code");
return doGet(WeChatConstants.HTTPS_SNS_OAUTH2_ACCESS_TOKEN, param);
}
public String wx_sns_userinfo(String oauth2_access_token, String openid) {
Map<String, String> param = new HashMap<>();
param.put("access_token", oauth2_access_token);
param.put("openid", openid);
param.put("lang", "zh_CN");
return doGet(WeChatConstants.HTTPS_SNS_USERINFO, param);
}
public String wx_get_userinfo(String oauth2_access_token, String openid) {
Map<String, String> param = new HashMap<>();
param.put("access_token", oauth2_access_token);
param.put("openid", openid);
param.put("lang", "zh_CN");
return doGet(WeChatConstants.GET_USER_INFO, param);
}
public String getToken(String appid, String secret,String code) {
String token = (String) redisUtils.get(WeChatConstants.TOKEN_KEY + appid);
if (StringUtils.isNotBlank(token)) {
return token;
}
token = this.getTokenNoRedis(appid, secret,code);
return token;
}
public String getToken(String appid, String secret) {
String token = (String) redisUtils.get(WeChatConstants.TOKEN_KEY + appid);
if (StringUtils.isNotBlank(token)) {
return token;
}
token = this.getTokenNoRedis(appid, secret,null);
return token;
}
public String getTokenNoRedis(String appid, String secret,String code) {
String token = null;
String response = this.wx_token(appid, secret);
// String response = this.wx_sns_oauth2_access_token(appid, secret,code);
try {
JSONObject joToken = JSON.parseObject(response);
if (null != joToken && null != joToken.getString("access_token")) {
token = joToken.getString("access_token");
Integer expiresIn = joToken.getInteger("expires_in");
redisUtils.set(WeChatConstants.TOKEN_KEY + appid, token, expiresIn, TimeUnit.SECONDS);
}
} catch (Exception e) {
e.printStackTrace();
}
return token;
}
public String getTokenNoRedis(String appid, String secret) {
String token = null;
// String response = this.wx_token(appid, secret);
String response = this.wx_sns_oauth2_access_token(appid, secret,null);
try {
JSONObject joToken = JSON.parseObject(response);
if (null != joToken && null != joToken.getString("access_token")) {
token = joToken.getString("access_token");
Integer expiresIn = joToken.getInteger("expires_in");
redisUtils.set(WeChatConstants.TOKEN_KEY + appid, token, expiresIn, TimeUnit.SECONDS);
}
} catch (Exception e) {
e.printStackTrace();
}
return token;
}
/**
* 发送订阅消息,access_token错误时,重新获取进行重试
*
* @param weixinInfo 微信参数
* @param request 订阅消息内容
*/
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public void sendNotice(Map<String, String> weixinInfo, WeiXinNotice request) {
String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
String url = MessageFormat.format(WeChatConstants.SUBSCRIBE_SEND_URL, accessToken);
log.info("send notice request : " + JSONObject.toJSONString(request));
HttpResponse response = HttpRequest.post(url).body(JSONObject.toJSONString(request), "application/json;charset=utf-8").execute();
if (!response.isOk()) {
log.error("send notice error || {}", response);
throw new RuntimeException("send notice error");
}
JSONObject jsonObject = JSONObject.parseObject(response.body());
Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
if (errCode != null && errCode != 0) {
if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
}
// 返回errCode时,也输出返回的结果信息
log.error("send notice error || {}", response.body());
throw new RuntimeException("send notice error");
}
log.info("send notice response : " + response.body());
}
/**
* 微信小程序客服发送消息,access_token错误时,重新获取进行重试
*
* @param weixinInfo 微信参数
* @param body 消息内容
*/
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public void sendMessage(Map<String, String> weixinInfo, String body) {
String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
String url = MessageFormat.format(WeChatConstants.CUSTOM_SEND_URL, accessToken);
HttpResponse response = HttpRequest.post(url).body(body, "application/json;charset=utf-8").execute();
if (!response.isOk()) {
log.error("send message error || {}", response);
throw new RuntimeException("send message error");
}
log.info("send message response || {}", response.body());
JSONObject jsonObject = JSONObject.parseObject(response.body());
Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
if (errCode != null && errCode != 0) {
if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
}
throw new RuntimeException("send message error");
}
}
/**
* 上传临时素材返回mediaId,access_token错误时,重新获取进行重试
*
* @param weixinInfo 微信参数
* @param imagePath 素材路径
*/
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public String getMediaId(Map<String, String> weixinInfo, String imagePath) throws IOException {
String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
String mediaId = (String) redisUtils.get(WeChatConstants.WEIXIN_MEDIA_KEY + weixinInfo.get("appid"));
if (StringUtils.isNotBlank(mediaId)) {
return mediaId;
}
String url = MessageFormat.format(WeChatConstants.UPLOAD_URL, accessToken);
HttpResponse response = HttpRequest.post(url).form("file", new File(imagePath)).execute();
if (!response.isOk()) {
log.error("upload image error || {}", response);
throw new RuntimeException("upload image error");
}
log.info("upload image response || {}", response.body());
JSONObject jsonObject = JSONObject.parseObject(response.body());
Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
if (errCode != null && errCode != 0) {
if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
}
throw new RuntimeException("upload image error");
}
mediaId = jsonObject.getString("media_id");
redisUtils.set(WeChatConstants.WEIXIN_MEDIA_KEY + weixinInfo.get("appid"), mediaId, 60, TimeUnit.HOURS);
return mediaId;
}
/**
* 公众号获取带参数二维码,access_token错误时,重新获取进行重试
*
* @param weixinInfo 微信参数
* @param qrCode 二维码信息
*/
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public JSONObject getQrCode(Map<String, String> weixinInfo, QrCode qrCode) throws IOException {
String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
String url = MessageFormat.format(WeChatConstants.QR_CODE_URL, accessToken);
HttpResponse response = HttpRequest.post(url).body(JSONObject.toJSONString(qrCode), "application/json;charset=utf-8").execute();
if (!response.isOk()) {
log.error("get qrCode error || {}", response);
throw new RuntimeException("get qrCode error");
}
log.info("get qrCode response || {}", response.body());
JSONObject jsonObject = JSONObject.parseObject(response.body());
Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
if (errCode != null && errCode != 0) {
if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
}
throw new RuntimeException("get qrCode error");
}
return jsonObject;
}
/**
* 公众号获取用户信息,access_token错误时,重新获取进行重试
*
* @param weixinInfo 微信参数
* @param openid 用户openid
*/
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public JSONObject getUserInfo(Map<String, String> weixinInfo, String openid,String code) throws IOException {
String accessToken = this.getToken(weixinInfo.get("appid"), weixinInfo.get("secret"),code);
String url = MessageFormat.format(WeChatConstants.GET_USER_INFO, accessToken, openid);
// String url = MessageFormat.format(WeChatConstants.HTTPS_SNS_USERINFO, accessToken, openid);
// String url = MessageFormat.format(WeChatConstants.HTTPS_AUTHORIZE_WITH_SNSAPI_USERINFO, accessToken, openid);
HttpResponse response = HttpRequest.get(url).execute();
if (!response.isOk()) {
log.error("get userInfo error || {}", response);
throw new RuntimeException("get userInfo error");
}
log.info("get userInfo response || {}", response.body());
JSONObject jsonObject = JSONObject.parseObject(response.body());
Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
if (errCode != null && errCode != 0) {
if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
this.getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
}
throw new RuntimeException("get userInfo error");
}
return jsonObject;
}
/**
* 公众号获取用户信息,access_token错误时,重新获取进行重试
*
* @param weixinInfo 微信参数
* @param openid 用户openid
*/
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public JSONObject getUserInfo(Map<String, String> weixinInfo, String openid) throws IOException {
return this.getUserInfo(weixinInfo,openid,"");
}
/**
* @param weixinInfo
* @param nextOpenId
* @return com.alibaba.fastjson.JSONObject
* @description 公众号批量获取关注者列表,不传nextOpenId默认从头开始拉取,引用重试机制
* @author Hongyan Wang
* @date 2021/9/2 9:42 上午
*/
@Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 0L, multiplier = 0.0))
public JSONObject getUserList(Map<String, String> weixinInfo, String nextOpenId) {
String accessToken = getToken(weixinInfo.get("appid"), weixinInfo.get("secret"));
// 不传next_openid,默认从头开始拉取
if (StrUtil.isBlank(nextOpenId))
nextOpenId = "";
String url = MessageFormat.format(WeChatConstants.GET_USER_LIST, accessToken, nextOpenId);
HttpResponse response = HttpRequest.get(url).execute();
if (!response.isOk()) {
log.error("get userList error || {}", response);
throw new RuntimeException("get userList error");
}
log.info("get userList response || {}", response.body());
//返回Json样例
// {
// "total":2,
// "count":2,
// "data":{
// "openid":["OPENID1","OPENID2"]},
// "next_openid":"NEXT_OPENID"
//}
JSONObject jsonObject = JSONObject.parseObject(response.body());
Integer errCode = jsonObject.getInteger(WeChatConstants.ERR_CODE);
if (errCode != null && errCode != 0) {
if (WeChatConstants.ACCESS_TOKEN_INVALID_CODE.equals(errCode.toString())) {
getTokenNoRedis(weixinInfo.get("appid"), weixinInfo.get("secret"));
}
throw new RuntimeException("get userList error");
}
return jsonObject;
}
}
package com.topdraw.weixin.util;
import com.topdraw.config.WeixinInfoConfig;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Component
@Slf4j
public class WeixinUtil {
private static WeixinInfoConfig WEIXININFOCONFIG;
@Autowired
public void setWeixinInfoConfig(WeixinInfoConfig weixinInfoConfig) {
WEIXININFOCONFIG = weixinInfoConfig;
}
public static Map<String, String> getWeixinInfoByAppid(String appid) {
if (StringUtils.isBlank(appid)) {
throw new RuntimeException("wxAppid can not be null");
}
List<Map<String, String>> list = WEIXININFOCONFIG.getList();
Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
if (!weixinInfoOptional.isPresent()) {
throw new RuntimeException("wxAppid error, appid is : " + appid);
}
return weixinInfoOptional.get();
}
public static Map<String, String> getWeixinInfoByIndex(Integer index) {
List<Map<String, String>> list = WEIXININFOCONFIG.getList();
if (list.size() < index + 1) {
throw new RuntimeException("wxinfo error, index out of range : {}" + index);
}
return list.get(index);
}
/**
* 使用SHA1算法对字符串数组进行加密
*
* @param strList
* @return
*/
public static String encodeUsingSHA1(String... strList) {
//将strList的值进行字典排序
Arrays.sort(strList);
StringBuilder content = new StringBuilder();
for (int i = 0; i < strList.length; i++) {
content.append(strList[i]);
}
return doEncodeUsingSHA1(content.toString());
}
/**
* SHA1实现
*
* @return sha1加密后的字符串
*/
private static String doEncodeUsingSHA1(String inStr) {
byte[] byteArray ;
try {
MessageDigest sha = MessageDigest.getInstance("SHA-1");
byteArray = sha.digest(inStr.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("no sha-1 algorithm");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported utf-8 encoding");
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < byteArray.length; i++) {
sb.append(Integer.toString((byteArray[i] & 0xff) + 0x100, 16).substring(1));
}
return sb.toString();
}
/**
* 公众号,小程序后台配置服务器,初次检验时使用
* @throws IOException
*/
public static void doGet(HttpServletRequest request, HttpServletResponse response, Map<String, String> weixinInfo) throws IOException {
log.info("doGet receive WeChat server request parameters:{}", request.getParameterMap());
String signature = request.getParameter("signature");
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
String echoStr = request.getParameter("echostr");
String[] arr = new String[]{weixinInfo.get("token"), timestamp, nonce};
String encrypt = WeixinUtil.encodeUsingSHA1(arr);
if (encrypt.equals(signature)) {
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(echoStr.getBytes());
outputStream.flush();
}
}
}
......@@ -6,14 +6,6 @@ spring:
username: root
password: Tjlh@2017
# url: jdbc:log4jdbc:mysql://47.100.212.170:3306/ucs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
# username: root
# password: Tjlh@2021
# url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
# username: root
# password: root
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
#Druid
type: com.alibaba.druid.pool.DruidDataSource
......@@ -107,5 +99,3 @@ generator:
swagger:
enabled: true
service:
platform: management
\ No newline at end of file
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
-->
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
<id>member-service-impl</id>
<classpath>
<dir name="C:/Users/lenovo/Documents/workspace/member-service/member-service-impl/target/classes">
</dir>
</classpath>
</application>
package com.topdraw;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.module.mq.DataSyncMsg;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@SpringBootTest(classes= MemberServiceApplication.class)
@RunWith(SpringRunner.class)
public class BaseTest {
public Logger LOG = LoggerFactory.getLogger(BaseTest.class);
private static String replaceUrl(String body, String ftpPath) {
boolean contains = body.contains("<source src=");
if (contains) {
body = body.replaceAll( "(<source src=(.*?)/>)","<source src="+"\""+ftpPath+"\"/>");
body = body.replaceAll("(<source src=(.*?)/>)", "<source src=" + "\"" + ftpPath + "\"/>");
}
return body;
}
public static void main(String[] args) {
String a = "<p>gfdsgf <video controls=\"controls\" width=\"300\" height=\"150\">\n" +
"<source src=\"dddd\" /></video></p>";
/* Map<String,Integer> map = new HashMap<>();
map.put("1",1);
map.put("2",15);
String c = "<p>测试正文<br /><br /><video controls=\"controls\" width=\"360\" height=\"180\">\n" +
"<source src=\"test\" /></video></p>";
int i = 5;
Object[] objects = map.values().toArray();
Integer object0 = (Integer) objects[0];
Integer object1 = (Integer) objects[1];
if (i > object0 && i < object1)
System.out.println(true);*/
String b = "{{nas-base-url.cms-upload}}/upload/commonFile/theme_activity/2021-12-15/aebd8dbb-87bb-4523-921f-4354c3298fdd.mp4";
String s = replaceUrl(c, b);
System.out.println(s);
String param = "{\"GOODS\":\"aabbccddeeff\"}";
Map<String,String> jsonObject = JSONObject.parseObject(param,Map.class);
System.out.println(jsonObject);
}
}
......
......@@ -39,16 +39,16 @@ public class GeneratorCode extends BaseTest {
@Rollback(value = false)
@Transactional(rollbackFor = Exception.class)
public void generator() {
var dbName = "uc_user_weixin";
var dbName = "tr_task_attr";
// 表名称,支持多表
var tableNames = Arrays.asList(dbName);
String[] s = dbName.split("_");
var pre = s[0];
var target1 = s[s.length-1];
var preRoute = "com.topdraw.business.basicdata.user.";
var preRoute = "com.topdraw.business.module.task.";
StringBuilder builder = new StringBuilder(preRoute);
builder.append("weixin");
builder.append("attribute");
// builder.append(target);
tableNames.forEach(tableName -> {
......
package com.topdraw.test.business.basicdata.member;
import com.topdraw.business.basicdata.member.rest.MemberController;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.rest.MemberController;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.BaseTest;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
......
......@@ -2,10 +2,8 @@ package com.topdraw.test.business.basicdata.member.profile;
import com.alibaba.fastjson.JSON;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import com.topdraw.business.basicdata.member.profile.service.MemberProfileService;
import com.topdraw.business.basicdata.member.service.MemberService;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.member.rest;
import com.alibaba.fastjson.JSON;
import com.topdraw.business.basicdata.member.address.domain.MemberAddress;
import com.topdraw.business.basicdata.member.address.rest.MemberAddressController;
import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.rest.MemberAddressController;
import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
import com.topdraw.common.ResultInfo;
import com.topdraw.BaseTest;
import org.junit.Test;
......
package com.topdraw.test.business.basicdata.member.rest;
import com.alibaba.fastjson.JSON;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.basicdata.member.rest.MemberController;
import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.rest.MemberController;
import com.topdraw.common.ResultInfo;
import com.topdraw.BaseTest;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import java.time.LocalDateTime;
public class MemberControllerTest extends BaseTest {
......@@ -78,7 +77,7 @@ public class MemberControllerTest extends BaseTest {
member.setDueCouponAmount(0L);
member.setUserIptvId(1L);
member.setBindIptvPlatformType(0);
member.setUpdateTime(TimestampUtil.now());
member.setUpdateTime(LocalDateTime.now());
String s = JSON.toJSONString(member);
ResultInfo byId = this.memberController.create(member);
LOG.info("===>>>"+byId);
......
......@@ -2,9 +2,8 @@ package com.topdraw.test.business.basicdata.member.rest;
import com.alibaba.fastjson.JSON;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.member.profile.domain.MemberProfile;
import com.topdraw.business.basicdata.member.profile.rest.MemberProfileController;
import com.topdraw.business.basicdata.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.rest.MemberProfileController;
import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.member.rest;
import com.alibaba.fastjson.JSON;
import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.basicdata.member.relatedinfo.rest.MemberRelatedInfoController;
import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
import com.topdraw.business.module.member.relatedinfo.rest.MemberRelatedInfoController;
import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
import com.topdraw.common.ResultInfo;
import com.topdraw.BaseTest;
import org.junit.Test;
......
package com.topdraw.test.business.basicdata.points;
import com.topdraw.business.basicdata.points.available.domain.PointsAvailable;
import com.topdraw.business.basicdata.points.available.service.PointsAvailableService;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.BaseTest;
import com.topdraw.util.DateUtil;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.points;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.basicdata.points.detail.service.PointsDetailService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.BaseTest;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.rights;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.member.service.dto.MemberDTO;
import com.topdraw.business.basicdata.points.detail.domain.PointsDetail;
import com.topdraw.business.basicdata.points.detail.service.PointsDetailService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.rights.history;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria;
import com.topdraw.business.basicdata.rights.history.rest.RightsHistoryController;
import com.topdraw.business.basicdata.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.business.basicdata.rights.rest.RightsController;
import com.topdraw.business.module.rights.history.rest.RightsHistoryController;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.rights.permanentrights;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.rights.permanentrights.rest.PermanentRightsController;
import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.business.basicdata.rights.rest.RightsController;
import com.topdraw.business.module.rights.permanentrights.rest.PermanentRightsController;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.rights.rest;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.rights.rest.RightsController;
import com.topdraw.business.module.rights.rest.RightsController;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.basicdata.task;
import com.topdraw.business.basicdata.task.template.domain.TaskTemplate;
import com.topdraw.business.basicdata.task.template.service.TaskTemplateService;
import com.topdraw.business.module.task.template.domain.TaskTemplate;
import com.topdraw.business.module.task.template.service.TaskTemplateService;
import com.topdraw.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.process.rest;
import com.alibaba.fastjson.JSON;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryType;
import com.topdraw.business.basicdata.points.detail.rest.PointsDetailController;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.points.detail.service.dto.PointsDetailQueryCriteria;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.business.process.rest.PointsOperationController;
import com.topdraw.common.ResultInfo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
public class PointsOperationControllerTest extends BaseTest {
......
......@@ -2,10 +2,9 @@ package com.topdraw.test.business.process.rest;
import com.topdraw.BaseTest;
import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.business.process.rest.RightsOperationController;
import com.topdraw.common.ResultInfo;
import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......
package com.topdraw.test.business.process.rest;
import com.alibaba.fastjson.JSON;
import com.topdraw.business.basicdata.points.service.dto.PointsQueryCriteria;
import com.topdraw.business.process.rest.TaskOperationController;
import com.topdraw.business.process.rest.TaskOperationQueryCriteria;
import com.topdraw.module.mq.DataSyncMsg;
import com.topdraw.module.mq.EntityType;
import com.topdraw.module.mq.EventType;
import com.topdraw.BaseTest;
import com.topdraw.utils.StringUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class TaskOperationControllerTest extends BaseTest {
......
package com.topdraw.test.business.process.service;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.business.basicdata.member.domain.Member;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.BaseTest;
import com.topdraw.util.IdWorker;
......@@ -9,6 +9,8 @@ import com.topdraw.util.TimestampUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDateTime;
public class MemberOperationServiceTest extends BaseTest {
@Autowired
......@@ -43,7 +45,7 @@ public class MemberOperationServiceTest extends BaseTest {
member.setDueCouponAmount(0L);
member.setUserIptvId(1L);
member.setBindIptvPlatformType(0);
member.setUpdateTime(TimestampUtil.now());
member.setUpdateTime(LocalDateTime.now());
String s = JSONObject.toJSONString(member);
this.memberOperationService.doUpdateMemberInfo(member);
......@@ -71,9 +73,9 @@ public class MemberOperationServiceTest extends BaseTest {
member.setDueCouponAmount(0L);
member.setUserIptvId(1L);
member.setBindIptvPlatformType(0);
member.setBindIptvTime(TimestampUtil.now());
member.setCreateTime(TimestampUtil.now());
member.setUpdateTime(TimestampUtil.now());
member.setBindIptvTime(LocalDateTime.now());
member.setCreateTime(LocalDateTime.now());
member.setUpdateTime(LocalDateTime.now());
// member.setUpdateTime(Timestamp.valueOf(LocalDateTime.now()));
this.memberOperationService.doInsertMember(member);
}
......
package com.topdraw.test.business.process.service;
import com.alibaba.fastjson.JSON;
import com.topdraw.BaseTest;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.module.mq.DataSyncMsg;
import com.topdraw.module.mq.EventType;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class UserOperationServiceTest extends BaseTest {
@Autowired
UserOperationService taskOperationService;
@Test
public void appletLogin() {
/* Long memberId = 3L;
DataSyncMsg dataSyncMsg = new DataSyncMsg();
// dataSyncMsg.setEntityType(EntityType.MEMBER);
dataSyncMsg.setEventType(EventType.LOGIN.name());
DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData();
msgData.setEvent(1);
msgData.setRemarks("remark");
msgData.setMemberId(memberId);
msgData.setDeviceType(2);
msgData.setAppCode("WEI_XIN_GOLD_PANDA");
dataSyncMsg.setMsg(msgData);
String s = JSON.toJSONString(dataSyncMsg);*/
WeiXinUserBean weiXinUserBean = new WeiXinUserBean();
weiXinUserBean.setWxAppid("1");
weiXinUserBean.setWxCode("1");
weiXinUserBean.setSourceType("1");
weiXinUserBean.setSourceId("1");
weiXinUserBean.setIv("1");
weiXinUserBean.setEncryptedData("1");
weiXinUserBean.setSourceEntity("1");
weiXinUserBean.setSourceDesc("1");
weiXinUserBean.setSourceUser(1L);
weiXinUserBean.setUserInfo("1");
this.taskOperationService.appletLogin(weiXinUserBean);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file