Merge pull request '未结算数据的补充' (#23) from feature/add_item into release

未结算数据的补充
master
郑永星 4 years ago
commit 6699ce1045

@ -10,6 +10,295 @@ namespace Admin\Controller;
class OldCountController extends \Think\Controller
{
public function setLackStatementInfo() {
$arrkey = [
'A'=>'num',
'B'=>'company_name',
'C'=>'account',
'D'=>'company_belong_str',
'E'=>'company_relation_str',
'F'=>'nickname',
'G'=>'company_type',
'H'=>'game_name',
'I'=>'game_type_name',
'J'=>'time',
'K'=>'platform_amount',
'L'=>'refund',
'M'=>'ratio',
'N'=>'increment_ratio',
'O'=>'sum_money',
'P'=>'reward',
'Q'=>'fine',
'R'=>'withhold',
'S'=>'week_amount',
'T'=>'sum_money_s',
'U'=>'payee_name',
'V'=>'bank_account',
'W'=>'opening_bank',
'X'=>'is_payment',
'Y'=>'is_pay',
'Z'=>'remark'
];
header("Content-type: text/html; charset=utf-8");
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Asia/Shanghai');
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
//设置模板文件
$objPHPExcel = $objReader->load("Public/Admin/excel/set_info.xls");
$objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel);
$currentSheet = $objPHPExcel->getSheet(0); //读取excel文件中的第一个工作表
$allColumn = 90; //取得最大的列号
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
$excelResult = []; //声明数组
// dump($allColumn);die();
$startRow = 3;
for ($j = $startRow; $j <= $allRow; $j++) {
//从A列读取数据
for ($k = 65; $k <= $allColumn; $k++) {
// 读取单元格
$excelResult[$j][$arrkey[chr($k)]] = (string)$objPHPExcel->getActiveSheet()->getCell(chr($k)."$j")->getValue();
}
}
$handle_data = [];
$pool_data = [];
// dump($excelResult);
foreach ($excelResult as $key => $value) {
$is_continue = 0;
$company_info = M("promote_company","tab_")->field("id company_id,company_type,bank_card,bank_cardname,bank_name,bank_address,ali_user,ali_account")->where(['company_name'=>$value['company_name']])->find();
if(!$company_info) {
continue;
}
$lack_data = M("company_lack_statement_info","tab_")
->where([
'company_id'=>$company_info['company_id']
])
->select();
$time = explode('-',$value['time']);
$game_data = M("game","tab_")->where(['relation_game_name'=>$value['game_name']])->find();
foreach ($lack_data as $lkey => $lvalue) {
$statement_info = json_decode($lvalue['statement_info'],true);
// dump($statement_info);
foreach ($statement_info as $skey => $svalue) {
$game_list = $svalue['game_list'];
foreach ($game_list as $gkey => $gvalue) {
// if($company_info['company_id'] == 73&&$gvalue['pay_amount']=='12.00' ) {
// dump($svalue);
// dump($gvalue['statement_begin_time'] == $time['0']);
// dump($gvalue['statement_end_time'] == $time['1']);
// dump($gvalue['relation_game_id'] == $game_data['relation_game_id']);
// dump($gvalue['pay_amount'] == number_format($value['platform_amount'],2,'.',''));
// }
//存在的游戏流水内部条件,如果存在不进行下列操作
if ($gvalue['statement_begin_time'] == $time['0']
&&$gvalue['statement_end_time'] == $time['1']
&&$gvalue['relation_game_id'] == $game_data['relation_game_id']
&&$gvalue['pay_amount'] == number_format($value['platform_amount'],2,'.','')) {
$is_continue = 1;
}
}
}
}
//已经存在的单子结算
if ($is_continue) {
continue;
}
$handle_data[$value['time'].$company_info['company_id']]['company_id'] = $company_info['company_id'];
$handle_data[$value['time'].$company_info['company_id']]['company_type'] = $company_info['company_type'];
$handle_data[$value['time'].$company_info['company_id']]['company_name'] = $value['company_name'];
$companyInfo = [
'account'=>$value['account'],
'company_relation_str'=>$value['company_relation_str'],
'company_belong_str'=>$value['company_belong_str'],
'company_type_str'=>$value['company_type'],
'nickname'=>'nickname',
];
$relation = M("company_relation","tab_")
->where("(first_company_id = {$company_info['company_id']} and first_company_type!=3) or (second_company_id = {$company_info['company_id']} and second_company_type!=3)")
->find();
if ($relation['is_payment'] == 1) {
$companyInfo['ali_user'] = $company_info['ali_user'];
$companyInfo['ali_account'] = $company_info['ali_account'];
} else {
$companyInfo['payee_name'] = $company_info['bank_address'];
$companyInfo['bank_account'] = $company_info['bank_card'];
$companyInfo['opening_bank'] = $company_info['bank_name'];
}
$handle_data[$value['time'].$company_info['company_id']]['statement_money'] += $value['sum_money']-$value['fine']+$value['reward']-$value['withhold'];
$handle_data[$value['time'].$company_info['company_id']]['pay_amount'] += $value['sum_money']-$value['fine']+$value['reward']-$value['withhold'];
$handle_data[$value['time'].$company_info['company_id']]['company_info'] = json_encode($companyInfo);
$handle_data[$value['time'].$company_info['company_id']]['platform_amount'] += $value['platform_amount'];
$handle_data[$value['time'].$company_info['company_id']]['fine'] += $value['fine'];
$handle_data[$value['time'].$company_info['company_id']]['reward'] += $value['reward'];
$handle_data[$value['time'].$company_info['company_id']]['statement_begin_time'] = strtotime(str_replace('.','-',$time['0']));
$handle_data[$value['time'].$company_info['company_id']]['statement_end_time'] = strtotime(str_replace('.','-',$time['1']))+86399;
$p_id = M("promote","tab_")->field("id")->where(['account'=>$value['account']])->find();
if ($handle_data[$value['time'].$company_info['company_id']]['statement_info']) {
$handle_data[$value['time'].$company_info['company_id']]['statement_info'][0]['game_list'][] =
[
'pay_amount'=>$value['platform_amount'],
'relation_game_id'=>$game_data['relation_game_id'],
'game_name'=>$game_data['relation_game_name'],
'p_id'=>$p_id['id'],
'all_pay_amount'=>$value['platform_amount'],
'game_type_name'=>$game_data['game_type_name'],
'ratio'=>$value['ratio']*100,
'sum_money'=>number_format($value['sum_money'],2,'.',''),
'fax_ratio'=>0,
'statement_begin_time'=>$time['0'],
'statement_end_time'=>$time['1'],
'fine'=>$value['fine'],
'reward'=>$value['reward'],
'statement_type'=>0,
'refund'=>$value['refund'],
'withhold'=>$value['withhold'],
'increment_ratio'=>$value['increment_ratio']*100
];
} else {
$handle_data[$value['time'].$company_info['company_id']]['statement_info'][] = [
"account"=>$value['account'],
"game_list"=>[
[
'pay_amount'=>$value['platform_amount'],
'relation_game_id'=>$game_data['relation_game_id'],
'game_name'=>$game_data['relation_game_name'],
'p_id'=>$p_id['id'],
'all_pay_amount'=>$value['platform_amount'],
'game_type_name'=>$game_data['game_type_name'],
'ratio'=>$value['ratio']*100,
'sum_money'=>number_format($value['sum_money'],2,'.',''),
'fax_ratio'=>0,
'statement_begin_time'=>$time['0'],
'statement_end_time'=>$time['1'],
'fine'=>$value['fine'],
'reward'=>$value['reward'],
'statement_type'=>0,
'refund'=>$value['refund'],
'withhold'=>$value['withhold'],
'increment_ratio'=>$value['increment_ratio']*100
]
]
];
}
// $handle_data[$value['time'].$company_info['company_id']]['statement_info'] = $statement_info;
// del_lack_ids
$company_statement_pool = M("company_statement_pool","tab_")
->field("statement_num,del_lack_ids")
->where([
'statement_begin_time'=>$handle_data[$value['time'].$company_info['company_id']]['statement_begin_time'],
'statement_end_time'=>$handle_data[$value['time'].$company_info['company_id']]['statement_end_time'],
'company_type'=>2,
'withdraw_type'=>['neq',3]
])
->find();
$handle_data[$value['time'].$company_info['company_id']]['statement_pool_num'] = $company_statement_pool['statement_num']?$company_statement_pool['statement_num']:"";
$handle_data[$value['time'].$company_info['company_id']]['is_payment'] = $relation['is_payment'];
$handle_data[$value['time'].$company_info['company_id']]['remark'] = $company_statement_pool['remark'];
}
$handle_data = array_values($handle_data);
// dump($handle_data);
foreach ($handle_data as $key => $value) {
$value['statement_info'] = json_encode($value['statement_info']);
$lack_id = M("company_lack_statement_info","tab_")->add($value);
$pool_data[$value['statement_pool_num']]['del_lack_ids'][] = $lack_id;
}
$lack_data324 = M("company_lack_statement_info","tab_")
->where([
'id'=>324
])
->find();
$lack_data324['fine'] = 5000;
$lack_data324['statement_money'] = $lack_data324['statement_money']-5000;
$lack_data324['pay_amount'] = $lack_data324['pay_amount']-5000;
$statement_info324 = json_decode($lack_data324['statement_info'],true);
$statement_info324[0]['game_list'][0]['fine'] = 5000;
$lack_data324['statement_info'] = json_encode($statement_info324);
M("company_lack_statement_info","tab_")
->where([
'id'=>324
])->save($lack_data324);
$lack_data334 = M("company_lack_statement_info","tab_")
->where([
'id'=>334
])
->find();
$lack_data334['fine'] = 2000;
$lack_data334['statement_money'] = $lack_data334['statement_money']-2000;
$lack_data334['pay_amount'] = $lack_data334['pay_amount']-2000;
$statement_info334 = json_decode($lack_data334['statement_info'],true);
$statement_info334[0]['game_list'][0]['fine'] = 2000;
$lack_data334['statement_info'] = json_encode($statement_info334);
M("company_lack_statement_info","tab_")
->where([
'id'=>334
])->save($lack_data334);
echo "success";
// foreach ($pool_data as $key => $value) {
//
// $pool_info = M("company_statement_pool","tab_")
// ->where(['statement_num'=>$key])
// ->find();
//
// $del_lack_ids = $pool_info['del_lack_ids'].','.implode(',',$value['del_lack_ids']);
// M("company_statement_pool","tab_")
// ->where(['statement_num'=>$key])
// ->save(['del_lack_ids'=>$del_lack_ids]);
//
// }
// M("company_lack_statement_info","tab_")->addAll($handle_data);
// dump($handle_data);
}
public function updateStatementInfo() {
$data = M("company_statement_info","tab_")

@ -507,7 +507,7 @@ class ExcelPaymentController extends BaseController
])
->select();
$check_company_statement_info = M("company_statement_info","tab_")
$check_company_statement_info = M("pay_statement_info","tab_")
->where([
'pay_status'=>1,
'company_name'=>$value['company_name'],

@ -277,7 +277,7 @@ class PaymentController extends BaseController
//周结算金额计算
for ($i=0;;$i++) {
if ($sv[$i]['sum_money']) {
$game_data['week_amount'] += $sv[$i]['sum_money'];
$game_data['week_amount'] += $sv[$i]['sum_money']- $sv[$i]['withhold']+$sv[$i]['reward']-$sv[$i]['fine'];
$game_data['withhold_amount'] += $sv[$i]['withhold'];
$game_data['fine'] += $sv[$i]['fine'];
$game_data['reward'] += $sv[$i]['reward'];
@ -440,10 +440,11 @@ class PaymentController extends BaseController
$v['statement_money'] .= "S{$line}+";
}else{
$count['platform_amount'] += $val['pay_amount'];
$count['week_money'] += $val['sum_money'];
$count['sum_money'] += $val['sum_money'];
}
}
$count['week_money'] += $va['week_amount'];
$count['sum_money'] += $va['week_amount'];
}
@ -1133,9 +1134,9 @@ class PaymentController extends BaseController
$ids = $_REQUEST['ids'];
$data = M("company_statement_info","tab_")
$data = M("pay_statement_info","tab_")
->field("id,statement_money,company_name,statement_begin_time,statement_end_time,pay_time")
->where(['id'=>['in',implode(',',$ids)]])
->where(['statement_info_id'=>['in',implode(',',$ids)]])
->select();
// dump($data);die();
$return = [];
@ -1153,7 +1154,7 @@ class PaymentController extends BaseController
])
->select();
$check_company_statement_info = M("company_statement_info","tab_")
$check_company_statement_info = M("pay_statement_info","tab_")
->where([
'pay_status'=>1,
'company_name'=>$value['company_name'],

@ -106,10 +106,12 @@
<th>产品类型</th>
<th>结算时间</th>
<th>推广流水</th>
<th>退款</th>
<th>分成比例</th>
<th>补点</th>
<th>奖励</th>
<th>罚款</th>
<th>其他扣款</th>
<th>结算金额</th>
<!-- <th>开户名</th>-->
<!-- <th>银行卡号</th>-->
@ -193,14 +195,15 @@
<!-- <td>{$com['statement_info'][0]['game_list'][0]['statement_begin_time']} ~ {$com['statement_info'][0]['game_list'][0]['statement_end_time']}</td>-->
<td><span class="pay_amount">{$com['statement_info'][0]['game_list'][0]['pay_amount']}</span></td>
<td>{$com['statement_info'][0]['game_list'][0]['refund']|default=0}</td>
<td>{$com['statement_info'][0]['game_list'][0]['ratio']}%</td>
<td>{$com['statement_info'][0]['game_list'][0]['increment_ratio']}%</td>
<td rowspan="{$com['statement_info'][0]['time_row']}">{$com['statement_info'][0]['reward']||default="0"}</td>
<td rowspan="{$com['statement_info'][0]['time_row']}">{$com['statement_info'][0]['fine']||default="0"}</td>
<td><span class="sum_money_span">{$com['statement_info'][0]['game_list'][0]['sum_money']}</span></td>
<td rowspan="{$com['statement_info'][0]['time_row']}">{$com['statement_info'][0]['game_list'][0]['withhold']|default=0}</td>
<td rowspan="{$com['statement_info'][0]['time_row']}">{$com['statement_info'][0]['week_amount']||default="0"}</td>
<else />
<td>-</td>
@ -241,9 +244,10 @@
<td>{$game['game_type_name']}</td>
<td><span class="pay_amount">{$game['pay_amount']}</span></td>
<td>{$game['refund']|default=0}</td>
<td>{$game['ratio']}%</td>
<td>{$game['increment_ratio']}%</td>
<td><span class="sum_money_span">{$game['sum_money']}</span></td>
<!-- <td><span class="sum_money_span">{$game['sum_money']}</span></td>-->
</tr>
@ -269,14 +273,16 @@
</notempty>
<td><span class="pay_amount">{$account['game_list'][0]['pay_amount']}</span></td>
<td>{$account['game_list'][0]['refund']|default=0}</td>
<td>{$account['game_list'][0]['ratio']}%</td>
<td>{$account['game_list'][0]['increment_ratio']}%</td>
<notempty name="account['time']">
<td rowspan="{$account['time_row']}">{$account['reward']|default=0}</td>
<td rowspan="{$account['time_row']}">{$account['fine']|default=0}</td>
<td rowspan="{$account['time_row']}">{$account['withhold_amount']|default=0}</td>
<td rowspan="{$account['time_row']}">{$account['week_amount']}</td>
</notempty>
<td><span class="sum_money_span">{$account['game_list'][0]['sum_money']}</span></td>
@ -304,7 +310,7 @@
<td>{$game['game_type_name']}</td>
<td><span class="pay_amount">{$game['pay_amount']}</span></td>
<td>{$game['refund']|default=0}</td>
<td>{$game['ratio']}%</td>
<td>{$game['increment_ratio']}%</td>
<td><span class="sum_money_span">{$game['sum_money']}</span></td>
@ -326,6 +332,8 @@
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>{$count.sum_money}</td>
<td></td>

Loading…
Cancel
Save