176 行
4.9 KiB
PHP
可执行文件
176 行
4.9 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Common\Model;
|
|
|
|
use Think\Model;
|
|
|
|
//[1.1.96]
|
|
class SmallProgramUserModel extends Model
|
|
{
|
|
protected $tableName = 'retail_xcxvip';
|
|
protected $fields = array(
|
|
'id', //int(11) NOT NULL AUTO_INCREMENT,
|
|
'openid', //varchar(255) DEFAULT '0',
|
|
'nickname', //varchar(30) DEFAULT NULL COMMENT '昵称',
|
|
'headimgurl', //varchar(255) DEFAULT NULL COMMENT '微信头像',
|
|
'merchantid', //int(11) DEFAULT NULL COMMENT '商户id',
|
|
'ctime', //varchar(255) DEFAULT NULL COMMENT '注册时间',
|
|
'card_num', //varchar(20) DEFAULT '' COMMENT '会员卡号',
|
|
'vip_id', //int(11) DEFAULT NULL COMMENT '与会员表id关联的字段',
|
|
'plus_vip_id', //int(11) DEFAULT NULL COMMENT 'plus会员id',
|
|
'mobile_phone', //varchar(11) DEFAULT NULL COMMENT '自提最近使用手机号',
|
|
'link_name', //varchar(50) DEFAULT NULL COMMENT '自提最近使用姓名',
|
|
'type', //tinyint(1) DEFAULT '1' COMMENT '1普通成员 2plus会员',
|
|
);
|
|
|
|
/**
|
|
* 添加
|
|
* @param $data
|
|
* @return mixed
|
|
*/
|
|
public function addOrder($data)
|
|
{
|
|
$res = $this->add($data);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 更新
|
|
* @param $map
|
|
* @param $save
|
|
* @return mixed
|
|
*/
|
|
public function updateOrder($map, $save)
|
|
{
|
|
$res = $this->where($map)->save($save);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取一条
|
|
* @param $map
|
|
* @param string $fields
|
|
* @param $bol
|
|
* @return mixed
|
|
*/
|
|
public function getFind($map, $fields = '*')
|
|
{
|
|
$res = $this->field($fields)->where($map)->find();
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取某字段
|
|
* @param $map
|
|
* @param string $fields
|
|
* @param $bol
|
|
* @param $order
|
|
* @return mixed
|
|
*/
|
|
public function getFindField($map, $fields = 'id', $bol = false, $order = 'id asc')
|
|
{
|
|
$res = $this->where($map)->order($order)->getField($fields, $bol);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 查询多条
|
|
* @param $map
|
|
* @param string $field
|
|
* @param string $order
|
|
* @param string $page
|
|
* @return mixed
|
|
*/
|
|
public function getSelect($map, $field = '*', $order = 'id asc', $page = '')
|
|
{
|
|
if ($page) {
|
|
$res = $this->field($field)->where($map)->order($order)->page($page)->select();
|
|
} else {
|
|
$res = $this->field($field)->where($map)->order($order)->select();
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 获取数量
|
|
* @param $map
|
|
* @return mixed
|
|
*/
|
|
public function getCount($map)
|
|
{
|
|
$res = $this->where($map)->count();
|
|
return $res;
|
|
}
|
|
|
|
|
|
/**
|
|
* 某字段增加
|
|
* @param $map
|
|
* @param $key
|
|
* @param $val
|
|
* @return mixed
|
|
*/
|
|
public function toSetInc($map, $key, $val)
|
|
{
|
|
$res = $this->where($map)->setInc($key, $val);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 某字段减少
|
|
* @param $map
|
|
* @param $key
|
|
* @param $val
|
|
* @return mixed
|
|
*/
|
|
public function toSetDec($map, $key, $val)
|
|
{
|
|
$res = $this->where($map)->setDec($key, $val);
|
|
return $res;
|
|
}
|
|
|
|
|
|
/*-----------------------以下为其他功能-----------------------------------*/
|
|
|
|
public function getFindVip($uid){
|
|
$user = $this->where(array('id'=>$uid))->find();
|
|
if(!$user || empty($user['vip_id'])){
|
|
$res['status'] = 0;
|
|
$res['msg'] = '未绑定会员';
|
|
}else{
|
|
$map = array(
|
|
'id'=>$user['vip_id'],
|
|
'merchantid'=>$user['merchantid']
|
|
);
|
|
$vip = D('Vip')->getFind($map);
|
|
if(!empty($vip)){
|
|
switch ($vip['status']){
|
|
case '1':
|
|
$res['vip'] = $vip;
|
|
$res['status'] = 1;
|
|
$res['msg'] = '获取会员信息成功';
|
|
break;
|
|
case '2':
|
|
$res['status'] = 0;
|
|
$res['msg'] = '会员已被删除';
|
|
break;
|
|
case '3':
|
|
$res['status'] = 0;
|
|
$res['msg'] = '会员已被冻结';
|
|
break;
|
|
case '4':
|
|
$res['status'] = 0;
|
|
$res['msg'] = '该会员已挂失';
|
|
break;
|
|
default:
|
|
$res['status'] = 0;
|
|
$res['msg'] = '会员不存在';
|
|
}
|
|
}else{
|
|
$res['status'] = 0;
|
|
$res['msg'] = '会员不存在';
|
|
}
|
|
}
|
|
return $res;
|
|
}
|
|
} |