134 行
3.7 KiB
PHP
可执行文件
134 行
3.7 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Common\Model;
|
||
|
||
use Think\Model;
|
||
//[1.1.96]
|
||
class CardUseCodeModel extends Model
|
||
{
|
||
protected $tableName = 'retail_card_use_code';
|
||
protected $fields = array(
|
||
'id', // `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||
'merchantid', // `merchantid` int(10) DEFAULT '0' COMMENT '商户id',
|
||
'vip_id', // `vip_id` int(10) DEFAULT '0' COMMENT '会员卡id',
|
||
'vip_card_id', // `card_id` int(10) DEFAULT '0' COMMENT '次卡id',
|
||
'use_code', // `use_code` varchar(20) DEFAULT '' COMMENT '使用码',
|
||
'addtime', // `addtime` varchar(20) DEFAULT '' COMMENT '添加时间',
|
||
'end_time', // `end_time` varchar(20) DEFAULT '' COMMENT '使用码过期时间',
|
||
'status', // `status` tinyint(1) DEFAULT '0' COMMENT '使用状态 0.未使用 1.已使用',
|
||
);
|
||
|
||
/**
|
||
* 添加(add)
|
||
* @param [array] $cr
|
||
* @return [int|bool] $add|false
|
||
*/
|
||
public function toAdd($cr)
|
||
{
|
||
if(!$cr){
|
||
return false;
|
||
}
|
||
$add = $this->add($cr);
|
||
return $add;
|
||
}
|
||
|
||
/**
|
||
* @param $map
|
||
* @param $up
|
||
* @return bool
|
||
*/
|
||
public function toSave($map,$up)
|
||
{
|
||
if(!$map || !$up){
|
||
return false;
|
||
}
|
||
$save = $this->where($map)->save($up);
|
||
return $save;
|
||
}
|
||
|
||
/**
|
||
* @param [array] $map 条件
|
||
* @param [string] $field 字段
|
||
* @return [array|bool] $find|false
|
||
*/
|
||
public function toFind($map,$field = '*')
|
||
{
|
||
if(!$map){
|
||
return false;
|
||
}
|
||
$find = $this->field($field)->where($map)->find();
|
||
return $find;
|
||
}
|
||
|
||
/**
|
||
* 多条查询(select)
|
||
* @param [array] $map 查询条件
|
||
* @param [int] $page 分页 default ''
|
||
* @param [int] $limit 数量 default ''
|
||
* @param [string] $field 字段 default '*'
|
||
* @param [string] $order 排序 default 'addtime desc'
|
||
* @return [array|bool] $select|false
|
||
*/
|
||
public function toSelect($map,$page = '',$limit = '',$field = '*',$order = 'addtime desc')
|
||
{
|
||
if(!$map){
|
||
return false;
|
||
}
|
||
if(!$page || !$limit){
|
||
$select = $this->field($field)->where($map)->order($order)->select();
|
||
}else{
|
||
$select = $this->field($field)->where($map)->page((int)$page,(int)$limit)->order($order)->select();
|
||
}
|
||
return $select;
|
||
}
|
||
|
||
/**
|
||
* 统计数量(count)
|
||
*/
|
||
public function total($map)
|
||
{
|
||
$total = $this->where($map)->count();
|
||
return $total;
|
||
}
|
||
|
||
/**
|
||
* @param array $map
|
||
* @param string $up_field
|
||
* @param int $num
|
||
* @return bool
|
||
*/
|
||
public function toSetInc($map = array(),$up_field = '',$num = 1)
|
||
{
|
||
if(!$map || !$up_field){
|
||
return false;
|
||
}
|
||
$up = $this->where($map)->setInc($up_field,$num);
|
||
return $up;
|
||
}
|
||
|
||
/**
|
||
* @param array $map
|
||
* @param string $up_field
|
||
* @param int $num
|
||
* @return bool
|
||
*/
|
||
public function toSetDec($map = array(),$up_field = '',$num = 1)
|
||
{
|
||
if(!$map || !$up_field){
|
||
return false;
|
||
}
|
||
$up = $this->where($map)->setDec($up_field,$num);
|
||
return $up;
|
||
}
|
||
|
||
/**
|
||
* 删除记录
|
||
* @param $map
|
||
* @return mixed
|
||
*/
|
||
public function deleteOrder($map)
|
||
{
|
||
$res = $this->where($map)->delete();
|
||
return $res;
|
||
}
|
||
} |