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 $url = "http://git.wepolicy.cn/errorlog/ding";
  26. // public function sendToDing($error_msg){
  27. // $data = [
  28. // 'bs'=>$this->logic_tools->toolsjiami($this->key),
  29. // 'content'=>$error_msg,
  30. // ];
  31. // $data = json_encode($data,JSON_UNESCAPED_UNICODE);
  32. // $ch = curl_init($this->url);
  33. // // 设置cURL选项
  34. // $options = array(
  35. // CURLOPT_SSL_VERIFYPEER=>false,
  36. // CURLOPT_SSL_VERIFYHOST=>false,
  37. // CURLOPT_RETURNTRANSFER => true,
  38. // CURLOPT_POST => true,
  39. // CURLOPT_POSTFIELDS => $data,
  40. // CURLOPT_HTTPHEADER => [
  41. // 'Content-Type: application/json'
  42. // ],
  43. // CURLOPT_ENCODING => "gzip,deflate"
  44. // );
  45. // // 应用这些选项到cURL会话
  46. // curl_setopt_array($ch, $options);
  47. // // 执行cURL会话并获取响应
  48. // $response = curl_exec($ch);
  49. // // 检查是否有错误发生
  50. // if ($response === false) {
  51. // $error = curl_error($ch);
  52. // curl_close($ch);
  53. // return [
  54. // "code"=> -1,
  55. // "msg"=> $error
  56. // ];
  57. // }
  58. // // 关闭cURL会话
  59. // curl_close($ch);
  60. // }
  61. /**
  62. * 添加到执行队列上
  63. */
  64. public function addJobs($type,$params){
  65. $this->zzjobs->insert([
  66. 'status'=>0,
  67. 'quque'=>$type,
  68. 'payload'=>json_encode($params),
  69. 'do_interval'=>1,
  70. 'create_time'=>time(),
  71. ]);
  72. }
  73. }