This commit is contained in:
777
2025-08-19 21:48:18 +08:00
parent 10eea85347
commit 43b13d4da9
28 changed files with 436 additions and 183 deletions

View File

@@ -1,9 +0,0 @@
ALTER TABLE `cai_anchor`
ADD COLUMN `show_me_rate` int NOT NULL DEFAULT 10 COMMENT '展示自己概率' AFTER `recommend_status`;
ALTER TABLE `cai_account`
ADD COLUMN `message_income_coin` bigint NOT NULL DEFAULT 0 COMMENT '聊天收入' AFTER `total_buy_coin`,
ADD COLUMN `video_income_coin` bigint NOT NULL DEFAULT 0 COMMENT '视频收入' AFTER `message_income_coin`,
ADD COLUMN `gift_income_coin` bigint NOT NULL DEFAULT 0 COMMENT '礼物收入' AFTER `video_income_coin`,
ADD COLUMN `guard_income_coin` bigint NOT NULL DEFAULT 0 COMMENT '守护收入' AFTER `gift_income_coin`,
ADD COLUMN `union_income_coin` bigint NOT NULL DEFAULT 0 COMMENT '工会收入' AFTER `guard_income_coin`;

View File

@@ -1,42 +0,0 @@
CREATE TABLE `cai_account_black`
(
`id` bigint unsigned NOT NULL,
`card_account` varchar(50) NOT NULL COMMENT '账户号',
`card_name` varchar(50) NOT NULL COMMENT '账户名称',
`enable_status` tinyint NOT NULL DEFAULT '1' COMMENT '是否开启',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_account` (`card_account`, `card_name`) USING BTREE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci
ROW_FORMAT = DYNAMIC COMMENT ='账户黑名单';
ALTER TABLE `cai_anchor`
ADD COLUMN `enable_greet` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否允许群发' AFTER `recommend_status`;
ALTER TABLE `cai_anchor`
ADD COLUMN `top_show_rank` datetime NOT NULL DEFAULT now() COMMENT '置顶时间' AFTER `show_me_rate`;
ALTER TABLE `cai_anchor`
ADD INDEX `idx_top_date`(`top_show_rank`) USING BTREE;
-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1819683762522001409, '账户黑名单', '1737668638361206786', '1', 'accountBlack', 'cai/accountBlack/index', 1, 0, 'C', '0', '0', 'cai:accountBlack:list', '#', 'admin', sysdate(), '', null, '账户黑名单菜单');
-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1819683762522001410, '账户黑名单查询', 1819683762522001409, '1', '#', '', 1, 0, 'F', '0', '0', 'cai:accountBlack:query', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1819683762522001411, '账户黑名单新增', 1819683762522001409, '2', '#', '', 1, 0, 'F', '0', '0', 'cai:accountBlack:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1819683762522001412, '账户黑名单修改', 1819683762522001409, '3', '#', '', 1, 0, 'F', '0', '0', 'cai:accountBlack:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1819683762522001413, '账户黑名单删除', 1819683762522001409, '4', '#', '', 1, 0, 'F', '0', '0', 'cai:accountBlack:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1819683762522001414, '账户黑名单导出', 1819683762522001409, '5', '#', '', 1, 0, 'F', '0', '0', 'cai:accountBlack:export', '#', 'admin', sysdate(), '', null, '');

View File

@@ -1,2 +0,0 @@
ALTER TABLE `cai_anchor` ADD COLUMN `hidden_status` tinyint NOT NULL DEFAULT 0 COMMENT '是否隐藏状态';
ALTER TABLE `cai_pay_trd_config` ADD COLUMN `for_num` tinyint NOT NULL DEFAULT 1 COMMENT '轮训次数';

View File

@@ -1,13 +0,0 @@
ALTER TABLE `cai_pay_trd_config`
ADD COLUMN `min_amount` decimal(20, 2) NOT NULL DEFAULT 0 AFTER `create_time`,
ADD COLUMN `max_amount` decimal(20, 2) NOT NULL DEFAULT 0 AFTER `min_amount`
ADD COLUMN `sort_by` int(10) NOT NULL DEFAULT 0 AFTER `min_amount`;
-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1879078121599889409, '订单日志', '1738084052270563330', '1', 'orderLogs', 'cai/orderLogs/index', 1, 0, 'C', '0', '0', 'cai:orderLogs:list', '#', 'admin', sysdate(), '', null, '订单日志菜单');
-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1879078121599889410, '订单日志查询', 1879078121599889409, '1', '#', '', 1, 0, 'F', '0', '0', 'cai:orderLogs:query', '#', 'admin', sysdate(), '', null, '');

View File

@@ -1,3 +0,0 @@
ALTER TABLE `cai_pay_trd_config`
ADD COLUMN `wx_product_id` varchar(100) NULL COMMENT '微信产品号' AFTER `sign`,
ADD COLUMN `enable_wx_status` tinyint(1) NOT NULL DEFAULT 0 AFTER `enable_status`;

View File

@@ -1,18 +0,0 @@
drop table cai_batch_add_user;
CREATE TABLE `cai_batch_add_user`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`add_num` int NOT NULL COMMENT '新增用户数',
`gender` tinyint default 1 NOT NULL COMMENT '1-女 2-男',
`invite_user_code` bigint comment '邀请人code',
`phone_prefix` varchar(100) comment '手机前缀(前7位)',
`phone_suffix_start` int(7) comment '手机后缀起点(后4位)',
`password_prefix` varchar(100) comment '密码前缀',
`password_suffix_start` varchar(100) comment '密码后缀起点',
`run_status` tinyint NOT NULL DEFAULT 0 comment '0-未执行 1-执行中 2-执行失败 3-执行成功' COMMENT '执行状态',
`run_fail` text comment '执行失败原因',
`run_result` JSON comment '执行结果',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`run_time` datetime COMMENT '执行时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='批量新增用户脚本';

View File

@@ -1,3 +0,0 @@
ALTER TABLE `cai_user_count`
ADD COLUMN `new_fans_count` int NOT NULL DEFAULT 0 COMMENT '新增粉丝数' AFTER `give_gift_count`,
ADD COLUMN `new_visitor_count` int NOT NULL DEFAULT 0 COMMENT '新增访客数' AFTER `give_gift_count`;

View File

@@ -1,2 +0,0 @@
ALTER TABLE `cai_batch_add_user`
ADD COLUMN `password_type` int NOT NULL DEFAULT 1 COMMENT '1=规则生成 2-随机密码';

38
doc/20250819.sql Normal file
View File

@@ -0,0 +1,38 @@
ALTER TABLE `cai_user_count`
ADD COLUMN `im_count` bigint(20) NOT NULL DEFAULT 0 COMMENT '发言次数',
ADD COLUMN `im_refresh_time` datetime COMMENT '刷新时间';
CREATE TABLE `cai_anchor_im_count_day`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`user_id` int NOT NULL COMMENT '用户ID',
`count_date` date NOT NULL COMMENT '时间',
`im_count` bigint(20) NOT NULL COMMENT '数量',
`refresh_time` datetime not null default now() comment '刷新时间',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_user_id`(`user_id`,`im_count`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci
ROW_FORMAT = DYNAMIC COMMENT ='主播每日发言统计';
-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1957731146459230209, '每日发言统计', '1738072642014617602', '1', 'anchorImCountDay', 'cai/anchorImCountDay/index', 1, 0, 'C', '0', '0', 'cai:anchorImCountDay:list', '#', 'admin', sysdate(), '', null, '每日发言统计菜单');
-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1957731146459230210, '每日发言统计查询', 1957731146459230209, '1', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorImCountDay:query', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1957731146459230211, '每日发言统计新增', 1957731146459230209, '2', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorImCountDay:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1957731146459230212, '每日发言统计修改', 1957731146459230209, '3', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorImCountDay:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1957731146459230213, '每日发言统计删除', 1957731146459230209, '4', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorImCountDay:remove', '#', 'admin', sysdate(), '', null, '');

