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
0f6e18b7
authored
May 15, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' into dev
parents
221d7cf6
9e449996
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
8 deletions
doc/price_generation_logic.md
model/ly_sku.go
service/service_ly.go
service/service_price.go
service/service_tags.go
service/service_zy.go
service/service_zy_common.go
doc/price_generation_logic.md
0 → 100644
View file @
0f6e18b7
This diff is collapsed.
Click to expand it.
model/ly_sku.go
View file @
0f6e18b7
...
...
@@ -102,8 +102,9 @@ type LySku struct {
OnwayStock
int
`json:"onway_stock"`
CompareRatio
float64
`json:"compare_ratio"`
//兼容自营下单的字段,取成本价的第一个阶梯的人民币
Cost
float64
`json:"cost"`
CostUs
float64
`json:"cost_us"`
Cost
float64
`json:"cost"`
CostUs
float64
`json:"cost_us"`
IsZiying
int
`json:"is_ziying"`
}
type
DiscountRatio
struct
{
...
...
@@ -287,6 +288,12 @@ func InitSkuData(sku string) (data LySku) {
data
.
Encoded
=
"10142-L"
}
//判断是否自营
data
.
IsZiying
=
0
if
supplierId
==
17
&&
(
data
.
Canal
==
"L0018319"
||
data
.
Canal
==
"L0018562"
||
data
.
Canal
==
"L0003270"
)
{
data
.
IsZiying
=
1
}
cpTime
:=
gjson
.
Get
(
sku
,
"cp_time"
)
.
Int
()
data
.
CpTime
=
cpTime
...
...
service/service_ly.go
View file @
0f6e18b7
...
...
@@ -266,8 +266,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
sku
=
priceService
.
GetActivityPrice
(
sku
)
}
// sku = priceService.GetComparePrice(sku)
sku
=
priceService
.
GetCostForZiying
(
sku
)
//仅提供价格和库存
...
...
@@ -327,6 +325,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
//获取关税以及价格转换
sku
=
ls
.
GetTariffAndPrice
(
sku
)
sku
=
priceService
.
GetComparePrice
(
sku
)
//获取新的限制库存信息
has
,
limitStock
:=
ls
.
getLimitStock
(
sku
.
GoodsId
)
if
has
{
...
...
service/service_price.go
View file @
0f6e18b7
...
...
@@ -932,6 +932,7 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
// compare_price_ratio
func
(
ps
*
PriceService
)
GetComparePrice
(
sku
model
.
LySku
)
model
.
LySku
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
//判断是否存在
compareData
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"compare_price_ratio"
,
sku
.
GoodsId
))
if
compareData
==
""
{
...
...
@@ -943,7 +944,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
ladderPrice
:=
sku
.
LadderPrice
for
index
,
ladder
:=
range
ladderPrice
{
if
priceLimitOn
==
2
&&
ladder
.
PriceAc
!=
0
{
if
priceLimitOn
==
1
&&
ladder
.
PriceAc
!=
0
{
ladder
.
PriceAc
=
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceAc
,
ratio
),
4
)
}
else
{
ladder
.
PriceCn
=
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceCn
,
ratio
),
4
)
...
...
service/service_tags.go
View file @
0f6e18b7
...
...
@@ -77,6 +77,18 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
goodsTags
.
GoodsLabelName
=
goodsLabel
goodsTags
.
GoodsLabel
=
goodsLabelType
//系统打的标签
systemTagArr
:=
gjson
.
Get
(
goodsTagsStr
,
"tags"
)
.
Array
()
if
len
(
systemTagArr
)
>
0
{
for
_
,
tagIdResult
:=
range
systemTagArr
{
tagId
:=
int
(
tagIdResult
.
Int
())
tags
=
append
(
tags
,
tagId
)
if
tagName
,
ok
:=
vars
.
GoodsTags
[
tagId
];
ok
{
tagNames
=
append
(
tagNames
,
tagName
)
}
}
}
//自定义标签
customerTag
:=
gjson
.
Get
(
goodsTagsStr
,
"customer_tag"
)
.
String
()
if
customerTag
!=
""
{
...
...
service/service_zy.go
View file @
0f6e18b7
...
...
@@ -185,8 +185,8 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams
A
.
Set
(
"stock"
,
0
)
//默认库存为0
dbStock
:=
gjson
.
Get
(
info
,
"stock"
)
.
Int
()
//当前db库存
if
dbStock
>
0
{
lockStock
:=
qs
.
skuLockNum
(
&
redisConn
,
goodsId
)
//当前锁库库存
stockG
:=
dbStock
-
lockStock
//当前可购买库存
lockStock
:=
SkuLockNum
(
goodsId
)
//当前锁库库存
stockG
:=
dbStock
-
lockStock
//当前可购买库存
if
stockG
>
0
{
A
.
Set
(
"actual_stock"
,
dbStock
)
//锁定库存
A
.
Set
(
"stock"
,
stockG
)
...
...
@@ -367,6 +367,8 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx context.Context, params RequestParams
Stock
:
gconv
.
Int64
(
nowstock
),
AbilityLevel
:
2
,
StandardBrand
:
standardBrand
,
Moq
:
moq
,
Mpq
:
mpq
,
GoodsName
:
gjson
.
Get
(
info
,
"goods_name"
)
.
String
(),
SpuId
:
gconv
.
String
(
spuId
),
ClassID1
:
gconv
.
Int
(
spuClassId1
),
...
...
service/service_zy_common.go
View file @
0f6e18b7
...
...
@@ -4,6 +4,7 @@ import (
"go_sku_server/model"
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
"strconv"
"github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap"
...
...
@@ -12,8 +13,21 @@ import (
)
//自营公共函数类
/*
获取自营锁库数量
*/
func
SkuLockNum
(
goodsId
string
)
int64
{
//获取总锁库库存
redisCon
:=
gredis
.
Conn
(
"spu"
)
defer
redisCon
.
Close
()
stockStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"sku_lock_stock"
,
goodsId
))
lockStock
,
_
:=
strconv
.
ParseInt
(
stockStr
,
10
,
64
)
return
lockStock
}
/*
计算单个sku总锁库数量
计算单个sku总锁库数量-废弃
*/
func
(
qs
*
ZiyingService
)
skuLockNum
(
c
*
redis
.
Conn
,
goodsId
string
)
int64
{
reply
,
err
:=
redis
.
Values
((
*
c
)
.
Do
(
"hvals"
,
"Self_StockLock"
+
goodsId
))
...
...
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