<?php

namespace app\workerapi\lists\shops;

use app\common\enum\YesNoEnum;
use app\common\lists\ListsSearchInterface;
use app\common\model\shops\ShopAddress;
use app\common\model\shops\ShopGoods;
use app\workerapi\lists\BaseWorkerDataLists;
use think\db\Query;

class ShopAddressLists extends BaseWorkerDataLists implements ListsSearchInterface
{
    /**
     * @notes 设置搜索条件
     * @return \string[][]
     * @author likeadmin
     * @date 2024/07/07 18:23
     */
    public function setSearch(): array
    {
        return [
            '%like%' => ['contact_people'],
        ];
    }

    public function querySearch():array
    {
        $where = [];
        $where[] = ['worker_id','=',$this->userId];
        return $where;
    }

    public function lists(): array
    {
        return ShopAddress::where($this->searchWhere)
            ->where($this->querySearch())
            ->field(['id','area' ,'address', 'house_number','house_number','contact_number','contact_people'])
            ->limit($this->limitOffset, $this->limitLength)
            ->order('id','desc')
            ->select()
            ->toArray();
    }

    public function count(): int
    {
        return ShopAddress::where($this->searchWhere)->where($this->querySearch())->count();
    }
}