Ejemplo n.º 1
0
 protected function get_area_data()
 {
     foreach ($this->_area_list as $v) {
         $arr = $this->_redis->lRange($v, 0, 500);
         $reg = 0;
         $reg_in = 0;
         $auth = 0;
         $auth_in = 0;
         //获得认证总数
         $remote = new maindb();
         foreach ($arr as $row) {
             $num1 = $remote->count('p_user', '*', array('school' => $row));
             $reg += $num1;
             $num2 = $remote->count('p_user', '*', array('AND' => array('school' => $row, 'invite[!]' => '')));
             $reg_in += $num2;
             $num3 = $remote->count('p_user', '*', array('AND' => array('school' => $row, 'auth' => 1)));
             $auth += $num3;
             $num4 = $remote->count('p_user', '*', array('AND' => array('school' => $row, 'auth' => 1, 'invite[!]' => '')));
             $auth_in += $num4;
         }
         $result = array('register_all' => $reg, 'authority_all' => $auth, 'register_invite' => $reg_in, 'authority_invite' => $auth_in, 'register_nature' => $reg - $reg_in, 'authority_nature' => $auth - $auth_in);
         $this->_redis->hMset('_' . $v, $result);
         echo $v . '成功!';
     }
     //        $this->_redis->hMset('_安徽',array(
     //            'name'=>'keensting',
     //            'age'=>23,
     //            'school'=>'wwwww',
     //        ));
     //
     //        $list=$this->_redis->hGetAll('_安徽');
     //        print_r($list);
 }
Ejemplo n.º 2
0
 static function static_run($key, $begin = 0, $end = 9999999999)
 {
     //        $local=new medoo();
     $remote = new maindb();
     $firstdb = new firstdb();
     $auth_list = $remote->select('p_user', 'uid', array('AND' => array('invite' => $key, 'auth_time[>]' => $begin, 'auth_time[<]' => $end, 'auth' => 1)));
     if (empty($auth_list)) {
         return 0;
         //没有邀请认证,b值返回0
     } else {
         //根据每个uid去查询机器码
         //            print_r($auth_list);
         $mc_list = array();
         $null_mc = 0;
         foreach ($auth_list as $v) {
             $re = $firstdb->select('auth', 'deviceid', array('uid' => $v));
             if (empty($re[0])) {
                 $mc_list[$null_mc] = '';
                 $null_mc += 1;
             } else {
                 $mc_list[$re[0]] = '';
             }
             //                $mc_list[]=$re[0];
         }
         //            print_r($mc_list);
         $b_value = number_format(count($auth_list) / count($mc_list), 2);
         //b_value保留两位小数
         return $b_value;
     }
 }
Ejemplo n.º 3
0
 protected function performance_data()
 {
     $remote = new maindb();
     $num = $remote->count('p_user', '*', array('invite' => $this->key));
     $re = $remote->select('p_user', array('nickname', 'phone', 'auth'), array('invite' => $this->key, 'LIMIT' => 20));
     if ($num != 0) {
         $pages = ceil($num / 20);
         //分多少页
     } else {
         $pages = 0;
     }
     //推送总数和数据
     $this->assign('data', array('num' => $num, 'list' => $re, 'pages' => $pages, 'index' => 1, 'key' => $this->key));
 }
Ejemplo n.º 4
0
 protected function get_order_list()
 {
     $local = new medoo();
     $remote = new maindb();
     $list = $local->select('orders', '*', array('ekey' => $this->key));
     if (!empty($list)) {
         foreach ($list as &$v) {
             $info = $remote->select('p_order', '*', array('id' => $v['order_id']));
             //将unix时间戳转化为日期
             $v['u_time'] = date('Y-m-d H:i:s', $v['u_time']);
             $v['c_time'] = date('Y-m-d H:i:s', $v['c_time']);
             if ($info[0]['did'] > 0) {
                 $v['order_state'] = $this->state['-1'];
             } else {
                 $v['order_state'] = $this->state[$info[0]['state']];
             }
         }
     }
     $this->assign('list', $list);
 }
