Model_logic_ding.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * 对接crm接口
  4. */
  5. class Model_logic_ding extends Lin_Model {
  6. function __construct(){
  7. parent::__construct();
  8. $this->load->_model("Model_logic_tools","logic_tools");
  9. $this->load->_model("Model_zzjobs","zzjobs");
  10. $this->load->_model("Model_zzerrlog","zzerrlog");
  11. }
  12. public $key = "ly20250115@0911";
  13. //public $key = "Hello, World!";
  14. public function getKey(){
  15. return $this->key;
  16. }
  17. public function sendToDing($error_msg){
  18. $this->zzerrlog->insert([
  19. 'content'=>$error_msg,
  20. 'created_time'=>date("Y-m-d H:i:s"),
  21. 'time'=>time(),
  22. ]);
  23. }
  24. // public $url = "https://1.wepolicy.cn/errorlog/ding";
  25. // public function sendToDing($error_msg){
  26. // $data = [
  27. // 'bs'=>$this->logic_tools->toolsjiami($this->key),
  28. // 'content'=>$error_msg,
  29. // ];
  30. // $data = json_encode($data,JSON_UNESCAPED_UNICODE);
  31. // $ch = curl_init($this->url);
  32. // // 设置cURL选项
  33. // $options = array(
  34. // CURLOPT_SSL_VERIFYPEER=>false,
  35. // CURLOPT_SSL_VERIFYHOST=>false,
  36. // CURLOPT_RETURNTRANSFER => true,
  37. // CURLOPT_POST => true,
  38. // CURLOPT_POSTFIELDS => $data,
  39. // CURLOPT_HTTPHEADER => [
  40. // 'Content-Type: application/json'
  41. // ],
  42. // CURLOPT_ENCODING => "gzip,deflate"
  43. // );
  44. // // 应用这些选项到cURL会话
  45. // curl_setopt_array($ch, $options);
  46. // // 执行cURL会话并获取响应
  47. // $response = curl_exec($ch);
  48. // // 检查是否有错误发生
  49. // if ($response === false) {
  50. // $error = curl_error($ch);
  51. // curl_close($ch);
  52. // return [
  53. // "code"=> -1,
  54. // "msg"=> $error
  55. // ];
  56. // }
  57. // // 关闭cURL会话
  58. // curl_close($ch);
  59. // }
  60. /**
  61. * 添加到执行队列上
  62. */
  63. public function addJobs($type,$params){
  64. $this->zzjobs->insert([
  65. 'status'=>0,
  66. 'quque'=>$type,
  67. 'payload'=>json_encode($params),
  68. 'do_interval'=>1,
  69. 'create_time'=>time(),
  70. ]);
  71. }
  72. }