|
@@ -173,6 +173,164 @@ class Sale extends BaseController{
|
|
|
}
|
|
|
return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public function query(){
|
|
|
+
|
|
|
+ $post =$this->request->param();
|
|
|
+ $condition = [['a.is_del',"=",0]];
|
|
|
+// $roleid = $this->roleid;
|
|
|
+// $check = checkRole($roleid,'86');
|
|
|
+// if($check){
|
|
|
+// $condition[]=["a.ownerid","=",$this->uid];
|
|
|
+// }
|
|
|
+
|
|
|
+ $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","in",explode(",",$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%"];
|
|
|
+ }
|
|
|
+ $platform_type = isset($post['platform_type'])&&$post['platform_type']!==''?intval($post['platform_type']):'';
|
|
|
+ if($platform_type!==''){
|
|
|
+ $condition[]=["a.platform_type","=",$platform_type];
|
|
|
+ }
|
|
|
+
|
|
|
+ $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];
|
|
|
+ $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)->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,"获取成功",$data);
|
|
|
+ }
|
|
|
/**
|
|
|
* 更改销售单状态 是否需要回款 0 未回款对账 1 回款对账 2 无需汇款操作
|
|
|
*/
|