SystemStatusInfoController.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Jobs\ClearCache;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\DB;
  6. use Illuminate\Support\Facades\Redis;
  7. class SystemStatusInfoController
  8. {
  9. // 客服功能
  10. public function customer_service(Request $request)
  11. {
  12. if ($request->isMethod('post')) {
  13. $post = $request->post();
  14. if (is_array($post)) {
  15. foreach ($post as $key => $value) {
  16. // if ($key == 'WhatsApp') {
  17. // DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  18. // ->where('StatusName', $key)
  19. // ->update(['StatusString' => $value, 'StatusValue' => $post['WhatsApp_ID']]);
  20. //
  21. // DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  22. // ->where('StatusName', $key)
  23. // ->update(['StatusString' => $value, 'StatusValue' => $post['WhatsApp_ID']]);
  24. // } else {
  25. if(strstr($value,'{')) {
  26. try {
  27. $value=json_decode($value,true);
  28. $def=$value['default'];
  29. $value['default']=$def;
  30. $value=json_encode($value);
  31. } catch (\Exception $e) {
  32. return apiReturnFail("修改失败,格式有误");
  33. }
  34. }
  35. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  36. ->where('StatusName', $key)
  37. ->update(['StatusString' => $value]);
  38. // }
  39. }
  40. }
  41. ClearCache::dispatch();
  42. Redis::del('customer_service');
  43. Redis::del('customer_service_n');
  44. return apiReturnSuc();
  45. }
  46. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  47. ->where('StatusName', 'Email')
  48. ->orWhere('StatusName', 'WhatsApp')
  49. ->orWhere('StatusName', 'WhatsApp_ID')
  50. ->orWhere('StatusName', 'Telegram')
  51. ->get();
  52. $Channels = session('all_channels');
  53. $title="客服信息管理";
  54. return view('admin.system_status_info.customer_service', compact('list','Channels','title'));
  55. }
  56. public function high_customer_service(Request $request)
  57. {
  58. if ($request->isMethod('post')) {
  59. $post = $request->post();
  60. if (is_array($post)) {
  61. foreach ($post as $key => $value) {
  62. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  63. ->where('StatusName', $key)
  64. ->update(['StatusString' => $value]);
  65. }
  66. }
  67. ClearCache::dispatch();
  68. Redis::del('high_customer_service');
  69. return apiReturnSuc();
  70. }
  71. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  72. ->orWhere('StatusName', 'High_WhatsApp')
  73. ->orWhere('StatusName', 'High_WhatsApp_ID')
  74. ->get();
  75. $Channels = session('all_channels');
  76. $title="高级客服信息管理";
  77. return view('admin.system_status_info.customer_service', compact('list','Channels','title'));
  78. }
  79. }