Accept Merge Request #173: (su -> mark)
Merge Request: 商城推荐商品取京西活动价 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/173
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user