request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $userinfo = GetUserInfo($token); if(!isset($userinfo['code'])|| $userinfo['code']!=0){ return error_show(101,'未能获取用户信息'); } $condition = "a.status!=0"; $check = checkRole($userinfo['data']['roleid'],49); if($check){ $condition .=" and `a`.`creater` = {$userinfo['data']['id']}"; } $name= isset($post['name'])&&$post['name']!="" ? trim($post['name']) :""; $contector= isset($post['contector'])&&$post['contector']!="" ? trim($post['contector']) :""; $startTime= isset($post['startTime'])&&$post['startTime']!="" ? trim($post['startTime']) :""; $endTime= isset($post['endTime'])&&$post['endTime']!="" ? trim($post['endTime']) :""; $supplierNo= isset($post['supplierNo'])&&$post['supplierNo']!="" ? trim($post['supplierNo']) :""; $payNo= isset($post['payNo'])&&$post['payNo']!="" ? trim($post['payNo']) :""; $apply= isset($post['apply'])&&$post['apply']!="" ? trim($post['apply']) :""; $paystatus= isset($post['pay_status'])&&$post['pay_status']!="" ? $post['pay_status'] :""; $inv_status= isset($post['inv_status'])&&$post['inv_status']!="" ? $post['inv_status'] :""; if($name!=""){ $condition .=" and `c`.`name`like '%{$name}%'"; } if($contector!=""){ $condition .=" and `c`.`contector` like '%{$contector}%'"; } if($startTime!=""){ $condition.=" and `d`.`addtime` >= '{$startTime}'"; } if($endTime!=""){ $condition.=" and `d`.`addtime` <= '{$endTime}'"; } if($supplierNo!=""){ $condition.=" and `a`.`supplierNo` like '%{$supplierNo}%'"; } if($payNo!=""){ $condition.=" and `a`.`payNo` like '%{$payNo}%'"; } if($apply!=""){ $condition .=" and a.apply_name like '%{$apply}%'"; } if($paystatus!=""){ $condition .=" and `d`.`pay_status` = {$paystatus}"; } if($inv_status!=""){ $condition .=" and `d`.`status` = {$inv_status}"; } // echo $condition; $page = isset($post['page'])&&$post['page']!="" ? intval($post['page']) :1; $size = isset($post['size'])&&$post['size']!="" ? intval($post['size']) :10; $count = Db::name("pay")->alias('a') ->join('cfp_supplier_info c',' `a`.`supplierNo` = `c`.`code` ','left') ->join("cfp_pay_stages d",'`a`.`payNo` = `d`.`payNo` AND ( `d`.`is_del` = 0 ) ','left') ->join("cfp_order_rate p",'a.`inv_rate` = `p`.`id` ','left') ->where($condition)->count(); $total = ceil($count/$size)>1 ? ceil($count/$size) : 1; $page = $page>=$total?intval($total):$page; $list = Db::name("pay")->alias('a') ->join('cfp_supplier_info c',' `a`.`supplierNo` = `c`.`code` ','left') ->join("cfp_pay_stages d",'`a`.`payNo` = `d`.`payNo` AND ( `d`.`is_del` = 0 ) ','left') ->join("cfp_order_rate p",'a.`inv_rate` = `p`.`id` ','left') ->where($condition)->page(intval($page),$size)->order("addtime desc") ->field(" `a`.`id` AS `id`, `a`.`payNo` AS `payNo`, `a`.`supplierNo` AS `supplierNo`, `a`.`pay_fee` AS `pay_fee`, `a`.`total_fee` AS `total_fee`, `a`.`run_fee` AS `run_fee`, `a`.`invoiceNo` AS `invoiceNo`, `a`.`pay_method` AS `pay_method`, `a`.`pay_rate` AS `pay_rate`, `c`.`name` AS `name`, `c`.`contector` AS `contector`, `a`.`wait_fee` AS `wait_fee`, `d`.`id` AS `sid`, `d`.`pay_fee` AS `dpay_fee`, `d`.`pay_rate` AS `dpay_rate`, `d`.`pay_stages` AS `pay_stages`, `d`.`inv_fee` AS `inv_fee`, `d`.`return_img` AS `return_img`, `d`.`status` AS `dstatus`, `a`.`status` AS `status`, `a`.`remark` AS `remark`, `d`.`addtime` AS `addtime`, `d`.`companyNo` AS `companyNo`, `d`.`remark` AS `aremark`, `a`.`creater` AS `creater`, `d`.`dzNo` AS `dzNo`, `a`.`inv_rate` AS `inv_rate`, ifnull( `p`.`rate`, '' ) AS `rate`, `d`.`pay_status` AS `pay_status`, `d`.`pay_remark` AS `pay_remark`, `a`.`ainv_fee` AS `ainv_fee`, `a`.`winv_fee` AS `winv_fee` ")->select(); //echo Db::name("pay_ment")->getLastSql(); $data=[]; foreach ($list as $key=>$value){ $value['ordeNum'] = Db::name("pay_info")->where("payNo","=",$value["payNo"])->count(); $user = GetInfoById($token,["id"=>$value['creater']]); $username = ""; if(isset($user['code'])&&$user['code']==0){ $username = isset($user['data']['nickname']) ? $user['data']['nickname']: ""; } $value['createrName'] = $username; $data[]=$value; } return app_show(0,"获取成功",["list"=>$data,"count"=>$count]); } /** * 显示创建资源表单页. * * @return \think\Response */ public function PayAdd() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $guserinfo =GetUserInfo($token); if(isset($guserinfo['code']) && $guserinfo['code']!=0){ return error_show($guserinfo['code'],$guserinfo['message']); } $cids = isset($post['cids'])&&$post['cids']!="" ? trim($post['cids']) :""; if($cids==""){ return error_show(1003,"参数cids不能为空"); } $supplierNo = isset($post['supplierNo'])&&$post['supplierNo']!="" ? trim($post['supplierNo']) :""; if($supplierNo==""){ return error_show(1003,"参数supplierNo不能为空"); } $pay_method = isset($post['pay_method'])&&$post['pay_method']!="" ? $post['pay_method']:""; if($pay_method==""){ return error_show(1004,"账期类型不能为空"); } $pay_rate = isset($post['pay_rate'])&&is_array($post['pay_rate'])? $post['pay_rate']:[100]; $inv_rate = isset($post['inv_rate'])&&$post['inv_rate']!==""? $post['inv_rate']:""; if($inv_rate==""){ return error_show(1004,"发票税率不能为空"); } $rate = Db::name("order_rate")->where("id","=",$inv_rate)->find(); if(empty($rate)){ return error_show(1004,"未找到对应发票税率"); } $cgd = Db::name("cgd_info")->where([["id","in",$cids],["ShortText1617861287265","=",$supplierNo], ["status","=",0]] )->field("sequenceNo,`ShortText1619463208482` as inv_status,`ShortText1619463188366` as pay_status,Number1618330470625 as apay,Number1618330472961 as wpay,Number1618330541286 ainv,Number1618330543270 as winv,id")->select(); if(empty($cgd->toArray())){ return error_show(1004,"未找到有关的数据"); } $payNo = makeNo("PAY"); Db::startTrans(); try { $data=[]; $paydata=[ "payNo"=>$payNo, "creater"=>$effetc['data']['user']['id'], "apply_name"=>$guserinfo['data']['nickname'], "total_fee"=>0, "pay_fee"=>0, "supplierNo"=>$supplierNo, "invoiceNo"=>"", "run_fee"=>0, "pay_method"=>$pay_method, "pay_rate"=>json_encode($pay_rate), "wait_fee"=>0, "ainv_fee"=>0, "winv_fee"=>0, "inv_rate"=>$inv_rate, "remark"=>"", "status"=>1, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s"), ]; $invcom = ""; foreach ($cgd as $key=>$value){ $temp=[]; $coma =Db::name("cgd_inv")->where([['status',"=",2],['cgdNo',"=",$value['sequenceNo']]])->find(); if(empty($coma)){ Db::rollback(); return error_show(1003,"采购单{$value['sequenceNo']}未确认发票开票信息"); } if($invcom==""){ $invcom = $coma['companyNo']; }else{ if($invcom!=$coma['companyNo']){ Db::rollback(); return error_show(1003,"采购单{$value['sequenceNo']}发票开票信息不一致"); } } $temp['sequenceNo']=$value['sequenceNo']; $temp['total_fee']=($value['apay']*100+$value['wpay']*100)/100; $temp['pay_fee']=round($value['apay'],2); $temp['wait_fee']=round($value['wpay'],2); $temp['winv_fee']=round($value['winv'],2); $temp['ainv_fee']=round($value['ainv'],2); $temp['payNo']=$payNo; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $data[]=$temp; $paydata['total_fee']+= $temp['total_fee']; $paydata['wait_fee']+= $temp['wait_fee']; $paydata['pay_fee']+= $temp['pay_fee']; $paydata['ainv_fee']+= $temp['ainv_fee']; $paydata['winv_fee']+= $temp['winv_fee']; } if($invcom==""){ Db::rollback(); return error_show(1003,"采购单未确认发票开票信息"); } $paydata['total_fee']= round($paydata['total_fee'],2); $paydata['wait_fee']= round($paydata['wait_fee'],2); $paydata['pay_fee']= round($paydata['pay_fee'],2); $paydata['ainv_fee']= round($paydata['ainv_fee'],2); $paydata['winv_fee']= round($paydata['winv_fee'],2); if(count($pay_rate)>=1){ $paydata['run_fee'] = round($pay_rate[0],2); $paydata['wait_fee'] = round($paydata['total_fee']-$paydata['pay_fee'],2); //$paydata['wait_fee'] = round($paydata['total_fee']-$paydata['pay_fee']- $paydata['run_fee'],2);:ToDo } $info = Db::name("pay_info")->insertAll($data); if($info!=0){ $payDA=Db::name("pay")->insert($paydata); if($payDA){ $stage=[]; $pay=0; $tota= round(array_sum($pay_rate),2); if( $paydata['wait_fee']!= $tota){ return error_show(1005,'剩余待付金额未对账'); } foreach ($pay_rate as $key=>$value){ $temp=[]; $temp['payNo']=$payNo; $temp['dzNo']=makeNo("DZ"); if($paydata['wait_fee']>=$value){ $paydata['wait_fee']=round($paydata['wait_fee']-$value,2); $temp['pay_fee']=round($value,2); }else{ return error_show(1005,'待付金额不足于分期金额'); } $temp['pay_rate']=$value; $temp['pay_stages']=$key+1; $temp['status']=$paydata['winv_fee']==0?7: 0; $temp['pay_status']=$temp['pay_fee']==0?4: 0; $temp['return_img']=""; $temp['companyNo'] = $invcom; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $pay+=$temp['pay_fee']; $stage[] =$temp; } $pay_stage = Db::name("pay_stages")->insertAll($stage); if($pay_stage){ Db::name("cgd_info")->where("id","in",$cids)->save(['status'=>1,"check_rate"=>""]); Db::commit(); return app_show(0,"添加成功"); } } } Db::rollback(); return error_show(1003,"添加失败"); }catch(\Exception $e){ Db::rollback(); return error_show(1003,$e->getMessage()); } } /** * 保存新建的资源 * * @param \think\Request $request * @return \think\Response */ public function PayStatus() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $payNo = isset($post['payNo']) && $post['payNo']!="" ? trim($post['payNo']):""; if($payNo==""){ return error_show(1004,"参数payNo不能为空"); } $status= isset($post['status']) && $post['status']!=="" ? trim($post['status']):""; if($status===""){ return error_show(1004,"参数status不能为空"); } $data = Db::name("pay")->where("payNo","=",$payNo)->find(); if($data==false){ return error_show(1004,"未能找到对应数据"); } Db::startTrans(); try{ $result = Db::name("pay")->where("payNo","=",$payNo)->update(['status'=>$status]); if($result){ $cgd = Db::name("pay_info")->where([["payNo","=",$payNo],["status","=",1]])->column("sequenceNo"); if(!empty($cgd)){ Db::name("pay_info")->where([["payNo","=",$payNo],["status","=",1]])->save(['status'=>0,"updatetime"=>date("Y-m-d H:i:s")]); Db::name("pay_stages")->where([["payNo","=",$payNo],["is_del","=",0]])->save(['is_del'=>1, "updatetime"=>date("Y-m-d H:i:s")]); $update = Db::name("cgd_info")->where([["sequenceNo","in",$cgd],['status',"=",1]])->save(['status'=>0]); if($update){ Db::commit(); return app_show(0,"状态更新成功"); } } } Db::rollback(); return error_show(1004,"状态更新失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } // return $result ? app_show(0,"状态更新成功") : error_show(1004,"状态更新失败"); } /** * status 1申请付款 2 业务驳回 3发票已上传 4发票确认 5 财务审核发票 6 付款回执 7完成 0 取消申请 * * @param int $id * @return \think\Response */ public function BusAduit() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $payNo = isset($post['payNo'])&& $post['payNo']!="" ? trim($post['payNo']) :""; if($payNo==""){ return error_show(1004,"参数payNo 不能为空"); } $stageid = isset($post['sid'])&& $post['sid']!="" ? intval($post['sid']) :""; if($stageid==""){ return error_show(1004,"参数sid 不能为空"); } $status = isset($post['status'])&& $post['status']!="" ? intval($post['status']) :""; if($status==""){ return error_show(1004,"参数status 不能为空"); } if(!in_array($status,[1,2,3,4,5,6,0])){ return error_show(1004,"参数status 错误"); } $pay = Db::name("pay")->where(['payNo'=>$payNo])->find(); if(empty($pay)){ return error_show(1004,"未找到付款码{$payNo}的数据"); } if(!in_array($pay['status'],[0,1])){ return error_show(1004,"数据状态异常"); } $payStage = Db::name("pay_stages")->where([['id',"=",$stageid],['payNo',"=",$payNo],["is_del","=",0]])->find(); if(empty($payStage)){ return error_show(1005,"未找到付款申请信息"); } if($payStage["pay_stages"]>1){ $prev = $payStage["pay_stages"]-1; $prevStage = Db::name("pay_stages")->where([['pay_stages',"=",$prev],['payNo',"=",$payNo],["is_del","=",0]])->find(); if(empty($prevStage)){ return error_show(1004,"付款码{$payNo}上一期数据丢失"); } if($prevStage['status']!=7){ return error_show(1004,"付款码{$payNo}上一期数据流程正在进行中"); } } if($pay['winv_fee']==0){ $status=7; } $data=[ "status"=>$status, "updatetime"=>date("Y-m-d H:i:s") ]; // $companyNo=isset($post['companyNo'])&&$post['companyNo']!="" ? $post['companyNo'] :""; // if($status==3&& $payStage['status']==2 ){ // if($companyNo==""){ // return error_show(1005,"参数companyNo 不能为空"); // }else{ // $data['companyNo'] = $companyNo; // } // } $remark = isset($post['remark'])&&$post['remark']!="" ? $post['remark'] :""; if(($status==4 && $payStage['status']==5) || $status==2){ if($remark==""){ return error_show(1005,"参数remark 不能为空"); }else{ $data['remark'] = $remark; } } // $img = isset($post['image'])&&$post['image']!="" ? $post['image'] :""; // if($status==8 && $payStage['status']==7){ // if($img==""){ // return error_show(1005,"参数img 不能为空"); // }else{ // $data['return_img'] =$img; // } // } Db::startTrans(); try { $upd=Db::name("pay_stages")->where([['id',"=",$stageid],['payNo',"=",$payNo],["is_del","=",0]])->save($data); if($upd){ if($status==7){ // if($pay['wait_fee']<$payStage['pay_fee']){ // Db::rollback(); // return error_show(1005,"付款金额与待付款金额不符"); // } // $pay['wait_fee'] = $pay['wait_fee'] - $payStage['pay_fee']; // $pay['run_fee'] = $pay['run_fee'] - $payStage['pay_fee'];//::ToDo // $pay['pay_fee'] = $pay['pay_fee']+ $payStage['pay_fee']; $num = Db::name("pay_stages")->whereOr([['status',"<>",7],['pay_status',"<>",4]])->where ([['payNo',"=", $pay['payNo']],["is_del","=",0]])->count(); if($num==0){ $pay['status']=2; } $pay['updatetime']=date("Y-m-d H:i:s"); $pay_up = Db::name("pay")->save($pay); if($pay_up){ Db::commit(); return app_show(0,"状态修改成功"); }else{ Db::rollback(); return error_show(1004,"状态修改失败"); } } Db::commit(); return app_show(0,"状态修改成功"); }else{ Db::rollback(); return error_show(1004,"状态修改失败"); } }catch (\Exception $e){ Db::rollback(); return error_show(1005,$e->getMessage()); } } /** * 显示编辑资源表单页. * 付款审核状态 0 待付款 1 付款待审核 2 审核通过 3 审核未通过 * @param int $id * @return \think\Response */ public function PayExam() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } // $payNo = isset($post['payNo'])&& $post['payNo']!="" ? trim($post['payNo']) :""; // if($payNo==""){ // return error_show(1004,"参数payNo 不能为空"); // } $stageid = isset($post['sid'])&& $post['sid']!="" ? intval($post['sid']) :""; if($stageid==""){ return error_show(1004,"参数sid 不能为空"); } $status = isset($post['status'])&& $post['status']!="" ? intval($post['status']) :""; if($status==""){ return error_show(1004,"参数status 不能为空"); } if(!in_array($status,[0,1,2,3,4,5])){ return error_show(1004,"参数status 无效值"); } $payment= Db::name("pay_ment")->where([['sid',"=",$stageid],['status',"<>",0]])->find(); if(empty($payment)){ return error_show(1005,"未找到付款申请信息"); } if(($status==1 && (!in_array($payment['pay_status'],[0,5,6]))) || ($status==2 && $payment['pay_status']!=1) || ($status==3 && $payment['pay_status']!=2) ||($status==4 && $payment['pay_status']!=3)){ return error_show(1005,"数据状态有误"); } $remark = isset($post['remark'])? trim($post['remark']) :""; $image = isset($post['image'])? trim($post['image']) :""; if($status==4 && $image==""){ return error_show(1005,"付款回单图片不能为空"); } $paytime = isset($post['paytime'])&&$post['paytime']!=""?$post['paytime'] :date("Y-m-d H:i:s"); Db::startTrans(); try{ $status==1&&$payment['dpay_fee']==0 ? $status =4 : ""; $data = [ "pay_status"=>$status, "pay_remark"=>$remark, "return_img"=>$image!=""?$image :$payment['return_img'] ]; if($status==4){ $data['paytime']=$paytime; } $upd=Db::name("pay_stages")->where([['id',"=",$stageid],["is_del","=",0]])->save($data); if($upd){ if($status==4){ $num = Db::name("pay_stages")->whereOr([['status',"<>",7],['pay_status',"<>",4]])->where ([['payNo',"=", $payment['payNo']],["is_del","=",0]])->count(); if($num==0){ $pay_up = Db::name("pay")->where('payNo',"=",$payment['payNo'])->save(["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]); if($pay_up){ Db::commit(); return app_show(0,"状态修改成功"); }else{ Db::rollback(); return error_show(1004,"状态修改失败"); } } } if($status==3){ if($payment['wait_fee']<$payment['dpay_fee']){ Db::rollback(); return error_show(1005,"付款金额与待付款金额不符"); } $pay=[ "wait_fee"=>$payment['wait_fee']-$payment['dpay_fee'], "pay_fee"=>$payment['pay_fee']+$payment['dpay_fee'], "updatetime"=>date("Y-m-d H:i:s") // "run_fee"=>$payment['run_fee']-$payment['dpay_fee'], ]; $pay_up = Db::name("pay")->where('payNo',"=",$payment['payNo'])->save($pay); if($pay_up){ Db::commit(); return app_show(0,"状态修改成功"); }else{ Db::rollback(); return error_show(1004,"状态修改失败"); } } Db::commit(); return app_show(0,"状态修改成功"); }else{ Db::rollback(); return error_show(1003,"状态修改失败"); } }catch (\Exception $e){ Db::rollback(); return error_show(1008,$e->getMessage()); } } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function CgdList() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $userinfo = GetUserInfo($token); if(!isset($userinfo['code'])|| $userinfo['code']!=0){ return error_show(101,'未能获取用户信息'); } $condition = [["a.status","=",0 ]]; $check = checkRole($userinfo['data']['roleid'],46); if($check){ $condition []=["a.ownerName","=",$userinfo['data']['nickname']]; } $name= isset($post['name'])&&$post['name']!="" ? trim($post['name']) :""; if($name!=""){ $condition[]=["b.name","like","%{$name}%"]; } $code= isset($post['code'])&&$post['code']!="" ? trim($post['code']) :""; if($code!=""){ $condition[]=["b.code", "=",$code]; } $cgdNo = isset($post["sequenceNo"]) && $post["sequenceNo"]!="" ? $post["sequenceNo"] : ""; if($cgdNo!=""){ // $condition[]=[" `a`.`ShortText1618315935182` like '%{$cgdNo}%'"; $condition[]=["a.ShortText1618315935182", "like","%{$cgdNo}%"]; } $invcom= isset($post["inv_company"]) && $post["inv_company"]!="" ? $post["inv_company"] : ""; if($invcom!=""){ // $condition[]=[" `c`.`companyNo` = '{$invcom}'"; $condition[]=["b.companyNo", "=",$invcom]; } $invstatus= isset($post["inv_status"]) && $post["inv_status"]!=="" ? $post["inv_status"] : ""; if($invstatus!==""){ $cgdnp = Db::name("cgd_inv")->where(["status"=>$invstatus])->column("cgdNo"); $condition[]=["a.sequenceNo","in",$cgdnp]; } $send_status= isset($post["send_status"]) && $post["send_status"]!=="" ? $post["send_status"] : ""; if($send_status!==""){ $condition[]=["a.ShortText1618859321070","=",$send_status]; } $th_status= isset($post["th_status"]) && $post["th_status"]!=="" ? $post["th_status"] : ""; if($th_status!==""){ // $condition[]=["a.th_status = '{$th_status}'"; $condition[]=["a.th_status","=",$th_status]; } $payinfo= isset($post["payinfo"]) && $post["payinfo"]!=="" ? $post["payinfo"] : ""; if($payinfo!==""){ // $condition[]=[" `a`.`ShortText1619463188366` = '{$payinfo}'"; $condition[]=["a.ShortText1619463188366","=",$payinfo]; } $invinfo= isset($post["invinfo"]) && $post["invinfo"]!=="" ? $post["invinfo"] : ""; if($invinfo !==""){ $condition[]=["a.ShortText1619463208482", "=", $invinfo]; } $owner= isset($post['owner'])&&$post['owner']!="" ? trim($post['owner']) :""; if($owner!=""){ $condition[]=["a.ownerName","like", "%{$owner}%"]; } $goodNo= isset($post['goodNo'])&&$post['goodNo']!="" ? trim($post['goodNo']) :""; if($goodNo!=""){ $condition[]=["a.ShortText1617861001482", "like", "%{$goodNo}%"]; } $page = isset($post['page'])&&$post['page']!="" ? intval($post['page']) :0; $size = isset($post['size'])&&$post['size']!="" ? intval($post['size']) :10; $count = Db::name("cgd_info")->alias('a')->join('cfp_supplier_info b','a.ShortText1617861287265=b.code','left') ->where($condition)->count(); // echo Db::name("cgd_info")->getLastSql(); $total = ceil($count/$size)>1 ? ceil($count/$size) : 1; $page = $page>=$total?intval($total):$page; $list = Db::name("cgd_info")->alias('a')->join('cfp_supplier_info b','a.ShortText1617861287265=b.code','left') ->where($condition)->page($page,$size)->order('a.Date1618315953443 desc')->field("a.id, `a`.`sequenceNo` AS `sequenceNo`, `a`.`ownerName` AS `ownerName`, `a`.`department` AS `department`, b.code as supplierNo, `a`.`ShortText1618315935182` AS `cgdNO`, `b`.`name` AS `name`, `b`.`contector` AS `contector`, `b`.`mobile` AS `mobile`, `a`.`ShortText1617861001482` AS `goodNo`, `a`.`ShortText1617861966146` AS `goodName`, `a`.`ShortText1617865626160` AS `goodType`, `a`.`ShortText1617865633070` AS `goodBank`, `a`.`ShortText1617865675342` AS `goodModel`, `a`.`ShortText1617865678025` AS `goodMaterial`, `a`.`ShortText1617865680605` AS `goodColor`, `a`.`text1618268357055` AS `goodDesc`, `a`.`ShortText1617865685744` AS `goodUnit`, `a`.`ShortText1618240134229` AS `goodCat`, ifnull( `a`.`Number1618240480148`, '0' ) AS `weight`, ifnull( `a`.`Number1618240458074`, '0' ) AS `price`, `a`.`ShortText1617866158120` AS `isDiff`, `a`.`number1618240356104` AS `workDay`, `a`.`ShortText1617865688485` AS `taxPoint`, ifnull(`a`.`Number1617865804813`,0) AS `nakedPrice`, ifnull(`a`.`Number1617865807879`,0) AS `markPrice`, ifnull(`a`.`Number1617865810822`,0) AS `packPrice`, ifnull(`a`.`Number1617865813284`,0) AS `certPrice`, ifnull(`a`.`Number1617865816181`,0) AS `openPrice`, ifnull(`a`.`number1618240204358`,0) AS `craftPrice`, ifnull(`a`.`number1618240287778`,0) AS `postPrice`, ifnull(`a`.`Number1617865818517`,0) AS `totalPrice`, ifnull(`a`.`Number1618240685904`,0) AS `purchasePrice`, ifnull(`a`.`Number1618240600907`,0) AS `orderNum`, ifnull(`a`.`Number1618330470625`,0) AS `pay_fee`, ifnull(`a`.`Number1618330472961`,0) AS `wait_fee`, ifnull(`a`.`Number1618330541286`,0) AS `inv_open_fee`, ifnull(`a`.`Number1618330543270`,0) AS `inv_wait_fee`, `a`.`ShortText1619463188366` AS `payinfo`, `a`.`ShortText1619463208482` AS `invinfo`, a.th_status as th_info, ifnull(a.Number1619625470651,0) as th_num, ifnull(a.Number1619625483510,0) as th_fee, a.ShortText1618859321070 as send_info, `a`.`Number1619632826654` AS `diff_fee`, `a`.`Number1619632830397` AS `diff_info`, createdTime, a.Date1618315953443 as DownTime, IF (( `a`.`sequenceStatus` = 'COMPLETED' ), 2, 1 ) AS `order_status` ")->select(); $data = []; foreach ($list as $key=>$value){ $value['pay_price'] = sprintf( "%.2f",$value['totalPrice']*$value['orderNum']); $value['purchasePrice']-= $value['th_fee']; $value['orderNum']-= $value['th_num']; // ifnull( `c`.`companyNo`, '' ) AS `inv_company`, // ifnull( `c`.`status`, '0' ) AS `inv_status`, // ifnull( `c`.`id`, '0' ) AS `invid`", $cgdinvfo = Db::name("cgd_inv")->where(["cgdNo"=>$value['sequenceNo']])->find(); $value['inv_company'] = isset($cgdinvfo['companyNo'])&&$cgdinvfo['companyNo']!="" ? trim($cgdinvfo['companyNo']) :''; $value['inv_status'] = isset($cgdinvfo['status'])&&$cgdinvfo['status']!=="" ? $cgdinvfo['status'] :''; $value['invid'] = isset($cgdinvfo['id'])&&$cgdinvfo['id']!="" ? intval($cgdinvfo['id']) :''; if($value['inv_company']!=""){ $invcom = Db::name("company_info")->where([['companyNo',"=",$value['inv_company']],['status',"=",1]]) ->find(); $value['inv_company_name'] =isset($invcom['company_name']) ? $invcom['company_name']:""; }else{ $value['inv_company_name'] =""; } $data[]=$value; } return app_show(0,"获取成功",["list"=>$data,"count"=>$count]); } public function PayInfo() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $sid = isset($post['sid'])&& $post['sid']!="" ? intval($post['sid']) :""; if($sid==""){ return error_show(1004,"参数sid 不能为空"); } $payinfo = Db::name("pay_ment")->where("sid","=",$sid)->field("id,payNo,contector,supplierNo,name,pay_method,pay_rate,dpay_fee,inv_rate,rate,dpay_rate,pay_stages,return_img,remark,pay_status,dstatus,pay_remark")->find(); if(empty($payinfo)){ return error_show(1004,"付款申请信息未找到"); } $payinfo['return_img'] = isset($payinfo['return_img']) && $payinfo['return_img']!="" ? explode(",",$payinfo['return_img']):""; $paylist = Db::name("pay_info")->where([["payNo","=",$payinfo['payNo']],["status","=",1]])->column("sequenceNo"); $payinfo['list']=[]; if($paylist){ $list = Db::name("cgd_info")->alias('a')->join('cfp_supplier_info b','a.ShortText1617861287265=b.code','left') ->join("cfp_cgd_inv c",'c.cgdNo=a.sequenceNo','left') ->where([["a.sequenceNo","in",$paylist],["a.status","=",1]])->field("a.id, `a`.`sequenceNo` AS `sequenceNo`, `a`.`ownerName` AS `ownerName`, `a`.`department` AS `department`, b.code as supplierNo, `a`.`ShortText1618315935182` AS `cgdNO`, `b`.`name` AS `name`, `b`.`contector` AS `contector`, `b`.`mobile` AS `mobile`, `a`.`ShortText1617861001482` AS `goodNo`, `a`.`ShortText1617861966146` AS `goodName`, `a`.`ShortText1617865626160` AS `goodType`, `a`.`ShortText1617865633070` AS `goodBank`, `a`.`ShortText1617865675342` AS `goodModel`, `a`.`ShortText1617865678025` AS `goodMaterial`, `a`.`ShortText1617865680605` AS `goodColor`, `a`.`text1618268357055` AS `goodDesc`, `a`.`ShortText1617865685744` AS `goodUnit`, `a`.`ShortText1618240134229` AS `goodCat`, ifnull( `a`.`Number1618240480148`, '0' ) AS `weight`, ifnull( `a`.`Number1618240458074`, '0' ) AS `price`, `a`.`ShortText1617866158120` AS `isDiff`, `a`.`number1618240356104` AS `workDay`, `a`.`ShortText1617865688485` AS `taxPoint`, `a`.`Number1617865804813` AS `nakedPrice`, `a`.`Number1617865807879` AS `markPrice`, `a`.`Number1617865810822` AS `packPrice`, `a`.`Number1617865813284` AS `certPrice`, `a`.`Number1617865816181` AS `openPrice`, `a`.`number1618240204358` AS `craftPrice`, `a`.`number1618240287778` AS `postPrice`, `a`.`Number1617865818517` AS `totalPrice`, `a`.`Number1618240685904` AS `purchasePrice`, `a`.`Number1618240600907` AS `orderNum`, `a`.`Number1618330470625` AS `pay_fee`, `a`.`Number1618330472961` AS `wait_fee`, `a`.`Number1618330541286` AS `inv_open_fee`, `a`.`Number1618330543270` AS `inv_wait_fee`, `a`.`ShortText1619463188366` AS `payinfo`, `a`.`ShortText1619463208482` AS `invinfo`, a.th_status as th_info, a.ShortText1618859321070 as send_info, `a`.`Number1619632826654` AS `diff_fee`, `a`.`Number1619632830397` AS `diff_info`, createdTime, a.Date1618315953443 as DownTime, IF (( `a`.`sequenceStatus` = 'COMPLETED' ), 2, 1 ) AS `order_status`, ifnull( `c`.`companyNo`, '' ) AS `inv_company`, ifnull( `c`.`status`, '0' ) AS `inv_status`, ifnull( `c`.`id`, '0' ) AS `invid`") ->select(); $data=[]; foreach ($list as $key=>$value){ $value['pay_price'] =sprintf( "%.2f",$value['totalPrice']*$value['orderNum']); if($value['inv_company']!=""){ $invcom = Db::name("company_info")->where([['companyNo',"=",$value['inv_company']],['status',"=",1]]) ->find(); $value['inv_company_name'] =isset($invcom['company_name']) ? $invcom['company_name']:""; }else{ $value['inv_company_name'] =""; } $data[]=$value; } $payinfo['list']=$data; } return app_show(0,"获取成功",$payinfo); } /** * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function PaySave(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $payNo = isset($post['payNo'])&&$post['payNo']!="" ? trim($post['payNo']) :""; if($payNo==""){ return error_show(1003,"参数payNo 不能为空"); } $pay = Db::name("pay")->where("payNo","=",$payNo)->find(); if(empty($pay)){ return error_show(1003,"对账数据不存在"); } $payStage= Db::name("pay_stages")->where([["is_del","=",0],["payNo","=",$payNo],["status","<>",0]]) ->count(); $payT= Db::name("pay_stages")->where([["is_del","=",0],["payNo","=",$payNo],["status","=",2]]) ->count(); if($payStage!=0&&$payT==0){ return error_show(1003,"对账已申请付款无法修改"); } $inv_rate = isset($post['inv_rate'])&&$post['inv_rate']!==""? $post['inv_rate']:""; if($inv_rate===""){ return error_show(1004,"发票税率不能为空"); } $rate = Db::name("order_rate")->where("id","=",$inv_rate)->find(); if(empty($rate)){ return error_show(1004,"未找到对应发票税率"); } $paystatus= Db::name("pay_stages")->where([["is_del","=",0],["payNo","=",$payNo],["pay_status","<>",0]]) ->count(); if($paystatus!=0 || $payT>0){ $pay['inv_rate'] = $inv_rate; $pay['updatetime'] = date("Y-m-d H:i:s"); $payDAba=Db::name("pay")->save($pay); if($payDAba){ return app_show(0,"税率修改成功"); }else{ return error_show(1005,"税率修改失败"); } } $cids = isset($post['cids'])&&$post['cids']!="" ? trim($post['cids']) :""; if($cids==""){ return error_show(1003,"参数cids不能为空"); } $supplierNo = isset($post['supplierNo'])&&$post['supplierNo']!="" ? trim($post['supplierNo']) :""; if($supplierNo==""){ return error_show(1003,"参数supplierNo不能为空"); } $pay_method = isset($post['pay_method'])&&$post['pay_method']!="" ? $post['pay_method']:""; if($pay_method==""){ return error_show(1004,"账期类型不能为空"); } $pay_rate = isset($post['pay_rate'])&&is_array($post['pay_rate'])? $post['pay_rate']:[100]; Db::startTrans(); $payinfo = Db::name("pay_info")->where([['payNo',"=",$payNo],['status',"=",1]])->column("sequenceNo"); $reset = Db::name("cgd_info")->where([["sequenceNo","in",$payinfo],["ShortText1617861287265","=",$pay['supplierNo']], ["status","=",1]] )->save(["status"=>0,"check_rate"=>""]); if($reset==false){ Db::rollback(); return error_show(1004,"采购单状态修改失败!"); }else{ $delpay = Db::name("pay_info")->where([['payNo',"=",$payNo],['status',"=",1]])->save(["status"=>0]); if($delpay==false){ Db::rollback(); return error_show(1004,"采购单关联失败!"); } $delstage = Db::name("pay_stages")->where([['payNo',"=",$payNo],['is_del',"=",0]])->save(["is_del"=>1]); if($delstage==false){ Db::rollback(); return error_show(1004,"对账单付款修改失败!"); } } $cgd = Db::name("cgd_info")->where([["id","in",$cids],["ShortText1617861287265","=",$supplierNo],["status","=",0]] )->field("sequenceNo,`ShortText1619463208482` as inv_status,`ShortText1619463188366` as pay_status,Number1618330470625 as apay,Number1618330472961 as wpay,Number1618330541286 ainv,Number1618330543270 as winv,id")->select(); if(empty($cgd->toArray())){ return error_show(1004,"未找到有关的数据"); } try { $data=[]; $paydata=[ "payNo"=>$payNo, "id"=>$pay['id'], "creater"=>$effetc['data']['user']['id'], "total_fee"=>0, "pay_fee"=>0, "supplierNo"=>$supplierNo, "invoiceNo"=>"", "run_fee"=>$pay['run_fee'], "pay_method"=>$pay_method, "pay_rate"=>json_encode($pay_rate), "wait_fee"=>0, "ainv_fee"=>0, "winv_fee"=>0, "inv_rate"=>$inv_rate, //"inv_rate"=>0, "remark"=>"", "status"=>1, "updatetime"=>date("Y-m-d H:i:s"), ]; $invcom=""; foreach ($cgd as $key=>$value){ $temp=[]; $coma =Db::name("cgd_inv")->where([['status',"=",2],['cgdNo',"=",$value['sequenceNo']]])->find(); if(empty($coma)){ Db::rollback(); return error_show(1003,"采购单{$value['sequenceNo']}未确认发票开票信息"); } if($invcom==""){ $invcom = $coma['companyNo']; }else{ if($invcom!=$coma['companyNo']){ Db::rollback(); return error_show(1003,"采购单{$value['sequenceNo']}发票开票信息不一致"); } } $temp['sequenceNo']=$value['sequenceNo']; $temp['total_fee']=($value['apay']*100+$value['wpay']*100)/100; $temp['pay_fee']=round($value['apay'],2); $temp['wait_fee']=round($value['wpay'],2); $temp['winv_fee']=round($value['winv'],2); $temp['ainv_fee']=round($value['ainv'],2); $temp['payNo']=$payNo; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $data[]=$temp; $paydata['total_fee']+= $temp['total_fee']; $paydata['wait_fee']+= $temp['wait_fee']; $paydata['pay_fee']+= $temp['pay_fee']; $paydata['ainv_fee']+= $temp['ainv_fee']; $paydata['winv_fee']+= $temp['winv_fee']; } $paydata['total_fee']= round($paydata['total_fee'],2); $paydata['wait_fee']= round($paydata['wait_fee'],2); $paydata['pay_fee']= round($paydata['pay_fee'],2); $paydata['ainv_fee']= round($paydata['ainv_fee'],2); $paydata['winv_fee']= round($paydata['winv_fee'],2); if(count($pay_rate)>=1){ $paydata['run_fee'] = round($pay_rate[0],2); $paydata['wait_fee'] = round($paydata['total_fee']-$paydata['pay_fee'],2); //$paydata['wait_fee'] = round($paydata['total_fee']-$paydata['pay_fee']- $paydata['run_fee'],2);:ToDo } $info = Db::name("pay_info")->insertAll($data); if($info!=0){ $payDA=Db::name("pay")->save($paydata); if($payDA){ $stage=[]; $pay=0; $tota= round(array_sum($pay_rate),2); if( $paydata['wait_fee']!= $tota){ return error_show(1005,'剩余待付金额未对账'); } foreach ($pay_rate as $key=>$value){ $temp=[]; $temp['payNo']=$payNo; $temp['dzNo']=makeNo("DZ"); if($paydata['wait_fee']>=$value){ $paydata['wait_fee']=round($paydata['wait_fee']-$value,2); $temp['pay_fee']=round($value,2); }else{ return error_show(1005,'待付金额不足于分期金额'); } $temp['pay_rate']=$value; $temp['pay_stages']=$key+1; $temp['return_img']=""; $temp['status']=$paydata['winv_fee']==0?7: 0; $temp['pay_status']=$temp['pay_fee']==0?4: 0; $temp['companyNo'] = $invcom; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $pay+=$temp['pay_fee']; $stage[] =$temp; } $pay_stage = Db::name("pay_stages")->insertAll($stage); if($pay_stage){ Db::name("cgd_info")->where("id","in",$cids)->save(['status'=>1,"check_rate"=>""]); Db::commit(); return app_show(0,"修改成功"); } } } Db::rollback(); return error_show(1003,"修改失败"); }catch(\Exception $e){ Db::rollback(); return error_show(1003,$e->getMessage()); } } /** * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function CgdInv(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $cgd = isset($post['cgd'])&&$post['cgd']!='' ? $post['cgd']:""; if($cgd==""){ return error_show(1004,"参数cgd 不能为空"); } if(!is_array($cgd)){ return error_show(1004,"参数cgd 无效数据"); } // $cgd = Db::name("cgd_info")->where([["status","=",0],["sequenceNo","in",$cids]])->field("id,sequenceNo,ShortText1617861287265 as gys") // ->select()->toArray(); // if(empty($cgd)){ // return error_show(1004,"未找到绑定的数据"); // } // $company = isset($post['companyNo'])&&$post['companyNo']!="" ? $post['companyNo']:""; // if($company==""){ // return error_show(1003,"参数companyNo 不能为空"); // } // $companyinfo = Db::name("company_info")->where([["status","=",1],["companyNo","=",$company]])->find(); // if(empty($companyinfo)){ // return error_show(1004,"企业开票信息未找到"); // } Db::startTrans(); try{ foreach ($cgd as $value){ if(!isset($value['cgdNo'])||$value['cgdNo']==""){ Db::rollback(); return error_show(1003,"参数cgdNo 不能为空"); } if(!isset($value['companyNo'])||$value['companyNo']==""){ Db::rollback(); return error_show(1003,"参数companyNo 不能为空"); } $cgdinfo = Db::name("cgd_info")->where([["sequenceNo","=",$value['cgdNo']]])->field("id,sequenceNo,ShortText1617861287265 as gys,status")->find(); if(empty($cgdinfo)){ Db::rollback(); return error_show(1004,"未找到采购单{$value['cgdNo']}数据"); } if($cgdinfo['status']!=0){ Db::rollback(); return error_show(1004,"采购单{$value['cgdNo']}数据正在对账中"); } $companyinfo = Db::name("company_info")->where([["status","=",1],["companyNo","=",$value['companyNo']]])->find(); if(empty($companyinfo)){ Db::rollback(); return error_show(1004,"企业开票信息未找到"); } $inv = Db::name("cgd_inv")->where("cgdNo","=",$value['cgdNo'])->find(); if($inv){ $inv['companyNo']=$value['companyNo']; $inv['sup_company']=$cgdinfo['gys']; $inv['status']=1; $inv['updatetime']=date("Y-m-d H:i:s"); $que = Db::name("cgd_inv")->save($inv); }else{ $inv = [ "cgdNo"=> $value['cgdNo'], "companyNo"=> $value['companyNo'], "sup_company"=> $cgdinfo['gys'], "status"=> 1, "addtime"=> date("Y-m-d H:i:s"), "updatetime"=> date("Y-m-d H:i:s") ]; $que = Db::name("cgd_inv")->insert($inv); } if($que==false){ Db::rollback(); return error_show(1004,"采购单{$value['cgdNo']}数据关联失败"); } } Db::commit(); return app_show(0,"开票信息关联成功"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } /** * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function CgdExam(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $cgdinv = isset($post['cgdinv'])&& $post['cgdinv']!="" ? $post['cgdinv'] :""; if($cgdinv==""){ return error_show(1004,"参数cgdinv 不能为空"); } if(!is_array($cgdinv)){ return error_show(1004,"参数cgdinv 无效数据"); } Db::startTrans(); try { foreach ($cgdinv as $value){ $info = Db::name("cgd_inv")->where('cgdNo',"=",$value['invid'])->find(); if(empty($info)){ Db::rollback(); return error_show(1004,"未找到{$value['invid']}对应的关联数据"); } if($info['status']!=1){ Db::rollback(); return error_show(1004,"采购单{$info['cgdNo']}状态异常"); } if(!in_array($value['status'],[0,1,2,3])){ Db::rollback(); return error_show(1004,"参数status 无效值"); } $inv=["status"=>$value['status'],"remark"=>$value['remark'],"updatetime"=>date("Y-m-d H:i:s")]; $save= Db::name("cgd_inv")->where('cgdNo',"=",$value['invid'])->save($inv); if(!$save){ Db::rollback(); return error_show(1004,"采购单{$info['cgdNo']}状态更新失败"); } } Db::commit(); return app_show(0,"采购单关联状态更新成功"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } /** * status 1申请付款 2 业务驳回 3发票已上传 4发票确认 5 财务审核发票 6 付款回执 7完成 0 取消申请 * * @param int $id * @return \think\Response */ public function InvReset() { $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $stageid = isset($post['sid'])&& $post['sid']!="" ? intval($post['sid']) :""; if($stageid==""){ return error_show(1004,"参数sid 不能为空"); } $payStage = Db::name("pay_stages")->where([['id',"=",$stageid],["is_del","=",0]])->find(); if(empty($payStage)){ return error_show(1005,"未找到付款申请信息"); } $pay = Db::name("pay")->where(['payNo'=>$payStage['payNo']])->find(); if(empty($pay)){ return error_show(1004,"未找到对账的数据"); } if(!in_array($pay['status'],[0,1])){ return error_show(1004,"数据状态异常"); } if($payStage["pay_stages"]>1){ $prev = $payStage["pay_stages"]-1; $prevStage = Db::name("pay_stages")->where([['pay_stages',"=",$prev],['payNo',"=",$payStage['payNo']],["is_del","=",0]])->find(); if(empty($prevStage)){ return error_show(1004,"对账上一期数据丢失"); } if($prevStage['status']!=7){ return error_show(1004,"对账上一期数据流程正在进行中"); } } $data=[ "status"=>3, "updatetime"=>date("Y-m-d H:i:s") ]; Db::startTrans(); try { $upd=Db::name("pay_stages")->where([['id',"=",$stageid],['payNo',"=",$payStage['payNo']],["is_del","=",0]])->save($data); if($upd){ Db::commit(); return app_show(0,"状态修改成功"); }else{ Db::rollback(); return error_show(1004,"状态修改失败"); } }catch (\Exception $e){ Db::rollback(); return error_show(1005,$e->getMessage()); } } /**退货详情 * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function thinfo(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $type = isset($post['type'])&&$post['type']!=="" ? $post['type'] :1; $codeNo = isset($post['codeNo'])&&$post['codeNo']!=="" ? trim($post['codeNo']) :''; $condition =[]; if($type==1&&$codeNo!=""){ $condition[]=['th_cgdNo',"=",$codeNo]; } if($type==2&&$codeNo!=""){ $condition[]=['th_qrdNo',"=",$codeNo]; } if($type==3&&$codeNo!=""){ $condition[]=['th_qrdcpNo',"=",$codeNo]; } $status = isset($post['status'])&&$post['status']!=="" ? $post['status'] :''; if($status!=""){ $condition[]=['th_status',"=",$status]; } $company = isset($post['company'])&&$post['company']!=="" ? trim($post['company']) :''; if($company!=""){ $condition[]=['th_company',"like","%{$company}%"]; } $page = isset($post['page'])&&$post['page']!="" ? intval($post['page']) :1; $size = isset($post['size'])&&$post['size']!="" ? intval($post['size']) :10; $count = Db::name('th_source')->where($condition)->count(); $total = ceil($count/$size)>1 ? ceil($count/$size) : 1; $page = $page>=$total?intval($total):$page; $thinfo = Db::name('th_source')->where($condition)->page(intval($page),$size)->order("createtime desc")->select(); return app_show(0,"获取成功",["list"=>$thinfo,"count"=>$count]); } public function UnPay(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $codeNo = isset($post['id'])&&$post['id']!=="" ? trim($post['id']) :''; if($codeNo===""){ return error_show(1004,'参数id 不能为空'); } $update = Db::name('cgd_info')->where("id","in",$codeNo)->update(['status'=>2]); // echo Db::name('cgd_info')->getLastSql(); if($update){ return app_show(0,'更新成功'); }else{ return error_show(1004,'更新失败'); } } }