|
|
|
@ -93,6 +93,17 @@ class PaymentController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dump($map);die();
|
|
|
|
|
$sum = M("pay_statement_info","tab_")
|
|
|
|
|
->alias('c')
|
|
|
|
|
->field("sum(if(c.pay_status=0,c.statement_money,0)) unpay_amount,sum(if(c.pay_status>0,c.statement_money,0)) pay_amount,sum(if(c.pay_status<0,c.statement_money,0)) faild_pay_amount")
|
|
|
|
|
->join("left join tab_company_statement_info s on c.statement_info_id = s.id")
|
|
|
|
|
->where($map)
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
$this->assign('sum',$sum);
|
|
|
|
|
// dump($sum);die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$CompanyInfo = M("company_statement_info","tab_")
|
|
|
|
|
->alias('s')
|
|
|
|
|
->field("s.*,p.statement_num statement_pool_num")
|
|
|
|
@ -118,17 +129,29 @@ class PaymentController extends BaseController
|
|
|
|
|
$v['verify_status_str'] .= ("/". $v['pay_type']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$companypay_info = json_decode($v['company_info'],true);
|
|
|
|
|
if (empty($companypay_info['ali_user']) || empty($companypay_info['ali_account'])) {
|
|
|
|
|
$v['verify_status'] = -1;
|
|
|
|
|
$v['verify_status_str']="信息配置不全";
|
|
|
|
|
$v['can_pay'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($v['pay_verify_status'] == 0){
|
|
|
|
|
$v['verify'] = "--";
|
|
|
|
|
if($v['pay_check'] == 0){
|
|
|
|
|
$v['pay_check_detail'] = "--";
|
|
|
|
|
}else {
|
|
|
|
|
$member = M("payment_member")
|
|
|
|
|
->field("name")
|
|
|
|
|
->where(['id'=>$v['verify_member_id']])
|
|
|
|
|
->where(['id'=>$v['pay_check_member_id']])
|
|
|
|
|
->find();
|
|
|
|
|
$v['verify'] = (($v['pay_verify_status'] == 1)?'审核通过':'审核拒绝')."({$member['name']})<br>".date('Y-m-d H:i:s', $v['verify_time']);;
|
|
|
|
|
$v['pay_check_detail'] = $member['name'].(($v['pay_check'] == 1)?'已确认':'未确认')."<br>".date('Y-m-d H:i:s', $v['pay_check_time']);;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if ($v['pay_check'] == 0) {
|
|
|
|
|
// $v['pay_check_str'] = "未确认";
|
|
|
|
|
// } else {
|
|
|
|
|
// $v['pay_check_str'] = "已确认";
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
$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']);
|
|
|
|
@ -194,7 +217,6 @@ class PaymentController extends BaseController
|
|
|
|
|
$countmap['pay_status']=["neq",1];
|
|
|
|
|
$money = M("company_statement_info","tab_")->alias('s')->field("sum(statement_money) statement_money")->where($countmap)->find();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$count = M("company_statement_info","tab_")->alias('s')->field("count(id) count")->where($map)->find();
|
|
|
|
|
$page = set_pagination($count['count'], $row);
|
|
|
|
|
if ($page) {
|
|
|
|
@ -207,6 +229,75 @@ class PaymentController extends BaseController
|
|
|
|
|
$this->assign("PayStatus", $this->PayStatus);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//导出
|
|
|
|
|
public function export() {
|
|
|
|
|
|
|
|
|
|
if(!isset($_REQUEST['id'])){
|
|
|
|
|
$this->error('参数错误');
|
|
|
|
|
}
|
|
|
|
|
$id = $_REQUEST['id'];
|
|
|
|
|
$data = M("company_statement_info","tab_")
|
|
|
|
|
->alias('s')
|
|
|
|
|
->field("s.*,p.statement_num statement_pool_num")
|
|
|
|
|
->join("left join tab_company_statement_pool p ON p.id = s.pool_id")
|
|
|
|
|
->where(['s.id'=>['in',$id]])
|
|
|
|
|
->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
$company_info = json_decode($value['company_info'],true);
|
|
|
|
|
$data[$key]['ali_user'] = $company_info['ali_user'];
|
|
|
|
|
$data[$key]['ali_account'] = $company_info['ali_account'];
|
|
|
|
|
$data[$key]['statement_time'] = date("Y-m-d H:i:s",$value['statement_begin_time']).'-'.date("Y-m-d H:i:s",$value['statement_end_time']);
|
|
|
|
|
|
|
|
|
|
if($value['pay_check'] == 0){
|
|
|
|
|
$v['pay_check_detail'] = "--";
|
|
|
|
|
}else {
|
|
|
|
|
$member = M("payment_member")
|
|
|
|
|
->field("name")
|
|
|
|
|
->where(['id'=>$value['pay_check_member_id']])
|
|
|
|
|
->find();
|
|
|
|
|
$data[$key]['pay_check_detail'] = $member['name'].(($value['pay_check'] == 1)?'已确认':'未确认').date('Y-m-d H:i:s', $value['pay_check_time']);;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data[$key]['pay_status_str'] = $value['pay_status']==1?"已打款":($value['pay_status']==-1?'打款失败':'未打款');
|
|
|
|
|
$data[$key]['pay_time'] = $value['pay_time']?date("Y-m-d H:i:s",$value['pay_time']):'未支付';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$title = [
|
|
|
|
|
'company_name' => '公司名称',
|
|
|
|
|
'statement_time' => '结算时间',
|
|
|
|
|
'statement_money' => '结算金额',
|
|
|
|
|
'ali_user' => '支付宝真实姓名',
|
|
|
|
|
'ali_account'=>'支付宝账号',
|
|
|
|
|
'remark'=>'备注',
|
|
|
|
|
'statement_pool_num'=>'汇总单号',
|
|
|
|
|
'pay_check_detail'=>'打款信息确认',
|
|
|
|
|
'pay_status_str'=>'打款状态',
|
|
|
|
|
'pay_time'=>'打款时间',];
|
|
|
|
|
|
|
|
|
|
$sum = M("pay_statement_info","tab_")
|
|
|
|
|
->alias('s')
|
|
|
|
|
->field("sum(if(s.pay_status=0,s.statement_money,0)) unpay_amount,sum(if(s.pay_status>0,s.statement_money,0)) pay_amount,sum(if(s.pay_status<0,s.statement_money,0)) faild_pay_amount")
|
|
|
|
|
->join("left join tab_company_statement_info c on s.statement_info_id = c.id")
|
|
|
|
|
->where(['statement_info_id'=>['in',$id]])
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
$money = M("company_statement_info","tab_")->alias('s')->field("sum(statement_money) statement_money")->where(['s.id'=>['in',$id]])->find();
|
|
|
|
|
|
|
|
|
|
$sumData = [
|
|
|
|
|
'company_name'=>'合计',
|
|
|
|
|
'statement_time' => "待打款金额: {$money['statement_money']} 打款成功: {$sum['pay_amount']} 打款失败: {$sum['faild_pay_amount']}",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$data = array_merge($data,[$sumData]);
|
|
|
|
|
// dump($data);die();
|
|
|
|
|
data2csv($data,'线上打款',$title);
|
|
|
|
|
// $this->ajaxReturn(['stauts'=>1,'msg'=>'导出成功']);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查看
|
|
|
|
|
public function viewPool()
|
|
|
|
|
{
|
|
|
|
@ -329,52 +420,55 @@ class PaymentController extends BaseController
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($handle_data as $hk => $hv) {
|
|
|
|
|
$substract = 1;
|
|
|
|
|
if ($is_export) {
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
|
|
|
|
|
|
if (!$handle_data[$hk+$substract]['time']&&$handle_data[$hk+$substract]['account']) {
|
|
|
|
|
// if (
|
|
|
|
|
// $hv['account'] == 'zj9587' ||
|
|
|
|
|
// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') {
|
|
|
|
|
// dump($handle_data[$hk]['time']);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
$week_line++;
|
|
|
|
|
$substract++;
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count($hv['game_list'])>1) {
|
|
|
|
|
$week_line += count($hv['game_list'])-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$handle_data[$hk]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line})+SUM(P{$old_line}:P{$week_line})-SUM(Q{$old_line}:Q{$week_line})-SUM(R{$old_line}:R{$week_line}),2)";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (count($hv['game_list'])>1) {
|
|
|
|
|
|
|
|
|
|
$old_line += count($hv['game_list']);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$old_line++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(count($hv['game_list'])>1) {
|
|
|
|
|
|
|
|
|
|
$week_line = $old_line ;
|
|
|
|
|
} else {
|
|
|
|
|
$week_line = $old_line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// foreach($handle_data as $hk => $hv) {
|
|
|
|
|
// $substract = 1;
|
|
|
|
|
// if ($is_export) {
|
|
|
|
|
//
|
|
|
|
|
// for (;;) {
|
|
|
|
|
//
|
|
|
|
|
// if (!$handle_data[$hk+$substract]['time']&&$handle_data[$hk+$substract]['account']) {
|
|
|
|
|
//// if (
|
|
|
|
|
//// $hv['account'] == 'zj9587' ||
|
|
|
|
|
//// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') {
|
|
|
|
|
//// dump($handle_data[$hk]['time']);
|
|
|
|
|
//// }
|
|
|
|
|
//
|
|
|
|
|
// $week_line++;
|
|
|
|
|
// $substract++;
|
|
|
|
|
// } else {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (count($hv['game_list'])>1) {
|
|
|
|
|
// $week_line += count($hv['game_list'])-1;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $handle_data[$hk]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line})+SUM(P{$old_line}:P{$week_line})-SUM(Q{$old_line}:Q{$week_line})-SUM(R{$old_line}:R{$week_line}),2)";
|
|
|
|
|
//
|
|
|
|
|
// if ($hk > 0) {
|
|
|
|
|
// $handle_data[0]['week_amount'] = str_replace($old_line,$week_line,$handle_data[0]['week_amount']);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (count($hv['game_list'])>1) {
|
|
|
|
|
//
|
|
|
|
|
// $old_line += count($hv['game_list']);
|
|
|
|
|
//
|
|
|
|
|
// } else {
|
|
|
|
|
// $old_line++;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if(count($hv['game_list'])>1) {
|
|
|
|
|
//
|
|
|
|
|
// $week_line = $old_line ;
|
|
|
|
|
// } else {
|
|
|
|
|
// $week_line = $old_line;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return $handle_data?$handle_data:[];
|
|
|
|
|
}
|
|
|
|
@ -619,6 +713,168 @@ class PaymentController extends BaseController
|
|
|
|
|
$this->display("viewCpPool");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//打款设置
|
|
|
|
|
public function setPayment(){
|
|
|
|
|
if(!isset($_REQUEST['id'])) $this->error("参数错误");
|
|
|
|
|
$id = $_REQUEST['id'];
|
|
|
|
|
$CompanyInfo = M("company_statement_info","tab_")
|
|
|
|
|
->alias('i')
|
|
|
|
|
->field("i.id,i.pool_id,i.company_name,i.company_info,i.statement_money,i.remark,i.pay_status,i.verify_status,p.statement_num,i.statement_money")
|
|
|
|
|
->join("tab_company_statement_pool p ON p.id = i.pool_id")
|
|
|
|
|
->where("i.id in({$id})")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$all_money = 0;
|
|
|
|
|
foreach($CompanyInfo as $k=>&$v){
|
|
|
|
|
if($v['verify_status'] == 2){
|
|
|
|
|
$v['is_payment'] = 2;
|
|
|
|
|
}else{
|
|
|
|
|
$v['is_payment'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$v['company_info'] = json_decode($v['company_info'],true);
|
|
|
|
|
$v['company_info']['ali_user'] ?? '';
|
|
|
|
|
$v['company_info']['ali_account'] ?? '';
|
|
|
|
|
|
|
|
|
|
$all_money += $v['statement_money'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assign('all_money',$all_money);
|
|
|
|
|
$this->assign("CompanyInfo",$CompanyInfo);
|
|
|
|
|
$this->assign("id",$id);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function returnSetPayment() {
|
|
|
|
|
|
|
|
|
|
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
|
|
|
|
|
$ids = $_REQUEST['ids'];
|
|
|
|
|
|
|
|
|
|
$ids = explode(',',$ids);
|
|
|
|
|
|
|
|
|
|
$CompanyInfo = M("company_statement_info","tab_");
|
|
|
|
|
|
|
|
|
|
$CompanyInfo
|
|
|
|
|
->where(['id'=>['in',$ids]])
|
|
|
|
|
->save([
|
|
|
|
|
'pay_check'=>0,
|
|
|
|
|
'pay_check_member_id'=>0,
|
|
|
|
|
'pay_check_time'=>0
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn(array(
|
|
|
|
|
'status' => 1,
|
|
|
|
|
"info"=>"打款信息编辑成功"
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改打款设置
|
|
|
|
|
public function editPayment(){
|
|
|
|
|
if(!isset($_REQUEST['info'])) $this->error("参数错误");
|
|
|
|
|
$info = $_REQUEST['info'];
|
|
|
|
|
$id = [];
|
|
|
|
|
|
|
|
|
|
$CompanyInfo = M("company_statement_info","tab_");
|
|
|
|
|
//循环保存
|
|
|
|
|
foreach($info as $k=>$v){
|
|
|
|
|
array_push($id,$k);
|
|
|
|
|
$ydata = $CompanyInfo->where("id= '{$k}'")->find();
|
|
|
|
|
$company_info = json_decode($ydata['company_info'],true);
|
|
|
|
|
if($ydata['verify_status'] == 2){
|
|
|
|
|
$company_info['payee_name'] = $v['payee_name'];
|
|
|
|
|
$company_info['bank_account'] = $v['bank_account'];
|
|
|
|
|
$company_info['opening_bank'] = $v['opening_bank'];
|
|
|
|
|
}else{
|
|
|
|
|
$company_info['ali_user'] = $v['ali_user'];
|
|
|
|
|
$company_info['ali_account'] = $v['ali_account'];
|
|
|
|
|
}
|
|
|
|
|
$savedata = [
|
|
|
|
|
"company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE),
|
|
|
|
|
"remark"=>$v['remark'],
|
|
|
|
|
"pay_check"=>1,
|
|
|
|
|
"pay_check_member_id"=>$member_id = $_SESSION['onethink_admin']['payment_user']['id'],
|
|
|
|
|
"id"=>$k,
|
|
|
|
|
"pay_check_time"=>time()
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
M("pay_statement_info","tab_")->where(['statement_info_id'=>$k])->save(["company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE)]);
|
|
|
|
|
$CompanyInfo->save($savedata);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$companyStatementInfo = M("company_statement_info","tab_")
|
|
|
|
|
->where([
|
|
|
|
|
'id'=>['in',$id]
|
|
|
|
|
])
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
foreach ($companyStatementInfo as $key => $value) {
|
|
|
|
|
if ($value['statement_money'] <= 0) {
|
|
|
|
|
$payres["remark"] = '打款金额非正,直接打款成功';
|
|
|
|
|
|
|
|
|
|
$pay_info = json_encode($payres, JSON_UNESCAPED_UNICODE);
|
|
|
|
|
M("company_statement_info","tab_")
|
|
|
|
|
->where([
|
|
|
|
|
'id'=>['in',$value['id']]
|
|
|
|
|
])
|
|
|
|
|
->save(['pay_status'=>1,'pay_time'=>time(),'pay_type'=>2,'pay_info'=>$pay_info]);
|
|
|
|
|
M("pay_statement_info","tab_")
|
|
|
|
|
->where([
|
|
|
|
|
'statement_info_id'=>['in',$value['id']]
|
|
|
|
|
])
|
|
|
|
|
->save(['pay_status'=>1,'pay_time'=>time(),'pay_type'=>2,'pay_info'=>$pay_info]);
|
|
|
|
|
} else {
|
|
|
|
|
$payres["remark"] = '打款金额非正,直接打款成功';
|
|
|
|
|
|
|
|
|
|
$pay_info = json_encode($payres, JSON_UNESCAPED_UNICODE);
|
|
|
|
|
M("pay_statement_info","tab_")
|
|
|
|
|
->where([
|
|
|
|
|
'statement_info_id'=>['in',$value['id']],
|
|
|
|
|
'statement_money'=>['elt',0]
|
|
|
|
|
])
|
|
|
|
|
->save(['pay_status'=>1,'pay_time'=>time(),'pay_type'=>2,'pay_info'=>$pay_info]);
|
|
|
|
|
|
|
|
|
|
$pay_statement_info = M("pay_statement_info","tab_")
|
|
|
|
|
->where([
|
|
|
|
|
'statement_info_id'=>['in',$value['id']]
|
|
|
|
|
])
|
|
|
|
|
->order("statement_money ASC")
|
|
|
|
|
->select();
|
|
|
|
|
$subtraction = 0;
|
|
|
|
|
foreach ($pay_statement_info as $sk => $sv) {
|
|
|
|
|
|
|
|
|
|
if ($sv['statement_money'] < 0) {
|
|
|
|
|
$subtraction += -($sv['statement_money']);
|
|
|
|
|
$sv['final_statement_money'] = 0;
|
|
|
|
|
} elseif($sv['statement_money'] > 0 && $subtraction > 0) {
|
|
|
|
|
if($sv['statement_money'] >= $subtraction) {
|
|
|
|
|
$sv['final_statement_money'] = $sv['statement_money']-$subtraction;
|
|
|
|
|
$subtraction = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$sv['final_statement_money'] = 0;
|
|
|
|
|
$subtraction =-$sv['final_statement_money'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
M("pay_statement_info","tab_")
|
|
|
|
|
->where([
|
|
|
|
|
'id'=>$sv['id']
|
|
|
|
|
])->save($sv);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn(array(
|
|
|
|
|
'status' => 1,
|
|
|
|
|
"info"=>"打款信息编辑成功"
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function transfer_set()
|
|
|
|
|
{
|
|
|
|
|
$this->getAccountMoney();
|
|
|
|
@ -900,10 +1156,16 @@ class PaymentController extends BaseController
|
|
|
|
|
$fund = new \Fund(C("ALI_PAYMENT"));
|
|
|
|
|
$dbres = M("pay_statement_info", "tab_")->where("id='{$id}'")->find();
|
|
|
|
|
|
|
|
|
|
$company_statement = M("company_statement_info", "tab_")->field("pay_check")->where(['id'=>$dbres['statement_info_id']])->find();
|
|
|
|
|
|
|
|
|
|
if ($company_statement['pay_check']!=1) {
|
|
|
|
|
$this->ajaxReturn(["success"=>"打款信息未确认,打款失败","data"=>["status"=>0]]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$company_info = json_decode($dbres['company_info'], true);
|
|
|
|
|
if ($dbres['pay_status'] != 1 && $dbres['verify_status'] == 1) {
|
|
|
|
|
//执行打款
|
|
|
|
|
$title = "信息服务费";
|
|
|
|
|
$title = $remark;
|
|
|
|
|
$amount = $dbres['final_statement_money'];
|
|
|
|
|
|
|
|
|
|
$payres = $fund->transfer($company_info['ali_account'], $company_info['ali_user'], $dbres['statement_num'], $amount, $title);
|
|
|
|
|