<?php
/**
 * @Copyright (c) 2019  XIGU Inc. All rights reserved.
 * @Link https://www.vlcms.com
 * @License江苏溪谷网络科技有限公司版权所有
 */

namespace app\common\logic;

class System extends Base
{


    public function setSMSInfo($param = [])
    {
        $result = ['code' => '200', 'msg' => '保存成功', 'data' => []];
        $option['access_key_id'] = empty($param['access_key_id']) ? '' : $param['access_key_id'];
        $option['access_key_secret'] = empty($param['access_key_secret']) ? '' : $param['access_key_secret'];
        $option['sign_name'] = empty($param['sign_name']) ? '' : $param['sign_name'];
        $option['change_password_code'] = empty($param['change_password_code']) ? '' : $param['change_password_code'];  //改密通知
        $option['wage_code'] = empty($param['wage_code']) ? '' : $param['wage_code'];  //工资到账
        $option['honor_code'] = empty($param['honor_code']) ? '' : $param['honor_code']; //荣誉等级
        $option['privilege_code'] = empty($param['privilege_code']) ? '' : $param['privilege_code'];  //特权奖励
        $option['number'] = empty($param['number']) ? '' : $param['number'];
        $option['status'] = empty($param['status']) ? 0 : 1;
        //设置客服手机号
        if (empty($param['service_mobile']) || !check_mobile($param['service_mobile'])) {
            $result['code'] = 0;
            $result['msg'] = '请输入正确的客服手机号';
            return $result;
        }
        $option['service_mobile'] = empty($param['service_mobile']) ? '' : $param['service_mobile'];
        set_option('sms_info', $option, true);
        return $result;
    }


    public function getSMSInfo($param)
    {
        $result = ['code' => '200', 'msg' => '请求成功', 'data' => []];
        $option = get_option('sms_info');
        if (empty($option)) {
            $this -> setSMSInfo();
            $option = get_option('sms_info');
        }
        $result['data'] = $option;
        return $result;
    }

}