@ -51,7 +51,7 @@ class CompanyStatementPoolController extends ThinkController
public function _initialize()
public function _initialize()
{
{
$this->admininfo = $_SESSION['onethink_admin']['user_auth'];
$this->admininfo = $_SESSION['onethink_admin']['user_auth'];
$this->DBModel = M("CompanyStatementPool","tab_");
$this->DBModel = S M("CompanyStatementPool","tab_");
parent::_initialize();
parent::_initialize();
}
}
@ -216,12 +216,12 @@ class CompanyStatementPoolController extends ThinkController
$is_export = true;
$is_export = true;
}
}
//获取基本信息
//获取基本信息
$infolist = M("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}'")->select();
$infolist = S M("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}'")->select();
//获取母单
//获取母单
$pool_info = M("company_statement_pool","tab_")->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type,statement_begin_time,statement_end_time')->where("id={$id}")->find();
$pool_info = S M("company_statement_pool","tab_")->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type,statement_begin_time,statement_end_time')->where("id={$id}")->find();
if(!empty($pool_info['create_lack_ids'])){
if(!empty($pool_info['create_lack_ids'])){
$l_ids = $pool_info['create_lack_ids'];
$l_ids = $pool_info['create_lack_ids'];
$lack_info = M("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select();
$lack_info = S M("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select();
$infolist =array_merge($infolist,$lack_info);
$infolist =array_merge($infolist,$lack_info);
}
}
@ -251,12 +251,12 @@ class CompanyStatementPoolController extends ThinkController
$is_export = true;
$is_export = true;
}
}
//获取基本信息
//获取基本信息
$infolist = M("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}'")->select();
$infolist = S M("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}'")->select();
//获取母单
//获取母单
$pool_info = M("company_statement_pool","tab_")->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type')->where("id={$id}")->find();
$pool_info = S M("company_statement_pool","tab_")->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type')->where("id={$id}")->find();
if(!empty($pool_info['create_lack_ids'])){
if(!empty($pool_info['create_lack_ids'])){
$l_ids = $pool_info['create_lack_ids'];
$l_ids = $pool_info['create_lack_ids'];
$lack_info = M("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select();
$lack_info = S M("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select();
$infolist =array_merge($infolist,$lack_info);
$infolist =array_merge($infolist,$lack_info);
}
}
@ -1143,7 +1143,7 @@ class CompanyStatementPoolController extends ThinkController
public function delPayInfo($id) {
public function delPayInfo($id) {
$company_statement_info = M("company_statement_info","tab_")->field("id")->where("pool_id={$id}")->select();
$company_statement_info = S M("company_statement_info","tab_")->field("id")->where("pool_id={$id}")->select();
//有一笔单子已打款将不可撤回
//有一笔单子已打款将不可撤回
foreach ($company_statement_info as $key => $value) {
foreach ($company_statement_info as $key => $value) {
if($value['pay_status'] == 1) {
if($value['pay_status'] == 1) {
@ -1151,14 +1151,14 @@ class CompanyStatementPoolController extends ThinkController
}
}
}
}
//线上打款审核状态撤回
//线上打款审核状态撤回
M("company_statement_info","tab_")->where("pool_id={$id}")->save(['pay_verify_status'=>0,'verify_time'=>'','verify_member_id'=>0]);
S M("company_statement_info","tab_")->where("pool_id={$id}")->save(['pay_verify_status'=>0,'verify_time'=>'','verify_member_id'=>0]);
//线上打款支付宝状态撤回
//线上打款支付宝状态撤回
M("company_statement_info","tab_")->where("pool_id={$id} and verify_status != 2")->save(['verify_status'=>0]);
S M("company_statement_info","tab_")->where("pool_id={$id} and verify_status != 2")->save(['verify_status'=>0]);
foreach ($company_statement_info as $key => $value) {
foreach ($company_statement_info as $key => $value) {
$is_hav = M("pay_statement_info","tab_")->where(['statement_info_id'=>$value['id']])->find();
$is_hav = S M("pay_statement_info","tab_")->where(['statement_info_id'=>$value['id']])->find();
if ($is_hav) {
if ($is_hav) {
M("pay_statement_info","tab_")->where(['statement_info_id'=>$value['id']])->delete();
S M("pay_statement_info","tab_")->where(['statement_info_id'=>$value['id']])->delete();
}
}
}
}
@ -1171,7 +1171,7 @@ class CompanyStatementPoolController extends ThinkController
$ids = $_REQUEST['ids'];
$ids = $_REQUEST['ids'];
//修改info
//修改info
$ires = M("company_statement_info","tab_")->where("pool_id='{$ids}'")->save(['pay_type'=>3,'pay_status'=>1]);
$ires = S M("company_statement_info","tab_")->where("pool_id='{$ids}'")->save(['pay_type'=>3,'pay_status'=>1]);
if($ires !== false){
if($ires !== false){
$this->setVerifyStatus(1,4,"payment");
$this->setVerifyStatus(1,4,"payment");
}
}
@ -1237,7 +1237,7 @@ class CompanyStatementPoolController extends ThinkController
public function setPayment(){
public function setPayment(){
if(!isset($_REQUEST['id'])) $this->error("参数错误");
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$id = $_REQUEST['id'];
$CompanyInfo = M("company_statement_info","tab_")
$CompanyInfo = S M("company_statement_info","tab_")
->alias('i')
->alias('i')
->field("i.id,i.pool_id,i.company_name,i.company_info,i.statement_money,p.statement_num,i.remark,i.pay_status,p.statement_money all_money,i.verify_status")
->field("i.id,i.pool_id,i.company_name,i.company_info,i.statement_money,p.statement_num,i.remark,i.pay_status,p.statement_money all_money,i.verify_status")
->join("tab_company_statement_pool p ON p.id = i.pool_id")
->join("tab_company_statement_pool p ON p.id = i.pool_id")
@ -1264,7 +1264,7 @@ class CompanyStatementPoolController extends ThinkController
if(!isset($_REQUEST['info'])) $this->error("参数错误");
if(!isset($_REQUEST['info'])) $this->error("参数错误");
$info = $_REQUEST['info'];
$info = $_REQUEST['info'];
$pool_id = $_REQUEST['pool_id'];
$pool_id = $_REQUEST['pool_id'];
$CompanyInfo = M("company_statement_info","tab_");
$CompanyInfo = S M("company_statement_info","tab_");
//循环保存
//循环保存
foreach($info as $k=>$v){
foreach($info as $k=>$v){
$ydata = $CompanyInfo->where("id= '{$k}'")->find();
$ydata = $CompanyInfo->where("id= '{$k}'")->find();
@ -1305,7 +1305,7 @@ class CompanyStatementPoolController extends ThinkController
public function viewPayment(){
public function viewPayment(){
if(!isset($_REQUEST['id'])) $this->error("参数错误");
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$id = $_REQUEST['id'];
$CompanyInfo = M("company_statement_info","tab_")
$CompanyInfo = S M("company_statement_info","tab_")
->alias('i')
->alias('i')
->field("i.id,i.pool_id,i.company_name,i.company_info,i.statement_money,p.statement_num,i.remark,i.pay_status,i.verify_status,p.statement_money all_money")
->field("i.id,i.pool_id,i.company_name,i.company_info,i.statement_money,p.statement_num,i.remark,i.pay_status,i.verify_status,p.statement_money all_money")
->join("tab_company_statement_pool p ON p.id = i.pool_id")
->join("tab_company_statement_pool p ON p.id = i.pool_id")
@ -1428,11 +1428,11 @@ class CompanyStatementPoolController extends ThinkController
if(!isset($_REQUEST['id'])) $this->error("参数错误");
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$id = $_REQUEST['id'];
//获取结算信息
//获取结算信息
$v = M("company_statement_info","tab_")->where("id = '{$id}'")->find();
$v = S M("company_statement_info","tab_")->where("id = '{$id}'")->find();
if(empty($v)){
if(empty($v)){
$this->error("请勿重复操作");
$this->error("请勿重复操作");
}
}
$pool = M("company_statement_pool","tab_")->where("id = {$v['pool_id']}")->find();
$pool = S M("company_statement_pool","tab_")->where("id = {$v['pool_id']}")->find();
// dump($pool);
// dump($pool);
@ -1461,7 +1461,7 @@ class CompanyStatementPoolController extends ThinkController
"withdraw_type"=>$v['withdraw_type'],
"withdraw_type"=>$v['withdraw_type'],
"remark"=>$v["remark"],
"remark"=>$v["remark"],
];
];
$l_id = M("company_lack_statement_info","tab_")->add($lackcompany);
$l_id = S M("company_lack_statement_info","tab_")->add($lackcompany);
//汇总表
//汇总表
$pool_data = [
$pool_data = [
@ -1480,8 +1480,8 @@ class CompanyStatementPoolController extends ThinkController
}else{
}else{
$pool_data['create_lack_ids'] = $pool['create_lack_ids'].",".$l_id;
$pool_data['create_lack_ids'] = $pool['create_lack_ids'].",".$l_id;
}
}
M("company_statement_pool","tab_")->save($pool_data);
S M("company_statement_pool","tab_")->save($pool_data);
M("company_statement_info","tab_")->where("id='{$id}'")->delete();
S M("company_statement_info","tab_")->where("id='{$id}'")->delete();
$this->ajaxReturn(array(
$this->ajaxReturn(array(
'status' => 1,
'status' => 1,
"info"=>"不结算成功"
"info"=>"不结算成功"
@ -1504,7 +1504,7 @@ class CompanyStatementPoolController extends ThinkController
$re_op = true;
$re_op = true;
$create_lack_ids = $db_res['create_lack_ids'];
$create_lack_ids = $db_res['create_lack_ids'];
if(!empty($create_lack_ids) & & !$is_qz){
if(!empty($create_lack_ids) & & !$is_qz){
$clsi = M("company_lack_statement_info","tab_")->where("is_pool = 1 and id in ({$create_lack_ids})")->find();
$clsi = S M("company_lack_statement_info","tab_")->where("is_pool = 1 and id in ({$create_lack_ids})")->find();
$re_op = true;
$re_op = true;
if(!empty($clsi)){
if(!empty($clsi)){
$re_op = false; //被引用无法重算
$re_op = false; //被引用无法重算
@ -1533,32 +1533,32 @@ class CompanyStatementPoolController extends ThinkController
//执行删除
//执行删除
$dids = $info['del_lack_ids'];
$dids = $info['del_lack_ids'];
$cids = $info['create_lack_ids'];
$cids = $info['create_lack_ids'];
M()->startTrans();
S M()->startTrans();
//删除info
//删除info
$infores = M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
$infores = S M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
if($infores === false){
if($infores === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
}
}
//删除自己
//删除自己
$poolres = $this->DBModel->where("id = {$info['id']}")->delete();
$poolres = $this->DBModel->where("id = {$info['id']}")->delete();
if($poolres === false){
if($poolres === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
}
}
//修改引用不足单
//修改引用不足单
if(!empty($dids)){
if(!empty($dids)){
$dres = M("company_lack_statement_info","tab_")->where("id in ({$dids})")->save(['is_pool'=>0]);
$dres = S M("company_lack_statement_info","tab_")->where("id in ({$dids})")->save(['is_pool'=>0]);
if($dres === false){
if($dres === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
}
}
}
}
//删除创建的不足单
//删除创建的不足单
if(!empty($cids)){
if(!empty($cids)){
$cres = M("company_lack_statement_info","tab_")->where("id in ({$cids})")->delete();
$cres = S M("company_lack_statement_info","tab_")->where("id in ({$cids})")->delete();
if($cres === false){
if($cres === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"重算失败"));
}
}
}
}
@ -1567,7 +1567,7 @@ class CompanyStatementPoolController extends ThinkController
$type = $info['withdraw_type'];
$type = $info['withdraw_type'];
A("CompanyStatementSet")->promoteUserPool($type,$stime,true);
A("CompanyStatementSet")->promoteUserPool($type,$stime,true);
M()->commit();
S M()->commit();
$this->ajaxReturn(array(
$this->ajaxReturn(array(
'status' => 1,
'status' => 1,
'info' => "重算成功"
'info' => "重算成功"
@ -1576,19 +1576,19 @@ class CompanyStatementPoolController extends ThinkController
public function cancelQzPool($info){
public function cancelQzPool($info){
if(!empty($info['del_lack_ids'])){
if(!empty($info['del_lack_ids'])){
M()->startTrans();//事务
S M()->startTrans();//事务
$dbres = M("company_lack_statement_info","tab_")->where("id in ({$info['del_lack_ids']})")->save(['is_pool'=>0]);
$dbres = S M("company_lack_statement_info","tab_")->where("id in ({$info['del_lack_ids']})")->save(['is_pool'=>0]);
$poolres = $this->DBModel->where("id = {$info['id']}")->delete();
$poolres = $this->DBModel->where("id = {$info['id']}")->delete();
$infores = M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
$infores = S M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
if($dbres !== false & & $poolres !== false & & $infores !== false){
if($dbres !== false & & $poolres !== false & & $infores !== false){
M()->commit();
S M()->commit();
$this->ajaxReturn(array(
$this->ajaxReturn(array(
'status' => 1,
'status' => 1,
'info' => "撤销汇总成功"
'info' => "撤销汇总成功"
));
));
}
}
}
}
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array(
$this->ajaxReturn(array(
'status' => 0,
'status' => 0,
'info' => "撤销汇总失败"
'info' => "撤销汇总失败"
@ -1603,50 +1603,50 @@ class CompanyStatementPoolController extends ThinkController
$dids = $info['del_lack_ids'];
$dids = $info['del_lack_ids'];
$cids = $info['create_lack_ids'];
$cids = $info['create_lack_ids'];
M()->startTrans();//事务
S M()->startTrans();//事务
//删除info
//删除info
$infores = M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
$infores = S M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
if($infores === false){
if($infores === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
}
//删除自己
//删除自己
$poolres = $this->DBModel->where("id = {$info['id']}")->delete();
$poolres = $this->DBModel->where("id = {$info['id']}")->delete();
if($poolres === false){
if($poolres === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
}
//修改结算单信息
//修改结算单信息
$st_res = M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select();
$st_res = S M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select();
foreach($st_res as $k=>& $v){
foreach($st_res as $k=>& $v){
$v['verify_log'] = json_decode($v['verify_log'],true);
$v['verify_log'] = json_decode($v['verify_log'],true);
$v['verify_log']['pool_user']=$this->admininfo["username"];
$v['verify_log']['pool_user']=$this->admininfo["username"];
$v['verify_log']['pool_time']=date("Y.m.d H:i:s");
$v['verify_log']['pool_time']=date("Y.m.d H:i:s");
$v['verify_log'] = json_encode($v['verify_log']);
$v['verify_log'] = json_encode($v['verify_log']);
$v['verify_status']=-2;
$v['verify_status']=-2;
$stres = M("company_statement","tab_")->save($v);
$stres = S M("company_statement","tab_")->save($v);
if($stres === false){
if($stres === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
}
}
}
//修改引用不足单
//修改引用不足单
if(!empty($dids)){
if(!empty($dids)){
$dres = M("company_lack_statement_info","tab_")->where("id in ({$dids})")->save(['is_pool'=>0]);
$dres = S M("company_lack_statement_info","tab_")->where("id in ({$dids})")->save(['is_pool'=>0]);
if($dres === false){
if($dres === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
}
}
}
//删除创建的不足单
//删除创建的不足单
if(!empty($cids)){
if(!empty($cids)){
$cres = M("company_lack_statement_info","tab_")->where("id in ({$cids})")->delete();
$cres = S M("company_lack_statement_info","tab_")->where("id in ({$cids})")->delete();
if($cres === false){
if($cres === false){
M()->rollback();
S M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
}
}
}
M()->commit();
S M()->commit();
$this->ajaxReturn(array(
$this->ajaxReturn(array(
'status' => 1,
'status' => 1,
"info"=>"撤销汇总成功"
"info"=>"撤销汇总成功"
@ -1665,7 +1665,7 @@ class CompanyStatementPoolController extends ThinkController
$re_op = true;
$re_op = true;
if(!empty($create_lack_ids) & & !$is_qz){
if(!empty($create_lack_ids) & & !$is_qz){
$clsi = M("company_lack_statement_info","tab_")->where("is_pool = 1 and id in ({$create_lack_ids})")->find();
$clsi = S M("company_lack_statement_info","tab_")->where("is_pool = 1 and id in ({$create_lack_ids})")->find();
$re_op = true;
$re_op = true;
if(!empty($clsi)){
if(!empty($clsi)){
$re_op = false; //被引用无法重算
$re_op = false; //被引用无法重算
@ -1852,7 +1852,7 @@ class CompanyStatementPoolController extends ThinkController
foreach($value as $akey => $aval) {
foreach($value as $akey => $aval) {
if ($st[$key][$akey] == 1) {
if ($st[$key][$akey] == 1) {
$model = M("company_statement_info","tab_");
$model = S M("company_statement_info","tab_");
if (!$handledata[$key][1]) {
if (!$handledata[$key][1]) {
$handledata[$key][1] = 1;
$handledata[$key][1] = 1;
@ -1862,7 +1862,7 @@ class CompanyStatementPoolController extends ThinkController
} else {
} else {
$model = M("company_lack_statement_info","tab_");
$model = S M("company_lack_statement_info","tab_");
if (!$handledata[$key][0]) {
if (!$handledata[$key][0]) {
$handledata[$key][0] = 1;
$handledata[$key][0] = 1;
@ -1913,7 +1913,7 @@ class CompanyStatementPoolController extends ThinkController
$statement_info_data = json_encode($statement_info);
$statement_info_data = json_encode($statement_info);
$r_data = $model->field("fine,reward")->where(['id'=>$key])->find();
$r_data = $model->field("fine,reward")->where(['id'=>$key])->find();
if($model == M("company_statement_info","tab_")) {
if($model == S M("company_statement_info","tab_")) {
$reward += $r_data['reward'];
$reward += $r_data['reward'];
$fine += $r_data['fine'];
$fine += $r_data['fine'];
} else {
} else {
@ -1929,7 +1929,7 @@ class CompanyStatementPoolController extends ThinkController
}
}
//die();
//die();
M("company_statement_pool","tab_")->where(['id'=>$id])->save(['pay_amount'=>$statement_amount,'statement_money'=>$statement_amount+$reward-$fine,'lack_statement_money'=>$statement_lack_amount+$lreward-$lfine]);
S M("company_statement_pool","tab_")->where(['id'=>$id])->save(['pay_amount'=>$statement_amount,'statement_money'=>$statement_amount+$reward-$fine,'lack_statement_money'=>$statement_lack_amount+$lreward-$lfine]);
$this->ajaxReturn(['status'=>1,'info'=>'保存成功']);
$this->ajaxReturn(['status'=>1,'info'=>'保存成功']);
@ -2021,7 +2021,7 @@ class CompanyStatementPoolController extends ThinkController
$save['reward'] = $svalue['reward'];
$save['reward'] = $svalue['reward'];
$save['is_limit'] = 1;
$save['is_limit'] = 1;
M("pay_statement_info", "tab_")->add($save);
S M("pay_statement_info", "tab_")->add($save);
}
}
} else {
} else {
@ -2040,7 +2040,7 @@ class CompanyStatementPoolController extends ThinkController
$save['fine'] = $svalue['fine'];
$save['fine'] = $svalue['fine'];
$save['reward'] = $svalue['reward'];
$save['reward'] = $svalue['reward'];
M("pay_statement_info", "tab_")->add($save);
S M("pay_statement_info", "tab_")->add($save);
}
}
@ -2089,7 +2089,7 @@ class CompanyStatementPoolController extends ThinkController
$save['fine'] = $svalue['fine'];
$save['fine'] = $svalue['fine'];
$save['reward'] = $svalue['reward'];
$save['reward'] = $svalue['reward'];
M("pay_statement_info", "tab_")->add($save);
S M("pay_statement_info", "tab_")->add($save);
}
}
} else {
} else {
$save['statement_begin_time'] = $svalue['statement_begin_time'];
$save['statement_begin_time'] = $svalue['statement_begin_time'];
@ -2110,7 +2110,7 @@ class CompanyStatementPoolController extends ThinkController
$save['fine'] = $svalue['fine'];
$save['fine'] = $svalue['fine'];
$save['reward'] = $svalue['reward'];
$save['reward'] = $svalue['reward'];
M("pay_statement_info", "tab_")->add($save);
S M("pay_statement_info", "tab_")->add($save);
}
}
}
}
}
}