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

77 行
2.2 KiB
PHP
可执行文件

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

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

<?php
namespace Common\Model;
use Think\Model\ViewModel;
//[1.8.20]
class SubCardViewModel extends ViewModel
{
public $viewFields = array(
'SubCard' => array(
'_table' => 'ls_retail_sub_card',
'name', 'use_type', 'frequency', 'limit' => 'limit_num', 'give_num', 'time_interval', 'end_time', 'gallery_id', 'image',
'effective_start', 'effective_end', 'introduce', 'card_type', 'bag_id', 'effective_time_type', 'effective_day',
),
'VipCard' => array(
'_table' => 'ls_retail_vip_card',
'id', 'sub_card_id', 'card_bag_id', 'use_num', 'addtime', 'merchantid', 'status', 'state', 'start_time', 'end_time',
'_on' => 'VipCard.sub_card_id = SubCard.id'
),
'Vip' => array(
'_table' => 'ls_retail_vip',
'mobile_phone', 'name' => 'vip_name', 'nickname', 'card_key',
'_on' => 'VipCard.vip_id = Vip.id'
),
);
/**
* 查询单条数据(find)
* @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 分页
* @param [int] $limit 数量
* @return [array|bool] $res|false
*/
public function toSelect($map, $page = '', $limit = '', $field = '*', $order = 'VipCard.id 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($page, $limit)->order($order)->select();
}
return $select;
}
/**
* 统计数量(count)
* @parma [array] $map 条件
* @return [array|bool] $res|false
*/
public function total($map)
{
if (!$map) {
return false;
}
$total = $this->where($map)->count();
return $total;
}
}