| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace app\api\lists;
- use app\adminapi\lists\BaseAdminDataLists;
- use app\common\model\goods\Goods;
- use app\common\model\home_service\HomeSpecial;
- use app\common\lists\ListsSearchInterface;
- /**
- * HomeSpecial列表
- * Class HomeSpecialLists
- * @package app\api\listshome_service
- */
- class HomeSpecialLists extends BaseApiDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2024/11/18 10:05
- */
- public function setSearch(): array
- {
- return [
- '=' => ['special_type'],
- ];
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2024/11/18 10:05
- */
- public function lists(): array
- {
- return HomeSpecial::where($this->searchWhere)
- ->where('status',1)
- ->field(['id', 'special_type','special_way', 'title', 'cover_type', 'cover', 'user_head', 'user_nickname', 'vue_web', 'vue_param', 'view_num', 'tags', 'status', 'original_price' ,'present_price','goods_id'])
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->each(function($item){
- if($item->goods_id){
- $item->goods = Goods::where('id',$item->goods_id)->field('goods_banners,goods_name,service_total,service_fee')->findOrEmpty();
- }
- })
- ->toArray();
- }
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2024/11/18 10:05
- */
- public function count(): int
- {
- return HomeSpecial::where($this->searchWhere)->count();
- }
- }
|