You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
4.4 KiB
130 lines
4.4 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\web\model\special;
|
|
|
|
|
|
use traits\ModelTrait;
|
|
use basic\ModelBasic;
|
|
|
|
/**
|
|
* Class SpecialSource 专题素材关联表
|
|
*/
|
|
class SpecialSource extends ModelBasic
|
|
{
|
|
use ModelTrait;
|
|
|
|
/**获取专题素材
|
|
* @param bool $special_id
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public static function getSpecialSource($special_id = false, $source_id = false, $limit = false, $page = false, $order = 0)
|
|
{
|
|
$where = array();
|
|
$data = self::where($where);
|
|
if ($special_id) {
|
|
if (is_array($special_id)) {
|
|
$data->whereIn('special_id', $special_id);
|
|
} else {
|
|
$where['special_id'] = $special_id;
|
|
$data->where($where);
|
|
}
|
|
}
|
|
if ($source_id) {
|
|
if (!is_array($source_id)) {
|
|
$where['source_id'] = $source_id;
|
|
$data->where($where);
|
|
} else {
|
|
$data->whereIn('source_id', $source_id);
|
|
}
|
|
}
|
|
if ($page) {
|
|
$data->page((int)$page, !$limit ? 10 : (int)$limit);
|
|
}
|
|
if ($order) {
|
|
$data->order('sort asc,id asc');
|
|
} else {
|
|
$data->order('sort desc,id desc');
|
|
}
|
|
return $data->select();
|
|
}
|
|
|
|
/**专栏里专题获取
|
|
* @param int $special_id
|
|
* @param bool $limit
|
|
* @param bool $page
|
|
* @param int $is_member
|
|
* @param $type
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public static function get_special_source_list($special_id = 0, $is_member = 0, $type, $limit = false, $page = false, $order = 0)
|
|
{
|
|
$where = array();
|
|
$data = self::alias('o');
|
|
if ($special_id) {
|
|
if (is_array($special_id)) {
|
|
$data = $data->whereIn('o.special_id', $special_id);
|
|
} else {
|
|
$where['o.special_id'] = $special_id;
|
|
$data = $data->where($where);
|
|
}
|
|
}
|
|
if ($type == 5) {
|
|
$data = $data->join('special s', 's.id=o.source_id')->where(['s.is_del' => 0, 's.is_show' => 1]);
|
|
if (!$is_member) {
|
|
$data = $data->where('s.is_mer_visible', 0);
|
|
}
|
|
}
|
|
if ($page) {
|
|
$data->page((int)$page, !$limit ? 10 : (int)$limit);
|
|
}
|
|
if ($order) {
|
|
$data->order('o.sort asc,o.id asc');
|
|
} else {
|
|
$data->order('o.sort desc,o.id desc');
|
|
}
|
|
return $data->select();
|
|
}
|
|
|
|
/**专栏里专题数量
|
|
* @param bool $special_id
|
|
* @param bool $source_id
|
|
* @return int|string
|
|
* @throws \think\Exception
|
|
*/
|
|
public static function get_special_source_count($special_id = 0, $is_member = 0, $type)
|
|
{
|
|
$where = array();
|
|
$data = self::alias('o');
|
|
if ($special_id) {
|
|
if (is_array($special_id)) {
|
|
$data = $data->whereIn('o.special_id', $special_id);
|
|
} else {
|
|
$where['o.special_id'] = $special_id;
|
|
$data = $data->where($where);
|
|
}
|
|
}
|
|
if ($type == 5) {
|
|
$data = $data->join('special s', 's.id=o.source_id')->where(['s.is_del' => 0, 's.is_show' => 1]);
|
|
if (!$is_member) {
|
|
$data = $data->where('s.is_mer_visible', 0);
|
|
}
|
|
}
|
|
return $data->count();
|
|
}
|
|
|
|
}
|
|
|