wangtengyu
2018-12-03 5e00a4a4adb70df30defacbd4eaa0616ec7474b1
获取用户列表 and 用户订单 接口
2 files added
70 ■■■■■ changed files
api/init_db.php 13 ●●●●● patch | view | raw | blame | history
api/userApi.php 57 ●●●●● patch | view | raw | blame | history
api/init_db.php
New file
@@ -0,0 +1,13 @@
<?php
error_reporting(E_ALL);
/* 初始化数据库类 */
require('../data/config.php');
require('../includes/cls_mysql.php');
require('../includes/cls_session.php');
$db = new cls_mysql($db_host, $db_user, $db_pass, $db_name);
$db_host = $db_user = $db_pass = $db_name = NULL;
?>
api/userApi.php
New file
@@ -0,0 +1,57 @@
<?php
/**
 * 获取用户数据相关 Api
 *  王腾宇
 */
define('IN_ECS', true);
require('./init_db.php');
require('./common/interface.func.php');
if($_SERVER['REQUEST_METHOD'] != 'POST'){
    http_response_code(405);
} else {
    $retData=checkParam($_GET);
    switch ($retData["rspCode"]){
        case "e00000":
            $userApi = new UserApi();
            switch (getUrl($_SERVER['REQUEST_URI']))
            {
                case "getUserList":
                    $retData["rspData"] = $userApi->getUserList($retData["repData"]);
                    break;
                case "getUserOrderList":
                    $retData["rspData"] = $userApi->getUserOrderList($retData["repData"]);
                    break;
                default: http_response_code(404);
            }
            break;
        case "e00001":
            $retData["rspMsg"]="接入平台不存在";
            break;
        case "e00002":
            $retData["rspMsg"]="鉴权失败";
            break;
    }
    exit(json_encode($retData,JSON_UNESCAPED_UNICODE));
}
class UserApi
{
    function _initialize()
    {}
    public function getUserList($param)
    {
        global $db;
        return $db->getAll("SELECT * from ecs_users where invitation_code="."'".$param["invitationCode"]."'");
    }
    public function getUserOrderList($param)
    {
        global $db;
        return $db->getAll("select *,(select user_name from ecs_users where i.user_id = user_id) as user_name from ecs_order_info i left join ecs_order_goods g on i.order_id = g.order_id  where i.user_id in (select ecs_users.user_id from ecs_users where invitation_code="."'".$param["invitationCode"]."')");
    }
}