144 lines
5.4 KiB
Java
144 lines
5.4 KiB
Java
package com.ruoyi.job.op;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.ruoyi.cai.domain.*;
|
|
import com.ruoyi.cai.pay.PayManager;
|
|
import com.ruoyi.cai.pay.PayStatusEnum;
|
|
import com.ruoyi.cai.service.*;
|
|
import com.ruoyi.cai.ws.constant.RoomStatusEnums;
|
|
import com.ruoyi.common.utils.BeanConvertUtil;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.system.domain.SysOperLog;
|
|
import com.ruoyi.system.domain.SysOperLogCopy;
|
|
import com.ruoyi.system.mapper.SysOperLogMapper;
|
|
import com.ruoyi.system.mapper.SysOperLogCopyMapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.time.LocalDateTime;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Component
|
|
@Slf4j
|
|
public class BusOp {
|
|
@Autowired
|
|
private UserService userService;
|
|
@Autowired
|
|
private UserMemberService userMemberService;
|
|
@Autowired
|
|
private PayManager payManager;
|
|
@Autowired
|
|
private RechargeOrderService rechargeOrderService;
|
|
@Autowired
|
|
private VipOrderService vipOrderService;
|
|
@Autowired
|
|
private UserCallService userCallService;
|
|
@Resource
|
|
private SysOperLogMapper sysOperLogMapper;
|
|
@Resource
|
|
private SysOperLogCopyMapper sysOperLogCopyMapper;
|
|
|
|
public void deleteUserCall(int days){
|
|
LocalDateTime deleteTimeFlag = LocalDateTime.now().plusDays(-days);
|
|
int current = 0;
|
|
while (true){
|
|
List<UserCall> list = userCallService.list(Wrappers.lambdaUpdate(UserCall.class)
|
|
.lt(UserCall::getCreateTime, deleteTimeFlag)
|
|
.eq(UserCall::getStatus, RoomStatusEnums.STATUS_CREATE.getCode())
|
|
.last("limit 100"));
|
|
if(current > 500 || CollectionUtils.isEmpty(list)){
|
|
break;
|
|
}
|
|
current++;
|
|
List<Long> ids = list.stream().map(UserCall::getId).collect(Collectors.toList());
|
|
userCallService.removeBatchByIds(ids);
|
|
}
|
|
}
|
|
|
|
public void copySysLog(int days){
|
|
Date copyTimeFlag = DateUtils.addDays(new Date(), -days);
|
|
int current = 0;
|
|
while (true){
|
|
List<SysOperLog> list = sysOperLogMapper.selectList(Wrappers.lambdaUpdate(SysOperLog.class)
|
|
.lt(SysOperLog::getOperTime, copyTimeFlag)
|
|
.last("limit 300"));
|
|
if(current > 1000 || CollectionUtils.isEmpty(list)){
|
|
break;
|
|
}
|
|
current++;
|
|
for (SysOperLog sysOperLog : list) {
|
|
sysOperLogMapper.deleteById(sysOperLog.getOperId());
|
|
sysOperLogCopyMapper.insert(BeanConvertUtil.convertTo(sysOperLog, SysOperLogCopy::new));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void checkVipOrder(LocalDateTime startTime, LocalDateTime endTime, String orderNo){
|
|
if(StringUtils.isNotEmpty(orderNo)){
|
|
payManager.queryAndUpdateCallbackPayStatus(orderNo,"wx228d04f4dbf691c6");
|
|
return;
|
|
}
|
|
if(startTime != null && endTime != null){
|
|
List<VipOrder> list = vipOrderService.list(Wrappers.lambdaQuery(VipOrder.class)
|
|
.between(VipOrder::getCreateTime, startTime, endTime)
|
|
.eq(VipOrder::getPayStatus, PayStatusEnum.READY_PAY));
|
|
for (VipOrder order : list) {
|
|
try {
|
|
payManager.queryAndUpdateCallbackPayStatus(order.getOrderNo(),"wx228d04f4dbf691c6");
|
|
}catch (Exception e){
|
|
log.error("检查订单失败!",e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void checkRechargeOrder(LocalDateTime startTime, LocalDateTime endTime, String orderNo){
|
|
if(StringUtils.isNotEmpty(orderNo)){
|
|
payManager.queryAndUpdateCallbackPayStatus(orderNo,"wx228d04f4dbf691c6");
|
|
return;
|
|
}
|
|
if(startTime != null && endTime != null){
|
|
List<RechargeOrder> list = rechargeOrderService.list(Wrappers.lambdaQuery(RechargeOrder.class)
|
|
.between(RechargeOrder::getCreateTime, startTime, endTime)
|
|
.eq(RechargeOrder::getPayStatus, PayStatusEnum.READY_PAY.getCode()));
|
|
for (RechargeOrder order : list) {
|
|
try {
|
|
payManager.queryAndUpdateCallbackPayStatus(order.getOrderNo(),"wx228d04f4dbf691c6");
|
|
}catch (Exception e){
|
|
log.error("检查订单失败!",e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void refreshUserVipStatus(){
|
|
int current = 0;
|
|
Page<User> page = new Page<>(0, 100);
|
|
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) {
|
|
if(user.getNoGreet() != null && user.getRankHide() != null){
|
|
if(user.getNoGreet().equals(1) || user.getRankHide().equals(1)){
|
|
userMemberService.checkAndUpdateUser(user.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|