wangtengyu
2018-12-07 f459412e0dac4ed94106da043b4c6f8576bfe496
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?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();
            try {
                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);
                }    
            } catch (Exception $e){
                $retData["rspCode"] = "e99999";
                $retData["rspData"] = $e->getMessage();
            }   
            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"]."')");
    }
}