request->isGet) { return $this->error('请求方式错误'); } $settings = \Yii::$app->services->setting->addons->get($this->mall_id, HappinessEnum::ADDONS_NAME, 'basic'); if (0 == $settings['is_enable']) { return $this->error('小店入驻未开启'); } $store = HappinessStore::find() ->select('id,mall_id,user_id,shop_owner,shop_mobile,store_name,store_desc,city_id,district_id,province_id, logo_img,license_img,address,longitude,latitude,check_status,check_remark') ->where(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED]) ->asArray() ->one(); // 入驻申请进度,0:未申请;1:审核中;2:审核通过;3:审核未通过 $apply_step = 0; $store_account = []; if (!empty($store)) { //省市区ID $where[] = ['in', 'id', [$store['province_id'], $store['city_id'], $store['district_id']]]; $region = Region::getRegionList($where); if (!empty($region)) { $region = array_column($region, null, 'id'); } $store['province_name'] = $region[$store['province_id']]['name'] ?? ''; $store['city_name'] = $region[$store['city_id']]['name'] ?? ''; $store['district_name'] = $region[$store['district_id']]['name'] ?? ''; $store['detail_address'] = $store['address']; if (HappinessEnum::CHECK_WAITING == $store['check_status']) { $apply_step = 1; } elseif (HappinessEnum::CHECK_ADOPT == $store['check_status']) { $apply_step = 2; $backend_domain = \Yii::$app->services->setting->platform->get('system.backend_url'); $backend_domain = empty($backend_domain) ? '' : (string)$backend_domain; $store_account = [ 'store_login_url' => trim($backend_domain, '/') . '?r=happiness/client/auth/login&sign=' . $this->mall['mall_sign'], 'account' => $store['shop_mobile'], 'login_pwd' => substr($store['shop_mobile'], -6), ]; } else if (HappinessEnum::CHECK_FAILED == $store['check_status']) { $apply_step = 3; } } $result = [ 'settings' => $settings, 'apply_step' => $apply_step, 'store' => $store, 'store_account' => $store_account, ]; return $this->success('success', $result); } /** * @name: * @msg: 提交入驻申请 * @param {*} * @return {*} */ public function actionEnterApply() { if (!\Yii::$app->request->isPost) { return $this->error('请求方式错误'); } $settings = \Yii::$app->services->setting->addons->get($this->mall_id, HappinessEnum::ADDONS_NAME, 'basic'); $upload_license_image = 1; $post = \Yii::$app->request->post(); $rules = [ [['shop_owner', 'shop_mobile', 'store_name', 'logo_img'], 'required'], [['shop_owner', 'store_name', 'store_desc', 'logo_img', 'license_img', 'longitude', 'latitude'], 'string', 'max' => 255], [[ 'province_id', 'city_id', 'district_id'], 'integer'], [['business_id'],'safe'], ['license_img', 'required', 'when' => function ($model) use ($upload_license_image) { return $upload_license_image == 1; }], [['id'], 'safe'], // 小店入驻新增参数 [['card_type', 'card_name', 'card_no', 'prov_id', 'area_id', 'branch_code', 'cert_type', 'cert_no', 'cert_validity_type', 'cert_begin_date', 'cert_end_date', 'mp', 'is_settle_default'], 'required'] ]; $res = \Yii::$app->services->validate->validate($post, $rules); if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage()); $post['address'] .= $post['detail_address']; $post['mall_id'] = $this->mall_id; $post['user_id'] = $this->user_id; unset($post['detail_address']); $post['shop_mobile'] = (string)$post['shop_mobile']; $query = HappinessStore::find()->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'shop_mobile' => $post['shop_mobile'], 'shop_owner' => $post['shop_owner']]); if (!empty($post['id'])) { $query->andWhere(['id' => $post['id']]); } else { unset($post['id']); } $clinic = $query->one(); if (!empty($clinic)) { if (empty($post['id'])) { // 新提交的申请 return $this->error('您已经申请过请勿重复申请'); } else { // 审核失败后重新提交的申请 if ($clinic->check_status != HappinessEnum::CHECK_FAILED) { return $this->error('商户状态异常'); } $clinic->attributes = $post; $clinic->check_status = HappinessEnum::CHECK_WAITING; //查询业务员 $business = User::find() ->andWhere(['mall_id' => $this->mall_id]) ->andWhere([ 'or', ['id' => $post['business_id']], ['mobile' => $post['business_id']] ]) ->one(); if(empty($business)) { return $this->error( '推广员不存在'); } $business=HappinessBusiness::find()->where(['mall_id' =>$this->mall_id, 'user_id' => $business->id]) ->one(); if(empty($business)) { return $this->error('用户'.$business->id.'不是推广员'); } $clinic->business_id = $business->user_id; $res = $clinic->save(); if (!$res) { return $this->error($clinic->getErrorMessage()); } return $this->success('提交成功'); } } if ($settings['store_audit'] == 1) { $post['check_status'] = HappinessEnum::CHECK_WAITING; } else { $post['check_status'] = HappinessEnum::CHECK_ADOPT; } $res = HappinessStore::addStore($post); if (false === $res) { return $this->error(HappinessStore::getStaticError()); } return $this->success('提交成功'); } public function actionAgreement() { $setting = \Yii::$app->services->setting->addons->get($this->mall_id, HappinessEnum::ADDONS_NAME, 'basic'); $data = [ 'recruit_title' => $setting['recruit_title'] ?? '', 'recruit_content' => $setting['recruit_content'] ?? '', ]; return $this->success('获取成功', $data); } }