'require', 'name' => 'require|max:50|checkName', 'short_name' => 'require|max:20|checkShortName', 'mobile' => 'require|mobile|checkMobile', 'type' => 'require|in:1,2', 'social_credit_ode' => 'require', 'legal_person' => 'require', 'legal_id_card' => 'require|idCard', 'province_id' => 'require', 'city_id' => 'require', 'shop_address_detail' => 'require', 'longitude' => 'require', 'latitude' => 'require', 'category_ids' => 'require|array|checkCategory', 'goods_ids' => 'require|array|checkGoods', 'id_card_front' => 'require', 'id_card_back' => 'require', // 'portrait_shooting' => 'require', 'logo' => 'require', 'business_license' => 'require', 'work_status' => 'require|in:0,1', 'server_status' => 'require|in:0,1' ]; protected $message = [ 'id.require' => '请选择店铺', 'name.require' => '请输入店铺名称', 'name.max' => '店铺名称不能超过50个字符', 'name.unique' => '店铺名称重复', 'short_name.require' => '请输入店铺简称', 'mobile.require' => '请输入手机号码', 'mobile.mobile' => '手机号码格式错误', 'mobile.unique' => '手机号码已存在', 'short_name.max' => '店铺简称不能超过20个字符', 'short_name.unique' => '店铺简称重复', 'type.require' => '请输入店铺类型', 'type.in' => '店铺类型错误', 'social_credit_ode.require' => '请输入社会统一信用代码', 'legal_person.require' => '请输入法人', 'legal_id_card.require' => '请输入法人身份证', 'legal_id_card.idCard' => '法人身份证错误', 'province_id.require' => '请选择省份', 'city.require' => '请选择城市', 'shop_address_detail.require' => '请输入店铺详情地址', 'longitude.require' => '请在地图上标记位置', 'latitude.require' => '请在地图上标记位置', 'category_ids.require' => '请选择分类', 'category_ids.array' => '分类数据错误', 'goods_ids.require' => '请选择服务', 'goods_ids.array' => '服务数据错误', 'id_card_front.require' => '请上传身份证正面照', 'id_card_back.require' => '请上传身份证背面照', 'portrait_shooting.require' => '请上传人像实照', 'logo.require' => '请上传logo', 'business_license.require' => '请上传营业执照', 'work_status.require' => '请选择工作状态', 'work_status.in' => '工作状态错误', 'server_status.require' => '请选择服务状态', 'server_status.in' => '服务状态错误', ]; protected function checkCategory($value,$rule,$data) { $categoryLists = GoodsCategory::where(['id'=>$value])->select()->toArray(); if(count($categoryLists) != count($value)){ return '分类错误,请刷新列表重新选择'; } return true; } protected function checkShortName($value,$rule,$data) { $where[] = ['short_name','=',$value]; $where[] = ['audit_status','in',[0,1]]; if(isset($data['id'])){ $where[] = ['id','<>',$data['id']]; } $shop = Shop::where($where)->findOrEmpty(); if(!$shop->isEmpty()){ return '简称重复'; } return true; } protected function checkMobile($value,$rule,$data){ $where[] = ['mobile','=',$value]; $where[] = ['audit_status','in',[0,1]]; if(isset($data['id'])){ $where[] = ['id','<>',$data['id']]; } $shop = Shop::where($where)->findOrEmpty(); if(!$shop->isEmpty()){ return '手机号码已存在'; } return true; } protected function checkName($value,$rule,$data) { $where[] = ['name','=',$value]; $where[] = ['audit_status','in',[0,1]]; if(isset($data['id'])){ $where[] = ['id','<>',$data['id']]; } $shop = Shop::where($where)->findOrEmpty(); if(!$shop->isEmpty()){ return '名称重复'; } return true; } protected function checkGoods($value,$rule,$data) { $where = []; foreach ($data['category_ids'] as $categoryId){ $categoryIds[] = $categoryId; $category = GoodsCategory::where(['id'=>$categoryId])->findOrEmpty(); if(1 == $category['level']){ $categoryId = GoodsCategory::where(['pid'=>$category['id']])->column('id'); $categoryIds = array_merge($categoryId,$categoryIds); } } $goodsLists = Goods::where(['category_id'=>$categoryIds])->column('id'); foreach ($value as $goodsId) { if(!in_array($goodsId,$goodsLists)){ return '服务错误,请刷新列表重新选择'; } } return true; } public function sceneId() { return $this->only(['id']); } public function sceneAdd() { return $this->remove(['id'=>true]); } }