- ExportMTWaybills
- Obj2Excel
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
@@ -168,3 +174,33 @@ func (c *OrderController) GetOrderWaybillInfo() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Param token header string true "认证token"
|
||||
|
||||
// @Title 导出美团运单
|
||||
// @Description 导出美团运单
|
||||
// @Param fromDate query string true "开始日期(包含),格式(2006-01-02)"
|
||||
// @Param toDate query string false "结束日期(包含),格式(2006-01-02)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /ExportMTWaybills [get]
|
||||
func (c *OrderController) ExportMTWaybills() {
|
||||
var content []byte
|
||||
var fromDate, toDate string
|
||||
c.callExportMTWaybills(func(params *tOrderExportMTWaybillsParams) (retVal interface{}, errCode string, err error) {
|
||||
fromDate = params.FromDate
|
||||
toDate = params.ToDate
|
||||
if toDate == "" {
|
||||
toDate = fromDate
|
||||
}
|
||||
content, err = orderman.FixedOrderManager.ExportMTWaybills(params.FromDate, params.ToDate)
|
||||
globals.SugarLogger.Debug(err)
|
||||
return retVal, ignoreCode, err
|
||||
})
|
||||
if content != nil {
|
||||
c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/vnd.ms-excel")
|
||||
fileName := strings.Replace(fmt.Sprintf("attachment;filename=美团运单表%s至%sat%s.xlsx", fromDate, toDate, utils.Time2Str(time.Now())), " ", "-", 1)
|
||||
c.Ctx.ResponseWriter.Header().Set("content-disposition", fileName)
|
||||
c.Ctx.ResponseWriter.Write(content)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user