field('paytype,payname') ->where(['paytype' => ['in', $denyPayType]]) ->select(); $this->result($arrPayType, 1, '成功', 'json'); } //v1.pay public function pay() { $data['type'] = input('type'); //类型 1充值平台币 2 充值游戏 $data['paytype'] = input('paytype'); //支付类型 $data['amount'] = input('amount'); //支付金额 $data['accountType'] = input('accountType'); //账号类型1当前账号2其他账号 $data['username'] = input('username'); $data['gameid'] = input('gameid'); $data['serverid'] = input('serverid'); $data['roleid'] = input('roleid'); $data['ip'] = request()->ip(); $checkResult = $this->validate($data, [ ['type', 'require|integer|in:1', '类型不能为空|必须为整型'], ['paytype', 'require', '支付类型不能为空'], ['amount', 'require|integer|egt:0', '支付金额不能为空|支付金额必须为整型|支付金额大于等于0的整型'], ['accountType', 'require|in:1,2', '账号类型不能为空|账号类型错误'], ['username', 'requireIf:accountType,2', '账号必填'], ['gameid', 'requireIf:type,2|integer', '游戏必填|游戏必须为整型'], ['serverid', 'requireIf:type,2', '区服必填'], ['roleid', 'requireIf:type,2', '角色必填'], ['coin_amt', 'float|egt:0', '金额必须为数字|支付金额大于等于0'], ]); if (true !== $checkResult) { $this->result('', 0, $checkResult, 'json'); } if (!in_array($data['paytype'], ['airwallex'])) { $this->jsonResult('', 0, '支付类型错误'); } if (in_array($data['paytype'], ['airwallex']) && $data['accountType'] != 1) { $this->jsonResult('', 0, '支付方式错误'); } if ($data['accountType'] == 2) { if (!$user = (new Members())->getUseridByName($data)) { $this->result([], 0, '账号不存在'); } $data['member_id'] = $user['id']; } else { if(!session('front_userid')){ $this->result([], 0, '未登录请先登录'); } $data['member_id'] = session('front_userid'); if (!$user = (new Members())->getUseridById($data)) { $this->result([], 0, '账号不存在'); } } $data['place_user_id'] = session('front_userid'); if ($data['type'] == 1) {//充值平台币 $data['coin_amt'] = 0; $result = (new MemberCoinService())->payCoin($data); } // else { // // $data['attach'] = makeOrderid('CP'); //上一级的扩展参数,多数是订单编号[祈盟文化自己聚合自己时,会加个aoyou###前缀] // $data['ptb_amt'] = 0; //专属币使用金额 // $data['imeil'] = 'pc'; //手机imeil码 // $data['productname'] = '游戏充值'; //消费的商品名称 // // // if($data['accountType'] == 2 || $data['type'] == 1){ // $data['coin_amt'] = 0; // }else{ // $data['coin_amt'] = input('coin_amt'); //平台币使用金额 // } // // $result = (new GamePayService())->gamePay($data,2); // // //全部平台币支付,并且支付成功时 // if ($result['code'] == 1 && (isset($result['data']['pay_status'])&& $result['data']['pay_status'] == 1)) { // // // 通知CP,支付成功 // (new PayCallback())->callBackToCp($result['data']['orderid']); // (new PayLogic())->payWarning($data['member_id'], $result['data']['channel_id'], $data['gameid'], $data['amount']); // } // } if ($result['code'] == 1) { $this->jsonResult($result['data'], 1, (isset($result['data']['pay_status'])&&$result['data']['pay_status'] == 1) ? '付款成功' : '订单生成成功', false); } else { $this->jsonResult('', 0, $result['msg']); } } /** * 获取可支付游戏 */ public function getGameList() { $this->result((new Game())->getGameListPay(), 1, '成功'); } public function getServerList() { $data['gameid'] = input('gameid'); //游戏id $checkResult = $this->validate($data, [ ['gameid', 'require|integer|gt:0', '游戏id不能为空|游戏id必须为整型|游戏id大于0的整型'], ]); if (true !== $checkResult) { $this->result('', 0, $checkResult, 'json'); } $this->result((new GameServer())->getServerList($data), 1, '成功'); } public function getRoleList() { $data['gameid'] = input('gameid'); //游戏id $data['serverid'] = input('serverid'); //游戏id $data['accountType'] = input('accountType'); //账号类型1当前账号2其他账号 $data['username'] = input('username'); $checkResult = $this->validate($data, [ ['gameid', 'require|integer|gt:0', '游戏id不能为空|游戏id必须为整型|游戏id大于0的整型'], ['serverid', 'require|integer|gt:0', '区服id不能为空|区服id必须为整型区服id大于0的整型'], ['accountType', 'require|in:1,2', '账号类型不能为空|账号类型错误'], ['username', 'requireIf:accountType,2', '账号必填'] ]); if (true !== $checkResult) { $this->result('', 0, $checkResult, 'json'); } if ($data['accountType'] == 2) { if (!$user = (new Members())->getUseridByName($data)) { $this->result([], 0, '账号不存在'); } $data['userid'] = $user['id']; } else { $data['userid'] = session('front_userid'); } $this->result((new MemberGameServer())->getRoleList($data), 1, '成功'); } public function verifyUserName() { $data['username'] = input('username'); //游戏id $checkResult = $this->validate($data, [ ['username', 'require', '账号不能为空'], ]); if (true !== $checkResult) { $this->result('', 0, $checkResult, 'json'); } $user = (new Members())->getUserName($data); if ($user) { $this->result($user, 1, '成功'); } else { $this->result([], 0, '账号不存在'); } } public function payHtml() { $data['data'] = input('data'); $checkResult = $this->validate($data, [ ['data', 'require', '参数不能为空'], ]); if (true !== $checkResult) { $this->result('', 0, $checkResult, 'json'); } if (!$data = json_decode(opensslDecrypt($data['data']), true)) { $this->result('', 0, '订单不存在', 'json'); } $this->assign('data', $data); return $this->fetch(); } public function recharge() { $this->setPreUrl(); $this->_isLogin(); if (is_mobile_request()) { $url = MOBILE_SITE_DOMAIN . '/coin/recharge.html?' . http_build_query(input()); header("Location: $url"); exit(); } $token = input('token'); $token = str_ireplace(" ", "+", $token); if ($token) { try { //聚合渠道时,$sub_username对应的值是mg_username list($userid2, $username2, $gameid2, $sub_username, $token_random, $type) = explode('|', auth_code($token, "DECODE", Env::get('auth_key'))); // var_dump($userid2, $username2, $gameid2,$sub_username,$token_random,$type);die(); $redisTokenRandom = Cache::store('default')->get('token|' . $type . '|' . $userid2 . '|' . $gameid2); $this->assign('username2', $username2); } catch (Exception $e) { $username2 = ''; } } else { $username2 = ''; } $this->assign('username2', $username2); return $this->fetch(); } public function getCoin(){ if (session('front_userid')){ model('MemberCoinInfo')->releaseCoin(session('front_userid')); $userinfo = model('members')->field('id,amount')->where('id',session('front_userid'))->find(); $this->jsonResult($userinfo, 1,'获取成功'); }else{ $this->jsonResult(['id'=>'','amount'=>'0'], 1,'获取成功'); } } public function airwallex() { $pay = new AirwallexPay(); $pay->getToken(); // $money = input('money', 0, 'intval'); $orderid = input('orderid', ''); $goods = urldecode(input('goods', '')); $urltype = input('urltype',1); $money = cache('memberCoin:real_amount:'.$orderid); if($urltype == 1){ $return_url = 'https://www.46yx.com/coin_airwallex/recharge.html'; }elseif($urltype == 3){ $return_url = "https://" . HTTP_HOST_URL . "/v1.pay_return/pay_success_airwallex.html"; } if($money<0){ echo 'money err'; exit(); } if(!$orderid){ echo 'orderid err'; exit(); } $result = $pay->createOrder($money, $orderid,$return_url); $result['goods'] = $goods; $this->assign('result', $result); $this->assign('orderid', $orderid); return $this->fetch(); } }