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
adb8b41f
authored
Apr 07, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
ssh://git.ichunt.net:22611/q578953158/go_sku_server
parents
5bab8b4d
b4b87eda
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
289 deletions
doc/test3/gjson.go
model/ly_sku.go
service/service_zy.go
doc/test3/gjson.go
deleted
100644 → 0
View file @
5bab8b4d
package
main
import
(
"fmt"
"github.com/gogf/gf/util/gconv"
"github.com/tidwall/gjson"
"go_sku_server/pkg/common"
)
func
main
()
{
a
:=
"123"
fmt
.
Println
(
gconv
.
Int
(
a
))
ladderprice
()
}
func
ladderprice
()
error
{
jsonStr
:=
jsonStr
()
goodsId
:=
"1160551099531105977"
costly
:=
1
//
var
num
int64
num
=
94
var
data
=
make
(
map
[
string
]
interface
{})
goodsResult
:=
gjson
.
Get
(
jsonStr
,
goodsId
)
if
(
goodsResult
.
Exists
()){
ladderPriceS
:=
goodsResult
.
Get
(
"ladder_price"
)
if
(
len
(
ladderPriceS
.
Array
())
>
0
){
var
price
=
gjson
.
Result
{}
for
k
,
item
:=
range
ladderPriceS
.
Array
(){
purchases
:=
item
.
Get
(
"purchases"
)
.
Int
()
if
(
k
==
0
){
price
=
item
//默认最小数量
if
(
purchases
>
num
){
num
=
purchases
//如果小于最小的,J
break
}
}
if
(
costly
==
1
){
//人民币就使用最小数量的阶梯价
break
}
if
(
purchases
<=
num
){
price
=
item
}
}
if
(
price
.
Exists
()
==
false
){
fmt
.
Println
(
"这个SKU没有阶梯价 504003"
)
}
data
[
"price_cn"
]
=
price
.
Get
(
"price_cn"
)
.
Float
()
price_cn_total
:=
gconv
.
Float64
(
data
[
"price_cn"
])
*
gconv
.
Float64
(
num
)
data
[
"price_cn_total"
]
=
common
.
MyRound
(
price_cn_total
,
4
)
data
[
"ladder_price"
]
=
price
.
Get
(
"price_cn"
)
.
Int
()
data
[
"num"
]
=
num
/*if(price.Get("price_ac").Exists()){
data["price_ac"]
}*/
}
else
{
fmt
.
Println
(
"这个SKU没有阶梯价 104002"
)
}
}
else
{
fmt
.
Println
(
"未找到对应SKU 20001"
)
}
return
nil
}
func
GetLadderPrice
(
goodsId
string
,
num
int64
,
costly
int
)
(
gjson
.
Result
,
error
){
jsonStr
:=
jsonStr
()
goodsResult
:=
gjson
.
Get
(
jsonStr
,
goodsId
)
if
(
goodsResult
.
Exists
()){
ladderPriceS
:=
goodsResult
.
Get
(
"ladder_price"
)
if
(
len
(
ladderPriceS
.
Array
())
>
0
){
var
price
=
gjson
.
Result
{}
for
k
,
item
:=
range
ladderPriceS
.
Array
(){
purchases
:=
item
.
Get
(
"purchases"
)
.
Int
()
if
(
k
==
0
){
price
=
item
//默认最小数量
if
(
purchases
>
num
){
num
=
purchases
//如果小于最小的,J
break
}
}
if
(
costly
==
1
){
//人民币就使用最小数量的阶梯价
break
}
if
(
purchases
<=
num
){
price
=
item
}
}
if
(
price
.
Exists
()
==
false
){
fmt
.
Println
(
"这个SKU没有阶梯价 504003"
)
}
}
else
{
fmt
.
Println
(
"这个SKU没有阶梯价 104002"
)
}
}
else
{
fmt
.
Println
(
"未找到对应SKU 20001"
)
}
}
func
jsonStr
()
string
{
/*
data["price_cn"]=price.Get("price_cn").Float()
price_cn_total:=gconv.Float64(data["price_cn"])*gconv.Float64(num)
data["price_cn_total"]=common.MyRound(price_cn_total,4)
data["ladder_price"]=price.Get("price_cn").Int()
data["num"]=num
*/
str
:=
`{
"1160551099531105977": {
"spu_id": "2160551099534657107",
"old_goods_id": 15000000037,
"update_time": 1607657661,
"cp_time": 0,
"goods_status": 1,
"goods_type": 1,
"supplier_id": 7,
"encoded": "",
"batch_sn": "",
"moq": 95,
"mpq": 1,
"stock": 9999999,
"hk_delivery_time": "2-3个工作日",
"cn_delivery_time": "1-3个工作日",
"ladder_price": [
{
"purchases": 95,
"price_us": 1.2431,
"price_cn": 10.1276
},
{
"purchases": 190,
"price_us": 1.0584,
"price_cn": 8.6231
},
{
"purchases": 950,
"price_us": 0.8384,
"price_cn": 6.8304
}
],
"goods_images": "//media.digikey.com/Photos/Rohm%20Photos/RPM871-H14E2_sml.JPG",
"canal": "",
"packing": "",
"goods_id": "1160551099531105977",
"goods_name": "RPM871-H14E2",
"brand_name": "ROHM",
"supplier_name": "digikey",
"attrs": [
{
"attr_name": "25°C 时待机电流,典型值",
"attr_value": "73µA"
},
{
"attr_name": "产品族",
"attr_value": "IrDA 收发器模块"
},
{
"attr_name": "关断",
"attr_value": "-"
},
{
"attr_name": "其它名称",
"attr_value": "RPM871-H14E2-ND\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tRPM871-H14E2TR\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tRPM871H14E2"
},
{
"attr_name": "包装",
"attr_value": "标准卷带"
},
{
"attr_name": "尺寸",
"attr_value": "8.00mm x 2.90mm x 2.40mm"
},
{
"attr_name": "工作温度",
"attr_value": "-20°C ~ 85°C"
},
{
"attr_name": "数据速率",
"attr_value": "115.2kbs(SIR)"
},
{
"attr_name": "方向",
"attr_value": "侧视图"
},
{
"attr_name": "标准",
"attr_value": "IrDA 1.2"
},
{
"attr_name": "标准包装",
"attr_value": "1,000"
},
{
"attr_name": "电压 - 供电",
"attr_value": "2.6V ~ 3.6V"
},
{
"attr_name": "类别",
"attr_value": "传感器,变送器"
},
{
"attr_name": "系列",
"attr_value": "-"
},
{
"attr_name": "链路范围,低功耗",
"attr_value": "20cm,60cm"
}
],
"scm_brand": [],
"ac_type": 0,
"allow_coupon": 1,
"brand_id": 1749,
"coefficient": {
"cn": 1.03,
"hk": 1,
"extra_ratio": 1,
"ratio": 7,
"tax": 1.13
},
"original_price": [
{
"purchases": 95,
"price_us": 1.243068,
"price_cn": 9.4233255876,
"cost_price": 0
},
{
"purchases": 190,
"price_us": 1.058397,
"price_cn": 8.0233901379,
"cost_price": 0
},
{
"purchases": 950,
"price_us": 0.838368,
"price_cn": 6.3554162976,
"cost_price": 0
}
],
"supp_extend_fee": {
"cn": {
"max": "10000",
"price": "20"
},
"hk": {
"max": 69000,
"price": 138
}
},
"is_buy": 1,
"class_id1": 13287,
"class_id2": 13288,
"class_id3": 0,
"spu_name": "RPM871-H14E2",
"status": 1,
"images_l": "//media.digikey.com/Photos/Rohm%20Photos/RPM871-H14E2_sml.JPG",
"encap": "",
"pdf": "//media.digikey.com/pdf/Data%20Sheets/Rohm%20PDFs/RPM871-H14.pdf",
"spu_brief": "MODULE IRDA 115.2KBPS 8SMD",
"class_name": "其他",
"erp_tax": false,
"goods_sn": "",
"goods_details": "",
"content": null
}
}`
return
str
}
\ No newline at end of file
model/ly_sku.go
View file @
adb8b41f
...
@@ -20,6 +20,7 @@ type LySku struct {
...
@@ -20,6 +20,7 @@ type LySku struct {
BatchSn
string
`json:"batch_sn"`
BatchSn
string
`json:"batch_sn"`
Moq
int64
`json:"moq"`
Moq
int64
`json:"moq"`
Mpq
int64
`json:"mpq"`
Mpq
int64
`json:"mpq"`
Multiple
int64
`json:"multiple"`
Stock
int64
`json:"stock"`
Stock
int64
`json:"stock"`
HkDeliveryTime
string
`json:"hk_delivery_time"`
HkDeliveryTime
string
`json:"hk_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_time"`
...
@@ -168,6 +169,18 @@ func InitSkuData(sku string) (data LySku) {
...
@@ -168,6 +169,18 @@ func InitSkuData(sku string) (data LySku) {
mpq
:=
gjson
.
Get
(
sku
,
"mpq"
)
.
Int
()
mpq
:=
gjson
.
Get
(
sku
,
"mpq"
)
.
Int
()
data
.
Mpq
=
mpq
data
.
Mpq
=
mpq
//递增量
Multiple
:=
gjson
.
Get
(
sku
,
"multiple"
)
.
Int
()
if
Multiple
>
0
{
data
.
Multiple
=
Multiple
}
else
{
if
mpq
>
moq
{
data
.
Multiple
=
moq
}
else
{
data
.
Multiple
=
mpq
}
}
stock
:=
gjson
.
Get
(
sku
,
"stock"
)
.
Int
()
stock
:=
gjson
.
Get
(
sku
,
"stock"
)
.
Int
()
data
.
Stock
=
stock
data
.
Stock
=
stock
...
...
service/service_zy.go
View file @
adb8b41f
...
@@ -130,8 +130,24 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
...
@@ -130,8 +130,24 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
A
.
Set
(
"packing"
,
gjson
.
Get
(
info
,
"packing"
)
.
Int
())
//
A
.
Set
(
"packing"
,
gjson
.
Get
(
info
,
"packing"
)
.
Int
())
//
A
.
Set
(
"goods_unit"
,
gjson
.
Get
(
info
,
"goods_unit"
)
.
Int
())
//
A
.
Set
(
"goods_unit"
,
gjson
.
Get
(
info
,
"goods_unit"
)
.
Int
())
//
A
.
Set
(
"goods_brief"
,
gjson
.
Get
(
info
,
"goods_brief"
)
.
String
())
//
A
.
Set
(
"goods_brief"
,
gjson
.
Get
(
info
,
"goods_brief"
)
.
String
())
//
A
.
Set
(
"moq"
,
gjson
.
Get
(
info
,
"moq"
)
.
Int
())
//
A
.
Set
(
"mpq"
,
gjson
.
Get
(
info
,
"mpq"
)
.
Int
())
//
moq
:=
gjson
.
Get
(
info
,
"moq"
)
.
Int
()
mpq
:=
gjson
.
Get
(
info
,
"mpq"
)
.
Int
()
//自营递增量
Multiple
:=
gjson
.
Get
(
info
,
"multiple"
)
.
Int
()
if
Multiple
>
0
{
Multiple
=
Multiple
}
else
{
if
mpq
>
moq
{
Multiple
=
moq
}
else
{
Multiple
=
mpq
}
}
A
.
Set
(
"moq"
,
moq
)
//
A
.
Set
(
"mpq"
,
mpq
)
//
A
.
Set
(
"multiple"
,
Multiple
)
//
A
.
Set
(
"update_time"
,
gjson
.
Get
(
info
,
"update_time"
)
.
Int
())
//
A
.
Set
(
"update_time"
,
gjson
.
Get
(
info
,
"update_time"
)
.
Int
())
//
A
.
Set
(
"sku_name"
,
strings
.
Trim
(
gjson
.
Get
(
info
,
"sku_name"
)
.
String
(),
" "
))
//
A
.
Set
(
"sku_name"
,
strings
.
Trim
(
gjson
.
Get
(
info
,
"sku_name"
)
.
String
(),
" "
))
//
...
...
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