You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
5.6 KiB
175 lines
5.6 KiB
<?php
|
|
|
|
|
|
|
|
/**
|
|
* 获取未付款订单的数量
|
|
*/
|
|
function not_pay($user_id) {
|
|
$where = 'and pay_status = ' . PS_UNPAYED . ' and order_status not in(' . OS_CANCELED . ','. OS_INVALID .','. OS_RETURNED .')';
|
|
$sql = "SELECT count(*) as num FROM {pre}order_info WHERE user_id = '$user_id' " . $where ;
|
|
$res = $GLOBALS['db']->getRow($sql);
|
|
return $res['num'];
|
|
}
|
|
/**
|
|
* 获取未收货订单的数量
|
|
*/
|
|
function not_shouhuo($user_id) {
|
|
$sql = "SELECT count(*) as num FROM {pre}order_info WHERE user_id = '$user_id' and shipping_status = 1 " ;
|
|
$res = $GLOBALS['db']->getRow($sql);
|
|
return $res['num'];
|
|
}
|
|
/**
|
|
* 获取未评价订单的数量
|
|
* 未评价订单条件:订单全部完成
|
|
*/
|
|
function not_comments($user_id) {
|
|
$sql="select count(b.goods_id) from {pre}order_info as o LEFT JOIN {pre}order_goods as b on o.order_id=b.order_id where user_id='$user_id' ".
|
|
" AND o.order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED)) .
|
|
" AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) .
|
|
" AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) .
|
|
" AND b.goods_id not in(select id_value from {pre}comment where user_id='$user_id')";
|
|
|
|
$res = $GLOBALS['db']->getRow($sql);
|
|
$row = $res['count(b.goods_id)'];
|
|
return $row;
|
|
}
|
|
/**
|
|
* 获取用户红包数量
|
|
*/
|
|
function my_bonus($user_id) {
|
|
$time = time();
|
|
$sql='select count(u.bonus_id) from {pre}user_bonus as u left join {pre}bonus_type as b on u.bonus_type_id=b.type_id' .
|
|
" where u.user_id='$user_id' and b.use_end_date>$time and u.order_id=0 ";
|
|
$res = $GLOBALS['db']->getRow($sql);
|
|
$count= $res['count(u.bonus_id)'];
|
|
return $count;
|
|
}
|
|
/**
|
|
* 获取用户积分余额
|
|
*/
|
|
function pay_money($user_id) {
|
|
$sql = "SELECT user_money , pay_points FROM {pre}users WHERE user_id = '$user_id'" ;
|
|
$res = $GLOBALS['db']->getRow($sql);
|
|
return $res;
|
|
}
|
|
/**
|
|
* 获取未读取的消息数量
|
|
*/
|
|
function msg_lists($user_id){
|
|
|
|
$sql = "select msg_id from {pre}feedback where user_id= '".$user_id."'";
|
|
$ress = $GLOBALS['db']->getAll($sql);
|
|
$str = '';
|
|
if($ress){
|
|
foreach($ress as $k)
|
|
{
|
|
$str.=$k['msg_id'].',';
|
|
}
|
|
}
|
|
$reb = substr($str,0,-1) ;
|
|
if(!$reb){
|
|
$reb = 0;
|
|
}
|
|
$sql = "select parent_id from {pre}feedback where parent_id in ($reb)";
|
|
$res = $GLOBALS['db']->getAll($sql);
|
|
if($res){
|
|
$strs = '';
|
|
foreach($res as $k)
|
|
{
|
|
$strs.=$k['parent_id'].',';
|
|
}
|
|
}
|
|
$rebs = substr($strs,0,-1) ;
|
|
if(!$rebs){
|
|
$rebs = 0;
|
|
}
|
|
// $sql = "select count(*) as num from {pre}feedback where msg_id in ($rebs) and msg_read =0 ";
|
|
// $resb = $GLOBALS['db']->getRow($sql);
|
|
// return $resb['num'];
|
|
}
|
|
/**
|
|
* 获取收藏商品的数量
|
|
*/
|
|
function num_collection_goods($user_id) {
|
|
|
|
$sql = "SELECT count(*) as num FROM {pre}collect_goods WHERE user_id = '$user_id' " ;
|
|
$res = $GLOBALS['db']->getRow($sql);
|
|
return $res;
|
|
}
|
|
/**
|
|
* 获取关注店铺的数量
|
|
*/
|
|
function num_collection_store($user_id) {
|
|
|
|
$sql = "SELECT count(*) as num FROM {pre}collect_store WHERE user_id = '$user_id' " ;
|
|
$res = $GLOBALS['db']->getRow($sql);
|
|
return $res;
|
|
}
|
|
|
|
|
|
/**
|
|
* 调用浏览历史
|
|
*
|
|
* @access public
|
|
* @return string
|
|
*/
|
|
function historys() {
|
|
$str = '';
|
|
$history = array();
|
|
if (!empty($_COOKIE['ECS']['history_goods'])) {
|
|
$where = db_create_in($_COOKIE['ECS']['history_goods'], 'goods_id');
|
|
$sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM {pre}goods' .
|
|
" WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
|
|
$query = $GLOBALS['db']->getAll($sql);
|
|
$res = array();
|
|
foreach ($query as $key => $row) {
|
|
$goods['goods_id'] = $row['goods_id'];
|
|
$name = mb_substr($row['goods_name'],0,7, 'utf-8');
|
|
$goods['goods_name'] = $name;
|
|
$goods['short_name'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('goods_name_length')) : $row['goods_name'];
|
|
$goods['goods_thumb'] = get_image_path($row['goods_thumb']);
|
|
$goods['shop_price'] = price_format($row['shop_price']);
|
|
$goods['url'] = U('goods/index/index', array('id' => $row['goods_id']));
|
|
$history[] = $goods;
|
|
}
|
|
}
|
|
return $history;
|
|
}
|
|
/**
|
|
* 验证用户信息
|
|
|
|
*/
|
|
function check_user_info($data,$type='mobile') {
|
|
if($type=='mobile'){
|
|
|
|
$where=" user_name='".$data['user_name']."' and mobile_phone='".$data['mobile_phone']."'";
|
|
}else{
|
|
|
|
$where=" user_name='".$data['user_name']."' and email='".$data['email']."'";
|
|
}
|
|
$sql="SELECT mobile_phone, email FROM {pre}users WHERE ".$where;
|
|
$query = $GLOBALS['db']->getRow($sql);
|
|
if(!empty($query)){
|
|
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取管理员留言数量
|
|
*/
|
|
function get_admin_feedback($user_id){
|
|
if(!empty($user_id)){
|
|
$sql = "SELECT COUNT(*) AS admin_count FROM {pre}feedback AS a WHERE a.parent_id IN ".
|
|
" (SELECT msg_id FROM {pre}feedback AS b WHERE b.user_id = '".$user_id."')";
|
|
$query = $GLOBALS['db']->getRow($sql);
|
|
}
|
|
return $query['admin_count'];
|
|
}
|
|
|
|
|
|
|
|
|
|
|