| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace app\api\complex;
- use think\Request;
- /**
- * 从语
- */
- class Congyu implements ComplexInterface
- {
- private $channel = 'congyu';
- /**
- * ## 登陆 - 校验
- *
- * @param $data
- * @param $polyChannelGame
- *
- * @return false
- */
- public function getSpecialParam($data, $polyChannelGame = [])
- {
- // 参数:channel_token = sid
- if (!isset($data['channel_token'])) {
- return false;
- }
- if (empty($polyChannelGame['param'])) {
- return false;
- }
- if (!$channelConfig = json_decode($polyChannelGame['param'], true)) {
- return false;
- }
- $res = getHttpPost('http://api.cqchongyu.com/user/info', ['token' => $data['channel_token']]);
- $res = json_decode($res, true);
- if ($res['errorno'] == 200) {
- return $res['data']['uid'];
- }
- return false;
- }
- // ## 登陆 - 登陆
- public function checkLogin($data, $polyChannelGame = [])
- {
- return ['user_id' => $data['user_id']];
- }
- // ## 回调 - 效验
- public function paySign($data, $polyChannelGame = [])
- {
- $param = Request::instance()->only(['version', 'gameId', 'paySn', 'orderSn', 'itemName', 'userId', 'orderAmount', 'sign', 'developerInfo']);
- if (!$channelConfig = json_decode($polyChannelGame['param'], true)) {
- return false;
- }
- ksort($param);
- $string = "";
- foreach ($param as $k => $v) {
- if($k == 'sign'){
- continue;
- }
- if ($string) {
- $string .= "&{$k}={$v}";
- } else {
- $string = "{$k}={$v}";
- }
- }
- $sign = $string."&".$channelConfig['secretKey'];
- $md5Res = md5($sign);
- if ($param['sign'] == $md5Res) {
- return true;
- }
- return false;
- }
- // ## 回调 - 下单参数获取
- public function getData($data)
- {
- if (!isset($data['developerInfo']) || !isset($data['orderAmount']) || !isset($data['orderSn'])) {
- return false;
- }
- return [
- 'orderid' => $data['developerInfo'], // 我方聚合订单
- 'amount' => formatFenToYuan($data['orderAmount']),// 充值金额(单位:元)
- 'sub_orderid' => $data['orderSn'], // 渠道订单
- ];
- }
- // ## 回调 - 成功返回
- public function getSuccess($msg = '')
- {
- echo "success";
- exit();
- }
- // ## 回调 - 失败返回
- public function getFail($msg = '')
- {
- echo "fail";
- exit();
- }
- }
|