From 42e96f3451b212b4dde621828a0cf11d3690150d Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 5 Nov 2018 17:42:58 +0800 Subject: [PATCH] - return store name also. --- business/jxstore/promotion/jd_promotion.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/business/jxstore/promotion/jd_promotion.go b/business/jxstore/promotion/jd_promotion.go index 261a0ba8c..dee38d51d 100644 --- a/business/jxstore/promotion/jd_promotion.go +++ b/business/jxstore/promotion/jd_promotion.go @@ -58,6 +58,11 @@ type SkuPrice struct { 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 { Name string Advertising string @@ -75,10 +80,10 @@ type tStoreSkuBindExt struct { type tPromotionInfo struct { model.Promotion - StoreIDStr string `orm:"column(store_id_str)" json:"-"` - SkuPriceStr string `orm:"column(sku_price_str)" json:"-"` - StoreIDs []int `orm:"-" json:"storeIDs"` - SkuPrices []*SkuPrice `orm:"-" json:"skuPrices"` + StoreStr string `orm:"column(store_str)" json:"-"` + SkuPriceStr string `orm:"column(sku_price_str)" json:"-"` + Stores []*tSimpleStore `orm:"-" json:"stores"` + SkuPrices []*SkuPrice `orm:"-" json:"skuPrices"` } var ( @@ -420,10 +425,11 @@ func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]i t1.begin_at, t1.end_at, 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 FROM promotion t1 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 WHERE t1.deleted_at = ? ` @@ -512,8 +518,8 @@ func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]i var promotionList []*tPromotionInfo if err = dao.GetRows(db, &promotionList, sql, sqlParams...); err == nil { for _, v := range promotionList { - if v.StoreIDStr != "" { - if err = utils.UnmarshalUseNumber([]byte(v.StoreIDStr), &v.StoreIDs); err != nil { + if v.StoreStr != "" { + if err = utils.UnmarshalUseNumber([]byte(v.StoreStr), &v.Stores); err != nil { return nil, err } }