request->param(); $condition = [['a.is_del',"=",0]]; $page = isset($post['page'])&&$post['page']!==''?intval($post['page']):1; $size = isset($post['size'])&&$post['size']!==''?intval($post['size']):15; $start =isset($post['start'])&&$post['start']!==''?trim($post['start']):''; if($start!=''){ $condition[]=["a.createdTime",">=",$start." 00:00:00"]; } $end =isset($post['end'])&&$post['end']!==''?trim($post['end']):''; if($end!=''){ $condition[]=["a.createdTime","<=",$end." 23:59:59"]; } $total_min = isset($post['total_min'])&&$post['total_min']!==''?floatval($post['total_min']):''; if($total_min!==''){ $condition[]=["a.totalPrice",">=",$total_min]; } $total_max = isset($post['total_max'])&&$post['total_max']!==''?floatval($post['total_max']):''; if($total_max!==''){ $condition[]=["a.totalPrice","<=",$total_max]; } $cxCode = isset($post['cxCode'])&&$post['cxCode']!==''?trim($post['cxCode']):''; if($cxCode!==''){ $condition[]=["a.cxCode","=",$cxCode]; } $inv_status = isset($post['inv_status'])&&$post['inv_status']!==''?intval($post['inv_status']):''; if($inv_status!==''){ if($inv_status==0){ $condition[]=["a.inv_status","<>",3]; }else{ $condition[]=["a.inv_status","=",$inv_status]; } } $invIs = isset($post['inv_is'])&&$post['inv_is']!==''?intval($post['inv_is']):''; if($invIs!==''){ if($invIs==1){ $condition[]=["a.winv_fee","<>",0]; }else{ $condition[]=["a.winv_fee","=",0]; } } $payIs = isset($post['pay_is'])&&$post['pay_is']!==''?intval($post['pay_is']):''; if($payIs!==''){ if($invIs==1){ $condition[]=["a.wpay_fee","<>",0]; }else{ $condition[]=["a.wpay_fee","=",0]; } } $pay_status = isset($post['pay_status'])&&$post['pay_status']!==''?intval($post['pay_status']):''; if($pay_status!==''){ if($pay_status==0){ $condition[]=["a.pay_status","<>",3]; }else{ $condition[]=["a.pay_status","=",$pay_status]; } } $status = isset($post['status'])&&$post['status']!==''?intval($post['status']):''; if($status!==''){ if($status==3){ $condition[]=["a.status","<>",2]; }else{ $condition[]=["a.status","=",$status]; } } $qrdNo = isset($post['sequenceNo'])&&$post['sequenceNo']!=''?trim($post['sequenceNo']):''; if($qrdNo!==''){ $condition[]=["a.sequenceNo","like","%$qrdNo%"]; } $department = isset($post['department'])&&$post['department']!=''?trim($post['department']):''; if($department!==''){ $condition[]=["a.department","like","%$department%"]; } $customerNo = isset($post['customerNo'])&&$post['customerNo']!=''?trim($post['customerNo']):''; if($customerNo!==''){ $condition[]=["a.customerNo","like","%$customerNo%"]; } $customer = isset($post['customer'])&&$post['customer']!=''?trim($post['customer']):''; if($customer!=''){ $condition[]=["a.customerName","like","%$customer%"]; } $companyNo = isset($post['companyNo'])&&$post['companyNo']!=''?trim($post['companyNo']):''; if($companyNo!==''){ $condition[]=["a.companyNo","=",$companyNo]; } $companyName = isset($post['companyName'])&&$post['companyName']!=''?trim($post['companyName']):''; if($companyName !=''){ $condition[]=["a.companyName","like","%$companyName%"]; } $platName = isset($post['platName'])&&$post['platName']!=''?trim($post['platName']):''; if($platName!=''){ $condition[]=["a.platName","like","%$platName%"]; } $saler= isset($post['saler']) && $post['saler']!='' ? trim($post['saler']) :""; if($saler!='') $condition []=["a.ownerName","like","%$saler%"]; $salerid= isset($post['salerid']) && $post['salerid']!='' ? intval($post['salerid']) :""; if($salerid!='') $condition []=["a.ownerid","=",$salerid]; $qrdtype= isset($post['qrdtype']) && $post['qrdtype']!='' ? intval($post['qrdtype']) :""; if($qrdtype!='') $condition []=["a.qrdType","=",$qrdtype]; $qrdsource= isset($post['qrdsource']) && $post['qrdsource']!='' ? intval($post['qrdsource']) :""; if($qrdsource!='') $condition []=["a.qrdSource","=",$qrdsource]; $sendstatus= isset($post['sendstatus']) && $post['sendstatus']!='' ? intval($post['sendstatus']) :""; if($sendstatus!='') $condition []=["a.sendStatus","=",$sendstatus]; $tag_id= isset($post['tag_id'])&&$post['tag_id']!=="" ? intval($post['tag_id']) :""; if($tag_id!==''){ if($tag_id==1) $condition[]=["a.inv_tag","=",1]; if($tag_id==2) $condition[]=["a.pay_tag","=",1]; if($tag_id==3) $condition[]=["a.pay_tag|inv_tag","=",1]; if($tag_id==4) $condition[]=["a.pay_tag&inv_tag","=",1]; } $cat_status= isset($post['cat_status'])&&$post['cat_status']!=="" ? intval($post['cat_status']) :""; if($cat_status!=='') $condition[]=["b.status","=",$cat_status]; $count =Db::name("qrd_info")->alias("a")->leftJoin("good b","a.goodNo=b.spuCode")->where($condition)->count(); $total = ceil($count/$size); $page = $page>$total ? intval($total) : $page; $list =Db::name("qrd_info")->alias("a") ->leftJoin("good b","a.goodNo=b.spuCode") ->field("a.*,b.status as cat_status,b.inv_cat_name,b.inv_cat_code,b.inv_tax,b.inv_good_name,b.isZx") ->order("a.createdTime desc") ->where($condition)->page($page,$size)->select(); $data=[]; foreach ( $list as $ky=>$value){ $value['catInfo'] = json_decode($value['catInfo'],true); $tag =Db::name("tag_log")->alias("a")->leftJoin("order_tag b","a.tag_id=b.id")->where (["code"=>$value['sequenceNo'],"a.status"=>1])->column("b.tag_name,a.tag_img,a.tag_remark","b.type"); $value['goodNum'] = $value['goodNum'] -$value['thNum']; $value['sendNum'] = $value['sendNum'] -$value['thNum']; $value['inv_tag_name']=$tag[4]['tag_name']??''; $value['pay_tag_name']=$tag[3]['tag_name']??''; $value['pay_tag_img']=$tag[3]['tag_img']??''; $value['inv_tag_img']=$tag[4]['tag_img']??''; $value['inv_tag_remark']=$tag[4]['tag_remark']??''; $value['pay_tag_remark']=$tag[3]['tag_remark']??''; $invArr = Db::name("assoc") ->alias("a") ->leftJoin("invoice_good b", "a.viceCode=b.invNo AND b.orderCode =a.orderCode") ->where(["a.status" => [1, 2], "a.is_del" => 0, "a.type" => 1, "a.orderCode" => $value['sequenceNo']])->group("a.status") ->column("sum(b.goodNum) as goodNum", "a.status"); $value['inv_num'] = $invArr[1]??0; $value['ainv_num'] = $invArr[2]??0; $value['winv_num'] =$value['goodNum']- $value['inv_num']-$value['ainv_num']; $data[]=$value; } return app_show(0,"获取成功",["list"=>$data,"count"=>$count]); } /** * 更改销售单状态 是否需要回款 0 未回款对账 1 回款对账 2 无需汇款操作 */ public function status(){ $post =$this->request->only(["sequenceNo"=>'',"status"=>0],"post","trim"); if($post['sequenceNo']==''){ return error_show(1004,"参数 sequenceNo 不能为空"); } if($post['status']===''){ return error_show(1004,"参数 status 不能为空"); } $qrdinfo =Db::name("qrd_info")->where("sequenceNo","=",$post['sequenceNo'])->findOrEmpty(); if(empty($qrdinfo)){ return error_show(1004,"未找到确认单信息"); } if ($qrdinfo['status']==1){ return error_show(1004,"确认单已参与对账"); } $update=[ "status"=>$post['status'], "updatetime"=>date("Y-m-d H:i:s") ]; $up =Db::name("qrd_info")->where($qrdinfo)->update($update); if($up){ return app_show(0,"更新成功"); }else{ return error_show(1003,"更新失败"); } } //确认单信息详情 public function saleinfo(){ $post=$this->post; $sequenceNo =isset($post['sequenceNo'])&&$post['sequenceNo']?trim($post['sequenceNo']):""; if($sequenceNo==''){ return error_show(1003,"参数 sequenceNo 不能为空"); } $qrdinfo =Db::name("qrd_info")->where("sequenceNo","=",$post['sequenceNo'])->findOrEmpty(); if(empty($qrdinfo)){ return error_show(1004,"未找到确认单信息"); } $goodinfo = Db::name("good")->where(["spuCode"=>$qrdinfo["goodNo"]])->findOrEmpty(); $qrdinfo['goodinfo'] =$goodinfo; $qrdinfo['catInfo'] = json_decode($qrdinfo['catInfo'],true); $tag =Db::name("tag_log")->alias("a")->leftJoin("order_tag b","a.tag_id=b.id") ->where(["code"=>$qrdinfo['sequenceNo'],"a.status"=>1])->column("b.tag_name,a.tag_img,a.tag_remark","b.type"); $qrdinfo['inv_tag_name']=$tag[4]['tag_name']??''; $qrdinfo['pay_tag_name']=$tag[3]['tag_name']??''; $qrdinfo['pay_tag_img']=$tag[3]['tag_img']??''; $qrdinfo['pay_tag_remark']=$tag[3]['tag_remark']??''; $qrdinfo['inv_tag_img']=$tag[4]['tag_img']??''; $qrdinfo['inv_tag_remark']=$tag[4]['tag_remark']??''; $qrdinfo['goodNum'] = $qrdinfo['goodNum'] -$qrdinfo['thNum']; $qrdinfo['sendNum'] = $qrdinfo['sendNum'] -$qrdinfo['thNum']; $qrdinfo['customerAttr'] = Db::name("customer_info")->where(["companyNo"=>$qrdinfo['customerNo']])->value("parent",''); return app_show(0,"获取成功",$qrdinfo); } }