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
3468a49f
authored
Jul 10, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-mrq需求-20230710' into dev
parents
60aa49b9
a4bc9f85
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
9 deletions
go.mod
model/ly_sku.go
service/service_ly_common.go
go.mod
View file @
3468a49f
...
@@ -45,7 +45,6 @@ require (
...
@@ -45,7 +45,6 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
github.com/shopspring/decimal v1.0.1
)
)
...
...
model/ly_sku.go
View file @
3468a49f
...
@@ -6,7 +6,7 @@ import (
...
@@ -6,7 +6,7 @@ import (
"github.com/tidwall/gjson"
"github.com/tidwall/gjson"
)
)
//联营sku结构体
//
联营sku结构体
type
LySku
struct
{
type
LySku
struct
{
LadderPrice
[]
LadderPrice
`json:"-"`
LadderPrice
[]
LadderPrice
`json:"-"`
SpuId
string
`json:"spu_id"`
SpuId
string
`json:"spu_id"`
...
@@ -31,6 +31,7 @@ type LySku struct {
...
@@ -31,6 +31,7 @@ type LySku struct {
Packing
string
`json:"packing"`
Packing
string
`json:"packing"`
GoodsId
string
`json:"goods_id"`
GoodsId
string
`json:"goods_id"`
GoodsName
string
`json:"goods_name"`
GoodsName
string
`json:"goods_name"`
SkuName
string
`json:"sku_name"`
BrandName
string
`json:"brand_name"`
BrandName
string
`json:"brand_name"`
SupplierName
string
`json:"supplier_name"`
SupplierName
string
`json:"supplier_name"`
Attrs
interface
{}
`json:"attrs"`
Attrs
interface
{}
`json:"attrs"`
...
@@ -131,7 +132,7 @@ type StockInfo struct {
...
@@ -131,7 +132,7 @@ type StockInfo struct {
Stock
int
`json:"stock" bson:"stock"`
Stock
int
`json:"stock" bson:"stock"`
}
}
//为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
//
为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
func
InitSkuData
(
sku
string
)
(
data
LySku
)
{
func
InitSkuData
(
sku
string
)
(
data
LySku
)
{
goodsSn
:=
gjson
.
Get
(
sku
,
"goods_sn"
)
.
String
()
goodsSn
:=
gjson
.
Get
(
sku
,
"goods_sn"
)
.
String
()
data
.
GoodsSn
=
goodsSn
data
.
GoodsSn
=
goodsSn
...
@@ -148,15 +149,18 @@ func InitSkuData(sku string) (data LySku) {
...
@@ -148,15 +149,18 @@ func InitSkuData(sku string) (data LySku) {
goodsStatus
:=
gjson
.
Get
(
sku
,
"goods_status"
)
.
Int
()
goodsStatus
:=
gjson
.
Get
(
sku
,
"goods_status"
)
.
Int
()
data
.
GoodsStatus
=
goodsStatus
data
.
GoodsStatus
=
goodsStatus
supplierId
:=
gjson
.
Get
(
sku
,
"supplier_id"
)
.
Int
()
data
.
SupplierId
=
supplierId
goodsName
:=
gjson
.
Get
(
sku
,
"goods_name"
)
.
String
()
goodsName
:=
gjson
.
Get
(
sku
,
"goods_name"
)
.
String
()
data
.
GoodsName
=
goodsName
data
.
GoodsName
=
goodsName
skuName
:=
gjson
.
Get
(
sku
,
"goods_name"
)
.
String
()
data
.
SkuName
=
skuName
goodsType
:=
gjson
.
Get
(
sku
,
"goods_type"
)
.
Int
()
goodsType
:=
gjson
.
Get
(
sku
,
"goods_type"
)
.
Int
()
data
.
GoodsType
=
goodsType
data
.
GoodsType
=
goodsType
supplierId
:=
gjson
.
Get
(
sku
,
"supplier_id"
)
.
Int
()
data
.
SupplierId
=
supplierId
encoded
:=
gjson
.
Get
(
sku
,
"encoded"
)
.
String
()
encoded
:=
gjson
.
Get
(
sku
,
"encoded"
)
.
String
()
data
.
Encoded
=
encoded
data
.
Encoded
=
encoded
...
@@ -226,7 +230,7 @@ func InitSkuData(sku string) (data LySku) {
...
@@ -226,7 +230,7 @@ func InitSkuData(sku string) (data LySku) {
return
return
}
}
//获取联营商品的阶梯价
//
获取联营商品的阶梯价
func
getLadderPrice
(
ladderPriceStr
string
)
(
ladderPrice
[]
LadderPrice
)
{
func
getLadderPrice
(
ladderPriceStr
string
)
(
ladderPrice
[]
LadderPrice
)
{
ladderPriceArr
:=
gjson
.
Parse
(
ladderPriceStr
)
.
Array
()
ladderPriceArr
:=
gjson
.
Parse
(
ladderPriceStr
)
.
Array
()
for
_
,
price
:=
range
ladderPriceArr
{
for
_
,
price
:=
range
ladderPriceArr
{
...
@@ -247,7 +251,7 @@ func getLadderPrice(ladderPriceStr string) (ladderPrice []LadderPrice) {
...
@@ -247,7 +251,7 @@ func getLadderPrice(ladderPriceStr string) (ladderPrice []LadderPrice) {
return
return
}
}
//获取原始价格
//
获取原始价格
func
getOriginPrice
(
ladderPriceStr
string
)
(
ladderPrice
[]
OriginPrice
)
{
func
getOriginPrice
(
ladderPriceStr
string
)
(
ladderPrice
[]
OriginPrice
)
{
ladderPriceArr
:=
gjson
.
Parse
(
ladderPriceStr
)
.
Array
()
ladderPriceArr
:=
gjson
.
Parse
(
ladderPriceStr
)
.
Array
()
for
_
,
price
:=
range
ladderPriceArr
{
for
_
,
price
:=
range
ladderPriceArr
{
...
...
service/service_ly_common.go
View file @
3468a49f
...
@@ -184,7 +184,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
...
@@ -184,7 +184,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
//获取系数
//获取系数
func
(
ls
*
LyService
)
GetCoefficientAndPrice
(
sku
model
.
LySku
)
model
.
LySku
{
func
(
ls
*
LyService
)
GetCoefficientAndPrice
(
sku
model
.
LySku
)
model
.
LySku
{
if
len
(
sku
.
LadderPrice
)
==
0
{
if
len
(
sku
.
LadderPrice
)
==
0
{
sku
.
Original
=
nil
//
sku.Original = nil
return
sku
return
sku
}
}
flag
:=
0
flag
:=
0
...
...
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