123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\dao\product\shipping;
- use app\dao\BaseDao;
- use app\model\product\shipping\ShippingTemplatesNoDelivery;
- use app\model\other\SystemCity;
- class ShippingTemplatesNoDeliveryCityDao extends BaseDao
- {
-
- protected $alias = 'a';
-
- protected $joinAlis = 'c';
-
- protected function setModel(): string
- {
- return ShippingTemplatesNoDelivery::class;
- }
-
- protected function setJoinModel(): string
- {
- return SystemCity::class;
- }
-
- protected function getModel(string $key = 'province_id', string $join = 'LEFT')
- {
-
- $city = app()->make($this->setJoinModel());
- $name = $city->getName();
- return parent::getModel()->join($name . ' ' . $this->joinAlis, $this->alias . '.' . $key . ' = ' . $this->joinAlis . '.city_id', $join)->alias($this->alias);
- }
-
- public function getUniqidList(array $where, bool $group = true)
- {
- return $this->getModel($group ? 'province_id' : 'city_id')->when(isset($where['uniqid']), function ($query) use ($where) {
- $query->where($this->alias . '.uniqid', $where['uniqid']);
- })->when(isset($where['province_id']), function ($query) use ($where) {
- $query->where($this->alias . '.province_id', $where['province_id']);
- })->when($group, function ($query) {
- $query->group($this->alias . '.province_id');
- })->field($this->alias . '.province_id,' . $this->joinAlis . '.name,' . $this->alias . '.city_id')->select()->toArray();
- }
- }
|