quanwei
2 days ago 04102f7237efefa744090ed7c25f7b5d0807b679
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
 
namespace app\agent\controller\setting;
 
use app\agent\controller\Controller;
use app\agent\model\settings\Setting as SettingModel;
 
/**
 * 短信配置控制器
 */
class Sms extends Controller
{
    /**
     * 短信配置
     */
    public function index()
    {
        if($this->request->isGet()){
            return $this->fetchData();
        }
        $model = new SettingModel;
        $data = $this->request->param();
        $arr = [
            'default' => 'aliyun',
            'engine' => [
                'aliyun' => [
                    'AccessKeyId' => $data['AccessKeyId'],
                    'AccessKeySecret' => $data['AccessKeySecret'],
                    'sign' => $data['sign'],
                    'login_template' => $data['login_template'],
                    'apply_template' => $data['apply_template'],
                    'supplier_reject_code' => $data['supplier_reject_code'],
                    'supplier_pass_code' => $data['supplier_pass_code'],
                ]
            ]
        ];
        if ($model->edit('sms', $arr)) {
            return $this->renderSuccess('操作成功');
        }
        return $this->renderError($model->getError() ?: '操作失败');
    }
 
    /**
     * 获取短信配置
     */
    public function fetchData()
    {
        $key = 'sms';
        $vars['values'] = SettingModel::getItem($key);
        return $this->renderSuccess('', compact('vars'));
    }
 
}