View File

@@ -1,9 +0,0 @@
ALTER TABLE `cai_account_cash`
ADD COLUMN `coin_callback_coin` int(11) NOT NULL DEFAULT 0 COMMENT '提现紫贝返还值' AFTER `withdraw_coin`;
update cai_account_cash
set coin_callback_coin = withdraw_coin;
ALTER TABLE `cai_withdraw_exchange`
ADD COLUMN `coin_callback_num` bigint(20) NOT NULL DEFAULT 0 COMMENT '失败返还货币' AFTER `coin_num`;
update cai_withdraw_exchange
set coin_callback_num = coin_num;

View File

@@ -1,27 +0,0 @@
CREATE TABLE `cai_anchor_banner`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint NOT NULL COMMENT '用户ID',
`anchor_id` bigint NOT NULL COMMENT '主播ID',
`open_status` tinyint not null default 1 comment '开启状态',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT '主播首页推荐';
-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1809856380386619394, '主播首页推荐', '1738072642014617602', '1', 'anchorBanner', 'cai/anchorBanner/index', 1, 0, 'C', '0', '0', 'cai:anchorBanner:list', '#', 'admin', sysdate(), '', null, '主播首页推荐菜单');
-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1809856380386619395, '主播首页推荐查询', 1809856380386619394, '1', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:query', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1809856380386619396, '主播首页推荐新增', 1809856380386619394, '2', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1809856380386619397, '主播首页推荐修改', 1809856380386619394, '3', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(1809856380386619398, '主播首页推荐删除', 1809856380386619394, '4', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:remove', '#', 'admin', sysdate(), '', null, '');

