去掉SkuCategoryWithVendor
This commit is contained in:
@@ -44,16 +44,16 @@ func SyncCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs
|
|||||||
// todo 按vendorID orgCode合并操作
|
// todo 按vendorID orgCode合并操作
|
||||||
task := tasksch.NewParallelTask(fmt.Sprintf("同步分类:%v", catIDs), nil, ctx,
|
task := tasksch.NewParallelTask(fmt.Sprintf("同步分类:%v", catIDs), nil, ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
catVendorInfo := batchItemList[0].(*dao.SkuCategoryWithVendor)
|
catVendorInfo := batchItemList[0].(*dao.SkuStoreCatInfo)
|
||||||
if multiStoresHandler, ok := partner.GetPurchasePlatformFromVendorID(catVendorInfo.VendorID).(partner.IMultipleStoresHandler); ok {
|
if multiStoresHandler, ok := partner.GetPurchasePlatformFromVendorID(catVendorInfo.VendorID).(partner.IMultipleStoresHandler); ok {
|
||||||
if model.IsSyncStatusDelete(catVendorInfo.SyncStatus) { //删除
|
if model.IsSyncStatusDelete(catVendorInfo.CatSyncStatus) { //删除
|
||||||
if !dao.IsVendorThingIDEmpty(catVendorInfo.VendorCatID) &&
|
if !dao.IsVendorThingIDEmpty(catVendorInfo.VendorCatID) &&
|
||||||
model.IsSyncStatusNeedDelete(catVendorInfo.SyncStatus) {
|
model.IsSyncStatusNeedDelete(catVendorInfo.CatSyncStatus) {
|
||||||
err = multiStoresHandler.DeleteCategory2(ctx, catVendorInfo)
|
err = multiStoresHandler.DeleteCategory2(ctx, catVendorInfo)
|
||||||
}
|
}
|
||||||
} else if model.IsSyncStatusNew(catVendorInfo.SyncStatus) { // 新增
|
} else if model.IsSyncStatusNew(catVendorInfo.CatSyncStatus) { // 新增
|
||||||
err = multiStoresHandler.CreateCategory2(ctx, catVendorInfo)
|
err = multiStoresHandler.CreateCategory2(ctx, catVendorInfo)
|
||||||
} else if model.IsSyncStatusUpdate(catVendorInfo.SyncStatus) { // 修改
|
} else if model.IsSyncStatusUpdate(catVendorInfo.CatSyncStatus) { // 修改
|
||||||
err = multiStoresHandler.UpdateCategory2(ctx, catVendorInfo)
|
err = multiStoresHandler.UpdateCategory2(ctx, catVendorInfo)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -94,7 +94,7 @@ func SyncReorderCategories(ctx *jxcontext.Context, parentCatID int, isAsync bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(vendorCatIDList) > 0 {
|
if len(vendorCatIDList) > 0 {
|
||||||
if err = multiStoresHandler.ReorderCategories2(ctx, vendorInfo.OrgCode, catList[0].VendorParentCatID, vendorCatIDList); err == nil {
|
if err = multiStoresHandler.ReorderCategories2(ctx, vendorInfo.OrgCode, catList[0].ParentVendorCatID, vendorCatIDList); err == nil {
|
||||||
retVal = []int{len(vendorCatIDList)}
|
retVal = []int{len(vendorCatIDList)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,14 +163,14 @@ func OnDeleteThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SkuCategoryVendor2ThingMap(cat *dao.SkuCategoryWithVendor) (thingMap *model.ThingMap) {
|
func SkuCategoryVendor2ThingMap(cat *dao.SkuStoreCatInfo) (thingMap *model.ThingMap) {
|
||||||
thingMap = &model.ThingMap{
|
thingMap = &model.ThingMap{
|
||||||
ThingID: int64(cat.ID),
|
ThingID: int64(cat.ID),
|
||||||
ThingType: model.ThingTypeCategory,
|
ThingType: model.ThingTypeCategory,
|
||||||
VendorID: cat.VendorID,
|
VendorID: cat.VendorID,
|
||||||
VendorOrgCode: cat.VendorOrgCode,
|
VendorOrgCode: cat.VendorOrgCode,
|
||||||
|
|
||||||
SyncStatus: cat.SyncStatus,
|
SyncStatus: cat.CatSyncStatus,
|
||||||
VendorThingID: cat.VendorCatID,
|
VendorThingID: cat.VendorCatID,
|
||||||
}
|
}
|
||||||
thingMap.ID = cat.MapID // 一定要赋值
|
thingMap.ID = cat.MapID // 一定要赋值
|
||||||
|
|||||||
@@ -8,18 +8,18 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SkuCategoryWithVendor struct {
|
// type SkuStoreCatInfo struct {
|
||||||
model.SkuCategory
|
// model.SkuCategory
|
||||||
|
|
||||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
// VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
// VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||||
|
|
||||||
MapID int `orm:"column(map_id)" json:"mapID"`
|
// MapID int `orm:"column(map_id)" json:"mapID"`
|
||||||
VendorCatID string `orm:"size(32);column(vendor_cat_id)" json:"vendorCatID"`
|
// VendorCatID string `orm:"size(32);column(vendor_cat_id)" json:"vendorCatID"`
|
||||||
SyncStatus int8 `orm:"default(2)"`
|
// SyncStatus int8 `orm:"default(2)"`
|
||||||
|
|
||||||
VendorParentCatID string `orm:"size(32);column(vendor_parent_cat_id)" json:"vendorParentCatID"`
|
// VendorParentCatID string `orm:"size(32);column(vendor_parent_cat_id)" json:"vendorParentCatID"`
|
||||||
}
|
// }
|
||||||
|
|
||||||
func GetSellCities(db *DaoDB, nameID int, vendorID int) (cities []*model.Place, err error) {
|
func GetSellCities(db *DaoDB, nameID int, vendorID int) (cities []*model.Place, err error) {
|
||||||
cities = []*model.Place{}
|
cities = []*model.Place{}
|
||||||
@@ -157,14 +157,20 @@ func SetSkuSyncStatus(db *DaoDB, vendorID int, skuIDs []int, syncStatus int) (nu
|
|||||||
return ExecuteSQL(db, sql, sqlParams...)
|
return ExecuteSQL(db, sql, sqlParams...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSkuCategoryWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string, parentCatID int, catIDs []int, mustDirty bool) (catList []*SkuCategoryWithVendor, err error) {
|
func GetSkuCategoryWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string, parentCatID int, catIDs []int, mustDirty bool) (catList []*SkuStoreCatInfo, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*,
|
SELECT
|
||||||
t1m.vendor_id, t1m.vendor_org_code,
|
t1m.vendor_id, t1m.vendor_org_code,
|
||||||
|
|
||||||
t1m.id map_id,
|
t1m.id map_id,
|
||||||
t1m.sync_status,
|
t1.*,
|
||||||
t1m.vendor_thing_id vendor_cat_id,
|
t1m.vendor_thing_id vendor_cat_id,
|
||||||
t1pm.vendor_thing_id vendor_parent_cat_id
|
t1m.sync_status cat_sync_status,
|
||||||
|
|
||||||
|
t1pm.id parent_map_id,
|
||||||
|
t1pm.t1p.name parent_cat_name
|
||||||
|
t1pm.vendor_thing_id parent_vendor_cat_id,
|
||||||
|
t1pm.sync_status parent_cat_sync_status
|
||||||
/*
|
/*
|
||||||
t1.jd_sync_status sync_status,
|
t1.jd_sync_status sync_status,
|
||||||
t1.jd_id vendor_cat_id,
|
t1.jd_id vendor_cat_id,
|
||||||
|
|||||||
@@ -25,13 +25,16 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SkuStoreCatInfo struct {
|
type SkuStoreCatInfo struct {
|
||||||
model.SkuCategory
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||||
|
|
||||||
MapID int `orm:"column(map_id)"` // 这个主要用于判断是否有store_sku_category_map
|
MapID int `orm:"column(map_id)"` // 这个主要用于判断是否有store_sku_category_map
|
||||||
|
model.SkuCategory
|
||||||
VendorCatID string `orm:"column(vendor_cat_id)"`
|
VendorCatID string `orm:"column(vendor_cat_id)"`
|
||||||
CatSyncStatus int8
|
CatSyncStatus int8
|
||||||
|
|
||||||
ParentCatName string
|
|
||||||
ParentMapID int `orm:"column(parent_map_id)"` // 这个主要用于判断是否有父store_sku_category_map
|
ParentMapID int `orm:"column(parent_map_id)"` // 这个主要用于判断是否有父store_sku_category_map
|
||||||
|
ParentCatName string
|
||||||
ParentVendorCatID string `orm:"column(parent_vendor_cat_id)"`
|
ParentVendorCatID string `orm:"column(parent_vendor_cat_id)"`
|
||||||
ParentCatSyncStatus int8
|
ParentCatSyncStatus int8
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,9 +161,9 @@ type IMultipleStoresHandler interface {
|
|||||||
DeleteCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error
|
DeleteCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error
|
||||||
ReorderCategories(db *dao.DaoDB, parentCatID int, userName string) (err error)
|
ReorderCategories(db *dao.DaoDB, parentCatID int, userName string) (err error)
|
||||||
|
|
||||||
CreateCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error)
|
CreateCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error)
|
||||||
UpdateCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error)
|
UpdateCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error)
|
||||||
DeleteCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error)
|
DeleteCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error)
|
||||||
ReorderCategories2(ctx *jxcontext.Context, vendorOrgCode, vendorParentCatID string, vendorCatIDList []string) (err error)
|
ReorderCategories2(ctx *jxcontext.Context, vendorOrgCode, vendorParentCatID string, vendorCatIDList []string) (err error)
|
||||||
|
|
||||||
// sku
|
// sku
|
||||||
|
|||||||
@@ -149,9 +149,9 @@ func (p *PurchaseHandler) ReorderCategories(db *dao.DaoDB, parentCatID int, user
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error) {
|
func (p *PurchaseHandler) CreateCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error) {
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
result, err2 := getAPI(cat.VendorOrgCode).AddShopCategory(utils.Str2Int64(cat.VendorParentCatID), cat.Name, int(cat.Level), cat.Seq, ctx.GetUserName())
|
result, err2 := getAPI(cat.VendorOrgCode).AddShopCategory(utils.Str2Int64(cat.ParentVendorCatID), cat.Name, int(cat.Level), cat.Seq, ctx.GetUserName())
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
if jdID := utils.Str2Int64WithDefault(result, 0); jdID != 0 {
|
if jdID := utils.Str2Int64WithDefault(result, 0); jdID != 0 {
|
||||||
cat.VendorCatID = utils.Int64ToStr(jdID)
|
cat.VendorCatID = utils.Int64ToStr(jdID)
|
||||||
@@ -163,14 +163,14 @@ func (p *PurchaseHandler) CreateCategory2(ctx *jxcontext.Context, cat *dao.SkuCa
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) UpdateCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error) {
|
func (p *PurchaseHandler) UpdateCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error) {
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
err = getAPI(cat.VendorOrgCode).UpdateShopCategory(utils.Str2Int64(cat.VendorCatID), cat.Name)
|
err = getAPI(cat.VendorOrgCode).UpdateShopCategory(utils.Str2Int64(cat.VendorCatID), cat.Name)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error) {
|
func (p *PurchaseHandler) DeleteCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error) {
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
err = getAPI(cat.VendorOrgCode).DelShopCategory(utils.Str2Int64(cat.VendorCatID))
|
err = getAPI(cat.VendorOrgCode).DelShopCategory(utils.Str2Int64(cat.VendorCatID))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ func (p *PurchaseHandler) ReorderCategories(db *dao.DaoDB, parentCatID int, user
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error) {
|
func (p *PurchaseHandler) CreateCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) UpdateCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error) {
|
func (p *PurchaseHandler) UpdateCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteCategory2(ctx *jxcontext.Context, cat *dao.SkuCategoryWithVendor) (err error) {
|
func (p *PurchaseHandler) DeleteCategory2(ctx *jxcontext.Context, cat *dao.SkuStoreCatInfo) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user