Ejemplo n.º 5
0
 static function manager_area_data_load($area, $start = 0, $end = 9999999999)
 {
     $result = array();
     if ($start == 0 && $end == 9999999999) {
         //缓存中寻找数据
         try {
             $redis = new Redis();
         } catch (Exception $e) {
             echo $e->getMessage();
         }
         $redis->connect('127.0.0.1', 6379);
         $result = $redis->hGetAll('_' . $area);
     }
     //缓存中没有,去数据库查找
     if (empty($result)) {
         $list = self::through_area_get_school($area);
         $reg = 0;
         $reg_in = 0;
         $auth = 0;
         $auth_in = 0;
         //获得认证总数
         $remote = new maindb();
         foreach ($list as $v) {
             $num1 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'reg_time[>]' => $start, 'reg_time[<]' => $end)));
             $reg += $num1;
             $num2 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'reg_time[>]' => $start, 'reg_time[<]' => $end, 'invite[!]' => '')));
             $reg_in += $num2;
             $num3 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'auth_time[>]' => $start, 'auth' => 1, 'auth_time[<]' => $end)));
             $auth += $num3;
             $num4 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'auth_time[>]' => $start, 'auth' => 1, 'auth_time[<]' => $end, 'invite[!]' => '')));
             $auth_in += $num4;
         }
         $result = array('register_all' => $reg, 'authority_all' => $auth, 'register_invite' => $reg_in, 'authority_invite' => $auth_in, 'register_nature' => $reg - $reg_in, 'authority_nature' => $auth - $auth_in);
     }
     unset($redis);
     return $result;
 }
Ejemplo n.º 6
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/10/24
 * Time: 0:57
 */
require './maindb.php';
//require('./firstdb.php');
//$db=new firstdb();
$db = new maindb();
$re = $db->select('p_user', '*', array('nickname' => $_GET['name']));
//$re=$db->select('auth','*');
print_r($re);
Ejemplo n.º 7
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/10/15
 * Time: 13:54
 */
require_once '../../../medoo/maindb.php';
$page = $_POST['page'];
$key = $_POST['key'];
$remote = new maindb();
$start = ($page - 1) * 20;
$re = $remote->select('p_user', array('nickname', 'phone', 'auth'), array('invite' => $key, 'LIMIT' => [$start, 20]));
$result = array('list' => $re, 'index' => $page);
echo json_encode($result);
Ejemplo n.º 8
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/11/20
 * Time: 14:53
 */
require '../medoo/maindb.php';
$demo = new maindb();
$id = $_POST['id'];
$re = $demo->select('p_user', '*', array('uid' => $id));
$lifeTime = 3600;
//生命周期为1小时
session_set_cookie_params($lifeTime);
session_start();
$_SESSION['user_info'] = $re[0];
//将用户信息存储起来
echo $re[0]['nickname'];
Ejemplo n.º 9
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/10/15
 * Time: 17:09
 */
require_once '../../../medoo/medoo.php';
require_once '../../../medoo/maindb.php';
$type = $_POST['type'];
$begin = ($_POST['index'] - 1) * 20;
$local = new medoo();
$remote = new maindb();
//管理员查全部的
if ($type == 'admin') {
    $re = $local->select('ambassador', '*', array('auth[>]' => 0, 'LIMIT' => [$begin, 20]));
} elseif ($type == 'manager') {
    $province = $_POST['province'];
    $re = $local->select('ambassador', '*', array('AND' => array('province' => $province, 'auth' => 2), 'LIMIT' => [$begin, 20]));
}
//统一去远端数据库匹配数据
foreach ($re as &$v) {
    $reg = $remote->count('p_user', '*', array('invite' => $v['ekey']));
    $aut = $remote->count('p_user', '*', array('AND' => array('invite' => $v['ekey'], 'auth' => 1)));
    $orders = $local->count('orders', '*', array('ekey' => $v['ekey']));
    $v['reg'] = $reg;
    $v['aut'] = $aut;
    $v['ord'] = $orders;
}
unset($remote);
Ejemplo n.º 10
0
<?php

