Commit 33ef06bb 33ef06bb886b7d4479c754a937b300da6ada4820 by xianghan

1.调整部分系统默认配置

1 parent 31bc317b
......@@ -29,7 +29,7 @@ public class UserAppBind implements Serializable {
@Transient
private String password;
@Transient
private String headImgUrl;
private String headimgurl;
// 主键
@Id
......
......@@ -40,7 +40,7 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec
Integer updatePasswordById(Long id, String password);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `status` = -1 WHERE `id` = ?1", nativeQuery = true)
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `delete_time` = now(), `status` = -1 WHERE `id` = ?1", nativeQuery = true)
Integer appCancellation(Long id);
@Modifying
......
package com.topdraw.business.module.user.app.service.dto;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import lombok.Data;
import java.io.Serializable;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/7/11 21:21
* @version: :
* @modified By:
* @since : modified in 2022/7/11 21:21
*/
@Data
public class AppRegisterDTO implements Serializable {
private UserAppDTO userAppDTO;
private MemberDTO memberDTO;
}
package com.topdraw.business.module.user.app.service.dto;
import lombok.Data;
import javax.persistence.Transient;
import java.sql.Timestamp;
import java.io.Serializable;
......@@ -12,6 +14,11 @@ import java.io.Serializable;
@Data
public class UserAppDTO implements Serializable {
private Integer accountType;
// 第三方账号
private String account;
// ID
private Long id;
......
......@@ -3,7 +3,6 @@ package com.topdraw.business.process.rest;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.annotation.Log;
......@@ -33,7 +32,6 @@ import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.resttemplate.RestTemplateClient;
import com.topdraw.util.Base64Util;
import com.topdraw.util.JSONUtil;
import com.topdraw.util.RegexUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.weixin.util.WeChatConstants;
import com.topdraw.weixin.util.WeixinUtil;
......@@ -184,7 +182,7 @@ public class UserOperationController {
@ApiOperation("app账号绑定第三方账号")
@AnonymousAccess
public ResultInfo appBindThirdAccount(@Validated @RequestBody UserAppBind resources) {
log.info("app账号绑定第三方账号,参数 ==>> [appBindUserAccount#{}]", resources);
log.info("app账号绑定第三方账号,参数 ==>> [appBindThirdAccount#{}]", resources);
String username = resources.getUsername();
if (StringUtils.isBlank(username)) {
......@@ -291,7 +289,11 @@ public class UserOperationController {
if (!CollectionUtils.isEmpty(playDurationWithCategory)) {
GrowthReport growthReport = new GrowthReport();
growthReport.setPlatformAccount(platformAccount);
growthReport.setData(JSONArray.toJSONString(playDurationWithCategory));
JSONObject jsonObject = new JSONObject();
// jsonObject.put("playDurationWithCategory", JSONArray.toJSONString(playDurationWithCategory));
jsonObject.put("playDurationWithCategory", playDurationWithCategory);
growthReport.setData(jsonObject.toJSONString());
boolean result = this.userOperationService.saveGrowthReport(growthReport);
return ResultInfo.success(result);
}
......
......@@ -15,6 +15,7 @@ import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
import com.topdraw.business.module.user.app.domain.*;
import com.topdraw.business.module.user.app.service.UserAppBindService;
import com.topdraw.business.module.user.app.service.UserAppService;
import com.topdraw.business.module.user.app.service.dto.AppRegisterDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
......@@ -52,7 +53,6 @@ import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.resttemplate.RestTemplateClient;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.RedisUtils;
......@@ -72,7 +72,6 @@ import org.springframework.util.CollectionUtils;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -146,9 +145,18 @@ public class UserOperationServiceImpl implements UserOperationService {
// 保存绑定关系
UserAppBind userAppBind = UserAppBindBuilder.build(_userAppDTO.getId(), resources.getAccount(), resources.getAccountType());
this.userAppBindService.create(userAppBind);
_userAppDTO.setAccount(resources.getAccount());
_userAppDTO.setAccountType(resources.getAccountType());
}
}
AppRegisterDTO appRegisterDTO = new AppRegisterDTO();
appRegisterDTO.setMemberDTO(memberDTO);
appRegisterDTO.setUserAppDTO(_userAppDTO);
((UserOperationServiceImpl)AopContext.currentProxy()).asyncAppRegister(appRegisterDTO);
return _userAppDTO;
}
......@@ -164,19 +172,29 @@ public class UserOperationServiceImpl implements UserOperationService {
Integer accountType = resources.getAccountType();
UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
if (Objects.nonNull(userAppBindDTO.getId())) {
return this.userAppBindService.cancelUserAppBind(account, accountType);
boolean result = this.userAppBindService.cancelUserAppBind(account, accountType);
/* if (result) {
UserAppBindDTO _userAppBindDTO = new UserAppBindDTO();
_userAppBindDTO.setAccount(account);
_userAppBindDTO.setAccountType(accountType);
((UserOperationServiceImpl) AopContext.currentProxy()).asyncCancelUserAppBind(_userAppBindDTO);
}*/
return result;
}
return false;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean appBindThirdAccount(UserAppBind resources) {
String username = resources.getUsername();
String headImgUrl = resources.getHeadImgUrl();
String headImgUrl = resources.getHeadimgurl();
String nickname = resources.getNickname();
UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
log.info("通过app账号查询app信息是否存在,[appBindThirdAccount#{}]", userAppDTO);
if (Objects.isNull(userAppDTO.getId())) {
return false;
}
......@@ -184,35 +202,80 @@ public class UserOperationServiceImpl implements UserOperationService {
if (Objects.isNull(userAppDTO.getHeadimgurl())) {
UserApp userApp = new UserApp();
userApp.setUsername(username);
if (StringUtils.isNotBlank(headImgUrl) && StringUtils.isNotBlank(nickname)) {
if (StringUtils.isNotBlank(headImgUrl)) {
if (headImgUrl.contains("http") || headImgUrl.contains("https")) {
String image = this.downloadWeixinImgeFromAppEngine(headImgUrl);
userApp.setHeadimgurl(image);
}
}
userApp.setNickname(nickname);
this.userAppService.updateAppLastActiveTimeAndNicknameAndHeadImg(userApp);
log.info("同步app账号的昵称、头像,[appBindThirdAccount#{}]", userAppDTO);
boolean result = this.userAppService.updateAppLastActiveTimeAndNicknameAndHeadImg(userApp);
if (result) {
UserAppDTO userAppDTO1 = new UserAppDTO();
BeanUtils.copyProperties(userApp, userAppDTO1);
((UserOperationServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(userAppDTO1);
}
}
String account = resources.getAccount();
Integer accountType = resources.getAccountType();
UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
if (Objects.nonNull(userAppBindDTO.getId())){
if (Objects.nonNull(userAppBindDTO.getId())) {
resources.setUserAppId(userAppDTO.getId());
boolean result = this.userAppBindService.updateValidStatusAndUserAppIdAndNickname(resources);
if (result) {
UserAppDTO userAppDTO1 = new UserAppDTO();
userAppDTO1.setUsername(username);
userAppDTO1.setNickname(nickname);
userAppDTO1.setHeadimgurl(headImgUrl);
((UserOperationServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(userAppDTO1);
}
return result;
} else {
resources.setUserAppId(userAppDTO.getId());
return this.userAppBindService.updateValidStatusAndUserAppIdAndNickname(resources);
resources.setStatus(1);
log.info("第三方账号不存在,新增关联关系[appBindThirdAccount#{}]", resources);
this.userAppBindService.create(resources);
UserAppDTO userAppDTO1 = new UserAppDTO();
BeanUtils.copyProperties(resources, userAppDTO1);
userAppDTO1.setUsername(username);
((UserOperationServiceImpl) AopContext.currentProxy()).asyncCreateUserAppBindThirdAccount(userAppDTO1);
return true;
}
return false;
}
@Override
public UserAppSimpleDTO updateAppInfo(UserApp resources) {
return this.userAppService.updateAppInfo(resources);
UserAppSimpleDTO userAppSimpleDTO = this.userAppService.updateAppInfo(resources);
if (Objects.nonNull(userAppSimpleDTO.getId())) {
UserAppDTO userAppDTO = new UserAppDTO();
BeanUtils.copyProperties(resources, userAppDTO);
userAppDTO.setUsername(userAppSimpleDTO.getUsername());
((UserOperationServiceImpl)AopContext.currentProxy()).asyncUpdateAppInfo(userAppDTO);
}
return userAppSimpleDTO;
}
@Override
public boolean updatePasswordById(UserApp resources) {
return this.userAppService.updatePasswordById(resources);
UserAppDTO userAppDTO = this.userAppService.findById(resources.getId());
if (Objects.nonNull(userAppDTO.getId())) {
if (this.userAppService.updatePasswordById(resources)) {
((UserOperationServiceImpl)AopContext.currentProxy()).asyncUpdatePasswordByUsername(userAppDTO);
return true;
}
}
return false;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveGrowthReport(GrowthReport growthReport) {
......@@ -224,13 +287,10 @@ public class UserOperationServiceImpl implements UserOperationService {
return false;
}
String weekFirstDay = com.topdraw.util.DateUtil.getWeekFirstDay();
String weekLastDay = com.topdraw.util.DateUtil.getWeekLastDay();
GrowthReportDTO growthReportDTO = this.growthReportService.findByPlatformAccountAndStartDateAndEndDate(platformAccount, weekFirstDay, weekLastDay);
if (Objects.isNull(growthReportDTO.getId())) {
Long id = userTvDTO.getId();
Long memberId = userTvDTO.getMemberId();
growthReport.setUserId(id);
......@@ -238,7 +298,6 @@ public class UserOperationServiceImpl implements UserOperationService {
growthReport.setStartDate(weekFirstDay);
growthReport.setEndDate(weekLastDay);
this.growthReportService.create(growthReport);
} else {
this.growthReportService.updateGrowthReportData(growthReportDTO.getId(), growthReport.getData());
}
......@@ -256,16 +315,18 @@ public class UserOperationServiceImpl implements UserOperationService {
if (b) {
List<UserAppBindDTO> userAppBindDTOS = this.userAppBindService.findByUserAppId(userAppDTO.getId());
if (!CollectionUtils.isEmpty(userAppBindDTOS)) {
List<Long> ids = userAppBindDTOS.stream().map(t -> t.getId()).collect(Collectors.toList());
List<Long> ids = userAppBindDTOS.stream().map(UserAppBindDTO::getId).collect(Collectors.toList());
this.userAppBindService.appCancellation(ids);
}
((UserOperationServiceImpl)AopContext.currentProxy()).asyncAppCancellation(userAppDTO);
}
}
return true;
}
/**
* 创建大屏账户同时创建会员
*
......@@ -513,7 +574,7 @@ public class UserOperationServiceImpl implements UserOperationService {
/**
* 服务号登录
* @param resources 微信信息
* @return UserWeixinDTO
* @return UserWeiXinDTO
*/
@Override
public UserWeixinDTO serviceLogin(UserWeixin resources) {
......@@ -528,10 +589,10 @@ public class UserOperationServiceImpl implements UserOperationService {
/**
* 小程序登录
* @param resources 微信
* @return UserWeixinDTO
* @return UserWeiXinDTO
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public UserWeixinDTO appletLogin(UserWeixin resources) {
// 创建小屏账户同时创建会员
......@@ -606,27 +667,29 @@ public class UserOperationServiceImpl implements UserOperationService {
// 修改会员信息
memberDTO = this.memberService.doUpdateMemberVipAndVipExpireTime(member);
log.info("发送关注消息至大屏侧,发送的账号信息 ==>> {} || 会员信息 ==>> {}", userWeixinDTO , memberDTO);
// 同步至iptv
// 同步大屏侧
((UserOperationServiceImpl)AopContext.currentProxy()).asyncSubscribe(new MemberAndWeixinUserDTO(memberDTO, userWeixinDTO));
// 大屏信息
JSONObject iptvUserInfo = resources.getIptvUserInfo();
log.info("存储的大小屏账号信息 iptvUserInfo ==>> {}" , iptvUserInfo);
if (Objects.nonNull(iptvUserInfo)) {
JSONObject visUserInfo = resources.getIptvUserInfo();
log.info("存储的大小屏账号信息 iptvUserInfo ==>> {}" , visUserInfo);
if (Objects.nonNull(visUserInfo)) {
// 大屏账户
String platformAccount = iptvUserInfo.getString("platformAccount");
String platformAccount = visUserInfo.getString("platformAccount");
if (StringUtils.isBlank(platformAccount)) {
platformAccount = iptvUserInfo.getString("platformUserId");
platformAccount = visUserInfo.getString("platformUserId");
if (StringUtils.isBlank(platformAccount)) {
platformAccount = iptvUserInfo.getString("nNO");
platformAccount = visUserInfo.getString("nNO");
}
if (StringUtils.isBlank(platformAccount)) {
log.error("关注后绑定失败,platformAccount is null ");
return false;
}
}
log.info("存储的大屏账号信息 platformAccount ==>> {}" , platformAccount);
// 绑定
......@@ -656,8 +719,6 @@ public class UserOperationServiceImpl implements UserOperationService {
wechatSubscribeRecord.setOperationFlag(subscribe);
if (Objects.nonNull(sourceInfo)) {
// wechatSubscribeRecord.setSourceInfo(JSONObject.toJSONString(sourceInfo));
// 内容ID,entityId:实体ID
Object entityId = sourceInfo.get("entityId");
if (Objects.nonNull(entityId)) {
......@@ -892,10 +953,7 @@ public class UserOperationServiceImpl implements UserOperationService {
log.info("会员信息置空大屏的结果,memberDTO ==>> {}", memberDTO);
memberDTO.setPlatformAccount(platformAccount);
log.info("大屏解绑,重置大屏账号的主会员,查看当前会员是否是主账号 ==>>memberCode ==>> {} || 大屏账号 ==>> userTvDTO ==>> {}", userTvDTO);
if (StringUtils.isBlank(bindMemberCode)) {
UserTv userTv = new UserTv();
userTv.setId(userTvDTO.getId());
userTv.setPriorityMemberCode(null);
......@@ -1105,7 +1163,6 @@ public class UserOperationServiceImpl implements UserOperationService {
} else {
log.info("传过来的观影时间 ==>> {} 和今天的时间 ==>> {} 不相同,不做处理", userCollectionDetail.getCreateTime().getTime(),
new Date().toInstant().getEpochSecond());
continue;
}
}
......@@ -1278,7 +1335,7 @@ public class UserOperationServiceImpl implements UserOperationService {
memberDTO.setPlatformAccount(platformAccount);
log.info("发送绑定消息至大屏侧, 会员信息 ==>> {} || 账号信息 ==>> {}", memberDTO , userTvDTO);
// 同步至iptv
// 同步至大屏侧
((UserOperationServiceImpl)AopContext.currentProxy()).asyncMinaBind(new MemberAndUserTvDTO(memberDTO, userTvDTO));
this.updateUserTvSimplePriorityMemberCodeRedis(platformAccount, memberDTO.getCode());
......@@ -1301,7 +1358,7 @@ public class UserOperationServiceImpl implements UserOperationService {
*
* @param unionId 身份唯一标识
* @param appId 应用标识
* @return UserWeixinDTO
* @return UserWeiXinDTO
*/
private UserWeixinDTO findUserWeiXinByUnionIdAndAppId(String unionId, String appId) {
return this.userWeixinService.findFirstByUnionidAndAppid(unionId, appId);
......@@ -1495,12 +1552,7 @@ public class UserOperationServiceImpl implements UserOperationService {
if (!CollectionUtils.isEmpty(collect)) {
// 按绑定时间倒排
collect.sort(new Comparator<MemberDTO>() {
@Override
public int compare(MemberDTO memberDTO, MemberDTO t1) {
return t1.getBindIptvTime().compareTo(memberDTO.getBindIptvTime());
}
});
collect.sort((memberDTO1, t1) -> t1.getBindIptvTime().compareTo(memberDTO1.getBindIptvTime()));
// 绑定新的主账号
UserTv userTv = new UserTv();
userTv.setId(userTvDTO.getId());
......@@ -1568,6 +1620,24 @@ public class UserOperationServiceImpl implements UserOperationService {
}
@AsyncMqSend
public void asyncCreateUserAppBindThirdAccount(UserAppDTO userAppDTO) {}
@AsyncMqSend
public void asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(UserAppDTO userAppDTO) { }
@AsyncMqSend
public void asyncCancelUserAppBind(UserAppBindDTO userAppBindDTO) {}
@AsyncMqSend
public void asyncUpdatePasswordByUsername(UserAppDTO userAppDTO) {}
@AsyncMqSend
public void asyncUpdateAppInfo(UserAppDTO userAppDTO) {}
@AsyncMqSend
public void asyncAppCancellation(UserAppDTO userAppDTO) {}
@AsyncMqSend
public void asyncAppRegister(AppRegisterDTO appRegisterDTO) {}
@AsyncMqSend
public void asyncsaveGrowthReport(GrowthReport growthReport) {}
@AsyncMqSend
......
......@@ -23,13 +23,13 @@ import java.util.concurrent.TimeUnit;
@Configuration
public class TheadPoolTaskExecutorConfiguration {
@Value("${task.pool.core-pool-size}")
@Value("${task.pool.core-pool-size:16}")
private Integer corePoolSize;
@Value("${task.pool.core-pool-size}")
@Value("${task.pool.core-pool-size:35}")
private Integer maxPoolSize;
@Value("${task.pool.keep-alive-seconds}")
@Value("${task.pool.keep-alive-seconds:10}")
private Integer keepAliveSeconds;
@Value("${task.pool.queue-capacity}")
@Value("${task.pool.queue-capacity:300}")
private Integer queueCapacity;
@Bean
......
......@@ -28,23 +28,28 @@ spring:
test-while-idle: true
test-on-borrow: false
test-on-return: false
validation-query: select 1
# 配置监控统计拦截的filters
filters: stat
stat-view-servlet:
url-pattern: /druid/*
reset-enable: false
web-stat-filter:
url-pattern: /*
exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
jackson:
time-zone: GMT+8
data:
redis:
repositories:
enabled: false
#配置 Jpa
jpa:
properties:
hibernate:
# 生产环境设置成 none,避免程序运行时自动更新数据库结构
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
ddl-auto: none
open-in-view: true
show-sql: false
servlet:
multipart:
......@@ -89,7 +94,6 @@ jwt:
# 续期时间,2小时,单位毫秒
renew: 7200000
#是否允许生成代码,生产环境设置为false
generator:
enabled: false
......@@ -97,53 +101,3 @@ generator:
#是否开启 swagger-ui
swagger:
enabled: false
\ No newline at end of file
file:
path: system/file
avatar: system/avatar
upload: upload
# 文件大小 /M
maxSize: 100
avatarMaxSize: 5
service:
mq:
exchange: uce.exchange
queue: uce.queue
weixin:
list:
- appid: wxfaa765183a332521
secret: b5c1c39cb95b45b599a02fd68b5fcf17
token:
encodingAesKey:
imagePath:
content: 长按识别二维码,加入微信群。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 86400
env: dev
# 订阅号
- appid: wx5d88c7fe99f89f32
secret: b213afe99a469d4be576f330dad643b8
token: topdraw
encodingAesKey: g3mYB6yx2ZiebxwKcI1H2iw3LlYNBHb7PqsVYFHUQzi
# 应用类型 小程序 服务号 订阅号, 当前基于订阅号有特殊逻辑
appType: subscription
imagePath: /topdraw/app/user_center_service_te/upload/customer/weChat.png
content: 长按识别二维码,关注订阅号。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 300
env: dev
api:
uc-service: http://127.0.0.1:8446
uc:
# 主会员是否启用,如果启用任务获得的积分将添加至小屏会员上
validPriorityMember: 0
\ No newline at end of file
......
......@@ -2,40 +2,51 @@ server:
port: 8447
spring:
application:
name: member-service
freemarker:
check-template-location: false
name: uc-engine
profiles:
active: dev
jackson:
time-zone: GMT+8
data:
redis:
repositories:
enabled: false
#配置 Jpa
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
open-in-view: true
#mq
service:
mq:
exchange: uce.exchange
queue: uce.queue
weixin:
list:
- appid: wxfaa765183a332521
secret: b5c1c39cb95b45b599a02fd68b5fcf17
token:
encodingAesKey:
imagePath:
content: 长按识别二维码,加入微信群。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 86400
env: dev
# 订阅号
- appid: wx5d88c7fe99f89f32
secret: b213afe99a469d4be576f330dad643b8
token: topdraw
encodingAesKey: g3mYB6yx2ZiebxwKcI1H2iw3LlYNBHb7PqsVYFHUQzi
# 应用类型 小程序 服务号 订阅号, 当前基于订阅号有特殊逻辑
appType: subscription
imagePath: /topdraw/app/user_center_service_te/upload/customer/weChat.png
content: 长按识别二维码,关注订阅号。
miniprogramState: formal
# 点击模板卡片后的默认跳转页面
page: pages/index/main
# 生成带参数二维码的有效期
qrCodeExpireSeconds: 300
env: dev
task:
pool:
# 核心线程池大小
core-pool-size: 16
# 最大线程数
max-pool-size: 35
# 活跃时间
keep-alive-seconds: 10
# 队列容量
queue-capacity: 300
#第三方接口
api:
# ucs
uc-service: http://127.0.0.1:8446
#登录图形验证码有效时间/分钟
loginCode:
expiration: 2
#默认上传图片类型
default-image-type: -1
uc:
# 主会员是否启用,如果启用任务获得的积分将添加至小屏会员上
validPriorityMember: 0
\ No newline at end of file
......