83 行
2.0 KiB
PHP
可执行文件
83 行
2.0 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Common\Model;
|
||
|
||
use Think\Model\ViewModel;
|
||
|
||
//[1.8.50]
|
||
|
||
/**
|
||
* 拼团商品规格视图模型
|
||
* Class RetailGroupSkuViewModel
|
||
* @package Common\Model
|
||
*/
|
||
class RetailGroupSkuViewModel extends ViewModel
|
||
{
|
||
public $viewFields = array(
|
||
'RetailSkuGoods' => array(
|
||
'_table' => 'ls_retail_sku_goods',
|
||
'store_id', 'goods_id', 'sku_id_list',
|
||
'purchase_price', 'online_price',
|
||
'shop_mem_price', 'plus_price',
|
||
'goods_img', 'goods_num',
|
||
'sku_num', 'goods_img_id', 'weight_value',
|
||
'third_goods_code'
|
||
),
|
||
'RetailSkuGroup' => array(
|
||
'_table' => 'ls_retail_sku_group',
|
||
'id', 'sku_id', 'actnum' => 'act_num', 'actprice' => 'act_price',
|
||
'_on' => 'RetailSkuGoods.id = RetailSkuGroup.sku_id',
|
||
),
|
||
|
||
);
|
||
|
||
/**
|
||
* 查询单条数据(find)
|
||
* @param array $map 条件
|
||
* @param string $field 字段 '*'
|
||
* @return array|bool $find|false
|
||
*/
|
||
public function getFind($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 getSelect($map, $field = '*', $page = '', $limit = '')
|
||
{
|
||
if (!$map) {
|
||
return false;
|
||
}
|
||
if (!$page || !$limit) {
|
||
$select = $this->field($field)->where($map)->select();
|
||
} else {
|
||
$select = $this->field($field)->where($map)->page($page, $limit)->select();
|
||
}
|
||
return $select;
|
||
}
|
||
|
||
/**
|
||
* 统计数量(count)
|
||
* @parma [array] $map 条件
|
||
* @return [array|bool] $res|false
|
||
*/
|
||
public function getCount($map)
|
||
{
|
||
if (!$map) {
|
||
return 0;
|
||
}
|
||
$count = $this->where($map)->count();
|
||
return $count ? $count : 0;
|
||
}
|
||
|
||
} |