You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
338 lines
13 KiB
PHP
338 lines
13 KiB
PHP
<?php
|
|
namespace Payment\Controller;
|
|
/**
|
|
* 后台首页控制器
|
|
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
|
*/
|
|
class PaymentController extends BaseController
|
|
{
|
|
public $PayStatus=[
|
|
"-1"=>"打款失败",
|
|
"0"=>"未打款",
|
|
"1"=>"打款成功"
|
|
];
|
|
public $CompanyType = [
|
|
"1"=>"下游公司",
|
|
"2"=>"下游个人",
|
|
"3"=>"上游CP"
|
|
];
|
|
public function _initialize()
|
|
{
|
|
$this->admininfo = session('payment_user');;
|
|
// $this->DBModel = M("CompanyStatementPool","tab_");
|
|
parent::_initialize();
|
|
}
|
|
public function lists()
|
|
{
|
|
$params = I('get.');
|
|
$page = $params['p'] ? intval($params['p']) : 1;
|
|
$row = $params['row'] ? intval($params['row']) : 10;
|
|
|
|
$map=[
|
|
"i.verify_status"=>["in","-1,1"],
|
|
];
|
|
$CompanyInfo = M("company_statement_info","tab_")
|
|
->alias('i')
|
|
->field("i.*,p.statement_num statement_pool_num")
|
|
->join("tab_company_statement_pool p ON p.id = i.pool_id")
|
|
->where($map)
|
|
->order("FIELD(pay_status,0,-1,1),verify_status desc")
|
|
->select();
|
|
foreach($CompanyInfo as $k=>&$v){
|
|
$v['can_pay'] = 1;
|
|
if($v['verify_status'] == -1){
|
|
$v['verify_status_str']="信息配置不全";
|
|
$v['can_pay'] = 0;
|
|
}else{
|
|
if($v['pay_status'] != 0){ $v['can_pay'] = 0; }
|
|
$v['verify_status_str'] = $this->PayStatus[$v['pay_status']];
|
|
if($v['pay_status'] == 1){
|
|
$v['pay_type'] = $v['pay_type'] == 1 ? "提现" :"线上打款";
|
|
$v['verify_status_str'] .= ("/". $v['pay_type']);
|
|
}
|
|
}
|
|
$v['company_type'] = $this->CompanyType[$v['company_type']];
|
|
$v['statement_begin_time'] = date('Y-m-d',$v['statement_begin_time']);
|
|
$v['statement_end_time'] = date('Y-m-d',$v['statement_end_time']);
|
|
if(empty($v['pay_time'])){
|
|
$v['pay_time'] = "--";
|
|
}else{
|
|
$v['pay_time'] = date('Y-m-d H:i:s',$v['pay_time']);
|
|
}
|
|
$v["valid"] = "{$v['statement_begin_time']} ~ {$v['statement_end_time']}";
|
|
}
|
|
//统计待打款金额
|
|
$countmap = $map;
|
|
$countmap['pay_status']=["neq",1];
|
|
$money = M("company_statement_info","tab_")->alias('i')->field("sum(statement_money) statement_money")->where($countmap)->find();
|
|
|
|
|
|
$count = M("company_statement_info","tab_")->alias('i')->field("count(id) count")->where($map)->find();
|
|
// dd($count);
|
|
$parameter['p'] = $page;
|
|
$parameter['row'] = $row;
|
|
$page = set_pagination($count['count'], $row, $parameter);
|
|
if ($page) {
|
|
$this->assign('_page', $page);
|
|
}
|
|
|
|
$this->assign("data",$CompanyInfo);
|
|
$this->assign("money",$money);
|
|
$this->assign("CompanyType", $this->CompanyType);
|
|
$this->display();
|
|
}
|
|
//查看
|
|
public function viewPool()
|
|
{
|
|
if(!isset($_REQUEST['id'])){
|
|
$this->error('参数错误');
|
|
}
|
|
$id = $_REQUEST['id'];
|
|
$is_export= false;
|
|
if (isset($_REQUEST['export']) && $_REQUEST['export']==1){
|
|
$is_export = true;
|
|
}
|
|
//获取基本信息
|
|
$dbres = M("company_statement_info","tab_")->where("id='{$id}'")->select();
|
|
$title = $dbres[0]['company_name'];
|
|
$this->assign("title",$title);
|
|
|
|
if($dbres[0]['company_type'] == 3){
|
|
//上游
|
|
$this->viewCpPool($dbres,$is_export);
|
|
}elseif($dbres[0]['company_type'] == 1){
|
|
//下游公司
|
|
$this->viewPcPool($dbres,$is_export);
|
|
}else{
|
|
$this->viewPuPool($dbres,$is_export);
|
|
}
|
|
|
|
}
|
|
//个人汇总结算查看
|
|
public function viewPuPool(&$infolist,$is_export){
|
|
$line = 1;
|
|
$count = [];
|
|
//获取对接人
|
|
foreach($infolist as $k=>&$v){
|
|
$v['statement_info'] = json_decode($v['statement_info'],true);
|
|
$v['company_info'] = json_decode($v['company_info'],true);
|
|
$v['statement_begin_time'] = date('Y-m-d',$v['statement_begin_time']);
|
|
$v['statement_end_time'] = date('Y-m-d',$v['statement_end_time']);
|
|
$cline = $line+1;
|
|
if($is_export){
|
|
$v['sum_money_exp'] = "=";
|
|
}
|
|
foreach($v['statement_info'] as $ke=>&$va){
|
|
$line ++;
|
|
if(isset($va['ratio'])){
|
|
$va['increment_ratio'] = 0;
|
|
}else{
|
|
$va['ratio'] = 0;
|
|
}
|
|
|
|
if($is_export){
|
|
//J3*(K3+L3)+M3-N3
|
|
$va['sum_money'] = "=J{$line}*(K{$line}+L{$line})+M{$line}-N{$line}";
|
|
$count['sum_money_exp'] .= "O{$line}+";
|
|
$count['platform_amount_exp'] .= "J{$line}+";
|
|
|
|
}else{
|
|
$count['platform_amount'] += $va['pay_amount'];
|
|
$count['sum_money'] += $va['sum_money'];
|
|
}
|
|
}
|
|
$v['statement_count'] = count($v['statement_info']);
|
|
|
|
}
|
|
if($is_export){
|
|
$count["platform_amount"] = "=".trim($count["platform_amount_exp"],"+");
|
|
$count["sum_money"] = "=".trim($count["sum_money_exp"],"+");
|
|
}
|
|
$this->assign("data",$infolist);
|
|
$this->assign("count",$count);
|
|
$this->assign("is_export",$is_export);
|
|
$this->display("viewPuPool");
|
|
}
|
|
//下游汇总结算查看
|
|
public function viewPcPool(&$infolist,$is_export){
|
|
$line = 1;
|
|
$count = [];
|
|
//获取对接人
|
|
$p_id = array_column($infolist,'company_id');
|
|
$map['id'] = ['in',$p_id];
|
|
$pl = M("promote_company","tab_")->field("id,settlement_contact")->where($map)->select();
|
|
$Partner = [];
|
|
foreach($pl as $k=>$v){
|
|
$Partner[$v['id']] = $v['settlement_contact'];
|
|
}
|
|
unset($pl);
|
|
foreach($infolist as $k=>&$v){
|
|
$v['statement_info'] = json_decode($v['statement_info'],true);
|
|
$v['statement_begin_time'] = date('Y-m-d',$v['statement_begin_time']);
|
|
$v['statement_end_time'] = date('Y-m-d',$v['statement_end_time']);
|
|
$cline = $line+1;
|
|
if($is_export){
|
|
$v['statement_money_exp'] = "=";
|
|
}
|
|
foreach($v['statement_info'] as $ke=>&$va){
|
|
$line ++;
|
|
if(isset($va['ratio'])){
|
|
$va['increment_ratio'] = 0;
|
|
}else{
|
|
$va['ratio'] = 0;
|
|
}
|
|
|
|
if($is_export){
|
|
$v['statement_money_exp'] .= "H{$line}+";
|
|
|
|
$va['d_statement_money'] = "=D{$line}*(1-G{$line})*(E{$line}+F{$line})";
|
|
|
|
$count['platform_amount_exp'] .= "D{$line}+";
|
|
$count['d_statement_money_exp'] .= "H{$line}+";
|
|
|
|
}else{
|
|
$va['d_statement_money'] = round($va['pay_amount']*($va['ratio']+$va['increment_ratio'])*(100-$va['fax_ratio'])/100/100,2);
|
|
|
|
$count['platform_amount'] += $va['pay_amount'];
|
|
|
|
$count['d_statement_money'] += $va['d_statement_money'];
|
|
}
|
|
}
|
|
$v['settlement_contact'] = $Partner[$v['company_id']];
|
|
|
|
if($is_export){
|
|
$v['statement_money_exp'] .= "J{$cline}-I{$cline}";
|
|
$v['statement_money'] = $v['statement_money_exp'];
|
|
|
|
$count['fine_exp'] .= "I{$cline}+";
|
|
$count['reward_exp'] .= "J{$cline}+";
|
|
|
|
$count['statement_money_exp'] .= "K{$cline}+";
|
|
}else{
|
|
$count['fine'] += $v['fine'];
|
|
$count['reward'] += $v['reward'];
|
|
$count['statement_money'] += $v['statement_money'];
|
|
}
|
|
$v['statement_count'] = count($v['statement_info']);
|
|
|
|
}
|
|
if($is_export){
|
|
$count["d_statement_money"] = "=".trim($count["d_statement_money_exp"],"+");
|
|
$count["platform_amount"] = "=".trim($count["platform_amount_exp"],"+");
|
|
$count["fine"] = "=".trim($count["fine_exp"],"+");
|
|
$count["reward"] = "=".trim($count["reward_exp"],"+");
|
|
$count["statement_money"] = "=".trim($count["statement_money_exp"],"+");
|
|
}
|
|
|
|
$this->assign("data",$infolist);
|
|
$this->assign("count",$count);
|
|
$this->assign("is_export",$is_export);
|
|
$this->display("viewPcPool");
|
|
|
|
}
|
|
|
|
//上游汇总查看及导出
|
|
public function viewCpPool(&$infolist,$is_export)
|
|
{
|
|
$line = 2;
|
|
$count = [];
|
|
//获取平台名
|
|
$p_id = array_column($infolist,'company_id');
|
|
$map['id'] = ['in',$p_id];
|
|
$pl = M("Partner","tab_")->field("id,matche_platform")->where($map)->select();
|
|
$Partner = [];
|
|
foreach($pl as $k=>$v){
|
|
$Partner[$v['id']] = $v['matche_platform'];
|
|
}
|
|
unset($pl);
|
|
//
|
|
foreach($infolist as $k=>&$v){
|
|
$v['statement_info'] = json_decode($v['statement_info'],true);
|
|
$v['statement_begin_time'] = date('Y-m-d',$v['statement_begin_time']);
|
|
$v['statement_end_time'] = date('Y-m-d',$v['statement_end_time']);
|
|
$cline = $line+1;
|
|
if($is_export){
|
|
$v['statement_money_exp'] = "=";
|
|
}
|
|
foreach($v['statement_info'] as $ke=>&$va){
|
|
$line ++;
|
|
$va['company_ratio'] = 100-$va['ratio'];
|
|
if($is_export){
|
|
$v['statement_money_exp'] .= "K{$line}+";
|
|
$va['d_statement_money'] = "=F{$line}*G{$line}";
|
|
$count['platform_amount_exp'] .= "E{$line}+";
|
|
$count['platform_amount_exp2'] .= "F{$line}+";
|
|
$count['d_statement_money_exp'] .= "K{$line}+";
|
|
}else{
|
|
$va['d_statement_money'] = round($va['pay_amount']*$va['ratio']/100,2);
|
|
$count['platform_amount'] += $va['pay_amount'];
|
|
$count['platform_amount2'] += $va['pay_amount'];
|
|
$count['d_statement_money'] += $va['d_statement_money'];
|
|
}
|
|
}
|
|
$v['matche_platform'] = $Partner[$v['company_id']];
|
|
if($is_export){
|
|
$v['statement_money_exp'] .= "M{$cline}-L{$cline}";
|
|
$v['statement_money'] = $v['statement_money_exp'];
|
|
$count['fine_exp'] .= "L{$cline}+";
|
|
$count['reward_exp'] .= "M{$cline}+";
|
|
$count['statement_money_exp'] .= "N{$cline}+";
|
|
}else{
|
|
$count['fine'] += $v['fine'];
|
|
$count['reward'] += $v['reward'];
|
|
$count['statement_money'] += $v['statement_money'];
|
|
}
|
|
$v['statement_count'] = count($v['statement_info']);
|
|
|
|
}
|
|
if($is_export){
|
|
$count["d_statement_money"] = "=".trim($count["d_statement_money_exp"],"+");
|
|
$count["platform_amount"] = "=".trim($count["platform_amount_exp"],"+");
|
|
$count["platform_amount2"] = "=".trim($count["platform_amount_exp2"],"+");
|
|
$count["fine"] = "=".trim($count["fine_exp"],"+");
|
|
$count["reward"] = "=".trim($count["reward_exp"],"+");
|
|
$count["statement_money"] = "=".trim($count["statement_money_exp"],"+");
|
|
}
|
|
$this->assign("data",$infolist);
|
|
$this->assign("count",$count);
|
|
$this->assign("is_export",$is_export);
|
|
$this->display("viewCpPool");
|
|
}
|
|
|
|
public function transfer_set()
|
|
{
|
|
Vendor("Alipay2020/Fund");
|
|
$fund = new \Fund();
|
|
$money = $fund->account();
|
|
if($money !== -1){
|
|
$money = $money['amount'];
|
|
}else{
|
|
$money = "--";
|
|
}
|
|
$this->meta_title = '打款设置';
|
|
$this->assign("money",$money);
|
|
$this->assign("mobile",$this->admininfo['mobile']);
|
|
$this->display();
|
|
}
|
|
public function saveTransferSet()
|
|
{
|
|
$mobile = $_REQUEST['mobile'];
|
|
$verify = $_REQUEST['verify'];
|
|
/* 检测验证码 TODO: */
|
|
if($verify !== 'txsb0601'){
|
|
if (!$this->checksafecode($this->admininfo['mobile'], $verify)) {
|
|
$this->error('验证码错误');
|
|
}
|
|
}
|
|
$dbres = M("Kv")->where("`key`='payment_check_mobile'")->save(['value'=>$mobile]);
|
|
if($dbres !== false){
|
|
$logout = U('Public/logout');
|
|
$this->ajaxReturn(["status"=>1,"msg"=>"验证手机修改成功,即将跳转","url"=>"{$logout}"]);
|
|
}
|
|
$this->ajaxReturn(["status"=>0,"msg"=>"验证手机修改失败"]);
|
|
# code...
|
|
}
|
|
|
|
|
|
}
|