Haoxiaoyun.php 1.3 KB

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