Message.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\service;
  13. /**
  14. * 消息通知服务
  15. * Class Message
  16. * @package app\common\service
  17. */
  18. class Message extends BaseService
  19. {
  20. /**
  21. * 场景列表
  22. * [场景名称] => [场景类]
  23. * @var array
  24. */
  25. private static $sceneList = [
  26. // 短信验证码
  27. 'passport.captcha' => \app\common\service\message\passport\Captcha::class,
  28. // 订单支付成功
  29. 'order.payment' => \app\common\service\message\order\Payment::class,
  30. // 订单发货
  31. 'order.delivery' => \app\common\service\message\order\Delivery::class,
  32. // 订单退款
  33. 'order.refund' => \app\common\service\message\order\Refund::class,
  34. ];
  35. /**
  36. * 发送消息通知
  37. * @param string $sceneName 场景名称
  38. * @param array $param 参数
  39. * @param int $storeId 商城ID
  40. * @return bool
  41. */
  42. public static function send(string $sceneName, array $param, int $storeId)
  43. {
  44. if (!isset(self::$sceneList[$sceneName])) return false;
  45. $class = self::$sceneList[$sceneName];
  46. return (new $class($storeId))->send($param);
  47. }
  48. /**
  49. * 企业微信技术群公明腊肠系统监控zq
  50. * @param $msg
  51. */
  52. public static function wxRobot($msg){
  53. //$url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=bf17777d-35ab-4b80-9361-13927929cce5';
  54. $url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=103b767e-2e8a-4816-8d54-66642e414615';
  55. $payload = '{
  56. "msgtype": "text",
  57. "text": {
  58. "content": "'.$msg.'",
  59. "mentioned_list":["@all"]
  60. }
  61. }';
  62. curl_post($url,$payload);
  63. }
  64. }