Commit 42612a5f by 杨树贤

修复bug

parent 57942998
......@@ -3,6 +3,7 @@
namespace App\Jobs\Timer;
use App\Models\ExchangeSetting;
use Carbon\Carbon;
use Common\Model\RedisModel;
use Hhxsv5\LaravelS\Swoole\Timer\CronJob;
......@@ -11,22 +12,24 @@ use Swoole\Coroutine;
class ResetExchangeSettingsCronJob extends CronJob
{
// protected $i = 0;
// protected $i = 0;
// !!! 定时任务的`interval`和`isImmediate`有两种配置方式(二选一):一是重载对应的方法,二是注册定时任务时传入参数。
// --- 重载对应的方法来返回配置:开始
public function interval()
{
return 1000;// 每1秒运行一次
}
public function isImmediate()
{
return true;// 是否立即执行第一次,false则等待间隔时间后执行第一次
}
// --- 重载对应的方法来返回配置:结束
public function run()
{
//判断是否是10点,如果是10点就进行重置任务
$time = Carbon::create(null,null,null,14,30);
$time = Carbon::create(null, null, null, 15, 00);
$time = $time->timestamp;
$now = Carbon::now()->timestamp;
if ($time === $now) {
......@@ -35,18 +38,19 @@ class ResetExchangeSettingsCronJob extends CronJob
}
}
private function reset(){
private function reset()
{
Log::info("开始重置...");
//重置商品可兑换限额
//先从redis缓存里面去取需要的数据
$redis = new RedisModel();
$settings = $redis->hgetall('ic_exchange_settings');
$settings = ExchangeSetting::where('status', 1)
->get()->toArray();
//获取到所有配置项之后,就要根据配置项里面的stock字段更新对应的列表
//列表形式为ic_exchange_setting_{$id},然后这个键是list类型,里面简单存1就好
try {
foreach ($settings as $key => $setting) {
$setting = json_decode($setting, true);
$id = $setting['id'];
//先去删除原有的
......
12787
\ No newline at end of file
13457
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment