Accept Merge Request #31: (yonghui -> mark)
Merge Request: 读取永辉excel修改 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/31
This commit is contained in:
@@ -39,12 +39,12 @@ type SheetParam struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DataSuccessLock struct {
|
type DataSuccessLock struct {
|
||||||
dataSuccessList []*DataSuccess
|
dataSuccessList []DataSuccess
|
||||||
locker sync.RWMutex
|
locker sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataFailedLock struct {
|
type DataFailedLock struct {
|
||||||
dataFailedList []*DataFailed
|
dataFailedList []DataFailed
|
||||||
locker sync.RWMutex
|
locker sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,13 +152,13 @@ const (
|
|||||||
fileExt = ".xlsx"
|
fileExt = ".xlsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *DataSuccessLock) AppendData(dataSuccess *DataSuccess) {
|
func (d *DataSuccessLock) AppendData(dataSuccess DataSuccess) {
|
||||||
d.locker.Lock()
|
d.locker.Lock()
|
||||||
defer d.locker.Unlock()
|
defer d.locker.Unlock()
|
||||||
d.dataSuccessList = append(d.dataSuccessList, dataSuccess)
|
d.dataSuccessList = append(d.dataSuccessList, dataSuccess)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataFailedLock) AppendData2(dataFailed *DataFailed) {
|
func (d *DataFailedLock) AppendData2(dataFailed DataFailed) {
|
||||||
d.locker.Lock()
|
d.locker.Lock()
|
||||||
defer d.locker.Unlock()
|
defer d.locker.Unlock()
|
||||||
d.dataFailedList = append(d.dataFailedList, dataFailed)
|
d.dataFailedList = append(d.dataFailedList, dataFailed)
|
||||||
@@ -236,7 +236,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
for k, _ := range skuMap {
|
for k, _ := range skuMap {
|
||||||
//表示excel上有,微盟上没有
|
//表示excel上有,微盟上没有
|
||||||
if goodsInfoAndDetailMap[k] == nil {
|
if goodsInfoAndDetailMap[k] == nil {
|
||||||
outPutData := &DataFailed{
|
outPutData := DataFailed{
|
||||||
GoodsID: k,
|
GoodsID: k,
|
||||||
GoodsName: skuMap[k].Name,
|
GoodsName: skuMap[k].Name,
|
||||||
Comment: "在微盟上未找到该商品",
|
Comment: "在微盟上未找到该商品",
|
||||||
@@ -257,7 +257,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
//获取京西库商品
|
//获取京西库商品
|
||||||
skuList, _ := dao.GetSkus(db, nil, []int{int(utils.Str2Int64(goodsDetail.SkuMap.SingleSku.OuterSkuCode))}, nil, nil)
|
skuList, _ := dao.GetSkus(db, nil, []int{int(utils.Str2Int64(goodsDetail.SkuMap.SingleSku.OuterSkuCode))}, nil, nil)
|
||||||
if len(skuList) == 0 {
|
if len(skuList) == 0 {
|
||||||
outPutData := &DataFailed{
|
outPutData := DataFailed{
|
||||||
GoodsID: spuCode,
|
GoodsID: spuCode,
|
||||||
GoodsName: skuMap[spuCode].Name,
|
GoodsName: skuMap[spuCode].Name,
|
||||||
Comment: "在京西库中未找到该商品",
|
Comment: "在京西库中未找到该商品",
|
||||||
@@ -277,7 +277,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
_, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, isCompare, goodsDetail)
|
_, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, isCompare, goodsDetail)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
outPutData := &DataFailed{
|
outPutData := DataFailed{
|
||||||
GoodsID: spuCode,
|
GoodsID: spuCode,
|
||||||
GoodsName: skuMap[spuCode].Name,
|
GoodsName: skuMap[spuCode].Name,
|
||||||
Comment: errExt.ErrMsg(),
|
Comment: errExt.ErrMsg(),
|
||||||
@@ -285,7 +285,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
dataFailed.AppendData2(outPutData)
|
dataFailed.AppendData2(outPutData)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
outPutData := &DataSuccess{
|
outPutData := DataSuccess{
|
||||||
NameID: goodsDetail.SkuMap.SingleSku.OuterSkuCode,
|
NameID: goodsDetail.SkuMap.SingleSku.OuterSkuCode,
|
||||||
Name: goodsDetail.Title,
|
Name: goodsDetail.Title,
|
||||||
Unit: skuList[0].Unit,
|
Unit: skuList[0].Unit,
|
||||||
@@ -665,7 +665,7 @@ func GetReplaceNewTitle(title, prefix string) (newTitle string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteToExcel(task *tasksch.SeqTask, dataSuccess []*DataSuccess, dataFailed []*DataFailed) (err error) {
|
func WriteToExcel(task *tasksch.SeqTask, dataSuccess []DataSuccess, dataFailed []DataFailed) (err error) {
|
||||||
var sheetList1 []*excel.Obj2ExcelSheetConfig
|
var sheetList1 []*excel.Obj2ExcelSheetConfig
|
||||||
var sheetList2 []*excel.Obj2ExcelSheetConfig
|
var sheetList2 []*excel.Obj2ExcelSheetConfig
|
||||||
var downloadURL1, downloadURL2, fileName1, fileName2 string
|
var downloadURL1, downloadURL2, fileName1, fileName2 string
|
||||||
|
|||||||
Reference in New Issue
Block a user