Browse Source

1916 订单接入物流

kevin_zhangl 3 years ago
parent
commit
15b739ad53

+ 1 - 1
backendApi/config/menu.php

@@ -53,7 +53,7 @@ return [
 //            ['name'=>'External mall order list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-shop-list', 'routePath'=>'shop/order-shop-list', 'show'=>1,],//外部商城订单列表
             // ['name'=>'External mall entry list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-dec-list', 'routePath'=>'shop/order-dec-list', 'show'=>1,],//外部商城报单列表
             // ['name'=>'List of qualified orders of external mall', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-standard-list', 'routePath'=>'shop/order-standard-list', 'show'=>1,],//外部商城达标订单列表
-
+            ['name'=>'Order Upload', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-upload', 'routePath'=>'shop/order-upload', 'show'=>1],//订单上传
         ]
     ],
     'user'=>[

+ 64 - 2
backendApi/config/params.php

@@ -1,6 +1,68 @@
 <?php
 return [
     'adminEmail' => 'admin@example.com',
-    'noCheckTokenActions' => ['v1/oauth/login', 'v1/oauth/no-login-modify-password', 'v1/oauth/refresh-access-token', 'v1/oauth/refresh-refresh-token', 'v1/oauth/refresh-token', 'v1/site/days-diff', 'v1/site/page-data', 'v1/site/captcha'],
-    'noCheckPermissionActions' => ['oauth/login', 'oauth/no-login-modify-password', 'oauth/refresh-access-token', 'oauth/refresh-refresh-token', 'oauth/refresh-token', 'oauth/info', 'site/base-info', 'site/days-diff', 'site/page-data', 'site/captcha', 'user/full-info', 'user/filter-user', 'user/generate-user-name', 'reconsume/cant-deduct-date', 'user/get-sub-com', 'user/chk-relation', 'user/get-period-num', 'user/company-bank-get', 'user/main-divide', 'user/chk-del-user', 'reconsume/deduct-audit-add', 'finance/perf-apply-get','file/upload-excel', 'user/move-net-type', 'user/move-get', 'user/reg-info-audit-get', 'user/status-audit-get', 'user/status-audit-get-statuses', 'user/close-login-get', 'user/close-dec-get', 'atlas/main-user-info', 'reconsume/change-audit-get', 'reconsume/cant-deduct-month', 'finance/change-balance-type', 'finance/balance-audit-get', 'file/token', 'finance/perf-audit-get', 'finance/invoice-audit-get', 'finance/withdraw-get', 'finance/deal-type-get', 'ad/upload', 'config/reg-type-get', 'config/pact-get', 'user/reg-info-audit-add-opt', 'reconsume/get-flow-deal-type', 'user/status-close-get', 'finance/mult-point', 'shop/upload', 'article/upload'],
+    'noCheckTokenActions' => [
+        'v1/oauth/login',
+        'v1/oauth/no-login-modify-password',
+        'v1/oauth/refresh-access-token',
+        'v1/oauth/refresh-refresh-token',
+        'v1/oauth/refresh-token',
+        'v1/site/days-diff',
+        'v1/site/page-data',
+        'v1/site/captcha',
+    ],
+
+    'noCheckPermissionActions' => [
+        'oauth/login',
+        'oauth/no-login-modify-password',
+        'oauth/refresh-access-token',
+        'oauth/refresh-refresh-token',
+        'oauth/refresh-token',
+        'oauth/info',
+        'site/base-info',
+        'site/days-diff',
+        'site/page-data',
+        'site/captcha',
+        'user/full-info',
+        'user/filter-user',
+        'user/generate-user-name',
+        'reconsume/cant-deduct-date',
+        'user/get-sub-com',
+        'user/chk-relation',
+        'user/get-period-num',
+        'user/company-bank-get',
+        'user/main-divide',
+        'user/chk-del-user',
+        'reconsume/deduct-audit-add',
+        'finance/perf-apply-get',
+        'file/upload-excel',
+        'user/move-net-type',
+        'user/move-get',
+        'user/reg-info-audit-get',
+        'user/status-audit-get',
+        'user/status-audit-get-statuses',
+        'user/close-login-get',
+        'user/close-dec-get',
+        'atlas/main-user-info',
+        'reconsume/change-audit-get',
+        'reconsume/cant-deduct-month',
+        'finance/change-balance-type',
+        'finance/balance-audit-get',
+        'file/token',
+        'finance/perf-audit-get',
+        'finance/invoice-audit-get',
+        'finance/withdraw-get',
+        'finance/deal-type-get',
+        'ad/upload',
+        'config/reg-type-get',
+        'config/pact-get',
+        'user/reg-info-audit-add-opt',
+        'reconsume/get-flow-deal-type',
+        'user/status-close-get',
+        'finance/mult-point',
+        'shop/upload',
+        'article/upload',
+        'shop/order-upload',
+        'file/upload-order-list',
+    ],
 ];

+ 2 - 0
backendApi/config/urlManagerRules.php

@@ -48,6 +48,7 @@ return [
             'GET,POST package-delete' => 'package-delete',
             'POST package-status' => 'package-status',
             'GET,POST upload' => 'upload',
+            'GET,POST order-upload' => 'order-upload',
             'GET dec-order-list' => 'dec-order-list',
             'GET dec-order-list-export' => 'dec-order-list-export',
             'POST delete-order' => 'delete-order',
@@ -486,6 +487,7 @@ return [
             'GET token' => 'token',
             'POST upload-excel' => 'upload-excel',
             'POST export-delete' => 'export-delete',
+            'GET upload-order-list' => 'upload-order-list',
         ],
     ],
     [

+ 9 - 0
backendApi/modules/v1/controllers/FileController.php

@@ -140,4 +140,13 @@ class FileController extends BaseController
         }
     }
 
