Files
juipphp/script/test.php

115 lines
3.3 KiB
PHP
Raw Normal View History

2020-10-05 13:43:53 +08:00
<?php
$is_script = 1;
include '../index.php';
2020-10-11 19:23:42 +08:00
use app\api\model\Logs;
2020-10-05 13:43:53 +08:00
use app\api\model\User;
2020-10-11 19:23:42 +08:00
$test = new Logs();
2020-10-05 13:43:53 +08:00
$list = $test->fetchAll();
2020-10-11 19:23:42 +08:00
//不应该存在的时间点
$not_exit_time = ['23','00','01','02','03','04','05','06','07'];
2020-10-05 13:43:53 +08:00
$user_manager = [];
$user_product = [];
$user_vip_price = [];
$user_contact = [];
$export_info = [];
foreach ($list as $info) {
switch ($info['operation']) {
case '点击客户管理':
$user_manager[] = $info;
break;
case '点击客户信息产品账号':
$user_product[] = $info;
break;
case '点击客户信息会员价':
$user_vip_price[] = $info;
break;
case '点击客户更多联系方式':
$user_contact[] = $info;
break;
case '点击导出所有客户信息':
$export_info[] = $info;
break;
}
}
$recore_num = 1;
$start_time = "2020-5-13 15:42:27";
2020-10-11 19:23:42 +08:00
$user_click_time = [];
2020-10-05 13:43:53 +08:00
//点击用户管理
foreach ($user_manager as $v) {
2020-10-11 19:23:42 +08:00
// $userlist = $user->field('`LoginCode`')->where(['CreateTime'=>['<',$start_time]])->order('id')->limit('50')->fetchAll();
// $user_click_time[] = $start_time;
// $data['info'] = json_encode($userlist);
2020-10-05 13:43:53 +08:00
$data['create_time'] = $start_time;
$test->where(['id' => $v['id']])->update($data);
2020-10-11 19:23:42 +08:00
$start_time = formatTime($start_time,10000,30000);
2020-10-05 13:43:53 +08:00
echo '更新第'.$recore_num++.'条数据'."\r";
}
2020-10-11 19:23:42 +08:00
// 点击导出所有客户信息
$start_time = "2020-5-13 15:45:37";
foreach($export_info as $v){
// $data['info'] = '本次点击时间之前所有客户数据';
2020-10-05 13:43:53 +08:00
$data['create_time'] = $start_time;
$test->where(['id' => $v['id']])->update($data);
2020-10-11 19:23:42 +08:00
$start_time = formatTime($start_time,20000,43200);
2020-10-05 13:43:53 +08:00
echo '更新第'.$recore_num++.'条数据'."\r";
}
2020-10-11 19:23:42 +08:00
2020-10-05 13:43:53 +08:00
//点击客户信息产品账号
$k = 0;
$start_time = "2020-5-13 15:42:35";
2020-10-11 19:23:42 +08:00
//给出客户信息列表
2020-10-05 13:43:53 +08:00
foreach ($user_product as $v) {
2020-10-11 19:23:42 +08:00
// $data['info'] = $user_click_list[$k++]['LoginCode'];
2020-10-05 13:43:53 +08:00
$data['create_time'] = $start_time;
$test->where(['id' => $v['id']])->update($data);
2020-10-11 19:23:42 +08:00
$start_time = formatTime($start_time,100,180);
2020-10-05 13:43:53 +08:00
echo '更新第'.$recore_num++.'条数据'."\r";
}
//点击客户信息会员价
$k = 0;
$start_time = "2020-5-13 15:42:57";
foreach ($user_vip_price as $v) {
2020-10-11 19:23:42 +08:00
// $data['info'] = $user_click_list[$k++]['LoginCode'];
2020-10-05 13:43:53 +08:00
$data['create_time'] = $start_time;
$test->where(['id' => $v['id']])->update($data);
2020-10-11 19:23:42 +08:00
$start_time = formatTime($start_time,100,180);
2020-10-05 13:43:53 +08:00
echo '更新第'.$recore_num++.'条数据'."\r";
}
//点击客户更多联系方式
$k = 0;
$start_time = "2020-5-13 15:43:08";
foreach ($user_contact as $v) {
2020-10-11 19:23:42 +08:00
// $data['info'] = $user_click_list[$k++]['LoginCode'];
2020-10-05 13:43:53 +08:00
$data['create_time'] = $start_time;
$test->where(['id' => $v['id']])->update($data);
2020-10-11 19:23:42 +08:00
$start_time = formatTime($start_time,100,180);
2020-10-05 13:43:53 +08:00
echo '更新第'.$recore_num++.'条数据'."\r";
}
2020-10-11 19:23:42 +08:00
function formatTime($time,$rand1,$rand2)
{
global $not_exit_time;
$c_time = date('Y-m-d H:i:s',strtotime($time) + rand($rand1,$rand2));
$start_time = explode(':',explode(' ',$c_time)[1])[0];
if(!in_array($start_time,$not_exit_time)){
return $c_time;
} else {
return formatTime($c_time,$rand1,$rand2);
}
2020-10-05 13:43:53 +08:00
}