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
0618a067
authored
Jun 13, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-专营商品构建阶梯价-20230612' into dev
parents
57b0382c
bffa45a8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
25 deletions
conf/dev/redis.ini
model/ly_sku.go
service/service_ly.go
service/service_ly_common.go
service/service_price.go
service/service_tags.go
conf/dev/redis.ini
View file @
0618a067
;redis连接信息
[default_redis_read]
host
=
192.168.1.234
:6379
host
=
redis.liexindev.me
:6379
password
=
icDb29mLy2s
max_idle
=
2000
max_active
=
5000
idle_timeout
=
20
[default_redis_write]
host
=
192.168.1.234
:6379
host
=
redis.liexindev.me
:6379
password
=
icDb29mLy2s
max_idle
=
2000
max_active
=
5000
...
...
model/ly_sku.go
View file @
0618a067
...
...
@@ -180,6 +180,10 @@ func InitSkuData(sku string) (data LySku) {
data
.
Multiple
=
mpq
}
}
//todo 2023.5.6 如果是rochester ,递增量为1
if
supplierId
==
3
{
data
.
Multiple
=
1
}
stock
:=
gjson
.
Get
(
sku
,
"stock"
)
.
Int
()
data
.
Stock
=
stock
...
...
service/service_ly.go
View file @
0618a067
...
...
@@ -52,7 +52,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
GoodsRes
.
Store
(
goodsId
,
false
)
continue
}
//初始化有序map,拼接data
数据
//初始化有序map,拼接data
数据,就是从redis取出初始
数据
sku
:=
model
.
InitSkuData
(
skuStr
)
sku
.
GoodsId
=
goodsId
spu
:=
spuList
[
sku
.
SpuId
]
...
...
@@ -65,7 +65,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
//pdf
pdf
:=
gjson
.
Get
(
spu
,
"pdf"
)
.
String
()
// spuLargeImage := gjson.Get(spu, "images_l").String()
if
pdf
!=
""
{
pdf
=
strings
.
Replace
(
pdf
,
"http://img.ichunt.com"
,
"https://img.ichunt.com"
,
1
)
//还要针对如果是自己的上传服务的pdf文件,还要补上类型用于预览
...
...
@@ -75,12 +74,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
Pdf
=
pdf
}
//处理分类
//fast的参数含义,为了节省开销性能的参数,传1就不会去分类这些参数
if
fast
!=
"1"
{
sku
=
ls
.
GetGoodsClass
(
sku
,
spu
)
}
//获取商品名称
if
sku
.
GoodsName
==
""
{
sku
.
GoodsName
=
gjson
.
Get
(
spu
,
"spu_name"
)
.
String
()
...
...
@@ -90,8 +83,11 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
brandId
:=
gjson
.
Get
(
spu
,
"brand_id"
)
.
Int
()
brandName
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"brand"
,
brandId
))
sku
.
BrandName
=
brandName
//获取税务信息
if
fast
!=
"1"
{
//仅提供价格和库存
//判断是否要取精简信息
if
fast
!=
"1"
{
sku
=
ls
.
GetGoodsClass
(
sku
,
spu
)
//仅提供价格和库存
if
sku
.
GoodsName
!=
""
&&
brandId
!=
0
{
sku
.
ErpTax
=
ls
.
GetErpTax
(
sku
.
GoodsName
,
brandName
)
}
...
...
@@ -105,6 +101,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
}
//获取在途库存信息
if
showStockInfo
==
"1"
&&
sku
.
OldGoodsId
!=
0
{
sku
.
StockInfo
=
ls
.
getStockInfo
(
sku
.
SupplierId
,
sku
.
OldGoodsId
)
}
...
...
@@ -136,7 +133,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//这里获取活动价格和活动类型
sku
=
ls
.
GetActivity
(
sku
)
//
处理阶梯价数据
//
最小起订量要大于阶梯价的最小阶梯数量
if
len
(
sku
.
LadderPrice
)
>
0
{
//排序
sort
.
Sort
(
sorter
.
LadderPriceSorter
(
sku
.
LadderPrice
))
...
...
@@ -146,6 +143,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
Moq
=
purchases
}
}
//获取系数
sku
=
ls
.
GetCoefficientAndPrice
(
sku
)
...
...
@@ -156,12 +154,13 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
//还要处理货期
delivery
:=
ls
.
GetDelivery
(
sku
.
SupplierId
,
sku
.
Canal
)
if
delivery
[
"cn_delivery"
]
!
=
""
{
if
sku
.
CnDeliveryTime
=
=
""
{
sku
.
CnDeliveryTime
=
delivery
[
"cn_delivery"
]
}
if
delivery
[
"hk_delivery"
]
!
=
""
{
if
sku
.
HkDeliveryTime
=
=
""
{
sku
.
HkDeliveryTime
=
delivery
[
"hk_delivery"
]
}
}
//处理是否可以购买
...
...
@@ -175,11 +174,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
LadderPriceResult
=
[]
int
{}
}
//这边有个临时逻辑,如果供应商id是TI的,就库存为0
// if sku.SupplierId == 1679 {
// sku.Stock = 0
// }
//判断是否可以购买
sku
.
IsBuy
=
ls
.
GetIsBuy
(
sku
)
sku
.
IsBuy
=
1
...
...
@@ -188,6 +182,16 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
// sku.Stock = 0
}
//特殊判断,如果是罗侧斯特的ADI的商品,价格为0,库存为0
if
sku
.
StandardBrand
.
StandardBrandId
==
8
&&
sku
.
SupplierId
==
3
{
sku
.
Stock
=
0
sku
.
LadderPriceResult
=
[]
int
{}
sku
.
IsBuy
=
0
sku
.
BatchSn
=
""
sku
.
Attrs
=
[]
int
{}
}
//获取标签信息
var
TagService
TagsService
sku
.
GoodsTag
=
TagService
.
GetTags
(
sku
.
GoodsId
,
0
)
...
...
service/service_ly_common.go
View file @
0618a067
...
...
@@ -2,6 +2,7 @@ package service
import
(
"encoding/json"
"fmt"
"go_sku_server/model"
c
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
...
...
@@ -187,11 +188,23 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return
sku
}
flag
:=
0
data
:=
make
([]
model
.
LadderPrice
,
len
(
sku
.
LadderPrice
))
var
data
[]
model
.
LadderPrice
var
originalPrice
[]
model
.
OriginPrice
//专卖
//专卖
价格获取
if
sku
.
SupplierId
==
17
{
ladderPrice
:=
sku
.
LadderPrice
//判断redis里面是否有成本价,有的话,那就直接去取价格,不需要生成阶梯价
//如果没有成本价字段,就要去生成阶梯价格
if
len
(
ladderPrice
)
>
0
{
if
ladderPrice
[
0
]
.
PriceCostUs
==
0
&&
ladderPrice
[
0
]
.
PriceCostCn
==
0
{
var
priceService
PriceService
ladderPrice
=
priceService
.
GenerateLadderPrice
(
sku
)
sku
.
Original
=
ladderPrice
}
else
{
fmt
.
Println
(
"不走成本价生成"
)
}
}
data
=
make
([]
model
.
LadderPrice
,
len
(
ladderPrice
))
for
key
,
price
:=
range
ladderPrice
{
if
price
.
Purchases
==
0
{
continue
...
...
@@ -203,15 +216,16 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
price
.
PriceCn
!=
0
{
data
[
key
]
.
PriceCn
=
c
.
MyRound
(
price
.
PriceCn
,
4
)
}
//todo 2023.4.6 专卖成本价
//专卖成本价
data
[
key
]
.
PriceCostUs
=
price
.
PriceCostUs
data
[
key
]
.
PriceCostCn
=
price
.
PriceCostCn
//联营或者专卖 同时 存在活动价格
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
]
.
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,就代表没有搞活动
if
tempAcPrice
<=
0
{
...
...
@@ -227,6 +241,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
}
else
{
data
=
make
([]
model
.
LadderPrice
,
len
(
sku
.
LadderPrice
))
//去获取各种系数(成本折扣系数,售价组系数,供应商系数)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
...
...
service/service_price.go
View file @
0618a067
This diff is collapsed.
Click to expand it.
service/service_tags.go
View file @
0618a067
...
...
@@ -54,6 +54,9 @@ func (ts *TagsService) GetTags(skuId string, self_supplier_type int64) (goodsTag
if
!
php2go
.
InArray
(
TagZiyingSku
,
tags
)
{
tags
=
append
(
tags
,
TagZiyingSku
)
tagNames
=
append
(
tagNames
,
vars
.
GoodsTags
[
TagZiyingSku
])
goodsTags
.
GoodsLabel
=
TagZiyingSku
goodsTags
.
GoodsLabelName
=
vars
.
GoodsTags
[
TagZiyingSku
]
}
}
goodsTags
.
GoodsTagNames
=
tagNames
...
...
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