+    /**
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionUploadOrderList()
+    {
+        $data = Uploads::find()->where('CATEGORY = :CATEGORY', [':CATEGORY' => 'order'])->orderBy('CREATED_AT DESC')->asArray()->all();
+        return static::notice($data);
+    }
 }

+ 24 - 0
backendApi/modules/v1/controllers/ShopController.php

@@ -183,6 +183,30 @@ class ShopController extends BaseController {
         }
     }
 
+    /**
+     * 上传商品
+     * @return mixed
+     * @throws \yii\base\Exception
+     * @throws \yii\db\Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionOrderUpload(){
+        if(\Yii::$app->request->isPost){
+            $formModel = new UploadForm();
+            $formModel->scenario = 'order';
+            $formModel->file = UploadedFile::getInstanceByName('file');
+            $formModel->token = \Yii::$app->request->request('uploadToken');
+            if($formModel->file && $uploader = $formModel->upload()){
+                return static::notice($uploader);
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
+            }
+        } else {
+            $token = Cache::setUploadToken();
+            return static::notice($token);
+        }
+    }
+
     /**
      * 商品上下架
      * @return mixed

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

@@ -329,6 +329,11 @@ class OrderList extends \common\libs\dataList\DataList implements DataListInterf
                 'ORDER_TRACK_NO' => [
                     'header' => 'Courier Number',//快递单号
                     'headerOther' => ['width' => '200'],
+                    'valueOther' => function ($row) {
+                        return [
+                            'link' => ['type' => 'primary']
+                        ];
+                    },
                 ],
                 'EXPRESS_TYPE' => [
                     'header' => 'Shipping Method',//发货方式

+ 13 - 0
backendEle/src/router/index.js

@@ -153,6 +153,19 @@ export const constantRouterMap = [
           ],
         },
       },
+      {
+        path: '/shop/order-upload',
+        component: _import('shop/order-upload'),
+        name: 'shop_order-upload',
+        meta: {
+          title: 'order upload', // 订单列表
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // Dashboard
+            {title: 'Products Management', path: '/shop/order-upload'}, // 商城管理
+          ],
+        },
+
+      },
     ],
   },
   {

+ 35 - 1
backendEle/src/views/shop/order-list.vue

@@ -13,12 +13,15 @@
             <template v-if="scope.row[tableHeader.index].other.tag" >
               <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
             </template>
+            <template v-else-if="scope.row[tableHeader.index].other.link">
+              <el-link type="primary" v-if="scope.row.ORDER_TRACK_NO" @click="onLogisticsQuery(scope.row.ORDER_TRACK_NO.value)">{{ scope.row.ORDER_TRACK_NO.value }}</el-link>
+            </template>
             <template v-else>
               <div v-html="scope.row[tableHeader.index].value"></div>
             </template>
           </template>
         </el-table-column>
-        <el-table-column fixed="right" label="Action" width="180">&lt;!&ndash; 操作 &ndash;&gt;
+        <el-table-column fixed="right" label="Action" width="180">
          <template slot-scope="scope">
             <el-dropdown size="small" trigger="click">
               <el-button type="primary" size="small" @click.stop="">
@@ -56,6 +59,17 @@
         <el-button type="primary" @click.native="handleDelivery">deliver goods<!-- 发货 --></el-button>
       </div>
     </el-dialog>
+
+    <el-dialog title="物流信息" :visible.sync="dialog" width="30%">
+      <el-timeline :reverse="reverse">
+        <el-timeline-item
+          v-for="(activity, index) in logistics"
+          :key="index"
+          :timestamp="activity.timestamp">
+          {{activity.content}}
+        </el-timeline-item>
+      </el-timeline>
+    </el-dialog>
   </div>
 </template>
 
@@ -95,6 +109,20 @@ export default {
         expressCompany: '',
         orderTrackNo: '',
       },
+      dialog: false,
+      reverse: false,
+      logistics: [
+        {
+          content: '活动按期开始',
+          timestamp: '2018-04-15'
+        }, {
+          content: '通过审核',
+          timestamp: '2018-04-13'
+        }, {
+          content: '创建成功',
+          timestamp: '2018-04-11'
+        }
+      ],
     }
   },
   methods: {
@@ -245,6 +273,12 @@ export default {
         })
       })
     },
+    // 查询物流信息
+    onLogisticsQuery(trackNo) {
+      // 查询物流信息
+
+      this.dialog = true
+    },
   }
 }
 

+ 84 - 0
backendEle/src/views/shop/order-upload.vue

@@ -0,0 +1,84 @@
+<template>
+    <div v-loading="loading">
+        <div class="white-box">
+          <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;">
+            <el-table-column label="ID" prop="ID"> </el-table-column>
+            <el-table-column label="File">
+              <template slot-scope="scope">
+                <el-tag type="danger">{{ scope.row.FILE_NAME }}</el-tag>
+              </template>
+            </el-table-column>
+            <el-table-column label="Create time">
+              <template slot-scope="scope">
+                {{ tool.formatDate(scope.row.CREATED_AT) }}
+              </template>
+            </el-table-column>
+          </el-table>
+
+          <div class="white-box-footer">
+            <el-button type="primary" size="medium" @click="onDialogDisplay">Upload <i class="el-icon-upload el-icon--right"></i></el-button>
+          </div>
+
+          <el-dialog title="Upload" :visible.sync="dialog" width="30%">
+              <el-form ref="form" class="form-page">
+                  <el-form-item>
+                      <div class="up_load">
+                          <leo-uploader :request-route="'shop/order-upload'" @on-success="onSuccess"></leo-uploader>
+                      </div>
+                  </el-form-item>
+              </el-form>
+          </el-dialog>
+        </div>
+    </div>
+</template>
+
+<script>
+import network from '@/utils/network'
+import LeoUploader from '@/components/Uploader';
+import tool from '@/utils/tool';
+
+export default {
+    name: 'shop-upload',
+    components: {
+        LeoUploader
+    },
+    mounted() {
+        this.getFileToken();
+        this.getData();
+    },
+    data() {
+        return {
+            loading: false,
+            uploadToken: '',
+            dialog: false,
+            tool: tool,
+            tableData: [],
+        }
+    },
+    methods: {
+        getFileToken () {
+            network.getData('shop/order-upload').then(response => {
+                this.uploadToken = response;
+            })
+        },
+        onDialogDisplay() {
+            this.dialog = true;
+        },
+        onSuccess() {
+            this.dialog = false;
+            this.getData();
+        },
+        getData () {
+            network.getData('file/upload-order-list').then(response => {
+                this.tableData = response;
+            })
+        },
+    }
+}
+</script>
+
+<style scoped>
+.up_load{
+    width: 100px;
+}
+</style>

+ 2 - 0
common/components/SwooleAsyncTimer.php

@@ -67,6 +67,8 @@ class SwooleAsyncTimer extends SwooleAsyncTimerComponent implements SocketInterf
             Queue::instance()->initRedis();
             // 初始化备份历史奖金数据表
 //            TaskFunc::initAutoBakBalance();
+            // 自动发送订单信息
+            TaskFunc::initAutoOrderLogistics();
         }
     }
 

+ 1 - 1
common/config/main.php

@@ -53,7 +53,7 @@ return [
             // send all mails to a file by default. You have to set
             // 'useFileTransport' to false and configure a transport
             // for the mailer to send real emails.
-            'useFileTransport' => true,
+            'useFileTransport' => false,
         ],
         'swooleAsyncTimer' => [
             'class' => 'common\components\SwooleAsyncTimer',

+ 1 - 0
common/config/params.php

@@ -3,6 +3,7 @@ $nationParams = require_once __DIR__ . '/params-nation.php';
 return [
     'adminEmail' => 'admin@example.com',
     'supportEmail' => 'support@example.com',
+    'logisticsEmail' => '18511880790@163.com',  // 物流仓库EMAIL
     'nation' => $nationParams,
     'backAccessTokenExpiresIn' => 3000 * 60,
     'backRefreshTokenExpiresIn' => 3000 * 60 * 60,

+ 23 - 3
common/libs/taskQueue/TaskFunc.php

@@ -1,14 +1,12 @@
 <?php
 
-
 namespace common\libs\taskQueue;
 
-
 use common\helpers\Cache;
 use common\helpers\Date;
 use common\models\forms\HistoryBonusForm;
+use common\models\forms\OrderLogisticsForm;
 use common\models\TaskQueue;
-use SebastianBergmann\CodeCoverage\Report\PHP;
 
 class TaskFunc
 {
@@ -42,4 +40,26 @@ class TaskFunc
     public static function testTaskQueue(){
         print_r('执行到测试任务'.PHP_EOL);
     }
+
+    public static function initAutoOrderLogistics()
+    {
+        // 查看数据库中是否存在未开始的发送订单的任务,如果没有就添加一个新任务
+//        $taskQueue = TaskQueue::find()->where('TYPE = :TYPE AND CONTENT = :CONTENT AND STARTED_AT > :STARTED_AT', [':TYPE' => Queue::TYPE_FUNC, ':CONTENT' => TaskFunc::class . '::autoSendLogistics', ':STARTED_AT' => Date::nowTime()])->asArray()->exists();
+//        if (!$taskQueue) {
+//            // 获取站点配置中的备份时间
+//            $config = Cache::getSystemConfig();
+//            $backupTime = (int)$config['sendOrderTime']['VALUE'];
+//            Queue::instance()->addTask(Queue::TYPE_FUNC, TaskFunc::class . '::autoSendLogistics', [], Queue::LOOP_TYPE_DAY, $backupTime . ':00', 0);
+//        }
+        self::autoSendLogistics();
+    }
+
+    /**
+     * 自动发送订单到物流站
+     * @return void
+     */
+    public static function autoSendLogistics(){
+        $form = new OrderLogisticsForm();
+        $form->taskAutoSendEmail();
+    }
 }

