123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- /**
- * Created by PhpStorm.
- * User: tandunzhao
- * Date: 2017/11/20
- * Time: 下午5:26
- */
- namespace App\Console\Commands;
- use App\Modules\Trade\Services\OrderService;
- use DB;
- use Illuminate\Console\Command;
- use Log;
- class ChargeTemplateStat extends Command
- {
- /**
- * 执行命令 php artisan bill_task
- *
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'charge_template_stat';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '充值模板数据统计';
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $book_id = '1148';
- $distribution_channel_id = 123;
- $book_name = '婚情告急:总裁请别撩';
- $users = DB::table('user_first_visit_pay_page')->limit(12000)->get();
- foreach ($users as $userItem) {
- $uid = $userItem->uid;
- $created_at = $userItem->created_at;
- $created_at_timestamp = strtotime($created_at);
- $params = ['uid' => $uid, 'begin_time' => $created_at, 'end_time' => date('Y-m-d H:i:s', $created_at_timestamp + 86400)];
- $recharge_amount_in_24h = OrderService::getAmount($params);
- $params = ['uid' => $uid, 'begin_time' => $created_at, 'end_time' => date('Y-m-d H:i:s', $created_at_timestamp + 86400 * 3)];
- $recharge_amount_in_72h = OrderService::getAmount($params);
- $params = ['uid' => $uid, 'begin_time' => $created_at, 'end_time' => date('Y-m-d H:i:s', $created_at_timestamp + 86400 * 7)];
- $recharge_amount_in_7d = OrderService::getAmount($params);
- $params = ['uid' => $uid, 'begin_time' => $created_at, 'end_time' => date('Y-m-d H:i:s', $created_at_timestamp + 86400 * 30)];
- $recharge_amount_in_30d = OrderService::getAmount($params);
- $params = ['uid' => $uid];
- $recharge_amount = OrderService::getAmount($params);
- $template_type = $userItem->template_type;
- $data = ['uid' => $uid, 'book_id' => $book_id, 'book_name' => $book_name, 'template_tye' => $template_type,
- 'distribution_channel_id' => $distribution_channel_id, 'recharge_amount_in_24h' => $recharge_amount_in_24h,
- 'recharge_amount_in_72h' => $recharge_amount_in_72h, 'recharge_amount_in_7d' => $recharge_amount_in_7d,
- 'recharge_amount_in_30d' => $recharge_amount_in_30d, 'recharge_amount' => $recharge_amount,
- 'created_at' => $created_at];
- DB::table('charge_template_stat')->insert($data);
- }
- DB::update("UPDATE charge_template_stat a join users b on a.uid=b.id set a.distribution_channel_id=b.distribution_channel_id");
- }
- }
|