Commit ed04fedb by 杨树贤

新增产地判断

parent 150e4f47
......@@ -88,6 +88,8 @@ type LySku struct {
CustomizeRateUs float64
SpuEccn string `json:"spu_eccn"`
CustomPriceList []CustomPrice `json:"custom_price_list"`
Coo string `json:"coo"`
Tariff float64 `json:"tariff"`
}
type DiscountRatio struct {
......@@ -278,6 +280,8 @@ func InitSkuData(sku string) (data LySku) {
data.OriginalPrice = getOriginPrice(LadderPriceStr)
data.DatabasePrice = getDatabasePrice(LadderPriceStr)
data.Coo = gjson.Get(sku, "coo").String()
return
}
......
......@@ -665,3 +665,12 @@ func ConvertToGrams(input string) (float64, error) {
return 0, fmt.Errorf("未知的重量单位: %s", unit)
}
}
func CheckIntSliceContains(target int, slice []int) bool {
for _, value := range slice {
if value == target {
return true
}
}
return false
}
......@@ -246,6 +246,9 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
var TagService TagsService
sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0)
//获取关税以及价格转换
sku = ls.GetTariffAndPrice(sku)
//用spuInfo补全信息
sku = ls.CombineSup(sku, spu)
//最后一步,将sku的全部信息放到有序map里面
......
......@@ -563,3 +563,40 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return sku
}
func (ls *LyService) GetTariffAndPrice(sku model.LySku) model.LySku {
if len(sku.LadderPrice) == 0 {
return sku
}
//判断场地是否是美国,是美国的话,输出关税率以及转换价格
//https://cf.ichunt.net/pages/viewpage.action?pageId=35326045
usLabelList := []string{
"USA",
"US",
}
usSupplierIdList := []int{
6,
19,
7,
1675,
}
//先判断供应商对不对
if !c.CheckIntSliceContains(int(sku.SupplierId), usSupplierIdList) {
return sku
}
if php2go.InArray(sku.Coo, usLabelList) {
//转换价格
//判断原始人民币有没有价格,没有的话,那就是最终的人民币价格 X 2.25
var transformedLadderPrice []model.LadderPrice
transformedLadderPrice = sku.LadderPrice
for index, price := range sku.LadderPrice {
transformedLadderPrice[index].PriceCn = c.MyRound(c.MulFloat(price.PriceCn,2.25),4)
transformedLadderPrice[index].PriceAc = c.MyRound(c.MulFloat(price.PriceAc,2.25),4)
}
sku.Tariff = 2.25
}
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