1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- declare (strict_types = 1);
- namespace app\sys\controller;
- use app\model\OutCallSetting;
- use think\facade\View;
- class Luban
- {
- /**
- * 设置页面
- *
- * @return String
- */
- public function setting()
- {
- $setting = OutCallSetting::where(['root_id' => request()->employee->root_id, 'type' => 'luban'])->find();
- View::assign('data', $setting);
- return View::fetch();
- }
- /**
- * 配置保存
- *
- * @return String
- */
- public function settingSave()
- {
- // 单个企业只能设置一种外呼系统
- $setting = OutCallSetting::where(['root_id' => request()->employee->root_id])->findOrEmpty();
- if ($setting->isEmpty()) {
- $setting = new OutCallSetting;
- } elseif ($setting->type != 'luban') {
- $setting->delete();
- $setting = new OutCallSetting;
- }
- $param = request()->only(['appid', 'secretKey', 'tel_x']);
- $data = [
- 'config' => $param,
- 'root_id' => request()->employee->root_id,
- 'type' => 'luban'
- ];
- $rs = $setting->save($data);
- if (!$rs) return json(['code' => 1, 'msg' => '保存失败']);
- return json(['code' => 0, 'msg' => '保存成功']);
- }
- }
|