Commit 136d477e by 杨树贤

Merge branch 'ysx-华云价格新兼容-20250331' into dev

parents 60b609e8 9bc09bdb
...@@ -17,6 +17,9 @@ func (sc *CustomPrice) getCustomPriceList(sku model.LySku) (customPriceList []mo ...@@ -17,6 +17,9 @@ func (sc *CustomPrice) getCustomPriceList(sku model.LySku) (customPriceList []mo
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
customPriceRule, _ := redis.String(redisCon.Do("HGET", "cube_custom_price", sku.OrgId)) customPriceRule, _ := redis.String(redisCon.Do("HGET", "cube_custom_price", sku.OrgId))
if customPriceRule=="" {
return customPriceList, nil
}
customPriceRuleArr := gjson.Get(customPriceRule, "price_list").Array() customPriceRuleArr := gjson.Get(customPriceRule, "price_list").Array()
//这里是价格规则 //这里是价格规则
for _, customPriceRule := range customPriceRuleArr { for _, customPriceRule := range customPriceRuleArr {
......
...@@ -177,31 +177,20 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -177,31 +177,20 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
case 1: case 1:
//如果是寄售的,也不走价格体系 //如果是寄售的,也不走价格体系
if sku.Source != 12 { if sku.Source != 12 {
//这里还有个特殊判断,要兼容华云改价格体系之前的老数据 //这里猎芯和华云都是走同一套的价格体系了
//判断组织是3并且阶梯价数量为2的就是老数据 //获取系数和价格
if sku.OrgId == 3 && len(sku.LadderPrice) == 2 { sku = ls.GetCoefficientAndPrice(sku)
priceService := PriceService{} //获取自定义价格后的阶梯价
sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice) customPriceService := CustomPrice{}
} else { sku.CustomPriceList, _ = customPriceService.getCustomPriceList(sku)
//这里猎芯和华云都是走同一套的价格体系了
//获取系数和价格
sku = ls.GetCoefficientAndPrice(sku)
//获取自定义价格后的阶梯价
customPriceService := CustomPrice{}
sku.CustomPriceList, _ = customPriceService.getCustomPriceList(sku)
//这里还要针对华云的阶梯价进行一次转换,因为要兼容目前华云的试用方式
if sku.OrgId == 3 {
sku.LadderPrice = customPriceService.transformIEdgeLadderPrice(sku)
}
}
} }
case 3: case 3:
//如果是寄售的,也不走价格体系 //如果是寄售的,也不走价格体系
if sku.Source != 12 { if sku.Source != 12 {
//这里还有个特殊判断,要兼容华云改价格体系之前的老数据 //这里还有个特殊判断,要兼容华云改价格体系之前的老数据
//判断组织是3并且阶梯价数量为2的就是老数据 //判断组织是3并且阶梯价数量为2的就是老数据
if sku.OrgId == 3 && len(sku.LadderPrice) == 2 { //兼容最近的价格配置,即上传了成本价(阶梯数量0) + 会员价(阶梯数量1) + 企业价(阶梯数量2)
if (sku.OrgId == 3 && len(sku.LadderPrice) == 2) || (sku.OrgId == 3 && len(sku.LadderPrice) == 3 && sku.LadderPrice[0].Purchases == 0) {
priceService := PriceService{} priceService := PriceService{}
sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice) sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice)
} else { } else {
...@@ -211,7 +200,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -211,7 +200,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//获取自定义价格后的阶梯价 //获取自定义价格后的阶梯价
customPriceService := CustomPrice{} customPriceService := CustomPrice{}
sku.CustomPriceList, _ = customPriceService.getCustomPriceList(sku) sku.CustomPriceList, _ = customPriceService.getCustomPriceList(sku)
//这里还要针对华云的阶梯价进行一次转换,因为要兼容目前华云的用方式 //这里还要针对华云的阶梯价进行一次转换,因为要兼容目前华云的使用方式
if sku.OrgId == 3 { if sku.OrgId == 3 {
sku.LadderPrice = customPriceService.transformIEdgeLadderPrice(sku) sku.LadderPrice = customPriceService.transformIEdgeLadderPrice(sku)
} }
...@@ -331,9 +320,9 @@ func (ls *LyService) GetSpuExtra(spuId string) (spuExtra model.SpuExtra) { ...@@ -331,9 +320,9 @@ func (ls *LyService) GetSpuExtra(spuId string) (spuExtra model.SpuExtra) {
if err != nil && err != mgo.ErrNotFound { if err != nil && err != mgo.ErrNotFound {
logger.Select("sku_query").Error(err.Error()) logger.Select("sku_query").Error(err.Error())
} }
fmt.Println(spuExtra.Weight) fmt.Println(spuExtra.Weight)
if spuExtra.Weight!="" { if spuExtra.Weight != "" {
spuExtra.TransformedWeight,_ = common.ConvertToGrams(spuExtra.Weight) spuExtra.TransformedWeight, _ = common.ConvertToGrams(spuExtra.Weight)
} }
//兼容老版本数据 //兼容老版本数据
......
...@@ -739,11 +739,18 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS ...@@ -739,11 +739,18 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
func (ps *PriceService) GetIEdgePrice(ladderPrice []model.LadderPrice) []model.LadderPrice { func (ps *PriceService) GetIEdgePrice(ladderPrice []model.LadderPrice) []model.LadderPrice {
//目前的价格名称是硬编码到代码里面 //目前的价格名称是硬编码到代码里面
priceNameMap := map[int64]string{ priceNameMap := map[int64]string{
0: "成本价",
1: "标准价", 1: "标准价",
2: "企业价", 2: "企业价",
} }
for index, price := range ladderPrice { for index, price := range ladderPrice {
ladderPrice[index].PriceName = priceNameMap[price.Purchases] ladderPrice[index].PriceName = priceNameMap[price.Purchases]
} }
//如果是3个价格,那么删除第一个价格(成本价)
if len(ladderPrice) == 3 {
ladderPrice = ladderPrice[1:]
}
return ladderPrice return ladderPrice
} }
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