'ID', 'mall_id' => '商城ID', 'user_id' => '会员ID', 'mobile' => '手机号码', 'license' => '营业执照', 'store_info' => '店铺抬头', 'idcart_front' => '身份证照(正)', 'idcart_back' => '身份证照(反)', 'idcart_hands' => '身份证照(手持)', 'is_poss' => '审核状态[0审核中 1审核通过 -1拒绝]', 'reason' => '失败原因', 'status' => '状态[0禁用 1启用 -1删除]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } /** * @notes:关联用户 * @return \yii\db\ActiveQuery * @author: lun * @Time: 2022/10/22 17:45 */ public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,nickname,mobile,avatar_url'); } /** * @notes:数据保存 * @param $mall_id * @param $params * @return bool * @author: lun * @Time: 2022/10/22 18:28 */ public static function setData($mall_id, $params) { $trans = Yii::$app->db->beginTransaction(); try{ $model = self::find()->where(['mall_id' => $mall_id, 'user_id' => $params['user_id']])->andWhere(['<>','status',StatusEnum::DELETE])->one(); if (empty($model)) { $model = new self(); $model->mall_id = $mall_id; $model->is_poss = StatusEnum::DISABLED; $model->loadDefaultValues(); unset($params['is_poss']); } else { // 非首次审核处理 } if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); $trans->commit(); return $model->toArray(); }catch(\Exception $e){ $trans->rollBack(); self::$static_error = $e->getMessage(); return false; } } /** * @notes:驳回,同意,删除处理 * @param $mall_id * @param $params * @return bool * @author: lun * @Time: 2022/10/22 18:27 */ public static function handle($mall_id, $params) { $trans = Yii::$app->db->beginTransaction(); try{ $model = self::findOne(['mall_id' => $mall_id, 'id' => $params['id']]); if (empty($model)) throw new \Exception('该用户数据不存在'); if (!empty($params['is_poss'])) { $model->is_poss = $params['is_poss']; $params['is_poss'] == StatusEnum::ENABLED && $model->reason = ''; $params['is_poss'] == StatusEnum::DELETE && $params['reason'] && $model->reason = $params['reason']; } if (!empty($params['status'])) $model->status = $params['status']; if (!$model->save()) throw new Exception($model->getErrorMessage()); $trans->commit(); return true; }catch(\Exception $e){ $trans->rollBack(); self::$static_error = $e->getMessage(); return false; } } /** * @notes:检查用户是否审核通过 * @param $user_id * @return bool * @author: lun * @Time: 2022/10/31 11:32 */ public static function check($user_id) { $data = self::find()->where(['user_id' => $user_id, 'status' => StatusEnum::ENABLED])->asArray()->one(); if (empty($data)) return false; if ($data['is_poss'] != 1) return false; return true; } }