临时将发送门店账单用作上传永辉价格表
This commit is contained in:
@@ -3,6 +3,7 @@ package yonghui
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"mime/multipart"
|
||||
"unicode"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
@@ -82,6 +84,17 @@ const (
|
||||
)
|
||||
|
||||
func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, isAsync bool) (hint string, err error) {
|
||||
if len(files) == 0 {
|
||||
return "", errors.New("没有文件上传!")
|
||||
}
|
||||
fileHeader := files[0]
|
||||
file, err := fileHeader.Open()
|
||||
hint, err = LoadExcelBinByYongHui(ctx, file, isAsync)
|
||||
file.Close()
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync bool) (hint string, err error) {
|
||||
var (
|
||||
skuMap = make(map[string]float64)
|
||||
errMsg string
|
||||
@@ -90,18 +103,15 @@ func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, i
|
||||
goodsIDListForPutAway []interface{}
|
||||
)
|
||||
db := dao.GetDB()
|
||||
if len(files) == 0 {
|
||||
return "", errors.New("没有文件上传!")
|
||||
}
|
||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
//读取excel文件
|
||||
xlsx, err := excelize.OpenFile(files[0].Filename)
|
||||
xlsx, err := excelize.OpenReader(reader)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
for k, _ := range sheetMap {
|
||||
for k := range sheetMap {
|
||||
sheetParam := sheetMap[k]
|
||||
rows, _ := xlsx.GetRows(k)
|
||||
for rowNum, row := range rows {
|
||||
@@ -191,7 +201,7 @@ func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, i
|
||||
for _, v := range batchItemList {
|
||||
int64Slice = append(int64Slice, v.(int64))
|
||||
}
|
||||
// PutAwayWeiMobSku(int64Slice)
|
||||
PutAwayWeiMobSku(int64Slice)
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway)
|
||||
@@ -215,11 +225,14 @@ func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, i
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func PutAwayWeiMobSku(goodsIDListForPutAway []int64) {
|
||||
err := api.WeimobAPI.UpdateGoodsShelfStatus(goodsIDListForPutAway, false)
|
||||
func PutAwayWeiMobSku(goodsIDListForPutAway []int64) (err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
// err = api.WeimobAPI.UpdateGoodsShelfStatus(goodsIDListForPutAway, false)
|
||||
}
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("UpdateGoodsShelfStatus error:%v", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetGoodsInfoAndDetailMap(goodsList []*weimobapi.GoodsInfo) (goodsMap map[string]*weimobapi.GoodsInfo) {
|
||||
@@ -294,7 +307,10 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good
|
||||
updateGoodsParam := &weimobapi.UpdateGoodsParam{
|
||||
Goods: goods,
|
||||
}
|
||||
return api.WeimobAPI.UpdateGoods3(updateGoodsParam)
|
||||
if globals.EnableStoreWrite {
|
||||
goodsID, skuMap, err = api.WeimobAPI.UpdateGoods3(updateGoodsParam)
|
||||
}
|
||||
return goodsID, skuMap, err
|
||||
}
|
||||
|
||||
func GetWeiMobGoodsList() (goodsList []*weimobapi.GoodsInfo, err error) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/yonghui"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||
)
|
||||
@@ -42,7 +43,11 @@ func (c *FinancialController) SendFilesToStores() {
|
||||
c.callSendFilesToStores(func(params *tFinancialSendFilesToStoresParams) (retVal interface{}, errCode string, err error) {
|
||||
r := c.Ctx.Request
|
||||
files := r.MultipartForm.File["userfiles"]
|
||||
retVal, err = financial.SendFilesToStores(params.Ctx, files, params.Title, params.ShopName, params.IsAsync, params.Ctx.GetUserName())
|
||||
if params.Title != "永辉" {
|
||||
retVal, err = financial.SendFilesToStores(params.Ctx, files, params.Title, params.ShopName, params.IsAsync, params.Ctx.GetUserName())
|
||||
} else {
|
||||
retVal, err = yonghui.LoadExcelByYongHui(params.Ctx, files, params.IsAsync)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user