|
|
|
@ -217,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) {
|
|
|
|
@ -278,8 +277,23 @@ class PaymentController extends BaseController
|
|
|
|
|
'pay_status_str'=>'打款状态',
|
|
|
|
|
'pay_time'=>'打款时间',];
|
|
|
|
|
|
|
|
|
|
data2csv($data,'市场业绩提成',$title);
|
|
|
|
|
$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'=>'导出成功']);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -760,10 +774,12 @@ class PaymentController extends BaseController
|
|
|
|
|
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){
|
|
|
|
@ -788,6 +804,70 @@ class PaymentController extends BaseController
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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"=>"打款信息编辑成功"
|
|
|
|
|