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
025becc5
authored
Mar 27, 2026
by
hcy
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
d122acd4
43295c13
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
24 deletions
model/goods.go
model/ly_sku.go
service/service_attr.go
service/service_ly.go
service/service_ly_common.go
service/service_price.go
service/service_tags.go
model/goods.go
View file @
025becc5
...
@@ -21,11 +21,12 @@ type LadderPrice struct {
...
@@ -21,11 +21,12 @@ type LadderPrice struct {
}
}
type
OriginPrice
struct
{
type
OriginPrice
struct
{
Purchases
int64
`json:"purchases"`
//购买数量
Purchases
int64
`json:"purchases"`
//购买数量
PriceUs
float64
`json:"price_us"`
//数量对应的英文价格
PriceUs
float64
`json:"price_us"`
//数量对应的英文价格
PriceCn
float64
`json:"price_cn"`
//数量对应的中文价格
PriceCn
float64
`json:"price_cn"`
//数量对应的中文价格
PriceAc
float64
`json:"price_ac,omitempty"`
PriceAc
float64
`json:"price_ac,omitempty"`
CostPrice
float64
`json:"cost_price"`
CostPrice
float64
`json:"cost_price"`
CostPriceUs
float64
`json:"cost_price_us"`
}
}
type
DatabasePrice
struct
{
type
DatabasePrice
struct
{
...
...
model/ly_sku.go
View file @
025becc5
...
@@ -60,16 +60,20 @@ type LySku struct {
...
@@ -60,16 +60,20 @@ type LySku struct {
ClassName
string
`json:"class_name,omitempty"`
ClassName
string
`json:"class_name,omitempty"`
ErpTax
interface
{}
`json:"erp_tax"`
ErpTax
interface
{}
`json:"erp_tax"`
GoodsSn
string
`json:"goods_sn"`
GoodsSn
string
`json:"goods_sn"`
GoodsDetails
string
`json:"goods_details"`
GoodsDetails
string
`json:"goods_details"`
ClassName1
string
`json:"class_name1,omitempty"`
ClassName1
string
`json:"class_name1,omitempty"`
ClassName2
string
`json:"class_name2,omitempty"`
ClassName2
string
`json:"class_name2,omitempty"`
ClassName3
string
`json:"class_name3,omitempty"`
ClassName3
string
`json:"class_name3,omitempty"`
Ratio
float64
`json:"ratio,omitempty"`
Ratio
float64
`json:"ratio,omitempty"`
RatioUs
float64
`json:"ratio_us,omitempty"`
RatioUs
float64
`json:"ratio_us,omitempty"`
SpuDetail
string
`json:"spu_detail,omitempty"`
SpuDetail
string
`json:"spu_detail,omitempty"`
ApplicationLevel
string
`json:"application_level"`
AcType
int
`json:"ac_type"`
HasRohs
string
`json:"has_rohs"`
Series
string
`json:"series"`
Lifecycle
string
`json:"lifecycle"`
Humistor
string
`json:"humistor"`
AcType
int
`json:"ac_type"`
//活动信息
//活动信息
HasGiftActivity
int
`json:"has_gift_activity"`
HasGiftActivity
int
`json:"has_gift_activity"`
GiftActivity
GiftActivity
`json:"gift_activity"`
GiftActivity
GiftActivity
`json:"gift_activity"`
...
@@ -98,7 +102,8 @@ type LySku struct {
...
@@ -98,7 +102,8 @@ type LySku struct {
OnwayStock
int
`json:"onway_stock"`
OnwayStock
int
`json:"onway_stock"`
CompareRatio
float64
`json:"compare_ratio"`
CompareRatio
float64
`json:"compare_ratio"`
//兼容自营下单的字段,取成本价的第一个阶梯的人民币
//兼容自营下单的字段,取成本价的第一个阶梯的人民币
Cost
float64
`json:"cost"`
Cost
float64
`json:"cost"`
CostUs
float64
`json:"cost_us"`
}
}
type
DiscountRatio
struct
{
type
DiscountRatio
struct
{
...
...
service/service_attr.go
View file @
025becc5
...
@@ -34,6 +34,8 @@ func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
...
@@ -34,6 +34,8 @@ func (ls *LyService) GetSpuAttr(spuId string) (attrsResult interface{}) {
data
[
"attr_name"
]
=
value
.
AttrName
data
[
"attr_name"
]
=
value
.
AttrName
//€符号全部替换为逗号
//€符号全部替换为逗号
data
[
"attr_value"
]
=
strings
.
ReplaceAll
(
value
.
AttrValue
,
"€"
,
","
)
data
[
"attr_value"
]
=
strings
.
ReplaceAll
(
value
.
AttrValue
,
"€"
,
","
)
data
[
"attr_value_id"
]
=
value
.
AttrValueId
data
[
"attr_id"
]
=
value
.
AttrId
data
[
"attr_unit"
]
=
value
.
AttrUnit
data
[
"attr_unit"
]
=
value
.
AttrUnit
attrsList
=
append
(
attrsList
,
data
)
attrsList
=
append
(
attrsList
,
data
)
attrsResult
=
attrsList
attrsResult
=
attrsList
...
...
service/service_ly.go
View file @
025becc5
...
@@ -266,8 +266,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
...
@@ -266,8 +266,6 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
sku
=
priceService
.
GetActivityPrice
(
sku
)
sku
=
priceService
.
GetActivityPrice
(
sku
)
}
}
// sku = priceService.GetComparePrice(sku)
sku
=
priceService
.
GetCostForZiying
(
sku
)
sku
=
priceService
.
GetCostForZiying
(
sku
)
//仅提供价格和库存
//仅提供价格和库存
...
@@ -327,6 +325,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
...
@@ -327,6 +325,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
//获取关税以及价格转换
//获取关税以及价格转换
sku
=
ls
.
GetTariffAndPrice
(
sku
)
sku
=
ls
.
GetTariffAndPrice
(
sku
)
sku
=
priceService
.
GetComparePrice
(
sku
)
//获取新的限制库存信息
//获取新的限制库存信息
has
,
limitStock
:=
ls
.
getLimitStock
(
sku
.
GoodsId
)
has
,
limitStock
:=
ls
.
getLimitStock
(
sku
.
GoodsId
)
if
has
{
if
has
{
...
...
service/service_ly_common.go
View file @
025becc5
...
@@ -2,7 +2,6 @@ package service
...
@@ -2,7 +2,6 @@ package service
import
(
import
(
"encoding/json"
"encoding/json"
"github.com/gogf/gf/util/gconv"
"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"
...
@@ -13,6 +12,8 @@ import (
...
@@ -13,6 +12,8 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/gomodule/redigo/redis"
_
"github.com/iancoleman/orderedmap"
_
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/syyongx/php2go"
...
@@ -118,9 +119,11 @@ type SpuAttr struct {
...
@@ -118,9 +119,11 @@ type SpuAttr struct {
}
}
type
AttrsExtend
struct
{
type
AttrsExtend
struct
{
AttrName
string
`bson:"attr_name" json:"attr_name"`
AttrId
int
`bson:"attr_id" json:"attr_id"`
AttrValue
string
`bson:"attr_value" json:"attr_value"`
AttrName
string
`bson:"attr_name" json:"attr_name"`
AttrUnit
string
`bson:"attr_unit" json:"attr_unit,omitempty"`
AttrValue
string
`bson:"attr_value" json:"attr_value"`
AttrValueId
int
`bson:"attr_value_id" json:"attr_value_id"`
AttrUnit
string
`bson:"attr_unit" json:"attr_unit,omitempty"`
}
}
// H获取供应链标准品牌
// H获取供应链标准品牌
...
@@ -249,7 +252,9 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
...
@@ -249,7 +252,9 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
if
len
(
sku
.
LadderPrice
)
==
0
{
if
len
(
sku
.
LadderPrice
)
==
0
{
return
return
}
}
if
sku
.
AbilityLevel
==
0
{
//L0016691 L0015730 L0015835 L0016793 L0016887 L0016886 L0016784
if
sku
.
AbilityLevel
==
0
&&
sku
.
OrgId
==
1
&&
(
sku
.
Canal
!=
"L0015730"
&&
sku
.
Canal
!=
"L0015835"
&&
sku
.
Canal
!=
"L0016691"
&&
sku
.
Canal
!=
"L0016793"
&&
sku
.
Canal
!=
"L0016887"
&&
sku
.
Canal
!=
"L0016886"
&&
sku
.
Canal
!=
"L0016784"
)
{
return
return
}
}
if
sku
.
Stock
==
0
{
if
sku
.
Stock
==
0
{
...
@@ -298,6 +303,11 @@ func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku {
...
@@ -298,6 +303,11 @@ func (ls *LyService) CombineSup(sku model.LySku, spuStr string) model.LySku {
sku
.
Status
=
int
(
gjson
.
Get
(
spuStr
,
"status"
)
.
Int
())
sku
.
Status
=
int
(
gjson
.
Get
(
spuStr
,
"status"
)
.
Int
())
sku
.
Encap
=
gjson
.
Get
(
spuStr
,
"encap"
)
.
String
()
sku
.
Encap
=
gjson
.
Get
(
spuStr
,
"encap"
)
.
String
()
sku
.
SpuEccn
=
gjson
.
Get
(
spuStr
,
"eccn"
)
.
String
()
sku
.
SpuEccn
=
gjson
.
Get
(
spuStr
,
"eccn"
)
.
String
()
sku
.
ApplicationLevel
=
gjson
.
Get
(
spuStr
,
"application_level"
)
.
String
()
sku
.
HasRohs
=
gjson
.
Get
(
spuStr
,
"has_rohs"
)
.
String
()
sku
.
Series
=
gjson
.
Get
(
spuStr
,
"series"
)
.
String
()
sku
.
Lifecycle
=
gjson
.
Get
(
spuStr
,
"lifecycle"
)
.
String
()
sku
.
Humistor
=
gjson
.
Get
(
spuStr
,
"humistor"
)
.
String
()
return
sku
return
sku
}
}
...
@@ -347,6 +357,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -347,6 +357,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
Purchases
:
price
.
Purchases
,
Purchases
:
price
.
Purchases
,
PriceCn
:
priceCnTax
,
PriceCn
:
priceCnTax
,
PriceUs
:
price
.
PriceUs
,
PriceUs
:
price
.
PriceUs
,
CostPrice
:
price
.
CostPrice
,
})
})
}
}
...
...
service/service_price.go
View file @
025becc5
...
@@ -327,6 +327,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
...
@@ -327,6 +327,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
if
costMapIndex
<=
0
{
if
costMapIndex
<=
0
{
costMapIndex
=
0
costMapIndex
=
0
}
}
if
costMapIndex
>=
len
(
priceRatioList
)
{
return
sku
}
priceRatioAndPurchases
=
priceRatioList
[
costMapIndex
]
priceRatioAndPurchases
=
priceRatioList
[
costMapIndex
]
priceCnRatio
:=
priceRatioAndPurchases
.
Ratio
priceCnRatio
:=
priceRatioAndPurchases
.
Ratio
priceUsRatio
:=
priceRatioAndPurchases
.
RatioUsd
priceUsRatio
:=
priceRatioAndPurchases
.
RatioUsd
...
@@ -929,6 +932,7 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
...
@@ -929,6 +932,7 @@ func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
// compare_price_ratio
// compare_price_ratio
func
(
ps
*
PriceService
)
GetComparePrice
(
sku
model
.
LySku
)
model
.
LySku
{
func
(
ps
*
PriceService
)
GetComparePrice
(
sku
model
.
LySku
)
model
.
LySku
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
//判断是否存在
//判断是否存在
compareData
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"compare_price_ratio"
,
sku
.
GoodsId
))
compareData
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"compare_price_ratio"
,
sku
.
GoodsId
))
if
compareData
==
""
{
if
compareData
==
""
{
...
@@ -940,7 +944,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
...
@@ -940,7 +944,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
ladderPrice
:=
sku
.
LadderPrice
ladderPrice
:=
sku
.
LadderPrice
for
index
,
ladder
:=
range
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
)
ladder
.
PriceAc
=
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceAc
,
ratio
),
4
)
}
else
{
}
else
{
ladder
.
PriceCn
=
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceCn
,
ratio
),
4
)
ladder
.
PriceCn
=
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceCn
,
ratio
),
4
)
...
@@ -956,6 +960,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
...
@@ -956,6 +960,7 @@ func (ps *PriceService) GetComparePrice(sku model.LySku) model.LySku {
func
(
ps
*
PriceService
)
GetCostForZiying
(
sku
model
.
LySku
)
model
.
LySku
{
func
(
ps
*
PriceService
)
GetCostForZiying
(
sku
model
.
LySku
)
model
.
LySku
{
if
len
(
sku
.
OriginalPrice
)
!=
0
{
if
len
(
sku
.
OriginalPrice
)
!=
0
{
sku
.
Cost
=
sku
.
OriginalPrice
[
0
]
.
CostPrice
sku
.
Cost
=
sku
.
OriginalPrice
[
0
]
.
CostPrice
sku
.
CostUs
=
sku
.
OriginalPrice
[
0
]
.
PriceUs
}
}
return
sku
return
sku
...
...
service/service_tags.go
View file @
025becc5
...
@@ -77,6 +77,18 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
...
@@ -77,6 +77,18 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
goodsTags
.
GoodsLabelName
=
goodsLabel
goodsTags
.
GoodsLabelName
=
goodsLabel
goodsTags
.
GoodsLabel
=
goodsLabelType
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
()
customerTag
:=
gjson
.
Get
(
goodsTagsStr
,
"customer_tag"
)
.
String
()
if
customerTag
!=
""
{
if
customerTag
!=
""
{
...
...
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