/**处理大使后台的各种搜索条件,返回结果
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/10/14
 * Time: 15:35
 */
require_once '../../../medoo/medoo.php';
require_once '../../../medoo/maindb.php';
require_once '../../include/school_handler.php';
session_start();
$type = $_POST['type'];
$local = new medoo();
//本地数据库接口
$remote = new maindb();
//远端数据库接口
//根据不同的type制定不同的操作
if ($type == 'key') {
    if ($_SESSION['userinfo']['auth'] == 2) {
        echo 'auth';
        //大使拒绝查询
        exit;
    }
    $key = $_POST['key'];
    $begin = $_POST['begin'] == '' ? 0 : $_POST['begin'];
    $end = $_POST['end'] == '' ? 9999999999 : $_POST['end'];
    //转化为linux的时间戳
    if ($begin != 0) {
        $arr = explode('/', substr($begin, 0, 10));
        $begin = gmmktime(0, 0, 0, $arr[0], $arr[1], $arr[2]);
Ejemplo n.º 11
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/10/19
 * Time: 10:30
 */
require_once '../../../medoo/medoo.php';
require_once '../../../medoo/maindb.php';
$id = $_POST['id'];
session_start();
$key = $_SESSION['userinfo']['ekey'];
//获取用户的唯一key
$remote = new maindb();
$local = new medoo();
//查询一次远端数据库,匹配订单状态
$item = $remote->select('p_order', '*', array('id' => $id));
if (empty($item)) {
    echo 'noinfo';
} elseif ($item[0]['state'] < 2) {
    echo 'unfinish';
} else {
    //todo
    //可能会添加几个大使开放所有订单种类
    $sid = $item[0]['sid'];
    $sell_info = $remote->select('p_sell_goods', 'ccid', array('id' => $sid));
    $ccid = $sell_info[0];
    if ($ccid != 100) {
        echo 'type';
        exit;
Ejemplo n.º 12
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/10/24
 * Time: 0:57
 */
//require('medoo.php');
//$local=new medoo();
//$orders=$local->count('orders','*',array(
//    'AND'=>array(
//        'u_time[<]'=>9999999999,
//        'u_time[>]'=>0,
//        'state'=>0,//只统计未结算的订单
//        'ekey'=>'230230',
//        'act_id'=>0,
//    )));
//echo 'dasd';
//print_r($orders);
require 'maindb.php';
$demo = new maindb();
$list = $demo->select('p_user', '*', array('phone' => '13121062200'));
print_r($list);
Ejemplo n.º 13
-1
 /**
  *获得自身的注册数和认证数&订单数,如果我是主管,将学校列表写入session
  */
 protected function get_self_counter()
 {
     $local = new medoo();
     $db = new maindb();
     $register = $db->count('p_user', '*', array('invite' => $_SESSION['userinfo']['ekey']));
     $authority = $db->count('p_user', '*', array('AND' => array('invite' => $_SESSION['userinfo']['ekey'], 'auth' => 1)));
     $orders = $local->count('orders', '*', array('ekey' => $_SESSION['userinfo']['ekey']));
     unset($db);
     unset($local);
     if ($_SESSION['userinfo']['auth'] == 1) {
         //主管,写入学校列表
         $_SESSION['school'] = school_handler::through_area_get_school($_SESSION['userinfo']['province']);
     }
     $_SESSION['userinfo']['register'] = $register;
     $_SESSION['userinfo']['authority'] = $authority;
     $_SESSION['userinfo']['orders'] = $orders;
 }