Accept Merge Request #80: (yonghui -> mark)
Merge Request: 根据Excel修改京西价修改 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/80
This commit is contained in:
@@ -2182,6 +2182,7 @@ func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader io.
|
||||
skuBindInfoList []*StoreSkuBindInfo
|
||||
errMsg string
|
||||
isErr bool = false
|
||||
nameMap = make(map[string]string)
|
||||
)
|
||||
dataLock.dataFailedList = dataLock.dataFailedList[0:0]
|
||||
dataLock.dataSuccessList = dataLock.dataSuccessList[0:0]
|
||||
@@ -2196,6 +2197,7 @@ func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader io.
|
||||
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)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -2206,7 +2208,7 @@ func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader io.
|
||||
continue
|
||||
}
|
||||
storeSkuNamePrice := &model.StoreSkuNamePrice{}
|
||||
errMsg += GetCellIntoStruct(rowNum, row, sheetParam, storeSkuNamePrice)
|
||||
errMsg += GetCellIntoStruct(rowNum, row, sheetParam, storeSkuNamePrice, nameMap)
|
||||
storeSkuNamePriceList = append(storeSkuNamePriceList, storeSkuNamePrice)
|
||||
}
|
||||
if errMsg != "" {
|
||||
@@ -2380,8 +2382,7 @@ func StoreSkuNamePriceList2Map(ctx *jxcontext.Context, storeSkuNamePriceList []*
|
||||
return result
|
||||
}
|
||||
|
||||
func GetCellIntoStruct(rowNum int, row []string, sheetParam *SheetParam, storeSkuNamePrice *model.StoreSkuNamePrice) (errMsg string) {
|
||||
var nameMap = make(map[string]string)
|
||||
func GetCellIntoStruct(rowNum int, row []string, sheetParam *SheetParam, storeSkuNamePrice *model.StoreSkuNamePrice, nameMap map[string]string) (errMsg string) {
|
||||
for k, cell := range row {
|
||||
if k == sheetParam.OutSkuIDCol {
|
||||
if IsChineseChar(cell) {
|
||||
@@ -2398,16 +2399,16 @@ func GetCellIntoStruct(rowNum int, row []string, sheetParam *SheetParam, storeSk
|
||||
if cellReplace[len(cellReplace)-1:len(cellReplace)] == "," {
|
||||
cellReplace = cellReplace[0 : len(cellReplace)-1]
|
||||
}
|
||||
}
|
||||
storeSkuNamePrice.NameIDGroup = cellReplace
|
||||
nameIDs := strings.Split(cellReplace, ",")
|
||||
for _, v := range nameIDs {
|
||||
if nameMap[v] != "" {
|
||||
return fmt.Sprintf("Excel中含有重复的nameID![%v]列,[%v]行,nameID [%v]", k+1, rowNum+1, v)
|
||||
} else {
|
||||
nameMap[v] = v
|
||||
nameIDs := strings.Split(cellReplace, ",")
|
||||
for _, v := range nameIDs {
|
||||
if nameMap[v] != "" {
|
||||
return fmt.Sprintf(" Excel中含有重复的nameID![%v]列,[%v]行,nameID [%v]\n", k+1, rowNum+1, v)
|
||||
} else {
|
||||
nameMap[v] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
storeSkuNamePrice.NameIDGroup = cellReplace
|
||||
}
|
||||
if k == sheetParam.SkuPriceCol {
|
||||
if IsChineseChar(cell) {
|
||||
|
||||
Reference in New Issue
Block a user