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['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']);
$data = array(

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

@ -874,21 +874,39 @@ class BaseController extends RestController{
/**
* 获取cp传过来的订单号等信息在exchange接口
*/
public function get_sdk_request($game_id) {
if (!$this->userId) {
return ;
public function get_sdk_request($game_id, $user_id=0) {
if (!$user_id) {
if (!$this->userId) {
return ;
}
$user_id = $this->userId;
}
$payInfo = M("pay_info", "tab_")->where([
'user_id' => $this->userId,
'user_id' => $user_id,
'game_id' => $game_id
])->order('id desc')->find();
if (!$payInfo || !$payInfo['info']) {
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,68 +32,74 @@ class ExchangeController extends BaseController{
$request = SafeFilter($request);
// $request['server_id'] = 0;
// $request['game_player_id'] = 0;
if (empty($request['server_id']) && empty($request['serve_name'])
&& empty($request['game_player_id']) && empty($request['game_player_name'])) {
$this->set_message(0,"fail","未上传角色,不允许充值.");
}
if ($request['code'] == 1) {
if (empty($request['server_id']) && empty($request['serve_name'])
&& empty($request['game_player_id']) && empty($request['game_player_name'])) {
$this->set_message(0,"fail","未上传角色,不允许充值.");
}
if (!isset($request['server_id']) || !$request['server_id']
|| !isset($request['game_player_id']) || !$request['game_player_id']
) {
// 加入日志表
M('serverid_null_log', 'tab_')->add([
'user_id' => $request['user_id'],
'game_id' => $request['game_id'],
'sdk_version' => $request['sdk_version'],
'request' => json_encode($request),
'create_time' => time()
]);
if (!$request['server_name']) {
$this->set_message(0,"fail","区服名不能为空");
}
if (!$request['game_id']) {
$this->set_message(0,"fail","game_id不存在");
}
$server = M('server', 'tab_')->where([
'game_id' => $request['game_id'],
'server_name' => $request['server_name']
])->find();
$request['server_id'] = $server['server_id'];
if (!isset($request['server_id']) || !$request['server_id']) {
$unionServer = M('server_union', 'tab_')->where([
'game_id' => $request['game_id'],
'server_name' => $request['server_name']
])->find();
$request['server_id'] = $unionServer['server_id'];
}
$userPlayInfo = M('user_play_info', 'tab_')->where([
'user_id' => $request['user_id'],
'game_id' => $request['game_id'],
'server_name' => $request['server_name']
])->find();
if ($userPlayInfo) {
$request['game_player_id'] = $userPlayInfo['role_id'];
}
}
if (!isset($request['server_id']) || !$request['server_id']
|| !isset($request['game_player_id']) || !$request['game_player_id']
) {
// 加入日志表
M('serverid_null_log', 'tab_')->add([
$role = M("user_play_info", "tab_")->where([
'user_id' => $request['user_id'],
'game_id' => $request['game_id'],
'sdk_version' => $request['sdk_version'],
'request' => json_encode($request),
'create_time' => time()
]);
if (!$request['server_name']) {
$this->set_message(0,"fail","区服名不能为空");
}
if (!$request['game_id']) {
$this->set_message(0,"fail","game_id不存在");
}
$server = M('server', 'tab_')->where([
'game_id' => $request['game_id'],
'server_name' => $request['server_name']
])->find();
$request['server_id'] = $server['server_id'];
if (!isset($request['server_id']) || !$request['server_id']) {
$unionServer = M('server_union', 'tab_')->where([
'game_id' => $request['game_id'],
'server_name' => $request['server_name']
])->find();
$request['server_id'] = $unionServer['server_id'];
}
$userPlayInfo = M('user_play_info', 'tab_')->where([
'user_id' => $request['user_id'],
'game_id' => $request['game_id'],
'server_name' => $request['server_name']
])->find();
if ($userPlayInfo) {
$request['game_player_id'] = $userPlayInfo['role_id'];
}
}
'server_id' => $request['server_id']
])->find();
if (!$role || !$role['role_id']) {
$this->set_message(0,"fail","未上传角色,不允许充值"/* .M("user_play_info", "tab_")->_sql() */);
}
}
$role = M("user_play_info", "tab_")->where([
'user_id' => $request['user_id'],
'game_id' => $request['game_id'],
'server_id' => $request['server_id']
])->find();
if (!$role || !$role['role_id']) {
$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']);
M("pay_info", "tab_")->add([
'user_id' => $request['user_id'],
'game_id' => $request['game_id'],
'order_id' => '',
'order_id' => $request['pay_order_number'],
'extend' => $request['extend'],
'price' => $request['price'],
'type' => '', //
@ -109,18 +115,15 @@ class ExchangeController extends BaseController{
'game_player_id' => $request['game_player_id'],
'sdk_version' => $request['sdk_version'],
'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";
if (isset($request['api_ver']) && $request['api_ver'] == 2) {
$payPage = "pay_way";
// 用户
$userToken = $request['user_token'];
// M('user', 'tab_')->where(['id' => $request['user_id']])->getField('user_token');
// M('user', 'tab_')->where(['id' => $request['user_id']])->getField('user_token');
if (!$userToken) {
$this->set_message(0,"fail","请重新登入");
}
@ -155,7 +158,7 @@ class ExchangeController extends BaseController{
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_";
@ -168,7 +171,7 @@ class ExchangeController extends BaseController{
$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';
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';
// 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;

@ -275,7 +275,6 @@ class PayH5Controller extends BaseController{
public function ali_pay($user_id,$game_id){
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
$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_way'] = C("PAY_WAY.ALIPAY");
$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 = $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_way'] = C("PAY_WAY.WEIXIN");
$request['spend_ip'] = get_client_ip();

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

Loading…
Cancel
Save