View File

@@ -1,22 +0,0 @@
ALTER TABLE `cai_account`
ADD COLUMN `total_trd_money` decimal(20, 2) NOT NULL DEFAULT 0 COMMENT '三方充值总额' AFTER `total_buy_coin`;
CREATE TABLE `cai_pay_trd_config`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`type` varchar(100) NOT NULL COMMENT '第三方支付类型',
`name` varchar(100) NOT NULL COMMENT '第三方支付名称',
`gateway_url` varchar(100) DEFAULT NULL COMMENT '请求域名',
`notify_url` varchar(100) NOT NULL COMMENT '回调域名',
`mch_id` varchar(100) NOT NULL COMMENT '商户ID',
`sign` varchar(200) NOT NULL COMMENT '秘钥',
`ali_product_id` varchar(100) NOT NULL COMMENT '支付宝产品号',
`ali_pay_type` varchar(10) NOT NULL DEFAULT 'H5' COMMENT '支付宝支付方式',
`enable_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否开启',
`delete_flag` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 3;

View File

@@ -1,26 +0,0 @@
ALTER TABLE `cai_recharge_order`
ADD COLUMN `device_type` varchar(255) NULL COMMENT '设备' AFTER `appid`;
DROP TABLE cai_order_logs;
CREATE TABLE `cai_order_logs`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`order_no` varchar(100) NOT NULL COMMENT '订单号',
`step_name` varchar(100) NOT NULL COMMENT '操作名称',
`flag_name` varchar(100) NULL COMMENT '标识1',
`in_params` JSON COMMENT '入参',
`out_params` JSON COMMENT '出参',
`remark` varchar(2100) NULL COMMENT '备注',
`success` varchar(100) NULL COMMENT '成功',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_order` (`order_no`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1;
ALTER TABLE `cai_pay_trd_config`
ADD COLUMN `enable_ios` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否开启IOS' AFTER `mch_id`;

View File

@@ -1,26 +1,33 @@
package com.ruoyi.job;
import com.ruoyi.cai.service.AnchorImCountDayService;
import com.ruoyi.job.op.BusOp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
@Component
@Slf4j
public class EveryDaysJob {
@Autowired
private BusOp busOp;
@Autowired
private AnchorImCountDayService anchorImCountDayService;
// 凌晨0点3分执行一次
@Scheduled(cron = "0 3 0 * * ? ")
public void run() {
try {
log.info("执行用户VIP状态码回转-开始");
log.info("执行IM统计入库-开始");
// busOp.refreshUserVipStatus();
anchorImCountDayService.refreshCount(LocalDate.now().plusDays(-1));
anchorImCountDayService.totalUserCount();
}catch (Exception e){
log.error("执行用户VIP状态码回转-失败!",e);
log.error("执行IM统计入库-失败!",e);
}finally {
log.info("执行用户VIP状态码回转-结束");
log.info("执行IM统计入库-结束");
}
}
}

View File

@@ -0,0 +1,75 @@
package com.ruoyi.web.controller.cai.admin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.cai.domain.AnchorImCountDay;
import com.ruoyi.cai.dto.admin.vo.AnchorImCountDayAdminVO;
import com.ruoyi.cai.dto.admin.vo.UserCountAdminVo;
import com.ruoyi.cai.mapper.UserCountMapper;
import com.ruoyi.cai.service.AnchorImCountDayService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 每日发言统计
*
* @author 777
* @date 2025-08-19
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/cai/anchorImCountDay")
public class AnchorImCountDayController extends BaseController {
private final AnchorImCountDayService anchorImCountDayService;
private final UserCountMapper userCountMapper;
/**
* 查询每日发言统计列表
*/
@SaCheckPermission("cai:anchorImCountDay:list")
@GetMapping("/list")
public TableDataInfo<AnchorImCountDayAdminVO> list(AnchorImCountDayAdminVO bo, PageQuery pageQuery) {
IPage<AnchorImCountDayAdminVO> page = anchorImCountDayService.pageAdmin(bo, pageQuery);
return TableDataInfo.build(page);
}
@SaCheckPermission("cai:anchorImCountDay:list")
@GetMapping("/imCountAll/list")
public TableDataInfo<UserCountAdminVo> imCountAllList(UserCountAdminVo bo, PageQuery pageQuery) {
Page<UserCountAdminVo> page = userCountMapper.pageAdmin(pageQuery.build(), bo);
return TableDataInfo.build(page);
}
/**
* 刷新今日统计
*/
@Log(title = "刷新每日发言统计", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PostMapping("/refreshCount")
public R<Void> refreshCount(@RequestBody AnchorImCountDay bo) {
anchorImCountDayService.refreshCount(bo.getCountDate());
return R.ok();
}
@Log(title = "刷新用户所有发言统计", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PostMapping("/totalUserCount")
public R<Void> totalUserCount() {
anchorImCountDayService.totalUserCount();
return R.ok();
}
}

View File

@@ -20,7 +20,7 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://124.222.254.188:5306/cai-v5?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
url: jdbc:mysql://124.222.254.188:5306/cai-v6?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
username: root
password: 383200134
# 从库数据源

View File

@@ -0,0 +1,52 @@
package com.ruoyi.cai.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.constant.DateConstant;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 每日发言统计对象 cai_anchor_im_count_day
*
* @author 777
* @date 2025-08-19
*/
@Data
@TableName("cai_anchor_im_count_day")
public class AnchorImCountDay implements Serializable {
private static final long serialVersionUID=1L;
/**
*
*/
@TableId(value = "id")
private String id;
/**
* 用户ID
*/
private Long userId;
/**
* 时间
*/
@DateTimeFormat(pattern = DateConstant.PATTERN_DATE)
@JsonFormat(pattern = DateConstant.PATTERN_DATE)
private LocalDate countDate;
/**
* 数量
*/
private Long imCount;
/**
* 刷新时间
*/
private LocalDateTime refreshTime;
private LocalDateTime createTime;
}

View File

@@ -25,6 +25,9 @@ public class UserCount implements Serializable {
*/
@TableId(value = "user_id",type = IdType.INPUT)
private Long userId;
private Long imCount;
private LocalDateTime imRefreshTime;
/**
* 新增粉丝数
*/

View File

@@ -0,0 +1,39 @@
package com.ruoyi.cai.dto.admin.vo;
import com.ruoyi.cai.domain.AnchorImCountDay;
import com.ruoyi.common.annotation.Sensitive;
import com.ruoyi.common.enums.SensitiveStrategy;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class AnchorImCountDayAdminVO extends AnchorImCountDay {
/**
* 用户号/ID号
*/
private String usercode;
/**
* 昵称
*/
private String nickname;
/**
* 手机号
*/
@Sensitive(strategy = SensitiveStrategy.PHONE)
private String mobile;
/**
* 头像
*/
private String avatar;
/**
* 性别
*/
private Integer gender;
private Integer age;
private Boolean imSpeck;
private Boolean enableIm;
private Integer status;
}

View File

@@ -33,4 +33,6 @@ public class UserCountAdminVo extends UserCount {
private Integer age;
private Integer isAnchor;
private Integer status;
private Boolean imSpeck;
private Boolean enableIm;
}

View File

@@ -122,7 +122,8 @@ public enum SystemConfigEnum {
IPV6_FILTER("0", "是否开启IPV6请求拦截",SystemConfigGroupEnum.SYSTEM, new BooleanSystemConfigCheck()),
IPV6_FILTER_PATH("/api/auth/login", "IPV6拦截路由配置逗号分隔",SystemConfigGroupEnum.SYSTEM, new BooleanSystemConfigCheck(),"textarea"),
VIP_PRIVATE_PLUS("0", "开启VIP隐私模式增强模式",SystemConfigGroupEnum.SYSTEM,new BooleanSystemConfigCheck()),
OPEN_USER_CHAT_COUNT("0", "开启用户主动消息统计",SystemConfigGroupEnum.SYSTEM,new BooleanSystemConfigCheck()),
OPEN_ANCHOR_CHAT_COUNT("0", "开启主播主动消息统计",SystemConfigGroupEnum.SYSTEM,new BooleanSystemConfigCheck()),
// 4-recordId拦截 5-recordId加强拦截 6-性别拦截 7-vip加强拦截
IM_FILTER_PLUS("0", "IM拦截配置勿动开发配置",SystemConfigGroupEnum.SYSTEM),
COS_DOMAIN("http://ap-shanghai.myqcloud.com/", "文件系统域名前缀",SystemConfigGroupEnum.SYSTEM),
PAY_LIMIT("200000", "原生支付的阈值(元)",SystemConfigGroupEnum.SYSTEM, new NumberSystemConfigCheck()),

View File

@@ -60,6 +60,8 @@ public class ImService {
private UserChatFilterService userChatFilterService;
@Autowired
private SystemConfigManager systemConfigManager;
@Autowired
private AnchorImCountDayService anchorImCountDayService;
public ImResp sendMessage(Long fromUserId, ImMessageDTO message) {
ChatTypeEnum typeEnum = ChatTypeEnum.getByType(message.getType());
@@ -172,6 +174,10 @@ public class ImService {
if(filter == 1){
userChatFilterService.saveFilter(fromUser, toUser, message.getContent(),content);
}
boolean bool = systemConfigManager.getSystemConfigOfBool(SystemConfigEnum.OPEN_ANCHOR_CHAT_COUNT);
if(bool){
anchorImCountDayService.incCount(fromUserId);
}
resp.setRecordId(record.getId());
resp.setFilter(filter);
resp.setContent(content);

View File

@@ -0,0 +1,21 @@
package com.ruoyi.cai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.cai.domain.AnchorImCountDay;
import com.ruoyi.cai.dto.admin.vo.AnchorImCountDayAdminVO;
import org.apache.ibatis.annotations.Param;
/**
* 每日发言统计Mapper接口
*
* @author 777
* @date 2025-08-19
*/
public interface AnchorImCountDayMapper extends BaseMapper<AnchorImCountDay> {
IPage<AnchorImCountDayAdminVO> pageAdmin(@Param("build") Page<Object> build, @Param("bo") AnchorImCountDayAdminVO bo);
IPage<AnchorImCountDay> totalUserId(IPage<AnchorImCountDay> page);
}

View File

@@ -27,4 +27,5 @@ public interface UserCountMapper extends BaseMapper<UserCount> {
void resetNewVisitorIncs(Long userId);
Page<UserCountAdminVo> pageAdmin(@Param("build") Page<Object> build, @Param("bo") UserCountAdminVo bo);
Page<UserCountAdminVo> pageImCount(@Param("build") Page<Object> build, @Param("bo") UserCountAdminVo bo);
}

View File

@@ -0,0 +1,26 @@
package com.ruoyi.cai.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.cai.domain.AnchorImCountDay;
import com.ruoyi.cai.dto.admin.vo.AnchorImCountDayAdminVO;
import com.ruoyi.common.core.domain.PageQuery;
import java.time.LocalDate;
/**
* 每日发言统计Service接口
*
* @author 777
* @date 2025-08-19
*/
public interface AnchorImCountDayService extends IService<AnchorImCountDay> {
void totalUserCount();
IPage<AnchorImCountDayAdminVO> pageAdmin(AnchorImCountDayAdminVO bo, PageQuery pageQuery);
void incCount(Long userId);
void refreshCount(LocalDate localDate);
}

View File

@@ -0,0 +1,116 @@
package com.ruoyi.cai.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.cai.domain.AnchorImCountDay;
import com.ruoyi.cai.domain.UserCount;
import com.ruoyi.cai.dto.admin.vo.AnchorImCountDayAdminVO;
import com.ruoyi.cai.mapper.AnchorImCountDayMapper;
import com.ruoyi.cai.service.AnchorImCountDayService;
import com.ruoyi.cai.service.UserCountService;
import com.ruoyi.common.core.domain.PageQuery;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 每日发言统计Service业务层处理
*
* @author 777
* @date 2025-08-19
*/
@Service
@Slf4j
public class AnchorImCountDayServiceImpl extends ServiceImpl<AnchorImCountDayMapper, AnchorImCountDay> implements AnchorImCountDayService {
@Autowired
private RedissonClient redissonClient;
@Autowired
private UserCountService userCountService;
@Override
public void totalUserCount() {
IPage<AnchorImCountDay> page = new Page<>();
page.setSize(1000);
int i = 0;
while (true){
i++;
if(i > 10000){
break;
}
page.setCurrent(i);
IPage<AnchorImCountDay> totalUserId = baseMapper.totalUserId(page);
List<AnchorImCountDay> records = totalUserId.getRecords();
for (AnchorImCountDay record : records) {
userCountService.update(Wrappers.<UserCount>lambdaUpdate()
.eq(UserCount::getUserId, record.getUserId())
.set(UserCount::getImCount, record.getImCount())
.set(UserCount::getImRefreshTime, LocalDateTime.now()));
}
if(CollectionUtil.isEmpty(records)){
break;
}
}
}
@Override
public IPage<AnchorImCountDayAdminVO> pageAdmin(AnchorImCountDayAdminVO bo, PageQuery pageQuery) {
return baseMapper.pageAdmin(pageQuery.build(),bo);
}
@Override
public void incCount(Long userId){
try {
String redisKey = getRedisKey(LocalDate.now());
RMap<Long, Long> map = redissonClient.getMap(redisKey);
Long newScore = map.addAndGet(userId, 1);
if(newScore == 1){
map.expire(5, TimeUnit.DAYS);
}
}catch (Exception e){
log.error("主播自增im发言失败",e);
}
}
@Override
public void refreshCount(LocalDate localDate){
String redisKey = getRedisKey(localDate);
RMap<Long, Long> map = redissonClient.getMap(redisKey);
Map<Long, Long> longMap = map.readAllMap();
for (Map.Entry<Long, Long> entry : longMap.entrySet()) {
Long userId = entry.getKey();
Long imCount = entry.getValue();
AnchorImCountDay one = this.getOne(Wrappers.lambdaQuery(AnchorImCountDay.class)
.eq(AnchorImCountDay::getCountDate, localDate)
.eq(AnchorImCountDay::getUserId, userId));
if(one != null){
this.update(Wrappers.lambdaUpdate(AnchorImCountDay.class)
.eq(AnchorImCountDay::getId, one.getId())
.set(AnchorImCountDay::getImCount, imCount));
}else{
one = new AnchorImCountDay();
one.setImCount(imCount);
one.setUserId(userId);
one.setRefreshTime(LocalDateTime.now());
this.save(one);
}
}
}
private String getRedisKey(LocalDate localDate){
String now = localDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
return String.format("cai:anchorImCountDay:%s",now);
}
}

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.cai.mapper.AnchorImCountDayMapper">
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.AnchorImCountDayAdminVO">
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age,t2.im_speck,t2.enable_im,t2.status
from cai_anchor_im_count_day t1
left join cai_user t2 on t1.user_id = t2.id
<where>
<if test="bo.mobile != null and bo.mobile != ''">
and t2.mobile = #{bo.mobile}
</if>
<if test="bo.usercode != null and bo.usercode != ''">
and t2.usercode = #{bo.usercode}
</if>
<if test="bo.countDate != null">
and t1.count_date = #{bo.countDate}
</if>
</where>
order by t1.im_count desc
</select>
<select id="totalUserId" resultType="com.ruoyi.cai.domain.AnchorImCountDay">
select max(user_id) as user_id, sum(im_count) as im_count
from cai_anchor_im_count_day
group by user_id
order by user_id
</select>
</mapper>

View File

@@ -50,7 +50,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where user_id = #{userId}
</select>
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.UserCountAdminVo">
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age,t2.status
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age,t2.status,t2.enable_im,t2.im_speck
from cai_user_count t1
left join cai_user t2 on t1.user_id = t2.id
where t1.im_count > 0
<if test="bo.mobile != null and bo.mobile != ''">
and t2.mobile = #{bo.mobile}
</if>
<if test="bo.usercode != null and bo.usercode != ''">
and t2.usercode = #{bo.usercode}
</if>
order by t2.create_time desc
</select>
<select id="pageImCount" resultType="com.ruoyi.cai.dto.admin.vo.UserCountAdminVo">
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age,t2.status,t2.enable_im,t2.im_speck
from cai_user_count t1
left join cai_user t2 on t1.user_id = t2.id
<where>
@@ -61,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and t2.usercode = #{bo.usercode}
</if>
</where>
order by t2.create_time desc
order by t1.im_count desc
</select>