商品映射类目
This commit is contained in:
@@ -904,6 +904,8 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
|||||||
}
|
}
|
||||||
outSkuNameExt = tmpInfo.SkuNames[0]
|
outSkuNameExt = tmpInfo.SkuNames[0]
|
||||||
_, err = CurVendorSync.SyncSku(ctx, db, outSkuNameExt.SkuName.ID, -1, false, false, userName)
|
_, err = CurVendorSync.SyncSku(ctx, db, outSkuNameExt.SkuName.ID, -1, false, false, userName)
|
||||||
|
|
||||||
|
updateOrCreateSkuVendorCategoryMap(db, ctx, outSkuNameExt.SkuName.ID, nil, skuNameExt, false)
|
||||||
return outSkuNameExt, err
|
return outSkuNameExt, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -981,7 +983,7 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateOrCreateSkuVendorCategoryMap(db, ctx, nameID, payload, false)
|
updateOrCreateSkuVendorCategoryMap(db, ctx, nameID, payload, nil, false)
|
||||||
if utils.Interface2Int64WithDefault(payload["isGlobal"], 0) == 0 && payload["places"] != nil {
|
if utils.Interface2Int64WithDefault(payload["isGlobal"], 0) == 0 && payload["places"] != nil {
|
||||||
if places, ok := payload["places"].([]interface{}); ok {
|
if places, ok := payload["places"].([]interface{}); ok {
|
||||||
if _, err = dao.DeleteSkuNamePlace(db, nameID, nil); err != nil {
|
if _, err = dao.DeleteSkuNamePlace(db, nameID, nil); err != nil {
|
||||||
@@ -1053,23 +1055,55 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, nameID int, payload map[string]interface{}, isDelete bool) {
|
func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, nameID int, payload map[string]interface{}, skuNameExt *model.SkuNameExt, isDelete bool) {
|
||||||
if isDelete {
|
if isDelete {
|
||||||
|
skuVendorCatMaps, _ := dao.GetSkuVendorCategoryMaps(db, []int{nameID}, nil, nil)
|
||||||
|
for _, v := range skuVendorCatMaps {
|
||||||
|
v.DeletedAt = time.Now()
|
||||||
|
v.LastOperator = ctx.GetUserName()
|
||||||
|
dao.UpdateEntity(db, v, "DeletedAt", "LastOperator")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
updateOrCreate := func(vendorID, nameID int, vendorCatID string) {
|
||||||
if payload["jdCategoryID"].(string) != "" {
|
skuVendorCatMaps, _ := dao.GetSkuVendorCategoryMaps(db, []int{nameID}, []int{vendorID}, nil)
|
||||||
skuVendorCatMaps, _ := dao.GetSkuVendorCategoryMaps(db, []int{nameID}, []int{model.VendorIDJD}, nil)
|
|
||||||
if len(skuVendorCatMaps) > 0 {
|
if len(skuVendorCatMaps) > 0 {
|
||||||
skuVendorCatMaps[0].VendorCategoryID = payload["jdCategoryID"].(string)
|
skuVendorCatMaps[0].VendorCategoryID = vendorCatID
|
||||||
dao.UpdateEntity(db, skuVendorCatMaps[0], "VendorCategoryID")
|
dao.UpdateEntity(db, skuVendorCatMaps[0], "VendorCategoryID")
|
||||||
} else {
|
} else {
|
||||||
skuVendorCatMap := &model.SkuVendorCategoryMap{
|
skuVendorCatMap := &model.SkuVendorCategoryMap{
|
||||||
NameID: nameID,
|
NameID: nameID,
|
||||||
VendorID: model.VendorIDJD,
|
VendorID: vendorID,
|
||||||
VendorCategoryID: payload["jdCategoryID"].(string),
|
VendorCategoryID: vendorCatID,
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(skuVendorCatMap, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(skuVendorCatMap, ctx.GetUserName())
|
||||||
|
dao.CreateEntity(db, skuVendorCatMap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if skuNameExt != nil {
|
||||||
|
if skuNameExt.JdCategoryID != "" {
|
||||||
|
updateOrCreate(model.VendorIDJD, nameID, skuNameExt.JdCategoryID)
|
||||||
|
}
|
||||||
|
if skuNameExt.JdsCategoryID != "" {
|
||||||
|
updateOrCreate(model.VendorIDJDShop, nameID, skuNameExt.JdsCategoryID)
|
||||||
|
}
|
||||||
|
if skuNameExt.EbaiCategoryID != "" {
|
||||||
|
updateOrCreate(model.VendorIDEBAI, nameID, skuNameExt.EbaiCategoryID)
|
||||||
|
}
|
||||||
|
if skuNameExt.MtwmCategoryID != "" {
|
||||||
|
updateOrCreate(model.VendorIDMTWM, nameID, skuNameExt.MtwmCategoryID)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if payload["jdCategoryID"].(string) != "" {
|
||||||
|
updateOrCreate(model.VendorIDJD, nameID, payload["jdCategoryID"].(string))
|
||||||
|
}
|
||||||
|
if payload["jdsCategoryID"].(string) != "" {
|
||||||
|
updateOrCreate(model.VendorIDJDShop, nameID, payload["jdsCategoryID"].(string))
|
||||||
|
}
|
||||||
|
if payload["ebaiCategoryID"].(string) != "" {
|
||||||
|
updateOrCreate(model.VendorIDEBAI, nameID, payload["ebaiCategoryID"].(string))
|
||||||
|
}
|
||||||
|
if payload["mtwmCategoryID"].(string) != "" {
|
||||||
|
updateOrCreate(model.VendorIDMTWM, nameID, payload["mtwmCategoryID"].(string))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1142,6 +1176,7 @@ func DeleteSkuName(ctx *jxcontext.Context, nameID int, userName string) (num int
|
|||||||
if len(skuList) > 0 {
|
if len(skuList) > 0 {
|
||||||
_, err = CurVendorSync.SyncSku(ctx, db, skuName.ID, -1, false, false, userName)
|
_, err = CurVendorSync.SyncSku(ctx, db, skuName.ID, -1, false, false, userName)
|
||||||
}
|
}
|
||||||
|
updateOrCreateSkuVendorCategoryMap(db, ctx, nameID, nil, nil, true)
|
||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -284,6 +284,11 @@ type SkuNameExt struct {
|
|||||||
Places []int `orm:"-" json:"places"`
|
Places []int `orm:"-" json:"places"`
|
||||||
PlacesStr string `json:"-"`
|
PlacesStr string `json:"-"`
|
||||||
MidUnitPrice int `json:"midUnitPrice"`
|
MidUnitPrice int `json:"midUnitPrice"`
|
||||||
|
|
||||||
|
JdCategoryID string `json:"JdCategoryID"`
|
||||||
|
JdsCategoryID string `json:"JdsCategoryID"`
|
||||||
|
EbaiCategoryID string `json:"EbaiCategoryID"`
|
||||||
|
MtwmCategoryID string `json:"MtwmCategoryID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SkuExinfoMap struct {
|
type SkuExinfoMap struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user