Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -107,8 +107,8 @@ public class AppController {
|
||||
userEntity.setUserId(userId);
|
||||
old.setZhiFuBao(userEntity.getZhiFuBao());
|
||||
old.setZhiFuBaoName(userEntity.getZhiFuBaoName());
|
||||
boolean bool = userService.updateById(userEntity);
|
||||
// 去除首绑支付宝奖励
|
||||
// boolean bool = userService.updateById(userEntity);
|
||||
// if (bool && isFirstBind) {
|
||||
// userService.firstBindAwardsMoney(old);
|
||||
// }
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -17,6 +18,7 @@ import lombok.EqualsAndHashCode;
|
||||
@TableName(value ="invite_achievement")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class InviteAchievement implements Serializable {
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -18,8 +18,8 @@ public interface InviteAchievementMapper extends BaseMapper<InviteAchievement> {
|
||||
@Update("update invite_achievement set count = count + #{i}, update_time=now() where id = #{id}")
|
||||
int incrCount(Integer id, int i);
|
||||
|
||||
@Insert("INSERT INTO invite_achievement (user_id, by_user_id, count, is_first, create_time)\n" +
|
||||
"SELECT #{userId}, #{byUserId}, #{count}, #{isFirst}, #{createTime} " +
|
||||
@Insert("INSERT INTO invite_achievement (user_id, source_user_id, count, state, create_time)\n" +
|
||||
"SELECT #{userId}, #{sourceUserId}, #{count}, #{state}, #{createTime} " +
|
||||
"WHERE NOT EXISTS ( " +
|
||||
" SELECT 1 FROM invite_achievement WHERE user_id = #{userId} " +
|
||||
");")
|
||||
|
||||
@@ -1498,7 +1498,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
||||
if (ret) {
|
||||
ThreadUtil.execAsync(()->{
|
||||
discSpinningService.withdrawAsync(entity, money.doubleValue(), "[提现]");
|
||||
},true);
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("首绑支付宝发放奖励异常,用户信息:{}", JSONUtil.toJsonStr(entity));
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.sqx.modules.job.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 定时任务配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class ScheduleConfig {
|
||||
|
||||
@Bean
|
||||
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
|
||||
SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
||||
factory.setDataSource(dataSource);
|
||||
|
||||
//quartz参数
|
||||
Properties prop = new Properties();
|
||||
prop.put("org.quartz.scheduler.instanceName", "sqxScheduler");
|
||||
prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
||||
//线程池配置
|
||||
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
||||
prop.put("org.quartz.threadPool.threadCount", "20");
|
||||
prop.put("org.quartz.threadPool.threadPriority", "5");
|
||||
//JobStore配置
|
||||
prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
|
||||
//集群配置
|
||||
prop.put("org.quartz.jobStore.isClustered", "true");
|
||||
prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
|
||||
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
|
||||
|
||||
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
|
||||
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
||||
prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
|
||||
|
||||
//PostgreSQL数据库,需要打开此注释
|
||||
//prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
|
||||
|
||||
factory.setQuartzProperties(prop);
|
||||
|
||||
factory.setSchedulerName("sqxScheduler");
|
||||
//延时启动
|
||||
factory.setStartupDelay(30);
|
||||
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
||||
//可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
|
||||
factory.setOverwriteExistingJobs(true);
|
||||
//设置自动启动,默认为true
|
||||
factory.setAutoStartup(true);
|
||||
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
@@ -81,34 +81,34 @@ public class ScheduleJobController {
|
||||
/**
|
||||
* 立即执行任务
|
||||
*/
|
||||
@SysLog("立即执行任务")
|
||||
@RequestMapping("/run")
|
||||
public Result run(@RequestBody Long[] jobIds){
|
||||
scheduleJobService.run(jobIds);
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停定时任务
|
||||
*/
|
||||
@SysLog("暂停定时任务")
|
||||
@RequestMapping("/pause")
|
||||
public Result pause(@RequestBody Long[] jobIds){
|
||||
scheduleJobService.pause(jobIds);
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复定时任务
|
||||
*/
|
||||
@SysLog("恢复定时任务")
|
||||
@RequestMapping("/resume")
|
||||
public Result resume(@RequestBody Long[] jobIds){
|
||||
scheduleJobService.resume(jobIds);
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
// @SysLog("立即执行任务")
|
||||
// @RequestMapping("/run")
|
||||
// public Result run(@RequestBody Long[] jobIds){
|
||||
// scheduleJobService.run(jobIds);
|
||||
//
|
||||
// return Result.success();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 暂停定时任务
|
||||
// */
|
||||
// @SysLog("暂停定时任务")
|
||||
// @RequestMapping("/pause")
|
||||
// public Result pause(@RequestBody Long[] jobIds){
|
||||
// scheduleJobService.pause(jobIds);
|
||||
//
|
||||
// return Result.success();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 恢复定时任务
|
||||
// */
|
||||
// @SysLog("恢复定时任务")
|
||||
// @RequestMapping("/resume")
|
||||
// public Result resume(@RequestBody Long[] jobIds){
|
||||
// scheduleJobService.resume(jobIds);
|
||||
//
|
||||
// return Result.success();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -34,18 +34,18 @@ public interface ScheduleJobService extends IService<ScheduleJobEntity> {
|
||||
*/
|
||||
int updateBatch(Long[] jobIds, int status);
|
||||
|
||||
/**
|
||||
* 立即执行
|
||||
*/
|
||||
void run(Long[] jobIds);
|
||||
|
||||
/**
|
||||
* 暂停运行
|
||||
*/
|
||||
void pause(Long[] jobIds);
|
||||
|
||||
/**
|
||||
* 恢复运行
|
||||
*/
|
||||
void resume(Long[] jobIds);
|
||||
// /**
|
||||
// * 立即执行
|
||||
// */
|
||||
// void run(Long[] jobIds);
|
||||
//
|
||||
// /**
|
||||
// * 暂停运行
|
||||
// */
|
||||
// void pause(Long[] jobIds);
|
||||
//
|
||||
// /**
|
||||
// * 恢复运行
|
||||
// */
|
||||
// void resume(Long[] jobIds);
|
||||
}
|
||||
|
||||
@@ -9,38 +9,22 @@ import com.sqx.common.utils.Query;
|
||||
import com.sqx.modules.job.dao.ScheduleJobDao;
|
||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||
import com.sqx.modules.job.service.ScheduleJobService;
|
||||
import com.sqx.modules.job.utils.ScheduleUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.Scheduler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("scheduleJobService")
|
||||
public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService {
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化定时器
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
List<ScheduleJobEntity> scheduleJobList = this.list();
|
||||
for(ScheduleJobEntity scheduleJob : scheduleJobList){
|
||||
CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getJobId());
|
||||
//如果不存在,则创建
|
||||
if(cronTrigger == null) {
|
||||
ScheduleUtils.createScheduleJob(scheduler, scheduleJob);
|
||||
}else {
|
||||
ScheduleUtils.updateScheduleJob(scheduler, scheduleJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
@@ -61,25 +45,18 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
||||
scheduleJob.setCreateTime(new Date());
|
||||
scheduleJob.setStatus(Constant.ScheduleStatus.NORMAL.getValue());
|
||||
this.save(scheduleJob);
|
||||
|
||||
ScheduleUtils.createScheduleJob(scheduler, scheduleJob);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(ScheduleJobEntity scheduleJob) {
|
||||
ScheduleUtils.updateScheduleJob(scheduler, scheduleJob);
|
||||
|
||||
|
||||
this.updateById(scheduleJob);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteBatch(Long[] jobIds) {
|
||||
for(Long jobId : jobIds){
|
||||
ScheduleUtils.deleteScheduleJob(scheduler, jobId);
|
||||
}
|
||||
|
||||
//删除数据
|
||||
this.removeByIds(Arrays.asList(jobIds));
|
||||
}
|
||||
@@ -92,32 +69,32 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
||||
return baseMapper.updateBatch(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void run(Long[] jobIds) {
|
||||
for(Long jobId : jobIds){
|
||||
ScheduleUtils.run(scheduler, this.getById(jobId));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void pause(Long[] jobIds) {
|
||||
for(Long jobId : jobIds){
|
||||
ScheduleUtils.pauseJob(scheduler, jobId);
|
||||
}
|
||||
|
||||
updateBatch(jobIds, Constant.ScheduleStatus.PAUSE.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void resume(Long[] jobIds) {
|
||||
for(Long jobId : jobIds){
|
||||
ScheduleUtils.resumeJob(scheduler, jobId);
|
||||
}
|
||||
|
||||
updateBatch(jobIds, Constant.ScheduleStatus.NORMAL.getValue());
|
||||
}
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void run(Long[] jobIds) {
|
||||
// for(Long jobId : jobIds){
|
||||
// ScheduleUtils.run(scheduler, this.getById(jobId));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void pause(Long[] jobIds) {
|
||||
// for(Long jobId : jobIds){
|
||||
// ScheduleUtils.pauseJob(scheduler, jobId);
|
||||
// }
|
||||
//
|
||||
// updateBatch(jobIds, Constant.ScheduleStatus.PAUSE.getValue());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void resume(Long[] jobIds) {
|
||||
// for(Long jobId : jobIds){
|
||||
// ScheduleUtils.resumeJob(scheduler, jobId);
|
||||
// }
|
||||
//
|
||||
// updateBatch(jobIds, Constant.ScheduleStatus.NORMAL.getValue());
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Component("CashOutTask")
|
||||
public class CashOutTask implements ITask {
|
||||
@Component
|
||||
public class CashOutTask{
|
||||
|
||||
@Resource
|
||||
private CashOutDao cashOutDao;
|
||||
@@ -32,7 +32,6 @@ public class CashOutTask implements ITask {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
logger.info("提现开始");
|
||||
List<CashOut> cashOuts = cashOutDao.selectYesterday();
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.sqx.modules.utils.AliPayOrderUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -23,8 +24,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component("CashOutTask2")
|
||||
public class CashOutTask2 implements ITask {
|
||||
@Component
|
||||
public class CashOutTask2{
|
||||
|
||||
@Resource
|
||||
private CashOutDao cashOutDao;
|
||||
@@ -37,7 +38,6 @@ public class CashOutTask2 implements ITask {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
logger.info("提现开始");
|
||||
if (StringUtils.isBlank(params) || isValidDate(params)) {
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.sqx.modules.job.task;
|
||||
|
||||
/**
|
||||
* 定时任务接口,所有定时任务都要实现该接口
|
||||
*
|
||||
*/
|
||||
public interface ITask {
|
||||
|
||||
/**
|
||||
* 执行定时任务接口
|
||||
*
|
||||
* @param params 参数,多参数使用JSON数据
|
||||
*/
|
||||
void run(String params);
|
||||
}
|
||||
@@ -9,14 +9,17 @@ import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component("SpinningTask3")
|
||||
public class SpinningTask3 implements ITask {
|
||||
@Component
|
||||
@EnableScheduling
|
||||
public class SpinningTask3 {
|
||||
|
||||
@Resource
|
||||
private DiscSpinningService spinningController;
|
||||
@@ -25,8 +28,12 @@ public class SpinningTask3 implements ITask {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
@Scheduled(cron = "0 0/2 * * * ? ")
|
||||
public void record() {
|
||||
record("1");
|
||||
}
|
||||
|
||||
public void record(String params) {
|
||||
logger.info("大转盘到账补偿机制");
|
||||
// 获取当前时间
|
||||
Date now = DateUtil.date();
|
||||
@@ -48,6 +55,7 @@ public class SpinningTask3 implements ITask {
|
||||
recordQueryWrapper.lt("create_time", fiveMinutesAgoStr);
|
||||
//小于
|
||||
recordQueryWrapper.gt("create_time", tenMinutesAgoStr);
|
||||
logger.info("大转盘到账补偿时间范围:{}-----{}", tenMinutesAgoStr, fiveMinutesAgoStr);
|
||||
List<DiscSpinningRecord> list = recordService.list(recordQueryWrapper);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
for (DiscSpinningRecord record : list) {
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.List;
|
||||
* @author GYJoker
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("SupplyAgainSignRewardTask")
|
||||
public class SupplyAgainSignRewardTask implements ITask {
|
||||
@Component
|
||||
public class SupplyAgainSignRewardTask{
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@@ -35,7 +35,6 @@ public class SupplyAgainSignRewardTask implements ITask {
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
if (StringUtils.isBlank(params)) {
|
||||
log.error("参数为空");
|
||||
|
||||
@@ -13,8 +13,8 @@ import org.springframework.stereotype.Component;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Component("TempCashOutTask")
|
||||
public class TempCashOutTask implements ITask {
|
||||
@Component
|
||||
public class TempCashOutTask{
|
||||
|
||||
@Resource
|
||||
private CashOutDao cashOutDao;
|
||||
@@ -23,7 +23,6 @@ public class TempCashOutTask implements ITask {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
logger.info("提现开始");
|
||||
List<CashOut> cashOuts = cashOutDao.selectTemp();
|
||||
|
||||
@@ -40,8 +40,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("TempOrdersTask")
|
||||
public class TempOrdersTask implements ITask {
|
||||
@Component
|
||||
public class TempOrdersTask {
|
||||
|
||||
@Resource
|
||||
private OrdersDao ordersDao;
|
||||
@@ -71,7 +71,6 @@ public class TempOrdersTask implements ITask {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
logger.info("订单表数据处理开始");
|
||||
List<Orders> orders = ordersDao.selectList(Wrappers.<Orders>lambdaQuery()
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.sqx.modules.job.task;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 测试定时任务(演示Demo,可删除)
|
||||
*
|
||||
* testTask为spring bean的名称
|
||||
*
|
||||
*/
|
||||
@Component("testTask")
|
||||
public class TestTask implements ITask {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public void run(String params){
|
||||
|
||||
logger.debug("TestTask定时任务正在执行,参数为:{}", params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.sqx.modules.job.utils;
|
||||
|
||||
import com.sqx.common.utils.SpringContextUtils;
|
||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||
import com.sqx.modules.job.entity.ScheduleJobLogEntity;
|
||||
import com.sqx.modules.job.service.ScheduleJobLogService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
*
|
||||
*/
|
||||
public class ScheduleJob extends QuartzJobBean {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap()
|
||||
.get(ScheduleJobEntity.JOB_PARAM_KEY);
|
||||
|
||||
//获取spring bean
|
||||
ScheduleJobLogService scheduleJobLogService = (ScheduleJobLogService) SpringContextUtils.getBean("scheduleJobLogService");
|
||||
|
||||
//数据库保存执行记录
|
||||
ScheduleJobLogEntity log = new ScheduleJobLogEntity();
|
||||
log.setJobId(scheduleJob.getJobId());
|
||||
log.setBeanName(scheduleJob.getBeanName());
|
||||
log.setParams(scheduleJob.getParams());
|
||||
log.setCreateTime(new Date());
|
||||
|
||||
//任务开始时间
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
//执行任务
|
||||
logger.debug("任务准备执行,任务ID:" + scheduleJob.getJobId());
|
||||
|
||||
Object target = SpringContextUtils.getBean(scheduleJob.getBeanName());
|
||||
Method method = target.getClass().getDeclaredMethod("run", String.class);
|
||||
method.invoke(target, scheduleJob.getParams());
|
||||
|
||||
//任务执行总时长
|
||||
long times = System.currentTimeMillis() - startTime;
|
||||
log.setTimes((int)times);
|
||||
//任务状态 0:成功 1:失败
|
||||
log.setStatus(0);
|
||||
|
||||
logger.debug("任务执行完毕,任务ID:" + scheduleJob.getJobId() + " 总共耗时:" + times + "毫秒");
|
||||
} catch (Exception e) {
|
||||
logger.error("任务执行失败,任务ID:" + scheduleJob.getJobId(), e);
|
||||
|
||||
//任务执行总时长
|
||||
long times = System.currentTimeMillis() - startTime;
|
||||
log.setTimes((int)times);
|
||||
|
||||
//任务状态 0:成功 1:失败
|
||||
log.setStatus(1);
|
||||
log.setError(StringUtils.substring(e.toString(), 0, 2000));
|
||||
}finally {
|
||||
scheduleJobLogService.save(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
package com.sqx.modules.job.utils;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.Constant;
|
||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||
import org.quartz.*;
|
||||
|
||||
/**
|
||||
* 定时任务工具类
|
||||
*
|
||||
*/
|
||||
public class ScheduleUtils {
|
||||
private final static String JOB_NAME = "TASK_";
|
||||
|
||||
/**
|
||||
* 获取触发器key
|
||||
*/
|
||||
public static TriggerKey getTriggerKey(Long jobId) {
|
||||
return TriggerKey.triggerKey(JOB_NAME + jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取jobKey
|
||||
*/
|
||||
public static JobKey getJobKey(Long jobId) {
|
||||
return JobKey.jobKey(JOB_NAME + jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表达式触发器
|
||||
*/
|
||||
public static CronTrigger getCronTrigger(Scheduler scheduler, Long jobId) {
|
||||
try {
|
||||
return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId));
|
||||
} catch (SchedulerException e) {
|
||||
throw new SqxException("获取定时任务CronTrigger出现异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建定时任务
|
||||
*/
|
||||
public static void createScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
|
||||
try {
|
||||
//构建job信息
|
||||
JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(scheduleJob.getJobId())).build();
|
||||
|
||||
//表达式调度构建器
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
|
||||
.withMisfireHandlingInstructionDoNothing();
|
||||
|
||||
//按新的cronExpression表达式构建一个新的trigger
|
||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getJobId())).withSchedule(scheduleBuilder).build();
|
||||
|
||||
//放入参数,运行时的方法可以获取
|
||||
jobDetail.getJobDataMap().put(ScheduleJobEntity.JOB_PARAM_KEY, scheduleJob);
|
||||
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
|
||||
//暂停任务
|
||||
if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){
|
||||
pauseJob(scheduler, scheduleJob.getJobId());
|
||||
}
|
||||
} catch (SchedulerException e) {
|
||||
throw new SqxException("创建定时任务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新定时任务
|
||||
*/
|
||||
public static void updateScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
|
||||
try {
|
||||
TriggerKey triggerKey = getTriggerKey(scheduleJob.getJobId());
|
||||
|
||||
//表达式调度构建器
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
|
||||
.withMisfireHandlingInstructionDoNothing();
|
||||
|
||||
CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getJobId());
|
||||
|
||||
//按新的cronExpression表达式重新构建trigger
|
||||
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
|
||||
|
||||
//参数
|
||||
trigger.getJobDataMap().put(ScheduleJobEntity.JOB_PARAM_KEY, scheduleJob);
|
||||
|
||||
scheduler.rescheduleJob(triggerKey, trigger);
|
||||
|
||||
//暂停任务
|
||||
if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){
|
||||
pauseJob(scheduler, scheduleJob.getJobId());
|
||||
}
|
||||
|
||||
} catch (SchedulerException e) {
|
||||
throw new SqxException("更新定时任务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即执行任务
|
||||
*/
|
||||
public static void run(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
|
||||
try {
|
||||
//参数
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put(ScheduleJobEntity.JOB_PARAM_KEY, scheduleJob);
|
||||
|
||||
scheduler.triggerJob(getJobKey(scheduleJob.getJobId()), dataMap);
|
||||
} catch (SchedulerException e) {
|
||||
throw new SqxException("立即执行定时任务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停任务
|
||||
*/
|
||||
public static void pauseJob(Scheduler scheduler, Long jobId) {
|
||||
try {
|
||||
scheduler.pauseJob(getJobKey(jobId));
|
||||
} catch (SchedulerException e) {
|
||||
throw new SqxException("暂停定时任务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复任务
|
||||
*/
|
||||
public static void resumeJob(Scheduler scheduler, Long jobId) {
|
||||
try {
|
||||
scheduler.resumeJob(getJobKey(jobId));
|
||||
} catch (SchedulerException e) {
|
||||
throw new SqxException("暂停定时任务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除定时任务
|
||||
*/
|
||||
public static void deleteScheduleJob(Scheduler scheduler, Long jobId) {
|
||||
try {
|
||||
scheduler.deleteJob(getJobKey(jobId));
|
||||
} catch (SchedulerException e) {
|
||||
throw new SqxException("删除定时任务失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,6 @@ import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.PayClassify;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.pay.service.PayClassifyService;
|
||||
import com.yungouos.pay.alipay.AliPay;
|
||||
import com.yungouos.pay.entity.AliPayH5Biz;
|
||||
import com.yungouos.pay.util.PaySignUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -109,16 +106,16 @@ public class AliPayController {
|
||||
log.info(flag + "回调验证信息");
|
||||
if (flag) {
|
||||
String tradeStatus = params.get("trade_status");
|
||||
if("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)){
|
||||
if ("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)) {
|
||||
//支付宝返回的订单编号
|
||||
String outTradeNo = params.get("out_trade_no");
|
||||
//支付宝支付单号
|
||||
String tradeNo = params.get("trade_no");
|
||||
PayDetails payDetails = payDetailsDao.selectByOrderId(outTradeNo);
|
||||
if(payDetails.getState()==0){
|
||||
if (payDetails.getState() == 0) {
|
||||
String format = sdf.format(new Date());
|
||||
payDetailsDao.updateState(payDetails.getId(),1,format,tradeNo);
|
||||
if(payDetails.getType()==1){
|
||||
payDetailsDao.updateState(payDetails.getId(), 1, format, tradeNo);
|
||||
if (payDetails.getType() == 1) {
|
||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||
orders.setPayWay(4);
|
||||
orders.setStatus(1);
|
||||
@@ -128,34 +125,34 @@ public class AliPayController {
|
||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
||||
Map map = inviteService.updateInvite(byUser, format, user.getUserId(), orders.getPayMoney());
|
||||
Object oneUserId = map.get("oneUserId");
|
||||
if(oneUserId!=null){
|
||||
if (oneUserId != null) {
|
||||
orders.setOneUserId(Long.parseLong(String.valueOf(oneUserId)));
|
||||
orders.setOneMoney(new BigDecimal(String.valueOf(map.get("oneMoney"))));
|
||||
}
|
||||
Object twoUserId = map.get("twoUserId");
|
||||
if(twoUserId!=null){
|
||||
if (twoUserId != null) {
|
||||
orders.setTwoUserId(Long.parseLong(String.valueOf(twoUserId)));
|
||||
orders.setTwoMoney(new BigDecimal(String.valueOf(map.get("twoMoney"))));
|
||||
}
|
||||
Object sysUserId = map.get("sysUserId");
|
||||
if(sysUserId!=null){
|
||||
if (sysUserId != null) {
|
||||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
}
|
||||
ordersService.updateById(orders);
|
||||
ordersService.insertOrders(orders);
|
||||
}else{
|
||||
} else {
|
||||
String remark = payDetails.getRemark();
|
||||
PayClassify payClassify = payClassifyService.getById(Long.parseLong(remark));
|
||||
BigDecimal add = payClassify.getMoney().add(payClassify.getGiveMoney());
|
||||
userMoneyService.updateMoney(1,payDetails.getUserId(),add.doubleValue());
|
||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
||||
userMoneyService.updateMoney(1, payDetails.getUserId(), add.doubleValue());
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||
// ✅
|
||||
userMoneyDetails.setClassify(2);
|
||||
userMoneyDetails.setMoney(add);
|
||||
userMoneyDetails.setUserId(payDetails.getUserId());
|
||||
userMoneyDetails.setContent("支付宝充值金币");
|
||||
userMoneyDetails.setTitle("支付宝充值金币:"+payClassify.getMoney()+",赠送:"+payClassify.getGiveMoney());
|
||||
userMoneyDetails.setTitle("支付宝充值金币:" + payClassify.getMoney() + ",赠送:" + payClassify.getGiveMoney());
|
||||
userMoneyDetails.setType(1);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
|
||||
@@ -179,92 +176,15 @@ public class AliPayController {
|
||||
@ApiOperation("支付宝回调")
|
||||
@RequestMapping("/notifyAppYunOS")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String notifyAppYunOS(HttpServletRequest request, HttpServletResponse response){
|
||||
//获取支付宝POST过来反馈信息
|
||||
Map<String,String> params = new HashMap<String,String>();
|
||||
Map requestParams = request.getParameterMap();
|
||||
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
String[] values = (String[]) requestParams.get(name);
|
||||
String valueStr = "";
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
valueStr = (i == values.length - 1) ? valueStr + values[i]
|
||||
: valueStr + values[i] + ",";
|
||||
}
|
||||
//乱码解决,这段代码在出现乱码时使用。
|
||||
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
|
||||
params.put(name, valueStr);
|
||||
}
|
||||
String outTradeNo = params.get("outTradeNo");
|
||||
String code = params.get("code");
|
||||
String key = commonInfoService.findOne(169).getValue();
|
||||
try {
|
||||
boolean flag = PaySignUtil.checkNotifySign(request, key);
|
||||
if(flag){
|
||||
if("1".equals(code)){
|
||||
PayDetails payDetails=payDetailsDao.selectByOrderId(outTradeNo);
|
||||
if(payDetails.getState()==0) {
|
||||
String format = sdf.format(new Date());
|
||||
payDetailsDao.updateState(payDetails.getId(),1,format,null);
|
||||
if(payDetails.getType()==1){
|
||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||
orders.setPayWay(4);
|
||||
orders.setStatus(1);
|
||||
orders.setPayTime(DateUtils.format(new Date()));
|
||||
ordersService.updateById(orders);
|
||||
UserEntity user = userService.selectUserById(orders.getUserId());
|
||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
||||
Map map = inviteService.updateInvite(byUser, format, user.getUserId(), orders.getPayMoney());
|
||||
Object oneUserId = map.get("oneUserId");
|
||||
if(oneUserId!=null){
|
||||
orders.setOneUserId(Long.parseLong(String.valueOf(oneUserId)));
|
||||
orders.setOneMoney(new BigDecimal(String.valueOf(map.get("oneMoney"))));
|
||||
}
|
||||
Object twoUserId = map.get("twoUserId");
|
||||
if(twoUserId!=null){
|
||||
orders.setTwoUserId(Long.parseLong(String.valueOf(twoUserId)));
|
||||
orders.setTwoMoney(new BigDecimal(String.valueOf(map.get("twoMoney"))));
|
||||
}
|
||||
Object sysUserId = map.get("sysUserId");
|
||||
if(sysUserId!=null){
|
||||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
}
|
||||
ordersService.insertOrders(orders);
|
||||
}else{
|
||||
String remark = payDetails.getRemark();
|
||||
PayClassify payClassify = payClassifyService.getById(Long.parseLong(remark));
|
||||
BigDecimal add = payClassify.getMoney().add(payClassify.getGiveMoney());
|
||||
userMoneyService.updateMoney(1,payDetails.getUserId(),add.doubleValue());
|
||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
||||
// ✅
|
||||
userMoneyDetails.setClassify(2);
|
||||
userMoneyDetails.setMoney(add);
|
||||
userMoneyDetails.setUserId(payDetails.getUserId());
|
||||
userMoneyDetails.setContent("支付宝充值金币");
|
||||
userMoneyDetails.setTitle("支付宝充值金币:"+payClassify.getMoney()+",赠送:"+payClassify.getGiveMoney());
|
||||
userMoneyDetails.setType(1);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
|
||||
userMoneyDetails.setMoneyType(2);
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "SUCCESS";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("云购os支付报错!"+e.getMessage());
|
||||
}
|
||||
return null;
|
||||
public String notifyAppYunOS(HttpServletRequest request, HttpServletResponse response) {
|
||||
return "SUCCESS";
|
||||
}
|
||||
|
||||
@Login
|
||||
@ApiOperation("支付宝支付订单")
|
||||
@RequestMapping(value = "/payOrder", method = RequestMethod.POST)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result payOrder(Long orderId,Integer classify) {
|
||||
public Result payOrder(Long orderId, Integer classify) {
|
||||
//通知页面地址
|
||||
CommonInfo one = commonInfoService.findOne(19);
|
||||
String returnUrl = one.getValue() + "/#/pages/task/recharge";
|
||||
@@ -274,17 +194,17 @@ public class AliPayController {
|
||||
log.info("回调地址:" + url);
|
||||
Orders orders = ordersDao.selectById(orderId);
|
||||
PayDetails payDetails = payDetailsDao.selectByOrderId(orders.getOrdersNo());
|
||||
if(payDetails==null){
|
||||
payDetails=new PayDetails();
|
||||
if (payDetails == null) {
|
||||
payDetails = new PayDetails();
|
||||
payDetails.setState(0);
|
||||
payDetails.setCreateTime(sdf.format(new Date()));
|
||||
payDetails.setOrderId(orders.getOrdersNo());
|
||||
payDetails.setUserId(orders.getUserId());
|
||||
payDetails.setMoney(orders.getPayMoney().doubleValue());
|
||||
payDetails.setType(1);
|
||||
if(classify==1){
|
||||
if (classify == 1) {
|
||||
payDetails.setClassify(4);
|
||||
}else{
|
||||
} else {
|
||||
payDetails.setClassify(5);
|
||||
}
|
||||
payDetailsDao.insert(payDetails);
|
||||
@@ -300,7 +220,7 @@ public class AliPayController {
|
||||
@ApiOperation("支付宝支付订单")
|
||||
@RequestMapping(value = "/payMoney", method = RequestMethod.POST)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result payMoney(Long payClassifyId, Integer classify,@RequestAttribute Long userId) {
|
||||
public Result payMoney(Long payClassifyId, Integer classify, @RequestAttribute Long userId) {
|
||||
//通知页面地址
|
||||
CommonInfo one = commonInfoService.findOne(19);
|
||||
String returnUrl = one.getValue() + "/#/pages/task/recharge";
|
||||
@@ -310,15 +230,15 @@ public class AliPayController {
|
||||
log.info("回调地址:" + url);
|
||||
String generalOrder = getGeneralOrder();
|
||||
PayClassify payClassify = payClassifyService.getById(payClassifyId);
|
||||
PayDetails payDetails=new PayDetails();
|
||||
PayDetails payDetails = new PayDetails();
|
||||
payDetails.setState(0);
|
||||
payDetails.setCreateTime(sdf.format(new Date()));
|
||||
payDetails.setOrderId(generalOrder);
|
||||
payDetails.setUserId(userId);
|
||||
payDetails.setMoney(payClassify.getPrice().doubleValue());
|
||||
if(classify==1){
|
||||
if (classify == 1) {
|
||||
payDetails.setClassify(4);
|
||||
}else{
|
||||
} else {
|
||||
payDetails.setClassify(5);
|
||||
}
|
||||
payDetails.setType(2);
|
||||
@@ -368,7 +288,6 @@ public class AliPayController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Result payApp(String name, String generalOrder, Double money) {
|
||||
CommonInfo one = commonInfoService.findOne(19);
|
||||
String url = one.getValue() + "/sqx_fast/app/aliPay/notifyApp";
|
||||
@@ -405,7 +324,7 @@ public class AliPayController {
|
||||
model.setSubject(name);
|
||||
model.setOutTradeNo(generalOrder);
|
||||
model.setTimeoutExpress("30m");
|
||||
model.setTotalAmount(money +"");
|
||||
model.setTotalAmount(money + "");
|
||||
model.setProductCode("QUICK_MSECURITY_PAY");
|
||||
request.setBizModel(model);
|
||||
request.setNotifyUrl(url);
|
||||
@@ -417,7 +336,7 @@ public class AliPayController {
|
||||
return Result.error("获取订单失败!");
|
||||
}
|
||||
return Result.success().put("data", result);
|
||||
} else if("2".equals(payWay.getValue())){
|
||||
} else if ("2".equals(payWay.getValue())) {
|
||||
//实例化客户端
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2");
|
||||
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
|
||||
@@ -439,13 +358,6 @@ public class AliPayController {
|
||||
return Result.error("获取订单失败!");
|
||||
}
|
||||
return Result.success().put("data", result);
|
||||
}else{
|
||||
url=one.getValue()+"/sqx_fast/app/aliPay/notifyAppYunOS";
|
||||
log.info("回调地址:"+url);
|
||||
String mchId = commonInfoService.findOne(168).getValue();
|
||||
String key = commonInfoService.findOne(169).getValue();
|
||||
result = AliPay.appPay(generalOrder, String.valueOf(money), mchId, name ,null, url, null, null, null, null,key);
|
||||
return Result.success().put("data", result);
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
@@ -491,7 +403,7 @@ public class AliPayController {
|
||||
alipayRequest.setReturnUrl(returnUrl); //线上通知页面地址
|
||||
String result = alipayClient.pageExecute(alipayRequest).getBody();
|
||||
return Result.success().put("data", result);
|
||||
} else if ("2".equals(payWay.getValue())){
|
||||
} else if ("2".equals(payWay.getValue())) {
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2");
|
||||
AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();
|
||||
JSONObject order = new JSONObject();
|
||||
@@ -507,13 +419,6 @@ public class AliPayController {
|
||||
alipayRequest.setReturnUrl(returnUrl);
|
||||
String form = alipayClient.pageExecute(alipayRequest).getBody();
|
||||
return Result.success().put("data", form);
|
||||
}else{
|
||||
url=one.getValue()+"/sqx_fast/app/aliPay/notifyAppYunOS";
|
||||
log.info("回调地址:"+url);
|
||||
String mchId = commonInfoService.findOne(168).getValue();
|
||||
String key = commonInfoService.findOne(169).getValue();
|
||||
AliPayH5Biz aliPayH5Biz = AliPay.h5Pay(generalOrder, String.valueOf(money), mchId, name, null, url, returnUrl, null, null, null,null,key);
|
||||
return Result.success().put("data", aliPayH5Biz.getForm());
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("CreatPayOrderForH5", e);
|
||||
@@ -522,5 +427,4 @@ public class AliPayController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -361,18 +361,22 @@ public class WuyouController {
|
||||
}
|
||||
ordersService.updateById(order);
|
||||
ordersService.insertOrders(order);
|
||||
InviteAchievement inviteAchievement = inviteAchievementService.getByUserId(user.getUserId());
|
||||
if (inviteAchievement == null) {
|
||||
inviteAchievement = new InviteAchievement();
|
||||
inviteAchievement.setState(0);
|
||||
inviteAchievement.setCount(1);
|
||||
inviteAchievement.setCreateTime(DateUtil.date());
|
||||
inviteAchievement.setUserId(user.getUserId());
|
||||
inviteAchievement.setSourceUserId(byUser.getUserId());
|
||||
inviteAchievementService.insertNotExists(inviteAchievement);
|
||||
} else {
|
||||
inviteAchievementService.incrCount(inviteAchievement.getId(), 1);
|
||||
|
||||
if (byUser != null) {
|
||||
InviteAchievement inviteAchievement = inviteAchievementService.getByUserId(user.getUserId());
|
||||
if (inviteAchievement == null) {
|
||||
inviteAchievement = new InviteAchievement();
|
||||
inviteAchievement.setState(0);
|
||||
inviteAchievement.setCount(1);
|
||||
inviteAchievement.setCreateTime(DateUtil.date());
|
||||
inviteAchievement.setUserId(user.getUserId());
|
||||
inviteAchievement.setSourceUserId(byUser.getUserId());
|
||||
inviteAchievementService.insertNotExists(inviteAchievement);
|
||||
} else {
|
||||
inviteAchievementService.incrCount(inviteAchievement.getId(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadUtil.execAsync(() -> {
|
||||
activities(user, byUser);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sqx.modules.pay.wuyou;
|
||||
|
||||
import com.alibaba.druid.util.Utils;
|
||||
import com.sqx.modules.utils.MD5Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -23,7 +23,7 @@ public class Encrypt {
|
||||
sb.append("key=").append(APP_SECRET);
|
||||
String signStr = sb.toString();
|
||||
System.out.println("signStr: " + signStr);
|
||||
return Utils.md5(signStr).toUpperCase();
|
||||
return MD5Util.encodeByMD5(signStr).toUpperCase();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -97,7 +97,7 @@ public class RedisServiceImpl implements RedisService {
|
||||
expireTime = jsonObject.getLong("expireTime");
|
||||
}
|
||||
|
||||
if ((StrUtil.isNotBlank(permanentlyFreeWatch) && redisUtils.isExpiredSet(freeWatchKey)) || (StrUtil.isNotBlank(permanentlyFreeWatch) && DateUtil.current() >= expireTime)) {
|
||||
if ((StrUtil.isNotBlank(permanentlyFreeWatch) && redisUtils.isExpiredSet(freeWatchKey)) || (StrUtil.isNotBlank(permanentlyFreeWatch) && DateUtil.current(false) >= expireTime)) {
|
||||
if (StrUtil.isBlank(permanentlyFreeWatch)) {
|
||||
return null;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class RedisServiceImpl implements RedisService {
|
||||
redisUtils.set(watchKey, jsonObject.toJSONString(), expire);
|
||||
return false;
|
||||
}else {
|
||||
return DateUtil.current() > expireTime;
|
||||
return DateUtil.current(false) > expireTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class RedisServiceImpl implements RedisService {
|
||||
Integer expireTime = jsonObject.getInteger("expireTime");
|
||||
Long second = jsonObject.getLong("second");
|
||||
|
||||
return expireTime == -1 ? second : expireTime > DateUtil.current() ? expireTime - DateUtil.current() : 0L;
|
||||
return expireTime == -1 ? second : expireTime > DateUtil.current(false) ? expireTime - DateUtil.current(false) : 0L;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* oauth2过滤器
|
||||
*
|
||||
*/
|
||||
public class OAuth2Filter extends AuthenticatingFilter {
|
||||
|
||||
@@ -32,7 +31,7 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
||||
//获取请求token
|
||||
String token = getRequestToken((HttpServletRequest) request);
|
||||
|
||||
if(StringUtils.isBlank(token)){
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,7 +40,7 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
||||
|
||||
@Override
|
||||
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
|
||||
if(((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())){
|
||||
if (((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -52,7 +51,7 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
||||
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
|
||||
//获取请求token,如果token不存在,直接返回401
|
||||
String token = getRequestToken((HttpServletRequest) request);
|
||||
if(StringUtils.isBlank(token)){
|
||||
if (StringUtils.isBlank(token)) {
|
||||
HttpServletResponse httpResponse = (HttpServletResponse) response;
|
||||
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin());
|
||||
@@ -63,17 +62,8 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
||||
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
return executeLogin(request, response);
|
||||
}catch (AbstractMethodError e){
|
||||
if (e.getMessage().contains("sessionCreated")) {
|
||||
logger.error(e.getMessage());
|
||||
return false;
|
||||
}else {
|
||||
logger.error(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return executeLogin(request, response);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,12 +89,12 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
||||
/**
|
||||
* 获取请求的token
|
||||
*/
|
||||
private String getRequestToken(HttpServletRequest httpRequest){
|
||||
private String getRequestToken(HttpServletRequest httpRequest) {
|
||||
//从header中获取token
|
||||
String token = httpRequest.getHeader("token");
|
||||
|
||||
//如果header中不存在token,则从参数中获取token
|
||||
if(StringUtils.isBlank(token)){
|
||||
if (StringUtils.isBlank(token)) {
|
||||
token = httpRequest.getParameter("token");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user