89 行
2.8 KiB
PHP
可执行文件
89 行
2.8 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Common\Model;
|
||
//[1.2.41]
|
||
use Think\Model\ViewModel;
|
||
class BillAndSellViewModel extends ViewModel
|
||
{
|
||
public $viewFields = array(
|
||
'RetailBillOrder' => array(
|
||
'_table' => 'ls_retail_bill_order',
|
||
'id','all_money', 'pay_state','pay_type','refund_status','type', 'order_type','add_time','vid','store_id','merchant_id','cashier_id','guide_id','order_no','uid',
|
||
'refund_no','refund_money','amount_received','give_change','zero_storage','finish_time','pay_money',
|
||
),
|
||
'RetailSell' => array(
|
||
'_table' => 'ls_retail_sell',
|
||
'id'=>'sell_id', 'goods_id', 'price', 'all_money'=>'sell_all_money', 'purchase_price','original_price','vip_price','plus_vip_price',
|
||
'num','pay_state','use_integral','goods_class_id','goods_name','pricing_method','refund_num','vip_discount','attribute_state','sell_type',
|
||
'goods_type','sku_json_info','sell_number','goods_img_id','get_integral','vip_less_money','cashier_dis_money','coupon_money','integral_dis_money',
|
||
'vip_dis_money','small_changes_money','wait_refund_num','sell_id',
|
||
'_on' => 'RetailBillOrder.id = RetailSell.bill_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 = '')
|
||
{
|
||
if(!$map){
|
||
return false;
|
||
}
|
||
if(!$page || !$limit){
|
||
$select = $this->where($map)->select();
|
||
}else{
|
||
$select = $this->where($map)->page($page,$limit)->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;
|
||
}
|
||
|
||
/**
|
||
* 获取指定字段
|
||
* @param array $map 查询条件
|
||
* @param string $field 查询字段
|
||
* @param bool $bol 单条,多条
|
||
* @return array $fields
|
||
*/
|
||
public function getFieldFind($map,$field = 'RetailBillOrder.id',$bol = false)
|
||
{
|
||
if(!$map){
|
||
return array();
|
||
}
|
||
$fields = $this->where($map)->getField($field,$bol);
|
||
return $fields ? $fields : array();
|
||
}
|
||
|
||
} |