$type, ]; if ($key) { $arr['key'] = $key; } if ($desc) { $arr['desc'] = $desc; } $json = json_encode($arr); $r->lpush($rk, $json); } /** * this function should be called in timer process. */ public static function notify() { $r = Redis::instance(); $k = Config::get('app.redis_robot_msg_key'); $aristotle = Config::get('app.qy_weixin_robot_aristotle'); $supported_types = [ 'refund' => '退款', 'order' => '订单', 'compliant' => '反馈建议', 'withdraw' => '提现请求', 'message' => '客服消息', 'recharge' => '充值', 'comment' => '商品评论', ]; $total = $r->llen($k); while ($total > 0) { $json = $r->rpop($k); $arr = json_decode($json, true); if (!isset($arr['type']) || !is_string($arr['type'])) { continue; } $type = $arr['type']; $key = isset($arr['key']) ? $arr['key'] : ''; if (!isset($supported_types[$type])) { continue; } $desc = isset($arr['desc']) ? $arr['desc'] : ''; $msg = $supported_types[$type]; $md = "### 新" . $msg . "\n>key: " . $key . "\n备注:" . $desc; QyWeixinService::instance()->key($aristotle) ->markdown($md)->post(); $total = $r->llen($k); }// while }// }