运营权限修改,可修改市场负责人电话和组

This commit is contained in:
苏尹岚
2020-02-05 14:39:26 +08:00
parent a5f677d2b2
commit 52fbbb020b
3 changed files with 76 additions and 37 deletions

View File

@@ -1,11 +1,8 @@
package act package act
import ( import (
"errors"
"fmt" "fmt"
"io"
"math" "math"
"mime/multipart"
"time" "time"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
@@ -599,7 +596,7 @@ func CreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, vendorOr
_, err = SyncAct(ctx, task, actID, nil, false) _, err = SyncAct(ctx, task, actID, nil, false)
return retVal, err return retVal, err
}, neeSyncActIDs) }, neeSyncActIDs)
tasksch.HandleTask(task, nil, true).Run() tasksch.HandleTask(task, nil, true).Run()
if !isAsync { if !isAsync {
hint = utils.Int2Str(act.ID) hint = utils.Int2Str(act.ID)
@@ -1319,18 +1316,18 @@ func SyncSpecialAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model
return err return err
} }
func CreateActByExcel(ctx *jxcontext.Context, files []*multipart.FileHeader, vendorID int, vendorOrgCode string, mixType int, isFocus, isSync, isAsync, isContinueWhenError bool) (hint string, err error) { func CreateActByExcel(ctx *jxcontext.Context, files string, vendorID int, vendorOrgCode string, mixType int, isFocus, isSync, isAsync, isContinueWhenError bool) (hint string, err error) {
if len(files) == 0 { // if len(files) == 0 {
return "", errors.New("没有文件上传!") // return "", errors.New("没有文件上传!")
} // }
fileHeader := files[0] // fileHeader := files[0]
file, err := fileHeader.Open() // file, err := fileHeader.Open()
hint, err = CreateActByExcelBin(ctx, file, vendorID, vendorOrgCode, mixType, isFocus, isSync, isAsync, isContinueWhenError) hint, err = CreateActByExcelBin(ctx, files, vendorID, vendorOrgCode, mixType, isFocus, isSync, isAsync, isContinueWhenError)
file.Close() // file.Close()
return hint, err return hint, err
} }
func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int, vendorOrgCode string, mixType int, isFocus, isSync, isAsync, isContinueWhenError bool) (hint string, err error) { func CreateActByExcelBin(ctx *jxcontext.Context, reader string, vendorID int, vendorOrgCode string, mixType int, isFocus, isSync, isAsync, isContinueWhenError bool) (hint string, err error) {
sheetParam := &SheetParamAct{ sheetParam := &SheetParamAct{
StoreIDCol: 0, StoreIDCol: 0,
SkuIDCol: 2, SkuIDCol: 2,
@@ -1346,13 +1343,16 @@ func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int,
} }
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
var ( var (
actObj = &model.Act{} actObj = &model.Act{}
actStoreSkuList []*ActStoreSkuParam actStoreSkuList []*ActStoreSkuParam
actStoreSkusResult []*ActStoreSkuParam
storeIDs []int
) )
switch step { switch step {
case 0: case 0:
//读取excel文件 //读取excel文件
xlsx, err := excelize.OpenReader(reader) xlsx, err := excelize.OpenFile("111.xlsx")
// xlsx, err := excelize.OpenReader(reader)
if err != nil { if err != nil {
return result, err return result, err
} }
@@ -1361,9 +1361,23 @@ func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int,
if rowNum < 1 { if rowNum < 1 {
continue continue
} }
err = loadExcelForCreateAct(rowNum, mixType, row, sheetParam, actObj, actStoreSkuList) loadExcelForCreateAct(rowNum, mixType, row, sheetParam, actObj, actStoreSkuList, storeIDs)
} }
case 1: case 1:
//叉乘
if mixType == 2 {
for _, v := range storeIDs {
for _, vv := range actStoreSkuList {
actStoreSkus := &ActStoreSkuParam{}
actStoreSkus = vv
actStoreSkus.StoreID = v
actStoreSkusResult = append(actStoreSkusResult, actStoreSkus)
}
}
_, err = CreateAct(ctx, actObj, []int{vendorID}, vendorOrgCode, nil, actStoreSkusResult, isAsync)
} else if mixType == 1 {
_, err = CreateAct(ctx, actObj, []int{vendorID}, vendorOrgCode, nil, actStoreSkuList, isAsync)
}
} }
return result, err return result, err
} }
@@ -1378,7 +1392,8 @@ func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int,
return hint, err return hint, err
} }
func loadExcelForCreateAct(rowNum, mixType int, row []string, sheetParam *SheetParamAct, actObj *model.Act, actStoreSkuList []*ActStoreSkuParam) (err error) { func loadExcelForCreateAct(rowNum, mixType int, row []string, sheetParam *SheetParamAct, actObj *model.Act, actStoreSkuList []*ActStoreSkuParam, storeIDs []int) {
actStoreSku := &ActStoreSkuParam{}
for k, cell := range row { for k, cell := range row {
if rowNum == 1 { if rowNum == 1 {
if k == sheetParam.ActTypeCol { if k == sheetParam.ActTypeCol {
@@ -1386,31 +1401,55 @@ func loadExcelForCreateAct(rowNum, mixType int, row []string, sheetParam *SheetP
for k, v := range model.ActTypeName { for k, v := range model.ActTypeName {
if cell == v { if cell == v {
actType = k actType = k
break
} }
} }
actObj.Type = actType actObj.Type = actType
} }
if k == sheetParam.ActPricePercentageCol { if k == sheetParam.ActPricePercentageCol {
actObj.PricePercentage = int(utils.Str2Int64(cell) * 10) actObj.PricePercentage = int(utils.Str2Float64(cell) * 10)
} }
if k == sheetParam.ActNameCol { if k == sheetParam.ActNameCol {
actObj.Name = cell actObj.Name = cell
} }
// if k == sheetParam.BeginTimeCol { if k == sheetParam.BeginTimeCol {
// actObj.BeginAt = cell begin, err := time.Parse("2006年1月2日 15:04:05", cell)
// } if err != nil {
// if k == sheetParam.EndTimeCol { begin = utils.ZeroTimeValue
// actObj.EndAt = cell }
// } actObj.BeginAt = begin
}
if k == sheetParam.EndTimeCol {
end, err := time.Parse("2006年1月2日 15:04:05", cell)
if err != nil {
end = utils.ZeroTimeValue
}
actObj.EndAt = end
}
} }
//一行一行 if k == sheetParam.StoreIDCol {
if mixType == 1 { //一行一行
if mixType == 1 {
actStoreSku.StoreID = int(utils.Str2Int64(cell))
} else if mixType == 2 {
storeIDs = append(storeIDs, int(utils.Str2Int64(cell)))
}
} }
//叉乘 if k == sheetParam.SkuIDCol {
if mixType == 2 { actStoreSku.SkuID = int(utils.Str2Int64(cell))
}
if k == sheetParam.SkuPricePercentageCol {
actStoreSku.PricePercentage = int(utils.Str2Float64WithDefault(cell, 0) * 10)
}
if k == sheetParam.ActPriceCol {
actStoreSku.ActPrice = int64(utils.Str2Float64(cell) * 100)
}
if k == sheetParam.EarningPriceCol {
actStoreSku.EarningPrice = int64(utils.Str2Float64(cell) * 100)
}
if k == sheetParam.StockCol {
actStoreSku.Stock = int(utils.Str2Int64(cell))
} }
} }
return err actStoreSkuList = append(actStoreSkuList, actStoreSku)
} }

