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