- return store name also.

This commit is contained in:
gazebo
2018-11-05 17:42:58 +08:00
parent ef9739f00c
commit 42e96f3451

View File

@@ -58,6 +58,11 @@ type SkuPrice struct {
IsLock int8 `json:"isLock"` IsLock int8 `json:"isLock"`
} }
type tSimpleStore struct {
StoreID int `orm:"column(store_id)" json:"storeID"`
Name string `orm:"column(name)" json:"name"`
}
type PromotionParams struct { type PromotionParams struct {
Name string Name string
Advertising string Advertising string
@@ -75,9 +80,9 @@ type tStoreSkuBindExt struct {
type tPromotionInfo struct { type tPromotionInfo struct {
model.Promotion model.Promotion
StoreIDStr string `orm:"column(store_id_str)" json:"-"` StoreStr string `orm:"column(store_str)" json:"-"`
SkuPriceStr string `orm:"column(sku_price_str)" json:"-"` SkuPriceStr string `orm:"column(sku_price_str)" json:"-"`
StoreIDs []int `orm:"-" json:"storeIDs"` Stores []*tSimpleStore `orm:"-" json:"stores"`
SkuPrices []*SkuPrice `orm:"-" json:"skuPrices"` SkuPrices []*SkuPrice `orm:"-" json:"skuPrices"`
} }
@@ -420,10 +425,11 @@ func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]i
t1.begin_at, t1.begin_at,
t1.end_at, t1.end_at,
t1.advertising, t1.advertising,
CONCAT("[", GROUP_CONCAT(DISTINCT t2.store_id), "]") store_id_str, CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"storeID":', t2.store_id, ', "name":"', t22.name, '"}')), "]") store_str,
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"skuID":', t3.sku_id, ', "priceType":', t3.price_type, ', "price":', t3.price, ', "limitSkuCount":', t3.limit_sku_count, ', "isLock":', t3.is_lock, '}')), "]") sku_price_str CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"skuID":', t3.sku_id, ', "priceType":', t3.price_type, ', "price":', t3.price, ', "limitSkuCount":', t3.limit_sku_count, ', "isLock":', t3.is_lock, '}')), "]") sku_price_str
FROM promotion t1 FROM promotion t1
JOIN promotion_store t2 ON t1.id = t2.promotion_id JOIN promotion_store t2 ON t1.id = t2.promotion_id
JOIN store t22 ON t2.store_id = t22.id
JOIN promotion_sku t3 ON t1.id = t3.promotion_id JOIN promotion_sku t3 ON t1.id = t3.promotion_id
WHERE t1.deleted_at = ? WHERE t1.deleted_at = ?
` `
@@ -512,8 +518,8 @@ func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]i
var promotionList []*tPromotionInfo var promotionList []*tPromotionInfo
if err = dao.GetRows(db, &promotionList, sql, sqlParams...); err == nil { if err = dao.GetRows(db, &promotionList, sql, sqlParams...); err == nil {
for _, v := range promotionList { for _, v := range promotionList {
if v.StoreIDStr != "" { if v.StoreStr != "" {
if err = utils.UnmarshalUseNumber([]byte(v.StoreIDStr), &v.StoreIDs); err != nil { if err = utils.UnmarshalUseNumber([]byte(v.StoreStr), &v.Stores); err != nil {
return nil, err return nil, err
} }
} }