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
a03eba7e
authored
Jun 12, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
专营商品成本价构建逻辑
parent
9500c3c1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
service/service_ly.go
service/service_ly_common.go
service/service_price.go
service/service_ly.go
View file @
a03eba7e
...
@@ -52,7 +52,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -52,7 +52,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
GoodsRes
.
Store
(
goodsId
,
false
)
GoodsRes
.
Store
(
goodsId
,
false
)
continue
continue
}
}
//初始化有序map,拼接data
数据
//初始化有序map,拼接data
数据,就是从redis取出初始
数据
sku
:=
model
.
InitSkuData
(
skuStr
)
sku
:=
model
.
InitSkuData
(
skuStr
)
sku
.
GoodsId
=
goodsId
sku
.
GoodsId
=
goodsId
spu
:=
spuList
[
sku
.
SpuId
]
spu
:=
spuList
[
sku
.
SpuId
]
...
@@ -65,7 +65,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -65,7 +65,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
//pdf
//pdf
pdf
:=
gjson
.
Get
(
spu
,
"pdf"
)
.
String
()
pdf
:=
gjson
.
Get
(
spu
,
"pdf"
)
.
String
()
// spuLargeImage := gjson.Get(spu, "images_l").String()
if
pdf
!=
""
{
if
pdf
!=
""
{
pdf
=
strings
.
Replace
(
pdf
,
"http://img.ichunt.com"
,
"https://img.ichunt.com"
,
1
)
pdf
=
strings
.
Replace
(
pdf
,
"http://img.ichunt.com"
,
"https://img.ichunt.com"
,
1
)
//还要针对如果是自己的上传服务的pdf文件,还要补上类型用于预览
//还要针对如果是自己的上传服务的pdf文件,还要补上类型用于预览
...
@@ -75,12 +74,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -75,12 +74,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
Pdf
=
pdf
sku
.
Pdf
=
pdf
}
}
//处理分类
//fast的参数含义,为了节省开销性能的参数,传1就不会去分类这些参数
if
fast
!=
"1"
{
sku
=
ls
.
GetGoodsClass
(
sku
,
spu
)
}
//获取商品名称
//获取商品名称
if
sku
.
GoodsName
==
""
{
if
sku
.
GoodsName
==
""
{
sku
.
GoodsName
=
gjson
.
Get
(
spu
,
"spu_name"
)
.
String
()
sku
.
GoodsName
=
gjson
.
Get
(
spu
,
"spu_name"
)
.
String
()
...
@@ -90,8 +83,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -90,8 +83,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
brandId
:=
gjson
.
Get
(
spu
,
"brand_id"
)
.
Int
()
brandId
:=
gjson
.
Get
(
spu
,
"brand_id"
)
.
Int
()
brandName
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"brand"
,
brandId
))
brandName
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"brand"
,
brandId
))
sku
.
BrandName
=
brandName
sku
.
BrandName
=
brandName
//获取税务信息
if
fast
!=
"1"
{
//仅提供价格和库存
//判断是否要取精简信息
if
fast
!=
"1"
{
sku
=
ls
.
GetGoodsClass
(
sku
,
spu
)
//仅提供价格和库存
if
sku
.
GoodsName
!=
""
&&
brandId
!=
0
{
if
sku
.
GoodsName
!=
""
&&
brandId
!=
0
{
sku
.
ErpTax
=
ls
.
GetErpTax
(
sku
.
GoodsName
,
brandName
)
sku
.
ErpTax
=
ls
.
GetErpTax
(
sku
.
GoodsName
,
brandName
)
}
}
...
@@ -105,6 +101,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -105,6 +101,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
}
}
}
//获取在途库存信息
if
showStockInfo
==
"1"
&&
sku
.
OldGoodsId
!=
0
{
if
showStockInfo
==
"1"
&&
sku
.
OldGoodsId
!=
0
{
sku
.
StockInfo
=
ls
.
getStockInfo
(
sku
.
SupplierId
,
sku
.
OldGoodsId
)
sku
.
StockInfo
=
ls
.
getStockInfo
(
sku
.
SupplierId
,
sku
.
OldGoodsId
)
}
}
...
@@ -136,7 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -136,7 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//这里获取活动价格和活动类型
//这里获取活动价格和活动类型
sku
=
ls
.
GetActivity
(
sku
)
sku
=
ls
.
GetActivity
(
sku
)
//
处理阶梯价数据
//
最小起订量要大于阶梯价的最小阶梯数量
if
len
(
sku
.
LadderPrice
)
>
0
{
if
len
(
sku
.
LadderPrice
)
>
0
{
//排序
//排序
sort
.
Sort
(
sorter
.
LadderPriceSorter
(
sku
.
LadderPrice
))
sort
.
Sort
(
sorter
.
LadderPriceSorter
(
sku
.
LadderPrice
))
...
@@ -146,6 +143,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -146,6 +143,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
Moq
=
purchases
sku
.
Moq
=
purchases
}
}
}
}
//获取系数
//获取系数
sku
=
ls
.
GetCoefficientAndPrice
(
sku
)
sku
=
ls
.
GetCoefficientAndPrice
(
sku
)
...
@@ -176,11 +174,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -176,11 +174,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
LadderPriceResult
=
[]
int
{}
sku
.
LadderPriceResult
=
[]
int
{}
}
}
//这边有个临时逻辑,如果供应商id是TI的,就库存为0
// if sku.SupplierId == 1679 {
// sku.Stock = 0
// }
//判断是否可以购买
//判断是否可以购买
sku
.
IsBuy
=
ls
.
GetIsBuy
(
sku
)
sku
.
IsBuy
=
ls
.
GetIsBuy
(
sku
)
...
@@ -198,6 +191,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
...
@@ -198,6 +191,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
Attrs
=
[]
int
{}
sku
.
Attrs
=
[]
int
{}
}
}
//获取标签信息
var
TagService
TagsService
var
TagService
TagsService
sku
.
GoodsTag
=
TagService
.
GetTags
(
sku
.
GoodsId
,
0
)
sku
.
GoodsTag
=
TagService
.
GetTags
(
sku
.
GoodsId
,
0
)
...
...
service/service_ly_common.go
View file @
a03eba7e
...
@@ -2,6 +2,7 @@ package service
...
@@ -2,6 +2,7 @@ package service
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"go_sku_server/model"
"go_sku_server/model"
c
"go_sku_server/pkg/common"
c
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/gredis"
...
@@ -187,11 +188,22 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -187,11 +188,22 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return
sku
return
sku
}
}
flag
:=
0
flag
:=
0
data
:=
make
([]
model
.
LadderPrice
,
len
(
sku
.
LadderPrice
))
var
data
[]
model
.
LadderPrice
var
originalPrice
[]
model
.
OriginPrice
var
originalPrice
[]
model
.
OriginPrice
//专卖
//专卖
价格获取
if
sku
.
SupplierId
==
17
{
if
sku
.
SupplierId
==
17
{
ladderPrice
:=
sku
.
LadderPrice
ladderPrice
:=
sku
.
LadderPrice
//判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价
//如果没有成本价字段,就要去生成阶梯价格
if
len
(
ladderPrice
)
>
0
{
if
ladderPrice
[
0
]
.
PriceCostUs
==
0
&&
ladderPrice
[
0
]
.
PriceCostCn
==
0
{
var
priceService
PriceService
ladderPrice
=
priceService
.
GenerateLadderPrice
(
sku
)
}
else
{
fmt
.
Println
(
"不走成本价生成"
)
}
}
data
=
make
([]
model
.
LadderPrice
,
len
(
ladderPrice
))
for
key
,
price
:=
range
ladderPrice
{
for
key
,
price
:=
range
ladderPrice
{
if
price
.
Purchases
==
0
{
if
price
.
Purchases
==
0
{
continue
continue
...
@@ -203,15 +215,16 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -203,15 +215,16 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
price
.
PriceCn
!=
0
{
if
price
.
PriceCn
!=
0
{
data
[
key
]
.
PriceCn
=
c
.
MyRound
(
price
.
PriceCn
,
4
)
data
[
key
]
.
PriceCn
=
c
.
MyRound
(
price
.
PriceCn
,
4
)
}
}
//todo 2023.4.6 专卖成本价
//专卖成本价
data
[
key
]
.
PriceCostUs
=
price
.
PriceCostUs
data
[
key
]
.
PriceCostUs
=
price
.
PriceCostUs
data
[
key
]
.
PriceCostCn
=
price
.
PriceCostCn
data
[
key
]
.
PriceCostCn
=
price
.
PriceCostCn
//联营或者专卖 同时 存在活动价格
//联营或者专卖 同时 存在活动价格
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
tempAcPrice
:=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceCn
,
(
sku
.
Ratio
/
100
)
),
4
)
tempAcPrice
:=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceCn
,
sku
.
Ratio
/
100
),
4
)
data
[
key
]
.
PriceAc
=
tempAcPrice
data
[
key
]
.
PriceAc
=
tempAcPrice
data
[
key
]
.
PriceAcUs
=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceUs
,
(
sku
.
RatioUs
/
100
)
),
4
)
data
[
key
]
.
PriceAcUs
=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceUs
,
sku
.
RatioUs
/
100
),
4
)
//优惠价后等于0,就代表没有搞活动
//优惠价后等于0,就代表没有搞活动
if
tempAcPrice
<=
0
{
if
tempAcPrice
<=
0
{
...
@@ -227,6 +240,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -227,6 +240,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
}
}
}
else
{
}
else
{
data
=
make
([]
model
.
LadderPrice
,
len
(
sku
.
LadderPrice
))
//去获取各种系数(成本折扣系数,售价组系数,供应商系数)
//去获取各种系数(成本折扣系数,售价组系数,供应商系数)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
...
...
service/service_price.go
View file @
a03eba7e
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