Files
huangjingfen/pro_v3.5.1/app/dao/product/shipping/ShippingTemplatesRegionCityDao.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

80 lines
2.2 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace app\dao\product\shipping;
use app\dao\BaseDao;
use app\model\product\shipping\ShippingTemplatesRegion;
use app\model\other\SystemCity;
/**
* Class ShippingTemplatesRegionCityDao
* @package app\dao\product\shipping
*/
class ShippingTemplatesRegionCityDao extends BaseDao
{
/**
* 当前表别名
* @var string
*/
protected string $alias = 'a';
/**
* 设置join连表别名
* @var string
*/
protected string $joinAlis = 'c';
/**
* 设置当前模型
* @return string
*/
protected function setModel(): string
{
return ShippingTemplatesRegion::class;
}
/**
* 设置连表模型
* @return string
*/
protected function setJoinModel(): string
{
return SystemCity::class;
}
/**
* 关联模型
* @param string $alias
* @param string $join_alias
* @return \crmeb\basic\BaseModel
*/
protected function getModel(string $key = 'province_id', string $join = 'LEFT')
{
/** @var SystemCity $city */
$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);
}
/**
* 获取指定条件下的包邮列表
* @param array $where
* @return mixed
*/
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();
}
}