+ 1 - 0
common/models/Uploads.php

@@ -23,6 +23,7 @@ class Uploads extends \common\components\ActiveRecord
     const CATEGORY_IMAGE = 'image';
     const CATEGORY_EXCEL = 'excel';
     const CATEGORY_UN_KNOW = 'unKnow';
+    const CATEGORY_ORDER = 'order';
 
     /**
      * @inheritdoc

+ 84 - 0
common/models/forms/ExcelOrderForm.php

@@ -0,0 +1,84 @@
+<?php
+namespace common\models\forms;
+
+use common\models\Order;
+
+class ExcelOrderForm extends \common\components\ActiveRecord
+{
+    /**
+     * 导入excel数据
+     */
+    public function run($file)
+    {
+        $fileRows = count(file($file, FILE_SKIP_EMPTY_LINES));
+        if ($fileRows > 500) {
+            return '文件行数最多500';
+        }
+
+        $orderList = [];
+        if (false !== ($handle = fopen($file, 'r'))) {
+            while (false !== ($data = fgetcsv($handle, (filesize($file) + 1)))) {
+                // 订单号和运单号都不能为空
+                $orderSn = $data[0] ?? '';
+                $orderTraceNo = $data[1] ?? '';
+
+                if (!$orderSn) {
+                    fclose($handle);
+                    return '订单号不能为空';
+                }
+                if (!$orderTraceNo) {
+                    fclose($handle);
+                    return '运单号不能为空';
+                }
+                if ((strlen($orderTraceNo) < 5) || (strlen($orderTraceNo) > 20)) {
+                    fclose($handle);
+                    return '运单号长度错误';
+                }
+
+                $orderList[$orderSn] = $orderTraceNo;
+            }
+        } else {
+            return '文件打开错误';
+        }
+
+        fclose($handle);
+
+        if (!$orderList) {
+            return '订单内容为空';
+        }
+
+        $dayLimit = 100;
+        $transaction = \Yii::$app->db->beginTransaction();
+        try {
+            foreach ($orderList as $orderSn => $trackNo) {
+                // 查询订单
+                $order = Order::findOne(['SN' => $orderSn]);
+                if (!$order->SN) {
+                    return "订单【{$orderSn}】无效";
+                }
+                if ($order->STATUS !== \Yii::$app->params['orderStatus']['paid']['value']) {
+                    return "订单【{$orderSn}】支付状态错误";
+                }
+                if ($order->CREATED_AT < strtotime( "-{$dayLimit} days")) {
+                    return "订单【{$orderSn}】创建已超过{$dayLimit}天";
+                }
+
+                try {
+                    // 更新运单号
+                    $order->ORDER_TRACK_NO = $trackNo;
+                    $order->save(false);
+                } catch (\Exception $e) {
+                    $transaction->rollBack();
+                    return "订单【{$orderSn}】更新运单号错误. " . $e->getMessage();
+                }
+            }
+
+            $transaction->commit();
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            return "订单更新运单号错误. Exception " . $e->getMessage();
+        }
+
+        return true;
+    }
+}

