sync2.SyncCategories, SyncReorderCategories
This commit is contained in:
@@ -14,8 +14,11 @@ type SkuCategoryWithVendor struct {
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||
|
||||
MapID int `orm:"column(map_id)" json:"mapID"`
|
||||
VendorCatID string `orm:"size(32);column(vendor_cat_id)" json:"vendorCatID"`
|
||||
SyncStatus int8 `orm:"default(2)"`
|
||||
|
||||
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) {
|
||||
@@ -154,5 +157,55 @@ func SetSkuSyncStatus(db *DaoDB, vendorID int, skuIDs []int, syncStatus int) (nu
|
||||
return ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
|
||||
// func GetSkuCategoryWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string, catIDs []int) (num int64, err error) {
|
||||
// }
|
||||
func GetSkuCategoryWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string, parentCatID int, catIDs []int, mustDirty bool) (catList []*SkuCategoryWithVendor, err error) {
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
t1m.vendor_id, t1m.vendor_org_code,
|
||||
t1m.id map_id,
|
||||
t1m.sync_status,
|
||||
t1m.vendor_thing_id vendor_cat_id,
|
||||
t1pm.vendor_thing_id vendor_parent_cat_id
|
||||
/*
|
||||
t1.jd_sync_status sync_status,
|
||||
t1.jd_id vendor_cat_id,
|
||||
t1p.jd_id vendor_parent_cat_id
|
||||
*/
|
||||
FROM sku_category t1
|
||||
LEFT JOIN thing_map t1m ON t1m.thing_id = t1.id AND t1m.thing_type = ? AND t1m.deleted_at = ?
|
||||
LEFT JOIN sku_category t1p ON t1p.id = t1.parent_id
|
||||
LEFT JOIN thing_map t1pm ON t1pm.thing_id = t1p.id AND t1pm.thing_type = ? AND t1m.deleted_at = ?
|
||||
AND t1pm.vendor_id = t1m.vendor_id AND t1pm.vendor_org_code = t1m.vendor_org_code
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.ThingTypeCategory,
|
||||
utils.DefaultTimeValue,
|
||||
model.ThingTypeCategory,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if mustDirty {
|
||||
sql += " AND t1m.sync_status <> 0"
|
||||
} else {
|
||||
sql += " AND t1.deleted_at = ?"
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
}
|
||||
if len(vendorIDs) > 0 {
|
||||
sql += " AND t1m.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
|
||||
sqlParams = append(sqlParams, vendorIDs)
|
||||
}
|
||||
if len(appOrgCodes) > 0 {
|
||||
sql += " AND t1m.vendor_org_code IN (" + GenQuestionMarks(len(appOrgCodes)) + ")"
|
||||
sqlParams = append(sqlParams, appOrgCodes)
|
||||
}
|
||||
if len(catIDs) > 0 {
|
||||
sql += " AND t1.id IN (" + GenQuestionMarks(len(catIDs)) + ")"
|
||||
sqlParams = append(sqlParams, catIDs)
|
||||
}
|
||||
if parentCatID >= 0 {
|
||||
sql += " AND t1.parent_id = ?"
|
||||
sqlParams = append(sqlParams, parentCatID)
|
||||
}
|
||||
sql += " ORDER BY t1.seq"
|
||||
err = GetRows(db, &catList, sql, sqlParams...)
|
||||
return catList, err
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ type ThingMap struct {
|
||||
|
||||
VendorThingID string `orm:"size(32);column(vendor_thing_id);index" json:"vendorThingID"`
|
||||
SyncStatus int8 `orm:"default(2)"`
|
||||
|
||||
Remark string `orm:"size(255)" json:"remark"`
|
||||
}
|
||||
|
||||
func (*ThingMap) TableUnique() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user