From bb7738864d3d9365b9029e2c9c5394cb468d2346 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 30 Sep 2019 10:20:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/BaseController.class.php | 210 ------------------ 1 file changed, 210 deletions(-) diff --git a/Application/Callback/Controller/BaseController.class.php b/Application/Callback/Controller/BaseController.class.php index 6aa04e2cf..65b29bbda 100644 --- a/Application/Callback/Controller/BaseController.class.php +++ b/Application/Callback/Controller/BaseController.class.php @@ -4,7 +4,6 @@ namespace Callback\Controller; use Think\Controller; use Common\Api\GameApi; use Org\UcenterSDK\Ucservice; -use Think\Log; /** * 支付回调控制器 * @author 小纯洁 @@ -55,7 +54,6 @@ class BaseController extends Controller { $spend = M('Spend',"tab_"); $map['pay_order_number'] = $data['out_trade_no']; $d = $spend->where($map)->find(); - if(empty($d)){$this->record_logs("数据异常");return false;} // 支付金额判断 by zgc if ($d['pay_amount'] != $data['money']) { @@ -63,63 +61,6 @@ class BaseController extends Controller { } if($d['pay_status'] == 0){ - // 处理绑币平台币优先处理 - if ($d['deduction_amount'] > 0) { - $out_trade_no = "PF_" . date('Ymd') . date('His') . sp_random_string(4); - - $bind_balance = M('user_play', 'tab_')->where(array( - 'user_id' => $d['user_id'], - 'game_id' => $d['game_id'] - ))->getField('bind_balance'); - $request = $d; - $request['pay_order_number'] = $out_trade_no; - $request['price'] = $bind_balance; - $request['deduction_amount'] = 0; - $request['pay_way'] = -1; - $request['pay_status'] = 1; - - if ($d['deduction_amount'] > $bind_balance) - $bb = 0; - else - $bb = $bind_balance - $d['deduction_amount']; - - if ($bind_balance > 0) { - M('user_play', 'tab_')->where(array( - 'user_id' => $d['user_id'], - 'game_id' => $d['game_id'] - ))->save(array( - 'bind_balance' => $bb - )); - - $result = $this->add_spend($request); - $this->set_ratio($request['pay_order_number'], 2); // 游戏返利 - } - - if ($bb == 0) { - $mbalance = $d['deduction_amount'] - $bind_balance; - if ($mbalance > 0) { - $request['pay_way'] = 0; - $request['pay_order_number'] = $request['pay_order_number']."_1"; - $request['price'] = $mbalance; - $balance = M('user', 'tab_')->where(array( - 'id' => $d['user_id'], - ))->getField('balance'); - - if ($balance < $mbalance) { // 异常 - $this->record_logs($mbalance."平台币余额不足".$balance);return false; - } - M('user', 'tab_')->where(array( - 'id' => $d['user_id'] - ))->save(array( - 'balance' => $balance - $mbalance, - )); - $result = $this->add_spend($request); - $this->set_ratio($request['pay_order_number'], 2); // 游戏返利 - } - } - - } - $data_save['pay_status'] = 1; $data_save['order_number'] = $data['trade_no']; $map_s['pay_order_number'] = $data['out_trade_no']; @@ -523,155 +464,4 @@ class BaseController extends Controller { fwrite($myfile, $txt); fclose($myfile); } - - /** - *消费表添加数据 - */ - public function add_spend($data,$type=0){ - $spend = M("spend","tab_"); - $spend_data = $this->spend_param($data); - $ordercheck = $spend->where(array('pay_order_number'=>$spend_data["pay_order_number"]))->find(); - if($ordercheck) - { - if($type==1){ - redirect(U('Spend/notice',array('user_id'=>$ordercheck['user_id'],'game_id'=>$ordercheck['game_id'],'msg'=>'订单已经存在,请刷新充值页面重新下单!')));exit; - }else{ - $this->set_message(0,'fail',"订单已经存在,请刷新充值页面重新下单!"); - } - } - // if(!is_check_apply_promote($spend_data['game_id'],$spend_data['promote_id'])){ - // $spend_data['promote_id']=0; - // $spend_data['promote_account']="自然注册"; - // } - $result = $spend->add($spend_data); - return $result; - } - - /** - *消费记录表 参数 - */ - private function spend_param($param=array()){ - $user_entity = get_user_entity($param['user_id']); - $data_spned['user_id'] = $param["user_id"]; - $data_spned['user_account'] = $user_entity["account"]; - $data_spned['user_nickname'] = $user_entity["nickname"]; - $data_spned['game_id'] = $param["game_id"]; - $data_spned['game_appid'] = $param["game_appid"]; - $data_spned['game_name'] = get_game_name($param["game_id"]); - $data_spned['selle_ratio'] = get_game_selle_ratio($param["game_id"]); - $data_spned['server_id'] = $param["server_id"]; - $data_spned['server_name'] = $param["server_name"]; - $data_spned['game_player_name'] = $param["game_player_name"]; - $data_spned['promote_id'] = $user_entity["promote_id"]; - $data_spned['promote_account'] = $user_entity["promote_account"]; - $data_spned['order_number'] = $param["order_number"]; - $data_spned['pay_order_number'] = $param["pay_order_number"]; - $data_spned['props_name'] = $param["title"]; - $data_spned['cost'] = $param["price"];//原价 - $data_spned['deduction_amount'] = $param["deduction_amount"];// 抵扣价格 - $data_spned['discount_amount'] = $param["discount_amount"];// 折扣价格 - $data_spned['pay_time'] = NOW_TIME; - $data_spned['pay_status'] = $param["pay_status"]; - $data_spned['pay_game_status'] = 0; - $data_spned['extend'] = $param['extend']; - $data_spned['pay_way'] = $param["pay_way"]; - if($data_spned['pay_way'] != 7){ - $discount = $this->get_discount($param['game_id'],$user_entity['promote_id'],$param['user_id']); - $data_spned['pay_amount'] = $param["price"] * $discount['discount']/10;//实付金额 - $data_spned['discount_type'] = $discount['discount_type']; - }else{//苹果支付不计入折扣 - $data_spned['pay_amount'] = $param["price"]; - $data_spned['discount_type'] = 0; - } - if (isset($param['actual_amount']) && $param['actual_amount']) - $data_spned['pay_amount'] = $param['actual_amount']; // 实际支付价格 - $data_spned['spend_ip'] = $param["spend_ip"]; - $data_spned['sdk_version'] = $param["sdk_version"]; - if($param['small_user_id'] != $param['user_id']) { - $data_spned['small_id'] = $param["small_user_id"]; - $data_spned['small_account'] = get_user_account_by_id($param['small_user_id']); - } - return $data_spned; - } - - /** - * 获取用户折扣 - * @param $game_id 游戏ID - * @param $promote_id 渠道ID - * @param $user_id 用户ID - * @return mixed - */ - protected function get_discount($game_id,$promote_id,$user_id){ - //获取折扣 - $map['game_id'] = $game_id; - $map['promote_id'] =-1; - $map['status'] = 2; - $discount = M('Promote_welfare','tab_')->where($map)->find(); - if(null==$discount){ - $map['game_id'] = $game_id; - $map['promote_id'] = $promote_id == 0 ? 0 : -2; - $map['status'] = 2; - $discount = M('Promote_welfare','tab_')->where($map)->find(); - } - $discount = discount_data($discount); - if(empty($discount)){ - $res['discount'] = 10; - $res['discount_type'] = 0;//无折扣 - return $res; - } - - //判断用户是否为首冲 - $where['game_id'] = $game_id; - $where['user_id'] = $user_id; - $where['pay_status'] = 1; - $data = M('bind_spend','tab_')->where($where)->find(); - if(!empty($data) || !empty(M('spend','tab_')->where($where)->find())){ - $res['discount'] = $discount['continue_discount'];//续冲 - $res['discount_type'] = 2; - }else{ - $res['discount'] = $discount['first_discount'];//首冲 - $res['discount_type'] = 1; - } - return $res; - } - - /** - *游戏返利 - *$type 类型 1 非绑定平台币 2绑定平台币 - */ - /* public function set_ratio($data,$type = 1){ - $map['pay_order_number']=$data; - $map['pay_way'] = ($type==2) ? -1 : 0; // 判断支付类型 - $spend=M("Spend","tab_")->where($map)->find(); - $reb_map['game_id']=$spend['game_id']; - $time = time(); - $reb_map['starttime'] = ['lt',$time]; - $reb_map_str = "endtime > {$time} or endtime = 0"; - switch ($spend['promote_id']) { - case 0: - $reb_map['promote_id'] = array('in','0,-1'); - break; - default: - $reb_map['promote_id'] = array('in','1,-1'); - break; - } - - - //如果是绑币则判断是否开启绑币返利 - if($type == 2){$reb_map['bind_status'] = 1;} - $rebate=M("Rebate","tab_")->where($reb_map)->where($reb_map_str)->find();// - if (!empty($rebate)) { - if($rebate['money']>0 && $rebate['status']==1){ - if($spend['pay_amount']>=$rebate['money']){ - $this->compute($spend,$rebate); - }else{ - return false; - } - }else{ - $this->compute($spend,$rebate); - } - }else{ - return false; - } - } */ } \ No newline at end of file