diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 24c77deac..02e6809e1 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -293,7 +293,7 @@ function get_pay_way($id=null) return "微信APP"; break; case 4: - return "威富通"; + return "汇付宝"; break; case 5: return "聚宝云"; @@ -1485,6 +1485,7 @@ function cash_pay_way() $pay_way[3]=array('key'=>2,'value'=>"微信"); // $pay_way[3]=array('key'=>3,'value'=>'微信APP'); // $pay_way[4]=array('key'=>4,'value'=>'威富通'); + $pay_way[4]=array('key'=>4,'value'=>'汇付宝'); /* $pay_way[4]=array('key'=>5,'value'=>'聚宝云'); */ // $pay_way[5]=array('key'=>6,'value'=>'汇付宝'); /* $pay_way[6]=array('key'=>7,'value'=>"苹果支付"); @@ -1823,7 +1824,7 @@ function all_pay_way_other($type=false) // $pay_way[3]=array('key'=>3,'value'=>'微信APP'); // $pay_way[4]=array('key'=>4,'value'=>'威富通'); /* $pay_way[4]=array('key'=>5,'value'=>'聚宝云'); */ -// $pay_way[5]=array('key'=>6,'value'=>'汇付宝'); + $pay_way[5]=array('key'=>4,'value'=>'汇付宝'); /* $pay_way[6]=array('key'=>7,'value'=>"苹果支付"); */ $pay_way[15]=array('key'=>15,'value'=>'双乾支付-快捷'); diff --git a/Application/Admin/Controller/CompanyGameRatioController.class.php b/Application/Admin/Controller/CompanyGameRatioController.class.php index 968f39e3d..bfe5d3cc1 100644 --- a/Application/Admin/Controller/CompanyGameRatioController.class.php +++ b/Application/Admin/Controller/CompanyGameRatioController.class.php @@ -14,6 +14,12 @@ class CompanyGameRatioController extends AdminController "1"=>"市场部通过", "2"=>"管理员通过" ]; + public $SettlementType=[ + "-1"=>"未设定", + "0"=>"无", + "1"=>"周结", + "2"=>"月结" + ]; public function _initialize() { $this->admininfo = $_SESSION['onethink_admin']['user_auth']; @@ -36,23 +42,56 @@ class CompanyGameRatioController extends AdminController $gamewhere['relation_game_id'] = $params['relation_game_id']; $where['m.relation_game_id'] = $params['relation_game_id']; } + $pwhere = false; + if(isset($params['company_belong'])){ + $pwhere = " and p.company_belong = {$params['company_belong']}"; + } + + if(isset($params['company_id'])){ $where['m.company_id'] = $params['company_id']; } - $this->checkListOrCountAuthRestMap($where); + + if(isset($params['game_type'])){ + $gamewhere['game_type_id'] = $params['game_type']; + } + + if(isset($params['settlement_type'])){ + $companyid = $this->returnSettlementTypeCompanyid($params['settlement_type']); + if(empty($companyid)){ + $where['_string'] = "m.company_id = -1"; + }else{ + if($params['settlement_type'] != -1){ + $where['_string'] = "m.company_id in ({$companyid})"; + }else{ + $where['_string'] = "m.company_id NOT IN ({$companyid})"; + } + } + } + + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + $time_start = strtotime($_REQUEST['time_start']); + $time_end = strtotime($_REQUEST['time_end'])+ 86399; + $where["_string"] = "(begin_time BETWEEN {$time_start} AND {$time_end}) OR (end_time BETWEEN {$time_start} AND {$time_end})"; + } elseif (isset($_REQUEST['time_start'])) { + $time_start = strtotime($_REQUEST['time_start']); + $where["_string"] = "end_time >= {$time_start} OR end_time = 0"; + } elseif (isset($_REQUEST['time_end'])) { + $time_end = strtotime($_REQUEST['time_end'])+ 86399; + $where["_string"] = "begin_time <= {$time_end}"; + } $gameres = M("game","tab_")->field("tab_game.relation_game_id,tab_game.relation_game_name,IF(tab_game.original_package_name='','未配置',tab_game.original_package_name) original_package_name,tab_game_type.type_name game_type_name")->where($gamewhere)->join("tab_game_type on tab_game.game_type_id = tab_game_type.id")->group("tab_game.relation_game_id")->select(false); $dbres = M("company_game_ratio","tab_") ->alias('m') - ->field("m.*,g.*,p.company_name,p.company_belong,IFNULL(r.settlement_type,0) settlement_type") - ->join("left JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id") - ->join("left JOIN tab_promote_company p ON m.company_id = p.id") - ->join("left JOIN tab_company_relation r ON (r.first_company_type =2 AND r.first_company_id = m.company_id) OR (r.second_company_type =2 AND r.second_company_id = m.company_id)") - ->where($where); + ->field("m.*,g.*,p.company_name,p.company_belong,IFNULL(r.settlement_type,-1) settlement_type") + ->join("JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id") + ->join("JOIN tab_promote_company p ON ( m.company_id = p.id".$pwhere.")") + ->join("left JOIN tab_company_relation r ON (r.first_company_type =2 AND r.first_company_id = m.company_id) OR (r.second_company_type =2 AND r.second_company_id = m.company_id)"); if(isset($params['export'])){ - $dbres = $dbres->select(); + $dbres = $dbres->where($where)->select(); }else{ - $dbres = $dbres->page($page, $row)->select(); + $dbres = $dbres->where($where)->page($page, $row)->select(); } foreach($dbres as $k=>&$v){ $v['begin_time'] = date("Y-m-d",$v['begin_time']); @@ -66,11 +105,9 @@ class CompanyGameRatioController extends AdminController } else { $symbol = "
"; } - if($v['settlement_type'] == 0){ - $v['settlement_type'] = '--'; - }else{ - $v['settlement_type'] = $v['settlement_type']== 1 ? "周结" : '月结'; - } + + $v['settlement_type'] = $this->SettlementType[$v['settlement_type']]; + //新 $thisTurnoverRatios = $v['turnover_ratio'] ? json_decode($v['turnover_ratio'], true) : []; $thisRatioDtl = "默认:{$v['ratio']}%"; @@ -101,7 +138,10 @@ class CompanyGameRatioController extends AdminController )); } - $count = M("company_game_ratio","tab_")->alias('m')->field("count(id) count")->where($where)->find()['count']; + $count = M("company_game_ratio","tab_")->alias('m')->field("count(m.id) count") + ->join("JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id") + ->join("JOIN tab_promote_company p ON ( m.company_id = p.id".$pwhere.")") + ->where($where)->find()['count']; $this->assign('data', $dbres); $page = set_pagination($count, $row); if($page) { @@ -110,6 +150,7 @@ class CompanyGameRatioController extends AdminController $this->assign("companyList",D("PromoteCompany")->getList()); $this->assign("gameList",D("Game")->getRelationGameLits()); + $this->assign("SettlementType",$this->SettlementType); $this->display(); } @@ -129,20 +170,56 @@ class CompanyGameRatioController extends AdminController $gamewhere['relation_game_id'] = $params['relation_game_id']; $where['m.relation_game_id'] = $params['relation_game_id']; } + if(isset($params['status'])){ + $where['m.status'] = $params['status']; + } + + $pwhere = false; + if(isset($params['company_belong'])){ + $pwhere = " and p.company_belong = {$params['company_belong']}"; + } + if(isset($params['company_id'])){ $where['m.company_id'] = $params['company_id']; } - if(isset($params['status'])){ - $where['m.status'] = $params['status']; + + if(isset($params['game_type'])){ + $gamewhere['game_type_id'] = $params['game_type']; + } + + if(isset($params['settlement_type'])){ + $companyid = $this->returnSettlementTypeCompanyid($params['settlement_type']); + if(empty($companyid)){ + $where['_string'] = "m.company_id = -1"; + }else{ + if($params['settlement_type'] != -1){ + $where['_string'] = "m.company_id in ({$companyid})"; + }else{ + $where['_string'] = "m.company_id NOT IN ({$companyid})"; + } + } + } + + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + $time_start = strtotime($_REQUEST['time_start']); + $time_end = strtotime($_REQUEST['time_end'])+ 86399; + $where["_string"] = "(begin_time BETWEEN {$time_start} AND {$time_end}) OR (end_time BETWEEN {$time_start} AND {$time_end})"; + } elseif (isset($_REQUEST['time_start'])) { + $time_start = strtotime($_REQUEST['time_start']); + $where["_string"] = "end_time >= {$time_start} OR end_time = 0"; + } elseif (isset($_REQUEST['time_end'])) { + $time_end = strtotime($_REQUEST['time_end'])+ 86399; + $where["_string"] = "begin_time <= {$time_end}"; } + //TODO:未计算公司类型 - $this->checkListOrCountAuthRestMap($where); + // $this->checkListOrCountAuthRestMap($where); $gameres = M("game","tab_")->field("tab_game.relation_game_id,tab_game.relation_game_name,IF(tab_game.original_package_name='','未配置',tab_game.original_package_name) original_package_name,tab_game_type.type_name game_type_name")->where($gamewhere)->join("tab_game_type on tab_game.game_type_id = tab_game_type.id")->group("tab_game.relation_game_id")->select(false); $dbres = M("company_game_ratio_log","tab_") ->alias('m') ->field("m.*,g.*,p.company_name,p.company_belong,IFNULL(r.settlement_type,0) settlement_type") - ->join("left JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id") - ->join("left JOIN tab_promote_company p ON m.company_id = p.id") + ->join("JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id") + ->join("JOIN tab_promote_company p ON ( m.company_id = p.id".$pwhere.")") ->join("left JOIN tab_company_relation r ON (r.first_company_type =2 AND r.first_company_id = m.company_id) OR (r.second_company_type =2 AND r.second_company_id = m.company_id)") ->where($where) ->order("FIELD(m.status,0,1,-1,-2,2),id desc"); @@ -152,11 +229,7 @@ class CompanyGameRatioController extends AdminController $dbres = $dbres->page($page, $row)->select(); } foreach($dbres as $k=>&$v){ - if($v['settlement_type'] == 0){ - $v['settlement_type'] = '--'; - }else{ - $v['settlement_type'] = $v['settlement_type']== 1 ? "周结" : '月结'; - } + $v['settlement_type'] = $this->SettlementType[$v['settlement_type']]; $v['begin_time'] = date("Y-m-d",$v['begin_time']); $v['end_time'] = $v['end_time'] ? date('Y-m-d', $v['end_time']) : '永久'; @@ -239,7 +312,10 @@ class CompanyGameRatioController extends AdminController )); } - $count = M("company_game_ratio_log","tab_")->alias('m')->field("count(id) count")->where($where)->find()['count']; + $count =M("company_game_ratio_log","tab_")->alias('m')->field("count(m.id) count") + ->join("JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id") + ->join("JOIN tab_promote_company p ON ( m.company_id = p.id".$pwhere.")") + ->where($where)->find()['count']; $this->assign('data', $dbres); $page = set_pagination($count, $row); if($page) { @@ -251,6 +327,7 @@ class CompanyGameRatioController extends AdminController $this->assign("companyList",D("PromoteCompany")->getList()); $this->assign("gameList",D("Game")->getRelationGameLits()); + $this->assign("SettlementType",$this->SettlementType); $this->display(); } @@ -646,6 +723,31 @@ class CompanyGameRatioController extends AdminController $data =json_encode(['msg'=>$data,"code"=>4000],JSON_UNESCAPED_UNICODE); exit($data); } + protected function returnSettlementTypeCompanyid($st) + { + if($st != -1){ + $setwhere = [ + "settlement_type"=>$st, + "_string"=>"first_company_type=2 OR second_company_type=2" + ]; + }else{ + $setwhere = [ + "_string"=>"first_company_type=2 OR second_company_type=2" + ]; + } + $scompany_id = M("company_relation","tab_")->field("first_company_type,second_company_type,first_company_id,second_company_id")->where($setwhere)->select(); + $company_id = []; + foreach($scompany_id as $k=>$v){ + if($v['first_company_type'] == 0){ + $company_id[] = $v['second_company_id']; + }else{ + $company_id[] = $v['first_company_id']; + } + } + unset($scompany_id); + $company_id = implode(",",$company_id); + return $company_id; + } } \ No newline at end of file diff --git a/Application/Admin/Controller/CompanyRelationController.class.php b/Application/Admin/Controller/CompanyRelationController.class.php index 81c3a25ee..ea53aec9e 100644 --- a/Application/Admin/Controller/CompanyRelationController.class.php +++ b/Application/Admin/Controller/CompanyRelationController.class.php @@ -72,7 +72,7 @@ class CompanyRelationController extends AdminController $where['is_payment'] = $params['is_payment']; } - $this->checkListOrCountAuthRestMap($where);//导出权限 + // $this->checkListOrCountAuthRestMap($where);//导出权限 $dbres = $this->DBModel->where($where)->order("id desc");; if(isset($params['export'])){ $dbres = $dbres->select(); @@ -153,7 +153,7 @@ class CompanyRelationController extends AdminController if(isset($params['status'])){ $where['status'] = $params['status']; } - $this->checkListOrCountAuthRestMap($where);//导出权限 + // $this->checkListOrCountAuthRestMap($where);//导出权限 $dbres = $this->DBlogModel->where($where)->order("FIELD(status,0,1,-1,-2,2),id desc");; if(isset($params['export'])){ $dbres = $dbres->select(); diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 84062767f..d52539bf1 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -727,7 +727,7 @@ class CompanyStatementController extends ThinkController $upwhere = "(first_company_type = 1 AND first_company_id NOT IN ({$up_company_id}) ) OR ( second_company_type = 1 AND second_company_id NOT IN ({$up_company_id}) )"; } $uprelation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($upwhere)->select(); - + foreach($uprelation as $k=>$v){ if($v['first_company_type'] == 0){ $senddata["up_company_id"][] = $v['second_company_id']; @@ -741,7 +741,7 @@ class CompanyStatementController extends ThinkController $downwhere = "1=1"; }else{ $dowm_company_id =implode(",",$dowm_company_id); - $downwhere = "(first_company_type = 1 AND first_company_id NOT IN ({$dowm_company_id}) ) OR ( second_company_type = 1 AND second_company_id NOT IN ({$dowm_company_id}) )"; + $downwhere = "(first_company_type = 2 AND first_company_id NOT IN ({$dowm_company_id}) ) OR ( second_company_type = 2 AND second_company_id NOT IN ({$dowm_company_id}) )"; } $downrelation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($downwhere)->select(); diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 6c520083e..ef187639e 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -9,6 +9,11 @@ use Think\Controller; */ class CompanyStatementSetController extends Controller { public $cpapihost; + public $TYPE=[ + "0"=>"周结", + "1"=>"月结", + "2"=>"补点" + ]; public $token = "LYHTQDJS"; public function _initialize(){ @@ -71,7 +76,7 @@ class CompanyStatementSetController extends Controller { echo "∟----推广公司周结统计ok".PHP_EOL; $this->promoteUserPool(0,$stime); - echo "∟----推广个人月结&补点统计ok".PHP_EOL; + echo "∟----推广个人周结ok".PHP_EOL; } if($d == 1){ echo $nowdate.":".PHP_EOL; @@ -86,7 +91,7 @@ class CompanyStatementSetController extends Controller { echo "∟----推广公司月结&补点统计ok".PHP_EOL; $this->promoteUserPool(1,$stime); - $this->promoteUserPool(2,$stime); + // $this->promoteUserPool(2,$stime); echo "∟----推广个人月结&补点统计ok".PHP_EOL; } }else{ @@ -665,10 +670,54 @@ class CompanyStatementSetController extends Controller { $pcList[$k]['list'] = $v; } } + public function promoteUserPool($type,$stime,$recount = false){ + $t = $this->setBeginAndEndTime($type,$stime); + $begintime = $t[0]; + $endtime = $t[1]; + + $basedata = [ + "pay_amount"=>0, + "statement_money"=>0, + "lack_statement_money"=>0, + "withdraw_type"=>$type, + "platform_amount"=>0, + "create_lack_ids"=>[], + "del_lack_ids"=>[], + "statement_begin_time"=>$begintime, + "statement_end_time"=>$endtime, + "fine"=>0, + "reward"=>0, + "verify_status"=>0, + "company_type"=>2, + "verify_log"=>json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]), + "op_time"=>time() + ]; + $users = $user = $basedata; + $users['is_payment'] = 1; + $users['statement_num'] = "PL_".date('Ymd').date('His').sp_random_num(3); + + $user['is_payment'] = 2; + $user['statement_num'] = "PL_".date('Ymd').date('His').sp_random_num(3); + + + + if($type == 0){//周结 + $this->doPromoteUserPool($user,$users,$type,$stime,$recount); + }else{ + $users['withdraw_type'] = 1; + $user['withdraw_type'] = 1; + //月结&补点 + $this->doPromoteUserPool($user,$users,1,$stime,$recount); + $this->doPromoteUserPool($user,$users,2,$stime,$recount); + } + $this->savePromotateUserPool($users); + $this->savePromotateUserPool($user); + } + /** * 下游个人汇总单 */ - public function promoteUserPool($type,$stime,$recount = false) + public function doPromoteUserPool(&$user,&$users,$type,$stime,$recount = false) { $t = $this->setBeginAndEndTime($type,$stime); $begintime = $t[0]; @@ -718,33 +767,7 @@ class CompanyStatementSetController extends Controller { $RewardRecord = M("RewardRecord","tab_"); $LackStatement = M("company_lack_statement_info","tab_"); $StatementInfo = M("company_statement_info","tab_"); - $basedata = [ - "pay_amount"=>0, - "statement_money"=>0, - "lack_statement_money"=>0, - "withdraw_type"=>$type, - "platform_amount"=>0, - "create_lack_ids"=>[], - "del_lack_ids"=>[], - "statement_begin_time"=>$begintime, - "statement_end_time"=>$endtime, - "fine"=>0, - "reward"=>0, - "verify_status"=>0, - "company_type"=>2, - "verify_log"=>json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]), - "op_time"=>time() - ]; - $users = $user = $basedata; - $users['is_payment'] = 1; - $users['statement_num'] = "PL_".date('Ymd').date('His').sp_random_num(3); - - $user['is_payment'] = 2; - $user['statement_num'] = "PL_".date('Ymd').date('His').sp_random_num(3); - - // - foreach($pc as $k=>&$v){ //获取其他信息 $v = $this->getCompanyOtherInfo($v,$k); @@ -916,15 +939,12 @@ class CompanyStatementSetController extends Controller { } } } - $this->savePromotateUserPool($users,$type); - $this->savePromotateUserPool($user,$type); } /** * 保存信息汇总信息 */ public function savePromotateUserPool($data){ if(empty($data['create_lack_ids']) && empty($data['del_lack_ids']) && empty($data['info_ids'])){ return;} - if($data['statement_money'] == 0 && $type ==2){ return;} if($data['statement_money'] == 0){ $data['verify_status'] = 5; $data['verify_log'] = json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s"),"verify_user"=>"system","verify_time"=>date("Y-m-d H:i:s"),"payment_user"=>"system","payment_time"=>date("Y-m-d H:i:s")]); diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 7fd9fc095..fc7bef092 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -434,7 +434,6 @@ class ConsoleController extends Think { $start = I('start', date('Y-m-d')); $end = I('end', date('Y-m-d')); $gameIds = I('game_ids', ''); - $startTime = strtotime($start . ' 00:00:00'); $endTime = strtotime($end . ' 23:59:59'); $gameIdRows = explode(',', $gameIds); diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 7c61f0e95..fafccd128 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -1069,7 +1069,6 @@ class ExportController extends Controller ); break; case 7: - $startDate = empty($_REQUEST['timestart']) ? date('Y-m-d', strtotime('-6 day', time())) : $_REQUEST['timestart']; $endDate = empty($_REQUEST['timeend']) ? date('Y-m-d') : $_REQUEST['timeend']; @@ -1175,7 +1174,7 @@ class ExportController extends Controller $xlsCell = array( - "支付订单号","CP订单号", "充值时间","支付时间", "玩家账号", "游戏名称", L('Subordinate_channel'), "充值ip","区服ID", "游戏区服", + "支付订单号","CP订单号", "充值时间","支付时间", "玩家账号", "游戏名称", L('Subordinate_channel'), '所属推广公司', "充值ip","区服ID", "游戏区服", "角色ID","角色名称", "订单金额", "实付金额", "充值方式", L('Order_status'), "游戏通知状态", "消费"."{$total}" ); @@ -1207,13 +1206,21 @@ class ExportController extends Controller // ->join($tab_promote_join) // ->order('pay_time DESC') // ->select(); - ->field('pay_order_number,extend,pay_time,payed_time,user_account,game_name,promote_account,spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status') + ->field('pay_order_number,extend,pay_time,payed_time,user_account,game_name,promote_account, 0 as company_name, spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status, promote_id') + // ->join('tab_promote on tab_promote.id = tab_spend.promote_id', 'left') + // ->join('tab_promote_company on tab_promote_company.id and tab_promote.company_id', 'left') ->where($map) ->limit(($i-1)*$perSize ,$perSize) ->order($order ? $order : 'pay_time desc') ->select(); + $promoters = D('Promote')->where(['id'=>['in', array_unique(array_column($xlsData, 'promote_id'))]])->field('id, company_id')->select(); + $promoters = $promoters ? array_column($promoters, 'company_id', 'id') : []; + $companys = $promoters ? M('promote_company', 'tab_')->where(['id'=>['in', array_unique(array_values($promoters))]])->field('id, company_name')->select() : []; + $companys = $companys ? array_column($companys, 'company_name', 'id') : []; foreach($xlsData as $value) { + $value['company_name'] = $promoters[$value['promote_id']] == 0 ? '官方渠道' : ($companys[$promoters[$value['promote_id']]] ?? ''); + unset($value['promote_id']); $value['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']); if($value['pay_status'] == 1) { $value['payed_time'] = date('Y-m-d H:i:s',$value['payed_time']); diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 8d3b724cb..86b1c3d24 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -718,7 +718,7 @@ class FinanceController extends ThinkController if (!empty(I('timestart'))) { $timestart = strtotime(I('timestart')); - $map['_string'] = "s.pay_time >= {$timestart}"; + $map['_string'] = "s.payed_time >= {$timestart}"; } if (!empty(I('timeend'))) { @@ -726,7 +726,7 @@ class FinanceController extends ThinkController if (!empty($map['_string'])) { $map['_string'] .= " and "; } - $map['_string'] .= " s.pay_time < {$timeend}"; + $map['_string'] .= " s.payed_time < {$timeend}"; } if (!empty(I('game_type_id'))) { @@ -736,7 +736,6 @@ class FinanceController extends ThinkController //游戏统计列表 $data = D("spend")->gameStatistics($map, $row, $p); $endTime = time(); - foreach ($data as $key => $value) { $data[$key]['all_cash_count'] = number_format($value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count'],2,'.',''); } @@ -1221,6 +1220,7 @@ class FinanceController extends ThinkController } foreach ($cashStatistics as $key => $value) { + $cashStatistics[$key]['pay_rate'] = ''; $cashStatistics[$key]['total'] = $value['pay_amount'] + $value['balance'];//添加列表合计 } @@ -1237,11 +1237,12 @@ class FinanceController extends ThinkController foreach($cashStatistics as $key =>$value) { unset($cashStatistics[$key]['pay_way']); + $cashStatistics[$key]['pay_rate'] = strval(round($value['total']/$all_total, 4)*100) . "%"; } db2csv(array_merge($cashStatistics, - [0=>['pay_type'=>'总计','pay_amount'=>$all_pay_amount,'balance'=>$all_balance,'total'=>$all_total]]),'平台统计' - ,['支付方式','现金充值','平台币充值','合计']); + [0=>['pay_type'=>'总计','pay_amount'=>$all_pay_amount,'balance'=>$all_balance, 'pay_rate'=>'', 'total'=>$all_total]]),'平台统计' + ,['支付方式','现金充值','平台币充值', '支付方式占比', '合计']); } $this->checkListOrCountAuthRestMap($map,[]); diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 4e3f83117..081905879 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -216,7 +216,7 @@ class FinancePromoteController extends AdminController $map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) ); } if($istimeselect){ - $map['s.pay_time']=$istimeselect; + $map['s.payed_time']=$istimeselect; } $map['s.pay_status']=1; $field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 5602108ec..52e7500f8 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -9,6 +9,39 @@ namespace Admin\Controller; */ class OldCountController extends \Think\Controller { + /** + * 新的游戏比例后的数据迁移 + * 重复执行将会叠加数据,请勿重复执行 + */ + public function PromoteToCompanyRatioInit() + { + //获取旧数据 + $oldres = M("promote_game_ratio","tab_")->field("promote_id,relation_game_id,ratio,turnover_ratio,begin_time,end_time")->group("promote_id,relation_game_id")->select(); + $adddata = []; + $CompanyGameRatio = M("company_game_ratio","tab_"); + foreach ($oldres as $k => &$v) { + $comoany_id = $this->promoteIdToCompanyId($v['promote_id']); + unset($v['promote_id']); + $v['company_id'] = $comoany_id ; + $adddata[$comoany_id] = $v; + } + foreach($adddata as $k => &$v){ + $map = [ + "company_id"=>$v['company_id'], + "relation_game_id"=>$v['relation_game_id'] + ]; + $cres = $CompanyGameRatio->where($map)->find(); + if(empty($cres)){ + $CompanyGameRatio->add($v); + } + } + echo "PromoteToCompanyRatioInit success"; + } + protected function promoteIdToCompanyId($promote_id) + { + return M("promote","tab_")->field("company_id")->where("id='{$promote_id}'")->find()['company_id']; + } + /** * 财务分类汇总统计旧数据聚合 */ diff --git a/Application/Admin/Controller/PayChannelController.class.php b/Application/Admin/Controller/PayChannelController.class.php index 8a3f5a3e2..1e7f88a79 100644 --- a/Application/Admin/Controller/PayChannelController.class.php +++ b/Application/Admin/Controller/PayChannelController.class.php @@ -25,23 +25,23 @@ class PayChannelController extends ThinkController $map = []; if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['pay_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); - $coinMap['tab_deposit.create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); - $bindMap['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); + $map['payed_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); + $coinMap['tab_deposit.payed_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); + $bindMap['payed_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); $offcialmap['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); $spreadMap['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); $maptestorder['pay_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { - $map['pay_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); - $coinMap['tab_deposit.create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); - $bindMap['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); + $map['payed_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); + $coinMap['tab_deposit.payed_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); + $bindMap['payed_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); $offcialmap['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); $spreadMap['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); $maptestorder['pay_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['pay_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); - $coinMap['tab_deposit.create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); - $bindMap['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); + $map['payed_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); + $coinMap['tab_deposit.payed_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); + $bindMap['payed_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); $offcialmap['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); $spreadMap['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); $maptestorder['pay_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); @@ -131,6 +131,8 @@ class PayChannelController extends ThinkController $data[$key]['sdk_version'] =getGameTypeName($data[$key]['sdk_version']); } $superMap = $map; + unset($superMap['payed_time']); + $superMap['pay_time'] = $map['payed_time']; // unset($superMap['promote_id']); //超级签数据 $superSignData = M('game_supersign','tab_') @@ -193,12 +195,12 @@ class PayChannelController extends ThinkController $this->assign('spreadData',$spreadData); $channelData = $this->getPayChannel($map); - $testOrderChannelDatas = $this->getTestOrderPayChannel($maptestorder); $payTypeData['支付宝支付金额'] = 0; $payTypeData['微信支付金额'] = 0; $payTypeData['快捷支付金额'] = 0; $payTypeData['苹果支付金额'] = 0; + $payTypeData['汇付宝支付金额'] = 0; $payTypeData['易宝支付金额'] = 0; $payTypeData['其他支付金额'] = 0; @@ -206,6 +208,8 @@ class PayChannelController extends ThinkController if ($value['pay_way']==1 || $value['pay_way']==9 ) { $payTypeData['支付宝支付金额'] += number_format($value['pay_amount'],2,'.',''); + } else if ($value['pay_way']==4 ) { + $payTypeData['汇付宝支付金额'] += number_format($value['pay_amount'],2,'.',''); } else if ($value['pay_way']==2 || $value['pay_way']==3 ) { $payTypeData['微信支付金额'] += number_format($value['pay_amount'],2,'.',''); } else if ($value['pay_way']==15) { diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index f80948b8e..9f1f3eb48 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -575,6 +575,11 @@ class PlatformController extends ThinkController $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 $arraypage = $page; + + if(!array_key_exists("timestart",$_REQUEST)){ + $this->redirect(ACTION_NAME, array('timestart' => date('Y-m-d',strtotime('-7 day')),"timeend"=>date('Y-m-d'))); + } + if (isset($_REQUEST['row'])) { $row = $_REQUEST['row']; } else { diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 55d42c7e2..c25fec532 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -273,6 +273,7 @@ class PromoteCompanyController extends ThinkController )); } } else { + $this->assign('serviceAgreements', M('service_agreement', 'tab_')->select()); $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'PromoteCompany/add'])->find()); $this->meta_title = '新增推广公司'; $this->display(); @@ -304,6 +305,12 @@ class PromoteCompanyController extends ThinkController $this->assign('data', $data); $this->display(); } + + public function marketingDirectorShow($ids=[], $isShow=0) + { + $upt = M('promote_company','tab_')->where(['id'=>['in', $ids]])->save(['marketing_director_show'=>$isShow]); + return $upt ? $this->success('更新成功'): $this->error('更新失败'); + } //编辑 @@ -378,7 +385,7 @@ class PromoteCompanyController extends ThinkController if($data['resources'] == ''){ $data['resources'] ="[]"; } - + $this->assign('serviceAgreements', M('service_agreement', 'tab_')->select()); $this->assign('data', $data); $this->display(); } @@ -558,4 +565,91 @@ WHERE old_change_promote_id in ({$promoteData})"; } + public function serviceAgreementList($row = 10, $p = 1) + { + $map = []; + $map['_string'] = " 1=1 "; + if (isset($_GET['time-start'])) { + $map['_string'] .= " and created_time >= " . strtotime($_GET['time-start']); + } + if (isset($_GET['time-end'])) { + $map['_string'] .= " and created_time < " . (strtotime($_GET['time-end']) + 86400); + } + if (isset($_GET['type'])) { + $map['type'] = $_GET['type']; + } + if (!empty($_GET['title'])) { + $map['title'] = ['like', "%{$_GET['title']}%"]; + } + $list = M('service_agreement', 'tab_') + ->field("tab_service_agreement.*, group_concat(distinct(tab_promote_company.company_name)) as company_name") + ->join('tab_promote_company on tab_promote_company.service_agreement_show = tab_service_agreement.id', 'LEFT')->where($map)->group('tab_service_agreement.id asc')->page($p, $row)->order("status desc")->select(); + $count = M('service_agreement', 'tab_')->where($map)->count(); + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->assign('list_data', $list); + $this->display('service_agreement_list'); + } + + public function serviceAgreementSave($id=0, $delete=0) + { + if (IS_POST) { + if (!empty(I('ids'))) { + $ids = is_array(I('ids')) ? I('ids') : [I('ids')]; + if ($delete) { + // 获取默认合同id + $defaultService = M('service_agreement', 'tab_')->where(['status'=>2])->find(); + if(in_array($defaultService['id'], $ids)) { + return $this->error('无法删除默认模板'); + } + $usingService = M('promote_company', 'tab_')->where(['service_agreement_show'=>['in', $ids]])->find(); + if (!empty($usingService)) return $this->error('有正在使用该服务合同的公司,无法删除'); + $result = M('service_agreement', 'tab_')->where(['id'=>['in', $ids]])->delete(); + return $result ? $this->success('删除完成') : $this->error('删除失败'); + } + } + if (empty($_POST['name']) || empty($_POST['content'])) { + return $this->error('请填写完整内容'); + } + if ($id) { + $result = M('service_agreement', 'tab_')->where(['id'=>$id])->save($_POST); + return $result ? $this->success('更新完成') : $this->error('更新失败'); + } else { + $data = $_POST; + $data['creator'] = is_login(); + $data['created_time'] = time(); + $result = M('service_agreement', 'tab_')->add($data); + return $result ? $this->success('生成协议完成') : $this->error('生成协议失败'); + } + } else { + if (!empty($id)) { + if ($delete) { + $ids = [$id]; + // 获取默认合同id + $defaultService = M('service_agreement', 'tab_')->where(['status'=>2])->find(); + if(in_array($defaultService['id'], $ids)) { + return $this->error('无法删除默认模板'); + } + $usingService = M('promote_company', 'tab_')->where(['service_agreement_show'=>['in', $ids]])->find(); + if (!empty($usingService)) return $this->error('有正在使用该服务合同的公司,无法删除'); + $result = M('service_agreement', 'tab_')->where(['id'=>['in', $ids]])->delete(); + return $result ? $this->success('删除完成') : $this->error('删除失败'); + } + $info = M('service_agreement', 'tab_')->where(['id'=>$id])->find(); + if (empty($info)) return $this->error('未找到协议'); + $this->assign('info', $info); + } + $this->display('service_agreement_save'); + } + } + + public function serviceAgreementSetDefault($id) + { + M('service_agreement', 'tab_')->where('id > 0')->save(['status'=>1]); + M('service_agreement', 'tab_')->where(['id'=>$id])->save(['status'=>2]); + return $this->success('设置完成'); + } + } diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index 7b3ecd2b8..0d78d3e5c 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -1224,6 +1224,10 @@ class PromoteController extends ThinkController if (empty($id)) { $this->ajaxReturn(['code'=>0,'msg'=>'请选择推广员']); } + $promoter = M('promote', 'tab_')->where(['id'=>$id])->find(); + if (empty($promoter)) { + $this->ajaxReturn(['code'=>0,'msg'=>'未找到推广员']); + } $game_ids = I('game_ids', ''); if (!empty($game_ids)) { $game_ids = implode(',', $game_ids); @@ -1231,7 +1235,9 @@ class PromoteController extends ThinkController } else { $game_ids = 0; } - $res = M('promote', 'tab_')->where(['id'=>$id])->save(['game_ids'=>$game_ids]); + // 获取下级id + $childrens = M('promote', 'tab_')->where("chain like '{$promoter['chain']}{$promoter['id']}/%'")->select(); + $res = M('promote', 'tab_')->where(['id'=>['in', $childrens? array_merge([$id], array_column($childrens, 'id')) : [$id] ]])->save(['game_ids'=>$game_ids]); if ($res) { $this->ajaxReturn(['code'=>1,'msg'=>'更新成功']); } else { diff --git a/Application/Admin/Controller/PromoteLimitRuleController.class.php b/Application/Admin/Controller/PromoteLimitRuleController.class.php new file mode 100644 index 000000000..839704544 --- /dev/null +++ b/Application/Admin/Controller/PromoteLimitRuleController.class.php @@ -0,0 +1,233 @@ +field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true); + if (count($companyPromoteIds) > 0) { + $promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds; + $promoteIds[] = 0; + } else { + $promoteIds = [0]; + } + } + if (count($promoteIds)) { + $conditions['promote_id'] = ['in', $promoteIds]; + } + $query = M('promote_limit_rules', 'tab_')->where($conditions); + + $countQuery = clone $query; + $rules = $query->page($page, $row)->select(); + $count = $countQuery->count(); + + $recordPromotes = []; + $recordCompanys = []; + if (count($rules) > 0) { + $recordPromotes = M('promote', 'tab_')->field(['id', 'account', 'company_id'])->where(['id' => ['in', array_column($rules, 'promote_id')]])->select(); + $recordCompanyIds = array_column($recordPromotes, 'company_id'); + if (count($recordCompanyIds) > 0) { + $recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select(); + } + $recordPromotes = index_by_column('id', $recordPromotes); + $recordCompanys = index_by_column('id', $recordCompanys); + } + + $companyTypes = [ + 0 => '内团', + 1 => '外团', + 2 => '外团-分发联盟', + 3 => '无' + ]; + + $records = []; + foreach ($rules as $rule) { + $records[] = [ + 'id' => $rule['id'], + 'promote_account' => $recordPromotes[$rule['promote_id']]['account'], + 'company_name' => $recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_name'], + 'company_belong' => $companyTypes[$recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_belong']], + 'limit_rule' => $this->getDisplayRule($rule), + ]; + } + $companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select(); + + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } + $this->assign('records', $records); + $this->assign('companys', $companys); + $this->display(); + } + + private function getDisplayRule($rule) + { + if ($rule['started_at'] === null && $rule['ended_at'] === null) { + return '永久'; + } elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) { + return '从前 至 '.$rule['ended_at']; + } elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) { + return $rule['started_at'] . ' 至 永久'; + } else { + return $rule['started_at'] . ' ~ ' . $rule['ended_at']; + } + } + + public function edit() + { + $this->meta_title = '编辑推广限制'; + $id = I('id', 0); + $companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select(); + $record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find(); + $promote = null; + $company = null; + if ($record) { + $promote = M('promote', 'tab_')->where(['id' => $record['promote_id']])->field(['id', 'company_id', 'account'])->find(); + $company = M('promote_company', 'tab_')->where(['id' => $promote['company_id']])->field(['id', 'company_name'])->find(); + } + $this->assign('promote', $promote); + $this->assign('company', $company); + $this->assign('companys', $companys); + $this->assign('record', $record); + $this->display('form'); + } + + public function save() + { + $id = I('id', 0); + $promoteId = I('promote_id', 0); + $startedAt = I('started_at', ''); + $endedAt = I('ended_at', ''); + + $startedAt = $startedAt === '' ? null : $startedAt; + $endedAt = $endedAt === '' ? null : $endedAt; + + if ($startedAt && $endedAt && strtotime($startedAt) > strtotime($endedAt)) { + return $this->error('开始时间不能大于结束时间'); + } + + $record = null; + if ($id > 0) { + $record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find(); + if (!$record) { + return $this->error('修改记录不存在'); + } + } else { + if (empty($promoteId)) { + return $this->error('请选择会长'); + } + $promoteRecord = M('promote_limit_rules', 'tab_')->where(['promote_id' => $promoteId])->find(); + if ($promoteRecord) { + return $this->error('该会长已经设定限制规则,请前往更新'); + } + } + + if ($record) { + $data = []; + $data['started_at'] = $startedAt; + $data['ended_at'] = $endedAt; + $data['update_time'] = time(); + M('promote_limit_rules', 'tab_')->where(['id' => $id])->save($data); + addOperationLog([ + 'op_type' => 1, + 'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt, + 'op_name' => '修改推广限制', + 'url' => U('PresidentDeposit/edit', ['id'=>$id]), 'menu'=>'推广员-推广员管理-推广限制-修改推广限制' + ]); + } else { + $data = []; + $data['promote_id'] = $promoteId; + $data['started_at'] = $startedAt; + $data['ended_at'] = $endedAt; + $data['create_time'] = time(); + $data['update_time'] = time(); + M('promote_limit_rules', 'tab_')->add($data); + addOperationLog([ + 'op_type' => 0, + 'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt, + 'op_name' => '新增推广限制', + 'url' => U('PresidentDeposit/edit', ['promote_id'=>$promoteId]), 'menu'=>'推广员-推广员管理-推广限制-新增推广限制' + ]); + } + + return $this->success('保存成功', U('records')); + } + + public function delete() + { + $id = I('id', 0); + M('promote_limit_rules', 'tab_')->where(['id' => $id])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => $id, + 'op_name' => '删除会长推广限制', + 'url' => U('PresidentDeposit/delete', ['id' => $id]), + 'menu' => '推广员-推广员管理-推广限制-删除推广限制' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function batchDelete() + { + $ids = I('ids', []); + if (count($ids) == 0) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '无选中项' + ]); + } + M('promote_limit_rules', 'tab_')->where(['id' => ['in', $ids]])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => implode(',', $ids), + 'op_name' => '批量删除会长推广限制', + 'url' => U('PresidentDeposit/batchDelete', ['ids' => implode(',', $ids)]), + 'menu' => '推广员-推广员管理-推广限制-批量删除推广限制' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function getPromotesByCompany() + { + $companyId = I('company_id', 0); + $promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['level' => 1, 'company_id' => $companyId])->select(); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => [ + 'promotes' => $promotes + ] + ]); + } +} diff --git a/Application/Admin/Controller/PublicController.class.php b/Application/Admin/Controller/PublicController.class.php index 5f48fb3e0..1de768647 100644 --- a/Application/Admin/Controller/PublicController.class.php +++ b/Application/Admin/Controller/PublicController.class.php @@ -77,11 +77,8 @@ class PublicController extends \Think\Controller public function cp_login($mobile = null, $verify = null) { if (IS_POST) { - /* 检测验证码 TODO: */ - if($verify !== 'txsb0601'){ - if (!$this->checksafecode($mobile, $verify)) { - $this->error('验证码错误'); - } + if (!$this->checksafecode($mobile, $verify)) { + $this->error('验证码错误'); } $promote = M('promote_company', 'tab_')->where(['contact_phone' => $mobile])->find(); if ($promote) { diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index d11d33087..eb690a23d 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -147,7 +147,8 @@ class StatController extends ThinkController $start = I('start', date('Y-m-d',strtotime('-7 day'))); $end = empty(I('end')) ? time_format(time(),'Y-m-d') : I('end'); $dataOrder = I('data_order', ''); - $gameId = I('game_id', 0); + $baseGameId = I('game_id', 0); + $deviceType = I('device_type', ''); $promoteId = I('promote_id', 0); $orderType = 'asc'; @@ -162,10 +163,14 @@ class StatController extends ThinkController $status = true; $data = false; $error = ''; - if ($gameId == 0) { + if ($baseGameId == 0) { $error = '请选择游戏!'; $status = false; } + if ($deviceType == '') { + $error = '请选择设备类型!'; + $status = false; + } $startTime = strtotime($start . ' 00:00:00'); $endTime = strtotime($end . ' 23:59:59') + 1; if ((($endTime - $startTime)/(24*3600)) > 31) { @@ -173,6 +178,10 @@ class StatController extends ThinkController $status = false; } if ($status) { + + $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find(); + $gameId = $deviceType == 'android' ? $baseGame['android_game_id'] : $baseGame['ios_game_id']; + $client = new Client([ 'base_uri' => C('TASK_URL'), 'timeout' => 10.0, @@ -218,6 +227,9 @@ class StatController extends ThinkController $this->assign('error', $error); } + $baseGames = M('base_game', 'tab_')->select(); + + $this->assign('baseGames', $baseGames); $this->checkListOrCountAuthRestMap($map,[]); $this->assign('data', $data); @@ -676,6 +688,165 @@ AND UNIX_TIMESTAMP( } public function userarpu($p=0) + { + $start = I('start', date('Y-m-d')); + $end = I('end', date('Y-m-d')); + $baseGameIds = I('game_ids', ''); + $promoteId = I('promote_id', 0); + $dataOrder = I('data_order', ''); + $deviceType = I('device_type', ''); + $containBindCoins = I('contain_bind_coins', 0); + + $orderType = ''; + $order = 0; + if ($dataOrder != '') { + $dataOrderRow = explode(',', $dataOrder); + $order = $dataOrderRow[0]; + $orderType = $dataOrderRow[1]; + } + + $promoteIds = []; + if ($promoteId > 0) { + $promote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $promoteId])->find(); + $promoteIds = M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->getField('id', true); + $promoteIds[] = $promote['id']; + } + + $startTime = strtotime($start . ' 00:00:00'); + $endTime = strtotime($end . ' 23:59:59'); + $baseGameIdRows = $baseGameIds ? explode(',', $baseGameIds) : []; + $baseGames = M('base_game', 'tab_')->select(); + + $gameIds = null; + $conditions = []; + if (count($baseGameIdRows)) { + $tmpBaseGames = M('base_game', 'tab_')->where(['id' => ['in', $baseGameIdRows]])->select(); + $gameIds = array_merge(array_column($tmpBaseGames, 'android_game_id'), array_column($tmpBaseGames, 'ios_game_id')); + } + if (count($promoteIds)) { + $conditions['promote_id'] = ['in', $promoteIds]; + } + if ($deviceType != '') { + if ($gameIds) { + $gameIds = ( + $deviceType == 'android' ? + array_intersect($gameIds, array_column($baseGames, 'android_game_id')) : + array_intersect($gameIds, array_column($baseGames, 'ios_game_id')) + ); + } else { + $gameIds = ( + $deviceType == 'android' ? + array_column($baseGames, 'android_game_id') : + array_column($baseGames, 'ios_game_id') + ); + } + } + + if ($gameIds && count($gameIds)) { + if (count($gameIds)) { + $conditions['game_id'] = ['in', $gameIds]; + } else { + $conditions['game_id'] = ['in', 0]; + } + } + + // 新增用户 + + /* M('user', 'tab_') + ->field('count(*) count, FROM_UNIXTIME(register_time, "%Y-%m-%d") date') + ->where([ + 'game_id' => ['in', $gameIdRows], + 'register_time' => ['between', [$startTime, $endTime]] + ]) + ->group('date') + ->select(); */ + + $newUsers = M('user_play', 'tab_') + ->field('count(DISTINCT user_id) count, FROM_UNIXTIME(create_time, "%Y-%m-%d") date') + ->where(array_merge($conditions, ['create_time' => ['between', [$startTime, $endTime]]])) + ->group('date') + ->select(); + $newUsers = index_by_column('date', $newUsers); + + // 活跃用户 + $loginUsers = M('login_daily_record', 'tab_') + ->field('count(DISTINCT user_id) count, FROM_UNIXTIME(create_time, "%Y-%m-%d") date') + ->where(array_merge($conditions, ['create_time' => ['between', [$startTime, $endTime]]])) + ->group('date') + ->select(); + $loginUsers = index_by_column('date', $loginUsers); + + $spendConditions = array_merge($conditions, [ + 'pay_time' => ['between', [$startTime, $endTime]], + 'pay_status' => 1, + ]); + if ($containBindCoins == 0) { + $spendConditions['pay_way'] = ['gt', -1]; + } + + // 付费玩家,付费金额 + $payLogs = M('spend', 'tab_') + ->field('count(DISTINCT user_id) count, sum(pay_amount) amount, FROM_UNIXTIME(pay_time, "%Y-%m-%d") date') + ->where($spendConditions) + ->group('date') + ->select(); + $payLogs = index_by_column('date', $payLogs); + + $rows = []; + for ($time = $startTime; $time < $endTime; $time = $time + 24*3600) { + $date = date('Y-m-d', $time); + $newUser = isset($newUsers[$date]) ? $newUsers[$date]['count'] : 0; + $loginUser = isset($loginUsers[$date]) ? $loginUsers[$date]['count'] : 0; + $payAmount = isset($payLogs[$date]) ? $payLogs[$date]['amount'] : 0; + $payUser = isset($payLogs[$date]) ? $payLogs[$date]['count'] : 0; + $rows[] = [ + 'date' => $date, + 'new_user' => $newUser, + 'login_user' => $loginUser, + 'pay_amount' => $payAmount, + 'pay_user' => $payUser, + 'pay_rate' => $loginUser > 0 ? (round($payUser / $loginUser * 100, 2)) : '0', + 'arpu' => $loginUser > 0 ? (round($payAmount / $loginUser, 2)) : '0.00', + 'arppu' => $payUser > 0 ? (round($payAmount / $payUser, 2)) : '0.00', + ]; + } + + if (I('export', 0) == 1) { + $fields = [ + 'date' => '日期', + 'new_user' => '新增玩家', + 'login_user' => '活跃玩家', + 'pay_account' => '充值金额', + 'pay_user' => '付费玩家', + 'pay_rate' => '付费率', + 'arpu' => 'ARPU', + 'arppu' => 'ARPPU', + ]; + foreach ($rows as &$item) { + $item['pay_rate'] = $item['pay_rate'] . '%'; + } + + addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'ARPU分析','url'=>U('Stat/userarpu'),'menu'=>'统计-数据分析-ARPU分析']); + + data2csv($rows, '数据分析_ARPU分析', $fields); + exit; + } + + if ($dataOrder) { + $sort = $order == 3 ? SORT_DESC : SORT_ASC; + $orderColumn = array_column($rows, $orderType); + array_multisort($orderColumn, $sort, SORT_REGULAR, $rows); + } + + $this->meta_title = 'ARPU统计'; + $this->assign('baseGames', $baseGames); + $this->assign('records', $rows); + $this->assign('order', $order); + $this->assign('orderType', $orderType); + $this->display(); + } + + public function userarpu_old($p=0) { $request=$_REQUEST; $page = intval($p); diff --git a/Application/Admin/Controller/ToolController.class.php b/Application/Admin/Controller/ToolController.class.php index 9f997e287..53f91416e 100644 --- a/Application/Admin/Controller/ToolController.class.php +++ b/Application/Admin/Controller/ToolController.class.php @@ -711,10 +711,9 @@ class ToolController extends ThinkController { $parameter['id'] = $id; } - if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') { - $status = intval($_REQUEST['status']); - $map['tab_company_info.status'] = $status; - $parameter['status'] = $status; + + if (isset($_REQUEST['partner']) && $_REQUEST['partner'] !== '') { + $map['p.partner'] = ["like","%{$_REQUEST['partner']}%"]; } $page = intval(I('get.p', 0)); @@ -733,6 +732,7 @@ class ToolController extends ThinkController { /* 查询记录总数 */ $count = $model + ->alias('p') ->where($map) ->count(); diff --git a/Application/Admin/Model/PromoteModel.class.php b/Application/Admin/Model/PromoteModel.class.php index 180fa3fe8..2b50f2d39 100644 --- a/Application/Admin/Model/PromoteModel.class.php +++ b/Application/Admin/Model/PromoteModel.class.php @@ -80,6 +80,10 @@ class PromoteModel extends Model{ } } + public function login_phone($user) { + $this->autoLogin($user); + } + diff --git a/Application/Admin/View/AuthManager/dataempower.html b/Application/Admin/View/AuthManager/dataempower.html index 18fb9bf20..0635b726a 100644 --- a/Application/Admin/View/AuthManager/dataempower.html +++ b/Application/Admin/View/AuthManager/dataempower.html @@ -149,9 +149,37 @@ value: data2, id: 'key123', onchange: function(data, index){ + dataTransfer = transfer.getData('key123'); //获取右侧数据 - // layer.alert(JSON.stringify(dataTransfer)); - $('#promote_data').val(JSON.stringify(dataTransfer)); + + if (index == 0) { + + for (var i=0;i +
+ +
+ +
+ +
+ +
+ +
+ +
+ +  -  +
+ + +
+
+ + + +
搜索 @@ -157,10 +196,8 @@
- 导出 - {$_page|default=''}
@@ -186,6 +223,7 @@ $(".select_gallery").select2(); + + + + + + + + +
+ + +
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + ID标题是否默认合同应用公司操作人操作时间操作
aOh! 暂时还没有内容!
{$data.id}{$data.name} +
+ {$data.company_name} +
+
{:get_admin_nickname($data['creator'])}{$data.created_time|date='Y-m-d H:i:s',###} + + 设置默认 + + 编辑 + 删除 +
+
+
+
+ {$_page|default=''} +
+ +
+ +
+ + +
+ 已添加添加至常用设置 +
+ + + + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + diff --git a/Application/Admin/View/PromoteCompany/service_agreement_save.html b/Application/Admin/View/PromoteCompany/service_agreement_save.html new file mode 100644 index 000000000..53acb0136 --- /dev/null +++ b/Application/Admin/View/PromoteCompany/service_agreement_save.html @@ -0,0 +1,52 @@ + + + +
+
服务协议新增
+
    + +
  • + + +
  • +
  • + + {sn}:合同编号    {time}:合同开始时间    {endTime}:合同结束时间 +
    +     {account}:签约者账号 +     {email}:签约者邮箱 +     {realname}:签约者姓名 +     {phone}:签约者电话 +     {address}:签约者地址 +
    +
  • +
  • + + + + {:hook('adminArticleEdit', array('name'=>'content','value'=>$info['content']))} + + +
  • +
  • + +
  • +
+
+ + + +
+ + + \ No newline at end of file diff --git a/Application/Admin/View/PromoteLimitRule/form.html b/Application/Admin/View/PromoteLimitRule/form.html new file mode 100644 index 000000000..2912f2344 --- /dev/null +++ b/Application/Admin/View/PromoteLimitRule/form.html @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
*推广公司: + + {$company.company_name} + + + +
*会长: + + {$promote.account} + + + +
开始时间: + +
结束时间: + +
+
+ +
+ + + 返回 + +
+
+
+
+ + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + \ No newline at end of file diff --git a/Application/Admin/View/PromoteLimitRule/records.html b/Application/Admin/View/PromoteLimitRule/records.html new file mode 100644 index 000000000..80a197769 --- /dev/null +++ b/Application/Admin/View/PromoteLimitRule/records.html @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ 搜索 + 添加 + 删除 +
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 推广公司会长账号内外团限制时间操作
aOh! 暂时还没有内容!
+ + {$data.company_name}{$data.promote_account}{$data.company_belong}{$data.limit_rule} +
+ 编辑 + 删除 +
+
+
+
+
+ + + + {$_page|default=''} +
+ + +
+ + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/Stat/userarpu.html b/Application/Admin/View/Stat/userarpu.html index 0a336bf3b..b3404e974 100644 --- a/Application/Admin/View/Stat/userarpu.html +++ b/Application/Admin/View/Stat/userarpu.html @@ -48,18 +48,18 @@ 活跃玩家 当天登录的玩家总数 -
  • +
  • 付费玩家 当天付费的玩家数量
  • -
  • +
  • 付费率 付费玩家/活跃玩家 @@ -83,12 +83,12 @@
    参与统计设置: - +
    @@ -103,11 +103,18 @@
    - - - - + + + + +
    +
    +
    - 导出 + 导出 {$_page|default=''}
    @@ -212,11 +192,12 @@ @@ -251,8 +232,8 @@ $(function(){ if(interval < 0 || start == ''){ layer.msg('请选择搜索时间'); return false; - }else if(interval>90){ - layer.msg('请选择90日内的时间段'); + }else if(interval>31){ + layer.msg('请选择31日内的时间段'); return false; } @@ -285,8 +266,8 @@ $(function(){ $(".paixu").click(function(){ var that=$(this); $data_order=that.attr('data-order'); - $order_type='{$userarpu_order}'; - if($order_type==''||$order_type=='4'){ + $order_type='{$order}'; + if($order_type==0||$order_type=='4'){ $(".sortBy").attr('name','data_order'); val='3,'+$data_order; $(".sortBy").attr('value',val); diff --git a/Application/Admin/View/Stat/userarpu_old.html b/Application/Admin/View/Stat/userarpu_old.html new file mode 100644 index 000000000..de5c56d00 --- /dev/null +++ b/Application/Admin/View/Stat/userarpu_old.html @@ -0,0 +1,407 @@ + + + + + + + + + + + + + +
    +
    +
    + 参与统计设置: + + +
    +
    + +
    +
    + +
    +
    + +  -  + +
    +
    + +
    +
    + +
    + +
    + 搜索 +
    +
    +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    日期▲日期▼日期游戏名称渠道名称新增玩家▲新增玩家▼新增玩家活跃玩家▲活跃玩家▼活跃玩家1日留存▲1日留存▼1日留存充值▲充值▼充值付费玩家▲付费玩家▼付费玩家新付费玩家▲新付费玩家▼新付费玩家付费率▲付费率▼付费率ARPU▲ARPU▼ARPUARPPU▲ARPPU▼ARPPU累计付费玩家▲累计付费玩家▼累计付费玩家详情
    {$vo.time}{$game_name}{$promote_name}{$vo.register_num}{$vo.act_user}{$vo.keep_num}%{$vo.spend}{$vo.spend_people}{$vo.new_pop}{$vo.spend_rate}%{$vo.ARPU}{$vo.ARPPU}{$vo.pop_num}查看
    +
    +
    +
    + 导出 + {$_page|default=''} +
    +
    + + + + +if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Application/Admin/View/Stat/userretention.html b/Application/Admin/View/Stat/userretention.html index aafdbb393..b12f2c343 100644 --- a/Application/Admin/View/Stat/userretention.html +++ b/Application/Admin/View/Stat/userretention.html @@ -47,10 +47,17 @@
    + + + + +
    +
    +
      +
    + +
    + 搜索 +
    + diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index ae47f5b67..d441103df 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -1127,4 +1127,28 @@ class PromoteService { return $selfGameIds; } } + + public function checkPromoteLimitRule($promote) + { + $topPromote = $this->getTopPromote($promote); + $rule = M('promote_limit_rules', 'tab_')->where(['promote_id' => $topPromote['id']])->order('created_at desc')->limit(1)->find(); + if ($rule) { + if ($rule['started_at'] === null && $rule['ended_at'] === null) { + return false; + } elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) { + if (time() < strtotime($rule['ended_at'] . ' 23:59:59')) { + return false; + } + } elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) { + if (time() >= strtotime($rule['started_at'] . ' 00:00:00')) { + return false; + } + } else { + if (time() >= strtotime($rule['started_at'] . ' 00:00:00') && time() < strtotime($rule['ended_at'] . ' 23:59:59')) { + return false; + } + } + } + return true; + } } \ No newline at end of file diff --git a/Application/Home/Controller/BaseController.class.php b/Application/Home/Controller/BaseController.class.php index 70d61410b..d9cec83e2 100644 --- a/Application/Home/Controller/BaseController.class.php +++ b/Application/Home/Controller/BaseController.class.php @@ -46,6 +46,11 @@ class BaseController extends HomeController define('G_SETTLEMENT_GRADE', 'sub_status,third_status'); } + if ($loginer['company_id']) { + $company = M('promote_company', 'tab_')->where(['id'=>$loginer['company_id']])->find(); + $this->assign('company', $company); + } + $this->canViewUserRecharge = $this->promoteCan('view-user-recharge'); $this->checkUrlPermission(); diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index 345c8268a..c1c57599f 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -5,6 +5,7 @@ use Think\Controller; use User\Api\MemberApi; use Base\Facade\Request; use Base\Service\ApplyService; +use Base\Service\PromoteService; use Base\Service\PackageDownloadLogService; use Base\Tool\MobileDetect; @@ -170,6 +171,16 @@ class HomeController extends Controller $promoteId = $data['promote_id']; } + $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); + if (!$promote) { + $this->error('该链接已失效'); + } + + $promoteService = new PromoteService(); + if (!$promoteService->checkPromoteLimitRule($promote)) { + $this->error('链接已失效'); + } + $isWechat = Request::isWechat(); $isIOS = Request::isIOS() || Request::isIPadOS(); $isAndroid = Request::isAndroid(); @@ -208,8 +219,6 @@ class HomeController extends Controller $map = ['id' => intval($gameId)]; $game = M('game', 'tab_')->field($columns)->where($map)->find(); - $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); - if ($game['sdk_version'] == 1 && $isIOS) { $map = []; $map['relation_game_id'] = $game['relation_game_id']; diff --git a/Application/Home/Controller/IndexController.class.php b/Application/Home/Controller/IndexController.class.php index c91fac847..a6a629b73 100644 --- a/Application/Home/Controller/IndexController.class.php +++ b/Application/Home/Controller/IndexController.class.php @@ -14,6 +14,7 @@ use OT\DataDictionary; use User\Api\PromoteApi; use Home\Controller\DownController; +use Base\Tool\TaskClient; /** * 前台首页控制器 @@ -74,6 +75,12 @@ class IndexController extends HomeController $map['account'] = $account; $data['last_login_time'] = time(); M("promote", "tab_")->where($map)->save($data); + $loginrecord['promote_id'] = get_pid(); + $loginrecord['account'] = $_POST['account']; + $loginrecord['client_ip'] = $_SERVER['REMOTE_ADDR']; + $loginrecord['login_type'] = 1; + $loginrecord['create_time'] = time(); + M("promote_login_record", "tab_")->add($loginrecord); $this->ajaxReturn(array("status" => 1, "msg" => "登录成功", 'url' => U('Promote/index'))); } else { $msg = ""; @@ -99,6 +106,34 @@ class IndexController extends HomeController } } + public function doPhoneLogin() { + $mobile = $_POST['login_phone']; + $verify = $_POST['code']; + if (!$this->checksafecode($mobile, $verify)) { + $this->error('验证码错误'); + } + $promote = M('promote', 'tab_')->where([ + 'login_phone' => $mobile, + ])->find(); + if($promote) { + $loginrecord['promote_id'] = $promote['id']; + $loginrecord['account'] = $promote['account']; + $loginrecord['client_ip'] = $_SERVER['REMOTE_ADDR']; + $loginrecord['login_type'] = 2; + $loginrecord['create_time'] = time(); + M("promote_login_record", "tab_")->add($loginrecord); + setcookie('login_phone', $mobile, time() + 3600 * 10000, $_SERVER["HTTP_HOST"]); + $promote1 = new PromoteApi(); + $result = $promote1->login_phone($promote['account']); + if ($result) { + $this->ajaxReturn(array("status" => 1, "msg" => "登录成功", 'url' => U('Promote/index'))); + } + + }else { + $this->error('此电话未注册,登录失败'); + } + } + /* public function register() { if (IS_POST) { @@ -291,4 +326,51 @@ class IndexController extends HomeController $Promote->logout(); redirect(U('Index/index')); } + + public function phoneLogin() { + $this->display(); + } + + /** + * 发动手机验证码 + */ + public function telsafecode($phone = '', $exceptExists=1, $delay = 10, $flag = true) + { + $exists = M('promote', 'tab_')->where(['login_phone'=>$phone])->find(); + if (!$exceptExists) { + if ($exists) { + return $this->ajaxReturn(['status'=>0,'msg'=>'手机号已被绑定']); + } + } else { + if (!$exists) { + return $this->ajaxReturn(['status'=>0,'msg'=>'手机号未被绑定']); + } + } + $taskClient = new TaskClient(); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); + $data = []; + if ($result['code'] == TaskClient::SUCCESS) { + $data['status'] = 1; + } else { + $data['status'] = 0; + } + $data['msg'] = $result['message']; + echo json_encode($data); + exit; + } + + /** + * 手机安全码验证 + */ + public function checksafecode($phone, $code) + { + $taskClient = new TaskClient(); + $result = $taskClient->checkSms($phone, $code); + $data = []; + if ($result && $result['code'] == TaskClient::SUCCESS) { + return true; + } else { + return false; + } + } } diff --git a/Application/Home/Controller/PackageController.class.php b/Application/Home/Controller/PackageController.class.php index 41e70efce..6f664020d 100644 --- a/Application/Home/Controller/PackageController.class.php +++ b/Application/Home/Controller/PackageController.class.php @@ -54,6 +54,16 @@ class PackageController extends Controller $promoteId = $data['promote_id']; } + $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); + if (!$promote) { + $this->error('该链接已失效'); + } + + $promoteService = new PromoteService(); + if (!$promoteService->checkPromoteLimitRule($promote)) { + $this->error('链接已失效'); + } + $map = []; $map['status'] = 1; $map['enable_status'] = 1; @@ -65,7 +75,6 @@ class PackageController extends Controller $this->redirect("package/downloadError", ['message' => '该链接已经停止使用']); } - $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); $game = M('game','tab_')->field(['id', 'game_name', 'sdk_version', 'apply_auth'])->where(['id' => $apply['game_id']])->find(); if (Request::isMobile() || Request::isTablet()) { diff --git a/Application/Home/Controller/SafeController.class.php b/Application/Home/Controller/SafeController.class.php index 5e9d5bede..aa37c1988 100644 --- a/Application/Home/Controller/SafeController.class.php +++ b/Application/Home/Controller/SafeController.class.php @@ -9,6 +9,7 @@ namespace Home\Controller; use Think\Controller; use Base\Repository\PromoteRepository; +use Base\Tool\TaskClient; /** * 扩展控制器 @@ -18,12 +19,19 @@ class SafeController extends BaseController{ public function setSafeIndex() { $id = get_pid(); - $safePwd = M('promote','tab_')->where(['id'=>$id])->field('second_pwd')->find(); - if(empty($safePwd['second_pwd'])) { - return $this->display(); - }else { - return $this->display("verifySafePwd"); - } + $safePwd = M('promote','tab_')->where(['id'=>$id])->field('second_pwd, level, login_phone')->find(); + if(!empty($safePwd['login_phone'])) { + $this->assign('login_phone', $safePwd['login_phone']); + } + if ($safePwd['level'] != 1) { + return $this->error('非会长无法更改'); + } + return $this->display(); + // if(empty($safePwd['second_pwd'])) { + // return $this->display(); + // }else { + // return $this->display("verifySafePwd"); + // } } @@ -46,11 +54,9 @@ class SafeController extends BaseController{ $this->checkPaswwordFormat($confirmpassword); $data['second_pwd'] = $this->think_ucenter_md5($confirmpassword, UC_AUTH_KEY); $id = get_pid(); - $updateRs = M("promote","tab_")->where(['id'=>$id])->save($data); - if($updateRs) { - recordPromoteLogs('安全管理','设置安全密码'); - $this->success("安全密码设置成功"); - } + M("promote","tab_")->where(['id'=>$id])->save($data); + recordPromoteLogs('安全管理','设置安全密码'); + $this->success("安全密码设置成功"); } public function think_ucenter_md5($str, $key = 'ThinkUCenter') @@ -77,30 +83,33 @@ class SafeController extends BaseController{ } public function modifyPwdIndex() { + $id = get_pid(); + $promote = M('promote', 'tab_')->where(['id' => $id])->find(); + if(!empty($promote['login_phone'])) { + $this->assign('login_phone', $promote['login_phone']); + } if($_POST) { - $oldpwd = $_POST['oldpwd']; - $safepwd = $_POST['safepwd']; - if(empty($oldpwd)) { - $this->error("旧密码不能为空"); + if ($promote['level'] != 1) { + return $this->error('修改失败,非会长无法修改!'); } + //$oldpwd = $_POST['oldpwd']; + $safepwd = $_POST['safepwd']; + // if(empty($oldpwd)) { + // $this->error("旧密码不能为空"); + // } + $this->checkPaswwordFormat($safepwd); if(empty($safepwd)) { $this->error("安全密码不能为空"); } - $id = get_pid(); - $safePwd = M('promote','tab_')->where(['id'=>$id])->field('second_pwd')->find(); - if($safePwd['second_pwd'] == $this->think_ucenter_md5($oldpwd, UC_AUTH_KEY)){ - $data['second_pwd'] = $this->think_ucenter_md5($safepwd, UC_AUTH_KEY); - $updateRs = M("promote","tab_")->where(['id'=>$id])->save($data); - if($updateRs) { - $this->success("修改成功"); - }else { - $this->error("修改失败,请重新操作"); - } - } - else { - $this->error('旧密码错误,请确认'); + if (!$this->checksafecode($promote['login_phone'], $_POST['code'])) { + return $this->error('验证码错误'); } + $id = get_pid(); + $data['second_pwd'] = $this->think_ucenter_md5($safepwd, UC_AUTH_KEY); + M("promote","tab_")->where(['id'=>$id])->save($data); + $this->success("修改成功"); } + $this->display(); } @@ -338,7 +347,14 @@ class SafeController extends BaseController{ $this->assign('addr',json_decode($address)[1]); } $promoteInfo['address'] = json_decode($address); - + // 获取推广员的公司 + $promoteCompany = M('promote_company', 'tab_')->where(['id'=>$promoteInfo['company_id']])->find(); + if ($promoteCompany['service_agreement_show'] > 0) { + $serviceAgreement = M('service_agreement', 'tab_')->where(['id'=>$promoteCompany['service_agreement_show']])->find(); + $serviceAgreement['content'] = $this->renderServiceAgreement($serviceAgreement['content'], $promoteInfo); + $this->assign("serviceAgreement",$serviceAgreement); + } + $this->assign("promoteCompany",$promoteCompany); $this->assign("ver_status",$promoteInfo['ver_status']); $this->assign('promoteinfo', $promoteInfo); @@ -461,37 +477,63 @@ class SafeController extends BaseController{ $this->ajaxReturn($res); } - public function safeDocument() { - $realname = $_REQUEST['realname']; - $phone = $_REQUEST['phone']; - $email = $_REQUEST['email']; - $address = $_REQUEST['address']; - if (empty($realname)) { - $realname = '您未填写真实姓名'; - } - if (empty($email)) { - $email = '您未填写联系邮箱'; - } - if (empty($address)) { - $address = '您未填写注册地址'; - } - if (empty($phone)) { - $phone = '您未填写联系号码'; - } - $time = time(); - $loginPromote = $this->getLoginPromote(); - $sn = date('Ymd') . '-' . strtoupper(substr(md5($loginPromote['id']), 8, 16)); - $endTime = date('Y-m-d',strtotime('+1 year')); - $this->assign('time',date('Y-m-d',$time)); - $this->assign('endTime',$endTime); - $this->assign('sn',$sn); - $this->assign('realname',$realname); - $this->assign('email',$email); - $this->assign('address',$address); - $this->assign('phone',$phone); + public function safeDocument($templateId=0) { + $template = M('service_agreement', 'tab_')->where(['id'=>$templateId])->find(); + $promoteInfo = $this->getLoginPromote(); + + $sn = date('Ymd') . '-' . strtoupper(substr(md5($promoteInfo['id']), 8, 16)); + + $content = $template['content']; + $content = str_replace("{time}", date('Y-m-d'), $content); + $content = str_replace("{sn}", $sn, $content); + $content = str_replace("{endTime}", date('Y-m-d',strtotime('+1 year')), $content); + $content = str_replace("{account}", $promoteInfo['account'], $content); + $content = str_replace("{email}", $promoteInfo['email'], $content); + $content = str_replace("{realname}", $promoteInfo['real_name'], $content); + $content = str_replace("{phone}", $promoteInfo['mobile_phone'], $content); + $content = str_replace("{address}", json_decode($promoteInfo['address'],true)[1] ?? '', $content); + + // $realname = $_REQUEST['realname']; + // $phone = $_REQUEST['phone']; + // $email = $_REQUEST['email']; + // $address = $_REQUEST['address']; + // if (empty($realname)) { + // $realname = '您未填写真实姓名'; + // } + // if (empty($email)) { + // $email = '您未填写联系邮箱'; + // } + // if (empty($address)) { + // $address = '您未填写注册地址'; + // } + // if (empty($phone)) { + // $phone = '您未填写联系号码'; + // } + // $time = time(); + // $loginPromote = $this->getLoginPromote(); + + // $endTime = date('Y-m-d',strtotime('+1 year')); + // $this->assign('time',date('Y-m-d',$time)); + // $this->assign('endTime',$endTime); + // $this->assign('sn',$sn); + // $this->assign('realname',$realname); + // $this->assign('email',$email); + // $this->assign('address',$address); + // $this->assign('phone',$phone); + $this->assign('content', $content); $this->display(); } + private function renderServiceAgreement($content, $promoteInfo) + { + $content = str_replace("{account}", $promoteInfo['account'], $content); + $content = str_replace("{email}", $promoteInfo['email'], $content); + $content = str_replace("{real_name}", $promoteInfo['real_name'], $content); + $content = str_replace("{mobile_phone}", $promoteInfo['mobile_phone'], $content); + $content = str_replace("{addr}", $promoteInfo['addr'], $content); + return $content; + } + public function promoteLogs() { $page = intval(I('p', 1)); $row = intval(I('row', 10)); @@ -559,4 +601,83 @@ class SafeController extends BaseController{ $this->ajaxReturn(['code'=>0000,'mes'=>'删除成功']); } } + + public function bindTel() { + $id = get_pid(); + $promote = M('promote', 'tab_')->where(['id' => $id])->find(); + if(!empty($promote['login_phone'])) { + $this->assign('login_phone', $promote['login_phone']); + } + return $this->display(); + } + + /** + * 发动手机验证码 + */ + public function telsafecode($phone = '', $exceptExists=1, $delay = 10, $flag = true) + { + $exists = M('promote', 'tab_')->where(['login_phone'=>$phone])->find(); + if (!$exceptExists) { + if ($exists) { + return $this->ajaxReturn(['status'=>0,'msg'=>'手机号已被绑定']); + } + } else { + if (!$exists) { + return $this->ajaxReturn(['status'=>0,'msg'=>'手机号未被绑定']); + } + } + + $taskClient = new TaskClient(); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); + $data = []; + if ($result['code'] == TaskClient::SUCCESS) { + $data['status'] = 1; + } else { + $data['status'] = 0; + } + $data['msg'] = $result['message']; + echo json_encode($data); + exit; + } + + /** + * 手机安全码验证 + */ + public function checksafecode($phone, $code) + { + $taskClient = new TaskClient(); + $result = $taskClient->checkSms($phone, $code); + $data = []; + if ($result && $result['code'] == TaskClient::SUCCESS) { + return true; + } else { + return false; + } + } + + public function addLoginMobile() { + if (IS_POST) { + /* 检测验证码 TODO: */ + $mobile = $_POST['login_phone']; + $verify = $_POST['code']; + if (!$this->checksafecode($mobile, $verify)) { + $this->error('验证码错误'); + } + $id = get_pid(); + $promote = M('promote', 'tab_')->where([ + 'id' => $id + ])->find(); + if ($promote) { + $promote['login_phone'] = $mobile; + $updateRs = M('promote', 'tab_')->where(['id' => $id])->save($promote); + if($updateRs) { + $this->success("更新登陆手机号成功"); + }else { + $this->error("更新登陆手机号失败"); + } + }else { + $this->error("无此推广账号信息"); + } + } + } } \ No newline at end of file diff --git a/Application/Home/Controller/WithdrawController.class.php b/Application/Home/Controller/WithdrawController.class.php index 8c946ecf0..37aebdb44 100644 --- a/Application/Home/Controller/WithdrawController.class.php +++ b/Application/Home/Controller/WithdrawController.class.php @@ -37,6 +37,7 @@ class WithdrawController extends BaseController $map["promote.id"] = get_pid(); $map['tab_company_statement_info.company_type'] = ['in',"1,2"]; + $map['tab_company_statement_info.verify_status'] = 1; if ($_REQUEST['pay_status'] || $_REQUEST['pay_status'] == '0') { $map['pay_status'] = $_REQUEST['pay_status']; @@ -115,11 +116,12 @@ class WithdrawController extends BaseController $dbres = M("company_statement_info","tab_")->where("id='{$id}'")->find(); // $this->ajaxReturn(["msg"=>"打款成功","data"=>$dbres,"status"=>1]);die(); $company_info = json_decode($dbres['company_info'],true); - //TODO:未进行真实打款 + if($dbres['pay_status'] != 1 && $dbres['verify_status'] == 1){ //执行打款 $title = "测试-".$dbres['company_name']."结算"; $amount = $dbres['statement_money']; + //TODO:线上要关闭这个 $amount = 0.1;//测试金额为0 $payres = $fund->transfer($company_info['ali_account'],$company_info['ali_user'],$dbres['statement_num'],$amount, $title); $resultCode = $payres->code; @@ -139,12 +141,18 @@ class WithdrawController extends BaseController $savedata["pay_time"]=time(); } else { - $this->poolCount($dbres['pool_id']); + // $this->poolCount($dbres['pool_id']); $this->ajaxReturn(["msg"=>"已经打款过","data"=>$dbres,"status"=>0]); } - $this->poolCount($dbres['pool_id']); + M("company_statement_info","tab_")->save($savedata); - $this->ajaxReturn(["msg"=>"打款成功","data"=>$dbres,"status"=>1]); + // $this->poolCount($dbres['pool_id']); + + if ($savedata["pay_status"] == -1) { + $this->ajaxReturn(["msg"=>"提现失败","data"=>$dbres,"status"=>0]); + } + + $this->ajaxReturn(["msg"=>"提现成功","data"=>$dbres,"status"=>1]); } /** @@ -152,27 +160,22 @@ class WithdrawController extends BaseController * 整合数据,全部成功则支付成功,否则为支付中 */ public function poolCount($poolid){ - $pool_id = $poolid; - $CompanyInfo = M("company_statement_info","tab_"); - if(count($pool_id) > 0){ - foreach($pool_id as $k=>$v){ - $f = $CompanyInfo->where("pool_id = {$v} AND pay_status <> 1")->find(); - if(empty($f)){ - //全部完成 - $this->setOneVerifyStatus(4,"payment",$v); - }else{ - //打款中 - $this->setOneVerifyStatus(3,"payment",$v); - } - } + $f = M("company_statement_info","tab_")->field("id")->where("pool_id = {$poolid} AND pay_status <> 1")->find(); + + if(isset($f['id'])){ + //打款中 + $this->setOneVerifyStatus(3,"payment",$poolid); + }else{ + //全部完成 + $this->setOneVerifyStatus(4,"payment",$poolid); } + $this->ajaxReturn(["msg"=>"聚合成功","status"=>1]); } - protected function setOneVerifyStatus($change_status,$op_pre,$id) { $dbres = M("company_statement_pool","tab_")->field("id,verify_status,verify_log")->where("id = {$id}")->find(); $dbres['verify_log'] = json_decode($dbres['verify_log'],true); - $dbres['verify_log'][$op_pre.'_user']=$this->admininfo["mobile"]; + $dbres['verify_log'][$op_pre.'_user']=$_SESSION['onethink_home']['promote_auth']['account']; $dbres['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s"); $dbres['verify_log'] = json_encode($dbres['verify_log']); $dbres['verify_status']=$change_status; diff --git a/Application/Home/View/default/Finance/index.html b/Application/Home/View/default/Finance/index.html index ae9906f67..df042c3c6 100644 --- a/Application/Home/View/default/Finance/index.html +++ b/Application/Home/View/default/Finance/index.html @@ -31,13 +31,13 @@
  • 历史收益

    ¥{$income.history_income}
  • 本月收益

    ¥{$income.this_month_income}
  • 昨日收益

    ¥{$income.yesterday_income}
  • -
  • 账户余额

    ¥{$income.balance}
  • - -
      -
    • 已实际提现总金额

      ¥{$income.withdrawn_amount}
    • -
    • 未实际提现金额

      ¥{$income.not_withdrawn_amount}
    • -
    • 结算周期

      {$settlementCycle}
    • +
    + + + + +
    diff --git a/Application/Home/View/default/Index/index.html b/Application/Home/View/default/Index/index.html index 578362aeb..822ac37eb 100644 --- a/Application/Home/View/default/Index/index.html +++ b/Application/Home/View/default/Index/index.html @@ -38,6 +38,7 @@
    +
    diff --git a/Application/Home/View/default/Index/phoneLogin.html b/Application/Home/View/default/Index/phoneLogin.html new file mode 100644 index 000000000..48db08192 --- /dev/null +++ b/Application/Home/View/default/Index/phoneLogin.html @@ -0,0 +1,264 @@ + + + + + + + +
    +
    + + + +
    +
    +
    +
    + +
    + + + +
    + +
    + +
    +
    + + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index f1b159ba4..8c9a800f7 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -103,6 +103,7 @@