+ 139 - 0
common/models/forms/OrderLogisticsForm.php

@@ -0,0 +1,139 @@
+<?php
+
+namespace common\models\forms;
+
+use common\components\Model;
+use common\helpers\Date;
+use common\helpers\LoggerTool;
+use common\models\Order;
+
+/**
+ * 订单物流表单
+ */
+class OrderLogisticsForm extends Model
+{
+    /**
+     * 自动发送订单到仓储服务.
+     * @return bool
+     */
+    public function taskAutoSendEmail(): bool
+    {
+        try {
+            // 公司邮箱
+            $adminEmail = \Yii::$app->params['adminEmail'];
+            // 物流仓储邮件
+            $logisticsEmail = \Yii::$app->params['logisticsEmail'];
+            // 生成附件
+            $attachFile = $this->taskAutoAssembleOrder();
+
+            // 发送邮件
+            $result = \Yii::$app->mailer->compose()
+                ->setFrom([$adminEmail => 'elken'])
+                ->setTo($logisticsEmail)
+                ->setSubject('Order List')
+                ->setTextBody('Plain text content')
+                ->attach($attachFile)
+                ->send();
+        } catch(\Exception $e) {
+            LoggerTool::info('taskAutoSendEmail Exception!' . $e->getMessage());
+        }
+
+        return true;
+    }
+
+    /**
+     * 获取订单.
+     */
+    public function taskAutoAssembleOrder()
+    {
+        // 查询符合条件的订单
+        $orderListData = Order::find()
+            ->select('SN')
+            ->where(
+                'STATUS = :STATUS AND CREATED_AT > :CREATED_AT',
+                [':STATUS' => \Yii::$app->params['orderStatus']['paid']['value'], ':CREATED_AT' => strtotime('-100 days')]
+            )
+            ->asArray()
+            ->limit(10)
+            ->all();
+
+        // 生成Excel
+        if ($orderListData) {
+            $path =  __DS__ . $this->getSaveBasePath() . __DS__ . $this->getSavePath();
+            $this->mkdir($path);
+            $realFile = $path . __DS__ . $this->getFileName();
+            $_fp = fopen($realFile, 'w');
+
+            foreach ($orderListData as $orderData) {
+                fputcsv($_fp, $orderData);
+            }
+
+            fclose($_fp);
+
+            return $realFile;
+        }
+
+        return false;
+    }
+
+    /**
+     * 生成复杂的路径
+     * @param mixed ...$params
+     * @return string
+     */
+    public function pathCreator(...$params): string
+    {
+        $hash = md5(implode('_', $params));
+        $first = substr($hash, 0, 3);
+        $second = substr($hash, 3, 2);
+
+        return $first . __DS__ . $second . __DS__;
+    }
+
+    /**
+     * 获取文件名
+     */
+    public function getFileName($ext = '.csv'): string
+    {
+        return date('YmdHis', Date::nowTime()) . random_int(1000, 9999) . $ext;
+    }
+
+    /**
+     * 获取保存的路径
+     */
+    public function getSavePath(): string
+    {
+        $savePath = $this->pathCreator(date('Ymd', Date::nowTime()));
+        return trim($savePath, __DS__);
+    }
+
+    /**
+     * 获取文件存储位置
+     */
+    public function getSaveBasePath(): string
+    {
+        $saveBasePath = \Yii::getAlias('@common/runtime') . __DS__ . 'excelExport' . __DS__ . \Yii::$app->params['excelLocalDir'];
+        return trim($saveBasePath, __DS__);
+    }
+
+    /**
+     * 创建目录(递归创建)
+     *
+     * @param $dir
+     * @return false
+     */
+    public function mkdir($dir): bool
+    {
+        if (!is_dir($dir)) {
+            $this->mkdir(dirname($dir));
+            if (!mkdir($dir)) {
+                return false;
+            }
+
+            @exec('chown -R centos:centos /' . $dir);
+            @exec('chmod -R 777 /' . $dir);
+        }
+
+        return $dir;
+    }
+}

