wangtengyu
2018-12-03 0aaef70a400bee9b05d8b480fe9063910a428362
用户列表 and 用户订单列表 by 王腾宇
5 files added
1 files modified
395 ■■■■■ changed files
application/admin/conf/menu.php 28 ●●●●● patch | view | raw | blame | history
application/admin/controller/UserList.php 31 ●●●●● patch | view | raw | blame | history
application/admin/controller/UserOrderList.php 29 ●●●●● patch | view | raw | blame | history
application/admin/template/user_list/index.htm 82 ●●●●● patch | view | raw | blame | history
application/admin/template/user_order_list/index.htm 90 ●●●●● patch | view | raw | blame | history
application/common/util/interface.func.php 135 ●●●●● patch | view | raw | blame | history
application/admin/conf/menu.php
@@ -162,6 +162,34 @@
                'is_modules'=>1,
                'child' => array(),
            ),
            '1004' => array(
                'id'=>1004,
                'parent_id'=>1000,
                'name' => '用户列表',
                'action'=>'index',
                'controller'=>'UserList',
                'url'=>'',
                'target'=>'workspace',
                'icon'=>'fa fa-user',
                'grade'=>1,
                'is_menu'=>1,
                'is_modules'=>1,
                'child' => array(),
            ),
            '1005' => array(
                'id'=>1005,
                'parent_id'=>1000,
                'name' => '用户订单',
                'action'=>'index',
                'controller'=>'UserOrderList',
                'url'=>'',
                'target'=>'workspace',
                'icon'=>'fa fa-bookmark-o',
                'grade'=>1,
                'is_menu'=>1,
                'is_modules'=>1,
                'child' => array(),
            ),
        ),
    ),
        
application/admin/controller/UserList.php
New file
@@ -0,0 +1,31 @@
<?php
/**
 * Author: 王腾宇
 * Date: 2018-11-27
 */
namespace app\admin\controller;
require dirname(__FILE__) . '/../../common/util/interface.func.php';
class UserList extends Base
{
    // 页面初始化
    public function _initialize()
    {}
    public function index()
    {
        $retData= toPost("http://localhost:9119/api/userApi.php/getUserList",array(
            "invitationCode"=>"ICA001"
        ),"1000001");
        $list = array();
        if ($retData["rspCode"]==="e00000") {
            $list = $retData["rspData"];
        }
        $this->assign('list',$list);
        return $this->fetch();
    }
}
application/admin/controller/UserOrderList.php
New file
@@ -0,0 +1,29 @@
<?php
/**
 * Author: 王腾宇
 * Date: 2018-11-27
 */
namespace app\admin\controller;
require dirname(__FILE__) . '/../../common/util/interface.func.php';
class UserOrderList extends Base
{
    // 页面初始化
    public function _initialize()
    {}
    public function index()
    {
        $retData= toPost("http://localhost:9119/api/userApi.php/getUserOrderList",array(
            "invitationCode"=>"ICA001"
        ),"1000001");
        $list = array();
        if ($retData["rspCode"]==="e00000") {
            $list = $retData["rspData"];
        }
        $this->assign('list',$list);
        return $this->fetch();
    }
}
application/admin/template/user_list/index.htm
New file
@@ -0,0 +1,82 @@
{include file="public/layout" /}
<script type="text/javascript" src="__PUBLIC__/plugins/laydate/laydate.js"></script>
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page ad">
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>用户列表</h3>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th abbr="article_title" style="width: 25%">
                            <div style="text-align:center">ID</div>
                        </th>
                        <th abbr="article_title" style="width: 25%">
                            <div style="text-align:center">用户名</div>
                        </th>
                        <th abbr="article_title" style="width: 25%">
                            <div style="text-align:center">电子邮箱</div>
                        </th>
                        <th abbr="article_title" style="width: 25%" >
                            <div style="text-align:center">电话号码</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%;">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <td style="width: 23.91%">
                                <div style="text-align:center">
                                    {$vo.user_id}
                                </div>
                            </td>
                            <td style="width: 24.7%">
                                <div style="text-align:center">
                                    {$vo.user_name}
                                </div>
                            </td>
                            <td style="width: 24.6%">
                                <div style="text-align:center">
                                    {$vo.email}
                                </div>
                            </td>
                            <td style="width: 24.3%">
                                <div style="text-align:center">
                                    {$vo.mobile_phone}
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <!--分页位置-->
    </div>
