Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

孙龙 / note-library

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Find file
Normal viewHistoryPermalink
Switch branch/tag
  • note-library
  • app
  • Http
  • Controllers
  • ExportController.php
ExportController.php 2.98 KB
孙龙's avatar
init
1f46a6ed
 
孙龙 committed 5 years ago
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
<?php
namespace App\Http\Controllers;

use App\Model\ComCreditsModel;
use App\Model\Export\CommonModel;
use App\Model\Logic\ComCreditsLogic;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use App\Model\OrderModel;
use App\Model\CustomerModel;
use App\Model\SupplierModel;
use App\Model\SupplierBankModel;
use App\Model\GoodsModel;
use App\Model\ComBankModel;
use Excel;

Class ExportController extends Controller
{
    // 统一入口
    public function entrance(Request $request, $id)
    {
       return $this->$id($request);
    }

    // 导出订单
    public function orderListExport($request)
    {
    	$OrderModel = new OrderModel();
        $data = $OrderModel->lists($request, 1);

        foreach ($data as $k=>$v) {
            $cellData[$k]['order_id']          = $v['order_id']; 
            $cellData[$k]['order_sn']          = $v['order_sn']; 
            $cellData[$k]['company_full_name'] = $v['company_full_name']; 
            $cellData[$k]['customer_name']     = $v['customer_name']; 
            $cellData[$k]['follow_people']     = $v['follow_people']; 
            $cellData[$k]['status']            = Config('config.order_status')[$v['status']]; 
            $cellData[$k]['hk_in_store']       = $v['hk_in_store']; 
            $cellData[$k]['sz_in_store']       = $v['sz_in_store']; 
            $cellData[$k]['sz_out_store']      = $v['sz_out_store']; 
            $cellData[$k]['create_time']       = $v['create_time']; 
            $cellData[$k]['audit_time']        = $v['audit_time']; 
        }

        $headerCell = ['订单ID', '订单编号', '公司名称', '手机号码', '商务', '状态', '香港入仓', '深圳仓入仓', '深圳仓发货', '创建时间', '审核时间']; 
        $fileName   ='供应链订单导出'.date('_YmdHis');
        $sheetName  = '订单导出';

        $this->commonFunc($cellData, $headerCell, $fileName, $sheetName);       
    }


    //评分导出
    public function scoreList(Request $request)
    {
        $whereData = $request->only(['status','erp_company_code','company_name','begin_time','end_time']);
        $comCreditsObj = new ComCreditsModel();
        $list = ComCreditsLogic::postWhere($comCreditsObj,$whereData)->select()->get()->toArray();
        CommonModel::exportExcelNormal('score_list',$list,'评分列表');
    }

    /**
     *  导出
     * @param  [type] $cellData   [导出数据]
     * @param  [type] $headerCell [菜单项]
     * @param  [type] $fileName   [文件名]
     * @param  string $sheetName  [sheet名]
     * @return [type]             [description]
     */
    public function commonFunc($cellData, $headerCell, $fileName, $sheetName='') 
    {
        $sheetName = $sheetName ? $sheetName : '导出';

        array_unshift($cellData, $headerCell);

        Excel::create($fileName, function($excel) use ($cellData, $sheetName){
            $excel->sheet($sheetName, function($sheet) use ($cellData){
                $sheet->rows($cellData);
            });
        })->export('xls');
    }





}