Commit 2e21ca92 by 杨树贤

修复定时重置商品可兑换限额的bug

parent a5739cf1
...@@ -19,7 +19,7 @@ class ResetExchangeSetting extends Command ...@@ -19,7 +19,7 @@ class ResetExchangeSetting extends Command
public function handle() public function handle()
{ {
// 在命令行打印一行信息 // 在命令行打印一行信息
$this->info("开始查找..."); Log::info("开始重置...");
//重置商品可兑换限额 //重置商品可兑换限额
//先从redis缓存里面去取需要的数据 //先从redis缓存里面去取需要的数据
...@@ -27,15 +27,22 @@ class ResetExchangeSetting extends Command ...@@ -27,15 +27,22 @@ class ResetExchangeSetting extends Command
$settings = $redis->hgetall('ic_exchange_settings'); $settings = $redis->hgetall('ic_exchange_settings');
//获取到所有配置项之后,就要根据配置项里面的stock字段更新对应的列表 //获取到所有配置项之后,就要根据配置项里面的stock字段更新对应的列表
//列表形式为ic_exchange_setting_{$id},然后这个键是list类型,里面简单存1就好 //列表形式为ic_exchange_setting_{$id},然后这个键是list类型,里面简单存1就好
foreach ($settings as $key => $setting) { try {
$setting = json_decode($setting, true); foreach ($settings as $key => $setting) {
$id = $setting['id']; $setting = json_decode($setting, true);
//先去删除原有的 $id = $setting['id'];
$redis->del('ic_exchange_settings_' . $id);
$data = array_fill(0, $setting['stock'], 1); //先去删除原有的
$redis->lpush('ic_exchange_settings_' . $id, $data); $redis->del('ic_exchange_settings_' . $id);
$data = array_fill(0, $setting['stock'], 1);
$redis->lpush('ic_exchange_settings_' . $id, $data);
}
} catch (\Exception $e) {
Log::info("重置失败,原因是" . $e);
return;
} }
$this->info("执行成功!"); Log::info("重置完成");
} }
} }
\ No newline at end of file
478 517
\ No newline at end of file \ 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