Commit 658b9332 by 杨树贤

Merge branch 'ysx-mrq需求-20230710'

# Conflicts:
#	go.mod
parents 49d30d83 fd4e83fe
...@@ -45,6 +45,7 @@ require ( ...@@ -45,6 +45,7 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect sigs.k8s.io/yaml v1.2.0 // indirect
) )
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
...@@ -31,6 +31,7 @@ type LySku struct { ...@@ -31,6 +31,7 @@ type LySku struct {
Packing string `json:"packing"` Packing string `json:"packing"`
GoodsId string `json:"goods_id"` GoodsId string `json:"goods_id"`
GoodsName string `json:"goods_name"` GoodsName string `json:"goods_name"`
SkuName string `json:"sku_name"`
BrandName string `json:"brand_name"` BrandName string `json:"brand_name"`
SupplierName string `json:"supplier_name"` SupplierName string `json:"supplier_name"`
Attrs interface{} `json:"attrs"` Attrs interface{} `json:"attrs"`
...@@ -153,15 +154,18 @@ func InitSkuData(sku string) (data LySku) { ...@@ -153,15 +154,18 @@ func InitSkuData(sku string) (data LySku) {
goodsStatus := gjson.Get(sku, "goods_status").Int() goodsStatus := gjson.Get(sku, "goods_status").Int()
data.GoodsStatus = goodsStatus data.GoodsStatus = goodsStatus
supplierId := gjson.Get(sku, "supplier_id").Int()
data.SupplierId = supplierId
goodsName := gjson.Get(sku, "goods_name").String() goodsName := gjson.Get(sku, "goods_name").String()
data.GoodsName = goodsName data.GoodsName = goodsName
skuName := gjson.Get(sku, "goods_name").String()
data.SkuName = skuName
goodsType := gjson.Get(sku, "goods_type").Int() goodsType := gjson.Get(sku, "goods_type").Int()
data.GoodsType = goodsType data.GoodsType = goodsType
supplierId := gjson.Get(sku, "supplier_id").Int()
data.SupplierId = supplierId
encoded := gjson.Get(sku, "encoded").String() encoded := gjson.Get(sku, "encoded").String()
data.Encoded = encoded data.Encoded = encoded
......
...@@ -28,7 +28,7 @@ type Power struct { ...@@ -28,7 +28,7 @@ type Power struct {
} }
/* /*
联营数据详情 联营数据详情
*/ */
func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan sync.Map) { func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan sync.Map) {
redisConn := gredis.Conn("search_r") redisConn := gredis.Conn("search_r")
...@@ -77,6 +77,10 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -77,6 +77,10 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
} }
//获取商品名称 //获取商品名称
//1688就是mro的sku spuName和GoodsName不是一个东西,不能公用
if sku.GoodsName != "" && sku.SupplierId == 1688 {
sku.GoodsName = gjson.Get(spu, "spu_name").String()
}
if sku.GoodsName == "" { if sku.GoodsName == "" {
sku.GoodsName = gjson.Get(spu, "spu_name").String() sku.GoodsName = gjson.Get(spu, "spu_name").String()
} }
...@@ -207,7 +211,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan ...@@ -207,7 +211,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
ch <- GoodsRes ch <- GoodsRes
} }
//获取活动 // 获取活动
func (ls *LyService) GetActivity(sku model.LySku) model.LySku { func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
//去判断是否有活动(促销打折活动和满赠活动) //去判断是否有活动(促销打折活动和满赠活动)
checkData := model.ActivityCheckData{ checkData := model.ActivityCheckData{
......
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
_ "gopkg.in/mgo.v2/bson" _ "gopkg.in/mgo.v2/bson"
) )
//获取图片信息 // 获取图片信息
func (ls *LyService) GetGoodsImages(sku model.LySku, spu string) model.LySku { func (ls *LyService) GetGoodsImages(sku model.LySku, spu string) model.LySku {
//图片 //图片
spuLargeImage := gjson.Get(spu, "images_l").String() spuLargeImage := gjson.Get(spu, "images_l").String()
...@@ -40,7 +40,7 @@ func (ls *LyService) GetGoodsImages(sku model.LySku, spu string) model.LySku { ...@@ -40,7 +40,7 @@ func (ls *LyService) GetGoodsImages(sku model.LySku, spu string) model.LySku {
return sku return sku
} }
//获取分类信息 // 获取分类信息
func (ls *LyService) GetGoodsClass(sku model.LySku, spu string) model.LySku { func (ls *LyService) GetGoodsClass(sku model.LySku, spu string) model.LySku {
//仅提供价格和库存 //仅提供价格和库存
spuClassId1 := gjson.Get(spu, "class_id1").Int() spuClassId1 := gjson.Get(spu, "class_id1").Int()
...@@ -57,7 +57,7 @@ func (ls *LyService) GetGoodsClass(sku model.LySku, spu string) model.LySku { ...@@ -57,7 +57,7 @@ func (ls *LyService) GetGoodsClass(sku model.LySku, spu string) model.LySku {
return sku return sku
} }
//获取税务信息,对接税务系统 // 获取税务信息,对接税务系统
func (ls *LyService) GetErpTax(goodsName, brandName string) interface{} { func (ls *LyService) GetErpTax(goodsName, brandName string) interface{} {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
...@@ -73,7 +73,7 @@ func (ls *LyService) GetErpTax(goodsName, brandName string) interface{} { ...@@ -73,7 +73,7 @@ func (ls *LyService) GetErpTax(goodsName, brandName string) interface{} {
} }
} }
//获取联营供应商的名字 // 获取联营供应商的名字
func (ls *LyService) GetPoolSupplierName(supplierId int64) (supplierName string) { func (ls *LyService) GetPoolSupplierName(supplierId int64) (supplierName string) {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
...@@ -81,7 +81,7 @@ func (ls *LyService) GetPoolSupplierName(supplierId int64) (supplierName string) ...@@ -81,7 +81,7 @@ func (ls *LyService) GetPoolSupplierName(supplierId int64) (supplierName string)
return supplier return supplier
} }
//从缓存获取分类 // 从缓存获取分类
func (ls *LyService) GetCacheClass(classId int64) string { func (ls *LyService) GetCacheClass(classId int64) string {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
...@@ -102,7 +102,7 @@ type AttrsExtend struct { ...@@ -102,7 +102,7 @@ type AttrsExtend struct {
AttrUnit string `bson:"attr_unit" json:"attr_unit,omitempty"` AttrUnit string `bson:"attr_unit" json:"attr_unit,omitempty"`
} }
//H获取供应链标准品牌 // H获取供应链标准品牌
func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) { func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
...@@ -122,7 +122,7 @@ func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) { ...@@ -122,7 +122,7 @@ func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) {
} }
} }
//获取新版标准品牌 // 获取新版标准品牌
func (ls *LyService) GetStandardBrand(brandId int64) (standardBrand model.StandardBrand) { func (ls *LyService) GetStandardBrand(brandId int64) (standardBrand model.StandardBrand) {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
...@@ -150,7 +150,7 @@ type ExtendFee struct { ...@@ -150,7 +150,7 @@ type ExtendFee struct {
} `json:"hk"` } `json:"hk"`
} }
//获取附加费 // 获取附加费
func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} { func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
defer redisCon.Close() defer redisCon.Close()
...@@ -181,7 +181,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} { ...@@ -181,7 +181,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
} }
} }
//获取系数 // 获取系数
func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if len(sku.LadderPrice) == 0 { if len(sku.LadderPrice) == 0 {
//sku.Original = nil //sku.Original = nil
...@@ -225,7 +225,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -225,7 +225,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data[key].PriceCostCn = price.PriceCostCn data[key].PriceCostCn = price.PriceCostCn
//联营或者专卖 同时 存在活动价格 //联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 { if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4) tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
data[key].PriceAc = tempAcPrice data[key].PriceAc = tempAcPrice
data[key].PriceAcUs = c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4) data[key].PriceAcUs = c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
...@@ -323,7 +323,10 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -323,7 +323,10 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku.DiscountRatio.Ratio = cnDiscountRatio sku.DiscountRatio.Ratio = cnDiscountRatio
sku.DiscountRatio.RatioUsd = usDiscountRatio sku.DiscountRatio.RatioUsd = usDiscountRatio
//再去找售价组系数 /**
再去找售价组系数
**/
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的 //找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
isDefaultPriceRatio := false isDefaultPriceRatio := false
priceRatioCache, _ := redis.String(redisCon.Do("HGET", "magic_cube_price_rule_channel", sku.SupplierId)) priceRatioCache, _ := redis.String(redisCon.Do("HGET", "magic_cube_price_rule_channel", sku.SupplierId))
...@@ -333,7 +336,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -333,7 +336,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
isDefaultPriceRatio = true isDefaultPriceRatio = true
priceRatioCache, _ = redis.String(redisCon.Do("GET", "magic_cube_price_rule_channel_default")) priceRatioCache, _ = redis.String(redisCon.Do("GET", "magic_cube_price_rule_channel_default"))
} }
var priceRatioSort int var priceRatioSort int
//这个就是最终要获取到的价格系数 //这个就是最终要获取到的价格系数
var priceRatioList []model.PriceRatio var priceRatioList []model.PriceRatio
...@@ -341,7 +343,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -341,7 +343,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
findedRatio := false findedRatio := false
//如果只有默认系数,那么就去找默认系数 //如果只有默认系数,那么就去找默认系数
if isDefaultPriceRatio { if isDefaultPriceRatio {
} else { } else {
//拿到系数以后,就要去计算 //拿到系数以后,就要去计算
//拿出里面的所有排序 //拿出里面的所有排序
...@@ -461,7 +462,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -461,7 +462,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
} }
sku.PriceRatio = priceRatioList sku.PriceRatio = priceRatioList
sku.PriceRatioSort = priceRatioSort sku.PriceRatioSort = priceRatioSort
//这里是供应商系数,先保留这块逻辑 //这里是供应商系数,先保留这块逻辑
ratio, _ := redis.String(redisCon.Do("HGET", "pool_supplier_ratio", sku.SupplierId)) ratio, _ := redis.String(redisCon.Do("HGET", "pool_supplier_ratio", sku.SupplierId))
if ratio == "" { if ratio == "" {
...@@ -512,7 +512,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -512,7 +512,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if !hasCoefficient { if !hasCoefficient {
coefficient = defaultCoefficient coefficient = defaultCoefficient
} }
//下面是计算价格 //下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk //价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可 // 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
...@@ -553,14 +552,18 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -553,14 +552,18 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
RatioUsd: 1, RatioUsd: 1,
} }
} }
//美金成本价 //美金成本价
priceCostUs := c.MulFloat(price.PriceUs, usDiscountRatio) priceCostUs := c.MulFloat(price.PriceUs, usDiscountRatio)
priceCostUs = c.MyRound(priceCostUs, 4) priceCostUs = c.MyRound(priceCostUs, 4)
//美金售价 //美金售价
priceUs := c.MulFloat(priceCostUs, priceRatio.RatioUsd) priceUs := c.MulFloat(priceCostUs, priceRatio.RatioUsd)
//人民币成本价 //人民币成本价,mro只有人民币,所以人民币价格不是从美金来的,而且人民币是含税的.就它要特殊处理
priceCostCn := c.MulFloat(price.PriceUs, coefficient.Ratio, tax) var priceCostCn float64
if sku.SupplierId == 1688 {
priceCostCn = c.MulFloat(price.PriceCn, coefficient.Ratio)
} else {
priceCostCn = c.MulFloat(price.PriceUs, coefficient.Ratio, tax)
}
priceCostCn = c.MulFloat(c.MyRound(priceCostCn, 4), cnDiscountRatio) priceCostCn = c.MulFloat(c.MyRound(priceCostCn, 4), cnDiscountRatio)
priceCostCn = c.MyRound(priceCostCn, 4) priceCostCn = c.MyRound(priceCostCn, 4)
//人民币售价 //人民币售价
...@@ -571,7 +574,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -571,7 +574,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data[key].PriceCn = c.MyRound(priceCn, 4) data[key].PriceCn = c.MyRound(priceCn, 4)
data[key].PriceCostCn = priceCostCn data[key].PriceCostCn = priceCostCn
//处理活动价和原价相同的情况 //处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 { if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
priceAc := c.MyRound(c.MulFloat(data[key].PriceCn, (sku.Ratio/100)), 4) priceAc := c.MyRound(c.MulFloat(data[key].PriceCn, (sku.Ratio/100)), 4)
data[key].PriceAc = priceAc data[key].PriceAc = priceAc
if sku.RatioUs > 0 { if sku.RatioUs > 0 {
...@@ -603,7 +606,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -603,7 +606,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
} }
} }
} }
//判断原始价格有变化,那就要覆盖 //判断原始价格有变化,那就要覆盖
if len(originalPrice) > 0 { if len(originalPrice) > 0 {
sku.Original = originalPrice sku.Original = originalPrice
...@@ -619,7 +621,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -619,7 +621,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return sku return sku
} }
//获取供应商货期 // 获取供应商货期
func (ls *LyService) GetDelivery(supplierId int64, canal string) (delivery map[string]string) { func (ls *LyService) GetDelivery(supplierId int64, canal string) (delivery map[string]string) {
delivery = make(map[string]string) delivery = make(map[string]string)
redisCon := gredis.Conn("default_r") redisCon := gredis.Conn("default_r")
...@@ -655,7 +657,7 @@ func (ls *LyService) GetDelivery(supplierId int64, canal string) (delivery map[s ...@@ -655,7 +657,7 @@ func (ls *LyService) GetDelivery(supplierId int64, canal string) (delivery map[s
return return
} }
//判断能否购买 // 判断能否购买
func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) { func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
if sku.GoodsStatus != 1 { if sku.GoodsStatus != 1 {
return return
...@@ -672,7 +674,7 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) { ...@@ -672,7 +674,7 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
return 1 return 1
} }
//合并spu的信息 // 合并spu的信息
func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku { func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku {
sku.UpdateTime = gjson.Get(spuStr, "update_time").Int() sku.UpdateTime = gjson.Get(spuStr, "update_time").Int()
sku.ClassID1 = int(gjson.Get(spuStr, "class_id1").Int()) sku.ClassID1 = int(gjson.Get(spuStr, "class_id1").Int())
......
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