瀏覽代碼

1811 订单导出bugfix

kevin_zhangl 3 年之前
父節點
當前提交
cb92551b87

+ 1 - 1
backendApi/modules/v1/controllers/ShopController.php

@@ -410,7 +410,7 @@ class ShopController extends BaseController {
             'PERIOD_NUM'=> 'O.PERIOD_NUM',
             'CREATED_AT'=> 'O.CREATED_AT',
         ]);
-        $filter['condition'] .= $filter['condition'] ? ' 1=1 AND O.IS_DELETE=0' : ' AND O.IS_DELETE=0';
+        $filter['condition'] = !$filter['condition'] ? '1=1 AND O.IS_DELETE=0' : ('O.IS_DELETE=0 ' . $filter['condition']);
         $form = new ShopExportForm();
         $result = $form->run($filter, '订单列表');
         if (!$result) {

+ 2 - 2
backendApi/modules/v1/models/lists/shop/OrderList.php

@@ -124,11 +124,11 @@ class OrderList extends \common\libs\dataList\DataList implements DataListInterf
                     'headerOther' => ['width' => '200'],
                 ],
                 'BUY_NUMS' => [
-                    'header' => 'quantity',//数量
+                    'header' => 'Qty',//数量
                     'headerOther' => ['width' => '100'],
                 ],
                 'CONSIGNEE' => [
-                    'header' => 'consignee',//收货人
+                    'header' => 'Consignee',//收货人
                     'headerOther' => [
                         'width' => '150',
                     ],

+ 48 - 11
common/libs/export/BaseExport.php

@@ -7,6 +7,8 @@ use common\helpers\Date;
 use common\helpers\Form;
 use common\helpers\http\RemoteUploadApi;
 use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\DateTime;
 use common\libs\dataList\DataList;
 use common\models\ApproachOrder;
 use common\models\ApproachOrderGoods;
@@ -16,6 +18,7 @@ use common\models\OrderGoods;
 use common\models\Region;
 use common\models\ShopGoods;
 use common\models\User;
+use mysql_xdevapi\Result;
 use Yii;
 use yii\base\Exception;
 use yii\base\StaticInstanceTrait;
@@ -254,7 +257,7 @@ class BaseExport extends Component {
      */
     private function _loopWriteData($realFile, &$fileNameUpdated, $page = 0, $counter = 0){
         if(method_exists($this->_listModel, 'getList')){
-            $list = $this->_listModel->getList(['condition'=>$this->params['condition'], 'params'=>isset($this->params['params']) ? $this->params['params'] : [], 'others'=>isset($this->params['others']) ? $this->params['others'] : [], 'page'=>$page, 'pageSize'=>$this->pageSize, 'userId'=>$this->userId]);
+            $list = $this->_listModel->getList(['condition'=>$this->params['condition'], 'params'=> $this->params['params'] ?? [], 'others'=> $this->params['others'] ?? [], 'page'=>$page, 'pageSize'=>$this->pageSize, 'userId'=>$this->userId]);
         } else {
             throw new Exception($this->listModelClass.'的getList方法不存在');
         }
@@ -290,12 +293,6 @@ class BaseExport extends Component {
 
     /**
      * 循环写入数据
-     * @param $realFile
-     * @param $fileNameUpdated
-     * @param int $page
-     * @param int $counter
-     * @return string
-     * @throws Exception
      */
     private function _loopWriteDataOrder()
     {
@@ -325,9 +322,49 @@ class BaseExport extends Component {
         $lists = $query->all();
 
         if(!empty($lists)){
-            foreach($lists as $columnData){
-                fputcsv($this->_fp, Tool::arrTextConvert($columnData));
-                unset($percent, $columnData);
+            foreach($lists as $columnData) {
+                $CREATE_USER_ID = Info::getUserIdByUserName($columnData['CREATE_USER']);
+                $createUserName = Info::getUserRealNameByUserId($CREATE_USER_ID);
+                $decUserName = Info::getUserNameByUserId($columnData['DEC_ID']);
+
+                $columnAccept = [
+                    'USER_NAME' => $columnData['USER_NAME'],
+                    'DEC_USER_NAME' => $decUserName,
+                    'CREATE_USER' => $columnData['CREATE_USER'],
+                    'CREATE_USER_NAME' => $createUserName,
+                    'SN' => $columnData['SN'],
+                    'STATUS' => \Yii::$app->params['orderStatus'][$columnData['STATUS']]['label'] ?? '',
+                    'SKU_CODE' => $columnData['SKU_CODE'],
+                    'GOODS_TITLE' => $columnData['GOODS_TITLE'],
+                    'BUY_NUMS' => $columnData['BUY_NUMS'],
+                    'CONSIGNEE' => $columnData['CONSIGNEE'],
+                    'MOBILE' => $columnData['MOBILE'],
+                    'TEL' => $columnData['TEL'],
+                    'PROVINCE' => $regionConfig[$columnData['PROVINCE']]['REGION_NAME'] ?? '',
+                    'CITY' => $regionConfig[$columnData['CITY']]['REGION_NAME'] ?? '',
+                    'COUNTY' => $regionConfig[$columnData['COUNTY']]['REGION_NAME'] ?? '',
+                    'ADDRESS' => $columnData['ADDRESS'],
+                    'PERIOD_NUM' => $columnData['PERIOD_NUM'],
+                    'ORDER_TYPE' => ($columnData['ORDER_TYPE'] == 'ZC') ? 'Welcome pack' : (in_array($columnData['PAY_TYPE'], ['cash', 'pay_stack']) ? 'Reselling': 'Points'),
+                    'WAREHOUSE' => $columnData['WAREHOUSE'],
+                    'CREATED_AT' => Date('Y-m-d H:i:s', $columnData['CREATED_AT']),
+                    'PAY_TYPE' => ShopGoods::payTypes()[$columnData['PAY_TYPE']]['name'] ?? ShopGoods::payTypes()['cash']['name'],
+                    'PAY_AT' => Date('Y-m-d H:i:s', $columnData['PAY_AT']),
+                    'DELIVERY_AT' => Date('Y-m-d H:i:s', $columnData['DELIVERY_AT']),
+                    'REAL_PRICE' => $columnData['REAL_PRICE'],
+                    'REAL_PV' => $columnData['REAL_PV'],
+                    'PAY_FREIGHT' => $columnData['PAY_FREIGHT'],
+                    'TAX_RATE' => $columnData['TAX_RATE'],
+                    'TAX_AMOUNT' => Tool::calculateTax($columnData['REAL_PRICE'], $columnData['TAX_RATE'], $columnData['TAX_RATE']),
+                    'EXPRESS_COMPANY' => $columnData['EXPRESS_COMPANY'],
+                    'ORDER_TRACK_NO' => $columnData['ORDER_TRACK_NO'],
+                    'EXPRESS_TYPE' => $columnData['EXPRESS_TYPE'] == 0 ? 'mailing ':' auto pick',
+                    'FRONT_REMARK' => $columnData['FRONT_REMARK'],
+                    'DELIVERY_STATUS_NAME' => \Yii::$app->params['deliveryStatus'][$columnData['DELIVERY_STATUS']]['label'] ?? '',
+                ];
+
+                fputcsv($this->_fp, Tool::arrTextConvert($columnAccept));
+                unset($percent, $columnData, $columnAccept);
             }
             unset($list);
         }
@@ -505,7 +542,7 @@ class BaseExport extends Component {
         $this->_listModel->isExport = true;
         if(method_exists($this->_listModel, 'getExportHeaders')){
             if(method_exists($this->_listModel, 'exportPrepare')) {//导出数据提前设置参数
-                $this->_listModel->exportPrepare(['condition' => $this->params['condition'], 'params' => $this->params['params'], 'others' => isset($this->params['others']) ? $this->params['others'] : [], 'page' => 0, 'pageSize' => $this->pageSize, 'userId' => $this->userId]);
+                $this->_listModel->exportPrepare(['condition' => $this->params['condition'], 'params' => $this->params['params'], 'others' => $this->params['others'] ?? [], 'page' => 0, 'pageSize' => 100000, 'userId' => $this->userId]);
             }
             $headers = $this->_listModel->getExportHeaders($this->userId);
             fputcsv($this->_fp, $headers);