Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark
This commit is contained in:
@@ -97,7 +97,15 @@ func AddCategory(ctx *jxcontext.Context, cat *model.SkuCategory, userName string
|
|||||||
dao.WrapAddIDCULDEntity(cat, userName)
|
dao.WrapAddIDCULDEntity(cat, userName)
|
||||||
cat.JdSyncStatus = model.SyncFlagNewMask
|
cat.JdSyncStatus = model.SyncFlagNewMask
|
||||||
cat.JdID = 0
|
cat.JdID = 0
|
||||||
|
cat.Status = model.CategoryStatusEnable
|
||||||
cat.Name = strings.Trim(cat.Name, " ")
|
cat.Name = strings.Trim(cat.Name, " ")
|
||||||
|
if cat.Img != "" {
|
||||||
|
_, err2 := datares.TryRegisterDataResource(ctx, cat.Name, cat.Img, model.ImgTypeLocal, false)
|
||||||
|
if err = err2; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if cat.Seq <= 0 {
|
if cat.Seq <= 0 {
|
||||||
var maxSeq struct {
|
var maxSeq struct {
|
||||||
MaxSeq int
|
MaxSeq int
|
||||||
@@ -144,6 +152,22 @@ func UpdateCategory(ctx *jxcontext.Context, categoryID int, payload map[string]i
|
|||||||
syncStatus = model.SyncFlagModifiedMask
|
syncStatus = model.SyncFlagModifiedMask
|
||||||
valid[model.FieldJdSyncStatus] = int8(syncStatus) | cat.JdSyncStatus
|
valid[model.FieldJdSyncStatus] = int8(syncStatus) | cat.JdSyncStatus
|
||||||
}
|
}
|
||||||
|
if valid["status"] != nil {
|
||||||
|
if utils.Interface2Int64WithDefault(valid["status"], -1) == model.CategoryStatusDisabled {
|
||||||
|
if skuList, err2 := dao.GetSkuByCats(db, []int{categoryID}); err2 == nil && len(skuList) > 0 {
|
||||||
|
return 0, fmt.Errorf("暂不允许禁用分类下有商品的分类!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if valid["img"] != nil {
|
||||||
|
if imgStr := utils.Interface2String(valid["img"]); imgStr != "" {
|
||||||
|
_, err2 := datares.TryRegisterDataResource(ctx, cat.Name, utils.Interface2String(valid["img"]), model.ImgTypeLocal, false)
|
||||||
|
if err = err2; err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package cms
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"mime/multipart"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -2144,21 +2146,21 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefreshJxPriceByExcel(ctx *jxcontext.Context, storeIDs []int, files string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func RefreshJxPriceByExcel(ctx *jxcontext.Context, storeIDs []int, files []*multipart.FileHeader, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
// if len(files) == 0 {
|
if len(files) == 0 {
|
||||||
// return "", errors.New("没有文件上传!")
|
return "", errors.New("没有文件上传!")
|
||||||
// }
|
}
|
||||||
if len(storeIDs) == 0 {
|
if len(storeIDs) == 0 {
|
||||||
return "", errors.New("请选择至少一个门店!")
|
return "", errors.New("请选择至少一个门店!")
|
||||||
}
|
}
|
||||||
// fileHeader := files[0]
|
fileHeader := files[0]
|
||||||
// file, err := fileHeader.Open()
|
file, err := fileHeader.Open()
|
||||||
hint, err = RefreshJxPriceByExcelBin(ctx, storeIDs, files, true, true)
|
hint, err = RefreshJxPriceByExcelBin(ctx, storeIDs, file, true, true)
|
||||||
// file.Close()
|
file.Close()
|
||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader io.Reader, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
var (
|
var (
|
||||||
storeSkuNamePriceList []*model.StoreSkuNamePrice
|
storeSkuNamePriceList []*model.StoreSkuNamePrice
|
||||||
storeSkuNamePriceListUpdate []*model.StoreSkuNamePrice
|
storeSkuNamePriceListUpdate []*model.StoreSkuNamePrice
|
||||||
@@ -2178,8 +2180,8 @@ func RefreshJxPriceByExcelBin(ctx *jxcontext.Context, storeIDs []int, reader str
|
|||||||
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) {
|
||||||
switch step {
|
switch step {
|
||||||
case 0:
|
case 0:
|
||||||
xlsx, err := excelize.OpenFile("111.xlsx")
|
// xlsx, err := excelize.OpenFile("111.xlsx")
|
||||||
// xlsx, err := excelize.OpenReader(reader)
|
xlsx, err := excelize.OpenReader(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ const (
|
|||||||
SkuStatusNormal = 1
|
SkuStatusNormal = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CategoryStatusDisabled = 0
|
||||||
|
CategoryStatusEnable = 1
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
SpecUnitNames = []string{
|
SpecUnitNames = []string{
|
||||||
"g",
|
"g",
|
||||||
@@ -140,9 +145,10 @@ type SkuCategory struct {
|
|||||||
|
|
||||||
// ElmCategoryID int64 `orm:"column(elm_category_id)" json:"elmCategoryID"` // 这个是指对应的饿了么商品类别
|
// ElmCategoryID int64 `orm:"column(elm_category_id)" json:"elmCategoryID"` // 这个是指对应的饿了么商品类别
|
||||||
// WscCategoryID int64 `orm:"column(wsc_category_id)" json:"wscCategoryID"` // 这个是指对应的美团外卖商品类别
|
// WscCategoryID int64 `orm:"column(wsc_category_id)" json:"wscCategoryID"` // 这个是指对应的美团外卖商品类别
|
||||||
|
Status int8 `orm:"default(1)" json:"status"` //分类状态,0表示禁用,1表示启用
|
||||||
JdID int64 `orm:"column(jd_id)" json:"jdID"` // 这个是指商家自己的商品类别在京东平台上的ID
|
Img string `orm:"size(512)" json:"img"` //分类图片
|
||||||
JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
JdID int64 `orm:"column(jd_id)" json:"jdID"` // 这个是指商家自己的商品类别在京东平台上的ID
|
||||||
|
JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*SkuCategory) TableUnique() [][]string {
|
func (*SkuCategory) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -499,10 +499,10 @@ func (c *StoreSkuController) RefershStoreSkusMidPrice() {
|
|||||||
|
|
||||||
// @Title 根据Excel刷新京西门店商品价
|
// @Title 根据Excel刷新京西门店商品价
|
||||||
// @Description 根据Excel刷新京西门店商品价
|
// @Description 根据Excel刷新京西门店商品价
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param storeIDs query string true "门店列表"
|
// @Param storeIDs formData string true "门店列表"
|
||||||
// @Param isAsync query bool true "是否异步,缺省是同步"
|
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||||
// @Param isContinueWhenError query bool true "单个同步失败是否继续,缺省false"
|
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /RefreshJxPriceByExcel [post]
|
// @router /RefreshJxPriceByExcel [post]
|
||||||
@@ -510,9 +510,9 @@ func (c *StoreSkuController) RefreshJxPriceByExcel() {
|
|||||||
var storeIDList []int
|
var storeIDList []int
|
||||||
c.callRefreshJxPriceByExcel(func(params *tStoreSkuRefreshJxPriceByExcelParams) (retVal interface{}, errCode string, err error) {
|
c.callRefreshJxPriceByExcel(func(params *tStoreSkuRefreshJxPriceByExcelParams) (retVal interface{}, errCode string, err error) {
|
||||||
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
||||||
// r := c.Ctx.Request
|
r := c.Ctx.Request
|
||||||
// files := r.MultipartForm.File["userfiles"]
|
files := r.MultipartForm.File["userfiles"]
|
||||||
retVal, err = cms.RefreshJxPriceByExcel(params.Ctx, storeIDList, "files", params.IsAsync, params.IsContinueWhenError)
|
retVal, err = cms.RefreshJxPriceByExcel(params.Ctx, storeIDList, files, params.IsAsync, params.IsContinueWhenError)
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user