Commit 723ef51b by huangchengyi

1.0

parent 2b0f4f7b
...@@ -32,14 +32,12 @@ gjson 判断某值是否存在 map ...@@ -32,14 +32,12 @@ gjson 判断某值是否存在 map
@param targetk string 目标ID @param targetk string 目标ID
*/ */
func GInArray(json string,arrK string,targetK string) bool{ func GInArray(json string,arrK string,targetK string) bool{
s := gjson.Get(json,"brand_id").Array() s := gjson.Get(json,arrK).Array()
d := make([]string,0) d := make([]string,0)
for _,a := range s { for _,a := range s {
c := a.String() c := a.String()
d = append(d,c) d = append(d,c)
} }
return php2go.InArray(targetK,d) return php2go.InArray(targetK,d)
} }
/* /*
......
...@@ -127,14 +127,24 @@ func (qs *ZiyingService) HDActivityPrice(ctx *gin.Context,GoodsActivityPrice str ...@@ -127,14 +127,24 @@ func (qs *ZiyingService) HDActivityPrice(ctx *gin.Context,GoodsActivityPrice str
} }
} }
}else{ }else{
//fmt.Println(GoodsActivityPrice,SkuInfo)
brand_id := gjson.Get(GoodsActivityPrice,"brand_id").String()
class_id := gjson.Get(GoodsActivityPrice,"class_id").String()
if brand_id != "" {
if !common.GInArray(GoodsActivityPrice,"brand_id",gjson.Get(SkuInfo,"brand_id").String()) { if !common.GInArray(GoodsActivityPrice,"brand_id",gjson.Get(SkuInfo,"brand_id").String()) {
Ratio = false; //不符合活动价 Ratio = false; //不符合活动价
//fmt.Println("不符合活动价1")
goto End goto End
} }
}
if class_id != "" {
if !common.GInArray(GoodsActivityPrice,"class_id",gjson.Get(SkuInfo,"class_id2").String()) { if !common.GInArray(GoodsActivityPrice,"class_id",gjson.Get(SkuInfo,"class_id2").String()) {
Ratio = false; //不符合活动价 Ratio = false; //不符合活动价
//fmt.Println("不符合活动价2")
goto End goto End
} }
}
//会员价处理 //会员价处理
if Actype == "3" && is_part == "1" && visible_roster != "" { if Actype == "3" && is_part == "1" && visible_roster != "" {
...@@ -173,21 +183,19 @@ func (qs *ZiyingService) HDActivityPrice(ctx *gin.Context,GoodsActivityPrice str ...@@ -173,21 +183,19 @@ func (qs *ZiyingService) HDActivityPrice(ctx *gin.Context,GoodsActivityPrice str
} }
End: //最终执行 End: //最终执行
if Ratio { ladder_price_arr := gjson.Get(SkuInfo,"ladder_price").Array()
if Ratio && len(ladder_price_arr) > 0 {
discount_type := gjson.Get(GoodsActivityPrice,"discount_type").String() discount_type := gjson.Get(GoodsActivityPrice,"discount_type").String()
ratio := gjson.Get(GoodsActivityPrice,"ratio").Float() //当前活动折扣 ratio := gjson.Get(GoodsActivityPrice,"ratio").Float() //当前活动折扣
ladder_price_arr := gjson.Get(SkuInfo,"ladder_price").Array()
A := orderedmap.New(); A := orderedmap.New();
ladderType := make([]model.LadderPrice,0) ladderType := make([]model.LadderPrice,0)
for _,v := range ladder_price_arr{ for _,v := range ladder_price_arr{
if Actype != "7" || (Actype =="7" && discount_type != "") || discount_type == "1" { if Actype != "7" || (Actype =="7" && discount_type != "") || discount_type == "1" {
price_cn := v.Get("price_cn").Float() price_cn := v.Get("price_cn").Float()
price_ac := php2go.Round(price_cn*ratio/100) price_ac := php2go.Round(price_cn*ratio/100*10000)/10000
ladderType = append(ladderType, model.LadderPrice{ ladderType = append(ladderType, model.LadderPrice{
Purchases: v.Get("Purchases").Int(), Purchases: v.Get("purchases").Int(),
PriceUs: v.Get("price_us").Float(), PriceUs: v.Get("price_us").Float(),
PriceCn: price_cn, PriceCn: price_cn,
PriceAc: price_ac, PriceAc: price_ac,
...@@ -195,11 +203,26 @@ End: //最终执行 ...@@ -195,11 +203,26 @@ End: //最终执行
}) })
} }
} }
allow_not_login := gjson.Get(GoodsActivityPrice,"allow_not_login").Int()
if allow_not_login == 0 {
allow_not_login = 2
}
A.Set("activity_info",map[string]interface{}{
"activity_ad":gjson.Get(GoodsActivityPrice,"activity_ad").String(),
"sign_name":gjson.Get(GoodsActivityPrice,"sign_name").String(),
"allow_not_login":allow_not_login,
})
A.Set("ladder_price",ladderType)
A.Set("ratio",ratio) A.Set("ratio",ratio)
A.Set("ac_type",Actype) A.Set("ac_type",Actype)
A.Set("allow_coupon",ratio) allow_coupon := gjson.Get(GoodsActivityPrice,"allow_coupon").Int()
A.Set("activity_end_time",ratio) if gjson.Get(GoodsActivityPrice,"allow_coupon").Int() == 0 {
A.Set("activity_info",ratio) allow_coupon = 1
}
A.Set("allow_coupon",allow_coupon)
A.Set("activity_end_time",gjson.Get(GoodsActivityPrice,"end_time").Int())
return A return A
} }
return nil return nil
......
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