Commit 3361deab by mushishixian

Merge branch 'ysx-魔方改版-20230313' into dev

parents f0f46c41 74cb4a8d
......@@ -42,6 +42,8 @@ type Activity struct {
StandardBrandIdList []string
ExcludeStandardBrandIds string `json:"exclude_standard_brand_ids"`
ExcludeStandardBrandIdList []string
CurrencyRmb int `json:"currency_rmb"`
CurrencyUs int `json:"currency_us"`
}
type ActivityItem struct {
......
......@@ -9,13 +9,13 @@ type LyResponse struct {
//原始sku梯度
type LadderPrice struct {
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us,omitempty"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceCostUs float64 `json:"price_cost_us"` //成本价美金
PriceCostCn float64 `json:"price_cost_cn"` //成本价人民币
PriceAc float64 `json:"price_ac,omitempty"` //活动价人民币
PriceAcUs float64 `json:"price_ac_us"` //活动价美金
Purchases int64 `json:"purchases"` //购买数量
PriceUs float64 `json:"price_us,omitempty"` //数量对应的英文价格
PriceCn float64 `json:"price_cn"` //数量对应的中文价格
PriceCostUs float64 `json:"price_cost_us"` //成本价美金
PriceCostCn float64 `json:"price_cost_cn"` //成本价人民币
PriceAc float64 `json:"price_ac,omitempty"` //活动价人民币
PriceAcUs float64 `json:"price_ac_us,omitempty"` //活动价美金
CostPrice float64 `json:"-"`
}
......
......@@ -23,7 +23,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv"
"github.com/shopspring/decimal"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
)
......@@ -605,7 +604,11 @@ func MyRound(x float64, wei int) float64 {
////////////类型转换/////////////////////
//浮点数乘法
func MulFloat(x float64, y float64) float64 {
result, _ := decimal.NewFromFloat(x).Mul(decimal.NewFromFloat(y)).Float64()
func MulFloat(first float64, args ...float64) float64 {
var result float64
result = first
for _, arg := range args {
result = ((result * 1000000000) * (arg * 1000000000)) / 1000000000000000000
}
return result
}
......@@ -185,10 +185,15 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
UserScope: activity.UserScope,
},
}
if activity.RatioUs > 0 {
if activity.CurrencyRmb == 1 {
priceActivity.Ratio = activity.Ratio
} else {
priceActivity.Ratio = 0
}
if activity.CurrencyUs == 1 {
priceActivity.RatioUs = activity.RatioUs
} else {
priceActivity.RatioUs = 1
priceActivity.RatioUs = 0
}
break
}
......
......@@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"
"go_sku_server/model"
"go_sku_server/pkg/common"
c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger"
_ "go_sku_server/pkg/mongo"
......@@ -115,7 +115,7 @@ func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) {
scmBrand := make(map[string]interface{})
scmBrand["erp_brand_name"] = gjson.Get(scmBrandData, "erp_brand_name").String()
scmBrand["erp_brand_id"] = gjson.Get(scmBrandData, "erp_brand_id").String()
scmBrand["scm_brand_id"] = common.ToString(scmBrandId)
scmBrand["scm_brand_id"] = c.ToString(scmBrandId)
return scmBrand
} else {
return []string{}
......@@ -198,16 +198,16 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
data[key].Purchases = price.Purchases
if price.PriceUs != 0 {
data[key].PriceUs = common.MyRound(price.PriceUs, 4)
data[key].PriceUs = c.MyRound(price.PriceUs, 4)
}
if price.PriceCn != 0 {
data[key].PriceCn = common.MyRound(price.PriceCn, 4)
data[key].PriceCn = c.MyRound(price.PriceCn, 4)
}
//联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 {
tempAcPrice := common.MyRound(price.PriceCn*(sku.Ratio/100), 4)
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, (sku.Ratio/100)), 4)
data[key].PriceAc = tempAcPrice
data[key].PriceAcUs = common.MyRound(price.PriceUs*(sku.RatioUs/100), 4)
data[key].PriceAcUs = c.MyRound(c.MulFloat(price.PriceUs, (sku.RatioUs/100)), 4)
//优惠价后等于0,就代表没有搞活动
if tempAcPrice <= 0 {
sku.AcType = 0
......@@ -373,7 +373,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//这里是供应商系数,先保留这块逻辑
ratio, _ := redis.String(redisCon.Do("HGET", "pool_supplier_ratio", sku.SupplierId))
if ratio == "" {
logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId))
logger.Select("sku_query").Error("系数获取异常,供应商:" + c.ToString(sku.SupplierId))
return sku
}
ratios := gjson.Parse(ratio).Array()
......@@ -414,7 +414,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
if !hasCoefficient && !hasDefault {
logger.Select("sku_query").Error("系数获取异常,供应商:" + common.ToString(sku.SupplierId))
logger.Select("sku_query").Error("系数获取异常,供应商:" + c.ToString(sku.SupplierId))
return sku
}
if !hasCoefficient {
......@@ -444,40 +444,28 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
//美金成本价
priceCostUs := common.MulFloat(price.PriceUs, usDiscountRatio)
fmt.Println(priceCostUs)
priceCostUs = common.MyRound(priceCostUs, 4)
priceCostUs := c.MulFloat(price.PriceUs, usDiscountRatio)
priceCostUs = c.MyRound(priceCostUs, 4)
//美金售价
priceUs := common.MulFloat(priceCostUs, priceRatio.RatioUsd)
// priceUs := priceCostUs * priceRatio.RatioUsd
fmt.Println(priceUs)
priceUs := c.MulFloat(priceCostUs, priceRatio.RatioUsd)
//人民币成本价
priceCostCn := common.MyRound(price.PriceUs*coefficient.Ratio*cnDiscountRatio*tax, 4)
priceCostCn := c.MulFloat(price.PriceUs, cnDiscountRatio, coefficient.Ratio, tax)
priceCostCn = c.MyRound(priceCostCn, 4)
//人民币售价
priceCn := priceCostCn * priceRatio.Ratio
data[key].PriceUs = common.MyRound(priceUs, 4)
priceCn := c.MulFloat(priceCostCn, priceRatio.Ratio)
data[key].PriceUs = c.MyRound(priceUs, 4)
data[key].PriceCostUs = priceCostUs
//处理人民币
data[key].PriceCn = common.MyRound(priceCn, 4)
data[key].PriceCn = c.MyRound(priceCn, 4)
data[key].PriceCostCn = priceCostCn
//处理mouser的成本价
//mouser成本价是什么,斌哥同步过来的成本价
//sku.LadderPrice[key].CostPrice是专门针对贸泽(mouser)的
if sku.AcType == 2 && sku.SupplierId == 14 {
if price.CostPrice != 0 {
data[key].PriceAc = common.MyRound(price.CostPrice*coefficient.ExtraRatio*coefficient.Cn*coefficient.Ratio, 4)
data[key].PriceUs = common.MyRound(price.CostPrice*coefficient.ExtraRatio*coefficient.Hk, 4)
} else {
data[key].PriceAc = data[key].PriceCn
}
continue
}
//处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2) && sku.AcType > 1 && sku.Ratio > 0 {
priceAc := common.MyRound(data[key].PriceCn*(sku.Ratio/100), 4)
priceAc := c.MyRound(c.MulFloat(data[key].PriceCn, (sku.Ratio/100)), 4)
data[key].PriceAc = priceAc
priceAcUs := common.MyRound(data[key].PriceUs*(sku.RatioUs/100), 4)
data[key].PriceAcUs = priceAcUs
if sku.RatioUs > 0 {
priceAcUs := c.MyRound(c.MulFloat(data[key].PriceUs, (sku.RatioUs/100)), 4)
data[key].PriceAcUs = priceAcUs
}
if priceAc <= 0 {
sku.AcType = 0
......
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