render('index'); } /** * @return string */ public function actionGetSetting() { try { return $this->success('ok', ScratchSettingLogic::getData($this->mall_id)); } catch (\ErrorException $errorException) { return $this->error($errorException->getMessage()); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } /** * @return string */ public function actionSaveSetting() { try { $postData = \Yii::$app->request->post(); $res = \Yii::$app->services->validate ->validate( $postData, [ ['payment_type', 'required', 'message' => '请填写支付方式'], ['send_type', 'required', 'message' => '请填写发货方式'], [['title', 'is_sms', 'is_mail', 'is_print', 'is_wechat', 'type', 'probability', 'oppty', 'start_at', 'end_at', 'deplete_integral_num', 'rule', 'background_imgs'], 'safe'], ] ); if ($res === false) { throw new \ErrorException(\Yii::$app->services->validate->getErrorMessage()); } return $this->success('保存成功', ScratchSettingLogic::saveData( $this->mall_id, $postData )); } catch (\ErrorException $errorException) { return $this->error($errorException->getMessage()); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } /** * @return string */ public function actionSaveBackground() { try { $postData = \Yii::$app->request->post(); $res = \Yii::$app->services->validate ->validate( $postData, [ ['color', 'default', 'value' => ''], ['image', 'default', 'value' => ''], ] ); if ($res === false) { throw new \ErrorException(\Yii::$app->services->validate->getErrorMessage()); } return $this->success('保存成功', ScratchSettingLogic::saveBackground( $this->mall_id, $postData )); } catch (\ErrorException $errorException) { return $this->error($errorException->getMessage()); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } }