Exemplo n.º 1
0
function add_user($username, $password, $email, $studentid)
{
    $userid = get_user_number() + 1;
    //得到用户的数量并+1生成新用户的ID
    $password = hash_password($password);
    //加密密码
    $query = "INSERT INTO user(userid, username, password, email, studentid) VALUE('{$userid}', '{$username}', '{$password}','{$email}','{$studentid}')";
    if ($result = mysql_query($query)) {
        mysql_query("UPDATE status SET status.value = status.value+1 WHERE status.name = 'usernumber'");
        return true;
    } else {
        die("Error in query: {$query}. " . mysql_error());
    }
}
Exemplo n.º 2
0
/**
 *  获取发货单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function delivery_list()
{
    $result = get_filter();
    if ($result === false) {
        /* 过滤信息 */
        $filter['order_sn'] = empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']);
        if (!empty($_GET['is_ajax']) && $_GET['is_ajax'] == 1) {
            $_REQUEST['consignee'] = json_str_iconv($_REQUEST['consignee']);
            //$_REQUEST['address'] = json_str_iconv($_REQUEST['address']);
        }
        /*add by hg for date 2014-04-23 获取代理商id begin*/
        $filter['admin_agency_id'] = !empty($_REQUEST['admin_agency_id']) ? $_REQUEST['admin_agency_id'] : 0;
        /*end*/
        /*add by ccx for date 2014-11-12 获取支付类型payment_method*/
        $filter['payment_method'] = empty($_REQUEST['payment_method']) ? '' : trim($_REQUEST['payment_method']);
        /*end*/
        $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-360 days') : $_REQUEST['start_date'];
        $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : $_REQUEST['end_date'];
        if (strpos($filter['start_date'], '-') !== false) {
            $filter['start_date'] = local_strtotime($filter['start_date']);
            $filter['end_date'] = local_strtotime($filter['end_date']);
        }
        //dump(date('Y-m-d H-i-s',$filter['end_date']));
        $filter['pay_id'] = empty($_REQUEST['pay_id']) ? 0 : intval($_REQUEST['pay_id']);
        $filter['order_status'] = isset($_REQUEST['order_status']) ? intval($_REQUEST['order_status']) : -1;
        $filter['shipping_status'] = isset($_REQUEST['shipping_status']) ? intval($_REQUEST['shipping_status']) : -1;
        $filter['pay_status'] = isset($_REQUEST['pay_status']) ? intval($_REQUEST['pay_status']) : -1;
        $filter['user_id'] = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']);
        $filter['user_name'] = empty($_REQUEST['user_name']) ? '' : trim($_REQUEST['user_name']);
        $filter['composite_status'] = isset($_REQUEST['composite_status']) ? intval($_REQUEST['composite_status']) : -1;
        $filter['group_buy_id'] = isset($_REQUEST['group_buy_id']) ? intval($_REQUEST['group_buy_id']) : 0;
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'add_time' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['start_time'] = empty($_REQUEST['start_time']) ? '' : (strpos($_REQUEST['start_time'], '-') > 0 ? local_strtotime($_REQUEST['start_time']) : $_REQUEST['start_time']);
        $filter['end_time'] = empty($_REQUEST['end_time']) ? '' : (strpos($_REQUEST['end_time'], '-') > 0 ? local_strtotime($_REQUEST['end_time']) : $_REQUEST['end_time']);
        $where = 'WHERE 1 ';
        /*add by hg for date 2014-04-22 只显示代理商本身所属订单 begin*/
        $where .= agency_where();
        /*end*/
        if ($filter['order_sn']) {
            $where .= " AND o.order_sn LIKE '%" . mysql_like_quote($filter['order_sn']) . "%'";
        }
        if ($filter['consignee']) {
            $where .= " AND o.consignee LIKE '%" . mysql_like_quote($filter['consignee']) . "%'";
        }
        if ($filter['email']) {
            $where .= " AND o.email LIKE '%" . mysql_like_quote($filter['email']) . "%'";
        }
        if ($filter['address']) {
            $where .= " AND o.address LIKE '%" . mysql_like_quote($filter['address']) . "%'";
        }
        if ($filter['zipcode']) {
            $where .= " AND o.zipcode LIKE '%" . mysql_like_quote($filter['zipcode']) . "%'";
        }
        if ($filter['tel']) {
            $where .= " AND o.tel LIKE '%" . mysql_like_quote($filter['tel']) . "%'";
        }
        if ($filter['mobile']) {
            $where .= " AND o.mobile LIKE '%" . mysql_like_quote($filter['mobile']) . "%'";
        }
        if ($filter['country']) {
            $where .= " AND o.country = '{$filter['country']}'";
        }
        if ($filter['province']) {
            $where .= " AND o.province = '{$filter['province']}'";
        }
        if ($filter['city']) {
            $where .= " AND o.city = '{$filter['city']}'";
        }
        if ($filter['district']) {
            $where .= " AND o.district = '{$filter['district']}'";
        }
        if ($filter['shipping_id']) {
            $where .= " AND o.shipping_id  = '{$filter['shipping_id']}'";
        }
        if ($filter['pay_id']) {
            $where .= " AND o.pay_id  = '{$filter['pay_id']}'";
        }
        /* ccx 2014-11-12  增加了对支付类型的搜索功能*/
        if ($filter['payment_method']) {
            //$where .= " AND o.pay_id  = '$filter[payment_method]'";
            if ($filter['payment_method'] == 3) {
                $where .= " AND ( o.pay_id !=1 AND o.pay_id !=2 AND o.pay_id !=0)";
            } elseif ($filter['payment_method'] == 1) {
                $where .= " AND o.pay_id  = 1";
            } elseif ($filter['payment_method'] == 2) {
                $where .= " AND o.pay_id  = 2";
            }
        }
        if ($filter['order_status'] != -1) {
            $where .= " AND o.order_status  = '{$filter['order_status']}'";
        }
        if ($filter['shipping_status'] != -1) {
            $where .= " AND o.shipping_status = '{$filter['shipping_status']}'";
        }
        if ($filter['pay_status'] != -1) {
            $where .= " AND o.pay_status = '{$filter['pay_status']}'";
        }
        if ($filter['user_id']) {
            $where .= " AND o.user_id = '{$filter['user_id']}'";
        }
        if ($filter['user_name']) {
            $where .= " AND u.user_name LIKE '%" . mysql_like_quote($filter['user_name']) . "%'";
        }
        //对已进行收费确认的订单进行分润处理
        $where .= " AND o.order_status =5 AND o.shipping_status = 2 AND o.pay_status = 2 ";
        /*add by hg for date 2014-04-23 根据代理商筛选 begin*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                if ($filter['admin_agency_id'] != '-') {
                    $where .= " AND o.admin_agency_id = {$filter['admin_agency_id']}";
                } else {
                    $GLOBALS['smarty']->assign('show_agency', true);
                    //查询整站订单
                }
            } else {
                $where .= " AND o.admin_agency_id != 0";
            }
        }
        /*end*/
        //综合状态
        switch ($filter['composite_status']) {
            case CS_AWAIT_PAY:
                $where .= order_query_sql('await_pay');
                break;
            case CS_AWAIT_SHIP:
                $where .= order_query_sql('await_ship');
                break;
            case CS_FINISHED:
                $where .= order_query_sql('finished');
                break;
            case PS_PAYING:
                if ($filter['composite_status'] != -1) {
                    $where .= " AND o.pay_status = '{$filter['composite_status']}' ";
                }
                break;
            case OS_SHIPPED_PART:
                if ($filter['composite_status'] != -1) {
                    $where .= " AND o.shipping_status  = '{$filter['composite_status']}'-2 ";
                }
                break;
            default:
                if ($filter['composite_status'] != -1) {
                    $where .= " AND o.order_status = '{$filter['composite_status']}' ";
                }
        }
        /* 团购订单 */
        if ($filter['group_buy_id']) {
            $where .= " AND o.extension_code = 'group_buy' AND o.extension_id = '{$filter['group_buy_id']}' ";
        }
        /* 如果管理员属于某个办事处,只列出这个办事处管辖的订单 */
        $sql = "SELECT agency_id FROM " . $GLOBALS['ecs']->table('admin_user') . " WHERE user_id = '{$_SESSION['admin_id']}'";
        $agency_id = $GLOBALS['db']->getOne($sql);
        if ($agency_id > 0) {
            $where .= " AND o.agency_id = '{$agency_id}' ";
        }
        /* 分页大小 */
        $filter['page'] = empty($_REQUEST['page']) || intval($_REQUEST['page']) <= 0 ? 1 : intval($_REQUEST['page']);
        if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0) {
            $filter['page_size'] = intval($_REQUEST['page_size']);
        } elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0) {
            $filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']);
        } else {
            $filter['page_size'] = 15;
        }
        /* 记录总数 */
        if ($filter['user_name']) {
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('order_info') . " AS o ," . $GLOBALS['ecs']->table('users') . " AS u " . $where;
        } else {
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . $where;
        }
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        /* 查询 */
        $sql = "SELECT o.order_id, o.order_sn,o.add_time, o.order_status, o.shipping_status, " . "o.order_amount, o.money_paid,IFNULL(a.user_name, '主站') AS admin_user," . "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " . "IFNULL(u.user_name, '" . $GLOBALS['_LANG']['anonymous'] . "') AS buyer , o.is_separate, o.user_id , o.admin_agency_id " . " FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . " LEFT JOIN " . $GLOBALS['ecs']->table('users') . " AS u ON u.user_id=o.user_id LEFT JOIN " . $GLOBALS['ecs']->table('admin_user') . " as a ON a.agency_user_id=o.admin_agency_id " . $where . " ORDER BY {$filter['sort_by']} {$filter['sort_order']} " . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
        foreach (array('order_sn', 'consignee', 'email', 'address', 'zipcode', 'tel', 'user_name') as $val) {
            $filter[$val] = stripslashes($filter[$val]);
        }
        set_filter($filter, $sql);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $row = $GLOBALS['db']->getAll($sql);
    //print_r($row);
    /* 格式话数据 */
    foreach ($row as $key => $value) {
        $user_number = get_user_number($value['user_id']);
        //print_r($user_number); echo "<br>";
        $v2_message = 0;
        foreach ($user_number as $k => $v1) {
            $user_rank = $v1['user_rank'];
            $top_rank = $v1['top_rank'];
            //echo $user_rank;echo "ab";echo "<br>";
            if ($user_rank == 4) {
                $v1_message = $v1['user_id'];
                //判断是否是代理商
            }
            //if($user_rank == 36 )    //内网的V2等级是36
            if ($user_rank == 40) {
                $v2_message = 1;
                //判断是V2  1:表示存在V2,就可以参与分润了
                $sql = "SELECT user_name FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = " . $v1['user_id'];
                $user_name = $GLOBALS['db']->getOne($sql);
            }
            if ($top_rank == $value['admin_agency_id']) {
                $v1_message = $v1['top_rank'];
                //
            }
        }
        if ($v1_message != $value['admin_agency_id'] || $v2_message != 1) {
            //print_r($row[$key]);echo "<br>";
            unset($row[$key]);
            array_values($row);
            $filter['record_count'] = $filter['record_count'] - 1;
            //$filter['page_count']     = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
        } else {
            array_values($row);
            $sql = "SELECT el.order_id , el.money, g.goods_name, el.change_time FROM " . $GLOBALS['ecs']->table('earnings_log') . " AS el " . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON el.goods_id = g.goods_id " . " WHERE order_id = " . $value['order_id'];
            //$stat = $GLOBALS['db']->getRow($sql);
            $stat = $GLOBALS['db']->getAll($sql);
            $money_message = "";
            $count_money = "";
            if ($stat) {
                foreach ($stat as $ab => $stat_value) {
                    $money_message = $money_message . $stat_value['goods_name'] . ":" . $stat_value['money'] . "&nbsp;";
                    $count_money = $count_money + $stat_value['money'];
                    $change_time = $stat_value['change_time'];
                }
                $row[$key]['stat_fenrun'] = "1";
                //$row[$key]['info'] = "V2(推广商)获得的分润:". $stat['money']."元";
                $row[$key]['info'] = "V2(推广商)" . $user_name . "获得的分润:" . $count_money . "<br> (&nbsp; " . $money_message . ')';
                $row[$key]['change_time'] = local_date('m-d H:i', $change_time);
            } else {
                $row[$key]['stat_fenrun'] = "2";
                $row[$key]['info'] = "";
            }
            $row[$key]['formated_order_amount'] = price_format($value['order_amount']);
            $row[$key]['formated_money_paid'] = price_format($value['money_paid']);
            $row[$key]['formated_total_fee'] = price_format($value['total_fee']);
            $row[$key]['short_order_time'] = local_date('m-d H:i', $value['add_time']);
            if ($value['order_status'] == OS_INVALID || $value['order_status'] == OS_CANCELED) {
                /* 如果该订单为无效或取消则显示删除链接 */
                $row[$key]['can_remove'] = 1;
            } else {
                $row[$key]['can_remove'] = 0;
            }
        }
    }
    $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
    //print_r($row);
    //array_values($row);
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}