Merge remote-tracking branch 'origin/mark' into yonghui

This commit is contained in:
苏尹岚
2019-12-09 18:08:40 +08:00
51 changed files with 330 additions and 232 deletions

View File

@@ -13,6 +13,11 @@ type tStoreSkuSyncInfo2 struct {
VendorPlaceCode string
}
type SkuCategoryWithVendor struct {
*model.SkuCategory
MapList []*model.ThingMap `json:"mapList"`
}
func GetSellCities(db *DaoDB, nameID int, vendorID int) (cities []*model.Place, err error) {
cities = []*model.Place{}
sql := `
@@ -44,6 +49,26 @@ func DeleteSkuNamePlace(db *DaoDB, nameID int, placeCodes []int) (num int64, err
return ExecuteSQL(db, sql, sqlParams...)
}
func GetCategories(db *DaoDB, parentID int, catIDs []int) (cats []*model.SkuCategory, err error) {
sql := `
SELECT t1.*
FROM sku_category t1
WHERE t1.deleted_at = ?`
params := []interface{}{
utils.DefaultTimeValue,
}
if parentID != -1 {
sql += " AND t1.parent_id = ?"
params = append(params, parentID)
}
if len(catIDs) > 0 {
sql += " AND t1.id (" + GenQuestionMarks(len(catIDs)) + ")"
params = append(params, catIDs)
}
sql += " ORDER BY t1.level, t1.seq"
return cats, GetRows(db, &cats, sql, params)
}
func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int) (skuList []*model.SkuAndName, err error) {
sql := `
SELECT t1.*, t2.name, t2.unit, t2.prefix, t2.is_spu

View File

@@ -0,0 +1,34 @@
package dao
import "git.rosy.net.cn/jx-callback/business/model"
import "git.rosy.net.cn/baseapi/utils"
func GetThingMapList(db *DaoDB, thingType int, vendorIDs, thingIDs []int) (cats []*model.ThingMap, err error) {
sql := `
SELECT t1.*
FROM thing_map t1
WHERE t1.deleted_at = ? AND t1.thing_type = ?
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
thingType,
}
if len(thingIDs) > 0 { // 必须要指定ID
sql += " AND t1.thing_id IN (" + GenQuestionMarks(len(thingIDs)) + ")"
sqlParams = append(sqlParams, thingIDs)
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)
if err == nil {
thingMapMap = make(map[int64][]*model.ThingMap)
for _, thingMap := range thingMapList {
thingMapMap[thingMap.ThingID] = append(thingMapMap[thingMap.ThingID], thingMap)
}
}
return thingMapMap, err
}