Commit 576fd30c by mushishixian

fix

parent bc8f6310
......@@ -64,28 +64,29 @@ type LySku struct {
//活动信息
HasGiftActivity int `json:"has_gift_activity"`
GiftActivity GiftActivity `json:"gift_activity"`
ActivityInfo struct {
ActivityId int `json:"activity_id,omitempty"`
ActivityName string `json:"activity_name,omitempty"`
} `json:"activity_info"`
ActivityInfo PriceActivity `json:"activity_info"`
}
type PriceActivity struct {
HasActivity bool `json:"-"`
ActivityId int `json:"activity_id,omitempty"`
ActivityName string `json:"activity_name,omitempty"`
AllowCoupon int `json:"-"`
ActivityCommon
Ratio float64 `json:"ratio"`
}
type GiftActivity struct {
HasActivity bool `json:"-"`
ActivityId int `json:"activity_id,omitempty"`
ActivityName int `json:"activity_name,omitempty"`
AllowCoupon int `json:"-"`
ActivityCommon
ItemList []ActivityItem `json:"items,omitempty"`
}
type ActivityCommon struct {
HasActivity bool `json:"-"`
ActivityId int `json:"activity_id,omitempty"`
ActivityName string `json:"activity_name,omitempty"`
AllowCoupon int `json:"-"`
SignText string `json:"sign_text"`
Sign string `json:"sign"`
ShowName string `json:"show_name"`
}
//为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
func InitSkuData(sku string) (data LySku) {
goodsSn := gjson.Get(sku, "goods_sn").String()
......
......@@ -61,38 +61,52 @@ func (as *ActivityService) GetGiftActivity(checkData model.ActivityCheckData, ac
//如果是整个供应商搞活动,则直接返回系数
if activity.EntireSupplierActivity {
hasActivity = true
giftActivity.ItemList = activity.ItemList
giftActivity.ActivityId = activity.ActivityId
goto INFO
}
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
if as.CheckExcludeSku(checkData.GoodsId, activity) || as.CheckExcludeBrand(checkData.BrandId, activity) {
hasActivity = false
goto INFO
}
//判断是否是搞活动的品牌
if as.CheckBrand(checkData.BrandId, activity) {
hasActivity = true
giftActivity.ItemList = activity.ItemList
giftActivity.ActivityId = activity.ActivityId
goto INFO
}
//如果是专卖,则要去判断canal,如果是自营,则去判断分类
if checkData.SupplierId == 17 {
if as.CheckCanal(checkData.Canal, activity) {
hasActivity = true
giftActivity.ItemList = activity.ItemList
giftActivity.ActivityId = activity.ActivityId
goto INFO
}
} else {
if as.CheckClass(checkData.ClassId, activity) {
hasActivity = true
giftActivity.ItemList = activity.ItemList
giftActivity.ActivityId = activity.ActivityId
goto INFO
}
}
INFO:
if hasActivity {
giftActivity.ActivityName = activity.ActivityName
giftActivity.ActivityId = activity.ActivityId
giftActivity = model.GiftActivity{
ItemList: activity.ItemList,
ActivityCommon: model.ActivityCommon{
HasActivity: hasActivity,
ActivityId: activity.ActivityId,
ActivityName: activity.ActivityName,
AllowCoupon: activity.AllowCoupon,
SignText: activity.SignText,
Sign: activity.Sign,
ShowName: activity.ShowName,
},
}
}
}
giftActivity.HasActivity = hasActivity
return
}
......@@ -108,36 +122,49 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
//如果是整个供应商搞活动,则直接返回系数
if activity.EntireSupplierActivity {
hasActivity = true
priceActivity.Ratio = activity.Ratio
goto INFO
}
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
if as.CheckExcludeSku(checkData.GoodsId, activity) || as.CheckExcludeBrand(checkData.BrandId, activity) {
hasActivity = false
goto INFO
}
//判断是否是搞活动的品牌
if as.CheckBrand(checkData.BrandId, activity) {
hasActivity = true
priceActivity.Ratio = activity.Ratio
goto INFO
}
//如果是专卖,则要去判断canal,如果是自营,则去判断分类
if checkData.SupplierId == 17 {
if as.CheckCanal(checkData.Canal, activity) {
hasActivity = true
priceActivity.Ratio = activity.Ratio
goto INFO
}
} else {
if as.CheckClass(checkData.ClassId, activity) {
hasActivity = true
priceActivity.Ratio = activity.Ratio
goto INFO
}
}
INFO:
if hasActivity {
priceActivity.AllowCoupon = activity.AllowCoupon
priceActivity.ActivityName = activity.ActivityName
priceActivity.ActivityId = activity.ActivityId
priceActivity = model.PriceActivity{
Ratio: activity.Ratio,
ActivityCommon: model.ActivityCommon{
HasActivity: hasActivity,
ActivityId: activity.ActivityId,
ActivityName: activity.ActivityName,
AllowCoupon: activity.AllowCoupon,
SignText: activity.SignText,
Sign: activity.Sign,
ShowName: activity.ShowName,
},
}
}
}
......
......@@ -188,8 +188,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
if priceActivity.HasActivity {
sku.AcType = 10
sku.Ratio = priceActivity.Ratio
sku.ActivityInfo.ActivityId = priceActivity.ActivityId
sku.ActivityInfo.ActivityName = priceActivity.ActivityName
sku.ActivityInfo = priceActivity
}
if giftActivity.HasActivity {
sku.HasGiftActivity = gconv.Int(giftActivity.HasActivity)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment