request->isAjax) { $conf = Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_REAL_AUTH, 'basic'); $scene_conf = [ ['name' => '平台商品下单实名认证', 'value' => 'order'], ['name' => '提现实名认证', 'value' => 'cash'], ['name' => '部分平台商品下单', 'value' => 'part_order'], ]; if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_LAO_DA_FU)) { $scene_conf[] = ['name' => '佬大夫下单实名认证', 'value' => 'laodafu_order']; } $business_conf = [['name' => '交易钱包(门店余额)提现实名认证', 'value' => 'cash'],['name' => '申请开店(O2O门店和多商户)实名认证', 'value' => 'store']]; if(isset($conf['scene'])){ $conf['scene'] = explode(',',$conf['scene']); }else{ $conf['scene'] = []; } if(isset($conf['goods_list']) && !empty($conf['goods_list'])){ $conf['goods_list'] = json_decode($conf['goods_list'], true); }else{ $conf['goods_list'] = []; } if(isset($conf['goods_ids']) && !empty($conf['goods_ids'])){ $conf['goods_ids'] = json_decode($conf['goods_ids'], true); }else{ $conf['goods_ids'] = []; } if(isset($conf['business_scene'])){ $conf['business_scene'] = explode(',',$conf['business_scene']); }else{ $conf['business_scene'] = []; } return $this->success('ok', compact('conf','scene_conf','business_conf')); } return $this->render('index'); } /** * 保存设置 * * @return void */ public function actionSave() { if ($this->request->isPost) { try{ // 数据提交 $post = $this->request->post(); //检验数据 $validateService = Yii::$app->services->validate; $rules = [ [['secret_id','secret_key','scene', 'version'],'required'], [['status','id_no_limit'],'integer'], [['goods_ids', 'goods_list'], 'safe'], [['setting_status','business_status','business_verify_time','business_scene','business_no_limit','upgrade_status'],'safe'], ]; $labels = [ 'secret_id' => 'SecretID', 'secret_key' => 'SecretKey', 'scene' => '应用场景', 'goods_ids' => '商品id', 'goods_list' => '商品集合' ]; $valid = $validateService->validate($post, $rules,$labels); if (!$valid) { throw new \Exception($validateService->getFirstErrorSummary()); } unset($post['_csrf']); $post['scene'] = implode(',',$post['scene']); if(isset($post['business_scene'])){ $post['business_scene'] = implode(',',$post['business_scene']); } $conf['basic'] = $post; $res = Yii::$app->services->setting->addons->set($this->mall_id, AddonsEnum::ADDONS_NAME_REAL_AUTH, $conf); if(!$res){ throw new Exception('保存失败'); } return $this->success('保存成功'); } catch (Exception $e) { return $this->error($e->getMessage()); } } } }