aa
This commit is contained in:
@@ -2740,3 +2740,7 @@ func UpdateSkuExinfoMap(ctx *jxcontext.Context, nameIDs []int, imgWaterMark stri
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func GetThingMap(ctx *jxcontext.Context, vendorOrgCode string) (getThingMapResult []*dao.GetThingMapCategoryResult, err error) {
|
||||
return dao.GetThingMapCategory(dao.GetDB(), []int{model.VendorIDJD}, nil, []string{vendorOrgCode})
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
func GetThingMapList(db *DaoDB, thingType int, vendorIDs, thingIDs []int) (cats []*model.ThingMap, err error) {
|
||||
func GetThingMapList(db *DaoDB, thingType int, vendorIDs, thingIDs []int, vendorOrgCodes []string) (cats []*model.ThingMap, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
FROM thing_map t1
|
||||
@@ -19,13 +19,49 @@ func GetThingMapList(db *DaoDB, thingType int, vendorIDs, thingIDs []int) (cats
|
||||
if len(thingIDs) > 0 { // 必须要指定ID
|
||||
sql += " AND t1.thing_id IN (" + GenQuestionMarks(len(thingIDs)) + ")"
|
||||
sqlParams = append(sqlParams, thingIDs)
|
||||
err = GetRows(db, &cats, sql, sqlParams...)
|
||||
}
|
||||
if len(vendorOrgCodes) > 0 {
|
||||
sql += " AND t1.vendor_org_code IN (" + GenQuestionMarks(len(vendorOrgCodes)) + ")"
|
||||
sqlParams = append(sqlParams, vendorOrgCodes)
|
||||
}
|
||||
err = GetRows(db, &cats, sql, sqlParams...)
|
||||
return cats, err
|
||||
}
|
||||
|
||||
type GetThingMapCategoryResult struct {
|
||||
model.ThingMap
|
||||
Name string `orm:"size(255)" json:"name"`
|
||||
ParentID int `orm:"column(parent_id)" json:"parentID"`
|
||||
Level int8 `json:"level"`
|
||||
Seq int `json:"seq"`
|
||||
}
|
||||
|
||||
func GetThingMapCategory(db *DaoDB, vendorIDs, thingIDs []int, vendorOrgCodes []string) (cats []*GetThingMapCategoryResult, err error) {
|
||||
sql := `
|
||||
SELECT t1.*, t2.name, t2.parent_id, t2.level, t2.seq
|
||||
FROM thing_map t1
|
||||
JOIN sku_category t2 ON t2.id = t1.thing_id AND t2.deleted_at = ?
|
||||
WHERE t1.deleted_at = ? AND t1.thing_type = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
model.ThingTypeCategory,
|
||||
}
|
||||
if len(thingIDs) > 0 {
|
||||
sql += " AND t1.thing_id IN (" + GenQuestionMarks(len(thingIDs)) + ")"
|
||||
sqlParams = append(sqlParams, thingIDs)
|
||||
}
|
||||
if len(vendorOrgCodes) > 0 {
|
||||
sql += " AND t1.vendor_org_code IN (" + GenQuestionMarks(len(vendorOrgCodes)) + ")"
|
||||
sqlParams = append(sqlParams, vendorOrgCodes)
|
||||
}
|
||||
err = GetRows(db, &cats, sql, sqlParams...)
|
||||
return cats, err
|
||||
}
|
||||
|
||||
func GetThingMapMap(db *DaoDB, thingType int, vendorIDs, thingIDs []int) (thingMapMap map[int64][]*model.ThingMap, err error) {
|
||||
thingMapList, err := GetThingMapList(db, thingType, vendorIDs, thingIDs)
|
||||
thingMapList, err := GetThingMapList(db, thingType, vendorIDs, thingIDs, nil)
|
||||
if err == nil {
|
||||
thingMapMap = make(map[int64][]*model.ThingMap)
|
||||
for _, thingMap := range thingMapList {
|
||||
|
||||
@@ -21,6 +21,9 @@ type ThingMap struct {
|
||||
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||
|
||||
Remark string `orm:"size(255)" json:"remark"`
|
||||
|
||||
ThingName string `json:"thingName"`
|
||||
ThingSeq int `json:"thingSeq"`
|
||||
}
|
||||
|
||||
func (*ThingMap) TableUnique() [][]string {
|
||||
|
||||
12
business/model/vendor_org_code.go
Normal file
12
business/model/vendor_org_code.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
type VendorOrgCode struct {
|
||||
ModelIDCULD
|
||||
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||
Comment string `json:"comment"` //备注
|
||||
//appkey,secret token等
|
||||
|
||||
IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用
|
||||
}
|
||||
Reference in New Issue
Block a user