1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * Created by: PhpStorm
- * User: lytian
- * Date: 2019/10/25
- * Time: 19:52
- */
- namespace app\admin\command;
- use app\common\library\Redis;
- use app\main\constants\CacheConstants;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Option;
- use think\console\Output;
- use think\Request;
- class UpdateTodayReferralFollow extends Command
- {
- public function configure()
- {
- $this->setName('UpdateTodayReferralFollow')
- ->setDescription('更新今日的推广链接的关注');
- }
- public function execute(Input $input, Output $output)
- {
- Request::instance()->module('admin');
- $time = strtotime(date("Ymd"));
- $rows = model("Referral")->field("id")->where('createtime', '>=', $time)->select();
- if ($rows) {
- foreach ($rows as $v) {
- $uv = (int)Redis::instance()->get(CacheConstants::getReadOfReferralIdKey($v['id']));
- $follow = (int)Redis::instance()->get(CacheConstants::getSubscribeOfReferralIdKey($v['id']));
- $net_follow_num = (int)Redis::instance()->get(CacheConstants::getSubscribeOfPureReferralIdKey($v['id']));
- if ($uv || $follow || $net_follow_num) {
- $updateData = [
- 'uv' => $uv,
- 'follow' => $follow,
- 'net_follow_num' => $net_follow_num,
- ];
- if (model("Referral")->update($updateData, ['id' => $v['id']])) {
- echo "ID: {$v['id']} 刷入数据: ".json_encode($updateData)." 输入成功" .PHP_EOL;
- } else {
- echo "ID: {$v['id']} 刷入数据: ".json_encode($updateData)." 输入失败" .PHP_EOL;
- }
- }
- }
- }
- $output->write("脚本执行 结束");
- }
- }
|