Commit 73bfc670 by huangchengyi
parents 2c80ddc1 f0f76118
...@@ -63,6 +63,7 @@ type LySku struct { ...@@ -63,6 +63,7 @@ type LySku struct {
//活动信息 //活动信息
ActivityEndTime int64 `json:"activity_end_time,omitempty"` ActivityEndTime int64 `json:"activity_end_time,omitempty"`
ActivityInfo map[string]interface{} `json:"activity_info,omitempty"` ActivityInfo map[string]interface{} `json:"activity_info,omitempty"`
Content interface{} `json:"content"`
} }
//为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致 //为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"go_sku_server/model" "go_sku_server/model"
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis" "go_sku_server/pkg/gredis"
"sort" "sort"
"sync" "sync"
...@@ -33,7 +34,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -33,7 +34,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//wg.Done() //wg.Done()
redisConn.Close() redisConn.Close()
}() }()
fast := ctx.Request.FormValue("power[fast]") fast := ctx.Request.FormValue("power[fast]")
isNewCustomer := ctx.Request.FormValue("power[newCustomer]") isNewCustomer := ctx.Request.FormValue("power[newCustomer]")
power := Power{ power := Power{
...@@ -45,7 +45,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -45,7 +45,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
SpecialInvoice: ctx.Request.FormValue("power[special_invoice]"), SpecialInvoice: ctx.Request.FormValue("power[special_invoice]"),
VerifyBlacklist: ctx.Request.FormValue("power[verify_blacklist]"), VerifyBlacklist: ctx.Request.FormValue("power[verify_blacklist]"),
} }
common.PrintDebugHtml(ctx,power)
//批量获取商品详情 //批量获取商品详情
skuArr := gredis.Hmget("default_r", "sku", goodsIds) skuArr := gredis.Hmget("default_r", "sku", goodsIds)
//为了性能着想,这边也先去批量获取spu的信息 //为了性能着想,这边也先去批量获取spu的信息
...@@ -136,9 +136,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -136,9 +136,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
hasActivity = true hasActivity = true
} }
} }
common.PrintDebugHtml(ctx,power.Member)
//获取会员价 //获取会员价
if !hasActivity && (power.Member == "true" || power.Member == "1") { if !hasActivity && (power.Member == "true" || power.Member == "1") {
common.PrintDebugHtml(ctx,power.Member)
sku = ls.GetActivityPrice(sku, "_Member", power) sku = ls.GetActivityPrice(sku, "_Member", power)
if sku.AcType > 0 { if sku.AcType > 0 {
hasActivity = true hasActivity = true
......
...@@ -22,13 +22,13 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe ...@@ -22,13 +22,13 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe
if suffix == "" && sku.SupplierId == 14 { if suffix == "" && sku.SupplierId == 14 {
return getMouserActivityPrice(sku) return getMouserActivityPrice(sku)
} }
//先获取活动信息,针对不同供应商不同活动类型做活动吗,每个活动只能针对一个供应商 //先获取活动信息,针对不同供应商不同活动类型做活动吗,每个活动只能针对一个供应商
//比如有 Self_ActivityPrice_2_Discount,Self_ActivityPrice_1_NewCustomer //比如有 Self_ActivityPrice_2_Discount,Self_ActivityPrice_1_NewCustomer
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
supplierIdStr := strconv.Itoa(int(sku.SupplierId)) supplierIdStr := strconv.Itoa(int(sku.SupplierId))
activityInfo, _ := redis.String(redisCon.Do("GET", "Self_ActivityPrice_"+supplierIdStr+suffix)) activityInfo, _ := redis.String(redisCon.Do("GET", "Self_ActivityPrice_"+supplierIdStr+suffix))
//找不到对应的活动价格信息,就直接返回空 //找不到对应的活动价格信息,就直接返回空
if activityInfo == "" { if activityInfo == "" {
return sku return sku
...@@ -44,10 +44,10 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe ...@@ -44,10 +44,10 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe
//获取redis里面存储的活动相关信息 //获取redis里面存储的活动相关信息
brandIdArray := gjson.Get(activityInfo, "brand_id").Array() brandIdArray := gjson.Get(activityInfo, "brand_id").Array()
var brandIds []string var brandIds []int64
for _, brandId := range brandIdArray { for _, brandId := range brandIdArray {
if brandId.String() != "" { if brandId.String() != "" {
brandIds = append(brandIds, brandId.String()) brandIds = append(brandIds, brandId.Int())
} }
} }
goodsNameArray := gjson.Get(activityInfo, "goods_name").Array() goodsNameArray := gjson.Get(activityInfo, "goods_name").Array()
...@@ -134,7 +134,7 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe ...@@ -134,7 +134,7 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe
if suffix == "_Member" && gjson.Get(activityInfo, "is_part").Int() == 1 && if suffix == "_Member" && gjson.Get(activityInfo, "is_part").Int() == 1 &&
visibleRoster != "" { visibleRoster != "" {
//为了用字符串匹配 //为了用字符串匹配
visibleRoster = visibleRoster + "," visibleRoster = "," + visibleRoster + ","
//提取出user_id、手机号、邮箱 //提取出user_id、手机号、邮箱
userInfo := make(map[string]string) userInfo := make(map[string]string)
userInfo["user_id"] = power.UserId userInfo["user_id"] = power.UserId
...@@ -146,9 +146,9 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe ...@@ -146,9 +146,9 @@ func (ls *LyService) GetActivityPrice(sku model.LySku, suffix string, power Powe
hasActivity = false hasActivity = false
continue continue
} }
if !strings.Contains(visibleRoster, ","+value+",") { if strings.Contains(visibleRoster, ","+value+",") {
hasActivity = true hasActivity = true
continue break
} else { } else {
hasActivity = false hasActivity = false
} }
......
...@@ -6,9 +6,7 @@ import ( ...@@ -6,9 +6,7 @@ import (
) )
func main() { func main() {
str := `{"cn":{"max":"10000","price":"20"},"hk":{"max":69000,"price":138}}` var a = []string{"3923"}
var res interface{} var b = 3923
fmt.Println(php2go.JSONDecode([]byte(str), &res)) fmt.Println(php2go.InArray(b,a))
tem, _ := php2go.JSONEncode(res)
fmt.Println(string(tem))
} }
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