1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * 第三方接口
- * User: solu
- * Date: 2018/12/10
- * Time: 4:40 PM
- */
- class ThirdApi {
- /**
- * 上报游戏结果
- * @author solu
- * @param $gameId
- * @param $betAmount
- * @param $winAmount
- * @param string $appid
- * @return mixed
- */
- public static function reportGameResult($gameId, $betAmount, $winAmount, $appid = 'box') {
- $api = URL_SICBO . 'eos/gameResult';
- $data = [
- 'gameid' => $gameId,
- 'game_name' => $appid,
- 'bet_amount' => $betAmount,
- 'win_amount' => $winAmount,
- ];
- $objEosAES = new EosAES($GLOBALS['codeGtAdmin']);
- $objHttp = new dwHttp();
- $seed = "{$appid}|{$gameId}";
- $data['sign'] = $objEosAES->encode($seed);
- $resp = $objHttp->post2($api, $data);
- return json_decode($resp, true);
- }
- /**
- * 推送事件
- * @author solu
- * @param $channel
- * @param $data
- * @param null $objRedis
- * @return int
- */
- public static function event($channel, $data, $objRedis = null) {
- !$objRedis && $objRedis = dwRedis::initNewOne();
- if (is_array($data)) {
- $data = json_encode($data);
- }
- return $objRedis->publish($channel, $data);
- }
- public static function pushPersonEvent($to, array $data) {
- $channel = "chat:person:{$to}";
- !$data['timestamp'] && $data['timestamp'] = Session::getMS();
- return self::event($channel, $data);
- }
- public static function pushGroupEvent($groupId, array $data) {
- $channel = 'chat:group'; // 全局
- !$data['timestamp'] && $data['timestamp'] = Session::getMS();
- $data['group_id'] = $groupId;
- $groupId > 0 && $channel .= ":{$groupId}";
- return self::event($channel, $data);
- }
- }
|