Commit 025becc5 by hcy

Merge remote-tracking branch 'origin/master'

parents d122acd4 43295c13
......@@ -21,11 +21,12 @@ type LadderPrice struct {
}
type OriginPrice struct {
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceAc float64 `json:"price_ac,omitempty"`
CostPrice float64 `json:"cost_price"`
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceAc float64 `json:"price_ac,omitempty"`
CostPrice float64 `json:"cost_price"`
CostPriceUs float64 `json:"cost_price_us"`
}
type DatabasePrice struct {
......
......@@ -60,16 +60,20 @@ type LySku struct {
ClassName string `json:"class_name,omitempty"`
ErpTax interface{} `json:"erp_tax"`
GoodsSn string `json:"goods_sn"`
GoodsDetails string `json:"goods_details"`
ClassName1 string `json:"class_name1,omitempty"`
ClassName2 string `json:"class_name2,omitempty"`
ClassName3 string `json:"class_name3,omitempty"`
Ratio float64 `json:"ratio,omitempty"`
RatioUs float64 `json:"ratio_us,omitempty"`
SpuDetail string `json:"spu_detail,omitempty"`
AcType int `json:"ac_type"`
GoodsSn string `json:"goods_sn"`
GoodsDetails string `json:"goods_details"`
ClassName1 string `json:"class_name1,omitempty"`
ClassName2 string `json:"class_name2,omitempty"`
ClassName3 string `json:"class_name3,omitempty"`
Ratio float64 `json:"ratio,omitempty"`
RatioUs float64 `json:"ratio_us,omitempty"`
SpuDetail string `json:"spu_detail,omitempty"`
ApplicationLevel string `json:"application_level"`
HasRohs string `json:"has_rohs"`
Series string `json:"series"`
Lifecycle string `json:"lifecycle"`
Humistor string `json:"humistor"`
AcType int `json:"ac_type"`
//活动信息
HasGiftActivity int `json:"has_gift_activity"`
GiftActivity GiftActivity `json:"gift_activity"`
......@@ -98,7 +102,8 @@ type LySku struct {
OnwayStock int `json:"onway_stock"`
CompareRatio float64 `json:"compare_ratio"`
//兼容自营下单的字段,取成本价的第一个阶梯的人民币
Cost float64 `json:"cost"`
Cost float64 `json:"cost"`
CostUs float64 `json:"cost_us"`
}
type DiscountRatio struct {
......
......@@ -34,6 +34,8 @@ func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
data["attr_name"] = value.AttrName
//€符号全部替换为逗号
data["attr_value"] = strings.ReplaceAll(value.AttrValue, "€", ",")
data["attr_value_id"] = value.AttrValueId
data["attr_id"] = value.AttrId
data["attr_unit"] = value.AttrUnit
attrsList = append(attrsList, data)
attrsResult = attrsList
......
......@@ -266,8 +266,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
sku = priceService.GetActivityPrice(sku)
}
// sku = priceService.GetComparePrice(sku)
sku = priceService.GetCostForZiying(sku)
//仅提供价格和库存
......@@ -327,6 +325,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
//获取关税以及价格转换
sku = ls.GetTariffAndPrice(sku)
sku = priceService.GetComparePrice(sku)
//获取新的限制库存信息
has, limitStock := ls.getLimitStock(sku.GoodsId)
if has {
......
......@@ -2,7 +2,6 @@ package service
import (
"encoding/json"
"github.com/gogf/gf/util/gconv"
"go_sku_server/model"
c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
......@@ -13,6 +12,8 @@ import (
"strconv"
"strings"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
_ "github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
......@@ -118,9 +119,11 @@ type SpuAttr struct {
}
type AttrsExtend struct {
AttrName string `bson:"attr_name" json:"attr_name"`
AttrValue string `bson:"attr_value" json:"attr_value"`
AttrUnit string `bson:"attr_unit" json:"attr_unit,omitempty"`
AttrId int `bson:"attr_id" json:"attr_id"`
AttrName string `bson:"attr_name" json:"attr_name"`
AttrValue string `bson:"attr_value" json:"attr_value"`
AttrValueId int `bson:"attr_value_id" json:"attr_value_id"`
AttrUnit string `bson:"attr_unit" json:"attr_unit,omitempty"`
}
// H获取供应链标准品牌
......@@ -249,7 +252,9 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
if len(sku.LadderPrice) == 0 {
return
}
if sku.AbilityLevel == 0 {
//L0016691 L0015730 L0015835 L0016793 L0016887 L0016886 L0016784
if sku.AbilityLevel == 0 && sku.OrgId == 1 && (sku.Canal != "L0015730" && sku.Canal != "L0015835" && sku.Canal != "L0016691" && sku.Canal != "L0016793" && sku.Canal != "L0016887" && sku.Canal != "L0016886" && sku.Canal != "L0016784") {
return
}
if sku.Stock == 0 {
......@@ -298,6 +303,11 @@ func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku {
sku.Status = int(gjson.Get(spuStr, "status").Int())
sku.Encap = gjson.Get(spuStr, "encap").String()
sku.SpuEccn = gjson.Get(spuStr, "eccn").String()
sku.ApplicationLevel = gjson.Get(spuStr, "application_level").String()
sku.HasRohs = gjson.Get(spuStr, "has_rohs").String()
sku.Series = gjson.Get(spuStr, "series").String()
sku.Lifecycle = gjson.Get(spuStr, "lifecycle").String()
sku.Humistor = gjson.Get(spuStr, "humistor").String()
return sku
}
......@@ -347,6 +357,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
Purchases: price.Purchases,
PriceCn: priceCnTax,
PriceUs: price.PriceUs,
CostPrice: price.CostPrice,
})
}
......
......@@ -327,6 +327,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
if costMapIndex <= 0 {
costMapIndex = 0
}
if costMapIndex >= len(priceRatioList) {
return sku
}
priceRatioAndPurchases = priceRatioList[costMapIndex]
priceCnRatio := priceRatioAndPurchases.Ratio
priceUsRatio := priceRatioAndPurchases.RatioUsd
......@@ -929,6 +932,7 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
// compare_price_ratio
func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
//判断是否存在
compareData, _ := redis.String(redisCon.Do("HGET", "compare_price_ratio", sku.GoodsId))
if compareData == "" {
......@@ -940,7 +944,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
ladderPrice := sku.LadderPrice
for index, ladder := range ladderPrice {
if priceLimitOn == 2 && ladder.PriceAc != 0 {
if priceLimitOn == 1 && ladder.PriceAc != 0 {
ladder.PriceAc = c.MyRound(c.MulFloat(ladder.PriceAc, ratio), 4)
} else {
ladder.PriceCn = c.MyRound(c.MulFloat(ladder.PriceCn, ratio), 4)
......@@ -956,6 +960,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
func (ps *PriceService) GetCostForZiying(sku model.LySku) model.LySku {
if len(sku.OriginalPrice) != 0 {
sku.Cost = sku.OriginalPrice[0].CostPrice
sku.CostUs = sku.OriginalPrice[0].PriceUs
}
return sku
......
......@@ -77,6 +77,18 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
goodsTags.GoodsLabelName = goodsLabel
goodsTags.GoodsLabel = goodsLabelType
//系统打的标签
systemTagArr := gjson.Get(goodsTagsStr, "tags").Array()
if len(systemTagArr) > 0 {
for _, tagIdResult := range systemTagArr {
tagId := int(tagIdResult.Int())
tags = append(tags, tagId)
if tagName, ok := vars.GoodsTags[tagId]; ok {
tagNames = append(tagNames, tagName)
}
}
}
//自定义标签
customerTag := gjson.Get(goodsTagsStr, "customer_tag").String()
if customerTag != "" {
......
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