Merge pull request 'feature/more_payment' (#388) from feature/more_payment into master

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/388
master
廖金灵 4 years ago
commit 82a40a79bd

@ -1475,10 +1475,10 @@ class CompanyStatementController extends ThinkController
$company_info = $va['company_info'];
$LackStatement = SM("company_lack_statement_info","tab_");
$no_pool_money = 300;
$no_pool_money = 0;//公司原定小于300不结算现在取消
//统一比例字段
if($k == "up" || $k=="ups"){
$no_pool_money = 500;
// $no_pool_money = 500;//上游原定小于500不结算现在取消
foreach ($va['statement_info'] as $key => &$value) {
if($company_info['pay_type'] == 2){
$value["ratio"] = $value["second_ratio"];

@ -200,7 +200,7 @@ class GameMarginController extends AdminController
$v["jh_margin_ratio"] = "=ROUND(Y{$line}/V{$line},3)";
}
$v['margin_amount'] = "=ROUND((D{$line}-G{$line}-I{$line}-J{$line}-M{$line}-R{$line}+X{$line}),2)";
$v['margin_amount'] = "=ROUND((D{$line}-G{$line}-I{$line}-J{$line}-M{$line}-R{$line}-(V{$line}}-X{$line})),2)";
$v['margin_ratio'] = "=ROUND(AB{$line}/D{$line},3)";
$v['count_year'] = $date['count_year'];
$v['count_month'] = $date['count_month'];
@ -427,7 +427,7 @@ class GameMarginController extends AdminController
$v["jh_margin_ratio"] = "=ROUND(Y{$line}/V{$line},3)";
}
$v['margin_amount'] = "=ROUND((D{$line}-G{$line}-I{$line}-J{$line}-M{$line}-R{$line}+X{$line}),2)";
$v['margin_amount'] = "=ROUND((D{$line}-G{$line}-I{$line}-J{$line}-M{$line}-R{$line}-(V{$line}-X{$line})),2)";
$v['margin_ratio'] = "=ROUND(AB{$line}/D{$line},3)";
@ -565,7 +565,7 @@ class GameMarginController extends AdminController
$item["jh_margin_amount"] = round( $item["jh_statement_amount"]-$item["jh_pay_amount"]*(1-$item['cp_promote_ratio']/100)*($item["cp_ratio"]+$item['cp_rebate_ratio'])/100 ,2);
$item["jh_margin_ratio"] = round($item["jh_margin_amount"]/$item['jh_pay_amount'],4)*100;
}
$item['margin_amount'] = round( ($item['pay_amount']-$item['cp_statement_amount']-$item['cp_rebate_amount']-$item['cp_other_amount']-$item['pc_statement_amount']-$item['pu_statement_amount']+$item['jh_statement_amount']),2);
$item['margin_amount'] = round( ($item['pay_amount']-$item['cp_statement_amount']-$item['cp_rebate_amount']-$item['cp_other_amount']-$item['pc_statement_amount']-$item['pu_statement_amount']-($item['jh_pay_amount'] - $item['jh_statement_amount'])),2);
$item['margin_ratio'] = round($item['margin_amount']/$item['pay_amount'],4)*100;
$margin_amount = 0;

@ -17,12 +17,11 @@ class GameMarginSetController extends Controller {
private $year;//年份
private $adddata;//要添加的数据
private $inSideCompanyIds;
private $debugGame=false;
private $debugStr='';
private $downFlowData;
/**
* 更新某月数据
*/
public function setFreeMonth($count_date,$debug_game=false)
public function setFreeMonth($count_date)
{
//设置转换精度
ini_set('serialize_precision',14);
@ -38,8 +37,6 @@ class GameMarginSetController extends Controller {
$this->month= $tarry[1];
$this->beginThismonth=mktime(0,0,0,$tarry[1],1,$tarry[0]);
$this->endThismonth=mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1;
$this->debugGame=$debug_game;
$this->reCount();
$this->setGameMargin();
}
@ -62,16 +59,19 @@ class GameMarginSetController extends Controller {
private function setGameMargin()
{
$this->getInsideCompanyid();
//获取所有下游支付信息
$this->getAllDownFlowSpend();
$this->getAllGameSpend();
$this->getJuheStatement();
$this->getCpStatement();
$this->getPuStatement();
$this->getPcStatement();
//计算内外团数据
$this->setDownFlowCount();
//3.特殊补点
$this->getPuSpecialStatement();
$this->setMarginCount();
if($this->debugGame){
$str = $this->debugGame . PHP_EOL."公司名称,团体归属,时间,流水,分成". $this->debugStr . PHP_EOL;
echo $str;
}
echo "{$this->year}-{$this->month}生成成功".PHP_EOL;
}
/**
@ -88,6 +88,33 @@ class GameMarginSetController extends Controller {
}
$this->inSideCompanyIds = implode(",",$res);
}
//获取期间下游公司游戏流水
private function getAllDownFlowSpend()
{
$where = [
"pay_status"=>1,
"is_refund"=>0,
"is_check"=>1,
"payed_time"=>["between",[$this->beginThismonth,$this->endThismonth]],
"p.company_id"=>["NOT IN",$this->inSideCompanyIds]
];
$dbres = M("Spend","tab_")
->alias("s")
->field("substring_index(game_name, '(', 1) relation_game_name,SUM(pay_amount) pay_amount,p.company_id,p.company_belong")
->join("tab_promote as p on s.promote_id = p.id")
->where($where)
->group("relation_game_name,company_id")
->order("pay_amount desc")->select();
foreach ($dbres as $v) {
if($v['company_belong'] > 0){
$v['company_belong'] = 1;
}else{
$v['company_belong'] = 0;
}
$this->downFlowData[$v['company_belong']][$v['company_id']][$v['relation_game_name']]['pay_amount'] = $v['pay_amount'];
}
unset($dbres);
}
//获取期间所有有流水的游戏
private function getAllGameSpend()
{
@ -149,7 +176,7 @@ class GameMarginSetController extends Controller {
"company_type"=>2,
"withdraw_type"=>0
];
$statement_pool = M("company_statement_pool","tab_")->where($where)->order("statement_begin_time asc")->select();
$statement_pool = M("company_statement_pool","tab_")->where($where)->order("statement_begin_time desc")->select();
//获取结算分段
$date_arr = [];
foreach ($statement_pool as $k => $v) {
@ -158,18 +185,15 @@ class GameMarginSetController extends Controller {
"statement_end_time"=>$v['statement_end_time'],
"begin_time"=>date("Y.m.d",$v['statement_begin_time']),
"end_time"=>date("Y.m.d",$v['statement_end_time']),
"recount"=>false,
"withdraw_type"=>0
];
if($v['statement_begin_time'] < $this->beginThismonth){
$tem['statement_begin_time'] = $this->beginThismonth;
$tem['begin_time'] = date("Y.m.d",$this->beginThismonth);
$tem['recount'] = true;
}
if($v['statement_end_time'] > $this->endThismonth){
$tem['statement_end_time'] = $this->endThismonth;
$tem['end_time'] = date("Y.m.d",$this->endThismonth);
$tem['recount'] = true;
}
$this->getPuAllStatement($tem,$v);
$this->getPuCompanyStatement($tem);//对公周结
@ -181,13 +205,10 @@ class GameMarginSetController extends Controller {
"statement_end_time"=>$this->endThismonth,
"begin_time"=>date("Y.m.d",$this->beginThismonth),
"end_time"=>date("Y.m.d",$this->endThismonth),
"recount"=>false,
"withdraw_type"=>1
];
$this->getPuCompanyStatement($tem);
//3.特殊补点
$this->getPuSpecialStatement();
}
/**
* 获取所有个人周结
@ -215,22 +236,11 @@ class GameMarginSetController extends Controller {
if( ($val['statement_begin_time'] != $time['begin_time']) && ($val['statement_end_time'] != $time['end_time']) ){
continue;
}
if($time['recount']){
$pay_amount = $this->getPuGameSpend($va['account'],$val['game_name']."(",$time['statement_begin_time'],$time['statement_end_time']);
$val['sum_money'] = round($pay_amount/$val['pay_amount']*$val['sum_money'],2);
$val['pay_amount'] = $pay_amount;
}
if( array_key_exists("pu_pay_amount",$this->adddata[$val['game_name']]) ){
$this->adddata[$val['game_name']]['pu_pay_amount'] += $val['pay_amount'];
$this->adddata[$val['game_name']]['pu_statement_amount'] += $val['sum_money'];
}else{
$this->adddata[$val['game_name']]['pu_pay_amount'] = $val['pay_amount'];
$this->adddata[$val['game_name']]['pu_statement_amount'] = $val['sum_money'];
if(!array_key_exists($val['game_name'],$this->downFlowData[1][$v['company_id']])){
continue;
}
if($this->debugGame && $this->debugGame == $val['game_name']){
$this->debugStr .= (PHP_EOL."{$v['company_name']},外团,{$time['begin_time']}-{$time['end_time']},{$val['pay_amount']},{$val['sum_money']}");
if(!array_key_exists("ratio",$this->downFlowData[1][$v['company_id']][$val['game_name']])){
$this->downFlowData[1][$v['company_id']][$val['game_name']]["ratio"] = $val['ratio'];
}
}
}
@ -290,21 +300,12 @@ class GameMarginSetController extends Controller {
if( ($val['statement_begin_time'] != $time['begin_time']) && ($val['statement_end_time'] != $time['end_time']) ){
continue;
}
if($time['recount']){
$pay_amount = $this->getPuCompanyGameSpend($v['company_id'],$val['game_name']."(",$time['statement_begin_time'],$time['statement_end_time']);
$val['sum_money'] = round($pay_amount/$val['pay_amount']*$val['sum_money'],2);
$val['pay_amount'] = $pay_amount;
}
if( array_key_exists("pu_pay_amount",$this->adddata[$val['game_name']]) ){
$this->adddata[$val['game_name']]['pu_pay_amount'] += $val['pay_amount'];
$this->adddata[$val['game_name']]['pu_statement_amount'] += $val['sum_money'];
}else{
$this->adddata[$val['game_name']]['pu_pay_amount'] = $val['pay_amount'];
$this->adddata[$val['game_name']]['pu_statement_amount'] = $val['sum_money'];
}
if($this->debugGame && $this->debugGame == $val['game_name']){
$this->debugStr .= (PHP_EOL."{$v['company_name']},外团,{$time['begin_time']}-{$time['end_time']},{$val['pay_amount']},{$val['sum_money']}");
if(!array_key_exists($val['game_name'],$this->downFlowData[1][$v['company_id']])){
continue;
}
if(!array_key_exists("ratio",$this->downFlowData[1][$v['company_id']][$val['game_name']])){
$this->downFlowData[1][$v['company_id']][$val['game_name']]["ratio"] = $val['ratio'];
}
}
}
@ -399,7 +400,7 @@ class GameMarginSetController extends Controller {
return [$OPName];
}
}
//获取下游内团
//获取下游内团,未计算下游内团周结算
private function getPcStatement()
{
$where = [
@ -418,17 +419,48 @@ class GameMarginSetController extends Controller {
if( !array_key_exists($val['game_name'],$this->adddata) ){
continue;
}
if( array_key_exists("pc_pay_amount",$this->adddata[$val['game_name']]) ){
$this->adddata[$val['game_name']]['pc_pay_amount'] += $val['pay_amount'];
$this->adddata[$val['game_name']]['pc_statement_amount'] += $val['sum_money'];
}else{
$this->adddata[$val['game_name']]['pc_pay_amount'] = $val['pay_amount'];
$this->adddata[$val['game_name']]['pc_statement_amount'] = $val['sum_money'];
if(!array_key_exists($val['game_name'],$this->downFlowData[0][$v['company_id']])){
continue;
}
if(!array_key_exists("ratio",$this->downFlowData[1][$v['company_id']][$val['game_name']])){
$this->downFlowData[0][$v['company_id']][$val['game_name']]["ratio"] = $val['ratio'];
}
}
}
}
}
private function setDownFlowCount()
{
$insideGroup = $this->downFlowData[0];
$outGroup = $this->downFlowData[1];
foreach ($insideGroup as $companyId => $gameList) {
foreach ($gameList as $gameName => $v) {
$v['sum_money'] = round($v['pay_amount']*$v['ratio']/100,2);
if( array_key_exists("pc_pay_amount",$this->adddata[$gameName]) ){
$this->adddata[$gameName]['pc_pay_amount'] += $v['pay_amount'];
$this->adddata[$gameName]['pc_statement_amount'] += $v['sum_money'];
}else{
$this->adddata[$gameName]['pc_pay_amount'] = $v['pay_amount'];
$this->adddata[$gameName]['pc_statement_amount'] = $v['sum_money'];
}
}
}
foreach ($outGroup as $companyId => $gameList) {
foreach ($gameList as $gameName => $v) {
$v['sum_money'] = round($v['pay_amount']*$v['ratio']/100,2);
if( array_key_exists("pu_pay_amount",$this->adddata[$gameName]) ){
$this->adddata[$gameName]['pu_pay_amount'] += $v['pay_amount'];
$this->adddata[$gameName]['pu_statement_amount'] += $v['sum_money'];
}else{
$this->adddata[$gameName]['pu_pay_amount'] = $v['pay_amount'];
$this->adddata[$gameName]['pu_statement_amount'] = $v['sum_money'];
}
}
}
}
//相关属性计算
private function setMarginCount()
{
@ -484,7 +516,7 @@ class GameMarginSetController extends Controller {
$v["jh_margin_ratio"] = round($v["jh_margin_amount"]/$v['jh_pay_amount'],3)*100;
}
$v['margin_amount'] = round( ($v['pay_amount']-$v['cp_statement_amount']-$v['cp_rebate_amount']-$v['cp_other_amount']-$v['pc_statement_amount']-$v['pu_statement_amount']+$v['jh_statement_amount']),2);
$v['margin_amount'] = round( ($v['pay_amount']-$v['cp_statement_amount']-$v['cp_rebate_amount']-$v['cp_other_amount']-$v['pc_statement_amount']-$v['pu_statement_amount']-( $v['jh_pay_amount'] - $v['jh_statement_amount'] )),2);
$v['margin_ratio'] = round($v['margin_amount']/$v['pay_amount'],3)*100;
$pay_amount += $v['pay_amount'];

@ -396,10 +396,15 @@ class PaymentMerchantController extends ThinkController
$alipayId = I('alipay_merchant_id', 0);
$weixinId = I('weixin_merchant_id', 0);
$expressId = I('express_merchant_id', 0);
$timeType = I('time_type', 1);
$export = I('export', 0);
$conditions = [];
$conditions = ["_string"=>"1=1"];
if ($companyBelong != -1) {
$conditions['company_belong'] = $companyBelong;
// $conditions['company_belong'] = $companyBelong;
$promoteCompanyIds = M("promote_company","tab_")->where("company_belong = '{$companyBelong}'")->getField("id",true);
$promoteCompanyIds = implode(",",$promoteCompanyIds);
$conditions['_string'].=" AND ( r.company_belong = {$companyBelong} or company_id in ({$promoteCompanyIds}) )";
}
if ($companyId != 0) {
$conditions['company_id'] = $companyId;
@ -422,7 +427,7 @@ class PaymentMerchantController extends ThinkController
[$start, $end] = $this->getEffectiveTimeRange($startedAt, $endedAt);
// var_dump($start, $end);die();
$timeCondition = ' ((start_time >= ' . $start . ' AND start_time <= ' . $end . ') OR (start_time <= ' . $start . ' AND end_time >= ' . $end
$timeCondition = ' AND ((start_time >= ' . $start . ' AND start_time <= ' . $end . ') OR (start_time <= ' . $start . ' AND end_time >= ' . $end
. ') OR (end_time >= ' . $start . ' AND end_time <= ' . $end . '))';
if (isset($conditions['_string'])) {
$conditions['_string'] .= $timeCondition;
@ -430,16 +435,25 @@ class PaymentMerchantController extends ThinkController
$conditions['_string'] = $timeCondition;
}
if($timeType == 2){
$now = strtotime(date("Y-m-d") . ' 00:00:00');
$conditions['_string'] .= ' AND ( start_time <= ' . $now . " AND end_time >= {$now} )";
}
$paymentRuleService = new PaymentRuleService();
$gameService = new GameService();
$paymentMerchantService = new PaymentMerchantService();
$companyService = new PromoteCompanyService();
$query = M('payment_rule', 'tab_')->where($conditions);
$query = M('payment_rule', 'tab_')->alias("r")->field("r.*,pc.company_belong pc_company_belong")->where($conditions)->join("tab_promote_company as pc on pc.id = r.company_id","left");
$countQuery = clone $query;
$items = $query->order('start_time desc')->page($page, $row)->select();
if($export == 1){
$items = $query->order('start_time desc')->select();
}else{
$items = $query->order('start_time desc')->page($page, $row)->select();
}
$count = $countQuery->count();
$gameTypes = $gameService->getGameTypes(null, 'id,type_name');
@ -457,7 +471,7 @@ class PaymentMerchantController extends ThinkController
foreach ($items as $item) {
$records[] = [
'id' => $item['id'],
'company_type_name' => $companyTypes[$item['company_belong']] ?? '--',
'company_type_name' => $companyTypes[$item['company_belong']] ?? ($companyTypes[$item['pc_company_belong']] ?? '--') ,
'company_name' => isset($companies[$item['company_id']]) ? $companies[$item['company_id']]['company_name'] : '--',
'game_name' => isset($games[$item['game_id']]) ? $games[$item['game_id']]['name'] : '--',
'game_type_name' => isset($gameTypes[$item['game_type_id']]) ? $gameTypes[$item['game_type_id']]['type_name'] : '--',
@ -470,6 +484,21 @@ class PaymentMerchantController extends ThinkController
'effective_time_display' => $paymentRuleService->getEffectiveTimeDisplay($item)
];
}
if($export == 1){
data2csv($records,'支付商户配置',array(
"company_type_name"=>"公司类型",
"company_name"=>"推广公司",
"game_type_name"=>"游戏类型",
"game_name"=>"游戏产品",
"alipay_merchant_name"=>"支付宝支付配置",
"alipay_merchant_account"=>"商户账号",
"weixin_merchant_name"=>"微信支付配置",
"weixin_merchant_account"=>"商户账号",
'express_merchant_name' => '快捷支付配置',
'express_merchant_account' =>'商户账号',
'effective_time_display'=>'生效时间'
));
}
$page = set_pagination($count, $row);
if($page) {

@ -91,6 +91,9 @@
border-right: solid 1px #b6cad2;
text-align: center;
}
.margintips{
color: #0FA6D8;
}
</style>
<body>
<!-- <div style="width: 100%;line-height: 100px;font-size: 25px;font-weight: 600;text-align: center;">
@ -106,7 +109,7 @@
<th rowspan="2">年份</th>
<th rowspan="2">月份</th>
<th rowspan="2">游戏名</th>
<th rowspan="2">流水</th>
<th rowspan="2" class="margintips" data-id="pay_amount">流水</th>
<th colspan="3">成本——上游CP</th>
<th colspan="2">上游返点</th>
@ -125,18 +128,18 @@
</if>
</tr>
<tr>
<th>渠道费率</th>
<th class="margintips" data-id="cp_promote_ratio">渠道费率</th>
<th>分成比例</th>
<th>结算金额</th>
<th>返点比例</th>
<th>返点金额</th>
<th>推广流水</th>
<th class="margintips" data-id="pc_pay_amount">推广流水</th>
<th>分成比例</th>
<th>结算金额</th>
<th>内团毛利额</th>
<th>内团毛利率</th>
<th>推广流水</th>
<th>分成比例</th>
<th class="margintips" data-id="pu_pay_amount">推广流水</th>
<th class="margintips" data-id="pu_ratio">分成比例</th>
<th>结算金额</th>
<th>外团毛利额</th>
<th>外团毛利率</th>
@ -301,6 +304,20 @@
});
});
</if>
var tipsmsg ={
"pay_amount":"上游结算流水,已剔除退款、奖罚数据",
"cp_promote_ratio":"上游结算时的渠道费",
"pc_pay_amount":"内团结算流水,已剔除退款、奖罚数据、不结算数据",
"pu_pay_amount":"外团结算流水,已剔除退款、奖罚数据、不结算数据",
"pu_ratio":"外团结算比例,周结按当月最后一次结算的比例计算"
}
$(".margintips").on('mouseover', function(){
var that = this;
var id = $(this).data("id");
layer.tips(tipsmsg[id], that,{tips: [1, '#0FA6D8']}); //在元素的事件回调体中follow直接赋予this即可
});
$(".margin_edit").on("click",function(){
var data = $(this).data();
layer.open({

@ -96,6 +96,12 @@
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="time_type" name="time_type" class="select_gallery" style="width:150px;">
<option value="1" <if condition="$_GET['time_type'] eq 1">selected</if>>历史所有</option>
<option value="2" <if condition="$_GET['time_type'] eq 2">selected</if>>当前生效</option>
</select>
</div>
<br>
<div class="input-list input-list-promote search_label_rehab">
<select name="alipay_merchant_id" id="alipay-merchant-select" class="select_gallery" style="width:200px;">
@ -185,10 +191,7 @@
</div>
</div>
<div class="page">
<if condition="$role_export_check eq true ">
<!-- <a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a> -->
</if>
<a class="sch-btn export-btn" href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
{$_page|default=''}
</div>

Loading…
Cancel
Save