| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- declare (strict_types=1);
- namespace app\api\command;
- use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\AddShortUrlResponseBody\data;
- use app\common\model\PaymentModel;
- use app\common\model\ShopGoodsModel;
- use app\common\model\ShopOrderGoodsModel as OrderGoods;
- use app\common\model\ShopOrderModel;
- use app\common\model\UserModel;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\facade\Db;
- class OnedayUserDataupdate extends Command
- {
- protected function configure()
- {
- // 每天刷新用户一些用户信息
- $this->setName('oneday_user_dataupdate')
- ->setDescription('the oneday_user_dataupdate command');
- }
- protected function execute(Input $input, Output $output)
- {
- Db::startTrans();
- try {
- $this->updateUserData();
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- $output->writeln('error:' . $e->getMessage());
- }
- return 22;
- }
- public function updateUserData()
- {
- // 更新用户所有昨日今日数据
- $list = Db::name('money_log')->where('type', 6)->whereDay('create_at', 'yesterday')->field('uid')->group('uid')->select();
- foreach ($list as $key => $val) {
- $money = Db::name('money_log')->where('type', 6)->whereDay('create_at', 'yesterday')->where('uid', $val['uid'])->sum('money');
- Db::name('user')->where('id', $val['uid'])->save([
- 'yesterday_money' => $money
- ]);
- }
- Db::name('user')->where('today_box', '>', 0)->save(['today_box' => 0]);
- Db::name('user')->where('today_team_box', '>', 0)->save(['today_team_box' => 0]);
- // 开启下一期 福袋预约
- $max_id = Db::name('box')->where('status', 1)->max('id');
- $info = Db::name('box')->where('id', $max_id)->find();
- if ($info) {
- Db::name('box')->where('status', 1)->save([
- 'status' => 2
- ]);
- $count = $info['buy_most'] * (1 + env('boxsetting.ONCEDAY_ADD_SCALE') / 100);
- Db::name('box')->insert([
- 'buy_most' => intval($count / 10) * 10,
- 'once_buy' => $info['once_buy'],
- 'qi_count' => $info['qi_count'] + 1,
- 'time_set' => $info['time_set'],
- 'box_img' => $info['box_img'],
- 'box_title' => $info['box_title'],
- 'create_time' => sr_getcurtime(time()),
- 'appoint_day' => sr_getcurtime(time(), 'Y-m-d')
- ]);
- }
- }
- }
|