10], [['contact_phone'], 'string', 'max' => 11], [['intro', 'logo', 'license_pic', 'id_card_pic', 'street', 'area'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'name' => 'Name', 'intro' => 'Intro', 'logo' => 'Logo', 'license_pic' => 'License Pic', 'id_card_pic' => 'Id Card Pic', 'contact_name' => 'Contact Name', 'province_id' => 'Province ID', 'city_id' => 'City ID', 'district_id' => 'District ID', 'street' => 'Street', 'lng' => 'Lng', 'lat' => 'Lat', 'area' => 'Area', 'submit_count' => 'Submit Count', 'check_count' => 'Check Count', ]; } /** * @return ActiveQuery */ public function getUser(): ActiveQuery { return $this->hasOne(User::class, ['id' => 'user_id']); } /** * @return ActiveQuery */ public function getCheck(): ActiveQuery { return $this->hasOne(CommunityHeadCheck::class, ['apply_id' => 'id']); } /** * @param CommunityHead $head * @param int $admin_id * @return void * @throws \Exception */ public static function create(CommunityHead $head, int $admin_id) { $model = new CommunityHeadApply(); $model->user_id = $head->user_id; $model->mall_id = $head->mall_id; $model->submit_count = 1; $district_name = Region::find()->where(['id' => $head->district_id])->select('name')->scalar(); $area = $head->address; $street = $head->address; if (!empty($district_name)) { $index = strpos($head->address, $district_name); $d_len = strlen($district_name); $area = substr($area, 0, $index + $d_len); $street = substr($street, $index + $d_len); } $model->name = $head->name; $model->intro = $head->desc; $model->logo = $head->logo; $model->license_pic = $head->license_img; $model->id_card_pic = $head->idcard_img; $model->contact_name = $head->contacts; $model->contact_phone = $head->mobile; $model->province_id = $head->province_id; $model->city_id = $head->city_id; $model->district_id = $head->district_id; $model->street = $street; // 这里有问题 $model->area = $area; // 这里有问题 $model->lng = $head->longitude; $model->lat = $head->latitude; $model->is_home_delivery = $head->is_home_delivery; $model->apply_status = ConfigEnum::COMMUNITY_CHECK_STATUS_AGREE; // 修改为待审核 if (!$model->save()) throw new \Exception($model->getErrorMessage()); $checkModel = new CommunityHeadCheck(); $checkModel->mall_id = $head->mall_id; $checkModel->apply_id = $model->id; $checkModel->admin_id = $admin_id; $checkModel->remark = "由后台管理员 [{$admin_id}] 直接创建"; $checkModel->check_status = ConfigEnum::COMMUNITY_CHECK_STATUS_AGREE; if (!$checkModel->save()) throw new \Exception($checkModel->getErrorMessage()); } }