wugg 2 years ago
parent
commit
a7f1c494b0
1 changed files with 14 additions and 14 deletions
  1. 14 14
      app/admin/controller/Export.php

+ 14 - 14
app/admin/controller/Export.php

@@ -374,7 +374,7 @@ class Export extends BaseController
     {
         $param = $this->request->only(['companyNo' => '', 'start' => '', 'end' => ''], 'post', 'trim');
 
-        $where = [['a.is_del', '=', 0], ['d.is_del', '=', 0]];
+        $where = [['a.is_del', '=', 0], ['d.is_del', '=', 0], ['a.status', '=', 4]];
 
         if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['a.addtime', 'between', [$param['start'] . ' 00:00:00', $param['end'] . ' 23:59:59']];
         if ($param['companyNo'] != '') $where[] = ['a.inv_out', '=', $param['companyNo']];
@@ -387,14 +387,14 @@ class Export extends BaseController
             b.seller_title 销售方抬头,
             e.department 业务部门,
             e.ownerName 业务人员,
-            e.goodNum 本次开票数量,
+           ifnull((SELECT goodNum from cfp_invoice_good w where w.invNo =a.invNo and w.orderCode=e.sequenceNo),"") 本次开票数量,
             d.cancel_fee 本次开票金额,
-            a.addtime 本次开票时间,
+            c.open_date 本次开票时间,
             c.inv_number 发票号,
             e.tax 开票税点,
             a.status 开票状态,
             e.customerName 客户名称,
-            f.fundCode 财务核算码,
+            e.fundCode 财务核算码,
             e.firstCat 一级分类,
             e.secCat 二级分类,
             e.thirdCat 三级分类,
@@ -402,19 +402,19 @@ class Export extends BaseController
             f.qrdCode 采购单编号,
             f.supplierName 卖出方公司,
             f.sendType 发货方式,
-            f.cgdType 商品类型,
+            e.qrdType 商品类型,
             f.ownerName 采购员,
-            e.goodNum 采购下单数量,
-            e.goodPrice 采购裸价,            
+            ifnull(f.goodNum,e.goodNum) 采购下单数量,
+            f.barePrice 采购裸价,            
             f.markPrice 加标费,
             f.packPrice 包装费,
             f.certPrice 证书费,
             f.openPrice 开模费,
             f.costPrice 工艺费,
             f.deliveryPrice 物流费,
-            e.goodPrice 成本合计,
-            e.totalPrice 采购货款,
-            e.tax 采购单税点,
+            f.goodPrice 成本合计,
+            ifnull(f.totalPrice,e.total_origin_price) 采购货款,
+            f.tax 采购单税点,
             g.returnCode 退票编号,
             a.inv_value 退票金额,
             g.status 退票状态,
@@ -423,11 +423,11 @@ class Export extends BaseController
             f.th_fee 退货金额            
             ')
             ->leftJoin('invoice_pool_info b', 'b.invNo=a.invNo')
-            ->leftJoin('invoice_ticket c', 'c.invNo=a.invNo and c.type=0')
-            ->leftJoin('assoc d', 'd.viceCode=a.invNo')
+            ->leftJoin('invoice_ticket c', 'c.invNo=a.invNo and c.type=0 and c.status=1')
+            ->leftJoin('assoc d', 'd.viceCode=a.invNo and d.status=2 and d.type=1')
             ->leftJoin('qrd_info e', 'e.sequenceNo=d.orderCode')
             ->leftJoin('cgd_info f', 'f.qrdCode=d.orderCode')
-            ->leftJoin('invoice_return g', 'g.invNo=a.invNo')
+            ->leftJoin('invoice_return g', 'g.invNo=a.invNo and g.status=2')
             ->where($where)
             ->order(['a.id' => 'desc'])
             ->cursor();
@@ -437,7 +437,7 @@ class Export extends BaseController
         foreach ($data as $value) {
             $value['开票状态'] = $this->invoice_pool_status[$value['开票状态']] ?? '';
             $value['发货方式'] = $this->sendType[$value['发货方式']] ?? '';
-            $value['商品类型'] = $this->cgdType[$value['商品类型']] ?? '';
+            $value['商品类型'] = $this->qrdType[$value['商品类型']] ?? '';
             $value['退票状态'] = $this->invoice_return_status[$value['退票状态']] ?? '';
             $list[] = $value;
         }