setName('dayUserValue') ->addArgument('dayValue', Argument::OPTIONAL, 'php think menu [1] / [2]') ->setDescription('用户每日兑换率生成'); } protected function execute(Input $input, Output $output) { $config = systemConfig('brand_config'); $config_start = systemConfig('brand_config') ?? 1; $config_growth = systemConfig('brand_growth'); if (empty($config)) { echo '无配置'; exit; } $resConfig = []; foreach (explode('/', $config) as $k => $v) { $newConfig = explode(',', $v); $resConfig[$k]['start'] = $newConfig[0]; $resConfig[$k]['end'] = $newConfig[1]; $resConfig[$k]['bili'] = $newConfig[2]; } try { $growth_rate = 0; $days = $config_start + 1; foreach ($resConfig as $rk => $rv) { if ($days >= $rv['start'] && $rv['bili'] > 0) { if ($config_growth) { $growth_rate = $rv['bili']; } else { $growth_rate = bcadd($v['growth_rate'], $rv['bili'], 2); } } } $user = userModel::getDB()->where('status', 1)->select()->toArray(); foreach ($user as $k => $v) { userModel::getDB()->where('uid', $v['uid'])->update(['super_days' => $days, 'growth_rate' => $growth_rate]); } $system_1 = SystemConfigValue::getDB()->where('config_key', 'brand_start')->find(); $system_1->value = $system_1->value + 1; $system_1->save(); $system_2 = SystemConfigValue::getDB()->where('config_key', 'brand_growth')->find(); $system_2->value = $growth_rate; $system_2->save(); } catch (\Exception $e) { print_r($e->getMessage()); } echo 'ok'; } }