View File

@@ -208,8 +208,8 @@ var (
"运营负责人2", "运营负责人2",
} }
roleMap = map[string]string{ roleMap = map[string]string{
"marketManPhone": "市场负责人电话", // "marketManPhone": "市场负责人电话",
"marketManRole": "市场负责人组(角色,单人)", // "marketManRole": "市场负责人组(角色,单人)",
"jxBrandFeeFactor": "京西品牌费因子", "jxBrandFeeFactor": "京西品牌费因子",
"marketAddFeeFactor": "市场附加费因子", "marketAddFeeFactor": "市场附加费因子",
"payeeName": "收款人姓名", "payeeName": "收款人姓名",

View File

@@ -346,9 +346,9 @@ func (c *ActController) ForceUpdateVendorPrice() {
// @router /CreateActByExcel [post] // @router /CreateActByExcel [post]
func (c *ActController) CreateActByExcel() { func (c *ActController) CreateActByExcel() {
c.callCreateActByExcel(func(params *tActCreateActByExcelParams) (retVal interface{}, errCode string, err error) { c.callCreateActByExcel(func(params *tActCreateActByExcelParams) (retVal interface{}, errCode string, err error) {
r := c.Ctx.Request // r := c.Ctx.Request
files := r.MultipartForm.File["userfiles"] // files := r.MultipartForm.File["userfiles"]
retVal, err = act.CreateActByExcel(params.Ctx, files, params.VendorID, params.VendorOrgCode, params.MixType, params.IsFocus, params.IsSync, params.IsAsync, params.IsContinueWhenError) retVal, err = act.CreateActByExcel(params.Ctx, "files", params.VendorID, params.VendorOrgCode, params.MixType, params.IsFocus, params.IsSync, params.IsAsync, params.IsContinueWhenError)
return retVal, "", err return retVal, "", err
}) })
} }