Merge branch 'dev' of 47.111.118.107:/srv/git/sdk into dev

master
zhanglingsheng 5 years ago
commit 3f9c9c32e1

@ -42,6 +42,10 @@ class GameApi {
if(empty($game_data)){ $this->error_record("未找到指定游戏数据"); return false;} if(empty($game_data)){ $this->error_record("未找到指定游戏数据"); return false;}
if(empty($game_data['pay_notify_url'])){$this->error_record("未设置游戏支付通知地址"); return false;} if(empty($game_data['pay_notify_url'])){$this->error_record("未设置游戏支付通知地址"); return false;}
// 通知 抵扣的情况
if (isset($pay_data['deduction_amount']) && $pay_data['deduction_amount'] > 0) {
$pay_data['cost'] += $pay_data['deduction_amount'];
}
$md5_sign = md5($pay_data['pay_order_number'].$pay_data['cost']."1".$pay_data['extend'].$game_data['game_key']); $md5_sign = md5($pay_data['pay_order_number'].$pay_data['cost']."1".$pay_data['extend'].$game_data['game_key']);
$data = array( $data = array(

@ -90,8 +90,7 @@ class AppleController extends BaseController{
public function apple_alipay_pay($user_id,$game_id){ public function apple_alipay_pay($user_id,$game_id){
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组 #获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
//echo json_encode(['code'=>0,'msg'=> $user_id."game:".$game_id]);exit; //echo json_encode(['code'=>0,'msg'=> $user_id."game:".$game_id]);exit;
$request = $this->get_sdk_request($game_id); $request = $this->get_sdk_request($game_id, $user_id);
$request['pay_order_number'] = "SP_".date('Ymd').date('His').sp_random_string(4);
$request['pay_status'] = 0; $request['pay_status'] = 0;
$request['pay_way'] = C("PAY_WAY.ALIPAY"); $request['pay_way'] = C("PAY_WAY.ALIPAY");
$request['spend_ip'] = get_client_ip(); $request['spend_ip'] = get_client_ip();
@ -360,8 +359,7 @@ class AppleController extends BaseController{
*/ */
public function apple_weixin_pay($user_id,$game_id) public function apple_weixin_pay($user_id,$game_id)
{ {
$request = $this->get_sdk_request($game_id); $request = $this->get_sdk_request($game_id, $user_id);
$request['pay_order_number'] = "SP_".date('Ymd').date('His').sp_random_string(4);
$request['pay_status'] = 0; $request['pay_status'] = 0;
$request['pay_way'] = C("PAY_WAY.WEIXIN"); $request['pay_way'] = C("PAY_WAY.WEIXIN");
$request['spend_ip'] = get_client_ip(); $request['spend_ip'] = get_client_ip();
@ -400,11 +398,13 @@ class AppleController extends BaseController{
//$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付"); //$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
redirect(U('Spend/notice_v1',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'订单号重复,请关闭支付页面重新支付')));exit; redirect(U('Spend/notice_v1',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'订单号重复,请关闭支付页面重新支付')));exit;
} }
$table = $request['code'] == 1 ? "spend" : "deposit"; /* $table = $request['code'] == 1 ? "spend" : "deposit";
$prefix = $request['code'] == 1 ? "SP_" : "PF_"; $prefix = $request['code'] == 1 ? "SP_" : "PF_";
$request['pay_way'] = 3; $request['pay_order_number'] = $prefix."_".date('Ymd').date('His').sp_random_string(4); */
$request['pay_way'] = C('PAY_WAY.WEIXIN');
$request['pay_status'] = 0; $request['pay_status'] = 0;
$request['spend_ip'] = get_client_ip(); $request['spend_ip'] = get_client_ip();
//折扣 //折扣
$user = get_user_entity($request['user_id']); $user = get_user_entity($request['user_id']);
$discount = $this->get_discount($request['game_id'],$user['promote_id'],$request['user_id']); $discount = $this->get_discount($request['game_id'],$user['promote_id'],$request['user_id']);
@ -644,8 +644,14 @@ class AppleController extends BaseController{
* @author 鹿文学 * @author 鹿文学
*/ */
public function apple_platform_pay($user_id,$game_id) { public function apple_platform_pay($user_id,$game_id) {
$file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt"); /* $file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt");
$request = json_decode(think_decrypt($file),true); $request = json_decode(think_decrypt($file),true); */
$request = $this->get_sdk_request($game_id, $user_id);
$request['pay_status'] = 0;
// $request['pay_way'] = C("PAY_WAY.ALIPAY");
$request['spend_ip'] = get_client_ip();
$out_trade_no = $request['pay_order_number'];
$code = $_POST['way']; $code = $_POST['way'];
@ -675,7 +681,6 @@ class AppleController extends BaseController{
// $this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付"); // $this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
redirect(U('Spend/notice_v1',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'订单号重复,请关闭支付页面重新支付')));exit; redirect(U('Spend/notice_v1',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'订单号重复,请关闭支付页面重新支付')));exit;
} }
$out_trade_no = "PF_" . date('Ymd') . date('His') . sp_random_string(4);
$request['order_number'] = $out_trade_no; $request['order_number'] = $out_trade_no;
$request['pay_order_number'] = $out_trade_no; $request['pay_order_number'] = $out_trade_no;
$request['out_trade_no'] = $out_trade_no; $request['out_trade_no'] = $out_trade_no;

@ -874,21 +874,39 @@ class BaseController extends RestController{
/** /**
* 获取cp传过来的订单号等信息在exchange接口 * 获取cp传过来的订单号等信息在exchange接口
*/ */
public function get_sdk_request($game_id) { public function get_sdk_request($game_id, $user_id=0) {
if (!$user_id) {
if (!$this->userId) { if (!$this->userId) {
return ; return ;
} }
$user_id = $this->userId;
}
$payInfo = M("pay_info", "tab_")->where([ $payInfo = M("pay_info", "tab_")->where([
'user_id' => $this->userId, 'user_id' => $user_id,
'game_id' => $game_id 'game_id' => $game_id
])->order('id desc')->find(); ])->order('id desc')->find();
if (!$payInfo || !$payInfo['info']) { if (!$payInfo || !$payInfo['info']) {
return ; return ;
} }
$request = json_decode($payInfo['info'], true); $info = json_decode($payInfo['info'], true);
$info['pay_order_number'] = $payInfo['order_id'];
return $info;
return $request;
} }
/**
* 更新pay_info信息
*/
public function update_pay_info($id, $data) {
if (!$id || !$data) return 0;
$info['pay_order_number'] = $order_id;
$r = M("pay_info", "tab_")->where([
'id' => $id
])->save($data);
return $r;
}
} }

@ -32,6 +32,7 @@ class ExchangeController extends BaseController{
$request = SafeFilter($request); $request = SafeFilter($request);
// $request['server_id'] = 0; // $request['server_id'] = 0;
// $request['game_player_id'] = 0; // $request['game_player_id'] = 0;
if ($request['code'] == 1) {
if (empty($request['server_id']) && empty($request['serve_name']) if (empty($request['server_id']) && empty($request['serve_name'])
&& empty($request['game_player_id']) && empty($request['game_player_name'])) { && empty($request['game_player_id']) && empty($request['game_player_name'])) {
$this->set_message(0,"fail","未上传角色,不允许充值."); $this->set_message(0,"fail","未上传角色,不允许充值.");
@ -88,12 +89,17 @@ class ExchangeController extends BaseController{
if (!$role || !$role['role_id']) { if (!$role || !$role['role_id']) {
$this->set_message(0,"fail","未上传角色,不允许充值"/* .M("user_play_info", "tab_")->_sql() */); $this->set_message(0,"fail","未上传角色,不允许充值"/* .M("user_play_info", "tab_")->_sql() */);
} }
}
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
$out_trade_no = $prefix.date('Ymd').date('His').sp_random_string(4);
$request['pay_order_number'] = $out_trade_no;
$user_entity = get_user_entity($request['user_id']); $user_entity = get_user_entity($request['user_id']);
M("pay_info", "tab_")->add([ M("pay_info", "tab_")->add([
'user_id' => $request['user_id'], 'user_id' => $request['user_id'],
'game_id' => $request['game_id'], 'game_id' => $request['game_id'],
'order_id' => '', 'order_id' => $request['pay_order_number'],
'extend' => $request['extend'], 'extend' => $request['extend'],
'price' => $request['price'], 'price' => $request['price'],
'type' => '', // 'type' => '', //
@ -109,12 +115,9 @@ class ExchangeController extends BaseController{
'game_player_id' => $request['game_player_id'], 'game_player_id' => $request['game_player_id'],
'sdk_version' => $request['sdk_version'], 'sdk_version' => $request['sdk_version'],
'promote_account' => $user_entity['promote_account'], 'promote_account' => $user_entity['promote_account'],
'ip' => get_client_ip(),
]); ]);
/* if (!isset($request['api_ver'])) {
$payPage = "pay_way_v1";
} else {
$payPage = "pay_way_v".$request['api_ver'];
} */
$payPage = "pay_way_v1"; $payPage = "pay_way_v1";
if (isset($request['api_ver']) && $request['api_ver'] == 2) { if (isset($request['api_ver']) && $request['api_ver'] == 2) {
$payPage = "pay_way"; $payPage = "pay_way";
@ -155,7 +158,7 @@ class ExchangeController extends BaseController{
if($request['code'] == 0) { /* 平台币充值 */ if($request['code'] == 0) { /* 平台币充值 */
file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$request['scheme']); // file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$request['scheme']);
$prefix = "PF_"; $prefix = "PF_";
@ -168,7 +171,7 @@ class ExchangeController extends BaseController{
$request['spend_ip'] = get_client_ip(); $request['spend_ip'] = get_client_ip();
// $url = C('PAY_DOMAIN') . '/sdk.php?s=/Spend/'.$payPage.'&user_id='.$request['user_id'].'&game_id='.$request['game_id'].'&type=1'.'&user_token='.$userToken.'&action=pay'; // $url = C('PAY_DOMAIN') . '/sdk.php?s=/Spend/'.$payPage.'&user_id='.$request['user_id'].'&game_id='.$request['game_id'].'&type=1'.'&user_token='.$userToken.'&action=pay';
file_put_contents("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request))); // file_put_contents("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request)));
// $url = C('PAY_DOMAIN') . '/sdk.php?s=/userH/platform_pay/account/'.$request['account'].'&user_token='.$userToken.'&game_id='.$request['game_id'].'&money='.$request['price'].'&action=pay1&api_ver=1'; // $url = C('PAY_DOMAIN') . '/sdk.php?s=/userH/platform_pay/account/'.$request['account'].'&user_token='.$userToken.'&game_id='.$request['game_id'].'&money='.$request['price'].'&action=pay1&api_ver=1';
// echo base64_encode(json_encode(array('status'=>200,'out_trade_no'=>$out_trade_no,'img'=>$url))); // echo base64_encode(json_encode(array('status'=>200,'out_trade_no'=>$out_trade_no,'img'=>$url)));
echo base64_encode(json_encode(array('status'=>200,'out_trade_no'=>$out_trade_no,'img'=>C('PAY_DOMAIN').'/sdk.php?s=/Spend/pay_way_v1&user_id='.$request['user_id'].'&game_id='.$request['game_id'].'&type=1'.'&user_token='.$userToken)));exit; echo base64_encode(json_encode(array('status'=>200,'out_trade_no'=>$out_trade_no,'img'=>C('PAY_DOMAIN').'/sdk.php?s=/Spend/pay_way_v1&user_id='.$request['user_id'].'&game_id='.$request['game_id'].'&type=1'.'&user_token='.$userToken)));exit;

@ -275,7 +275,6 @@ class PayH5Controller extends BaseController{
public function ali_pay($user_id,$game_id){ public function ali_pay($user_id,$game_id){
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组 #获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
$request = $this->get_sdk_request($game_id); $request = $this->get_sdk_request($game_id);
$request['pay_order_number'] = "SP_".date('Ymd').date('His').sp_random_string(4);
$request['pay_status'] = 0; $request['pay_status'] = 0;
$request['pay_way'] = C("PAY_WAY.ALIPAY"); $request['pay_way'] = C("PAY_WAY.ALIPAY");
$request['spend_ip'] = get_client_ip(); $request['spend_ip'] = get_client_ip();
@ -1220,7 +1219,7 @@ ADD COLUMN `pay_url` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER
$request = json_decode(think_decrypt($file),true); */ $request = json_decode(think_decrypt($file),true); */
$request = $this->get_sdk_request($game_id); $request = $this->get_sdk_request($game_id);
$request['pay_order_number'] = "SP_".date('Ymd').date('His').sp_random_string(4); // $request['pay_order_number'] = "SP_".date('Ymd').date('His').sp_random_string(4);
$request['pay_status'] = 0; $request['pay_status'] = 0;
$request['pay_way'] = C("PAY_WAY.WEIXIN"); $request['pay_way'] = C("PAY_WAY.WEIXIN");
$request['spend_ip'] = get_client_ip(); $request['spend_ip'] = get_client_ip();

@ -1256,8 +1256,8 @@ class UserController extends BaseController
$user_data = $user -> find($user_id); $user_data = $user -> find($user_id);
$gameName = get_game_name($request['game_id']); $gameName = get_game_name($request['game_id']);
$data['promote_id'] = $request['promote_id']; //$data['promote_id'] = $request['promote_id'];
$data['promote_account'] = get_promote_account($request['promote_id']); //$data['promote_account'] = get_promote_account($request['promote_id']);
$data['game_id'] = $request['game_id']; $data['game_id'] = $request['game_id'];
$data['game_name'] = $gameName; $data['game_name'] = $gameName;
$data['server_id'] = $request['server_id']; $data['server_id'] = $request['server_id'];
@ -1284,6 +1284,8 @@ class UserController extends BaseController
// $data['create_device_number'] = time(); // $data['create_device_number'] = time();
// 修改重复插入问题 增加唯一索引 记录重复插入异常 // 修改重复插入问题 增加唯一索引 记录重复插入异常
try { try {
$data['promote_id'] = $user_data['promote_id'];
$data['promote_account'] = $user_data['promote_account'];
$user_play->add($data); $user_play->add($data);
$this -> set_message(200, "success", $user_play->_sql()); $this -> set_message(200, "success", $user_play->_sql());
} catch (\Exception $e) { } catch (\Exception $e) {

Loading…
Cancel
Save