67 行
2.1 KiB
PHP
可执行文件
67 行
2.1 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Common\Model;
|
||
|
||
//[1.8.68]
|
||
|
||
/**
|
||
* 普通用户领取的优惠券记录表
|
||
* Class RetailCouponLogsModel
|
||
* @package Common\Model
|
||
*/
|
||
class RetailCouponLogsModel extends BaseModel
|
||
{
|
||
protected $tableName = 'retail_coupon_logs';
|
||
const ID = 'id'; //int(11) NOT NULL AUTO_INCREMENT,
|
||
const COUPON_ID = 'coupon_id'; //int(11) DEFAULT NULL COMMENT '用户领取的优惠券id',
|
||
const UID = 'uid'; //int(11) DEFAULT NULL COMMENT '用户id',
|
||
const STORE_ID = 'storeid'; //int(11) DEFAULT NULL COMMENT '门店id',
|
||
const MERCHANT_ID = 'merchantid'; //int(11) DEFAULT NULL COMMENT '商户id ',
|
||
const ADD_TIME = 'addtime'; //varchar(18) DEFAULT NULL COMMENT '领取时间',
|
||
const STATUS = 'status'; //tinyint(3) DEFAULT '1' COMMENT '用户领取得优惠券状态 1:未使用 2:已使用',
|
||
const USE_TIME = 'usetime'; //varchar(18) DEFAULT NULL COMMENT '使用时间',
|
||
|
||
/**
|
||
* 获取已领取的优惠券的详细情况
|
||
* @param $where
|
||
* @param $field
|
||
* @param string $order
|
||
* @param $page
|
||
* @return mixed
|
||
*/
|
||
public function getCoupon($where, $field, $order = 'c.end_time', $page = '')
|
||
{
|
||
if ($page) {
|
||
$coupon = $this->alias('l')
|
||
->join("ls_retail_coupon as c ON c.id=l.coupon_id")
|
||
->field($field)
|
||
->where($where)
|
||
->order($order)
|
||
->page($page)
|
||
->select();
|
||
} else {
|
||
$coupon = $this->alias('l')
|
||
->join("ls_retail_coupon as c ON c.id=l.coupon_id")
|
||
->field($field)
|
||
->where($where)
|
||
->order($order)
|
||
->select();
|
||
}
|
||
|
||
return $coupon;
|
||
}
|
||
|
||
/**
|
||
* 获取已领取的优惠券的数量
|
||
* @param $where
|
||
* @return mixed
|
||
*/
|
||
public function getCouponCount($where)
|
||
{
|
||
$count = $coupon = $this->alias('l')
|
||
->join("ls_retail_coupon as c ON c.id=l.coupon_id")
|
||
->where($where)
|
||
->count();
|
||
return $count;
|
||
}
|
||
} |