101 行
3.4 KiB
PHP
可执行文件
101 行
3.4 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Common\Model;
|
||
|
||
use Think\Model\ViewModel;
|
||
|
||
//[1.8.68]
|
||
class RetailSpikeOrderViewModel 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',
|
||
),
|
||
'RetailBillOnline' => array(
|
||
'_table' => 'ls_retail_bill_online',
|
||
'status', 'eval_status', 'cancel_time', 'refund_time', 'pickup_type', 'user_name', 'user_phone', 'remind_state', 'remind_time', 'pick_code', 'shopping_ids',
|
||
'delivery_type', 'cancel_delivery_status', 'delivery_fee', 'order_genre', 'remark', 'refund_delivery_state', 'delivery_record_id', 'user_address', 'delivery_time',
|
||
'receiving_goods_time', 'user_select_time',
|
||
'_on' => 'RetailBillOrder.id = RetailBillOnline.bill_id',
|
||
),
|
||
'RetailBillDiscount' => array(
|
||
'_table' => 'ls_retail_bill_discount',
|
||
'use_integral', 'coupon_money', 'vip_dis_money', 'coupon_id',
|
||
'coupon_type', 'small_changes_money', 'discount',
|
||
'cashier_dis_money', 'get_integral', 'integral_dis_money','pay_coupon_fee',
|
||
'_on' => 'RetailBillOrder.id = RetailBillDiscount.bill_id',
|
||
),
|
||
'RetailBillSpike' => array(
|
||
'_table' => 'ls_retail_bill_spike',
|
||
'spike_id', 'buy_number', 'state',
|
||
'_on' => 'RetailBillOrder.id = RetailBillSpike.bill_id',
|
||
'_type' => 'LEFT',
|
||
)
|
||
);
|
||
|
||
/**
|
||
* 查询单条数据(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)->order('add_time desc')->select();
|
||
} else {
|
||
$select = $this->field($field)->where($map)->page($page, $limit)->order('add_time desc')->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 ? intval($count) : 0;
|
||
}
|
||
|
||
/**
|
||
* 获取某个字段累加值
|
||
* @param $map
|
||
* @param $sumField
|
||
* @return float|int
|
||
*/
|
||
public function getSum($map, $sumField)
|
||
{
|
||
if (!$map || !$sumField) {
|
||
return 0;
|
||
}
|
||
$sum = $this->where($map)->sum($sumField);
|
||
return $sum ? floatval($sum) : 0;
|
||
}
|
||
} |