根据Excel更新京西价
This commit is contained in:
@@ -3,7 +3,9 @@ package cms
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"mime/multipart"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -2144,21 +2146,21 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error
|
||||
return err
|
||||
}
|
||||
|
||||
func RefreshJxPriceByExcel(ctx *jxcontext.Context, storeIDs []int, files string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
// if len(files) == 0 {
|
||||
// return "", errors.New("没有文件上传!")
|
||||
// }
|
||||
func RefreshJxPriceByExcel(ctx *jxcontext.Context, storeIDs []int, files []*multipart.FileHeader, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
if len(files) == 0 {
|
||||
return "", errors.New("没有文件上传!")
|
||||
}
|
||||
if len(storeIDs) == 0 {
|
||||
return "", errors.New("请选择至少一个门店!")
|
||||
}
|
||||
// fileHeader := files[0]
|
||||
// file, err := fileHeader.Open()
|
||||
hint, err = RefreshJxPriceByExcelBin(ctx, storeIDs, files, true, true)
|
||||
// file.Close()
|
||||
fileHeader := files[0]
|
||||
file, err := fileHeader.Open()
|
||||
hint, err = RefreshJxPriceByExcelBin(ctx, storeIDs, file, true, true)
|
||||
file.Close()
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader io.Reader, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
var (
|
||||
storeSkuNamePriceList []*model.StoreSkuNamePrice
|
||||
storeSkuNamePriceListUpdate []*model.StoreSkuNamePrice
|
||||
@@ -2178,8 +2180,8 @@ func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader str
|
||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
xlsx, err := excelize.OpenFile("111.xlsx")
|
||||
// xlsx, err := excelize.OpenReader(reader)
|
||||
// xlsx, err := excelize.OpenFile("111.xlsx")
|
||||
xlsx, err := excelize.OpenReader(reader)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -510,9 +510,9 @@ func (c *StoreSkuController) RefreshJxPriceByExcel() {
|
||||
var storeIDList []int
|
||||
c.callRefreshJxPriceByExcel(func(params *tStoreSkuRefreshJxPriceByExcelParams) (retVal interface{}, errCode string, err error) {
|
||||
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
||||
// r := c.Ctx.Request
|
||||
// files := r.MultipartForm.File["userfiles"]
|
||||
retVal, err = cms.RefreshJxPriceByExcel(params.Ctx, storeIDList, "files", params.IsAsync, params.IsContinueWhenError)
|
||||
r := c.Ctx.Request
|
||||
files := r.MultipartForm.File["userfiles"]
|
||||
retVal, err = cms.RefreshJxPriceByExcel(params.Ctx, storeIDList, files, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user