Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e5fdc63d
authored
2 weeks ago
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
兼容爱智价格
parent
5ac25511
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
6 deletions
model/ly_sku.go
service/service_custom_price.go
service/service_ly.go
service/service_price.go
model/ly_sku.go
View file @
e5fdc63d
...
...
@@ -86,7 +86,8 @@ type LySku struct {
OriginCurrencySymbol
string
`json:"origin_currency_symbol,omitempty"`
CustomizeRateRMB
float64
CustomizeRateUs
float64
SpuEccn
string
`json:"spu_eccn"`
SpuEccn
string
`json:"spu_eccn"`
CustomPriceList
[]
CustomPrice
`json:"custom_price_list"`
}
type
DiscountRatio
struct
{
...
...
@@ -154,6 +155,11 @@ type SpuExtra struct {
SpuId
string
`bson:"spu_id" json:"spu_id"`
}
type
CustomPrice
struct
{
PriceName
string
`json:"price_name"`
LadderPrice
[]
LadderPrice
`json:"ladder_price"`
}
// 为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
func
InitSkuData
(
sku
string
)
(
data
LySku
)
{
...
...
This diff is collapsed.
Click to expand it.
service/service_custom_price.go
0 → 100644
View file @
e5fdc63d
package
service
import
(
"github.com/gomodule/redigo/redis"
"github.com/tidwall/gjson"
"go_sku_server/model"
c
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
)
type
CustomPrice
struct
{
}
// 加上自定义价格的转换
func
(
sc
*
CustomPrice
)
getCustomPriceList
(
sku
model
.
LySku
)
(
customPriceList
[]
model
.
CustomPrice
,
err
error
)
{
//先根据组织获取对应的自定义价格系数
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
customPriceRule
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"cube_custom_price"
,
sku
.
OrgId
))
customPriceRuleArr
:=
gjson
.
Get
(
customPriceRule
,
"price_list"
)
.
Array
()
//这里是价格规则
for
_
,
customPriceRule
:=
range
customPriceRuleArr
{
//每一个自定义价格都有一个系数,比如会员价利润 10%
ratio
:=
customPriceRule
.
Get
(
"ratio"
)
.
Int
()
priceName
:=
customPriceRule
.
Get
(
"price_name"
)
.
String
()
var
customPrice
model
.
CustomPrice
customPrice
.
PriceName
=
priceName
for
_
,
item
:=
range
sku
.
LadderPrice
{
ratioFloat
:=
c
.
DivFloat
(
float64
(
100
+
ratio
)
,
100
)
customPrice
.
LadderPrice
=
append
(
customPrice
.
LadderPrice
,
model
.
LadderPrice
{
Purchases
:
item
.
Purchases
,
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
item
.
PriceCn
*
ratioFloat
),
2
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
item
.
PriceUs
*
ratioFloat
),
2
),
PriceAc
:
c
.
MyRound
(
c
.
MulFloat
(
item
.
PriceAc
*
ratioFloat
),
2
),
PriceAcUs
:
c
.
MyRound
(
c
.
MulFloat
(
item
.
PriceAcUs
*
ratioFloat
),
2
),
})
}
customPriceList
=
append
(
customPriceList
,
customPrice
)
}
return
customPriceList
,
nil
}
// 单独处理华云的阶梯价
func
(
sc
*
CustomPrice
)
transformIEdgeLadderPrice
(
sku
model
.
LySku
)
(
ladderPriceList
[]
model
.
LadderPrice
)
{
//华云因为它只有一个阶梯,所以生成的阶梯价只有2个阶梯,为了兼容以前的数据格式
/*
{
"purchases": 1,
"price_us": 0,
"price_cn": 293.13,
"price_name": "标准价"
},
{
"purchases": 2,
"price_us": 0,
"price_cn": 190.59,
"price_name": "企业价"
}
]
*/
if
len
(
sku
.
CustomPriceList
)
!=
0
{
for
_
,
customPrice
:=
range
sku
.
CustomPriceList
{
//只取第一个元素价格就行
ladderPrice
:=
customPrice
.
LadderPrice
[
0
]
ladderPrice
.
PriceName
=
customPrice
.
PriceName
ladderPriceList
=
append
(
ladderPriceList
,
ladderPrice
)
}
}
return
ladderPriceList
}
This diff is collapsed.
Click to expand it.
service/service_ly.go
View file @
e5fdc63d
...
...
@@ -182,12 +182,19 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
if
sku
.
OrgId
==
3
&&
len
(
sku
.
LadderPrice
)
==
2
{
priceService
:=
PriceService
{}
sku
.
LadderPrice
=
priceService
.
GetIEdgePrice
(
sku
.
LadderPrice
)
}
else
{
}
else
{
//这里猎芯和华云都是走同一套的价格体系了
//获取系数和价格
sku
=
ls
.
GetCoefficientAndPrice
(
sku
)
}
//获取自定义价格后的阶梯价
customPriceService
:=
CustomPrice
{}
sku
.
CustomPriceList
,
_
=
customPriceService
.
getCustomPriceList
(
sku
)
//这里还要针对华云的阶梯价进行一次转换,因为要兼容目前华云的试用方式
if
sku
.
OrgId
==
3
{
sku
.
LadderPrice
=
customPriceService
.
transformIEdgeLadderPrice
(
sku
)
}
}
}
break
default
:
...
...
This diff is collapsed.
Click to expand it.
service/service_price.go
View file @
e5fdc63d
...
...
@@ -205,7 +205,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
costPriceCn
:=
sku
.
LadderPrice
[
0
]
.
PriceCn
costPriceUs
:=
sku
.
LadderPrice
[
0
]
.
PriceUs
//fmt.Println("人民币和美金的成本价分别为 : ", costPriceCn, costPriceUs)
//先去判断起订量,如果起订量小于50,就要走固定配置的阶梯系数
//先去判断起订量,如果起订量小于50,就要走固定配置的阶梯系数
(这里是猎芯的逻辑)
if
sku
.
Moq
<=
50
&&
sku
.
OrgId
==
1
{
moq
:=
int
(
sku
.
Moq
)
fixedRatio
:=
make
(
map
[
int
]
float64
)
...
...
@@ -311,7 +311,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
costMapIndex
=
0
}
priceRatioAndPurchases
=
priceRatioList
[
costMapIndex
]
//fmt.Println("获取到的阶梯系数为 : ", priceRatioAndPurchases)
priceCnRatio
:=
priceRatioAndPurchases
.
Ratio
priceUsRatio
:=
priceRatioAndPurchases
.
RatioUsd
// 阶梯价格系数正序取
...
...
@@ -427,7 +426,12 @@ func (ps *PriceService) GetDiscountRatio(sku model.LySku) model.LySku {
if
sku
.
SupplierId
==
17
{
discountRatioRedisKey
=
"magic_cube_channel_discount_zhuanying"
discountRatioDefaultRedisKey
=
"magic_cube_channel_discount_default_zhuanying"
supplierKey
=
sku
.
Canal
//这里还要判断是否是华云,如果是华云的话,key的格式应该是 L0012323_3
if
sku
.
OrgId
==
1
{
supplierKey
=
sku
.
Canal
}
else
{
supplierKey
=
sku
.
Canal
+
"-_"
+
gconv
.
String
(
sku
.
OrgId
)
}
}
//先去读取成本折扣系数
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment