V13
This commit is contained in:
@@ -41,3 +41,4 @@ values(1957731146459230212, '每日发言统计修改', 1957731146459230209, '3'
|
|||||||
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)
|
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, '');
|
values(1957731146459230213, '每日发言统计删除', 1957731146459230209, '4', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorImCountDay:remove', '#', 'admin', sysdate(), '', null, '');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
63
doc/20250911.sql
Normal file
63
doc/20250911.sql
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
ALTER TABLE cai_recharge_order
|
||||||
|
ADD COLUMN `fast_pay` tinyint NOT NULL DEFAULT 0 COMMENT '是否为首充';
|
||||||
|
|
||||||
|
ALTER TABLE cai_user_info
|
||||||
|
ADD COLUMN `fast_pay_time` datetime COMMENT '首充时间' after fast_pay;
|
||||||
|
|
||||||
|
CREATE TABLE `cai_fast_pay_total`
|
||||||
|
(
|
||||||
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`count_date` date NOT NULL COMMENT '时间',
|
||||||
|
`count` bigint(20) NOT NULL DEFAULT 0 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_date` (`count_date`) USING BTREE
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
AUTO_INCREMENT = 1
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_general_ci
|
||||||
|
ROW_FORMAT = DYNAMIC COMMENT ='每日首充统计';
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `cai_union_total`
|
||||||
|
(
|
||||||
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`union_id` bigint(20) not null comment '工会ID',
|
||||||
|
`union_name` varchar(255) not null comment '工会名称',
|
||||||
|
`union_earnings_total` bigint(20) not null default 0 COMMENT '工会收益',
|
||||||
|
`anchor_earnings_total` bigint(20) not null default 0 COMMENT '工会主播收入',
|
||||||
|
`count_date` date NOT NULL COMMENT '时间',
|
||||||
|
`refresh_time` datetime not null default now() comment '刷新时间',
|
||||||
|
`data_type` tinyint not null COMMENT '日期类型',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
INDEX `idx_date` (`count_date`) 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(1966159974722318338, '工会每日收益', '1737000285728587777', '1', 'unionTotal', 'cai/unionTotal/index', 1, 0, 'C', '0', '0', 'cai:unionTotal: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(1966159974722318339, '工会每日收益查询', 1966159974722318338, '1', '#', '', 1, 0, 'F', '0', '0', 'cai:unionTotal:query', '#', 'admin', sysdate(), '', null, '');
|
||||||
|
|
||||||
|
ALTER TABLE cai_union
|
||||||
|
ADD COLUMN `union_earnings_total` bigint(20) not null default 0 COMMENT '工会收益',
|
||||||
|
ADD COLUMN `anchor_earnings_total` bigint(20) not null default 0 COMMENT '工会主播收入';
|
||||||
|
|
||||||
|
|
||||||
|
UPDATE cai_recharge_order t1
|
||||||
|
JOIN (
|
||||||
|
-- 子查询:找到每个user_id对应的最小id(最早记录)
|
||||||
|
SELECT user_id, MIN(id) AS first_id
|
||||||
|
FROM cai_recharge_order
|
||||||
|
where pay_status = 1 and pay_time is not null and admin = 0
|
||||||
|
GROUP BY user_id
|
||||||
|
) t2 ON t1.id = t2.first_id
|
||||||
|
SET t1.fast_pay = 1
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.ruoyi.job;
|
package com.ruoyi.job;
|
||||||
|
|
||||||
|
import com.ruoyi.cai.enums.rank.RankDataTypeEnum;
|
||||||
import com.ruoyi.cai.service.AnchorImCountDayService;
|
import com.ruoyi.cai.service.AnchorImCountDayService;
|
||||||
|
import com.ruoyi.cai.service.FastPayTotalService;
|
||||||
|
import com.ruoyi.cai.service.UnionTotalService;
|
||||||
import com.ruoyi.job.op.BusOp;
|
import com.ruoyi.job.op.BusOp;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -16,6 +20,10 @@ public class EveryDaysJob {
|
|||||||
private BusOp busOp;
|
private BusOp busOp;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AnchorImCountDayService anchorImCountDayService;
|
private AnchorImCountDayService anchorImCountDayService;
|
||||||
|
@Autowired
|
||||||
|
private FastPayTotalService fastPayTotalService;
|
||||||
|
@Autowired
|
||||||
|
private UnionTotalService unionTotalService;
|
||||||
// 凌晨0点3分执行一次
|
// 凌晨0点3分执行一次
|
||||||
@Scheduled(cron = "0 3 0 * * ? ")
|
@Scheduled(cron = "0 3 0 * * ? ")
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -29,5 +37,45 @@ public class EveryDaysJob {
|
|||||||
}finally {
|
}finally {
|
||||||
log.info("执行IM统计入库-结束");
|
log.info("执行IM统计入库-结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("执行每日首充-开始");
|
||||||
|
fastPayTotalService.refreshDate(LocalDate.now().plusDays(-1));
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("执行每日首充-失败!",e);
|
||||||
|
}finally {
|
||||||
|
log.info("执行每日首充-结束");
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
LocalDate date = now.plusDays(-1);
|
||||||
|
try {
|
||||||
|
log.info("保存工会日收益 开始执行");
|
||||||
|
unionTotalService.refreshData(RankDataTypeEnum.DAY,date);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("保存工会日收益 失败", e);
|
||||||
|
} finally {
|
||||||
|
log.info("保存工会日收益 结束执行");
|
||||||
|
}
|
||||||
|
DayOfWeek week = now.getDayOfWeek();
|
||||||
|
if (week.getValue() == 1) { // 今天是周一 做一下持久化
|
||||||
|
LocalDate lastWeekDate = now.plusDays(-7);
|
||||||
|
try {
|
||||||
|
log.info("保存工会周收益 开始执行");
|
||||||
|
unionTotalService.refreshData(RankDataTypeEnum.WEEK,lastWeekDate);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("保存工会周收益 失败", e);
|
||||||
|
} finally {
|
||||||
|
log.info("保存工会周收益 结束执行");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
log.info("刷新工会总收益 开始执行");
|
||||||
|
unionTotalService.refreshUnionTotalAll();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("刷新工会总收益 失败", e);
|
||||||
|
} finally {
|
||||||
|
log.info("刷新工会总收益 结束执行");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,14 +55,29 @@ public class ImOp {
|
|||||||
|
|
||||||
|
|
||||||
public void refreshIm(){
|
public void refreshIm(){
|
||||||
List<User> list = userService.list();
|
int current = 0;
|
||||||
for (User user : list) {
|
Page<User> page = new Page<>(0, 10);
|
||||||
|
while (true){
|
||||||
|
current++;
|
||||||
|
page.setCurrent(current);
|
||||||
|
Page<User> userPage = userService.page(page);
|
||||||
|
List<User> records = userPage.getRecords();
|
||||||
|
if(records.isEmpty()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (User user : records) {
|
||||||
String imToken = IdUtil.simpleUUID();
|
String imToken = IdUtil.simpleUUID();
|
||||||
userService.update(Wrappers.lambdaUpdate(User.class).eq(User::getId,user.getId()).set(User::getImToken, imToken));
|
userService.update(Wrappers.lambdaUpdate(User.class).eq(User::getId,user.getId()).set(User::getImToken, imToken));
|
||||||
this.register(user.getId(),imToken,user.getNickname());
|
this.register(user.getId(),imToken,user.getNickname());
|
||||||
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname(),user.getGender());
|
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname(),user.getGender());
|
||||||
LoginHelper.logoutApp(user.getId());
|
LoginHelper.logoutApp(user.getId());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(300);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(Long userId,String token,String nickname){
|
public void register(Long userId,String token,String nickname){
|
||||||
@@ -102,6 +117,11 @@ public class ImOp {
|
|||||||
for (User user : records) {
|
for (User user : records) {
|
||||||
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname(),user.getGender());
|
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname(),user.getGender());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(300);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ruoyi.test;
|
|||||||
|
|
||||||
import com.ruoyi.cai.rank.RankManager;
|
import com.ruoyi.cai.rank.RankManager;
|
||||||
import com.ruoyi.cai.rank.RankNode;
|
import com.ruoyi.cai.rank.RankNode;
|
||||||
|
import com.ruoyi.cai.service.FastPayTotalService;
|
||||||
import com.ruoyi.cai.service.RankService;
|
import com.ruoyi.cai.service.RankService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -45,4 +46,19 @@ public class CaiUnitTest {
|
|||||||
rankService.saveDayRank(LocalDate.now(),1);
|
rankService.saveDayRank(LocalDate.now(),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FastPayTotalService fastPayTotalService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test(){
|
||||||
|
try {
|
||||||
|
log.info("执行每日首充-开始");
|
||||||
|
fastPayTotalService.refreshAll();
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("执行每日首充-失败!",e);
|
||||||
|
}finally {
|
||||||
|
log.info("执行每日首充-结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.ruoyi.cai.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.cai.domain.FastPayTotal;
|
||||||
|
import com.ruoyi.cai.domain.UnionTotal;
|
||||||
|
import com.ruoyi.cai.service.FastPayTotalService;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
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 com.ruoyi.common.utils.StringUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cai/fastPayTotal")
|
||||||
|
public class FastPayTotalController extends BaseController {
|
||||||
|
|
||||||
|
private final FastPayTotalService fastPayTotalService;
|
||||||
|
|
||||||
|
@GetMapping("/getCurrentDay")
|
||||||
|
public R<Long> getCurrentDay() {
|
||||||
|
Long page = fastPayTotalService.getCurrentDay();
|
||||||
|
return R.ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<FastPayTotal> list(FastPayTotal bo, PageQuery pageQuery) {
|
||||||
|
Page<FastPayTotal> page = fastPayTotalService.page(pageQuery.build(),
|
||||||
|
Wrappers.lambdaQuery(bo).orderByDesc(FastPayTotal::getCountDate));
|
||||||
|
return TableDataInfo.build(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "刷新今日首充统计", businessType = BusinessType.DELETE)
|
||||||
|
@GetMapping("/refreshData")
|
||||||
|
public R<Void> remove(String date) {
|
||||||
|
if(StringUtils.isBlank(date)){
|
||||||
|
fastPayTotalService.refreshAll();
|
||||||
|
}else{
|
||||||
|
LocalDate parse = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
fastPayTotalService.refreshDate(parse);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.ruoyi.cai.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.cai.domain.UnionTotal;
|
||||||
|
import com.ruoyi.cai.service.UnionTotalService;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
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 com.ruoyi.common.utils.StringUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工会每日收益
|
||||||
|
*
|
||||||
|
* @author 77
|
||||||
|
* @date 2025-09-11
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cai/unionTotal")
|
||||||
|
public class UnionTotalController extends BaseController {
|
||||||
|
|
||||||
|
private final UnionTotalService unionTotalService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询工会每日收益列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("cai:unionTotal:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<UnionTotal> list(UnionTotal bo, PageQuery pageQuery) {
|
||||||
|
Page<UnionTotal> page = unionTotalService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||||
|
return TableDataInfo.build(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "刷新工会每日收益", businessType = BusinessType.DELETE)
|
||||||
|
@GetMapping("/refreshData")
|
||||||
|
public R<Void> refreshData(String date) {
|
||||||
|
if(StringUtils.isBlank(date)){
|
||||||
|
unionTotalService.refreshAll();
|
||||||
|
}else{
|
||||||
|
LocalDate parse = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
unionTotalService.refreshData(parse);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "刷新所有工会总收益")
|
||||||
|
@GetMapping("/refreshAllUnion")
|
||||||
|
public R<Void> refreshAllUnion() {
|
||||||
|
unionTotalService.refreshUnionTotalAll();
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "刷新指定工会总收益")
|
||||||
|
@GetMapping("/refreshUnionTotal")
|
||||||
|
public R<Void> refreshUnionTotal(Long unionId) {
|
||||||
|
unionTotalService.refreshUnionTotal(unionId);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.ruoyi.cai.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
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.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("cai_fast_pay_total")
|
||||||
|
public class FastPayTotal implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子账户ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
@DateTimeFormat(pattern = DateConstant.PATTERN_DATE)
|
||||||
|
private LocalDate countDate;
|
||||||
|
private Long count;
|
||||||
|
private LocalDateTime refreshTime;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -87,6 +87,8 @@ public class RechargeOrder implements Serializable {
|
|||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
private Boolean fastPay;
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class Union implements Serializable {
|
|||||||
* 工会名称
|
* 工会名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
private Long unionEarningsTotal;
|
||||||
|
private Long anchorEarningsTotal;
|
||||||
/**
|
/**
|
||||||
* 是否开启提成
|
* 是否开启提成
|
||||||
*/
|
*/
|
||||||
|
|||||||
56
ruoyi-cai/src/main/java/com/ruoyi/cai/domain/UnionTotal.java
Normal file
56
ruoyi-cai/src/main/java/com/ruoyi/cai/domain/UnionTotal.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package com.ruoyi.cai.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
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_union_total
|
||||||
|
*
|
||||||
|
* @author 77
|
||||||
|
* @date 2025-09-11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cai_union_total")
|
||||||
|
public class UnionTotal implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private String id;
|
||||||
|
private Long unionId;
|
||||||
|
private String unionName;
|
||||||
|
/**
|
||||||
|
* 工会收益
|
||||||
|
*/
|
||||||
|
private Long unionEarningsTotal;
|
||||||
|
/**
|
||||||
|
* 工会主播收入
|
||||||
|
*/
|
||||||
|
private Long anchorEarningsTotal;
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = DateConstant.PATTERN_DATE)
|
||||||
|
private LocalDate countDate;
|
||||||
|
/**
|
||||||
|
* 刷新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime refreshTime;
|
||||||
|
/**
|
||||||
|
* 日期类型
|
||||||
|
*/
|
||||||
|
private Integer dataType;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -49,6 +49,7 @@ public class UserInfo {
|
|||||||
* 是否领取首充奖励(true领取 false未领取)
|
* 是否领取首充奖励(true领取 false未领取)
|
||||||
*/
|
*/
|
||||||
private Boolean fastPay;
|
private Boolean fastPay;
|
||||||
|
private LocalDateTime fastPayTime;
|
||||||
/**
|
/**
|
||||||
* 最后登录IP
|
* 最后登录IP
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class RechargeConsumerResp {
|
|||||||
* 充值金额
|
* 充值金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
private String orderNo;
|
||||||
/**
|
/**
|
||||||
* 充值彩贝
|
* 充值彩贝
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ public enum SystemConfigEnum {
|
|||||||
// 七牛云 ?imageView2/2/w/120/h/120
|
// 七牛云 ?imageView2/2/w/120/h/120
|
||||||
// 腾讯云 ?thumbnail=120y120&imageView
|
// 腾讯云 ?thumbnail=120y120&imageView
|
||||||
IM_ICON_SUFFIX("?thumbnail=120y120&imageView", "im头像后缀",SystemConfigGroupEnum.SYSTEM),
|
IM_ICON_SUFFIX("?thumbnail=120y120&imageView", "im头像后缀",SystemConfigGroupEnum.SYSTEM),
|
||||||
|
IM_ICON_PREFIX("0", "是否加im头像前缀域名",SystemConfigGroupEnum.SYSTEM, new BooleanSystemConfigCheck()),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -102,10 +102,13 @@ public class ImManager {
|
|||||||
uinfoReq.setAccid(userId+"");
|
uinfoReq.setAccid(userId+"");
|
||||||
if(StringUtils.isNotBlank(avatar)){
|
if(StringUtils.isNotBlank(avatar)){
|
||||||
String icon = avatar;
|
String icon = avatar;
|
||||||
// if(!avatar.startsWith("http")){
|
boolean imIconPrefix = systemConfigManager.getSystemConfigOfBool(SystemConfigEnum.IM_ICON_PREFIX);
|
||||||
// String cosDomain = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
if(imIconPrefix){
|
||||||
// icon = cosDomain + avatar;
|
if (!avatar.startsWith("http")) {
|
||||||
// }
|
String cosDomain = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
|
||||||
|
icon = cosDomain + avatar;
|
||||||
|
}
|
||||||
|
}
|
||||||
String iconSuffix = systemConfigManager.getSystemConfig(SystemConfigEnum.IM_ICON_SUFFIX);
|
String iconSuffix = systemConfigManager.getSystemConfig(SystemConfigEnum.IM_ICON_SUFFIX);
|
||||||
uinfoReq.setIcon(icon+iconSuffix);
|
uinfoReq.setIcon(icon+iconSuffix);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -45,6 +46,8 @@ public class AwardManager {
|
|||||||
private YunxinHttpService yunxinHttpService;
|
private YunxinHttpService yunxinHttpService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserInviteService userInviteService;
|
private UserInviteService userInviteService;
|
||||||
|
@Autowired
|
||||||
|
private RechargeOrderService rechargeOrderService;
|
||||||
|
|
||||||
public void giveJoinAnchorAsync(Long anchorUserId){
|
public void giveJoinAnchorAsync(Long anchorUserId){
|
||||||
AwardManager bean = SpringUtil.getBean(AwardManager.class);
|
AwardManager bean = SpringUtil.getBean(AwardManager.class);
|
||||||
@@ -130,11 +133,13 @@ public class AwardManager {
|
|||||||
boolean update = userInfoService.update(Wrappers.lambdaUpdate(UserInfo.class)
|
boolean update = userInfoService.update(Wrappers.lambdaUpdate(UserInfo.class)
|
||||||
.eq(UserInfo::getId, userInfo.getId())
|
.eq(UserInfo::getId, userInfo.getId())
|
||||||
.eq(UserInfo::getFastPay, false)
|
.eq(UserInfo::getFastPay, false)
|
||||||
.set(UserInfo::getFastPay, true));
|
.set(UserInfo::getFastPay, true)
|
||||||
|
.set(UserInfo::getFastPayTime, LocalDateTime.now()));
|
||||||
if(!update){
|
if(!update){
|
||||||
log.warn("首充奖励领取失败 用户已领取 无需二次领取 136 userId={}",userId);
|
log.warn("首充奖励领取失败 用户已领取 无需二次领取 136 userId={}",userId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
rechargeOrderService.setFastPay(resp.getOrderNo());
|
||||||
UserInvite userInvite = userInviteService.getByUserId(userId);
|
UserInvite userInvite = userInviteService.getByUserId(userId);
|
||||||
if(userInvite == null){
|
if(userInvite == null){
|
||||||
log.warn("首充奖励分发失败 用户无邀请人,首冲奖励流失");
|
log.warn("首充奖励分发失败 用户无邀请人,首冲奖励流失");
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.ruoyi.cai.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.cai.domain.FastPayTotal;
|
||||||
|
|
||||||
|
public interface FastPayTotalMapper extends BaseMapper<FastPayTotal> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.ruoyi.cai.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.cai.domain.UnionTotal;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工会每日收益Mapper接口
|
||||||
|
*
|
||||||
|
* @author 77
|
||||||
|
* @date 2025-09-11
|
||||||
|
*/
|
||||||
|
public interface UnionTotalMapper extends BaseMapper<UnionTotal> {
|
||||||
|
|
||||||
|
List<UnionTotal> countUnionTotal(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
UnionTotal countUnion(@Param("unionId") Long unionId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.cai.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.cai.domain.FastPayTotal;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public interface FastPayTotalService extends IService<FastPayTotal> {
|
||||||
|
void refreshDate(LocalDate date);
|
||||||
|
|
||||||
|
void refreshAll();
|
||||||
|
|
||||||
|
Long getCurrentDay();
|
||||||
|
}
|
||||||
@@ -30,4 +30,6 @@ public interface RechargeOrderService extends IService<RechargeOrder> {
|
|||||||
RechargeConsumerResp orderSuccess(String orderNo, Map<String,String> params, String appId, PayTypeEnum payTypeEnum);
|
RechargeConsumerResp orderSuccess(String orderNo, Map<String,String> params, String appId, PayTypeEnum payTypeEnum);
|
||||||
|
|
||||||
RechargeOrder updateAdminRechargeOrder(AddRechargeOrderAdminDto dto);
|
RechargeOrder updateAdminRechargeOrder(AddRechargeOrderAdminDto dto);
|
||||||
|
|
||||||
|
void setFastPay(String orderNo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.ruoyi.cai.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.cai.domain.UnionTotal;
|
||||||
|
import com.ruoyi.cai.enums.rank.RankDataTypeEnum;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工会每日收益Service接口
|
||||||
|
*
|
||||||
|
* @author 77
|
||||||
|
* @date 2025-09-11
|
||||||
|
*/
|
||||||
|
public interface UnionTotalService extends IService<UnionTotal> {
|
||||||
|
|
||||||
|
void refreshData(LocalDate localDate);
|
||||||
|
|
||||||
|
void refreshData(RankDataTypeEnum dataType, LocalDate localDate);
|
||||||
|
|
||||||
|
void refreshAll();
|
||||||
|
|
||||||
|
void refreshUnionTotalAll();
|
||||||
|
|
||||||
|
void refreshUnionTotal(Long unionId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.ruoyi.cai.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.cai.domain.FastPayTotal;
|
||||||
|
import com.ruoyi.cai.domain.RechargeOrder;
|
||||||
|
import com.ruoyi.cai.mapper.FastPayTotalMapper;
|
||||||
|
import com.ruoyi.cai.service.FastPayTotalService;
|
||||||
|
import com.ruoyi.cai.service.RechargeOrderService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FastPayTotalServiceImpl extends ServiceImpl<FastPayTotalMapper, FastPayTotal> implements FastPayTotalService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RechargeOrderService rechargeOrderService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getCurrentDay() {
|
||||||
|
LocalDate date = LocalDate.now();
|
||||||
|
LocalDateTime startTime = date.atTime(LocalTime.MIN);
|
||||||
|
LocalDateTime endTime = date.atTime(LocalTime.MAX);
|
||||||
|
long count = rechargeOrderService.count(Wrappers.lambdaQuery(RechargeOrder.class)
|
||||||
|
.eq(RechargeOrder::getFastPay, true)
|
||||||
|
.eq(RechargeOrder::getAdmin, false)
|
||||||
|
.between(RechargeOrder::getPayTime, startTime, endTime));
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshDate(LocalDate date) {
|
||||||
|
LocalDateTime startTime = date.atTime(LocalTime.MIN);
|
||||||
|
LocalDateTime endTime = date.atTime(LocalTime.MAX);
|
||||||
|
long count = rechargeOrderService.count(Wrappers.lambdaQuery(RechargeOrder.class)
|
||||||
|
.eq(RechargeOrder::getFastPay, true)
|
||||||
|
.eq(RechargeOrder::getAdmin, false)
|
||||||
|
.between(RechargeOrder::getPayTime, startTime, endTime));
|
||||||
|
FastPayTotal one = this.getOne(Wrappers.lambdaQuery(FastPayTotal.class)
|
||||||
|
.eq(FastPayTotal::getCountDate, date)
|
||||||
|
.last("limit 1"));
|
||||||
|
if(one == null){
|
||||||
|
one = new FastPayTotal();
|
||||||
|
one.setCountDate(date);
|
||||||
|
one.setCount(count);
|
||||||
|
one.setRefreshTime(LocalDateTime.now());
|
||||||
|
this.save(one);
|
||||||
|
}else{
|
||||||
|
FastPayTotal update = new FastPayTotal();
|
||||||
|
update.setRefreshTime(LocalDateTime.now());
|
||||||
|
update.setCount(count);
|
||||||
|
update.setId(one.getId());
|
||||||
|
this.updateById(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshAll(){
|
||||||
|
RechargeOrder one = rechargeOrderService.getOne(Wrappers.lambdaQuery(RechargeOrder.class)
|
||||||
|
.eq(RechargeOrder::getPayStatus,1)
|
||||||
|
.eq(RechargeOrder::getFastPay, true)
|
||||||
|
.eq(RechargeOrder::getAdmin, false)
|
||||||
|
.orderByAsc(RechargeOrder::getPayTime)
|
||||||
|
.last("limit 1"));
|
||||||
|
if(one == null){
|
||||||
|
log.error("无数据,不用刷");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LocalDate localDate = one.getPayTime().toLocalDate();
|
||||||
|
while (true){
|
||||||
|
if(localDate.equals(LocalDate.now())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
refreshDate(localDate);
|
||||||
|
localDate = localDate.plusDays(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -136,6 +136,7 @@ public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper,Re
|
|||||||
resp.setTraceId(traceId);
|
resp.setTraceId(traceId);
|
||||||
resp.setPrice(rechargeOrder.getPrice());
|
resp.setPrice(rechargeOrder.getPrice());
|
||||||
resp.setRechargeCoin(rechargeOrder.getRechargeCoin());
|
resp.setRechargeCoin(rechargeOrder.getRechargeCoin());
|
||||||
|
resp.setOrderNo(rechargeOrder.getOrderNo());
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,5 +203,12 @@ public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper,Re
|
|||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFastPay(String orderNo) {
|
||||||
|
if(orderNo != null){
|
||||||
|
this.update(Wrappers.<RechargeOrder>lambdaUpdate().set(RechargeOrder::getFastPay,true).eq(RechargeOrder::getOrderNo, orderNo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
package com.ruoyi.cai.service.impl;
|
||||||
|
|
||||||
|
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.ConsumeLog;
|
||||||
|
import com.ruoyi.cai.domain.Union;
|
||||||
|
import com.ruoyi.cai.domain.UnionTotal;
|
||||||
|
import com.ruoyi.cai.enums.rank.RankDataTypeEnum;
|
||||||
|
import com.ruoyi.cai.mapper.UnionTotalMapper;
|
||||||
|
import com.ruoyi.cai.service.ConsumeLogService;
|
||||||
|
import com.ruoyi.cai.service.UnionService;
|
||||||
|
import com.ruoyi.cai.service.UnionTotalService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工会每日收益Service业务层处理
|
||||||
|
*
|
||||||
|
* @author 77
|
||||||
|
* @date 2025-09-11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UnionTotalServiceImpl extends ServiceImpl<UnionTotalMapper, UnionTotal> implements UnionTotalService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnionTotalMapper unionTotalMapper;
|
||||||
|
@Autowired
|
||||||
|
private ConsumeLogService consumeLogService;
|
||||||
|
@Autowired
|
||||||
|
private UnionService unionService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshData(LocalDate localDate) {
|
||||||
|
this.refreshData(RankDataTypeEnum.DAY,localDate);
|
||||||
|
if(localDate.getDayOfWeek() == DayOfWeek.MONDAY){
|
||||||
|
this.refreshData(RankDataTypeEnum.WEEK,localDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshData(RankDataTypeEnum dataType, LocalDate localDate) {
|
||||||
|
if (dataType == RankDataTypeEnum.DAY) {
|
||||||
|
refreshDataDay(localDate);
|
||||||
|
} else if (dataType == RankDataTypeEnum.WEEK) {
|
||||||
|
refreshDataWeek(localDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshAll() {
|
||||||
|
ConsumeLog one = consumeLogService.getOne(Wrappers.lambdaQuery(ConsumeLog.class)
|
||||||
|
.orderByAsc(ConsumeLog::getCreateTime)
|
||||||
|
.last("limit 1"));
|
||||||
|
if(one == null){
|
||||||
|
log.error("无数据,不用刷");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LocalDate localDate = one.getCreateTime().toLocalDate();
|
||||||
|
while (true){
|
||||||
|
if(localDate.equals(LocalDate.now())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.refreshData(localDate);
|
||||||
|
localDate = localDate.plusDays(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshUnionTotalAll() {
|
||||||
|
int current = 0;
|
||||||
|
int pageSize = 10;
|
||||||
|
Page<Union> page = new Page<>(0, pageSize);
|
||||||
|
while (true){
|
||||||
|
current++;
|
||||||
|
page.setCurrent(current);
|
||||||
|
Page<Union> userPage = unionService.page(page);
|
||||||
|
List<Union> records = userPage.getRecords();
|
||||||
|
for (Union union : records) {
|
||||||
|
this.refreshUnionTotal(union.getId());
|
||||||
|
}
|
||||||
|
if(records.isEmpty() || records.size() < pageSize){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshUnionTotal(Long unionId) {
|
||||||
|
UnionTotal unionTotal = unionTotalMapper.countUnion(unionId);
|
||||||
|
unionService.update(Wrappers.lambdaUpdate(Union.class)
|
||||||
|
.eq(Union::getId, unionId)
|
||||||
|
.set(Union::getAnchorEarningsTotal, unionTotal.getAnchorEarningsTotal())
|
||||||
|
.set(Union::getUnionEarningsTotal, unionTotal.getUnionEarningsTotal()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshDataDay(LocalDate localDate) {
|
||||||
|
LocalDateTime minTime = localDate.atTime(LocalTime.MIN);
|
||||||
|
LocalDateTime maxTime = localDate.atTime(LocalTime.MAX);
|
||||||
|
List<UnionTotal> unionTotalList = unionTotalMapper.countUnionTotal(minTime, maxTime);
|
||||||
|
for (UnionTotal unionTotal : unionTotalList) {
|
||||||
|
UnionTotal one = this.getOne(Wrappers.lambdaQuery(UnionTotal.class).eq(UnionTotal::getCountDate, localDate)
|
||||||
|
.eq(UnionTotal::getDataType, RankDataTypeEnum.DAY.getCode()).last("limit 1"));
|
||||||
|
if (one == null) {
|
||||||
|
one = new UnionTotal();
|
||||||
|
one.setUnionId(unionTotal.getUnionId());
|
||||||
|
one.setUnionName(unionTotal.getUnionName());
|
||||||
|
one.setUnionEarningsTotal(unionTotal.getUnionEarningsTotal());
|
||||||
|
one.setAnchorEarningsTotal(unionTotal.getAnchorEarningsTotal());
|
||||||
|
one.setCountDate(localDate);
|
||||||
|
one.setRefreshTime(LocalDateTime.now());
|
||||||
|
one.setDataType(RankDataTypeEnum.DAY.getCode());
|
||||||
|
this.save(one);
|
||||||
|
} else {
|
||||||
|
UnionTotal update = new UnionTotal();
|
||||||
|
update.setUnionEarningsTotal(unionTotal.getUnionEarningsTotal());
|
||||||
|
update.setAnchorEarningsTotal(unionTotal.getAnchorEarningsTotal());
|
||||||
|
update.setRefreshTime(LocalDateTime.now());
|
||||||
|
update.setUnionId(unionTotal.getUnionId());
|
||||||
|
update.setUnionName(unionTotal.getUnionName());
|
||||||
|
update.setId(one.getId());
|
||||||
|
this.updateById(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void refreshDataWeek(LocalDate localDate) {
|
||||||
|
LocalDateTime minTime = localDate.atTime(LocalTime.MIN);
|
||||||
|
LocalDateTime maxTime = localDate.plusDays(6).atTime(LocalTime.MAX);
|
||||||
|
List<UnionTotal> unionTotalList = unionTotalMapper.countUnionTotal(minTime, maxTime);
|
||||||
|
for (UnionTotal unionTotal : unionTotalList) {
|
||||||
|
UnionTotal one = this.getOne(Wrappers.lambdaQuery(UnionTotal.class).eq(UnionTotal::getCountDate, localDate)
|
||||||
|
.eq(UnionTotal::getDataType, RankDataTypeEnum.WEEK.getCode()).last("limit 1"));
|
||||||
|
if (one == null) {
|
||||||
|
one = new UnionTotal();
|
||||||
|
one.setUnionId(unionTotal.getUnionId());
|
||||||
|
one.setUnionName(unionTotal.getUnionName());
|
||||||
|
one.setUnionEarningsTotal(unionTotal.getUnionEarningsTotal());
|
||||||
|
one.setAnchorEarningsTotal(unionTotal.getAnchorEarningsTotal());
|
||||||
|
one.setCountDate(localDate);
|
||||||
|
one.setRefreshTime(LocalDateTime.now());
|
||||||
|
one.setDataType(RankDataTypeEnum.WEEK.getCode());
|
||||||
|
this.save(one);
|
||||||
|
} else {
|
||||||
|
UnionTotal update = new UnionTotal();
|
||||||
|
update.setUnionEarningsTotal(unionTotal.getUnionEarningsTotal());
|
||||||
|
update.setAnchorEarningsTotal(unionTotal.getAnchorEarningsTotal());
|
||||||
|
update.setRefreshTime(LocalDateTime.now());
|
||||||
|
update.setId(one.getId());
|
||||||
|
this.updateById(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
ruoyi-cai/src/main/resources/mapper/cai/UnionTotalMapper.xml
Normal file
25
ruoyi-cai/src/main/resources/mapper/cai/UnionTotalMapper.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?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.UnionTotalMapper">
|
||||||
|
|
||||||
|
<select id="countUnionTotal" resultType="com.ruoyi.cai.domain.UnionTotal">
|
||||||
|
select
|
||||||
|
t2.id as unionId, t2.name as unionName,
|
||||||
|
sum(anchor_amount) as anchorEarningsTotal,
|
||||||
|
if(t2.id,sum(union_amount),0) as unionEarningsTotal
|
||||||
|
from cai_consume_log t1
|
||||||
|
join cai_union t2 on t1.union_user_id = t2.user_id
|
||||||
|
where t1.create_time between #{startTime} and #{endTime} and t2.id is not null
|
||||||
|
group by t2.id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countUnion" resultType="com.ruoyi.cai.domain.UnionTotal">
|
||||||
|
select
|
||||||
|
ifnull(sum(anchor_earnings_total),0) as anchor_earnings_total,
|
||||||
|
ifnull(sum(union_earnings_total),0) as union_earnings_total
|
||||||
|
from cai_union_total t1
|
||||||
|
where t1.union_id = #{unionId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user