+ 52 - 13
common/models/forms/UploadForm.php

@@ -71,6 +71,7 @@ class UploadForm extends Model {
             'article' => ['file', 'token'],
             'excel' => ['file', 'token', 'excelOption'],
             'goodsImg' => ['file', 'token'],
+            'order' => ['file', 'token'],
         ];
         return array_merge($parentScenarios, $customScenarios);
     }
@@ -122,7 +123,6 @@ class UploadForm extends Model {
 
     /**
      * 上传
-     * @return bool
      * @throws \yii\db\Exception
      */
     public function upload() {
@@ -133,6 +133,8 @@ class UploadForm extends Model {
         $db = \Yii::$app->db;
         $transaction = $db->beginTransaction();
         try {
+            $fileName = '';
+
             switch ($this->scenario) {
                 case 'invoiceFront':
                     $uploadCategory = Uploads::CATEGORY_INVOICE;
@@ -156,11 +158,23 @@ class UploadForm extends Model {
                     $uploadCategory = Uploads::CATEGORY_EXCEL;
                     $uploadRemark = $this->file->baseName;
                     break;
+                case 'order':
+                    if ($this->file->extension != 'csv') {
+                        LoggerTool::info($this->file->extension);
+                        throw new Exception('只能导入csv文件');
+                    }
+
+                    $uploadCategory = Uploads::CATEGORY_ORDER;
+                    $fileName = date('YmdHis') . mt_rand(1000, 9999);
+                    $uploadRemark = $this->file->baseName;
+                    break;
                 default :
                     $uploadCategory = Uploads::CATEGORY_UN_KNOW;
                     $uploadRemark = $this->file->baseName;
                     break;
             }
+
+            $localPath = '';
             // 上传图片到远程服务器
             if (in_array($this->scenario, $this->_remoteScenario)) {
                 $remoteUploadApi = RemoteUploadApi::instance();
@@ -179,10 +193,10 @@ class UploadForm extends Model {
                 unlink($this->file->tempName);
             } else {
                 // 生成文件名
-//                $fileName = Tool::generateId(false);
-                $fileName = $this->file->baseName;
+                $fileName = $fileName ?: $this->file->baseName;
                 // 保存在本地
                 $localPath = '/ng/Volumes/HDD/workshop/old/ar.upload.ming/files/' . $fileName . '.' . $this->file->extension;
+//                $localPath =  \Yii::getAlias('@common/runtime') . __DS__ . 'excelExport' . __DS__ . 'excel_upload' . __DS__ . $fileName . '.' . $this->file->extension;
                 if (!$this->file->saveAs($localPath)) {
                     throw new Exception('Failed');
                 }
@@ -192,6 +206,7 @@ class UploadForm extends Model {
                     'url' => $fileName . '.' . $this->file->extension,
                     'fileSize' => null,
                     'md5' => null,
+                    'localPath' => $localPath,
                 ];
             }
             // 把上传的文件写入数据库记录中
@@ -285,17 +300,37 @@ class UploadForm extends Model {
                 }
             }elseif ($this->scenario == 'proveFront') {
                 // 如果是上传充值凭证,绑定充值记录
-                    $recharge = Recharge::findOne(['ID' => $this->rechargeId]);
-                    if(!$recharge){
-                        throw new Exception("缺少参数ID");
-                    }
-                    //写入充值表
-                    $recharge->BANK_PROVE = $uploadInfo['url'];
-                    $recharge->AUDIT_STATUS = Recharge::STATUS_PROVED;
-                    if (!$recharge->save()) {
-                        throw new Exception(Form::formatErrorsForApi($recharge->getErrors()));
-                    }
+                $recharge = Recharge::findOne(['ID' => $this->rechargeId]);
+                if(!$recharge){
+                    throw new Exception("缺少参数ID");
+                }
+                //写入充值表
+                $recharge->BANK_PROVE = $uploadInfo['url'];
+                $recharge->AUDIT_STATUS = Recharge::STATUS_PROVED;
+                if (!$recharge->save()) {
+                    throw new Exception(Form::formatErrorsForApi($recharge->getErrors()));
+                }
+            } elseif ($this->scenario == 'order') {
+                // 执行订单上传服务
+                $orderForm = new ExcelOrderForm();
+                $run = $orderForm->run($uploadInfo['localPath']);
+                if ($run !== true) {
+                    throw new Exception(Form::formatErrorsForApi($run));
+                }
+
+                // 把上传的文件写入到导入记录中
+                $excelImport = new ExcelImport();
+                $excelImport->OPTION_NAME = '订单上传';
+                $excelImport->TABLE_NAME = '';
+                $excelImport->UPLOAD_ID = $uploads->ID;
+                $excelImport->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
+                $excelImport->IMPORT_ADMIN_ID = \Yii::$app->user->id;
+                $excelImport->AUDIT_ADMIN_ID = \Yii::$app->user->id;
+                $excelImport->CREATED_AT = Date::nowTime();
+                if (!$excelImport->save()) {
+                    throw new Exception(Form::formatErrorsForApi($excelImport->getErrors()));
                 }
+            }
 
             $transaction->commit();
         } catch (Exception $e) {
@@ -304,6 +339,10 @@ class UploadForm extends Model {
             return false;
         }
 
+        if ($this->scenario == 'order') {
+            $uploads->URL = $localPath;
+        }
+
         return $uploads;
     }
 }

+ 1 - 1
console/config/params.php

@@ -1,6 +1,6 @@
 <?php
 return [
-    'adminEmail' => 'admin@example.com',
+    'adminEmail' => '274435587@qq.com',
     'noticeInterval' => [30, 60, 120], // 秒
     'noticeUrl' => [
         'shopSystem' => 'http://api.anran.leo/users'

+ 36 - 1
frontendEle/src/views/shop/order-list.vue

@@ -28,6 +28,11 @@
                 <el-table-column width="120" label="Created time" prop="CREATED_AT"></el-table-column>
                 <el-table-column width="120" label="Pay time" prop="PAY_AT"></el-table-column>
                 <el-table-column width="120"  label="Pay Status" prop="STATUS"></el-table-column>
+                <el-table-column width="200"  label="Courier Number" prop="ORDER_TRACK_NO">
+                    <template slot-scope="props">
+                        <el-link type="primary" v-if="props.row.ORDER_TRACK_NO" @click="onLogisticsQuery(props.row.ORDER_TRACK_NO)">{{ props.row.ORDER_TRACK_NO }}</el-link>
+                    </template>
+                </el-table-column>
                 <el-table-column width="120" label="Action"><!--操作-->
                   <template slot-scope="scope">
                       <el-button type="primary" size="small" @click.native="handleOrderExportPDF(scope.row.SN)">Export PDF</el-button><!--导出 PDF-->
@@ -38,6 +43,17 @@
                 <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
             </div>
         </div>
+
+        <el-dialog title="物流信息" :visible.sync="dialog" width="30%">
+            <el-timeline :reverse="reverse">
+                <el-timeline-item
+                    v-for="(activity, index) in logistics"
+                    :key="index"
+                    :timestamp="activity.timestamp">
+                    {{activity.content}}
+                </el-timeline-item>
+            </el-timeline>
+        </el-dialog>
     </div>
 </template>
 
@@ -51,7 +67,6 @@
         components: {Pagination},
         mounted() {
             this.getData();
-
         },
         data() {
             return {
@@ -70,6 +85,20 @@
                 spanArr: [], // 用于存放需要合并的行的个数
                 pos: 0, // 记录spanArr数组的下标
                 maxHeight: tool.getTableHeight(),
+                dialog: false,
+                reverse: false,
+                logistics: [
+                    {
+                      content: '活动按期开始',
+                      timestamp: '2018-04-15'
+                    }, {
+                      content: '通过审核',
+                      timestamp: '2018-04-13'
+                    }, {
+                      content: '创建成功',
+                      timestamp: '2018-04-11'
+                    }
+                ],
             }
         },
 
@@ -175,6 +204,12 @@
                     downloadElement.click()
                 })
             },
+          // 查询物流信息
+          onLogisticsQuery(trackNo) {
+              // 查询物流信息
+
+              this.dialog = true
+          },
         }
     }
 </script>