diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index ae6f11519..219a31a09 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -14,6 +14,7 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" + "github.com/360EntSecGroup-Skylar/excelize" "git.rosy.net.cn/jx-callback/business/jxutils/jsonerr" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -70,6 +71,20 @@ type tActRuleInfo struct { type ActManager struct { } +type SheetParamAct struct { + StoreIDCol int + SkuIDCol int + SkuPricePercentageCol int + ActPriceCol int + EarningPriceCol int + StockCol int + ActTypeCol int + ActPricePercentageCol int + ActNameCol int + BeginTimeCol int + EndTimeCol int +} + var ( FixedActManager *ActManager @@ -1316,18 +1331,38 @@ func CreateActByExcel(ctx *jxcontext.Context, files []*multipart.FileHeader, ven } func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int, vendorOrgCode string, mixType int, isFocus, isSync, isAsync, isContinueWhenError bool) (hint string, err error) { + sheetParam := &SheetParamAct{ + StoreIDCol: 0, + SkuIDCol: 2, + SkuPricePercentageCol: 4, + ActPriceCol: 5, + EarningPriceCol: 6, + StockCol: 7, + ActTypeCol: 8, + ActPricePercentageCol: 9, + ActNameCol: 10, + BeginTimeCol: 11, + EndTimeCol: 12, + } taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { + var ( + actObj = &model.Act{} + actStoreSkuList []*ActStoreSkuParam + ) switch step { case 0: //读取excel文件 - // xlsx, err := excelize.OpenReader(reader) - // if err != nil { - // return "", err - // } - // rows, _ := xlsx.GetRows(xlsx.GetSheetName(1)) - // for rowNum, row := range rows { - - // } + xlsx, err := excelize.OpenReader(reader) + if err != nil { + return result, err + } + rows, _ := xlsx.GetRows(xlsx.GetSheetName(1)) + for rowNum, row := range rows { + if rowNum < 1 { + continue + } + err = loadExcelForCreateAct(rowNum, mixType, row, sheetParam, actObj, actStoreSkuList) + } case 1: } return result, err @@ -1342,3 +1377,40 @@ func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int, } return hint, err } + +func loadExcelForCreateAct(rowNum, mixType int, row []string, sheetParam *SheetParamAct, actObj *model.Act, actStoreSkuList []*ActStoreSkuParam) (err error) { + for k, cell := range row { + if rowNum == 1 { + if k == sheetParam.ActTypeCol { + var actType int + for k, v := range model.ActTypeName { + if cell == v { + actType = k + } + } + actObj.Type = actType + } + if k == sheetParam.ActPricePercentageCol { + actObj.PricePercentage = int(utils.Str2Int64(cell) * 10) + } + if k == sheetParam.ActNameCol { + actObj.Name = cell + } + // if k == sheetParam.BeginTimeCol { + // actObj.BeginAt = cell + // } + // if k == sheetParam.EndTimeCol { + // actObj.EndAt = cell + // } + } + //一行一行 + if mixType == 1 { + + } + //叉乘 + if mixType == 2 { + + } + } + return err +} diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index d6bbafb11..dfd58edc3 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -1044,7 +1044,7 @@ func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (storeSkuNameExt []*StoreSk } err = GetRows(db, &skus, sql2, sqlParams2...) v.Skus = skus - err = UpdateActPrice4StoreSkuNameNew(db, storeIDs, []int{v.SkuID}, skuNamesInfo, -1) + err = UpdateActPrice4StoreSkuNameNew(db, storeIDs, []int{v.SkuID}, skuNamesInfo, model.VendorIDJX) } return storeSkuNameExt, err }