Merge remote-tracking branch 'origin/mark' into yonghui
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
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ var (
|
||||
|
||||
type SkuStoreCatInfo struct {
|
||||
model.SkuCategory
|
||||
MapID int `orm:"column(map_id)"` // 这个主要用于判断是否有store_sku_category_map
|
||||
VendorCatID string `orm:"column(vendor_cat_id)"`
|
||||
StoreCatSyncStatus int8
|
||||
MapID int `orm:"column(map_id)"` // 这个主要用于判断是否有store_sku_category_map
|
||||
VendorCatID string `orm:"column(vendor_cat_id)"`
|
||||
CatSyncStatus int8
|
||||
|
||||
ParentCatName string
|
||||
ParentMapID int `orm:"column(parent_map_id)"` // 这个主要用于判断是否有父store_sku_category_map
|
||||
@@ -46,10 +46,10 @@ type StoreSkuSyncInfo struct {
|
||||
UnitPrice int64
|
||||
|
||||
// 平台相关的store sku信息
|
||||
StoreSkuStatus int
|
||||
StoreSkuSyncStatus int8
|
||||
VendorSkuID string `orm:"column(vendor_sku_id)"`
|
||||
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
||||
StoreSkuStatus int
|
||||
SkuSyncStatus int8
|
||||
VendorSkuID string `orm:"column(vendor_sku_id)"`
|
||||
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
||||
|
||||
model.Sku
|
||||
|
||||
@@ -74,12 +74,12 @@ type StoreSkuSyncInfo struct {
|
||||
// VendorVendorCatID3 int64 `orm:"column(vendor_vendor_cat_id3)"` // 平台商品分类再上一级
|
||||
|
||||
// sku的商家分类信息
|
||||
SkuStoreCatSyncStatus int8
|
||||
SkuVendorCatID string `orm:"column(sku_vendor_cat_id)"`
|
||||
SkuCatSyncStatus int8
|
||||
SkuVendorCatID string `orm:"column(sku_vendor_cat_id)"`
|
||||
|
||||
// sku_name的商家分类信息
|
||||
StoreCatSyncStatus int8
|
||||
VendorCatID string `orm:"column(vendor_cat_id)"`
|
||||
CatSyncStatus int8
|
||||
VendorCatID string `orm:"column(vendor_cat_id)"`
|
||||
|
||||
VendorPrice int64
|
||||
MergedStatus int
|
||||
@@ -117,7 +117,7 @@ type StoreSkuNameInfo struct {
|
||||
func GetSkusCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int) (cats []*SkuStoreCatInfo, err error) {
|
||||
sql := `
|
||||
SELECT DISTINCT t4.*,
|
||||
t5.id map_id, t5.%s_id vendor_cat_id, t5.%s_sync_status store_cat_sync_status,
|
||||
t5.id map_id, t5.%s_id vendor_cat_id, t5.%s_sync_status cat_sync_status,
|
||||
t4p.name parent_cat_name,
|
||||
t5p.id parent_map_id, t5p.%s_id parent_vendor_cat_id, t5p.%s_sync_status parent_cat_sync_status
|
||||
FROM store_sku_bind t1
|
||||
@@ -172,7 +172,7 @@ func GetStoreCategories(db *DaoDB, vendorID, storeID int, level int, mustDirty b
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := `
|
||||
SELECT t4.*,
|
||||
t5.id map_id, t5.%s_id vendor_cat_id, t5.%s_sync_status store_cat_sync_status,
|
||||
t5.id map_id, t5.%s_id vendor_cat_id, t5.%s_sync_status cat_sync_status,
|
||||
t4p.name parent_cat_name,
|
||||
t5p.id parent_map_id, t5p.%s_id parent_vendor_cat_id, t5p.%s_sync_status parent_cat_sync_status
|
||||
FROM store_sku_category_map t5
|
||||
@@ -219,7 +219,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := `
|
||||
SELECT t1.id bind_id, t1.sku_id, t1.price, t1.unit_price, t1.status store_sku_status,
|
||||
%s.%s_id vendor_sku_id, t1.%s_sync_status store_sku_sync_status, t1.%s_price vendor_price,
|
||||
%s.%s_id vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price,
|
||||
t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end,
|
||||
t2.*,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc,
|
||||
@@ -236,8 +236,8 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
||||
}
|
||||
if isSingleStorePF {
|
||||
sql += `,
|
||||
t5.%s_sync_status store_cat_sync_status, t5.%s_id vendor_cat_id,
|
||||
t5sku.%s_sync_status sku_store_cat_sync_status, t5sku.%s_id sku_vendor_cat_id`
|
||||
t5.%s_sync_status cat_sync_status, t5.%s_id vendor_cat_id,
|
||||
t5sku.%s_sync_status sku_cat_sync_status, t5sku.%s_id sku_vendor_cat_id`
|
||||
fmtParams = append(fmtParams, fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix)
|
||||
} else {
|
||||
sql += `,
|
||||
@@ -311,15 +311,15 @@ func GetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSyncInf
|
||||
|
||||
sql := `
|
||||
SELECT t1.id bind_id, t1.price, t1.unit_price, t1.status store_sku_status, t2.%s_id vendor_sku_id,
|
||||
t1.%s_sync_status store_sku_sync_status, t1.store_id, t1.deleted_at bind_deleted_at,
|
||||
t1.%s_sync_status sku_sync_status, t1.store_id, t1.deleted_at bind_deleted_at,
|
||||
t2.*, t2.id sku_id,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc,
|
||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
||||
t13.%s desc_img,
|
||||
t4.%s_category_id vendor_vendor_cat_id,
|
||||
t4.%s_sync_status store_cat_sync_status, t4.%s_id vendor_cat_id,
|
||||
t5sku.%s_sync_status sku_store_cat_sync_status, t5sku.%s_id sku_vendor_cat_id
|
||||
t4.%s_sync_status cat_sync_status, t4.%s_id vendor_cat_id,
|
||||
t5sku.%s_sync_status sku_cat_sync_status, t5sku.%s_id sku_vendor_cat_id
|
||||
FROM sku t2
|
||||
LEFT JOIN store_sku_bind t1 ON t1.sku_id = t2.id AND t1.store_id = ? AND t1.deleted_at = ?
|
||||
JOIN sku_name t3 ON t2.name_id = t3.id AND t3.deleted_at = ? AND t3.status = ?
|
||||
|
||||
@@ -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