feishu.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. use Longyi\Feishu\Listeners\PaymentAlertSubscriber;
  3. /*
  4. |--------------------------------------------------------------------------
  5. | 飞书群自定义机器人
  6. |--------------------------------------------------------------------------
  7. |
  8. | 用于把需要人工介入的运营事件推送到飞书群。发送始终走队列,飞书不可用
  9. | 不会影响支付主流程。
  10. |
  11. */
  12. return [
  13. /*
  14. | 总开关。未配置 webhook_url 时即使打开也不会发送。
  15. */
  16. 'enabled' => env('FEISHU_BOT_ENABLED', false),
  17. /*
  18. | 群机器人的 Webhook 地址,形如
  19. | https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx
  20. */
  21. 'webhook_url' => env('FEISHU_BOT_WEBHOOK_URL', ''),
  22. /*
  23. | 机器人「加签」安全设置里的密钥。留空表示未开启加签。
  24. */
  25. 'secret' => env('FEISHU_BOT_SECRET', ''),
  26. /*
  27. | 单次请求超时(秒)。飞书接口很快,不要设太长,免得拖住队列。
  28. */
  29. 'timeout' => (int) env('FEISHU_BOT_TIMEOUT', 5),
  30. /*
  31. | 发送任务所在队列。
  32. */
  33. 'queue' => env('FEISHU_BOT_QUEUE', 'notifications'),
  34. /*
  35. | 同一订单的同一类告警在该时间窗内只发一次,避免对账反复扫描时刷屏。
  36. | 设为 0 关闭去重。
  37. */
  38. 'throttle_minutes' => (int) env('FEISHU_BOT_THROTTLE_MINUTES', 60),
  39. /*
  40. | 卡片里「查看订单」按钮的地址模板,{id} 会被订单 id 替换。
  41. | 留空时回退到 admin.sales.orders.view 路由。
  42. */
  43. 'admin_order_url' => env('FEISHU_BOT_ADMIN_ORDER_URL', ''),
  44. /*
  45. | 环境标识,会显示在卡片脚注,避免测试环境的告警被误当成线上。
  46. */
  47. 'environment' => env('FEISHU_BOT_ENVIRONMENT', env('APP_ENV', 'production')),
  48. /*
  49. |--------------------------------------------------------------------------
  50. | 告警映射
  51. |--------------------------------------------------------------------------
  52. |
  53. | key 为事件名,value 描述这条告警怎么呈现:
  54. |
  55. | category — 归类,manual = 需人工处理的异常单,cancelled = 超时取消单
  56. | title — 卡片标题
  57. | color — 卡片头部颜色(red / orange / carmine / blue / green / grey)
  58. |
  59. | 想停掉某类告警,注释掉对应行即可,无需改代码。
  60. */
  61. 'alerts' => [
  62. /* 需人工处理的异常单 */
  63. 'bagistoapi.payment.reconcile.approved-unsettled' => [
  64. 'category' => PaymentAlertSubscriber::CATEGORY_MANUAL,
  65. 'title' => '支付已授权但未入账,需人工确认',
  66. 'color' => 'red',
  67. ],
  68. 'bagistoapi.payment.reconcile.settle-failed' => [
  69. 'category' => PaymentAlertSubscriber::CATEGORY_MANUAL,
  70. 'title' => '对账发现扣款但落账失败',
  71. 'color' => 'red',
  72. ],
  73. 'bagistoapi.payment.amount-mismatch' => [
  74. 'category' => PaymentAlertSubscriber::CATEGORY_MANUAL,
  75. 'title' => '支付金额与订单金额不符',
  76. 'color' => 'red',
  77. ],
  78. 'bagistoapi.payment.capture-not-completed' => [
  79. 'category' => PaymentAlertSubscriber::CATEGORY_MANUAL,
  80. 'title' => '网关扣款未完成',
  81. 'color' => 'orange',
  82. ],
  83. 'bagistoapi.payment.reconcile.no-gateway-info' => [
  84. 'category' => PaymentAlertSubscriber::CATEGORY_MANUAL,
  85. 'title' => '订单缺少网关信息,无法对账',
  86. 'color' => 'orange',
  87. ],
  88. /* 超时取消单 */
  89. 'bagistoapi.payment.reconcile.cancelled' => [
  90. 'category' => PaymentAlertSubscriber::CATEGORY_CANCELLED,
  91. 'title' => '支付超时,订单已自动取消',
  92. 'color' => 'grey',
  93. ],
  94. ],
  95. ];