优化不打款汇总

master
chenzhi 4 years ago
parent 19f7406298
commit b1a34cc9a0

@ -118,11 +118,11 @@ return array(
'SUBSITE_TABLE'=>[ 'SUBSITE_TABLE'=>[
"sys_auth_group", "sys_auth_group",
"tab_index_chart", "tab_index_chart",
"tab_deposit",
"tab_company_statement", "tab_company_statement",
"tab_company_lack_statement_info", "tab_company_lack_statement_info",
"tab_company_statement_info", "tab_company_statement_info",
"tab_company_statement_pool", "tab_company_statement_pool",
"tab_financial_summary" "tab_financial_summary",
"tab_pay_statement_info"
] ]
); );

@ -22,7 +22,7 @@ class CompanyStatementLackController 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("CompanyLackStatementInfo","tab_"); $this->DBModel = SM("CompanyLackStatementInfo","tab_");
parent::_initialize(); parent::_initialize();
} }
public function lists() { public function lists() {
@ -226,8 +226,8 @@ class CompanyStatementLackController extends ThinkController
} }
} }
$Pool = M("company_statement_pool","tab_"); $Pool = SM("company_statement_pool","tab_");
$Statemen = M("company_statement","tab_"); $Statemen = SM("company_statement","tab_");
foreach ($datas as $k => $v) { foreach ($datas as $k => $v) {
@ -253,10 +253,10 @@ class CompanyStatementLackController extends ThinkController
} }
if(!empty($info)){ if(!empty($info)){
$save["pool_id"]=$pool_id; $save["pool_id"]=$pool_id;
M("company_statement_info","tab_")->where("id in ({$info})")->save($save); SM("company_statement_info","tab_")->where("id in ({$info})")->save($save);
} }
if(!empty($v['del_lack_ids'])){ if(!empty($v['del_lack_ids'])){
M("company_lack_statement_info","tab_")->where("id in ({$v['del_lack_ids']})")->save(["is_pool"=>1]); SM("company_lack_statement_info","tab_")->where("id in ({$v['del_lack_ids']})")->save(["is_pool"=>1]);
} }
} }
$this->ajaxReturn(array( $this->ajaxReturn(array(
@ -296,7 +296,7 @@ class CompanyStatementLackController extends ThinkController
$verify_status = 2; $verify_status = 2;
} }
$StatementInfo = M("company_statement_info","tab_"); $StatementInfo = SM("company_statement_info","tab_");
if($va['pay_amount'] > 0){ if($va['pay_amount'] > 0){
//存成功 //存成功
$company =[ $company =[

@ -63,7 +63,7 @@ class CompanyStatementOfflineController extends ThinkController
//条件end //条件end
$data = M("company_statement_info","tab_") $data = SM("company_statement_info","tab_")
->alias("c") ->alias("c")
->field("c.*,p.statement_num,p.verify_status") ->field("c.*,p.statement_num,p.verify_status")
->where($map) ->where($map)
@ -92,7 +92,7 @@ class CompanyStatementOfflineController extends ThinkController
$v['oplist'] = $this->OpAuth($v); $v['oplist'] = $this->OpAuth($v);
} }
$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(); $count = SM("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); // dd($count);
$params['p'] = $page; $params['p'] = $page;
$params['row'] = $row; $params['row'] = $row;
@ -113,7 +113,7 @@ class CompanyStatementOfflineController extends ThinkController
$ids = $_REQUEST['ids']; $ids = $_REQUEST['ids'];
$payment_time = $_REQUEST['payment_time']; $payment_time = $_REQUEST['payment_time'];
//获取所有的母单id //获取所有的母单id
$companyStatementInfo = M("company_statement_info","tab_"); $companyStatementInfo = SM("company_statement_info","tab_");
$statementPool = $companyStatementInfo->where("id in ($ids) and pay_status <> 1")->field("pool_id,count(id) count")->group("pool_id")->select(); $statementPool = $companyStatementInfo->where("id in ($ids) and pay_status <> 1")->field("pool_id,count(id) count")->group("pool_id")->select();
$yPoolInfo = []; $yPoolInfo = [];
foreach ($statementPool as $k => $v) { foreach ($statementPool as $k => $v) {
@ -134,7 +134,7 @@ class CompanyStatementOfflineController extends ThinkController
$ires = $companyStatementInfo->where("id in ($ids)")->save($saveData); $ires = $companyStatementInfo->where("id in ($ids)")->save($saveData);
//全部就打款成功,否则打款中 //全部就打款成功,否则打款中
$companyStatementPool = M("company_statement_pool","tab_"); $companyStatementPool = SM("company_statement_pool","tab_");
foreach ($poolInfo as $k => $v) { foreach ($poolInfo as $k => $v) {
if($v['count'] == $yPoolInfo[$v['pool_id']]){ if($v['count'] == $yPoolInfo[$v['pool_id']]){
//打款成功 //打款成功
@ -161,7 +161,7 @@ class CompanyStatementOfflineController extends ThinkController
$is_export = true; $is_export = true;
} }
//获取基本信息 //获取基本信息
$dbres = M("company_statement_info","tab_")->where("id='{$id}'")->select(); $dbres = SM("company_statement_info","tab_")->where("id='{$id}'")->select();
$title = $dbres[0]['company_name']; $title = $dbres[0]['company_name'];
$this->assign("title",$title); $this->assign("title",$title);
@ -179,7 +179,7 @@ class CompanyStatementOfflineController extends ThinkController
public function export(){ public function export(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误"); if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids']; $ids = $_REQUEST['ids'];
$dbres = M("company_statement_info","tab_")->where("id in ({$ids})")->select(); $dbres = SM("company_statement_info","tab_")->where("id in ({$ids})")->select();
$is_export= false; $is_export= false;
if (isset($_REQUEST['export']) && $_REQUEST['export']==1){ if (isset($_REQUEST['export']) && $_REQUEST['export']==1){
@ -202,13 +202,13 @@ class CompanyStatementOfflineController extends ThinkController
protected function setOneVerifyStatus($change_status,$op_pre,$id) 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 = SM("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'] = json_decode($dbres['verify_log'],true);
$dbres['verify_log'][$op_pre.'_user']=$_SESSION['onethink_admin']['user_auth']["username"]; $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'][$op_pre.'_time']=date("Y-m-d H:i:s");
$dbres['verify_log'] = json_encode($dbres['verify_log']); $dbres['verify_log'] = json_encode($dbres['verify_log']);
$dbres['verify_status']=$change_status; $dbres['verify_status']=$change_status;
M("company_statement_pool","tab_")->save($dbres); SM("company_statement_pool","tab_")->save($dbres);
} }
public function OpAuth($info) public function OpAuth($info)

@ -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 = SM("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 = SM("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 = SM("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 = SM("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 = SM("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 = SM("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 = SM("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 = SM("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]); SM("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]); SM("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 = SM("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(); SM("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 = SM("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 = SM("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 = SM("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 = SM("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 = SM("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 = SM("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 = SM("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); SM("company_statement_pool","tab_")->save($pool_data);
M("company_statement_info","tab_")->where("id='{$id}'")->delete(); SM("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 = SM("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(); SM()->startTrans();
//删除info //删除info
$infores = M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete(); $infores = SM("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
if($infores === false){ if($infores === false){
M()->rollback(); SM()->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(); SM()->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 = SM("company_lack_statement_info","tab_")->where("id in ({$dids})")->save(['is_pool'=>0]);
if($dres === false){ if($dres === false){
M()->rollback(); SM()->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 = SM("company_lack_statement_info","tab_")->where("id in ({$cids})")->delete();
if($cres === false){ if($cres === false){
M()->rollback(); SM()->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(); SM()->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();//事务 SM()->startTrans();//事务
$dbres = M("company_lack_statement_info","tab_")->where("id in ({$info['del_lack_ids']})")->save(['is_pool'=>0]); $dbres = SM("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 = SM("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(); SM()->commit();
$this->ajaxReturn(array( $this->ajaxReturn(array(
'status' => 1, 'status' => 1,
'info' => "撤销汇总成功" 'info' => "撤销汇总成功"
)); ));
} }
} }
M()->rollback(); SM()->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();//事务 SM()->startTrans();//事务
//删除info //删除info
$infores = M("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete(); $infores = SM("company_statement_info","tab_")->where("pool_id = {$info['id']}")->delete();
if($infores === false){ if($infores === false){
M()->rollback(); SM()->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(); SM()->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 = SM("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 = SM("company_statement","tab_")->save($v);
if($stres === false){ if($stres === false){
M()->rollback(); SM()->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 = SM("company_lack_statement_info","tab_")->where("id in ({$dids})")->save(['is_pool'=>0]);
if($dres === false){ if($dres === false){
M()->rollback(); SM()->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 = SM("company_lack_statement_info","tab_")->where("id in ({$cids})")->delete();
if($cres === false){ if($cres === false){
M()->rollback(); SM()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
} }
} }
M()->commit(); SM()->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 = SM("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 = SM("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 = SM("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 == SM("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]); SM("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); SM("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); SM("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); SM("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); SM("pay_statement_info", "tab_")->add($save);
} }
} }
} }

@ -1597,12 +1597,12 @@ class CompanyStatementSetController extends Controller {
$this->getPuPromoteSpend($pc,array_unique(array_keys($pc)),$begintime,$endtime); $this->getPuPromoteSpend($pc,array_unique(array_keys($pc)),$begintime,$endtime);
// dump($pc);die(); // dump($pc);die();
$StatementDb = M("CompanyStatement","tab_"); $StatementDb = SM("CompanyStatement","tab_");
$statement_begin_time = date("Y.m.d",$begintime); $statement_begin_time = date("Y.m.d",$begintime);
$statement_end_time = date("Y.m.d",$endtime); $statement_end_time = date("Y.m.d",$endtime);
// $RewardRecord = M("RewardRecord","tab_"); // $RewardRecord = M("RewardRecord","tab_");
$LackStatement = M("company_lack_statement_info","tab_"); $LackStatement = SM("company_lack_statement_info","tab_");
$StatementInfo = M("company_statement_info","tab_"); $StatementInfo = SM("company_statement_info","tab_");
foreach($pc as $k=>&$v){ foreach($pc as $k=>&$v){
$fax_ratio = $v['taxation_rate']; $fax_ratio = $v['taxation_rate'];

Loading…
Cancel
Save