Commit b6f3c502 by 杨树贤

去除调试

parent ed01d0ca
...@@ -2,7 +2,6 @@ package service ...@@ -2,7 +2,6 @@ package service
import ( import (
"encoding/json" "encoding/json"
"fmt"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
_ "github.com/iancoleman/orderedmap" _ "github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
...@@ -277,7 +276,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -277,7 +276,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if ladderPrice[0].PriceCostUs == 0 && ladderPrice[0].PriceCostCn == 0 { if ladderPrice[0].PriceCostUs == 0 && ladderPrice[0].PriceCostCn == 0 {
sku = priceService.GenerateLadderPrice(sku) sku = priceService.GenerateLadderPrice(sku)
ladderPrice = sku.LadderPrice ladderPrice = sku.LadderPrice
fmt.Println(ladderPrice) //fmt.Println(ladderPrice)
} }
} }
//获取折扣系数 //获取折扣系数
...@@ -433,7 +432,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -433,7 +432,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
priceCostUs := c.MulFloat(price.PriceUs, sku.DiscountRatio.RatioUsd) priceCostUs := c.MulFloat(price.PriceUs, sku.DiscountRatio.RatioUsd)
priceCostUs = c.MyRound(priceCostUs, 4) priceCostUs = c.MyRound(priceCostUs, 4)
//美金售价 //美金售价
fmt.Println("计算美金价的系数", priceRatio.RatioUsd) //fmt.Println("计算美金价的系数", priceRatio.RatioUsd)
priceUs := c.MulFloat(priceCostUs, priceRatio.RatioUsd) priceUs := c.MulFloat(priceCostUs, priceRatio.RatioUsd)
//人民币成本价,mro只有人民币,所以人民币价格不是从美金来的,而且人民币是含税的.就它要特殊处理 //人民币成本价,mro只有人民币,所以人民币价格不是从美金来的,而且人民币是含税的.就它要特殊处理
var priceCostCn float64 var priceCostCn float64
...@@ -503,7 +502,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -503,7 +502,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku.LadderPrice = data sku.LadderPrice = data
} }
fmt.Println(sku.PriceRatio, sku.PriceRatioSort) //fmt.Println(sku.PriceRatio, sku.PriceRatioSort)
return sku return sku
} }
package service package service
import ( import (
"fmt"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go" "github.com/syyongx/php2go"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
...@@ -156,7 +155,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -156,7 +155,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
} }
//找不到特定的系数,那就去找全局的 //找不到特定的系数,那就去找全局的
if !foundRatio { if !foundRatio {
fmt.Println("去找默认系数") //fmt.Println("去找默认系数")
priceRatioCache, _ = redis.String(redisCon.Do("GET", "magic_cube_price_rule_v2_default")) priceRatioCache, _ = redis.String(redisCon.Do("GET", "magic_cube_price_rule_v2_default"))
priceRatioArr := gjson.Get(priceRatioCache, ratioDataKey).Array() priceRatioArr := gjson.Get(priceRatioCache, ratioDataKey).Array()
priceRatioList = nil priceRatioList = nil
...@@ -174,16 +173,16 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -174,16 +173,16 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//这是用来展示在商品服务的价格系数,专营的系数和代购的不一样,所以要转换一下展示形式 //这是用来展示在商品服务的价格系数,专营的系数和代购的不一样,所以要转换一下展示形式
//是否有设置最低利润点阶梯,不足5个阶梯时,最高阶梯对应的最小利润点阶梯 //是否有设置最低利润点阶梯,不足5个阶梯时,最高阶梯对应的最小利润点阶梯
var ladderPriceMiniProfitLevel int var ladderPriceMiniProfitLevel int
fmt.Println("是否找到系数", foundRatio) //fmt.Println("是否找到系数", foundRatio)
//fmt.Println("系数redis数据为 : ", priceRatioCache) //fmt.Println("系数redis数据为 : ", priceRatioCache)
fmt.Println("具体系数为 : ", priceRatioList) //fmt.Println("具体系数为 : ", priceRatioList)
if foundRatio { if foundRatio {
priceRatioSortStr := strconv.Itoa(priceRatioSort) priceRatioSortStr := strconv.Itoa(priceRatioSort)
ladderPriceMiniProfitLevel = int(gjson.Get(priceRatioCache, "ladder_price_mini_profit_level."+priceRatioSortStr).Int()) ladderPriceMiniProfitLevel = int(gjson.Get(priceRatioCache, "ladder_price_mini_profit_level."+priceRatioSortStr).Int())
} else { } else {
ladderPriceMiniProfitLevel = int(gjson.Get(priceRatioCache, "ladder_price_mini_profit_level").Int()) ladderPriceMiniProfitLevel = int(gjson.Get(priceRatioCache, "ladder_price_mini_profit_level").Int())
} }
fmt.Println("最低利润点阶梯数 : ", ladderPriceMiniProfitLevel) //fmt.Println("最低利润点阶梯数 : ", ladderPriceMiniProfitLevel)
var generatedLadderPrice []model.LadderPrice var generatedLadderPrice []model.LadderPrice
//先直接获取成本价原始值,判断第一个阶梯的阶梯数量是否为0,如果是0,那么代表是要走成本价生成,如果不是0,那么就要走阶梯价生成 //先直接获取成本价原始值,判断第一个阶梯的阶梯数量是否为0,如果是0,那么代表是要走成本价生成,如果不是0,那么就要走阶梯价生成
firstLadderPurchases := sku.LadderPrice[0].Purchases firstLadderPurchases := sku.LadderPrice[0].Purchases
...@@ -191,7 +190,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -191,7 +190,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//判断是否走成本价判断还是走阶梯价判断,因为上传sku的时候,可以设置每个sku的成本价(人民币&&美金),也可以设置每个sku的阶梯价 //判断是否走成本价判断还是走阶梯价判断,因为上传sku的时候,可以设置每个sku的成本价(人民币&&美金),也可以设置每个sku的阶梯价
//如果有阶梯价,就要跳过设置的成本价(假设有设置的话) //如果有阶梯价,就要跳过设置的成本价(假设有设置的话)
if isCostPrice { if isCostPrice {
fmt.Println("成本价") //fmt.Println("成本价")
costPriceCn := sku.LadderPrice[0].PriceCn costPriceCn := sku.LadderPrice[0].PriceCn
costPriceUs := sku.LadderPrice[0].PriceUs costPriceUs := sku.LadderPrice[0].PriceUs
//fmt.Println("人民币和美金的成本价分别为 : ", costPriceCn, costPriceUs) //fmt.Println("人民币和美金的成本价分别为 : ", costPriceCn, costPriceUs)
...@@ -279,8 +278,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -279,8 +278,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
} }
costLadderCount++ costLadderCount++
} }
fmt.Println("阶梯数量为 : ", costLadderCount) //fmt.Println("阶梯数量为 : ", costLadderCount)
fmt.Println("设置的利润阶梯为 : ", ladderPriceMiniProfitLevel) //fmt.Println("设置的利润阶梯为 : ", ladderPriceMiniProfitLevel)
if costLadderCount <= ladderPriceMiniProfitLevel { if costLadderCount <= ladderPriceMiniProfitLevel {
for i := 0; i < costLadderCount; i++ { for i := 0; i < costLadderCount; i++ {
priceRatioAndPurchases := priceRatioList[i] priceRatioAndPurchases := priceRatioList[i]
...@@ -296,7 +295,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -296,7 +295,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//如:库存满足1、2、3层阶梯,最小利润点层级是第5个层级,则利润点取3、4、5层级的 //如:库存满足1、2、3层阶梯,最小利润点层级是第5个层级,则利润点取3、4、5层级的
//最小利润点层级 - 库存满足多少个阶梯 + i //最小利润点层级 - 库存满足多少个阶梯 + i
costMapIndex := ladderPriceMiniProfitLevel - costLadderCount + i costMapIndex := ladderPriceMiniProfitLevel - costLadderCount + i
fmt.Println(costMapIndex) //fmt.Println(costMapIndex)
if costMapIndex <= 0 { if costMapIndex <= 0 {
costMapIndex = 0 costMapIndex = 0
} }
...@@ -363,7 +362,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -363,7 +362,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
priceCnRatio := priceRatio.Ratio priceCnRatio := priceRatio.Ratio
priceUsRatio := priceRatio.RatioUsd priceUsRatio := priceRatio.RatioUsd
// 阶梯价格系数正序取 // 阶梯价格系数正序取
fmt.Println("价格:",c.MulFloat(ladder.PriceCn, priceCnRatio)) //fmt.Println("价格:",c.MulFloat(ladder.PriceCn, priceCnRatio))
generatedLadderPrice = append(generatedLadderPrice, model.LadderPrice{ generatedLadderPrice = append(generatedLadderPrice, model.LadderPrice{
Purchases: ladder.Purchases, Purchases: ladder.Purchases,
PriceCn: c.MyRound(c.MulFloat(ladder.PriceCn, priceCnRatio), 5), PriceCn: c.MyRound(c.MulFloat(ladder.PriceCn, priceCnRatio), 5),
...@@ -653,13 +652,13 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku, priceUs f ...@@ -653,13 +652,13 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku, priceUs f
} else { } else {
currency, _ = redis.Int(redisCon.Do("HGET", "magic_cube_supplier_currency", sku.Canal)) currency, _ = redis.Int(redisCon.Do("HGET", "magic_cube_supplier_currency", sku.Canal))
} }
fmt.Println("进来的美金价格:", priceUs) //fmt.Println("进来的美金价格:", priceUs)
if currency > 0 { if currency > 0 {
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要 //这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率 //先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
rmbRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", currency)) rmbRatio, _ := redis.Float64(redisCon.Do("HGET", "erp_rate", currency))
fmt.Println("特殊转换", rmbRatio) //fmt.Println("特殊转换", rmbRatio)
fmt.Println(rmbRatio, usRatio) //fmt.Println(rmbRatio, usRatio)
//人民币汇率转美金汇率 //人民币汇率转美金汇率
usRatio = c.MyRound(c.DivFloat(rmbRatio, usRatio), 6) usRatio = c.MyRound(c.DivFloat(rmbRatio, usRatio), 6)
......
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