init: 项目初始代码
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user