123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- <?php
- namespace app\admin\controller;
- use app\admin\model\CgdInfo;use app\admin\model\OrderTag;
- use app\admin\model\Pay;
- use app\admin\model\QrdInfo;
- use app\admin\model\TagLog;
- use think\App;
- use think\facade\Db;use think\facade\Validate;
- class TagGood extends Base{
- // public $novalidate=['*'];
- public function __construct(App $app) {parent::__construct($app);}
- //新建标签
- public function create(){
- $post = $this->post;
- $type = isset($post['type'])&& $post['type']!="" ? intval($post['type']) :"";
- if($type==''){
- return error_show(1004,"参数 type 不能未空");
- }
- if($post['relaComNo']!=""){
- $companyNo = isset($post['relaComNo'])&& $post['relaComNo']!="" ? trim($post['relaComNo']) :"";
- }else{
- $companyNo = isset($post['companyNo'])&& $post['companyNo']!="" ? trim($post['companyNo']) :"";
- }
- if($companyNo==''){
- return error_show(1004,"参数 companyNo 不能未空");
- }
- $tagName =isset($post['tag_name'])&&$post['tag_name']!='' ? trim($post['tag_name']):"";
- if($tagName==''){
- return error_show(1004,"参数 tag_name 不能未空");
- }
- $isT =Db::name("order_tag")->where(["type"=>$type,"companyNo"=>$companyNo,"tag_name"=>$tagName,"is_del"=>0])
- ->findOrEmpty();
- if(!empty($isT)){
- return error_show(1004,"标签名称已存在");
- }
- $tagData=[
- "type"=>$type,
- "tag_name"=>$tagName,
- "status"=>1,
- "companyNo"=>$companyNo,
- "apply_id"=>$this->uid,
- "apply_name"=>$this->uname,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $ins=Db::name("order_tag")->insert($tagData);
- return $ins?app_show(0,"标签新建成功"): error_show(1004,"标签新建失败");
- }
- //标签列表翻页
- public function list(){
- $page = isset($this->post['page'])&&$this->post['page']!=''?intval($this->post['page']):1;
- $size = isset($this->post['size'])&&$this->post['size']!=''?intval($this->post['size']):15;
- $type = isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):'';
- $status = isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):'';
- if(isset($this->post['relaComNo']) && $this->post['relaComNo']!=""){
- $companyNo = isset($this->post['relaComNo'])&& $this->post['relaComNo']!="" ? trim($this->post['relaComNo']) :"";
- }else{
- $companyNo = isset($this->post['companyNo'])&& $this->post['companyNo']!="" ? trim($this->post['companyNo']) :"";
- }
- $condition =[["is_del","=",0]];
- $roleid = $this->roleid;
- $check = checkRole($roleid,'101');
- if($check){
- $condition[]=["apply_id","=",$this->uid];
- }
- if($type!=''){
- $condition[]=["type","=",$type];
- }
- if($status!==''){
- $condition[]=["status","=",$status];
- }
- $tagName =isset($this->post['tag_name'])&&$this->post['tag_name']!='' ? trim($this->post['tag_name']):"";
- if($tagName!=''){
- $condition[]=["tag_name","like","%$tagName%"];
- }
- if($companyNo!=''){
- $condition[]=["companyNo","=",$companyNo];
- }
- $count =Db::name("order_tag")->where($condition)->count();
- $total=ceil($count/$size);
- $page = $page>=$total ? intval($total):$page;
- $list =Db::name("order_tag")->where($condition)->page($page,$size)->order("addtime desc")->select()->toArray();
- $comNo=array_column($list,"companyNo");
- $ComArr=Db::connect("mysql_sys")->name("headquarters")->where(["code"=>$comNo])->column("name","code");
- foreach ($list as &$item){
- $item['companyName']=$ComArr[$item['companyNo']]??"";
- }
- return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
- }
- //根据条件筛选合适的标签数据
- public function query(){
- $type = isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):'';
- $condition =[["is_del","=",0]];
- if($type!=''){
- $condition[]=["type","=",$type];
- }
- if($this->post['relaComNo']!=""){
- $companyNo = isset($this->post['relaComNo'])&& $this->post['relaComNo']!="" ? trim($this->post['relaComNo']) :"";
- }else{
- $companyNo = isset($this->post['companyNo'])&& $this->post['companyNo']!="" ? trim($this->post['companyNo']) :"";
- }
- if($companyNo!=''){
- $condition[]=["companyNo","=",$companyNo];
- }
- $tagName =isset($this->post['tag_name'])&&$this->post['tag_name']!='' ? trim($this->post['tag_name']):"";
- if($tagName!=''){
- $condition[]=["tag_name","like","%$tagName%"];
- }
- $status = isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):'';
- if($status!==''){
- $condition[]=["status","=",$status];
- }
- $list =Db::name("order_tag")->where($condition)->order("addtime desc")->select()->toArray();
- return app_show(0,"获取成功",$list);
- }
- //启禁用状态
- public function status(){
- $id =isset($this->post['id'])&&$this->post['id']!=''?intval($this->post['id']):'';
- if($id==''){
- return error_show(1004,"参数 id 不能为空");
- }
- $taginfo =Db::name("order_tag")->find(["id"=>$id]);
- if($taginfo==false){
- return error_show(1004,"标签数据不存在");
- }
- $status=isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):'';
- if($status===''){
- return error_show(1004,"参数 status 不能为空");
- }
- $update =["status"=>$status,"updatetime"=>date("Y-m-d H:i:s")];
- $up =Db::name("order_tag")->where($taginfo)->update($update);
- return $up?app_show(0,"标签更新成功"): error_show(1004,"标签更新失败");
- }
- //编辑标签名称类型数据
- public function save(){
- $id =isset($this->post['id'])&&$this->post['id']!=''?intval($this->post['id']):'';
- if($id==''){
- return error_show(1004,"参数 id 不能为空");
- }
- $taginfo =Db::name("order_tag")->where(["id"=>$id,"is_del"=>0])->find();
- if($taginfo==false){
- return error_show(1004,"标签数据不存在");
- }
- $tagName=isset($this->post['tag_name'])&&$this->post['tag_name']!=''?trim($this->post['tag_name']):'';
- if($tagName===''){
- return error_show(1004,"参数 tag_name 不能为空");
- }
- $type=isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):'';
- if($type==''){
- return error_show(1004,"参数 type 不能为空");
- }
- $tag =Db::name("order_tag")->where([['tag_name',"=",$tagName],['companyNo',"=",$taginfo['companyNo']],
- ['type',"=",$type], ["id","<>",$id],["is_del","=",0]])->find();
- if($tag!=false){
- return error_show(1004,"标签名称已存在");
- }
- $update =["type"=>$type,"tag_name"=>$tagName,"updatetime"=>date("Y-m-d H:i:s")];
- $up =Db::name("order_tag")->where($taginfo)->update($update);
- return $up?app_show(0,"标签更新成功"): error_show(1004,"标签更新失败");
- }
- //删除标签
- public function delete(){
- $id =isset($this->post['id'])&&$this->post['id']!=''?intval($this->post['id']):'';
- if($id==''){
- return error_show(1004,"参数 id 不能为空");
- }
- $taginfo =Db::name("order_tag")->find(["id"=>$id]);
- if($taginfo==false){
- return error_show(1004,"标签数据不存在");
- }
- $update=["is_del"=>1,"updatetime"=>date("Y-m-d H:i:s")];
- $up =Db::name("order_tag")->where($taginfo)->update($update);
- return $up?app_show(0,"标签删除成功"): error_show(1004,"标签删除失败");
- }
- //单号添加标签
- public function AddTag(){
- $tagid =isset($this->post["tag_id"]) && $this->post["tag_id"]!=""?intval($this->post["tag_id"]) :"";
- if($tagid==""){
- return error_show(1004,"参数 tag_id 不能为空");
- }
- $taginfo =Db::name("order_tag")->where(["id"=>$tagid,"is_del"=>0])->find();
- if($taginfo==false){
- return error_show(1005,"标签数据不存在");
- }
- if($taginfo['status']==0){
- return error_show(1005,"标签已禁用");
- }
- $code =isset($this->post['code']) &&$this->post["code"]!="" ? trim($this->post["code"]):"";
- if($code==''){
- return error_show(1004,"参数 code 不能为空");
- }
- // $taglog =TagLog::where(["tag_id"=>$tagid,"code"=>$code,"status"=>1])->findOrEmpty();
- $total_fee =isset($this->post['total_fee']) &&$this->post["total_fee"]!=="" ? floatval($this->post["total_fee"]):"";
- if($total_fee==''){
- return error_show(1004,"参数 total_fee 不能为空");
- }
- $tagimg=isset($this->post["tag_img"]) && $this->post["tag_img"]!=""?$this->post["tag_img"]:"";
- $tag_remark=isset($this->post["tag_remark"]) && $this->post["tag_remark"]!=""?$this->post["tag_remark"]:"";
- Db::startTrans();
- try{
- if($taginfo['type']==1 || $taginfo['type']==2){
- $this->payTag($taginfo['type'],$code,$total_fee);
- }
- if($taginfo['type']==3|| $taginfo['type']==4){
- $this->qrdTag($taginfo['type'],$code,$total_fee);
- }
- if($taginfo['type']==5|| $taginfo['type']==6){
- $this->cgdTag($taginfo['type'],$code,$total_fee);
- }
- $tagdata=[
- "code"=>$code,
- "tag_id"=>$tagid,
- "creater"=>$this->uname,
- "createrid"=>$this->uid,
- "tag_fee"=>$total_fee,
- "tag_img"=>$tagimg,
- "tag_remark"=>$tag_remark,
- "status"=>1,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $in =Db::name("tag_log")->insert($tagdata);
- if($in==false) throw new \Exception("标签日志新建失败");
-
- Db::commit();
- return app_show(0,"标签添加成功");
- }catch (\Exception $e){
- Db::rollback();
- return error_show(1004,$e->getMessage());
- }
- }
- //标签废弃
- public function checkTag(){
- $param= $this->request->post(["logid"=>''],"post","trim");
- $loginfo = TagLog::where("id",$param['logid'])->findOrEmpty();
- if($loginfo->isEmpty())$this->error('未找到标签关联数据');
- $tag = OrderTag::where("id",$loginfo->tag_id)->findOrEmpty();
- if($tag->isEmpty())$this->error('未找到标签信息数据');
- TagLog::startTrans();
- $message="";
- try{
- if($tag['type']==1 || $tag['type']==2){
- $message="对账单{$loginfo->code}{$tag->tag_name}";
- $this->payReTag($tag['type'],$loginfo->code,$loginfo->tag_fee);
- }
- if($tag['type']==3|| $tag['type']==4){
- $message="销售单{$loginfo->code}{$tag->tag_name}";
- $this->qrdReTag($tag['type'],$loginfo->code,$loginfo->tag_fee);
- }
- if($loginfo['type']==5|| $loginfo['type']==6){
- $message="采购单{$loginfo->code}{$loginfo->tag_name}";
- $this->cgdReTag($loginfo['type'],$loginfo->code);
- }
- $loginfo->status=0;
- $loginfo->id=null;
- TagLog::create($loginfo->toArray());
- }catch (\Exception $exception){
- TagLog::rollback();
- $this->error($exception->getMessage());
- }
- TagLog::commit();
- $this->success("{$message}数据标签解除");
- }
-
- //解除标签
- public function returnTag(){
- $param= $this->request->post(['orderCode'=>'',"type"=>""],'post','trim');
- $valid =Validate::rule(["orderCode|订单编号"=>"require","type|标签类型"=>"require|number|in:1,2,3,4,5,6"]);
- if($valid->check($param)==false)$this->error($valid->getError());
- $loginfo = TagLog::withJoin(["tagInfo"])->where(['code'=>$param['orderCode'],"tag_log.status"=>[1,2],
- 'tagInfo.type'=>$param['type']])->order("tag_log.id","desc")->findOrEmpty();
- if($loginfo->isEmpty())$this->error('未找到标签关联数据');
- TagLog::startTrans();
- $message='';
- try{
- if($loginfo['type']==1 || $loginfo['type']==2){
- $message="对账单{$loginfo->code}{$loginfo->tag_name}";
- $fee= $this->payReTag($loginfo['type'],$loginfo->code);
- }
- if($loginfo['type']==3|| $loginfo['type']==4){
- $message="销售单{$loginfo->code}{$loginfo->tag_name}";
- $fee= $this->qrdReTag($loginfo['type'],$loginfo->code);
- }
- if($loginfo['type']==5|| $loginfo['type']==6){
- $message="采购单{$loginfo->code}{$loginfo->tag_name}";
- $fee= $this->cgdReTag($loginfo['type'],$loginfo->code);
- }
- $loginfo['status']=0;
- $loginfo['tag_fee']=$fee;
- unset($loginfo['addtime'],$loginfo['updatetime']);
- $loginfo->id=null;
- $loginfo->apply_id=$this->uid;
- $loginfo->apply_name=$this->uname;
- TagLog::create($loginfo->toArray());
- }catch (\Exception $exception){
- TagLog::rollback();
- $this->error($exception->getMessage());
- }
- TagLog::commit();
- $this->success("{$message}数据标签解除");
- }
- /**
- * @param $tagId 标签类型 1 付款2回票
- * @param $code 对账单编号
- * @param $total_fee 标签金额
- * @return \think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- private function payTag($tagId,$code,$total_fee){
- $pay=Db::name("pay")->where(["payNo"=>$code,"is_del"=>0])->findOrEmpty();
- if(empty($pay)){
- throw new \Exception('未找到对账单数据');
- }
- $update=["updatetime"=>date("Y-m-d H:i:s")];
- if($tagId==1){
- if($pay['wpay_fee']+$pay['pay_tag_fee']<$total_fee){
- throw new \Exception('对账单未付金额不足');
- }
- $update['wpay_fee']=$pay['wpay_fee']+$pay['pay_tag_fee']-$total_fee;
- $status = $update['wpay_fee']==0 &&$pay['pay_fee']==0 ? 3:($pay['apay_fee']==0?1:2);
- $update['pay_tag_fee'] =$pay['pay_tag_fee']+ $total_fee;
- $update['pay_status'] = $status;
- $update['pay_tag'] = 1;
- }
- if($tagId==2){
- if($pay['winv_fee']+$pay['inv_tag_fee']<$total_fee){
- throw new \Exception('对账单未开票金额不足');
- }
- $update['winv_fee']=$pay['winv_fee']+$pay['inv_tag_fee']-$total_fee;
- $status = $update['winv_fee']==0 &&$pay['inv_fee']==0 ? 3:($pay['ainv_fee']==0?1:2);
- $update['inv_tag_fee'] =$pay['inv_tag_fee']+ $total_fee;
- $update['inv_status'] = $status;
- $update['inv_tag'] = 1;
- }
- $resulr= Db::name("pay")->where($pay)->update($update);
- if($resulr==false) throw new \Exception('对账单更新失败');
- }
-
- /**解除标签
- * @param $tagId 标签类型 1 付款2回票
- * @param $code 对账单编号
- * @param $total_fee 标签金额
- * @return \think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- private function payReTag($tagId,$code){
- $pay=Pay::where(['payNo'=>$code,'is_del'=>0])->findOrEmpty();
- if($pay->isEmpty())throw new \Exception("未找到对账单数据");
- $fee=0;
- if($tagId==1){
- if($pay['pay_tag_fee']<0)throw new \Exception('对账单付款标签金额不足');
- $fee=$pay->pay_tag_fee;
- $pay->wpay_fee=$pay->wpay_fee+$pay->pay_tag_fee;
- $pay->pay_tag_fee=0;
- $pay->pay_status = $pay->wpay_fee==0 && $pay->pay_fee==0?3:($pay->apay_fee==0?1:2);
- $pay->pay_tag=0;
- }
- if($tagId==2){
- if($pay['inv_tag_fee']<0)throw new \Exception('对账单回票标签金额不足');
- $fee=$pay->inv_tag_fee;
- $pay->winv_fee=$pay->winv_fee+$pay->inv_tag_fee;
- $pay->inv_tag_fee=0;
- $pay->inv_status = $pay->winv_fee==0 && $pay->inv_fee==0?3:($pay->ainv_fee==0?1:2);
- $pay->inv_tag=0;
- }
- $resulr= $pay->save();
- if($resulr==false)throw new \Exception("对账单更新失败");
- return $fee;
- }
- /**
- * @param $tagId 标签类型 3 回款4开票
- * @param $code 销售单编号
- * @param $total_fee 标签金额
- * @return \think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- private function qrdTag($tagId,$code,$total_fee){
- $qrd=Db::name("qrd_info")->where(["sequenceNo"=>$code,"is_del"=>0])->findOrEmpty();
- if(empty($qrd)){
- throw new \Exception('未找到销售单数据');
- }
- $update=["updatetime"=>date("Y-m-d H:i:s")];
- if($tagId==3){
- if($qrd['wpay_fee']+$qrd['pay_tag_fee']<$total_fee){
- throw new \Exception('销售单未付金额不足');
- }
- $update['wpay_fee']=$qrd['wpay_fee']+$qrd['pay_tag_fee']-$total_fee;
- $status = $update['wpay_fee']==0 &&$qrd['pay_fee']==0 ? 3:($qrd['apay_fee']==0?1:2);
- $update['pay_tag_fee'] =$qrd['pay_tag_fee']+ $total_fee;
- $update['pay_status'] = $status;
- $update['pay_tag'] = 1;
- }
- if($tagId==4){
- if($qrd['winv_fee']+$qrd['inv_tag_fee']<$total_fee){
- throw new \Exception('销售单未开票金额不足');
- }
- $update['winv_fee']=$qrd['winv_fee']+$qrd['inv_tag_fee']-$total_fee;
- $status = $update['winv_fee']==0 &&$qrd['inv_fee']==0 ? 3:($qrd['ainv_fee']==0?1:2);
- $update['inv_tag_fee'] = $qrd['inv_tag_fee']+$total_fee;
- $update['inv_status'] = $status;
- $update['inv_tag'] = 1;
- }
- $resulr= Db::name("qrd_info")->where($qrd)->update($update);
- if($resulr==false) throw new \Exception('标签添加失败');
- }
-
- /** 解除标签销售单
- * @param $tagId 标签类型 3 回款4开票
- * @param $code 销售单编号
- * @param $total_fee 标签金额
- * @return \think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- private function qrdReTag($tagId,$code){
- $qrd=QrdInfo::where(['sequenceNo'=>$code,'is_del'=>0])->findOrEmpty();
- if($qrd->isEmpty())throw new \Exception('未找到销售单数据');
- $fee =0 ;
- if($tagId==3){
- if($qrd->pay_tag_fee<0)throw new \Exception('销售单回款标签金额不足');
- $fee =$qrd->pay_tag_fee ;
- $qrd->wpay_fee=$qrd->wpay_fee+$qrd->pay_tag_fee;
- $qrd->pay_tag_fee=0;
- $qrd->pay_status = $qrd->wpay_fee==0 && $qrd->pay_fee==0?3:($qrd->apay_fee==0?1:2);
- $qrd->pay_tag=0;
- }
- if($tagId==4){
- if($qrd->inv_tag_fee<0)throw new \Exception('销售单开票标签金额不足');
- $fee =$qrd->inv_tag_fee ;
- $qrd->winv_fee=$qrd->winv_fee+$qrd->inv_tag_fee;
- $qrd->inv_tag_fee=0;
- $qrd->inv_status = $qrd->winv_fee==0 && $qrd->inv_fee==0?3:($qrd->ainv_fee==0?1:2);
- $qrd->inv_tag=0;
- }
- $resulr= $qrd->save();
- if($resulr==false)throw new \Exception('销售单更新失败');
- return $fee;
- }
- /**
- * @param $tagId 标签类型 3 回款4开票
- * @param $code 销售单编号
- * @param $total_fee 标签金额
- * @return \think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- private function cgdTag($tagId,$code,$total_fee){
- $qrd=Db::name('cgd_info')->where(['sequenceNo'=>$code,'is_del'=>0])->findOrEmpty();
- if(empty($qrd)){
- throw new \Exception('未找到采购单数据');
- }
- $update=['updatetime'=>date('Y-m-d H:i:s')];
- if($tagId==5){
- if($qrd['wpay_fee']+$qrd['pay_tag_fee']<$total_fee){
- throw new \Exception('采购单未付金额不足');
- }
- $update['wpay_fee']=$qrd['wpay_fee']+$qrd['pay_tag_fee']-$total_fee;
- $status = $update['wpay_fee']==0 ? 3:($qrd['apay_fee']==0?1:2);
- $update['pay_tag_fee'] =$qrd['pay_tag_fee']+ $total_fee;
- $update['pay_status'] = $status;
- $update['pay_tag'] = 1;
- }
- if($tagId==6){
- if($qrd['winv_fee']+$qrd['inv_tag_fee']<$total_fee){
- throw new \Exception('采购单未开票金额不足');
- }
- $update['winv_fee']=$qrd['winv_fee']+$qrd['inv_tag_fee']-$total_fee;
- $status = $update['winv_fee']==0 ? 3:($qrd['ainv_fee']==0?1:2);
- $update['inv_tag_fee'] = $qrd['inv_tag_fee']+$total_fee;
- $update['inv_status'] = $status;
- $update['inv_tag'] = 1;
- }
- $resulr= Db::name('cgd_info')->where($qrd)->update($update);
- if($resulr==false) throw new \Exception('标签添加失败');
- }
- /** 解除标签销售单
- * @param $tagId 标签类型 3 回款4开票
- * @param $code 销售单编号
- * @param $total_fee 标签金额
- * @return \think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- private function cgdReTag($tagId,$code){
- $qrd=CgdInfo::where(['sequenceNo'=>$code,'is_del'=>0])->findOrEmpty();
- if($qrd->isEmpty())throw new \Exception('未找到采购单数据');
- $fee =0 ;
- if($tagId==5){
- if($qrd->pay_tag_fee<0)throw new \Exception('采购单回款标签金额不足');
- $fee =$qrd->pay_tag_fee ;
- $qrd->wpay_fee=$qrd->wpay_fee+$qrd->pay_tag_fee;
- $qrd->pay_tag_fee=0;
- $qrd->pay_status = $qrd->wpay_fee==0?3:($qrd->apay_fee==0?1:2);
- $qrd->pay_tag=0;
- }
- if($tagId==6){
- if($qrd->inv_tag_fee<0)throw new \Exception('采购单开票标签金额不足');
- $fee =$qrd->inv_tag_fee ;
- $qrd->winv_fee=$qrd->winv_fee+$qrd->inv_tag_fee;
- $qrd->inv_tag_fee=0;
- $qrd->inv_status = $qrd->winv_fee==0?3:($qrd->ainv_fee==0?1:2);
- $qrd->inv_tag=0;
- }
- $resulr= $qrd->save();
- if($resulr==false)throw new \Exception('采购单更新失败');
- return $fee;
- }
-
- public function logList(){
- $param = $this->request->param(["betweenTime"=>[],"customerNo"=>"","supplierNo"=>"",'companyNo'=>'',
- "type"=>'',"status"=>"","orderCode"=>"","creater"=>"","order_type"=>0,"size"=>10,"page"=>1],"post","trim");
- $modela=['','payInfo','orderInfo','cgdInfo'];
- $sbtable = $modela[$param['order_type']];
- $type = [[],[1,2],[3,4],[5,6]];
- $where=[["tagInfo.type","in",$type[$param['order_type']]],["{$sbtable}.is_del","=",0],["tagInfo.is_del",'=',0]];
- empty($param['betweenTime'])?:$where[]=["tag_log.addtime","between",$param['betweenTime']];
-
- if($param['order_type']==1)$param['customerNo']==""?:$where[]=["{$sbtable}.customerNo","like","%{$param['customerNo']}%"];
- if($param['order_type']!=1)$param['supplierNo']==""?:$where[]=["{$sbtable}.supplierNo","like","%{$param['supplierNo']}%"];
- $param['companyNo']==""?:$where[]=["{$sbtable}.companyNo","like","%{$param['companyNo']}%"];
- $param['type']==''?:$where[]=["tagInfo.type","=",$param['type']];
- $param['status']===""?:$where[]=["tag_log.status","=",$param['status']];
- $param['orderCode']==""?:$where[]=["code","like","%{$param['orderCode']}%"];
- $param['creater']==""?:$where[]=["creater","like","%{$param['creater']}%"];
- $model =new TagLog();
- $list = $model->withJoin(["tagInfo",$sbtable],"left")->where($where)
- ->order("id","desc")
- ->paginate(["list_rows"=>$param['size'],"page"=>$param['page']]);
- $this->success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
- }
- }
|