init: 项目初始代码
This commit is contained in:
28
app/index/model/About.php
Normal file
28
app/index/model/About.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class About extends BaseModel
|
||||
{
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array|string[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAboutBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
}
|
||||
23
app/index/model/AdvertisePage.php
Normal file
23
app/index/model/AdvertisePage.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 广告页模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class AdvertisePage extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'language_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'name' =>'string',
|
||||
'sort' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
25
app/index/model/AdvertiseSpace.php
Normal file
25
app/index/model/AdvertiseSpace.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class AdvertiseSpace extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'language_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'name' =>'string',
|
||||
'advertise_page_id'=>'int',
|
||||
'max_num' =>'int',
|
||||
'width' =>'int',
|
||||
'height' =>'int',
|
||||
'sort' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
}
|
||||
31
app/index/model/Advertisement.php
Normal file
31
app/index/model/Advertisement.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 广告模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Advertisement extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'language_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'advertise_space_id' =>'int',
|
||||
'command' =>'string',
|
||||
'name' =>'string',
|
||||
'image' =>'string',
|
||||
'url' =>'string',
|
||||
'start_time' =>'int',
|
||||
'stop_time' =>'int',
|
||||
'play_order' =>'int',
|
||||
'sort' =>'int',
|
||||
'status' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
20
app/index/model/Attribute.php
Normal file
20
app/index/model/Attribute.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Attribute extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'language_id' =>'int',
|
||||
'site_id' => 'int',
|
||||
'name' =>'string',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
}
|
||||
247
app/index/model/BaseModel.php
Normal file
247
app/index/model/BaseModel.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 模型基类
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class BaseModel extends Model
|
||||
{
|
||||
protected $autoWriteTimestamp = true;
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @param array $data 查询条件
|
||||
* @param mixed $simple 模糊搜索条件
|
||||
* @param mixed $focus 精准搜索条件
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAllList($data,$simple = null,$focus = null,$sort = null)
|
||||
{
|
||||
$fields = array_keys($this->schema);
|
||||
$collection = $this->where(function ($query) use ($data,$fields,$simple,$focus) {
|
||||
//模糊查询条件
|
||||
if (!empty($simple)) {
|
||||
foreach ($simple as $key => $item) {
|
||||
if (in_array($key,$fields)) {
|
||||
$query->where($key,'like',"%".$item."%");
|
||||
}
|
||||
}
|
||||
}
|
||||
//精准查询
|
||||
if (!empty($focus)) {
|
||||
foreach ($focus as $key => $item) {
|
||||
if (in_array($key,$fields)) {
|
||||
$query->where($key,$item);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (isset($data['page']) && isset($data['size'])) {
|
||||
$count = $collection->count() ?: 0;
|
||||
$page = $collection->limit($data['size'])->page($data['page'])->order($sort)->select()->toArray();
|
||||
return ['page'=>$page,'count'=>$count];
|
||||
} else {
|
||||
return $collection->order($sort)->select()->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getInfo($data)
|
||||
{
|
||||
$result = $this->find($data['id']);
|
||||
return $result ? $result->toArray() : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加数据
|
||||
* @param $data
|
||||
* @return bool
|
||||
*/
|
||||
public function addData($data)
|
||||
{
|
||||
return $this->save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function editData($data)
|
||||
{
|
||||
$result = $this->find($data['id']);
|
||||
return $result && $result->save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function delData($id)
|
||||
{
|
||||
$result = $this->find($id['id']);
|
||||
if ($result) {
|
||||
return $result->delete();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询对应ID有没有子项目,比如菜单类,通过ID查询子菜单是否存在
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function checkChildren($data)
|
||||
{
|
||||
$result = $this->where('pid',$data['id'])->find();
|
||||
return (bool)$result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量编辑数据
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function batchEditData($data)
|
||||
{
|
||||
$result = $result1 = true;
|
||||
foreach ($data as $item) {
|
||||
$models = $this->find($item['id']);
|
||||
if ($models) {
|
||||
$result1 = $models->save($item);
|
||||
}
|
||||
$result = $result && $result1;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除数据
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function batchDelData($data)
|
||||
{
|
||||
return $this->destroy($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新一条数据
|
||||
* @return array|Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getLatestData($data)
|
||||
{
|
||||
return $this->where($data)->order($this->pk,'desc')->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言名称
|
||||
* @param $id
|
||||
* @return string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getLanguageName($id)
|
||||
{
|
||||
$site = Site::find($id);
|
||||
$result = Language::find($site['language_id']);
|
||||
return $result ? $result['name'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取国家名称
|
||||
* @param $id
|
||||
* @return mixed|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getCountryName($id)
|
||||
{
|
||||
$result = Country::find($id);
|
||||
return $result ? $result['zh'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ID获取广告位名称
|
||||
* @param $id
|
||||
* @return mixed|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAdvertiseSpaceNameById($id)
|
||||
{
|
||||
$result = AdvertiseSpace::find($id);
|
||||
return $result ? $result['name'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过广告页ID,获取对应的BANNER
|
||||
* @param $languageId
|
||||
* @param $spaceId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getBanner($languageId,$spaceId):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'advertise_space_id' => $spaceId
|
||||
];
|
||||
return Advertisement::field(['id','image'])->where($where)->select()->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取浏览器标签
|
||||
* @param int $languageId
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getMetaTitle(int $languageId,string $type) : array
|
||||
{
|
||||
$result = SystemConfig::field('name,value')->where('site_id',$languageId)->where('pos',$type)->column('value','name');
|
||||
if (empty($result)) {
|
||||
return SystemConfig::field('name,value')->where('site_id',$languageId)->where('pos','common')->column('value','name');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
75
app/index/model/Brand.php
Normal file
75
app/index/model/Brand.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Brand extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 获取首页品牌矩阵
|
||||
* @param $data
|
||||
* @param $languageId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getBrandList($languageId,$data):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'status' => 0,
|
||||
];
|
||||
if (isset($data['brand_type_id']) && $data['brand_type_id'] != 0) {
|
||||
$where['brand_type_id'] = $data['brand_type_id'];
|
||||
}
|
||||
return $this->where($where)->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品牌矩阵分类
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getBrandTypeList($languageId,$data):array
|
||||
{
|
||||
$result = BrandType::where('site_id',$languageId)->select()->toArray();
|
||||
if (!empty($result)) {
|
||||
$arr[] = [
|
||||
'id' => 0,
|
||||
'name' => '全部',
|
||||
];
|
||||
$result = array_merge($arr,$result);
|
||||
foreach ($result as $key => $item) {
|
||||
$result[$key]['is_display'] = !empty($data) ? isset($data['brand_type_id']) && $data['brand_type_id'] == $item['id'] : $item['id'] == 0;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array|string[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getBrandBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
|
||||
}
|
||||
24
app/index/model/BrandType.php
Normal file
24
app/index/model/BrandType.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 文章分类
|
||||
*
|
||||
*/
|
||||
class BrandType extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'name' =>'string',
|
||||
'desc' =>'string',
|
||||
'icon' =>'string',
|
||||
'sort' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
14
app/index/model/Common.php
Normal file
14
app/index/model/Common.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Common extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
14
app/index/model/Concept.php
Normal file
14
app/index/model/Concept.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Concept extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
28
app/index/model/Contact.php
Normal file
28
app/index/model/Contact.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Contact extends BaseModel
|
||||
{
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array|string[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAboutBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
}
|
||||
305
app/index/model/Goods.php
Normal file
305
app/index/model/Goods.php
Normal file
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
|
||||
use app\api\model\GoodsAttribute;
|
||||
use app\api\model\GoodsBuyNow;
|
||||
use app\api\model\GoodsConnect;
|
||||
use app\api\model\GoodsImages;
|
||||
use app\api\model\GoodsSoftManual;
|
||||
use think\facade\Env;
|
||||
|
||||
/**
|
||||
* 商品模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Goods extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'language_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'name' =>'string',
|
||||
'main_img' =>'string',
|
||||
'model_number' =>'string',
|
||||
'goods_category_id' =>'int',
|
||||
'price' =>'int',
|
||||
'is_new' =>'int',
|
||||
'is_discount' =>'int',
|
||||
'details' =>'string',
|
||||
'title' =>'string',
|
||||
'keywords' =>'string',
|
||||
'description' =>'string',
|
||||
'sort' =>'int',
|
||||
'status' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
/**
|
||||
* 商品链接关联模型
|
||||
*/
|
||||
public function GoodsBuyNow()
|
||||
{
|
||||
return $this->hasMany(GoodsBuyNow::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品关联商品
|
||||
*/
|
||||
public function GoodsConnect()
|
||||
{
|
||||
return $this->hasMany(GoodsConnect::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品手册关联模型
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function GoodsSoftManual()
|
||||
{
|
||||
return $this->hasMany(GoodsSoftManual::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品主图关联模型
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function GoodsImages()
|
||||
{
|
||||
return $this->hasMany(GoodsImages::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品属性关联
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function goodsAttr()
|
||||
{
|
||||
return $this->hasMany(GoodsAttribute::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父级分类
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getFirstLeveCategory($data)
|
||||
{
|
||||
return GoodsCategory::where('pid',0)->where('status',0)->where('site_id',1)->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二级分类
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getSecondLevelCategory($data)
|
||||
{
|
||||
return GoodsCategory::where('pid',$data['cate1'])->where('status',0)->where('site_id',1)->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取三级分类
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getThreeLevelCategory($data)
|
||||
{
|
||||
return GoodsCategory::where('pid',$data['cate2'])->where('status',0)->where('site_id',1)->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有子分类
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAllSonCategory($id)
|
||||
{
|
||||
$arr = GoodsCategory::where('status',0)->where('site_id',1)->order('sort','desc')->select()->toArray();
|
||||
$feeds = category_to_all_children_id($arr,$id);
|
||||
|
||||
return $feeds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @param array $data 查询条件
|
||||
* @return \think\Paginator
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getGoodsList($data,$qstring)
|
||||
{
|
||||
$qs = explode('index/goods/index?',$qstring);
|
||||
parse_str($qs[1],$out);
|
||||
|
||||
$query = $queryOther = [];
|
||||
$forth = [
|
||||
'is_all','is_recommend','is_hot','is_new'
|
||||
];
|
||||
foreach ($forth as $f) {
|
||||
if (in_array($f,array_keys($data))) {
|
||||
$queryOther[$f] = $data[$f];
|
||||
}
|
||||
}
|
||||
// 判断是否选择了分类
|
||||
for ($i=1;$i<=3;$i++) {
|
||||
if (isset($data['cate'.$i])) {
|
||||
// 如果是3级分类
|
||||
if ($i === 3 && $data['cate'.$i] != 0) {
|
||||
$query['goods_category_id'] = $data['cate'.$i];
|
||||
}
|
||||
// 如果是2级分类
|
||||
if ($i === 2 && $data['cate'.$i] != 0) {
|
||||
$arr = array_column($this->getThreeLevelCategory(['cate2'=>$data['cate2']]),'id');
|
||||
array_push($arr,(int)$data['cate2']);
|
||||
$query['goods_category_id'] = $arr;
|
||||
}
|
||||
// 如果是1级分类
|
||||
if ($i === 1 && $data['cate'.$i] != 0) {
|
||||
$query['goods_category_id'] = $this->getAllSonCategory($data['cate1']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$collection = $this->where('status',0);
|
||||
if (isset($data['model_number'])) {
|
||||
$collection = $collection->where('model_number','like','%'.$data['model_number'].'%')->whereOr('name','like','%'.$data['model_number'].'%')->whereOr('title','like','%'.$data['model_number'].'%');
|
||||
} else {
|
||||
//查询
|
||||
if (!empty($queryOther) && !isset($queryOther['is_all'])) {
|
||||
$collection = $collection->where($queryOther);
|
||||
}
|
||||
|
||||
if (!empty($query) && is_array($query['goods_category_id'])) {
|
||||
// 表示是非3级分类
|
||||
$collection = $collection->whereIn('goods_category_id',$query['goods_category_id']);
|
||||
} else {
|
||||
$collection = $collection->where($query);
|
||||
}
|
||||
}
|
||||
|
||||
$pageNum = SystemConfig::where('pos','goods')->where('name','list_num')->find()->toArray();
|
||||
$listRow = [
|
||||
'query' => $out, //url额外参数
|
||||
'fragment' => '', //url锚点
|
||||
'var_page' => 'page', //分页变量
|
||||
'list_rows' => (int)$pageNum['value']??4, //每页数量
|
||||
];
|
||||
|
||||
//return $collection->order('create_time','desc')->paginate($listRow);
|
||||
$resutl = $collection->order('create_time','desc')->paginate($listRow);
|
||||
//dump($this->getLastSql());
|
||||
return $resutl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过商品ID,查出所有父级分类
|
||||
*/
|
||||
public function getCategoryToParent($id)
|
||||
{
|
||||
$goods = $this->where('id',$id)->find()->toArray();
|
||||
$data = GoodsCategory::where('status',0)->order('sort','desc')->select()->toArray();
|
||||
$arr = category_to_all_pid($data,$goods['goods_category_id']);
|
||||
$arr = GoodsCategory::whereIn('id',$arr)->order('sort','desc')->select()->toArray();
|
||||
|
||||
$url = '';
|
||||
for ($i=0;$i<=count($arr)-1;$i++) {
|
||||
$cate = 'cate'.($i + 1);
|
||||
$url .= http_build_query([$cate =>$arr[$i]['id']])."&";
|
||||
$arr[$i]['qs'] = rtrim($url,'&');
|
||||
}
|
||||
$arr[0]['qs'] = 'cate1='.$arr[0]['id'];
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function getInfo($data)
|
||||
{
|
||||
$result = $this->where('status',0)->find($data['id']);
|
||||
if ($result) {
|
||||
$goodsAttribute = $result->goodsAttr()->select()->toArray();
|
||||
$attr = $img = [];
|
||||
if ($goodsAttribute) {
|
||||
foreach ($goodsAttribute as $item) {
|
||||
$attr[] = array_merge($item,['attribute_name'=>Attribute::where('id',$item['attribute_id'])->value('name')]);
|
||||
}
|
||||
}
|
||||
$images = $result->goodsImages()->select()->toArray();
|
||||
$connect = $result->goodsConnect()->select()->toArray();
|
||||
if (!empty($connect)) {
|
||||
foreach ($connect as $item) {
|
||||
$res = $this->where('status',0)->find($item['connect_good_id']);
|
||||
if ($item['connect_good_id'] != 0 && $item['connect_good_id'] != '' && $res) {
|
||||
$tmp = $this->where('status',0)->find($item['connect_good_id'])->toArray();
|
||||
$tmp['main_img'] = Env::get('QINIU.cdn').$tmp['main_img'];
|
||||
$connectData[] = array_merge($item,$tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
//处理相关下载
|
||||
$relate = $result->GoodsSoftManual()->select()->toArray();
|
||||
$newRelate = [];
|
||||
foreach ($relate as $item) {
|
||||
$soft = SoftManual::where('status',0)->find($item['soft_manual_id']);
|
||||
if ($soft) {
|
||||
$btn = SoftManualBtn::where('soft_manual_id',$item['soft_manual_id'])->select()->toArray();
|
||||
$soft = $soft->toArray();
|
||||
$soft['btn'] = $btn;
|
||||
$newRelate[] = array_merge($soft,[]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($newRelate)) {
|
||||
foreach ($newRelate as $key => $item) {
|
||||
$newRelate[$key]['image'] = Env::get('QINIU.cdn').$item['image'];
|
||||
foreach ($item['btn'] as $item1) {
|
||||
$tmp = [
|
||||
'url' => Env::get('QINIU.cdn').$item1['url'],
|
||||
'name' => $item1['file_name']
|
||||
];
|
||||
$arr[$item1['btn_tips']][] = array_merge($tmp,[]);
|
||||
}
|
||||
unset($newRelate[$key]['btn']);
|
||||
$newRelate[$key]['getSoftBtn'] = $arr;
|
||||
$arr = [];
|
||||
}
|
||||
}
|
||||
//处理图片
|
||||
$result['main_img'] = Env::get('QINIU.cdn').$result['main_img'];
|
||||
// $img[0] = ['image'=>$result['main_img']];
|
||||
foreach ($images as $item) {
|
||||
$img[] = ['image'=>Env::get('QINIU.cdn').$item['image']];
|
||||
}
|
||||
//
|
||||
$categoryName = GoodsCategory::find($result['goods_category_id']);
|
||||
$result['category_name'] = $categoryName['name'];
|
||||
//buynow
|
||||
$result['buy_now'] = $result->goodsBuyNow()->select()->toArray();
|
||||
$result['goods_attribute'] = $attr;
|
||||
$result['relate_download'] = $newRelate;
|
||||
$result['images'] = empty($img) ? [['image'=>$result['main_img']]] : $img;
|
||||
$result['connect'] = empty($connectData) ? [] : $connectData;
|
||||
|
||||
return $result->toArray();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
27
app/index/model/GoodsCategory.php
Normal file
27
app/index/model/GoodsCategory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class GoodsCategory extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'language_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'name' =>'int',
|
||||
'desc' =>'int',
|
||||
'pid' =>'int',
|
||||
'icon' =>'int',
|
||||
'sort' =>'int',
|
||||
'status' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
137
app/index/model/Index.php
Normal file
137
app/index/model/Index.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
class Index extends BaseModel
|
||||
{
|
||||
protected $name = 'advertisement';
|
||||
|
||||
/**
|
||||
* 首页banner
|
||||
* @param $data
|
||||
* @param $languageId
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getIndexBanner($languageId,$data):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'advertise_space_id' => 1
|
||||
];
|
||||
return $this->where($where)->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页banner
|
||||
* @param $data
|
||||
* @param $languageId
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getIndexBannerMobile($languageId,$data):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'advertise_space_id' => 9
|
||||
];
|
||||
return $this->where($where)->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页品牌矩阵
|
||||
* @param $data
|
||||
* @param $languageId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getIndexGoodsCategoryList($languageId,$data):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'status' => 0,
|
||||
'pid' => 0
|
||||
];
|
||||
return GoodsCategory::where($where)->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $inputData
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getIndexGoodsRecommandList($languageId,$inputData):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'status' => 0,
|
||||
'is_recommend' => 0
|
||||
];
|
||||
$isNew = SystemConfig::where('pos','index')->where('name','is_new_num')->find()->toArray();
|
||||
return Goods::where($where)->order('sort','desc')->page(0)->limit((int)$isNew['value'])->select()->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $languageId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getGoodsBanner($languageId):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
];
|
||||
$newData = SystemConfig::field('name,pos,value,image,type')->where($where)->where('pos','index_goods')->column('pos,value,image,type','name');
|
||||
$ret = [
|
||||
'goods_one' => [
|
||||
'value' => '',
|
||||
'image' => ''
|
||||
],
|
||||
'goods_two' => [
|
||||
'value' => '',
|
||||
'image' => ''
|
||||
],
|
||||
'goods_three' => [
|
||||
'value' => '',
|
||||
'image' => ''
|
||||
],
|
||||
'goods_four' => [
|
||||
'value' => '',
|
||||
'image' => ''
|
||||
],
|
||||
];
|
||||
if (!empty($newData)) {
|
||||
foreach ($newData as $key => $value) {
|
||||
if ($value['image']) {
|
||||
$images = json_decode($value['image'],true);
|
||||
$newData[$key]['value'] = $value['value']??'';
|
||||
$newData[$key]['image'] = $images[0]['image']??'';
|
||||
} else {
|
||||
$newData[$key]['value'] = '';
|
||||
$newData[$key]['image'] = '';
|
||||
}
|
||||
}
|
||||
return $newData;
|
||||
} else {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
69
app/index/model/Join.php
Normal file
69
app/index/model/Join.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Join extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 获取首页品牌矩阵
|
||||
* @param $data
|
||||
* @param $languageId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getJoinList($languageId,$data):array
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'status' => 0,
|
||||
];
|
||||
if (isset($data['join_type_id']) && $data['join_type_id'] != 0) {
|
||||
$where['join_type_id'] = $data['join_type_id'];
|
||||
}
|
||||
return $this->where($where)->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品牌矩阵分类
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getJoinTypeList($languageId,$data):array
|
||||
{
|
||||
$result = JoinType::where('site_id',$languageId)->select()->toArray();
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $key => $item) {
|
||||
$result[$key]['is_display'] = !empty($data) ? isset($data['join_type_id']) && $data['join_type_id'] == $item['id'] : $item['id'] == 0;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array|string[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getJoinBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
}
|
||||
24
app/index/model/JoinType.php
Normal file
24
app/index/model/JoinType.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 文章分类
|
||||
*
|
||||
*/
|
||||
class JoinType extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'name' =>'string',
|
||||
'desc' =>'string',
|
||||
'icon' =>'string',
|
||||
'sort' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
41
app/index/model/Language.php
Normal file
41
app/index/model/Language.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
|
||||
/**
|
||||
* 语言包模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Language extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'name' => 'string',
|
||||
'code' => 'string',
|
||||
'icon' => 'string',
|
||||
'locale' => 'string',
|
||||
'coin' => 'string',
|
||||
'sort' => 'int',
|
||||
'status' => 'int',
|
||||
'create_time' => 'int',
|
||||
'update_time' => 'int'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @param array $data 查询条件
|
||||
* @param mixed $simple 模糊搜索条件
|
||||
* @param mixed $focus 精准搜索条件
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAllList($data,$simple = null,$focus = null,$sort = null)
|
||||
{
|
||||
$lang = Site::where('platform_id',$data['platform_id'])->column('language_id');
|
||||
return $this->order($sort)->where('id','in',$lang)->select()->toArray();
|
||||
}
|
||||
}
|
||||
83
app/index/model/Navigator.php
Normal file
83
app/index/model/Navigator.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
use think\helper\Str;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Navigator extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'platform_id' => 'int',
|
||||
'site_id' => 'int',
|
||||
'language_id' => 'int',
|
||||
'pid' => 'int',
|
||||
'name' => 'string',
|
||||
'desc' => 'string',
|
||||
'icon' => 'string',
|
||||
'link' => 'string',
|
||||
'sort' => 'int',
|
||||
'status' => 'int',
|
||||
'is_top' => 'int',
|
||||
'is_foot' => 'int',
|
||||
'create_time' => 'int',
|
||||
'update_time' => 'int'
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取首页导航菜单
|
||||
* @param $language_id
|
||||
* @param $platform_id
|
||||
* @param $controller
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getNavInfo($language_id,$platform_id,$controller):array
|
||||
{
|
||||
$result = $this->where(function($query) use ($language_id,$platform_id) {
|
||||
$query->where('is_top',0)->where('status',0)->where('platform_id',$platform_id);
|
||||
})->order('sort','desc')->select()->toArray();
|
||||
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $key => $item) {
|
||||
if (isset($controller) && $controller != '') {
|
||||
$url = explode('/',$item['url']);
|
||||
if (count($url) <= 2 && $controller == 'Index') {
|
||||
$result[$key]['is_show'] = true;
|
||||
} else {
|
||||
if (count($url) > 2) {
|
||||
if ($url[2] == Str::snake($controller)) {
|
||||
$result[$key]['is_show'] = true;
|
||||
} else {
|
||||
$result[$key]['is_show'] = false;
|
||||
}
|
||||
} else {
|
||||
$result[$key]['is_show'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页导航菜单
|
||||
* @param $language_id
|
||||
* @param $platform_id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getFootNavInfo($language_id,$platform_id):array
|
||||
{
|
||||
return $this->where(function($query) use ($language_id,$platform_id) {
|
||||
$query->where('is_foot',0)->where('status',0)->where('platform_id',$platform_id);
|
||||
})->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
}
|
||||
105
app/index/model/News.php
Normal file
105
app/index/model/News.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
|
||||
/**
|
||||
* 新闻模型
|
||||
*/
|
||||
class News extends BaseModel
|
||||
{
|
||||
protected $connection = 'yc';
|
||||
|
||||
/**
|
||||
* 获取新闻动态矩阵
|
||||
* @param $data
|
||||
* @param $languageId
|
||||
* @return \think\Paginator
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getNewsList($languageId,$data)
|
||||
{
|
||||
$where = [
|
||||
'site_id' => $languageId,
|
||||
'status' => 0,
|
||||
];
|
||||
if (isset($data['news_type_id']) && $data['news_type_id'] != 0) {
|
||||
$where['news_type_id'] = $data['news_type_id'];
|
||||
}
|
||||
|
||||
$listRow = [
|
||||
'query' => isset($data['news_type_id']) ? ['news_type_id'=>$data['news_type_id']??0] : [], //url额外参数
|
||||
'fragment' => '', //url锚点
|
||||
'var_page' => 'page', //分页变量
|
||||
'list_rows' => $data['size']??6, //每页数量
|
||||
];
|
||||
return $this->where($where)->order('create_time','desc')->paginate($listRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品牌矩阵分类
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getNewsTypeList($languageId,$data):array
|
||||
{
|
||||
$result = NewsType::where('site_id',$languageId)->select()->toArray();
|
||||
if (!empty($result)) {
|
||||
$arr[] = [
|
||||
'id' => 0,
|
||||
'name' => '全部新闻',
|
||||
];
|
||||
$result = array_merge($arr,$result);
|
||||
foreach ($result as $key => $item) {
|
||||
$result[$key]['is_display'] = !empty($data) ? isset($data['news_type_id']) && $data['news_type_id'] == $item['id'] : $item['id'] == 0;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array|string[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getNewsBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一篇,下一篇
|
||||
*/
|
||||
public function getPreNexInfo($data)
|
||||
{
|
||||
if (isset($data['id'])) {
|
||||
$info = $this->find($data['id'])->toArray();
|
||||
// 下一条
|
||||
$next = $this->field(['id','title'])->where('news_type_id',$info['news_type_id'])->where('id','>',$data['id'])->limit(1)->select()->toArray();
|
||||
// 上一条
|
||||
$pre = $this->field(['id','title'])->where('news_type_id',$info['news_type_id'])->where('id','<',$data['id'])->limit(1)->select()->toArray();
|
||||
|
||||
return [
|
||||
'pre' => empty($pre) ? [] : $pre[0],
|
||||
'next' => empty($next) ? [] : $next[0]
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
26
app/index/model/NewsType.php
Normal file
26
app/index/model/NewsType.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 文章分类
|
||||
*
|
||||
*/
|
||||
class NewsType extends BaseModel
|
||||
{
|
||||
protected $connection = 'yc';
|
||||
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'name' =>'string',
|
||||
'desc' =>'string',
|
||||
'icon' =>'string',
|
||||
'sort' =>'int',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
40
app/index/model/Platform.php
Normal file
40
app/index/model/Platform.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 平台模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Platform extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'vi_color1' => 'string',
|
||||
'vi_color2' => 'string',
|
||||
'vi_color3' => 'string',
|
||||
'language_id' => 'int',
|
||||
'coin_id' => 'int',
|
||||
'name' => 'string',
|
||||
'desc' => 'string',
|
||||
'icon' => 'string',
|
||||
'sort' => 'int',
|
||||
'status' => 'int',
|
||||
'create_time' => 'int',
|
||||
'update_time' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $platformName
|
||||
* @return int
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getPlatformId(string $platformName):int
|
||||
{
|
||||
$result = $this->where('name',$platformName)->find();
|
||||
return $result ? $result->id : 0;
|
||||
}
|
||||
}
|
||||
27
app/index/model/Product.php
Normal file
27
app/index/model/Product.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Product extends BaseModel
|
||||
{
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array|string[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getProductBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
}
|
||||
64
app/index/model/ReCenter.php
Normal file
64
app/index/model/ReCenter.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ReCenter extends BaseModel
|
||||
{
|
||||
protected $name = 'resource';
|
||||
|
||||
/**
|
||||
* 获取页面banner
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getResourceBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getResourceList($languageId,$data):array
|
||||
{
|
||||
return $this->where('site_id',$languageId)->where('status',0)->order('sort','desc')->select()->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取上一篇,下一篇
|
||||
*/
|
||||
public function getPreNexInfo($data)
|
||||
{
|
||||
if (isset($data['id'])) {
|
||||
// 下一条
|
||||
$next = $this->field(['id','title'])->where('id','>',$data['id'])->limit(1)->select()->toArray();
|
||||
// 上一条
|
||||
$pre = $this->field(['id','title'])->where('id','<',$data['id'])->limit(1)->select()->toArray();
|
||||
|
||||
return [
|
||||
'pre' => empty($pre) ? [] : $pre[0],
|
||||
'next' => empty($next) ? [] : $next[0]
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
20
app/index/model/Site.php
Normal file
20
app/index/model/Site.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 站点模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Site extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 获取当前品牌对应站点的域名
|
||||
* @param int $platformId
|
||||
* @return array
|
||||
*/
|
||||
public function getDomainsList(int $platformId):array
|
||||
{
|
||||
return $this->where('platform_id',$platformId)->column(['domain','language_id']);
|
||||
}
|
||||
}
|
||||
126
app/index/model/SoftManual.php
Normal file
126
app/index/model/SoftManual.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
|
||||
use app\api\model\FileType;
|
||||
use think\facade\Env;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class SoftManual extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'platform_id' => 'int',
|
||||
'site_id' => 'int',
|
||||
'language_id' => 'int',
|
||||
'file_type_id' => 'int',
|
||||
'name' => 'string',
|
||||
'introduce' => 'string',
|
||||
'support' => 'string',
|
||||
'os' => 'string',
|
||||
'download_count'=> 'int',
|
||||
'status' => 'int',
|
||||
'create_time' => 'int',
|
||||
'update_time' => 'int',
|
||||
];
|
||||
|
||||
public function getSoftBtn()
|
||||
{
|
||||
return $this->hasMany(SoftManualBtn::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @param array $data 查询条件
|
||||
* @param mixed $simple 模糊搜索条件
|
||||
* @param mixed $focus 精准搜索条件
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAllList($data,$simple = null,$focus = null,$sort = null)
|
||||
{
|
||||
$fields = array_keys($this->schema);
|
||||
$collection = $this->where(function ($query) use ($data,$fields,$simple,$focus) {
|
||||
//模糊查询条件
|
||||
if (!empty($simple)) {
|
||||
foreach ($simple as $key => $item) {
|
||||
if (in_array($key,$fields)) {
|
||||
$query->whereOr($key,'like',"%".$item."%");
|
||||
}
|
||||
}
|
||||
}
|
||||
//精准查询
|
||||
if (!empty($focus)) {
|
||||
foreach ($focus as $key => $item) {
|
||||
if (in_array($key,$fields)) {
|
||||
$query->where($key,$item);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// $listRow = [
|
||||
// 'query' => 'index/download/index', //url额外参数
|
||||
// 'fragment' => '', //url锚点
|
||||
// 'var_page' => 'page', //分页变量
|
||||
// 'list_rows' => $data['size']??4, //每页数量
|
||||
// ];
|
||||
// return $collection->order($sort)->with('getSoftBtn')->paginate($listRow);
|
||||
|
||||
|
||||
$arr = [];
|
||||
if (isset($data['page']) && isset($data['size'])) {
|
||||
$count = $collection->count() ?: 0;
|
||||
$page = $collection->limit($data['size'])->page($data['page'])->order($sort)->with('getSoftBtn')->select()->toArray();
|
||||
// if (!empty($page)) {
|
||||
// foreach ($page as $key => $item) {
|
||||
// $page[$key]['image'] = Env::get('QINIU.cdn').$item['image'];
|
||||
// foreach ($item['getSoftBtn'] as $item1) {
|
||||
// $tmp = [
|
||||
// 'url' => Env::get('QINIU.cdn').$item1['url'],
|
||||
// 'name' => $item1['file_name']
|
||||
// ];
|
||||
// $arr[$item1['btn_tips']][] = array_merge($tmp,[]);
|
||||
// }
|
||||
// $page[$key]['getSoftBtn'] = $arr;
|
||||
// $arr = [];
|
||||
// }
|
||||
// }
|
||||
return ['page'=>$page,'count'=>$count];
|
||||
} else {
|
||||
$resData = $collection->order($sort)->with('getSoftBtn')->select()->toArray();
|
||||
// dump($resData);
|
||||
// if (!empty($resData)) {
|
||||
// foreach ($resData as $key => $item) {
|
||||
// $resData[$key]['image'] = Env::get('QINIU.cdn').$item['image'];
|
||||
// $tmp = [];
|
||||
// foreach ($item['getSoftBtn'] as $item1) {
|
||||
// $tmp = [
|
||||
// 'url' => Env::get('QINIU.cdn').$item1['url'],
|
||||
// 'name' => $item1['file_name']
|
||||
// ];
|
||||
// $arr[$item1['btn_tips']][] = array_merge($tmp,[]);
|
||||
// }
|
||||
// $resData[$key]['getSoftBtn'] = $arr;
|
||||
// }
|
||||
// }
|
||||
// dump($this->getLastSql());
|
||||
return $resData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分类
|
||||
*/
|
||||
public function getDownloadType()
|
||||
{
|
||||
return FileType::select()->toArray();
|
||||
}
|
||||
}
|
||||
19
app/index/model/SoftManualBtn.php
Normal file
19
app/index/model/SoftManualBtn.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class SoftManualBtn extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'soft_manual_id'=> 'int',
|
||||
'btn_tips' => 'string',
|
||||
'url' => 'string',
|
||||
'file_name' => 'string',
|
||||
'create_time' => 'int',
|
||||
'update_time' => 'int',
|
||||
];
|
||||
|
||||
}
|
||||
78
app/index/model/SystemConfig.php
Normal file
78
app/index/model/SystemConfig.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class SystemConfig extends BaseModel
|
||||
{
|
||||
protected $schema = [
|
||||
'id' =>'int',
|
||||
'platform_id' =>'int',
|
||||
'language_id' =>'int',
|
||||
'site_id' =>'int',
|
||||
'type' =>'int',
|
||||
'page' =>'string',
|
||||
'pos' =>'string',
|
||||
'name' =>'string',
|
||||
'value' =>'string',
|
||||
'image' =>'string',
|
||||
'create_time' =>'int',
|
||||
'update_time' =>'int'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 获取尾部信息
|
||||
* @param $languageId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getFooterInfo($languageId):array
|
||||
{
|
||||
$result = $this->field(['name','value','image'])->where(['site_id'=>$languageId,'pos'=>'footer'])->select()->toArray();
|
||||
if (!empty($result)) {
|
||||
$newData = [];
|
||||
foreach ($result as $value) {
|
||||
if ($value['image']) {
|
||||
$images = json_decode($value['image'],true);
|
||||
$newData[$value['name']]['value'] = $value['value'] != '' ? $value['value'] : $images[0]['image'];
|
||||
} else {
|
||||
$newData[$value['name']]['value'] = '';
|
||||
}
|
||||
}
|
||||
return $newData;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* 获取尾部信息
|
||||
* @param $languageId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getWebSiteInfo($languageId):array
|
||||
{
|
||||
$result = $this->field(['name','value','image'])->where(['site_id'=>$languageId,'pos'=>'index'])->select()->toArray();
|
||||
if (!empty($result)) {
|
||||
$newData = [];
|
||||
foreach ($result as $value) {
|
||||
if ($value['image']) {
|
||||
$images = json_decode($value['image'],true);
|
||||
$newData[$value['name']]['value'] = $value['value'] != '' ? $value['value'] : $images[0]['image'];
|
||||
} else {
|
||||
$newData[$value['name']]['value'] = '';
|
||||
}
|
||||
}
|
||||
return $newData;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
28
app/index/model/Test.php
Normal file
28
app/index/model/Test.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class Test extends BaseModel
|
||||
{
|
||||
/**
|
||||
* @param $languageId
|
||||
* @param $data
|
||||
* @return array|string[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAboutBanner($languageId,$data):array
|
||||
{
|
||||
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
||||
if (!empty($space)) {
|
||||
return $this->getBanner($languageId,$space[0]['id']);
|
||||
}
|
||||
return ['image' => ''];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user