|
|
|
@ -63,7 +63,44 @@ class Setting extends BaseController |
|
|
|
|
|
|
|
return $this->renderSuccess('设置成功'); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
return $this->renderError($validateException['msg']); |
|
|
|
return $this->renderError($validateException->getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取概率 |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public function getProbability() |
|
|
|
{ |
|
|
|
try { |
|
|
|
$probability = SettingModel::settingLoad('amount_probability') ?: 0; |
|
|
|
return $this->renderSuccess('数据返回成功',['rate' => $probability]); |
|
|
|
} catch (\Exception $e) { |
|
|
|
return $this->renderError('操作失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置概率 |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public function settingProbability() |
|
|
|
{ |
|
|
|
$param = Request::param(); |
|
|
|
try { |
|
|
|
|
|
|
|
validate()->rule([ |
|
|
|
'rate' => 'require|float|between:0.01,500', |
|
|
|
])->check($param); |
|
|
|
|
|
|
|
SettingModel::settingSave('amount_probability',round($param['rate'] / 100,4)); |
|
|
|
|
|
|
|
return $this->renderSuccess('设置成功'); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
return $this->renderError($validateException->getMessage()); |
|
|
|
} catch (\Exception $e) { |
|
|
|
return $this->renderError('操作失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|