67 行
2.3 KiB
PHP
可执行文件
67 行
2.3 KiB
PHP
可执行文件
<?php
|
||
namespace Common\Model;
|
||
|
||
use Think\Model\ViewModel;
|
||
|
||
//[1.2.41]
|
||
class CouponGroupViewModel extends ViewModel
|
||
{
|
||
public $viewFields = array(
|
||
'RetailMCouponGroup' => array(
|
||
'_table' => 'ls_retail_mcoupon_group',
|
||
'merchantid'=>'merchant_id','coupon_group_num'=>'coupon_num','storeids','gradeids'=>'coupon_gradeid','status',
|
||
),
|
||
'RetailMCoupon' => array(
|
||
'_table' => 'ls_retail_mcoupon',
|
||
'id','addtime','needmoney','reducemoney','coupontype','daynum','starttime','endtime','type','mcoupon_group_id',
|
||
'_on' => 'RetailMCouponGroup.id = RetailMCoupon.mcoupon_group_id',
|
||
),
|
||
);
|
||
|
||
/**
|
||
* 获取单条券包优惠券(find)
|
||
* @param array $map 查询条件
|
||
* @param string|array 字段
|
||
* @return bool|array false|$find
|
||
*/
|
||
public function getFind($map,$field = '*')
|
||
{
|
||
if(!$map){
|
||
return false;
|
||
}
|
||
// 判断商户门店id(该表后删除)
|
||
if($map['RetailMCouponGroup.merchant_id']){
|
||
$map['RetailMCouponGroup.merchantid'] = $map['RetailMCouponGroup.merchant_id'];
|
||
unset($map['RetailMCouponGroup.merchant_id']);
|
||
}
|
||
$find = $this->field($field)->where($map)->find();
|
||
return $find;
|
||
}
|
||
|
||
/**
|
||
* 获取多条券包优惠券(find)
|
||
* @param array $map 查询条件
|
||
* @param int $page 分页
|
||
* @param int $limit 分页数量
|
||
* @param string $order 排序
|
||
* @param string|array 字段
|
||
* @return bool|array false|$find
|
||
*/
|
||
public function getSelect($map,$field = '*',$page = '',$limit = '',$order = 'RetailMCoupon.id desc')
|
||
{
|
||
if(!$map){
|
||
return false;
|
||
}
|
||
// 判断商户门店id(该表后删除)
|
||
if($map['RetailMCouponGroup.merchant_id']){
|
||
$map['RetailMCouponGroup.merchantid'] = $map['RetailMCouponGroup.merchant_id'];
|
||
unset($map['RetailMCouponGroup.merchant_id']);
|
||
}
|
||
if(!$page || !$limit){
|
||
$select = $this->field($field)->where($map)->page($page,$limit)->order($order)->select();
|
||
}else{
|
||
$select = $this->field($field)->where($map)->order($order)->select();
|
||
}
|
||
return $select ? $select : false;
|
||
}
|
||
} |