初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,154 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\model\city\City;
use app\common\model\Region;
use app\common\validate\BaseValidate;
class CityValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'city_id' => 'require|checkCity',
'taxi' => 'require|in:0,1|checkTaxi',
'bus' => 'require|in:0,1|checkBus',
];
protected $message = [
'id.require' => '参数错误',
'city_id.require' => '请选择城市',
'taxi.require' => '请选择滴滴/出租状态',
'taxi.in' => '滴滴/出租状态错误',
'bus.require' => '请选择公交/地铁状态',
'bus.in' => '公交/地铁状态错误',
];
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 检验ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:32 下午
*/
public function checkId($value,$rule,$data)
{
$result = City::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '数据不存在';
}
return true;
}
/**
* @notes 检验名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:36 下午
*/
public function checkCity($value,$rule,$data)
{
$cityWhere[] = ['city_id','=',$value];
if(isset($data['id'])){
$cityWhere[] = ['id','<>',$data['id']];
}
$city = City::where($cityWhere)->findOrEmpty();
if(!$city->isEmpty()){
return '该城市已添加';
}
$city = Region::where(['id'=>$value])->findOrEmpty();
if($city->isEmpty()){
return '城市不存在,请重新选择';
}
return true;
}
/**
* @notes 验证出租车价格
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/8/27 13:14
*/
public function checkTaxi($value,$rule,$data)
{
if(!$data['taxi']){
return true;
}
if('' == $data['start_km'] && $data['start_km'] < 0){
return '请输入起步里程数';
}
if( '' == $data['start_price'] && $data['start_price'] < 0){
return '请输入起步价格';
}
if('' == $data['continue_price'] && $data['continue_price'] < 0){
return '请输入每增加1公里价格';
}
return true;
}
/**
* @notes 验证出租车价格
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/8/27 13:14
*/
public function checkBus($value,$rule,$data)
{
if(!$data['bus']){
return true;
}
if('' == $data['bus_start_time']){
return '请输入公交/地铁开启时间';
}
if( '' == $data['bus_end_time'] ){
return '请输入公交/地铁结束时间';
}
if('' == $data['bus_fare'] && $data['continue_price'] < 0){
return '请输入固定车费';
}
return true;
}
}