Commit f7f2c0c3 by 叶明星

兼容提现名额为0的情况,优化自动刷新名额

parent 8b51d701
Showing with 17 additions and 3 deletions
...@@ -32,10 +32,21 @@ class ResetExchangeSettingsCronJob extends CronJob ...@@ -32,10 +32,21 @@ class ResetExchangeSettingsCronJob extends CronJob
$time = Carbon::create(null, null, null, 10); $time = Carbon::create(null, null, null, 10);
$time = $time->timestamp; $time = $time->timestamp;
$now = Carbon::now()->timestamp; $now = Carbon::now()->timestamp;
if ($time === $now) {
//判断是否进行名额刷新
if($now >= $time){//当前时间大于10点
//判断今天是否有刷新名额记录
$Redis = new RedisModel();
$day = date('Ymd');
$findCache = $Redis->get($day);
if($findCache)//已经刷新
return true;
Log::info("进行定时检测重置任务..."); Log::info("进行定时检测重置任务...");
$this->reset(); $this->reset();
} }
return true;
} }
private function reset() private function reset()
...@@ -56,14 +67,17 @@ class ResetExchangeSettingsCronJob extends CronJob ...@@ -56,14 +67,17 @@ class ResetExchangeSettingsCronJob extends CronJob
//先去删除原有的 //先去删除原有的
$redis->del('ic_exchange_settings_' . $id); $redis->del('ic_exchange_settings_' . $id);
$data = array_fill(0, $setting['stock'], 1); $data = array_fill(0, $setting['stock'], 1);
if(empty($data))//兼容名额为0的情况
continue;
$redis->lpush('ic_exchange_settings_' . $id, $data); $redis->lpush('ic_exchange_settings_' . $id, $data);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
Log::info("重置失败,原因是" . $e); Log::info("重置失败,原因是" . $e);
return; return;
} }
$day = date('Ymd');
$redis->set($day,1);
$redis->expire($day, 60*60*24);//24小时后过期掉
Log::info("重置完成"); Log::info("重置完成");
} }
......
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