api接口

This commit is contained in:
wanyongkang
2020-10-05 13:43:53 +08:00
parent a331e3f1d5
commit ce067b91dc
9 changed files with 198 additions and 103 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace app\api\controller;
use app\api\model\Test;
use app\api\model\User;
class Index
{
public function index()
{
$test = new Test();
$list = $test->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);
}
}

View File

@@ -1,7 +1,7 @@
<?php
namespace app\test\model;
namespace app\api\model;
use fastphp\base\Model;

View File

@@ -1,7 +1,7 @@
<?php
namespace app\test\model;
namespace app\api\model;
use fastphp\base\Model;

View File

@@ -1,74 +0,0 @@
<?php
namespace app\test\controller;
use app\test\model\Test;
use app\test\model\User;
class Index
{
public function index()
{
$test = new Test();
$user = new User();
$list = $test->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){
}
}
}