门店商品分类
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/aliupcapi"
|
||||
@@ -230,6 +231,8 @@ func GetSkuCategoryWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string,
|
||||
sqlParams = append(sqlParams, parentCatID)
|
||||
}
|
||||
sql += " ORDER BY t1.seq"
|
||||
fmt.Println(sql)
|
||||
fmt.Println(sqlParams)
|
||||
err = GetRows(db, &catList, sql, sqlParams...)
|
||||
return catList, err
|
||||
}
|
||||
|
||||
@@ -744,36 +744,37 @@ func GetRealLinkStoreID(db *DaoDB, linkStoreID int) (realLinkStoreID int, err er
|
||||
return realLinkStoreID, err
|
||||
}
|
||||
|
||||
// func GetStoreCategoryMap(db *DaoDB, parentID, storeID, categoryID int) (storeCatMaps []*StoreCatMap, err error) {
|
||||
// sql := `
|
||||
// SELECT a.*, b.level, b.parent_id, b.seq, b.name
|
||||
// FROM store_category_map a
|
||||
// JOIN sku_category b ON b.id = a.category_id
|
||||
// AND a.deleted_at = ?
|
||||
// AND b.deleted_at = ?
|
||||
// `
|
||||
// sqlParams := []interface{}{
|
||||
// utils.DefaultTimeValue,
|
||||
// utils.DefaultTimeValue,
|
||||
// }
|
||||
// if parentID != -1 {
|
||||
// sql += " AND b.parent_id = ?"
|
||||
// sqlParams = append(sqlParams, parentID)
|
||||
// }
|
||||
// if storeID > 0 {
|
||||
// sql += " AND a.store_id = ?"
|
||||
// sqlParams = append(sqlParams, storeID)
|
||||
// }
|
||||
// if categoryID > 0 {
|
||||
// sql += " AND a.category_id = ?"
|
||||
// sqlParams = append(sqlParams, categoryID)
|
||||
// }
|
||||
// err = GetRows(db, &storeCatMaps, sql, sqlParams)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return storeCatMaps, err
|
||||
// }
|
||||
func GetStoreCategoryMap(db *DaoDB, parentID, level, storeID, categoryID int) (storeCatMaps []*model.StoreCategoryMap, err error) {
|
||||
sql := `
|
||||
SELECT a.*
|
||||
FROM store_category_map a
|
||||
WHERE a.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if parentID >= 0 {
|
||||
sql += " AND a.parent_id = ?"
|
||||
sqlParams = append(sqlParams, parentID)
|
||||
}
|
||||
if level > 0 {
|
||||
sql += " AND a.level = ?"
|
||||
sqlParams = append(sqlParams, level)
|
||||
}
|
||||
if storeID > 0 {
|
||||
sql += " AND a.store_id = ?"
|
||||
sqlParams = append(sqlParams, storeID)
|
||||
}
|
||||
if categoryID > 0 {
|
||||
sql += " AND a.category_id = ?"
|
||||
sqlParams = append(sqlParams, categoryID)
|
||||
}
|
||||
err = GetRows(db, &storeCatMaps, sql, sqlParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return storeCatMaps, err
|
||||
}
|
||||
|
||||
func InsertStoreCategories(db *DaoDB, userName string, storeID int) (err error) {
|
||||
sql := `
|
||||
|
||||
@@ -41,6 +41,11 @@ type SkuStoreCatInfo struct {
|
||||
ParentCatName string
|
||||
ParentVendorCatID string `orm:"column(parent_vendor_cat_id)"`
|
||||
ParentCatSyncStatus int8
|
||||
|
||||
StoreCatID int `orm:"column(store_category_id)"`
|
||||
StoreCatName string
|
||||
StoreCatSeq int
|
||||
IsSysCat int
|
||||
}
|
||||
|
||||
type StoreSkuSyncInfo struct {
|
||||
@@ -347,15 +352,18 @@ func GetSkusCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int
|
||||
func GetStoreCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int, mustDirty bool) (cats []*SkuStoreCatInfo, err error) {
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := `
|
||||
SELECT t4.*,
|
||||
SELECT t4.*, ts.store_category_name store_cat_name, ts.store_category_seq store_cat_seq, ts.id store_category_id,
|
||||
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
|
||||
tsp.store_category_name parent_cat_name,
|
||||
t5p.id parent_map_id, t5p.%s_id parent_vendor_cat_id, t5p.%s_sync_status parent_cat_sync_status,
|
||||
t1.is_sys_cat
|
||||
FROM store_sku_category_map t5
|
||||
JOIN sku_category t4 ON t5.category_id = t4.id AND t4.deleted_at = ?
|
||||
LEFT JOIN store_category_map ts ON ts.store_id = t5.store_id AND ts.category_id = t4.id AND ts.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
fieldPrefixParams := []interface{}{fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix}
|
||||
if len(skuIDs) > 0 {
|
||||
@@ -372,9 +380,11 @@ func GetStoreCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level in
|
||||
}
|
||||
sql += `
|
||||
LEFT JOIN sku_category t4p ON t4.parent_id = t4p.id
|
||||
LEFT JOIN store_category_map tsp ON tsp.store_id = t5.store_id AND tsp.category_id = t4p.id AND tsp.deleted_at = ?
|
||||
LEFT JOIN store_sku_category_map t5p ON t4p.id = t5p.category_id AND t5.store_id = t5p.store_id AND t5p.deleted_at = ?
|
||||
LEFT JOIN store_map t1 ON t1.store_id = t5.store_id AND t1.vendor_id = ?
|
||||
WHERE t5.store_id = ? AND t5.deleted_at = ? AND t4.is_sync <> ?`
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, storeID, utils.DefaultTimeValue, model.YES)
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, utils.DefaultTimeValue, vendorID, storeID, utils.DefaultTimeValue, model.YES)
|
||||
if mustDirty {
|
||||
sql += " AND t5.%s_sync_status <> 0"
|
||||
fieldPrefixParams = append(fieldPrefixParams, fieldPrefix)
|
||||
|
||||
@@ -442,6 +442,8 @@ type StoreMap struct {
|
||||
YbAppID string `orm:"column(yb_app_id);size(255)" json:"ybAppID"`
|
||||
YbAppKey string `orm:"size(255)" json:"ybAppKey"`
|
||||
YbStorePrefix string `orm:"size(255)" json:"ybStorePrefix"`
|
||||
|
||||
IsSysCat int `orm:"default(0)" json:"isSysCat"` //是否使用京西分类
|
||||
}
|
||||
|
||||
func (*StoreMap) TableUnique() [][]string {
|
||||
@@ -666,3 +668,19 @@ func (l *FreightDeductionPack) Swap(i, j int) {
|
||||
l2[i] = l2[j]
|
||||
l2[j] = tmp
|
||||
}
|
||||
|
||||
type StoreCategoryMap struct {
|
||||
ModelIDCULD
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
CategoryID int `orm:"column(category_id)" json:"categoryID"` // 这个是指对应的sku_category
|
||||
StoreCategoryName string `orm:"size(255)" json:"storeCategoryName"` // 门店类别单独的名字
|
||||
StoreCategorySeq int `orm:"default(0)" json:"storeCategorySeq"` // 门店类别单独的序号
|
||||
Level int `json:"level"` // 门店类别单独的等级
|
||||
ParentID int `orm:"column(parent_id)" json:"parentID"` //门店类别父ID,和sku_category一致
|
||||
}
|
||||
|
||||
func (*StoreCategoryMap) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"StoreID", "CategoryID", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user