文件
mashangyoujiu/Application/Common/Model/TurntableModel.class.php

192 行
7.5 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Common\Model;
use Think\Model;
//[1.4.13]
/**
* 大转盘- 数据对象模型
* @author ocean
* @version LV1.0
*/
class TurntableModel extends BaseModel
{
protected $tableName = 'turntable'; // 大转盘
protected $fields = array(
'id',//int(11) NOT NULL AUTO_INCREMENT,
'turntable_name',// varchar(100) NOT NULL COMMENT '大转盘活动名',
'start_time',// int(11) NOT NULL COMMENT '活动开始时间',
'end_time',// int(11) NOT NULL COMMENT '活动结束时间',
'add_time',// int(11) NOT NULL COMMENT '活动添加时间',
'strategy',// varchar(255) NOT NULL COMMENT '活动规则',
'explain',// varchar(255) NOT NULL COMMENT '活动说明',
'merchant_id',// int(11) NOT NULL COMMENT '所属商户ID',
'status',// int(11) NOT NULL COMMENT '状态:1,可用,2,关闭,3,删除',
'max_num',// int(11) DEFAULT NULL COMMENT '每个用户最多中奖次数:0,不限制。1,1次。。。',
'day_num',// int(11) DEFAULT NULL COMMENT '每人每天最多中奖次数:0为无限制,1,1次。。。',
'shop_limit',// tinyint(1) DEFAULT '0' COMMENT '是否限制门店 默认0 不限制 1限制',
'turntable_type',// tinyint(1) DEFAULT NULL COMMENT '大转盘类型 1 公众号通知栏 2 小程序商城 3线上支付 线下支付 5任务',
'shop_id',// varchar(255) DEFAULT NULL COMMENT '参与活动门店ID ‘,’ 拼接 不限门店时为空',
'vip_limit',// tinyint(1) DEFAULT NULL COMMENT '是否会员限制 0关闭不限制 1开启 仅选中的会员等级可参与',
'vip_level',// varchar(100) DEFAULT NULL COMMENT '会员限制开启时 所选会员等级ID 多个'',''拼接',
'money_limit',// float(11,2) DEFAULT NULL COMMENT '线下支付转盘消费限制的金额数',
'task_type',// tinyint(1) DEFAULT NULL COMMENT '任务大转盘的任务形式 1每笔消费 2单月累计',
'one_consume',// float(11,2) DEFAULT NULL COMMENT '每笔消费或单次消费金额',
'one_month_num',// int(11) DEFAULT NULL COMMENT '单月累计消费数',
'prize_total'// int(11) DEFAULT NULL COMMENT '活动奖品总数',
);
/*
* 获取一条大转盘活动详情
*/
public function getTurntableInfo($id)
{
$one = $this
->field('id,turntable_name,start_time,end_time,strategy,explain,status,max_num,day_num,shop_limit,turntable_type,shop_id,vip_limit,vip_level,money_limit,task_type,one_consume,one_month_num')
->find($id);
return $one;
}
/*
* 获取商户历史大转盘数据
* param $merchant_id 商户ID
* param $title 活动名
* param $type '大转盘类型 1 公众号通知栏 2 小程序商城 3线上支付 线下支付 5任务',
* */
public function getMerchantList($merchant_id, $title, $type, $page, $page_size)
{
$w['merchant_id'] = $merchant_id;
if (!empty($title)) {
$w['turntable_name'] = '%' . $title . '%';
}
if (!empty($type)) {
$w['turntable_type'] = $type;
}
$list = $this
->field('id,turntable_name,start_time,end_time,add_time,prize_total')
->where($w)
->page($page, $page_size)
->order('add_time desc')
->select();
return $list;
}
/*
* 获取商户历史大转盘数据记录总数
* param $where 查询条件
* */
public function getTurntableCount($merchant_id, $title, $type)
{
$w['merchant_id'] = $merchant_id;
if (!empty($title)) {
$w['turntable_name'] = '%' . $title . '%';
}
if (!empty($type)) {
$w['turntable_type'] = $type;
}
$list = $this
->where($w)
->count();
return $list;
}
/*
* 获取大转盘活动列表
* param $merchant_id 商户ID
* param $title 搜索字段
* param $status 活动状态 1,可用,2,关闭,
* param $turntable_type 活动类型 1 公众号通知栏 2 小程序商城 3线上支付 线下支付 5任务
* param $start_time 开始时间
* param $end_time 结束时间
* param $page 当前页数
* param $page_size 每页记录数,
* */
public function getTurntableList($merchant_id, $title, $status, $turntable_type, $start_time, $end_time, $page, $page_size)
{
$where['merchant_id'] = $merchant_id;
$where['status'] = ['neq', 3];
if (!empty($status)) {
//活动状态 1,未开始,2,进行中,3已结束
$time = time();
switch ($status) {
case 1:
$where['start_time'] = ['gt', $time];
break;
case 2:
$where['start_time'] = ['elt', $time];
$where['end_time'] = ['egt', $time];
break;
case 3:
$where['end_time'] = ['lt', $time];
break;
}
$where['status'] = $status;
}
if (!empty($turntable_type)) {
$where['turntable_type'] = $turntable_type;
}
if (!empty($start_time) and !empty($end_time)) {
$where['add_time'] = array('between', $start_time . ',' . $end_time);
}
if (!empty($title)) {
// $map['a.username'] = array('like', '%'.$title.'%');
// $map['a.phone'] = array('like', '%'.$title.'%');
// $map['_logic'] = 'or';
// $where['_complex'] = $map;
$where['turntable_name'] = ['like', '%' . $title . '%'];
}
$list = $this
->field('id,turntable_name,start_time,end_time,add_time,status,turntable_type,shop_limit,shop_id,prize_total')
->where($where)
->page($page, $page_size)
->order('add_time desc')
->select();
return $list;
}
/*
* 获取大转盘活动列表总记录数
* param $merchant_id 商户ID
* param $title 搜索字段
* param $status 活动状态 1,可用,2,关闭,
* param $turntable_type 活动类型 1 公众号通知栏 2 小程序商城 3线上支付 线下支付 5任务
* param $start_time 开始时间
* param $end_time 结束时间
* param $page 当前页数
* param $page_size 每页记录数,
* */
public function getTurntableListCount($merchant_id, $title, $status, $turntable_type, $start_time, $end_time)
{
$where['merchant_id'] = $merchant_id;
$where['status'] = ['neq', 3];
if (!empty($status)) {
$where['status'] = $status;
}
if (!empty($turntable_type)) {
$where['turntable_type'] = $turntable_type;
}
if (!empty($start_time) and !empty($end_time)) {
$where['add_time'] = array('between', $start_time . ',' . $end_time);
}
if (!empty($title)) {
// $map['a.username'] = array('like', '%'.$title.'%');
// $map['a.phone'] = array('like', '%'.$title.'%');
// $map['_logic'] = 'or';
// $where['_complex'] = $map;
$where['turntable_name'] = ['like', '%' . $title . '%'];
}
$list = $this
->field('id,turntable_name,start_time,end_time,add_time,status,turntable_type,shop_limit,shop_id,prize_total')
->where($where)
->count();
return $list;
}
}