新增线下确认打款

master
chenzhi 4 years ago
parent e2d179acd8
commit 69cf42e895

@ -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 = [];

@ -151,24 +151,16 @@ class CompanyStatementPoolController extends ThinkController
if(isset($v['verify_log']['payment_user'])){
if($v['verify_status'] == -2){
$ts = "拒绝打款";
$v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}";
}elseif($v['verify_status'] == 2){
$ts = "待打款";
$v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}";
}elseif($v['verify_status'] == 3){
$ts = "打款中";
$v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}";
}elseif($v['verify_status'] == 4){
if($v['is_payment']==1){
$ts="线上打款成功";
}else{
$ts="线下打款成功";
}
$v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}";
$ts="打款成功";
}elseif($v['verify_status'] == 5){
$ts="无需打款";
$v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}";
}
$v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}";
}else{
$v["payment"] = '--';
}

@ -162,7 +162,6 @@
<th>结算金额</th>
<th>结算流水</th>
<th>汇总单状态</th>
<th>打款状态</th>
<th class="tooltip">汇总单号<span class="tooltiptext">汇总单号</span></th>
@ -180,13 +179,12 @@
<notemtpy name = "data">
<volist name="data" id="data">
<tr>
<td ><input class="ids" type="checkbox" value="{$data['id']}" name="ids[]"></td>
<td ><input class="ids" type="checkbox" value="{$data['id']}" name="ids[]" data-paystatus="{$data['pay_status']}"></td>
<td>{$data.company_name}</td>
<td>{$data.company_type_str}</td>
<td>{$data.valid}</td>
<td>{$data.statement_money}</td>
<td>{$data.platform_amount}</td>
<td>{$data.verify_status_str}</td>
<td>{$data.pay_status_str}</td>
<td>{$data.statement_num}</td>
<td>
@ -279,24 +277,23 @@
});
});
$("#pool").on("click",function(){
$("#doPayment").on("click",function(){
var id = $(this).attr("id");
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
return $(elem).val();
if($(elem).data("paystatus") == 0){
return $(elem).val();
}
}).get();
if(text.length > 40){
layer.msg("<font style='color:white'>" + '为保证效率暂不支持超过40条的批量操作' + "</font>");
return;
}
if(text.length < 1){
layer.msg("<font style='color:white'>" + '无需要汇总的操作'+"</font>");
layer.msg("<font style='color:white'>无需要进行确认打款确认操作的数据</font>");
return;
}
text = text.join(",");
if(confirm){
layer.confirm('【警告】汇总后将不可回退,如需继续请点击确认', {
layer.confirm('【警告】确认打款后将不可回退,如需继续请点击确认', {
btn: ['确认','取消'],
title:false
}, function(){
@ -310,7 +307,7 @@
//执行
$.ajax({
type: "POST",
url: "{:U('pool')}",
url: "{:U('doPayment')}",
dataType: 'json',
async: false,
data: {ids:text},

Loading…
Cancel
Save