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
4853474c
authored
Mar 06, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
兼容华云价格体系
parent
b5e3a6f4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
25 deletions
model/goods.go
model/ly_sku.go
service/service_ly.go
service/service_ly_common.go
service/service_price.go
model/goods.go
View file @
4853474c
...
...
@@ -9,14 +9,15 @@ 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,omitempty"`
//活动价美金
Purchases
int64
`json:"purchases"`
//购买数量
PriceUs
float64
`json:"price_us,omitempty"`
//数量对应的英文价格
PriceCn
float64
`json:"price_cn"`
//数量对应的中文价格
PriceCostUs
float64
`json:"price_cost_us
,omitempty"`
//成本价美金
PriceCostCn
float64
`json:"price_cost_cn
,omitempty"`
//成本价人民币
PriceAc
float64
`json:"price_ac,omitempty"`
//活动价人民币
PriceAcUs
float64
`json:"price_ac_us,omitempty"`
//活动价美金
CostPrice
float64
`json:"-"`
PriceName
string
`json:"price_name,omitempty"`
}
type
OriginPrice
struct
{
...
...
model/ly_sku.go
View file @
4853474c
...
...
@@ -45,6 +45,7 @@ type LySku struct {
DatabasePrice
interface
{}
`json:"database_price,omitempty"`
SuppExtendFee
interface
{}
`json:"supp_extend_fee"`
IsBuy
int
`json:"is_buy"`
OrgId
int
`json:"org_id"`
//spu信息
ClassID1
int
`json:"class_id1"`
ClassID2
int
`json:"class_id2"`
...
...
@@ -197,7 +198,8 @@ func InitSkuData(sku string) (data LySku) {
data
.
Multiple
=
mpq
}
}
//todo 2023.5.6 如果是rochester ,递增量为1
//2023.5.6 如果是rochester ,递增量为1
if
supplierId
==
3
{
data
.
Multiple
=
1
}
...
...
@@ -228,6 +230,14 @@ func InitSkuData(sku string) (data LySku) {
canal
:=
gjson
.
Get
(
sku
,
"canal"
)
.
String
()
data
.
Canal
=
canal
//组织id,默认都是猎芯,因为没有默认存到redis,所以默认是1
orgId
:=
gjson
.
Get
(
sku
,
"org_id"
)
.
Int
()
if
orgId
!=
0
{
data
.
OrgId
=
int
(
orgId
)
}
else
{
data
.
OrgId
=
1
}
//加上紧急判断,如果是立创(L0001175)的商品,就修改内部编码
if
data
.
Canal
==
"L0001175"
{
data
.
Encoded
=
"10142-L"
...
...
service/service_ly.go
View file @
4853474c
...
...
@@ -36,11 +36,13 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
redisConn
.
Close
()
redisConnSpu
.
Close
()
}()
fast
:=
ctx
.
Request
.
FormValue
(
"power[fast]"
)
//是否展示属性
showAttr
:=
ctx
.
Request
.
FormValue
(
"show_attr"
)
//是否展示在途库存
showStockInfo
:=
ctx
.
Request
.
FormValue
(
"show_stock_info"
)
//批量获取商品详情
skuArr
:=
gredis
.
Hmget
(
"default_r"
,
"sku"
,
goodsIds
)
//为了性能着想,这边也先去批量获取spu的信息
...
...
@@ -66,8 +68,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
sku
=
ls
.
GetPdf
(
sku
,
spu
)
//
todo
2023.11.20 DGK商品的包装若为“Tape & Reel (TR)”,则递增量=起订量
if
sku
.
SupplierId
==
7
&&
sku
.
Packing
==
"Tape & Reel (TR)"
{
// 2023.11.20 DGK商品的包装若为“Tape & Reel (TR)”,则递增量=起订量
if
sku
.
SupplierId
==
7
&&
sku
.
Packing
==
"Tape & Reel (TR)"
{
sku
.
Multiple
=
sku
.
Moq
}
...
...
@@ -121,7 +123,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//获取新版的标准品牌
sku
.
StandardBrand
=
ls
.
GetStandardBrand
(
brandId
)
//处理过期,
todo
2022.7.13 专卖没有过期
//处理过期, 2022.7.13 专卖没有过期
if
sku
.
SupplierId
!=
17
&&
gjson
.
Get
(
skuStr
,
"is_expire"
)
.
Int
()
!=
0
{
sku
.
LadderPrice
=
nil
}
...
...
@@ -145,8 +147,18 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
}
//获取系数
sku
=
ls
.
GetCoefficientAndPrice
(
sku
)
//这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断,如果是爱智,不需要走价格体系
//1是猎芯,3是爱智
switch
sku
.
OrgId
{
case
1
:
//获取系数和价格
sku
=
ls
.
GetCoefficientAndPrice
(
sku
)
break
case
3
:
priceService
:=
PriceService
{}
sku
.
LadderPrice
=
priceService
.
GetIEdgePrice
(
sku
.
LadderPrice
)
break
}
//仅提供价格和库存
if
fast
!=
"1"
{
...
...
service/service_ly_common.go
View file @
4853474c
...
...
@@ -497,16 +497,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//活动价都是有样式的和平时不一样,如果价格一样,但是样子是活动价,客户会迷惑,所以不输出即可,保持原来的样式
if
data
[
key
]
.
PriceCn
==
priceAc
&&
key
<
2
{
flag
++
//if flag >= 2 {
// sku.AcType = 0
// continue
//}
//if len(data) > 1 {
// if data[1].PriceCn == 0 {
// sku.AcType = 0
// continue
// }
//}
}
data
[
key
]
.
PriceAc
=
priceAc
...
...
@@ -541,7 +531,5 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku
.
LadderPrice
=
data
}
//fmt.Println(sku.PriceRatio, sku.PriceRatioSort)
return
sku
}
service/service_price.go
View file @
4853474c
...
...
@@ -716,3 +716,16 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
sku
.
OriginCurrencySymbol
=
symbol
return
sku
}
// 处理爱智的价格,目前爱智是有个价格名称的东西
func
(
ps
*
PriceService
)
GetIEdgePrice
(
ladderPrice
[]
model
.
LadderPrice
)
[]
model
.
LadderPrice
{
//目前的价格名称是硬编码到代码里面
priceNameMap
:=
map
[
int64
]
string
{
1
:
"标准价"
,
2
:
"企业价"
,
}
for
index
,
price
:=
range
ladderPrice
{
ladderPrice
[
index
]
.
PriceName
=
priceNameMap
[
price
.
Purchases
]
}
return
ladderPrice
}
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