文件
mashangyoujiu/Application/Common/Model/XcxVipModel.class.php

132 行
4.8 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Common\Model;
use Think\Model;
//[1.2.11]
class XcxVipModel extends Model
{
protected $tableName = 'retail_xcxvip';
protected $fields = array(
'id', // `id` int(11) NOT NULL AUTO_INCREMENT,
'openid', // `openid` varchar(255) DEFAULT '0',
'nickname', // `nickname` varchar(30) DEFAULT NULL COMMENT '昵称',
'headimgurl', // `headimgurl` varchar(255) DEFAULT NULL COMMENT '微信头像',
'merchantid', // `merchantid` int(11) DEFAULT NULL COMMENT '商户id',
'ctime', // `ctime` varchar(255) DEFAULT NULL COMMENT '注册时间',
'card_num', // `card_num` varchar(20) DEFAULT '' COMMENT '会员卡号',
'vip_id', // `vip_id` int(11) DEFAULT NULL COMMENT '与会员表id关联的字段',
'plus_vip_id', // `plus_vip_id` int(11) DEFAULT NULL COMMENT 'plus会员id',
'mobile_phone', // `mobile_phone` varchar(11) DEFAULT NULL COMMENT '自提最近使用手机号',
'link_name', // `link_name` varchar(50) DEFAULT NULL COMMENT '自提最近使用姓名',
'type', // `type` tinyint(1) DEFAULT '1' COMMENT '1普通成员 2plus会员',
);
/**
* 处理搜索条件
* @param [array] $seek_data 搜索条件
* @return [array|string] $map
*/
public function handleSeekData($seek_data)
{
// 时间搜索
$start_time = $seek_data['start_time'];
$end_time = $seek_data['end_time'];
if($start_time && $end_time){
$start_time = strtotime($start_time);
$end_time = strtotime($end_time);
$map['ctime'] = array('between',array($start_time,$end_time));
}else if($start_time && !$end_time){
$start_time = strtotime($start_time);
$map['ctime'] = array('egt',$start_time);
}else if(!$start_time && $end_time){
$end_time = strtotime($end_time);
$map['ctime'] = array('elt',$end_time);
}
// 昵称搜索
if(trim($seek_data['nickname'])){
$map['nickname'] = array('like','%' . trim($seek_data['nickname']) . '%');
}
$map = $map ? $map : array();
return $map;
}
/**
* 查询小程序用户
* @param [array] $map 查询条件
* @return [array|string] $find
*/
public function getFind($map)
{
$find = $this->where($map)->find();
return $find;
}
/**
* 查询所有小程序用户(select)
* @param [array] $map 查询条件
* @param [int] $page 分页
* @param [int] $limit 数量
* @return [array|string] $xcx_user
*/
public function getSelect($map,$page = 0,$limit = 0)
{
if($page && $page != 0 && $limit && $limit != 0){
$xcx_user = $this->where($map)->page($page,$limit)->order('id desc')->select();
}else{
$xcx_user = $this->where($map)->order('id desc')->select();
}
return $xcx_user;
}
/**
* 修改(save)
* @param [array] $map 搜索条件
* @param [array] $up 修改数据
* @return [bool] $save
*/
public function saveXcxVip($map,$up)
{
$save = $this->where($map)->save($up);
return $save;
}
/**
* 统计数据(count)
* @param [array] $map 查询条件
* @return [array] $res
*/
public function total($map)
{
$total = $this->where($map)->count();
return (int)$total;
}
/**
* 获取小程序用户
* @param [int] $storeid 门店id
* @param [array] $seek_data 搜索条件
* @param [int] $page 分页
* @limit [limit] $limit 数量
* @return [array] $res
*/
public function getXcxUser($map,$page = 0,$limit = 0)
{
$xcx_user = $this->getSelect($map,$page,$limit);
if(!$xcx_user){
$res = array('status'=>0,'msg'=>'暂无用户');
return $res;
}
$total = $this->total($map);
$where['state'] = 0;
$where['status'] = 1;
foreach ($xcx_user as $key=>&$val){
$val['index'] = $key + 1;
$val['ctime'] = date('Y-m-d H:i:s',$val['ctime']);
$val['mobile_phone'] = $val['mobile_phone'] ? $val['mobile_phone'] : '无';
$val['link_name'] = $val['link_name'] ? $val['link_name'] : '无';
}
$res = array('status'=>1,'xcx_user'=>$xcx_user,'total'=>(int)$total);
return $res;
}
}