diff --git a/Application/Admin/Conf/config.php b/Application/Admin/Conf/config.php index e3319f786..30a1267bb 100644 --- a/Application/Admin/Conf/config.php +++ b/Application/Admin/Conf/config.php @@ -129,6 +129,9 @@ return array( "tab_reward_detail", "tab_reward_record", "tab_new_company_statement_info", - "tab_spend" + "tab_game", + "tab_spend", + "tab_promote", + "tab_promote_company", ] ); \ No newline at end of file diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index a1d961da1..e4fe83fea 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -374,13 +374,16 @@ class CompanyStatementController extends ThinkController if(is_array($dbres['statement_info'])) { foreach ($dbres['statement_info'] as $key => $value) { + + $dbres['pay_amount_other'] += $value['platform_money']; + if ($value['game_name'] == "罚款" || $value['game_name'] == "奖励") { $dbres['statement_info'][$key]['pay_amount'] = "-"; } - $real_statement_amount - = number_format($value['platform_money']*(1-$value['promote_ratio']/100)*($value['ratio']/100)*(1-$value["fax_ratio"]/100),2,'.','');; + = number_format(($value['platform_money']+$value['aggregate_money'])*(1-$value['promote_ratio']/100)*($value['ratio']/100)*(1-$value["fax_ratio"]/100),2,'.',''); + if (!$dbres['statement_info'][$key]['other_amount']) { $dbres['statement_info'][$key]['other_amount'] = number_format($value["sum_money"] - $real_statement_amount,2,'.',''); } @@ -680,7 +683,7 @@ class CompanyStatementController extends ThinkController $statement_info[$k]['sum_amount'] = $v["platform_money"] + $v["aggregate_money"] ; $real_statement_amount - = number_format($v['platform_money']*(1-$v['promote_ratio']/100)*($v['ratio']/100)*(1-$v["fax_ratio"]/100),2,'.','');; + = number_format(($v['platform_money']+$value['aggregate_money'])*(1-$v['promote_ratio']/100)*($v['ratio']/100)*(1-$v["fax_ratio"]/100),2,'.',''); if (!$statement_info[$k]['other_amount']) { $statement_info[$k]['other_amount'] = number_format($v["sum_money"] - $real_statement_amount,2,'.',''); } diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 93fb2af19..0c7ab2198 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -294,13 +294,12 @@ class FinancePromoteController extends AdminController } $map['s.pay_status']=1; $map['s.is_check']=2; - D("Spend")->addSubsiteWhere($map,"s"); $field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count, SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id, IFNULL(company_id,0) company_id,company_name,develop_type,IFNULL(promote.company_belong,0) company_belong"; - $query = M() + $query = SM() ->table("tab_spend s use index(promote_time)") ->field($field) ->where($map) @@ -379,13 +378,12 @@ class FinancePromoteController extends AdminController } $map['s.pay_status']=1; // $map['s.is_check']=1; - D("Spend")->addSubsiteWhere($map,"s"); $field= "SUM(CASE WHEN pay_way > 0 and s.is_check=1 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 and s.is_check=1 THEN pay_amount ELSE 0 END) as balance_coin_count, SUM(CASE WHEN pay_way = -1 and s.is_check=1 THEN pay_amount ELSE 0 END) as bind_coin_count, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id, IFNULL(company_id,0) company_id,company_name,develop_type,IFNULL(promote.company_belong,0) company_belong"; - $query = M() + $query = SM() ->table("tab_spend s use index(promote_time)") ->field($field) ->where($map) @@ -610,13 +608,12 @@ class FinancePromoteController extends AdminController } $map['s.pay_status']=1; $map['s.is_check']=1; - D("Spend")->addSubsiteWhere($map,"s"); // dd($map); $field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count, SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count, IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,develop_type,IFNULL(promote.company_belong,0) company_belong"; - $query = M() + $query = SM() ->table("tab_spend s use index(promote_time)") ->field($field) ->where($map) @@ -895,9 +892,9 @@ class FinancePromoteController extends AdminController $group = ""; $order = "pay_time DESC"; if(isset($_REQUEST['export'])){ - $data = D('spend')->getSpendData($map,$field,$group,$order); + $data = D('spend')->getSubSpendData($map,$field,$group,$order); }else { - $data = D('spend')->getSpendData($map,$field,$group,$order,$page,$row); + $data = D('spend')->getSubSpendData($map,$field,$group,$order,$page,$row); } $marketAdmins = []; @@ -965,7 +962,7 @@ class FinancePromoteController extends AdminController $this->assign('sumInside', $sumInside); $this->assign('sumAll', null_to_0($sumAll)); - $count = D("spend")->getSpendData($map,$field,$group,$order); + $count = D("spend")->getSubSpendData($map,$field,$group,$order); $count = count($count); $page = set_pagination($count,$row); @@ -996,7 +993,7 @@ class FinancePromoteController extends AdminController $map['s.pay_status']=1; $map['s.is_check']=1; - $query = M("spend","tab_")->alias("s") + $query = SM("spend","tab_")->alias("s") ->field("s.game_id,s.game_name,s.sdk_version,p.partner as partner_name, SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count, @@ -1039,7 +1036,7 @@ class FinancePromoteController extends AdminController $map['s.market_admin_id'] = $adminId; } - $query = M("spend","tab_")->alias("s") + $query = SM("spend","tab_")->alias("s") ->field("SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count, SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count"); @@ -1099,7 +1096,7 @@ class FinancePromoteController extends AdminController $row = 10; } $map['pay_status'] = 1; - $map['is_check'] = 1; + $map['tab_spend.is_check'] = 1; if (!empty(I('user_account'))) { $map['tab_spend.user_account'] = array('like','%'.I("user_account").'%'); @@ -1107,7 +1104,7 @@ class FinancePromoteController extends AdminController if (!empty(I('user_nickname'))) { $map['tab_spend.game_player_name'] = array('like',I("user_nickname").'%'); } - D("Spend")->addSubsiteWhere($map,"s"); + D("Spend")->addSubsiteWhere($map,"tab_spend"); $field = "pay_order_number,FROM_UNIXTIME(payed_time) as pay_time,tab_spend.user_account, tab_spend.user_nickname,tab_spend.game_name,tab_spend.promote_account,spend_ip,tab_spend.server_name,tab_spend.sdk_version, game_player_name,pay_amount,cost,pay_way"; diff --git a/Application/Admin/Controller/FinancialSummaryController.class.php b/Application/Admin/Controller/FinancialSummaryController.class.php index b75b0de48..0998a121f 100644 --- a/Application/Admin/Controller/FinancialSummaryController.class.php +++ b/Application/Admin/Controller/FinancialSummaryController.class.php @@ -29,13 +29,7 @@ class FinancialSummaryController extends AdminController if(!IS_ROOT){ $this->OpAuthList= getModuleControllerAuth(); } - $this->assign('menubtn',$this->menuAuth()); - $lastRecount = D("CmdTasks")->getTypeLastTask("FinancialSummary"); - if(!$lastRecount){ - $lastRecount = "无"; - } - $this->assign('lastRecount',$lastRecount); - + $this->assign('menubtn',$this->menuAuth()); $this->getYearList(); $this->getYearData(); $this->display(); @@ -43,9 +37,10 @@ class FinancialSummaryController extends AdminController } public function updateStatement() { - - $temp = date('Y-m',strtotime(date('Y',time()).'-'.(date('m',time())-1).'-01')); - $params = "php ".SUBSITE_INDEX." FinancialSummarySet/setMonthFinancialSummary/recount/1/count_date/{$temp}"; + if(!isset($_REQUEST['time'])) $this->error("参数错误"); + + $time = $_REQUEST['time']; + $params = "php ".SUBSITE_INDEX." FinancialSummarySet/setMonthFinancialSummary/recount/1/count_date/{$time}"; $r = D("CmdTasks")->addTask("FinancialSummary",$params); if($r){ $this->ajaxReturn(["success"=>"ok"]); diff --git a/Application/Admin/Controller/FinancialSummarySetController.class.php b/Application/Admin/Controller/FinancialSummarySetController.class.php index 3a51e78d4..1e6e34a1b 100644 --- a/Application/Admin/Controller/FinancialSummarySetController.class.php +++ b/Application/Admin/Controller/FinancialSummarySetController.class.php @@ -266,12 +266,13 @@ class FinancialSummarySetController extends \Think\Controller */ public function setPromoteMoney() { + $SpendModel = SM("spend",'tab_'); $map = array( "payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), "pay_status"=>1, ); D("Spend")->addSubsiteWhere($map,"s"); - $res = $this->SpendModel + $res = $SpendModel ->alias('s') ->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count, IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count, @@ -358,7 +359,7 @@ class FinancialSummarySetController extends \Think\Controller $unmap = $map; $unmap['is_check'] = 2; - $unSettlementRes = $this->SpendModel + $unSettlementRes = $SpendModel ->alias('s') ->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count, IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count, diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 6e05c02fa..416f82fd6 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -466,7 +466,7 @@ ADD COLUMN `kefu_qq` varchar(255) NULL DEFAULT '' COMMENT 'kefu_qq_type为2 时 $otherData['flooring_page_video_cover'] = $sibling['flooring_page_video_cover']; $otherData['kefu_qq'] = I('post.kefu_qq'); $otherData['kefu_qq_type'] = I('post.kefu_qq_type'); - $otherData['data_share'] = I('post.data.share'); + $otherData['data_share'] = I('post.data_share'); M('Game', 'tab_')->data($otherData)->where(array('id' => $another['id']))->save(); //同时修改代充游戏折扣 diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 63e746e58..bacd17353 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -255,7 +255,6 @@ class PlatformController extends ThinkController "pay_time"=>["between",$yearMap], "pay_status"=>1 ]; - D("Spend")->addSubsiteWhere($map); $Payamount = SM("Spend","tab_")->field("sum(IF(is_check=1,pay_amount,0)) pay_amount,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select(); if(empty($Payamount)) return ; foreach ($Payamount as $v) { @@ -1174,7 +1173,7 @@ class PlatformController extends ThinkController } D("Spend")->addSubsiteWhere($map,"s"); - $data = M('promote', 'tab_')->alias('tp1') + $data = SM('promote', 'tab_')->alias('tp1') ->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name, floor(sum(IF(is_check=1,pay_amount,0))*100) as count,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_count') ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') @@ -1190,7 +1189,7 @@ class PlatformController extends ThinkController if(isset($map['pay_time'])){ $tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])]; } - $tdata = M('promote', 'tab_')->alias('tp1') + $tdata = SM('promote', 'tab_')->alias('tp1') ->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name, floor(sum(IF(s.pay_time ' . $today . ' and is_check=1,pay_amount,0))*100) as today, floor(sum(IF(s.pay_time ' . $week . ' and is_check=1,pay_amount,0))*100) as week, @@ -1248,11 +1247,11 @@ class PlatformController extends ThinkController $user_auth_promote_ids = session('user_auth_promote_ids'); if ($user_auth_promote_ids == 'all' || in_array('0', explode(",", $user_auth_promote_ids))) { //官方渠道数据添加 - $authorityData = M('spend', 'tab_')->alias('s') + $authorityData = SM('spend', 'tab_')->alias('s') ->field('floor(sum(IF(is_check=1,pay_amount,0))*100) as count,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_count') ->where($map) ->find(); - $tauthorityData = M('spend', 'tab_')->alias('s') + $tauthorityData = SM('spend', 'tab_')->alias('s') ->field(' floor(sum(IF(s.pay_time ' . $today . ' and is_check=1,pay_amount,0))*100) as today, floor(sum(IF(s.pay_time ' . $week . ' and is_check=1,pay_amount,0))*100) as week, diff --git a/Application/Admin/Controller/SubSynTableController.class.php b/Application/Admin/Controller/SubSynTableController.class.php new file mode 100644 index 000000000..abed98117 --- /dev/null +++ b/Application/Admin/Controller/SubSynTableController.class.php @@ -0,0 +1,73 @@ +SubSynTableModel = M("syn_table","sub_",SUBSITE_DB);//指定子库 + } + + public function run(){ + $synList = $this->SubSynTableModel->field("id,table_name,table_prefix,check_sum")->select(); + foreach ($synList as $k => $v) { + $this->doSyn($v); + } + } + + public function synOneTable($table_prefix,$tab_name) + { + $synInfo = $this->SubSynTableModel->where("table_name = '{$tab_name}' and table_prefix = '{$table_prefix}'")->field("id,table_name,table_prefix,check_sum")->find(); + $this->doSyn($synInfo); + } + + protected function doSyn($dbarr) + { + //获取最新check_sum + $table_prefix = $dbarr['table_prefix']; + $table_name = $dbarr['table_name']; + $res = M()->query(self::CHECK_SUM_SQL.$table_prefix.$table_name); + $now = time(); + $check_sum = $res[0]['checksum']; + if($check_sum !== $dbarr['check_sum']){ + $this->clearTable($table_prefix,$table_name); + $this->synTable($table_prefix,$table_name); + $dbarr['syn_time'] = $now; + $dbarr['check_sum'] = $check_sum; + } + $dbarr['update_time'] = $now; + $this->SubSynTableModel->save($dbarr); + echo $table_prefix.$table_name." success".PHP_EOL; + } + protected function clearTable($table_prefix,$table_name) + { + return SM()->query(self::TRUNCATE_SQL.$table_prefix.$table_name); + } + protected function synTable($table_prefix,$table_name) + { + $count = M($table_name,$table_prefix)->count(); + if(empty($count)) return true; + $pageCount = ceil($count/self::LIMIT); + for ($i=1; $i <= $pageCount; $i++) { + $tres = M($table_name,$table_prefix)->page($i,self::LIMIT)->select(); + $addRes = M($table_name,$table_prefix,SUBSITE_DB)->addAll($tres); + echo "[{$i}/{$pageCount}] {$addRes}".PHP_EOL; + } + return true; + } + +} diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 0ce2fb602..51fecfd41 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -843,6 +843,19 @@ class SpendModel extends Model } return $data; } + public function getSubSpendData($map = [], $field = '', $group = '', $order = '', $page = 0, $row = 0, $join = false) + { + $query = SM('spend',"tab_")->field($field)->where($map)->group($group)->order($order); + if ($join) { + $query = $query->join($join); + } + if ($row == 0) { + $data = $query->select(); + } else { + $data = $query->page($page, $row)->select(); + } + return $data; + } public function sumSpend($map = [], $field = '') { @@ -850,6 +863,12 @@ class SpendModel extends Model return $sum; } + public function sumSubSpend($map = [], $field = '') + { + $sum = SM('spend',"tab_")->where($map)->sum($field); + + return $sum; + } private function getGameMapByGameStatMap($map) { diff --git a/Application/Admin/View/CompanyStatement/editWmCpStatement.html b/Application/Admin/View/CompanyStatement/editWmCpStatement.html index e292a9d01..cff930076 100644 --- a/Application/Admin/View/CompanyStatement/editWmCpStatement.html +++ b/Application/Admin/View/CompanyStatement/editWmCpStatement.html @@ -210,12 +210,12 @@ 渠道费率 税费费率 其他 - 结算金额 - - - - 结算金额=平台总额*(1-渠道费)*分成比例*(1-税费费率) + 结算金额 + + + + @@ -373,11 +373,11 @@ ${it.statement_begin_time}~${it.statement_end_time} ${it.game_name} {@if it.statement_type==1} - -${it.pay_amount}元 + -${it.platform_money}元 {@else} - ${it.pay_amount}元 + ${it.platform_money}元 {@/if} - ${it.aggregate_money} + ${it.aggregate_money}元 {@if it.statement_type==0} % @@ -404,7 +404,7 @@ 合计 - ${pay_amount}元 + ${pay_amount_other}元 diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html index 4094d65e6..c6605e1b5 100644 --- a/Application/Admin/View/FinancePromote/index.html +++ b/Application/Admin/View/FinancePromote/index.html @@ -85,7 +85,7 @@

推广员充值统计

-

说明:针对所有推广员下的充值金额,进行充值排行统计:游戏、平台币、绑币的现金充值总额

+

说明:针对所有推广员下的充值金额,进行充值排行统计:游戏、平台币、绑币的现金充值总额/ 支付信息仅统计已固定的订单数据

diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index 30ed4bc2a..6933ad4de 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -307,9 +307,9 @@ class HomeController extends Controller $ssgUrl = $downloadDomain . '/mobile.php/Ssg/pay/game_id/' . $game['id'] . '/promote_id/' . $promoteId; - /* if(in_array($game['id'], [187, 188])) { - $game['relation_game_name'] = '游戏下载'; - } */ + if(in_array($game['id'], [191, 192])) { + $game['relation_game_name'] = '九灵神域'; + } $this->assign("serviceQQ", $serviceQQ); $this->assign('isNewIos', $isNewIos);