Commit efb5fb25 by 杨树贤

Merge branch 'ysx-爱智活动价-20250604' into dev

parents 7aab94d2 f3673076
...@@ -20,4 +20,4 @@ cmd.exe~ ...@@ -20,4 +20,4 @@ cmd.exe~
/doc/test3 /doc/test3
/.history /.history
/.vscode /.vscode
.codeiumignore
...@@ -69,4 +69,5 @@ type ActivityCheckData struct { ...@@ -69,4 +69,5 @@ type ActivityCheckData struct {
GoodsId string GoodsId string
Canal string Canal string
ClassId int ClassId int
OrgId int
} }
...@@ -92,6 +92,7 @@ type LySku struct { ...@@ -92,6 +92,7 @@ type LySku struct {
Tariff float64 `json:"tariff"` Tariff float64 `json:"tariff"`
TariffFormat string `json:"tariff_format"` TariffFormat string `json:"tariff_format"`
AbilityLevel int `json:"ability_level"` AbilityLevel int `json:"ability_level"`
BrandPack string `json:"brand_pack"`
} }
type DiscountRatio struct { type DiscountRatio struct {
...@@ -162,7 +163,7 @@ type SpuExtra struct { ...@@ -162,7 +163,7 @@ type SpuExtra struct {
TransformedWeight float64 `json:"weight"` TransformedWeight float64 `json:"weight"`
Width string `json:"width" bson:"width"` Width string `json:"width" bson:"width"`
Length string `json:"length" bson:"length"` Length string `json:"length" bson:"length"`
BrandPack string `json:"brand_pack" bson:"brand_pack"` BrandPack string `json:"brand_pack" bson:"brand_pack"`
} }
type CustomPrice struct { type CustomPrice struct {
...@@ -287,7 +288,6 @@ func InitSkuData(sku string) (data LySku) { ...@@ -287,7 +288,6 @@ func InitSkuData(sku string) (data LySku) {
data.AbilityLevel = int(gjson.Get(sku, "ability_level").Int()) data.AbilityLevel = int(gjson.Get(sku, "ability_level").Int())
return return
} }
......
...@@ -24,8 +24,16 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p ...@@ -24,8 +24,16 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
supplierId := checkData.SupplierId supplierId := checkData.SupplierId
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
var redisKey string
//区分猎芯和华云
if checkData.OrgId == 1 {
redisKey = gconv.String(supplierId)
} else {
redisKey = gconv.String(supplierId) + "_" + gconv.String(checkData.OrgId)
}
//处理单品促销活动(打折活动) //处理单品促销活动(打折活动)
activityStr, _ := redis.String(redisCon.Do("hget", "lie_price_activity", supplierId)) activityStr, _ := redis.String(redisCon.Do("hget", "lie_price_activity", redisKey))
if activityStr != "" { if activityStr != "" {
var activities []model.Activity var activities []model.Activity
err := json.Unmarshal([]byte(activityStr), &activities) err := json.Unmarshal([]byte(activityStr), &activities)
......
...@@ -7,11 +7,12 @@ import ( ...@@ -7,11 +7,12 @@ import (
"go_sku_server/pkg/logger" "go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo" "go_sku_server/pkg/mongo"
"go_sku_server/service/sorter" "go_sku_server/service/sorter"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"sort" "sort"
"sync" "sync"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
...@@ -140,9 +141,9 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -140,9 +141,9 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
brandPack := gjson.Get(spu, "brand_pack").String() brandPack := gjson.Get(spu, "brand_pack").String()
if brandPack != "" { if brandPack != "" {
sku.SpuExtra.BrandPack = brandPack sku.SpuExtra.BrandPack = brandPack
sku.BrandPack = brandPack
} }
//获取供应链标准品牌 //获取供应链标准品牌
//什么是供应链的标准品牌 供应链那边报关的时候要求他们的标准品牌,所以要吧自己的品牌映射上去 //什么是供应链的标准品牌 供应链那边报关的时候要求他们的标准品牌,所以要吧自己的品牌映射上去
//继来那边对接的标准品牌(下单的时候) //继来那边对接的标准品牌(下单的时候)
...@@ -160,9 +161,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -160,9 +161,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.AcType = 0 sku.AcType = 0
sku.AllowCoupon = 1 sku.AllowCoupon = 1
//这里获取活动价格和活动类型
sku = ls.GetActivity(sku)
//最小起订量要大于阶梯价的最小阶梯数量 //最小起订量要大于阶梯价的最小阶梯数量
if len(sku.LadderPrice) > 0 { if len(sku.LadderPrice) > 0 {
//排序 //排序
...@@ -173,7 +171,12 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -173,7 +171,12 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.Moq = purchases sku.Moq = purchases
} }
} }
//这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断,如果是爱智,不需要走价格体系
//这里获取活动价格和活动类型(折扣打折活动)
sku = ls.GetActivity(sku)
priceService := PriceService{}
//这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断
//1是猎芯,3是爱智 //1是猎芯,3是爱智
switch sku.OrgId { switch sku.OrgId {
//case为0是为了兼容价格体系之前的价格 //case为0是为了兼容价格体系之前的价格
...@@ -187,6 +190,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -187,6 +190,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)
sku = priceService.GetActivityPrice(sku)
} }
case 3: case 3:
//如果是寄售的,不走价格体系 //如果是寄售的,不走价格体系
...@@ -201,7 +205,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -201,7 +205,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
if (sku.OrgId == 3 && len(sku.LadderPrice) == 2 && sku.LadderPrice[0].Purchases != 0) || if (sku.OrgId == 3 && len(sku.LadderPrice) == 2 && sku.LadderPrice[0].Purchases != 0) ||
(sku.OrgId == 3 && len(sku.LadderPrice) == 3 && sku.LadderPrice[0].Purchases == 0) || (sku.OrgId == 3 && len(sku.LadderPrice) == 3 && sku.LadderPrice[0].Purchases == 0) ||
(sku.OrgId == 3 && len(sku.LadderPrice) == 4 && sku.LadderPrice[0].Purchases == 0) { (sku.OrgId == 3 && len(sku.LadderPrice) == 4 && sku.LadderPrice[0].Purchases == 0) {
priceService := PriceService{}
sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice) sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice)
} else { } else {
//判断是不是华云的,如果是的话,还要判断是不是有成本价和销售限价,如果是的话,要把销售限价去掉,因为走的价格体系的前提是有成本价的时候 //判断是不是华云的,如果是的话,还要判断是不是有成本价和销售限价,如果是的话,要把销售限价去掉,因为走的价格体系的前提是有成本价的时候
...@@ -219,11 +222,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -219,11 +222,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
if sku.OrgId == 3 { if sku.OrgId == 3 {
sku.LadderPrice = customPriceService.transformIEdgeLadderPrice(sku) sku.LadderPrice = customPriceService.transformIEdgeLadderPrice(sku)
} }
} }
break sku = priceService.GetActivityPrice(sku)
default:
break
} }
//仅提供价格和库存 //仅提供价格和库存
...@@ -286,6 +286,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku { ...@@ -286,6 +286,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
Canal: sku.Canal, Canal: sku.Canal,
GoodsName: sku.GoodsName, GoodsName: sku.GoodsName,
ClassId: sku.ClassID2, ClassId: sku.ClassID2,
OrgId: sku.OrgId,
} }
var activityService ActivityService var activityService ActivityService
priceActivity, giftActivity := activityService.GetActivityData(checkData) priceActivity, giftActivity := activityService.GetActivityData(checkData)
...@@ -350,7 +351,7 @@ func (ls *LyService) GetSpuExtra(spuId string) (spuExtra model.SpuExtra) { ...@@ -350,7 +351,7 @@ func (ls *LyService) GetSpuExtra(spuId string) (spuExtra model.SpuExtra) {
} `bson:"image_list" json:"old_image_list"` } `bson:"image_list" json:"old_image_list"`
} }
var oldSpuExtra OldSpuExtra var oldSpuExtra OldSpuExtra
err = mongodb.DB("ichunt").C("spu_extra").Find(bson.M{"spu_id": spuId}).One(&oldSpuExtra) mongodb.DB("ichunt").C("spu_extra").Find(bson.M{"spu_id": spuId}).One(&oldSpuExtra)
for _, image := range oldSpuExtra.OldImageList { for _, image := range oldSpuExtra.OldImageList {
spuExtra.ImageList = append(spuExtra.ImageList, struct { spuExtra.ImageList = append(spuExtra.ImageList, struct {
......
...@@ -2,20 +2,21 @@ package service ...@@ -2,20 +2,21 @@ package service
import ( import (
"encoding/json" "encoding/json"
"github.com/gomodule/redigo/redis"
_ "github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/model" "go_sku_server/model"
c "go_sku_server/pkg/common" c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis" "go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger" "go_sku_server/pkg/logger"
_ "go_sku_server/pkg/mongo" _ "go_sku_server/pkg/mongo"
"go_sku_server/service/sorter" "go_sku_server/service/sorter"
_ "gopkg.in/mgo.v2/bson"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"github.com/gomodule/redigo/redis"
_ "github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
_ "gopkg.in/mgo.v2/bson"
) )
// 获取图片信息 // 获取图片信息
...@@ -290,11 +291,9 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -290,11 +291,9 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//没有阶梯价格,直接跳过 //没有阶梯价格,直接跳过
if len(sku.LadderPrice) == 0 { if len(sku.LadderPrice) == 0 {
//sku.Original = nil
return sku return sku
} }
priceService := PriceService{} priceService := PriceService{}
flag := 0
var data []model.LadderPrice var data []model.LadderPrice
var originalPrice []model.OriginPrice var originalPrice []model.OriginPrice
sort.Sort(sorter.OriginPriceSorter(sku.OriginalPrice)) sort.Sort(sorter.OriginPriceSorter(sku.OriginalPrice))
...@@ -322,15 +321,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -322,15 +321,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data[key].Purchases = price.Purchases data[key].Purchases = price.Purchases
//下面的价格,还要乘于折扣系数 //下面的价格,还要乘于折扣系数
if price.PriceUs != 0 { if price.PriceUs != 0 {
priceUs := c.MyRound(price.PriceUs, 4) priceUs := c.MyRound(c.MulFloat(price.PriceUs, sku.DiscountRatio.RatioUsd), 4)
priceUs = c.MyRound(c.MulFloat(price.PriceUs, sku.DiscountRatio.RatioUsd), 4)
data[key].PriceUs = priceUs data[key].PriceUs = priceUs
price.PriceUs = priceUs price.PriceUs = priceUs
} }
if price.PriceCn != 0 { if price.PriceCn != 0 {
priceCn := c.MyRound(price.PriceCn, 4) priceCn := c.MyRound(c.MulFloat(price.PriceCn, sku.DiscountRatio.Ratio), 4)
priceCn = c.MyRound(c.MulFloat(price.PriceCn, sku.DiscountRatio.Ratio), 4)
data[key].PriceCn = priceCn data[key].PriceCn = priceCn
price.PriceCn = priceCn price.PriceCn = priceCn
} }
...@@ -338,32 +335,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -338,32 +335,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//专卖成本价 //专卖成本价
data[key].PriceCostUs = price.PriceCostUs data[key].PriceCostUs = price.PriceCostUs
data[key].PriceCostCn = price.PriceCostCn data[key].PriceCostCn = price.PriceCostCn
//联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
//价格与原价一样
if data[key].PriceCn == tempAcPrice && key < 2 {
//flag++
//if flag >= 2 || (len(ladderPrice) < 2) {
// sku.AcType = 0
// continue
//}
}
data[key].PriceAc = tempAcPrice
priceAcUs := c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
data[key].PriceAcUs = priceAcUs
//优惠价后等于0,就代表没有搞活动
if tempAcPrice <= 0 && priceAcUs <= 0 {
sku.AcType = 0
}
}
} }
} else { } else {
data = make([]model.LadderPrice, len(sku.LadderPrice)) data = make([]model.LadderPrice, len(sku.LadderPrice))
...@@ -513,40 +484,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -513,40 +484,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
RatioUsd: priceRatio.RatioUsd, RatioUsd: priceRatio.RatioUsd,
}) })
sku.PriceRatio = showPriceRatioList sku.PriceRatio = showPriceRatioList
//处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
priceAc := c.MyRound(c.MulFloat(data[key].PriceCn, (sku.Ratio/100)), 4)
//为什么$kp < 2,如果第一阶梯或第二阶梯价格和活动价一样,就不输出活动价了
//活动价都是有样式的和平时不一样,如果价格一样,但是样子是活动价,客户会迷惑,所以不输出即可,保持原来的样式
if data[key].PriceCn == priceAc && key < 2 {
flag++
}
data[key].PriceAc = priceAc
var priceAcUs float64
if sku.RatioUs > 0 {
priceAcUs = c.MyRound(c.MulFloat(data[key].PriceUs, (sku.RatioUs/100)), 4)
data[key].PriceAcUs = priceAcUs
}
if priceAc <= 0 && priceAcUs <= 0 {
sku.AcType = 0
break
} else {
if sku.AcType == 4 {
data[key].PriceCn = priceAc
sku.AcType = 0
}
}
}
} }
//判断原始价格有变化,那就要覆盖 //判断原始价格有变化,那就要覆盖
if len(originalPrice) > 0 { if len(originalPrice) > 0 {
......
package service package service
import ( import (
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/model" "go_sku_server/model"
c "go_sku_server/pkg/common" c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis" "go_sku_server/pkg/gredis"
...@@ -12,6 +8,11 @@ import ( ...@@ -12,6 +8,11 @@ import (
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
) )
type PriceService struct { type PriceService struct {
...@@ -775,3 +776,78 @@ func (ps *PriceService) GetIEdgePrice(ladderPrice []model.LadderPrice) []model.L ...@@ -775,3 +776,78 @@ func (ps *PriceService) GetIEdgePrice(ladderPrice []model.LadderPrice) []model.L
return ladderPrice return ladderPrice
} }
// 单独拎出来处理活动价
func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
if len(sku.LadderPrice) == 0 {
return sku
}
if sku.SupplierId == 17 {
for index, price := range sku.LadderPrice {
//联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
//价格与原价一样
if price.PriceCn == tempAcPrice && index < 2 {
//flag++
//if flag >= 2 || (len(ladderPrice) < 2) {
// sku.AcType = 0
// continue
//}
}
price.PriceAc = tempAcPrice
priceAcUs := c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
price.PriceAcUs = priceAcUs
sku.LadderPrice[index].PriceAc = tempAcPrice
sku.LadderPrice[index].PriceAcUs = priceAcUs
//优惠价后等于0,就代表没有搞活动
if tempAcPrice <= 0 && priceAcUs <= 0 {
sku.AcType = 0
}
}
}
} else {
for index, price := range sku.LadderPrice {
//处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
priceAc := c.MyRound(c.MulFloat(price.PriceCn, (sku.Ratio/100)), 4)
//为什么$kp < 2,如果第一阶梯或第二阶梯价格和活动价一样,就不输出活动价了
//活动价都是有样式的和平时不一样,如果价格一样,但是样子是活动价,客户会迷惑,所以不输出即可,保持原来的样式
if price.PriceCn == priceAc && index < 2 {
// flag++
}
sku.LadderPrice[index].PriceAc = priceAc
var priceAcUs float64
if sku.RatioUs > 0 {
priceAcUs = c.MyRound(c.MulFloat(price.PriceUs, (sku.RatioUs/100)), 4)
sku.LadderPrice[index].PriceAcUs = priceAcUs
}
if priceAc <= 0 && priceAcUs <= 0 {
sku.AcType = 0
break
} else {
if sku.AcType == 4 {
sku.LadderPrice[index].PriceCn = priceAc
sku.AcType = 0
}
}
}
}
}
return sku
}
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