Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
b09dde25
提交
b09dde25
authored
10月 08, 2022
作者:
gh
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
ddc798d9
25510db5
显示空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
448 行增加
和
53 行删除
+448
-53
Project_Default.xml
.idea/inspectionProfiles/Project_Default.xml
+0
-46
pom.xml
pom.xml
+6
-0
CustomerServiceCommonAsyncComponent.java
...tomer/components/CustomerServiceCommonAsyncComponent.java
+52
-1
MyCatchConfig.java
...ain/java/com/yaoyaozw/customer/configs/MyCatchConfig.java
+45
-0
RedisConfig.java
src/main/java/com/yaoyaozw/customer/configs/RedisConfig.java
+52
-0
RedissonConfig.java
...in/java/com/yaoyaozw/customer/configs/RedissonConfig.java
+40
-0
RedissonConfigProperties.java
...m/yaoyaozw/customer/configs/RedissonConfigProperties.java
+20
-0
CustomerCommonConstant.java
...m/yaoyaozw/customer/constants/CustomerCommonConstant.java
+11
-0
CrowdPackageController.java
.../yaoyaozw/customer/controller/CrowdPackageController.java
+6
-0
RegisterUserEntityMapper.java
...om/yaoyaozw/customer/mapper/RegisterUserEntityMapper.java
+23
-0
CrowdPackageConditionMatchService.java
...w/customer/service/CrowdPackageConditionMatchService.java
+11
-1
CrowdPackageService.java
...va/com/yaoyaozw/customer/service/CrowdPackageService.java
+16
-0
RegisterUserEntityService.java
.../yaoyaozw/customer/service/RegisterUserEntityService.java
+13
-0
CrowdPackageConditionMatchServiceImpl.java
...r/service/impl/CrowdPackageConditionMatchServiceImpl.java
+16
-2
CrowdPackageServiceImpl.java
...oyaozw/customer/service/impl/CrowdPackageServiceImpl.java
+52
-0
CustomerGraphicsServiceImpl.java
...zw/customer/service/impl/CustomerGraphicsServiceImpl.java
+15
-2
RegisterUserEntityServiceImpl.java
.../customer/service/impl/RegisterUserEntityServiceImpl.java
+7
-0
CrowdPackageUserVO.java
...com/yaoyaozw/customer/vo/customer/CrowdPackageUserVO.java
+26
-0
bootstrap.yml
src/main/resources/bootstrap.yml
+1
-1
RegisterUserEntityMapper.xml
src/main/resources/mapper/RegisterUserEntityMapper.xml
+36
-0
没有找到文件。
.idea/inspectionProfiles/Project_Default.xml
deleted
100644 → 0
浏览文件 @
ddc798d9
<component
name=
"InspectionProjectProfileManager"
>
<profile
version=
"1.0"
>
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"DuplicatedCode"
enabled=
"true"
level=
"WEAK WARNING"
enabled_by_default=
"true"
>
<Languages>
<language
minSize=
"80"
name=
"Java"
/>
</Languages>
</inspection_tool>
<inspection_tool
class=
"JavaDoc"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"TOP_LEVEL_CLASS_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"INNER_CLASS_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"METHOD_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
"@return@param@throws or @exception"
/>
</value>
</option>
<option
name=
"FIELD_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"IGNORE_DEPRECATED"
value=
"false"
/>
<option
name=
"IGNORE_JAVADOC_PERIOD"
value=
"true"
/>
<option
name=
"IGNORE_DUPLICATED_THROWS"
value=
"false"
/>
<option
name=
"IGNORE_POINT_TO_ITSELF"
value=
"false"
/>
<option
name=
"myAdditionalJavadocTags"
value=
"date"
/>
</inspection_tool>
<inspection_tool
class=
"SerializableHasSerialVersionUIDField"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"ignoreAnonymousInnerClasses"
value=
"false"
/>
<option
name=
"superClassString"
value=
"java.awt.Component"
/>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
pom.xml
浏览文件 @
b09dde25
...
...
@@ -196,6 +196,12 @@
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
<dependency>
<groupId>
org.redisson
</groupId>
<artifactId>
redisson
</artifactId>
<version>
3.12.0
</version>
</dependency>
<!-- JWT -->
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
...
...
src/main/java/com/yaoyaozw/customer/components/CustomerServiceCommonAsyncComponent.java
浏览文件 @
b09dde25
package
com
.
yaoyaozw
.
customer
.
components
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author darker
* @date 2022/9/28 15:16
...
...
@@ -10,9 +17,53 @@ import org.springframework.stereotype.Component;
@Component
public
class
CustomerServiceCommonAsyncComponent
{
private
final
static
Logger
LOCAL_LOG
=
LoggerFactory
.
getLogger
(
CustomerServiceCommonAsyncComponent
.
class
);
@Async
(
"myExecutor"
)
public
void
addMatchUserIntoPackage
(
Long
packageId
,
List
<
CrowdPackageUserVO
>
userList
)
{
long
startTime
=
System
.
currentTimeMillis
();
String
packIdStr
=
packageId
.
toString
();
// 筛选当前不在这个人群包的用户
List
<
CrowdPackageUserVO
>
userNotInPackageList
=
userList
.
stream
()
// 保留现在不在该人群包的用户
.
filter
(
item
->
ObjectUtil
.
isNull
(
item
.
getInPackage
())
||
!
item
.
getInPackage
().
contains
(
packIdStr
))
.
peek
(
item
->
{
if
(
ObjectUtil
.
isNull
(
item
.
getInPackage
()))
{
item
.
setInPackage
(
packIdStr
);
}
else
{
// 将当前人群包拼在后面
item
.
setInPackage
(
item
.
getInPackage
()
+
","
+
packIdStr
);
}
}).
collect
(
Collectors
.
toList
());
LOCAL_LOG
.
info
(
"人群包ID: {} 新增用户 {}个"
,
packIdStr
,
userNotInPackageList
.
size
());
long
endTime
=
System
.
currentTimeMillis
();
LOCAL_LOG
.
info
(
"异步添加符合条件用户人群包完成, 耗时: {}ms"
,
endTime
-
startTime
);
}
@Async
(
"myExecutor"
)
public
void
updateUserPackage
()
{
public
void
removeUnMatchUserFromPackage
(
Long
packageId
,
List
<
CrowdPackageUserVO
>
userList
)
{
long
startTime
=
System
.
currentTimeMillis
();
String
packIdStr
=
packageId
.
toString
();
// 筛选当前不在这个人群包的用户
List
<
CrowdPackageUserVO
>
userRemoveFromPackList
=
userList
.
stream
()
// 移除现在在该人群包但不符合当前条件的用户
.
filter
(
item
->
ObjectUtil
.
isNotNull
(
item
.
getInPackage
())
&&
item
.
getInPackage
().
contains
(
packIdStr
))
.
peek
(
item
->
{
String
removePackageStr
=
item
.
getInPackage
().
replace
(
","
+
packIdStr
,
""
)
.
replace
(
packIdStr
+
","
,
""
)
.
replace
(
packIdStr
,
""
);
item
.
setInPackage
(
removePackageStr
);
}).
collect
(
Collectors
.
toList
());
LOCAL_LOG
.
info
(
"人群包ID: {} 移除用户 {}个"
,
packIdStr
,
userRemoveFromPackList
.
size
());
long
endTime
=
System
.
currentTimeMillis
();
LOCAL_LOG
.
info
(
"异步删除不符合条件用户所属人群包完成, 耗时: {}ms"
,
endTime
-
startTime
);
}
...
...
src/main/java/com/yaoyaozw/customer/configs/MyCatchConfig.java
0 → 100644
浏览文件 @
b09dde25
package
com
.
yaoyaozw
.
customer
.
configs
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.boot.autoconfigure.cache.CacheProperties
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cache.annotation.CachingConfigurationSelector
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheConfiguration
;
import
org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.RedisSerializationContext
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
* @author 10626
*/
@Configuration
@ConditionalOnClass
(
CachingConfigurationSelector
.
class
)
@EnableConfigurationProperties
(
CacheProperties
.
class
)
@ConditionalOnProperty
(
prefix
=
"spring.cache"
,
name
=
"type"
,
havingValue
=
"redis"
)
public
class
MyCatchConfig
{
@Bean
public
RedisCacheConfiguration
redisCacheConfiguration
(
CacheProperties
cacheProperties
)
{
RedisCacheConfiguration
config
=
RedisCacheConfiguration
.
defaultCacheConfig
();
config
=
config
.
serializeKeysWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
new
StringRedisSerializer
()));
config
=
config
.
serializeValuesWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
new
GenericJackson2JsonRedisSerializer
()));
CacheProperties
.
Redis
redis
=
cacheProperties
.
getRedis
();
if
(
redis
.
getTimeToLive
()
!=
null
)
{
config
=
config
.
entryTtl
(
redis
.
getTimeToLive
());
}
if
(
StringUtils
.
isNotEmpty
(
redis
.
getKeyPrefix
()))
{
config
=
config
.
prefixKeysWith
(
redis
.
getKeyPrefix
());
}
if
(!
redis
.
isCacheNullValues
())
{
config
=
config
.
disableCachingNullValues
();
}
if
(!
redis
.
isUseKeyPrefix
())
{
config
=
config
.
disableKeyPrefix
();
}
return
config
;
}
}
src/main/java/com/yaoyaozw/customer/configs/RedisConfig.java
0 → 100644
浏览文件 @
b09dde25
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
yaoyaozw
.
customer
.
configs
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
* Redis配置
*
* @author Mark sunlightcs@gmail.com
*/
@Configuration
public
class
RedisConfig
{
@Autowired
private
RedisConnectionFactory
factory
;
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
()
{
RedisTemplate
<
String
,
Object
>
redisTemplate
=
new
RedisTemplate
<
String
,
Object
>();
redisTemplate
.
setConnectionFactory
(
factory
);
// key的序列化类型
redisTemplate
.
setKeySerializer
(
new
StringRedisSerializer
());
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
objectMapper
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
objectMapper
);
// value的序列化类型
redisTemplate
.
setValueSerializer
(
jackson2JsonRedisSerializer
);
redisTemplate
.
setHashKeySerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setHashValueSerializer
(
jackson2JsonRedisSerializer
);
redisTemplate
.
afterPropertiesSet
();
return
redisTemplate
;
}
}
src/main/java/com/yaoyaozw/customer/configs/RedissonConfig.java
0 → 100644
浏览文件 @
b09dde25
package
com
.
yaoyaozw
.
customer
.
configs
;
import
org.redisson.Redisson
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.data.redis.RedisProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.io.IOException
;
/**
* @author 10626
*/
@Configuration
@EnableConfigurationProperties
({
RedisProperties
.
class
,
RedissonConfigProperties
.
class
})
@ConditionalOnClass
(
RedissonClient
.
class
)
public
class
RedissonConfig
{
/**
* 所有对Redisson的使用都是通过RedissonClient对象
*/
@Bean
(
destroyMethod
=
"shutdown"
)
public
RedissonClient
redissonClient
(
RedisProperties
redisProperties
,
RedissonConfigProperties
redissonConfigProperties
)
throws
IOException
{
//1、创建配置
Config
config
=
new
Config
();
config
.
useSingleServer
().
setAddress
(
"redis://"
+
redisProperties
.
getHost
()+
":"
+
redisProperties
.
getPort
())
.
setPassword
(
redisProperties
.
getPassword
())
.
setTimeout
(
redissonConfigProperties
.
getTimeout
())
.
setRetryAttempts
(
redissonConfigProperties
.
getRetryAttempts
())
.
setRetryInterval
(
redissonConfigProperties
.
getRetryInterval
())
.
setConnectionPoolSize
(
redissonConfigProperties
.
getConnectionPoolSize
())
.
setConnectionMinimumIdleSize
(
redissonConfigProperties
.
getConnectionMinimumIdleSize
())
.
setPingConnectionInterval
(
redissonConfigProperties
.
getPingConnectionInterval
());
//**此项务必设置为redisson解决之前bug的timeout问题关键***** setPingConnectionInterval
//2、根据Config创建出RedissonClient示例
return
Redisson
.
create
(
config
);
}
}
src/main/java/com/yaoyaozw/customer/configs/RedissonConfigProperties.java
0 → 100644
浏览文件 @
b09dde25
package
com
.
yaoyaozw
.
customer
.
configs
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
/**
* @author 10626
*/
@ConfigurationProperties
(
prefix
=
"spring.redisson"
)
@Component
@Data
public
class
RedissonConfigProperties
{
private
Integer
timeout
;
private
Integer
retryAttempts
;
private
Integer
retryInterval
;
private
Integer
pingConnectionInterval
;
private
Integer
connectionPoolSize
;
private
Integer
connectionMinimumIdleSize
;
}
src/main/java/com/yaoyaozw/customer/constants/CustomerCommonConstant.java
0 → 100644
浏览文件 @
b09dde25
package
com
.
yaoyaozw
.
customer
.
constants
;
/**
* @author darker
* @date 2022/9/28 20:09
*/
public
class
CustomerCommonConstant
{
public
final
static
String
CROWD_HUMAN_NUN_REDIS_KEY
=
"crowdHumanNum"
;
}
src/main/java/com/yaoyaozw/customer/controller/CrowdPackageController.java
浏览文件 @
b09dde25
...
...
@@ -75,6 +75,12 @@ public class CrowdPackageController {
return
crowdPackageService
.
getOptions
(
conditionId
);
}
@ApiOperation
(
"更新用户列表所属的人群包"
)
@GetMapping
(
"/updateUserPackageBatch"
)
public
BaseResult
updateUserPackageBatch
(
@RequestBody
List
<
String
>
openIdList
)
{
return
crowdPackageService
.
updateUserPackageBatch
(
openIdList
);
}
}
src/main/java/com/yaoyaozw/customer/mapper/RegisterUserEntityMapper.java
浏览文件 @
b09dde25
...
...
@@ -2,8 +2,30 @@ package com.yaoyaozw.customer.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
RegisterUserEntityMapper
extends
BaseMapper
<
RegisterUserEntity
>
{
/**
* 获取符合动态条件的用户
*
* @param dynamicExpressList 动态表达列表
* @param openId 指定openId
* @return {@link List}<{@link RegisterUserEntity}>
*/
List
<
CrowdPackageUserVO
>
getUserMatchDynamicExpress
(
@Param
(
"dynamicExpressList"
)
List
<
String
>
dynamicExpressList
,
@Param
(
"openId"
)
String
openId
);
/**
* 更新用户所属人群包
*
* @param openId 用户 openId
* @param packageBelong 所属人群包
*/
void
updateUserPackageBelong
(
@Param
(
"openId"
)
String
openId
,
@Param
(
"packageBelong"
)
String
packageBelong
);
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/service/CrowdPackageConditionMatchService.java
浏览文件 @
b09dde25
...
...
@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.entity.CrowdPackageConditionMatch
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
java.util.List
;
...
...
@@ -16,8 +17,17 @@ public interface CrowdPackageConditionMatchService extends IService<CrowdPackage
* 从包中获取用户列表
*
* @param packageId 包id
* @param openId 用户openId
* @return {@link List}<{@link RegisterUserEntity}>
*/
List
<
RegisterUserEntity
>
getUserListFromPackage
(
Long
packageId
);
List
<
CrowdPackageUserVO
>
getUserListFromPackage
(
Long
packageId
,
String
openId
);
/**
* 获取用户是否符合人群包条件
* @param packageId 人群包id
* @param openId 用户openId
* @return 结果
*/
Boolean
getUserPackageBelong
(
Long
packageId
,
String
openId
);
}
src/main/java/com/yaoyaozw/customer/service/CrowdPackageService.java
浏览文件 @
b09dde25
...
...
@@ -84,4 +84,20 @@ public interface CrowdPackageService extends IService<CrowdPackage> {
* @return {@link GenericsResult}<{@link ConditionOptionResponseVO}
*/
GenericsResult
<
ConditionOptionResponseVO
>
getOptions
(
Long
conditionId
);
/**
* 更新用户所属人群包
* @param openId 用户标识
* @return 人群包id拼接
*/
BaseResult
updateUserPackageBelong
(
String
openId
);
/**
* 批处理更新用户包
*
* @param openIdList 开放id列表
* @return {@link BaseResult}
*/
BaseResult
updateUserPackageBatch
(
List
<
String
>
openIdList
);
}
src/main/java/com/yaoyaozw/customer/service/RegisterUserEntityService.java
浏览文件 @
b09dde25
...
...
@@ -3,6 +3,10 @@ package com.yaoyaozw.customer.service;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
java.util.List
;
public
interface
RegisterUserEntityService
extends
IService
<
RegisterUserEntity
>{
...
...
@@ -10,5 +14,14 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
);
/**
* 获取符合动态条件的用户
*
* @param dynamicExpressList 动态表达列表
* @param openId 指定用户openId
* @return {@link List}<{@link RegisterUserEntity}>
*/
List
<
CrowdPackageUserVO
>
getUserMatchDynamicExpress
(
List
<
String
>
dynamicExpressList
,
String
openId
);
}
src/main/java/com/yaoyaozw/customer/service/impl/CrowdPackageConditionMatchServiceImpl.java
浏览文件 @
b09dde25
...
...
@@ -10,6 +10,8 @@ import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import
com.yaoyaozw.customer.mapper.MaterialCrowdConditionMatchMapper
;
import
com.yaoyaozw.customer.service.CrowdPackageConditionMatchService
;
import
com.yaoyaozw.customer.service.CustomerServiceCommonService
;
import
com.yaoyaozw.customer.service.RegisterUserEntityService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -32,9 +34,11 @@ public class CrowdPackageConditionMatchServiceImpl extends ServiceImpl<MaterialC
@Autowired
private
CustomerServiceCommonService
commonService
;
@Autowired
private
RegisterUserEntityService
userEntityService
;
@Override
public
List
<
RegisterUserEntity
>
getUserListFromPackage
(
Long
package
Id
)
{
public
List
<
CrowdPackageUserVO
>
getUserListFromPackage
(
Long
packageId
,
String
open
Id
)
{
long
startTime
=
System
.
currentTimeMillis
();
// 获取人群包下的条件
...
...
@@ -51,7 +55,7 @@ public class CrowdPackageConditionMatchServiceImpl extends ServiceImpl<MaterialC
LOCAL_LOG
.
info
(
"获取SetupId列表耗时 {}ms, setupId列表长度: {}"
,
getSetupIdTime
-
getConditionTime
,
setupIdList
.
size
());
// 根据动态条件获取用户列表
List
<
RegisterUserEntity
>
userList
=
new
ArrayList
<>(
);
List
<
CrowdPackageUserVO
>
userList
=
userEntityService
.
getUserMatchDynamicExpress
(
nonStaticConditionList
,
openId
);
long
dynamicUserTime
=
System
.
currentTimeMillis
();
LOCAL_LOG
.
info
(
"获取SetupId列表符合动态条件的用户耗时 {}ms, 符合动态条件的用户: {}个"
,
dynamicUserTime
-
getSetupIdTime
,
userList
.
size
());
...
...
@@ -62,6 +66,16 @@ public class CrowdPackageConditionMatchServiceImpl extends ServiceImpl<MaterialC
long
allUserTime
=
System
.
currentTimeMillis
();
LOCAL_LOG
.
info
(
"获取符合全部条件的用户耗时: {}ms, 符合全部条件的用户: {}个"
,
allUserTime
-
dynamicUserTime
,
userList
.
size
());
if
(
CollectionUtil
.
isEmpty
(
userList
))
{
LOCAL_LOG
.
info
(
"人群包ID {}, 没有符合条件的用户"
,
packageId
);
}
return
userList
;
}
@Override
public
Boolean
getUserPackageBelong
(
Long
packageId
,
String
openId
)
{
List
<
CrowdPackageUserVO
>
userList
=
this
.
getUserListFromPackage
(
packageId
,
openId
);
return
CollectionUtil
.
isNotEmpty
(
userList
);
}
}
src/main/java/com/yaoyaozw/customer/service/impl/CrowdPackageServiceImpl.java
浏览文件 @
b09dde25
...
...
@@ -12,6 +12,7 @@ import com.yaoyaozw.customer.common.GenericsResult;
import
com.yaoyaozw.customer.components.SnowflakeComponent
;
import
com.yaoyaozw.customer.components.TokenManager
;
import
com.yaoyaozw.customer.constants.CrowdPackageCommonConstant
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageQueryDTO
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageConditionDTO
;
import
com.yaoyaozw.customer.entity.CrowdPackage
;
...
...
@@ -20,19 +21,24 @@ import com.yaoyaozw.customer.entity.CrowdPackageConditionMatch;
import
com.yaoyaozw.customer.enums.CrowdPackageConditionEnum
;
import
com.yaoyaozw.customer.mapper.KanbanCommonMapper
;
import
com.yaoyaozw.customer.mapper.MaterialCrowdPackageMapper
;
import
com.yaoyaozw.customer.mapper.RegisterUserEntityMapper
;
import
com.yaoyaozw.customer.service.CrowdPackageConditionMatchService
;
import
com.yaoyaozw.customer.service.CrowdPackageConditionService
;
import
com.yaoyaozw.customer.service.CrowdPackageService
;
import
com.yaoyaozw.customer.service.RegisterUserEntityService
;
import
com.yaoyaozw.customer.vo.CommonOptionResponseVO
;
import
com.yaoyaozw.customer.vo.crowd.*
;
import
org.apache.commons.lang3.StringUtils
;
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.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -53,6 +59,10 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
private
TokenManager
tokenManager
;
@Autowired
private
CrowdPackageConditionMatchService
matchService
;
@Autowired
private
RegisterUserEntityMapper
userEntityMapper
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Override
...
...
@@ -131,6 +141,11 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
if
(
CollectionUtil
.
isEmpty
(
pageList
))
{
return
new
GenericsResult
<>(
false
,
"暂无数据"
);
}
HashMap
<
String
,
Integer
>
entries
=
(
HashMap
<
String
,
Integer
>)
redisTemplate
.
boundHashOps
(
CustomerCommonConstant
.
CROWD_HUMAN_NUN_REDIS_KEY
).
entries
();
if
(
CollectionUtil
.
isNotEmpty
(
entries
))
{
pageList
.
forEach
(
item
->
item
.
setNumOfCrowdInPackage
(
entries
.
get
(
item
.
getId
().
toString
())));
}
return
new
GenericsResult
<>(
pageList
);
}
...
...
@@ -186,6 +201,43 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
return
new
GenericsResult
<>(
new
ConditionOptionResponseVO
(
conditionItem
.
getFrontType
(),
result
));
}
@Override
public
BaseResult
updateUserPackageBelong
(
String
openId
)
{
List
<
CrowdPackage
>
packageList
=
super
.
list
();
StringBuilder
packageConcatResult
=
new
StringBuilder
();
boolean
isFirst
=
true
;
for
(
CrowdPackage
crowdPackage
:
packageList
)
{
Boolean
matchPackage
=
matchService
.
getUserPackageBelong
(
crowdPackage
.
getId
(),
openId
);
if
(
matchPackage
)
{
// 用户符合人群包条件
if
(!
isFirst
)
{
// 除了第一个,其他的要在数字前拼上逗号
packageConcatResult
.
append
(
","
);
}
packageConcatResult
.
append
(
crowdPackage
.
getId
());
isFirst
=
false
;
}
}
String
packageStr
=
packageConcatResult
.
toString
();
userEntityMapper
.
updateUserPackageBelong
(
openId
,
StringUtils
.
isBlank
(
packageStr
)
?
null
:
packageStr
);
LOCAL_LOG
.
info
(
"用户openId: {} 人群包更新完成"
,
openId
);
return
new
BaseResult
().
success
();
}
@Override
public
BaseResult
updateUserPackageBatch
(
List
<
String
>
openIdList
)
{
List
<
CrowdPackage
>
packageList
=
super
.
list
();
return
null
;
}
/**
* 构造操作符
*
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsServiceImpl.java
浏览文件 @
b09dde25
...
...
@@ -2,11 +2,16 @@ package com.yaoyaozw.customer.service.impl;
import
com.yaoyaozw.customer.common.BaseResult
;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO
;
import
com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO
;
import
com.yaoyaozw.customer.service.CrowdPackageConditionMatchService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
com.yaoyaozw.customer.vo.customer.CustomerMessageListVO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
...
@@ -25,15 +30,23 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
private
final
static
Logger
LOCAL_LOG
=
LoggerFactory
.
getLogger
(
CustomerGraphicsServiceImpl
.
class
);
@Autowired
private
CrowdPackageConditionMatchService
matchService
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Override
public
BaseResult
insertCustomerMessage
(
CustomerMessageSaveDTO
saveDto
)
{
Long
packageId
=
saveDto
.
getPackageId
();
LOCAL_LOG
.
info
(
"根据人群包找到符合条件的用户数据"
);
LOCAL_LOG
.
info
(
"根据人群包 {} 找符合条件的用户数据"
,
packageId
);
List
<
CrowdPackageUserVO
>
userList
=
matchService
.
getUserListFromPackage
(
packageId
,
null
);
redisTemplate
.
opsForHash
().
put
(
CustomerCommonConstant
.
CROWD_HUMAN_NUN_REDIS_KEY
,
packageId
.
toString
(),
userList
.
size
());
// TODO: 2022/9/28 根据人群包找到下面的人所在的公众号,进行链接获取
return
n
ull
;
return
n
ew
BaseResult
().
success
()
;
}
@Override
...
...
src/main/java/com/yaoyaozw/customer/service/impl/RegisterUserEntityServiceImpl.java
浏览文件 @
b09dde25
...
...
@@ -8,6 +8,7 @@ import com.yaoyaozw.customer.service.AuthorizerTokenService;
import
com.yaoyaozw.customer.service.CustomerGraphicsDelayService
;
import
com.yaoyaozw.customer.service.CustomerGraphicsService
;
import
com.yaoyaozw.customer.service.wechat.service.WeChatService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -49,4 +50,10 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
}
@Override
public
List
<
CrowdPackageUserVO
>
getUserMatchDynamicExpress
(
List
<
String
>
dynamicExpressList
,
String
openId
)
{
return
baseMapper
.
getUserMatchDynamicExpress
(
dynamicExpressList
,
openId
);
}
}
src/main/java/com/yaoyaozw/customer/vo/customer/CrowdPackageUserVO.java
0 → 100644
浏览文件 @
b09dde25
package
com
.
yaoyaozw
.
customer
.
vo
.
customer
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/28 19:20
*/
@Data
public
class
CrowdPackageUserVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6564547615107105008L
;
private
Long
id
;
private
String
accountId
;
private
String
openId
;
private
Long
setupId
;
private
String
inPackage
;
}
src/main/resources/bootstrap.yml
浏览文件 @
b09dde25
...
...
@@ -4,7 +4,7 @@ spring:
application
:
name
:
customer-service
profiles
:
active
:
pro
active
:
dev
---
spring
:
profiles
:
dev
...
...
src/main/resources/mapper/RegisterUserEntityMapper.xml
浏览文件 @
b09dde25
...
...
@@ -20,4 +20,39 @@
id, app_id, open_id, setup_id, pay_type, pay_num, pay_amount, avg_month, last_active,
gmt_create, customer_sort, customer_publish
</sql>
<select
id=
"getUserMatchDynamicExpress"
resultType=
"com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO"
>
select
rue.id,
ai.account_id as accountId,
rue.setup_id as setupId,
rue.open_id as openId,
rue.in_package as inPackage
from register_user_entity rue
left join authorizer_info ai
on rue.app_id = ai.appid
where
<if
test=
"openId != null and openId != ''"
>
rue.open_id = #{openId} and
</if>
timestampdiff(HOUR, rue.last_active, now())
<
48
<if
test=
"dynamicExpressList != null and dynamicExpressList.size() != 0"
>
<foreach
collection=
"dynamicExpressList"
open=
" and "
item=
"express"
separator=
" and "
>
${express}
</foreach>
</if>
</select>
<update
id=
"updateUserPackageBelong"
>
update register_user_entity
set in_package = #{packageBelong}
where open_id = #{openId}
</update>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论