@ -21,11 +21,7 @@ class CompanyStatementOfflineController extends ThinkController
"0"=>"未打款",
"1"=>"打款成功"
];
public $VerifyStatus=[
"-1"=>"审批拒绝",
"0"=>"未审批",
"1"=>"审批通过",
];
public function lists() {
$params = I('get.');
$page = $params['p'] ? intval($params['p']) : 1;
@ -37,7 +33,8 @@ class CompanyStatementOfflineController extends ThinkController
$this->assign('menubtn',$this->menuAuth());
$map = [
"c.verify_status"=>2
"c.verify_status"=>2,
"p.verify_status"=>["GT",1]
];
if (isset($_REQUEST['time_start']) & & isset($_REQUEST['time_end'])) {
$time_start = strtotime($_REQUEST['time_start']);
@ -58,14 +55,6 @@ class CompanyStatementOfflineController extends ThinkController
if(isset($_REQUEST['company_name'])){
$map['c.company_name'] =["LIKE","%{$_REQUEST['company_name']}%"];
}
// if(isset($_REQUEST['statement_pool_num'])){
// $map['statement_pool_num'] =["LIKE","%{$_REQUEST['statement_pool_num']}%"];
// }
// if(isset($_REQUEST['is_payment'])){
// $map['is_payment'] = $_REQUEST['is_payment'];
// }
// $this->checkListOrCountAuthRestMap($map);//导出权限
//条件end
$data = M("company_statement_info","tab_")
@ -73,7 +62,7 @@ class CompanyStatementOfflineController extends ThinkController
->field("c.*,p.statement_num,p.verify_status")
->where($map)
->join("left join tab_company_statement_pool as p ON c.pool_id = p.id")
->join("tab_company_statement_pool as p ON c.pool_id = p.id")
->page($page,$row)
->order("id desc")
@ -86,19 +75,18 @@ class CompanyStatementOfflineController extends ThinkController
$v['company_type_str'] = $this->CompanyType[$v['company_type']];
$v["valid"] = "{$v['statement_begin_time']}-{$v['statement_end_time']}";
$v["pay_status_str"] = $this->PayStatus[$v["pay_status"]];
if($v["verify_status"] < 0 ) {
$v["verify_status"] = -1;
}
if($v["verify_status"] > 0){
$v["verify_status"] = 1;
}
$v["verify_status_str"] = $this->VerifyStatus[$v["verify_status"]];
$v["pay_info"] = json_decode($v['pay_info'], true);
if(isset($v['pay_info']['payment_user'])){
$v["payment"]= "{$v['pay_status_str']}({$v['verify_log']['payment_user']})< br > {$v['verify_log']['payment_time']}";
}else{
$v["payment"] = $v["pay_status_str"];
}
$v['oplist'] = $this->OpAuth($v);
}
$count = M("company_statement_info","tab_")->alias("c")->field("count(id) count,sum(statement_money) statement_money")->where($map)->find();
$count = M("company_statement_info","tab_")->alias("c")->field("count(c. id) count,sum(c. statement_money) statement_money")->join("tab_company_statement_pool as p ON c.pool_id = p.id ")->where($map)->find();
// dd($count);
$params['p'] = $page;
$params['row'] = $row;
@ -113,6 +101,58 @@ class CompanyStatementOfflineController extends ThinkController
$this->display();
}
public function doPayment()
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
//获取所有的母单id
$companyStatementInfo = M("company_statement_info","tab_");
$statementPool = $companyStatementInfo->where("id in ($ids) and pay_status < > 1")->field("pool_id,count(id) count")->group("pool_id")->select();
$poolInfo = [];
foreach ($statementPool as $k => $v) {
$poolInfo[$v['pool_id']] = $v['count'];
}
unset($statementPool);
//修改info
$saveData = [
"pay_type"=>3,
"pay_status"=>1,
"pay_info"=>json_encode(["payment_user"=>$_SESSION['onethink_admin']['user_auth']["username"],"payment_time"=>date("Y-m-d H:i:s")])
];
$ires = $companyStatementInfo->where("id in ($ids)")->save($saveData);
//获取母单未支付完成订单
$poolIds = implode(",",array_keys($poolInfo));
$poolInfo = $companyStatementInfo->where("pool_id in ($poolIds) and pay_status < > 1")->field("pool_id,count(id) count")->group("pool_id")->select();
//全部就打款成功,否则打款中
$companyStatementPool = M("company_statement_pool","tab_");
foreach ($poolInfo as $k => $v) {
if($v['count'] == $poolInfo[$v['pool_id']]){
//打款成功
$this->setOneVerifyStatus(4,"payment",$v['pool_id']);
}else{
//打款中
$this->setOneVerifyStatus(3,"payment",$v['pool_id']);
}
}
$this->ajaxReturn(array(
'status' =>1,
"info"=>"打款确认成功"
));
}
protected function setOneVerifyStatus($change_status,$op_pre,$id)
{
$dbres = M("company_statement_pool","tab_")->field("id,verify_status,verify_log")->where("id = {$id}")->find();
$dbres['verify_log'] = json_decode($dbres['verify_log'],true);
$dbres['verify_log'][$op_pre.'_user']=$_SESSION['onethink_admin']['user_auth']["username"];
$dbres['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s");
$dbres['verify_log'] = json_encode($dbres['verify_log']);
$dbres['verify_status']=$change_status;
M("company_statement_pool","tab_")->save($dbres);
}
public function OpAuth($info)
{
@ -139,7 +179,7 @@ class CompanyStatementOfflineController extends ThinkController
public function menuAuth()
{
$mentBtn = [
"pool "=>"< a class = 'butn' id = ' pool'> 发起汇总 < / a > ",
"doPayment "=>"< a class = 'butn' id = ' doPayment'> 打款确认 < / a > ",
"export"=>"< a class = 'butn' id = 'export' > 批量导出< / a > "
];
$resarr = [];