Luban.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\sys\controller;
  4. use app\model\OutCallSetting;
  5. use think\facade\View;
  6. class Luban
  7. {
  8. /**
  9. * 设置页面
  10. *
  11. * @return String
  12. */
  13. public function setting()
  14. {
  15. $setting = OutCallSetting::where(['root_id' => request()->employee->root_id, 'type' => 'luban'])->find();
  16. View::assign('data', $setting);
  17. return View::fetch();
  18. }
  19. /**
  20. * 配置保存
  21. *
  22. * @return String
  23. */
  24. public function settingSave()
  25. {
  26. // 单个企业只能设置一种外呼系统
  27. $setting = OutCallSetting::where(['root_id' => request()->employee->root_id])->findOrEmpty();
  28. if ($setting->isEmpty()) {
  29. $setting = new OutCallSetting;
  30. } elseif ($setting->type != 'luban') {
  31. $setting->delete();
  32. $setting = new OutCallSetting;
  33. }
  34. $param = request()->only(['appid', 'secretKey', 'tel_x']);
  35. $data = [
  36. 'config' => $param,
  37. 'root_id' => request()->employee->root_id,
  38. 'type' => 'luban'
  39. ];
  40. $rs = $setting->save($data);
  41. if (!$rs) return json(['code' => 1, 'msg' => '保存失败']);
  42. return json(['code' => 0, 'msg' => '保存成功']);
  43. }
  44. }