</div>
{include file="public/footer" /}
application/admin/template/user_order_list/index.htm
New file
@@ -0,0 +1,90 @@
{include file="public/layout" /}
<script type="text/javascript" src="__PUBLIC__/plugins/laydate/laydate.js"></script>
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page ad">
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>用户订单</h3>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th abbr="article_title" style="width: 5%">
                            <div style="text-align:center">ID</div>
                        </th>
                        <th abbr="article_title" style="width: 15%" >
                            <div style="text-align:center">购物人</div>
                        </th>
                        <th abbr="article_title" style="width: 15%">
                            <div style="text-align:center">支付方式</div>
                        </th>
                        <th abbr="article_title" style="width: 15%">
                            <div style="text-align:center">交易金额</div>
                        </th>
                        <th abbr="article_title" style="width: 15%" >
                            <div style="text-align:center">商品名</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%;">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <td style="width: 5%">
                                <div style="text-align:center">
                                    {$vo.order_id}
                                </div>
                            </td>
                            <td style="width: 15%">
                                <div style="text-align:center">
                                    {$vo.user_name}
                                </div>
                            </td>
                            <td style="width: 15%">
                                <div style="text-align:center">
                                    {$vo.pay_name}
                                </div>
                            </td>
                            <td style="width: 15%">
                                <div style="text-align:center">
                                    {$vo.goods_amount}
                                </div>
                            </td>
                            <td style="width: 15%">
                                <div style="text-align:center">
                                    {$vo.goods_name}
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <!--分页位置-->
    </div>
</div>
{include file="public/footer" /}
application/common/util/interface.func.php
New file
@@ -0,0 +1,135 @@
<?php
/**
 * 对外接口工具类 Api
 * 王腾宇
 */
// 1000001 微擎
// 1000002 商城
// 1000003 管理系统
global $systemId;
static $systemId = array(
    "1000001"=>"3a03c2e6f2f911e8b9245254009bf9ba",
    "1000002"=>"466a50d8f2f911e8b9245254009bf9ba",
    "1000003"=>"53cfae5df2f911e8b9245254009bf9ba",
);
/**
 * 接口数据校验
 * e00000 检验成功
 * e00001 接入平台不存在
 * e00002 鉴权失败
 */
function checkParam ($param)
{
    global $systemId;
    $retData = array();
    $sysKey = $systemId[substr($param["id"],0,7)];
    if ($sysKey == null){
        $retData["rspCode"] = "e00001";
    } else {
        if (checkSign($param,$sysKey)){
            $retData["rspCode"] = "e00000";
            $retData["repData"] = json_decode($param["data"],true);
        } else {
            $retData["rspCode"] = "e00002";
        }
    }
    return $retData;
}
/**
 * 校验签名
 */
function checkSign($data,$sysKey)
{
    $str = "";
    foreach ($data as $key => $value)
    {
        if ($key != "sign") {
            $str = $str.$key."=".$value."&";
        }
    }
    return $data["sign"] == md5($str."key=".$sysKey);
}
/**
 * 解析请求接口地址
 */
function getUrl($url)
{
    $arr = explode('/', $url);
    return substr($arr[count($arr)-1],0,strpos($arr[count($arr)-1], '?'));
}
/**
 * 生成对外接口字符串
 * 例子: id=100000120181128223494512&data=%7B%22code%22%3A%221%22%2C%22id%22%3A%22100000120181128223494512%22%7D&sign=a59336edda9fd6785fac6720d02c7d61
 */
function makeInterfaceParam($param, $appId)
{
    $param["id"]=$appId.date("Ymd").getRandomNumber(9);
    $paramJson = json_encode($param,JSON_UNESCAPED_UNICODE);
    return
        "id=".$param["id"].
        "&data=".urlencode($paramJson).
        "&sign=".getSign($paramJson,$appId,$param["id"]);
}
/**
 * 生成签名
 */
function getSign($param,$appId,$id){
    global $systemId;
    if ($systemId==null){
        $systemId = array(
            "1000001"=>"3a03c2e6f2f911e8b9245254009bf9ba",
            "1000002"=>"466a50d8f2f911e8b9245254009bf9ba",
            "1000003"=>"53cfae5df2f911e8b9245254009bf9ba",
        );
    }
    return md5(
        "id=".$id.
        "&data=".$param.
        "&key=".$systemId[$appId]
    );
}
/**
 * 生成随机数字
 */
function getRandomNumber($length){
    $arr = [0,1,2,3,4,5,6,7,8,9];
    $str = '';
    for ($i = 0; $i < $length; $i++)
    {
        $str .= $arr[rand(0, 9)];
    }
    return $str;
}
function toPost($url, $param, $appId){
    return send_post($url."?".makeInterfaceParam($param,$appId), array());
}
function send_post($url, $post_data) {
    $postdata = http_build_query($post_data);
    $options = array(
        'http' => array(
            'method' => 'POST',
            'header' => 'Content-type:application/x-www-form-urlencoded',
            'content' => $postdata,
            'timeout' => 15 * 60
        )
    );
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    return json_decode($result,true);
}