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

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
import (
"errors"
"fmt"
"io"
"math"
"mime/multipart"
"time"
"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)
return retVal, err
}, neeSyncActIDs)
tasksch.HandleTask(task, nil, true).Run()
if !isAsync {
hint = utils.Int2Str(act.ID)
@@ -1319,18 +1316,18 @@ func SyncSpecialAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model
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) {
if len(files) == 0 {
return "", errors.New("没有文件上传!")
}
fileHeader := files[0]
file, err := fileHeader.Open()
hint, err = CreateActByExcelBin(ctx, file, vendorID, vendorOrgCode, mixType, isFocus, isSync, isAsync, isContinueWhenError)
file.Close()
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 {
// return "", errors.New("没有文件上传!")
// }
// fileHeader := files[0]
// file, err := fileHeader.Open()
hint, err = CreateActByExcelBin(ctx, files, vendorID, vendorOrgCode, mixType, isFocus, isSync, isAsync, isContinueWhenError)
// file.Close()
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{
StoreIDCol: 0,
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) {
var (
actObj = &model.Act{}
actStoreSkuList []*ActStoreSkuParam
actObj = &model.Act{}
actStoreSkuList []*ActStoreSkuParam
actStoreSkusResult []*ActStoreSkuParam
storeIDs []int
)
switch step {
case 0:
//读取excel文件
xlsx, err := excelize.OpenReader(reader)
xlsx, err := excelize.OpenFile("111.xlsx")
// xlsx, err := excelize.OpenReader(reader)
if err != nil {
return result, err
}
@@ -1361,9 +1361,23 @@ func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int,
if rowNum < 1 {
continue
}
err = loadExcelForCreateAct(rowNum, mixType, row, sheetParam, actObj, actStoreSkuList)
loadExcelForCreateAct(rowNum, mixType, row, sheetParam, actObj, actStoreSkuList, storeIDs)
}
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
}
@@ -1378,7 +1392,8 @@ 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) {
func loadExcelForCreateAct(rowNum, mixType int, row []string, sheetParam *SheetParamAct, actObj *model.Act, actStoreSkuList []*ActStoreSkuParam, storeIDs []int) {
actStoreSku := &ActStoreSkuParam{}
for k, cell := range row {
if rowNum == 1 {
if k == sheetParam.ActTypeCol {
@@ -1386,31 +1401,55 @@ func loadExcelForCreateAct(rowNum, mixType int, row []string, sheetParam *SheetP
for k, v := range model.ActTypeName {
if cell == v {
actType = k
break
}
}
actObj.Type = actType
}
if k == sheetParam.ActPricePercentageCol {
actObj.PricePercentage = int(utils.Str2Int64(cell) * 10)
actObj.PricePercentage = int(utils.Str2Float64(cell) * 10)
}
if k == sheetParam.ActNameCol {
actObj.Name = cell
}
// if k == sheetParam.BeginTimeCol {
// actObj.BeginAt = cell
// }
// if k == sheetParam.EndTimeCol {
// actObj.EndAt = cell
// }
if k == sheetParam.BeginTimeCol {
begin, err := time.Parse("2006年1月2日 15:04:05", cell)
if err != nil {
begin = utils.ZeroTimeValue
}
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 mixType == 1 {
if k == sheetParam.StoreIDCol {
//一行一行
if mixType == 1 {
actStoreSku.StoreID = int(utils.Str2Int64(cell))
} else if mixType == 2 {
storeIDs = append(storeIDs, int(utils.Str2Int64(cell)))
}
}
//叉乘
if mixType == 2 {
if k == sheetParam.SkuIDCol {
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",
}
roleMap = map[string]string{
"marketManPhone": "市场负责人电话",
"marketManRole": "市场负责人组(角色,单人)",
// "marketManPhone": "市场负责人电话",
// "marketManRole": "市场负责人组(角色,单人)",
"jxBrandFeeFactor": "京西品牌费因子",
"marketAddFeeFactor": "市场附加费因子",
"payeeName": "收款人姓名",

View File

@@ -346,9 +346,9 @@ func (c *ActController) ForceUpdateVendorPrice() {
// @router /CreateActByExcel [post]
func (c *ActController) CreateActByExcel() {
c.callCreateActByExcel(func(params *tActCreateActByExcelParams) (retVal interface{}, errCode string, err error) {
r := c.Ctx.Request
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)
// r := c.Ctx.Request
// 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)
return retVal, "", err
})
}