| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- declare (strict_types = 1);
- namespace app\api\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\facade\Db;
- /**
- * 结算今日奖金 by wes
- * Class GetUserTeamMoney
- * @package app\api\command
- */
- class GetUserTeamMoney extends Command
- {
- protected function configure()
- {
- // 获取用户今日奖金
- $this->setName('get_user_team_money')
- ->setDescription('the get_user_team_money command');
- }
- protected function execute(Input $input, Output $output)
- {
- Db::startTrans();
- try {
- $list = Db::name('user')->where('today_money', '>', 0)->select();
- foreach ($list as $key=>$val){
- edit_user_money(6, $val['id'], $val['today_money']);
- // 累计奖金
- Db::name('user')->where('id', $val['id'])->inc('todayaward_money', floatval($val['today_money']))->update();
- }
- Db::name('user')->where('today_money', '>', 0)->save(['today_money'=>0]);
- Db::commit();
- }catch (\Exception $e){
- Db::rollback();
- $output->writeln('key'.$e->getMessage());
- return 22;
- }
- return 22;
- }
- }
|