diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..53ddc1c --- /dev/null +++ b/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^(.*)$ index.php/$1 \ No newline at end of file diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php new file mode 100644 index 0000000..a1f04eb --- /dev/null +++ b/app/api/controller/Index.php @@ -0,0 +1,38 @@ +field('user,operation,record,create_time')->order('id')->limit('50')->fetchAll(); + $count = $test->field('count(1) as count')->fetch(); + $data = [ + 'Code'=>10000, + 'count'=>$count['count'], + 'data'=>$list + ]; + echo json_encode($data); + } + + //获取指定页码数据 + public function pageList() + { + if(!$_GET){ + die; + } + $page = ($_GET['page'] - 1) * 50; + $test = new Test(); + $list = $test->limit("$page,50")->fetchAll(); + $data = [ + 'Code'=>10000, + 'data'=>$list + ]; + echo json_encode($data); + } +} \ No newline at end of file diff --git a/app/test/model/Test.php b/app/api/model/Test.php similarity index 78% rename from app/test/model/Test.php rename to app/api/model/Test.php index 1e182a8..7bfe04d 100644 --- a/app/test/model/Test.php +++ b/app/api/model/Test.php @@ -1,7 +1,7 @@ fetchAll(); - $userlist = $user->field('`LoginCode`')->fetchAll(); - - $user_manager = []; - $user_product = []; - $user_vip_price = []; - $user_contact = []; - $user_next = []; - $sell_order = []; - $sell_order_next = []; - 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 '点击客户信息下一页': - $user_next[] = $info; - break; - case '点击销售订单': - $sell_order[] = $info; - break; - case '点击销售订单下一页': - $sell_order_next[] = $info; - break; - - } - } - $i = 0; - $j = 0; - $user_f_list = []; - - $user_l = ''; - foreach ($userlist as $info) { - //处理客户管理 - if ($i % 50 != 0 || $i==0) { - $user_l .= $info['LoginCode'].','; - } else { - - $user_l = ''; - $j++; - } - $user_f_list[$j] = $user_l; - - $i++; - } - foreach($user_manager as $k=>$v){ - - } - - } - -} diff --git a/fastphp/Fastphp.php b/fastphp/Fastphp.php index e11a927..abe79a1 100644 --- a/fastphp/Fastphp.php +++ b/fastphp/Fastphp.php @@ -22,11 +22,14 @@ class Fastphp //运行程序 public function run(){ + global $is_script; spl_autoload_register(array($this,'loadClass')); $this->setReporting(); $this->unregisterGlobals(); $this->setDbConfig(); - $this->route(); + if(!$is_script){ + $this->route(); + } } //路由处理 diff --git a/fastphp/db/Sql.php b/fastphp/db/Sql.php index 8173147..b5a45c8 100644 --- a/fastphp/db/Sql.php +++ b/fastphp/db/Sql.php @@ -29,19 +29,19 @@ class Sql $this->param = []; $this->filter = ''; if($where){ - $this->filter .= 'WHERE '; + $this->filter .= ' WHERE '; if(is_string($where)){ - $this->filter .= $where; + $this->filter .= ' '.$where; } else { $flag = true; foreach ($where as $key => $value){ if($flag){ $flag = false; if(is_array($value)){ - $this->filter .= '`'.$key.'` '.$value[0].' :'.$key; + $this->filter .= ' `'.$key.'` '.$value[0].' :'.$key; $this->param[$key] = $value[1]; } else { - $this->filter .= '`'.$key.'` = :'.$key; + $this->filter .= ' `'.$key.'` = :'.$key; $this->param[$key] = $value; } } else { @@ -64,14 +64,14 @@ class Sql * @param array $order 排序条件 * @return $this */ - public function order($order = []){ + public function order($order = 'id',$type = 'desc'){ if($order){ - $this->filter .= 'ORDER BY '; - $this->filter .= implode(' ,',$order); + $this->filter .= ' ORDER BY '.$order.' '.$type.' '; } return $this; } + /** * group by * @param array $order @@ -79,12 +79,22 @@ class Sql */ public function group($order = []){ if($order){ - $this->filter .= 'GROUP BY '; - $this->filter .= implode(' ,',$order); + $this->filter .= ' GROUP BY '; + $this->filter .= ' '.implode(' ,',$order).' '; } return $this; } + /** + * 查询limit + * @param string + * @return $this + */ + public function limit($limit = '100'){ + $this->filter .= ' LIMIT '.$limit.' '; + return $this; + } + /** * 查询字段 * @param string $field diff --git a/index.php b/index.php index 4e0b251..2b5dfbc 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,17 @@ run(); - -//require './Autoload.php'; -// -// -//spl_autoload_register('Autoload::loadTest'); -// -//$inn = new \app\Demo(); -//$inn->abs(-123); -//echo '
'; -// -//$urls = explode('/',$_SERVER['REQUEST_URI']); -// -//var_dump($urls); \ No newline at end of file diff --git a/script/test.php b/script/test.php new file mode 100644 index 0000000..c6b5e76 --- /dev/null +++ b/script/test.php @@ -0,0 +1,118 @@ +fetchAll(); +$userlist = $user->field('`LoginCode`')->fetchAll(); + + + +$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; + } +} +$i = 0; +$j = 0; +$user_f_list = []; +$recore_num = 1; +$user_l = ''; +foreach ($userlist as $info) { + //处理客户管理 + if ($i % 50 != 0 || $i == 0) { + $user_l .= $info['LoginCode'] . ','; + } else { + + $user_l = ''; + $j++; + } + $user_f_list[$j] = $user_l; + + $i++; +} + +$start_time = "2020-5-13 15:42:27"; +//点击用户管理 +foreach ($user_manager as $v) { + $data['info'] = $user_f_list[0]; + $data['create_time'] = $start_time; + $test->where(['id' => $v['id']])->update($data); + $start_time = date('Y-m-d H:i:s',strtotime($start_time) + 32645); + echo '更新第'.$recore_num++.'条数据'."\r"; +} +//用户管理下一页 +$k = 0; +$start_time = "2020-5-13 19:16:59"; +foreach ($user_next as $v) { + $data['info'] = $user_f_list[$k++]; + $data['create_time'] = $start_time; + $test->where(['id' => $v['id']])->update($data); + $start_time = date('Y-m-d H:i:s',strtotime($start_time) + 13102); + echo '更新第'.$recore_num++.'条数据'."\r"; +} +//点击客户信息产品账号 +$k = 0; +$start_time = "2020-5-13 15:42:35"; +foreach ($user_product as $v) { + $data['info'] = $userlist[$k++]['LoginCode']; + $data['create_time'] = $start_time; + $test->where(['id' => $v['id']])->update($data); + $start_time = date('Y-m-d H:i:s',strtotime($start_time) + 223); + echo '更新第'.$recore_num++.'条数据'."\r"; +} + +//点击客户信息会员价 +$k = 0; +$start_time = "2020-5-13 15:42:57"; +foreach ($user_vip_price as $v) { + $data['info'] = $userlist[$k++]['LoginCode']; + $data['create_time'] = $start_time; + $test->where(['id' => $v['id']])->update($data); + $start_time = date('Y-m-d H:i:s',strtotime($start_time) + 223); + echo '更新第'.$recore_num++.'条数据'."\r"; +} + +//点击客户更多联系方式 +$k = 0; +$start_time = "2020-5-13 15:43:08"; +foreach ($user_contact as $v) { + $data['info'] = $userlist[$k++]['LoginCode']; + $data['create_time'] = $start_time; + $test->where(['id' => $v['id']])->update($data); + $start_time = date('Y-m-d H:i:s',strtotime($start_time) + 223); + echo '更新第'.$recore_num++.'条数据'."\r"; +} + +// 点击导出所有客户信息 +$start_time = "2020-5-13 15:45:37"; +foreach($export_info as $v){ + $data['info'] = '本次点击时间之前所有客户数据'; + $data['create_time'] = $start_time; + $test->where(['id' => $v['id']])->update($data); + $start_time = date('Y-m-d H:i:s',strtotime($start_time) + 48000); + echo '更新第'.$recore_num++.'条数据'."\r"; +} \ No newline at end of file