Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
L
library
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
stbz
library
Commits
255d9542
提交
255d9542
authored
1年前
作者:
张立波
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
云众
上级
38abac8c
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
1413 行增加
和
14 行删除
+1413
-14
upstream.go
upstream/upstream.go
+15
-14
yunzmall.go
upstream/yunzmall/yunzmall.go
+117
-0
yunzmall_goods.go
upstream/yunzmall/yunzmall_goods.go
+440
-0
yunzmall_order.go
upstream/yunzmall/yunzmall_order.go
+587
-0
yunzmall_refund.go
upstream/yunzmall/yunzmall_refund.go
+130
-0
yunzmall_storage.go
upstream/yunzmall/yunzmall_storage.go
+39
-0
yunzmall_token.go
upstream/yunzmall/yunzmall_token.go
+85
-0
没有找到文件。
upstream/upstream.go
浏览文件 @
255d9542
...
@@ -5,20 +5,21 @@ import (
...
@@ -5,20 +5,21 @@ import (
)
)
const
(
const
(
Cloud
=
1
//云仓
Cloud
=
1
//云仓
Jd
=
2
//京东
Jd
=
2
//京东
Ali
=
6
//阿里
Ali
=
6
//阿里
Tm
=
7
//天猫
Tm
=
7
//天猫
Sn
=
8
//苏宁
Sn
=
8
//苏宁
Gome
=
10
//国美
Gome
=
10
//国美
Schl
=
11
//盛创汇联
Schl
=
11
//盛创汇联
Wpc
=
12
//唯品会
Wpc
=
12
//唯品会
Ikc
=
13
//爱库存
Ikc
=
13
//爱库存
Dwd
=
14
//好食期
Dwd
=
14
//好食期
Itao
=
15
//淘特
Itao
=
15
//淘特
Hdh
=
16
//会订货
Hdh
=
16
//会订货
TmNew
=
17
//新版天猫
TmNew
=
17
//新版天猫
AliNew
=
18
//精选1688
AliNew
=
18
//精选1688
Yunzmall
=
19
)
)
var
(
var
(
...
...
This diff is collapsed.
Click to expand it.
upstream/yunzmall/yunzmall.go
0 → 100644
浏览文件 @
255d9542
package
yunzmall
import
(
"context"
"fmt"
"github.com/gogf/gf/container/garray"
"github.com/gogf/gf/crypto/gmd5"
"github.com/gogf/gf/crypto/gsha1"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/text/gregex"
"github.com/gogf/gf/text/gstr"
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/grand"
"sort"
"time"
)
type
Client
struct
{
AppKey
string
AppSecret
string
AccessToken
string
DB
int
}
var
server
*
Client
const
Url
=
"https://supply.yunzmall.com/supplyapi"
const
pkgName
=
"yunzmall"
const
CacheKey
=
"yunzmall:token"
func
New
(
req
*
Client
)
{
server
=
req
if
server
.
DB
==
0
{
server
.
DB
=
10
}
}
// post 请求
func
post
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
,
xToken
...
interface
{})
(
str
string
,
err
error
)
{
Start
:=
gtime
.
TimestampMilli
()
Request
:=
g
.
Client
()
.
ContentJson
()
var
AppNonce
=
grand
.
S
(
16
)
var
AppTimestamp
=
gtime
.
TimestampStr
()
Request
.
SetHeader
(
"App-Nonce-Str"
,
grand
.
S
(
16
))
Request
.
SetHeader
(
"App-Timestamp"
,
gtime
.
TimestampStr
())
if
len
(
xToken
)
==
0
{
var
token
string
token
,
err
=
Token
.
Access
(
ctx
)
if
err
!=
nil
{
return
}
Request
.
SetHeader
(
"x-token"
,
token
)
}
AppSign
,
err
:=
sign
(
AppNonce
,
AppTimestamp
,
params
)
if
err
!=
nil
{
return
}
Request
.
SetHeader
(
"App-Sign"
,
AppSign
)
resp
,
err
:=
Request
.
Timeout
(
time
.
Second
*
5
)
.
Post
(
Url
+
method
,
params
)
//resp.RawDump()
defer
func
()
{
_
=
resp
.
Close
()
paramStr
:=
gjson
.
New
(
params
)
.
MustToJsonString
()
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"POST"
)
ctx
=
context
.
WithValue
(
ctx
,
"URI"
,
method
)
if
err
!=
nil
{
g
.
Log
()
.
Ctx
(
ctx
)
.
Cat
(
pkgName
)
.
Cat
(
"error"
)
.
Infof
(
"参数【%v】错误【%v】响应时间【%v ms】"
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
}
else
{
g
.
Log
()
.
Ctx
(
ctx
)
.
Cat
(
pkgName
)
.
Infof
(
"参数【%v】响应【%v】响应时间【%v ms】"
,
paramStr
,
str
,
gtime
.
TimestampMilli
()
-
Start
)
}
}()
if
err
!=
nil
{
return
}
str
=
resp
.
ReadAllString
()
return
}
func
sign
(
nonce
string
,
timestamp
string
,
param
g
.
Map
)
(
res
string
,
err
error
)
{
var
keys
[]
string
keys
=
append
(
keys
,
"App-Nonce-Str"
)
keys
=
append
(
keys
,
"App-Timestamp"
)
mewparam
:=
gjson
.
New
(
param
)
.
Map
()
mewparam
[
"App-Timestamp"
]
=
timestamp
mewparam
[
"App-Nonce-Str"
]
=
nonce
for
k
:=
range
mewparam
{
keys
=
append
(
keys
,
k
)
}
sort
.
Strings
(
keys
)
var
array
=
garray
.
New
()
for
_
,
v
:=
range
keys
{
array
.
Append
(
fmt
.
Sprintf
(
"%s=%s"
,
v
,
gconv
.
String
(
mewparam
[
v
])))
}
array
.
Append
(
fmt
.
Sprintf
(
"%s=%s"
,
"appKey"
,
server
.
AppKey
))
array
.
Append
(
fmt
.
Sprintf
(
"%s=%s"
,
"appSecret"
,
server
.
AppSecret
))
var
str
=
array
.
Join
(
"&"
)
str
,
err
=
gregex
.
ReplaceString
(
`\s`
,
""
,
str
)
if
err
!=
nil
{
return
}
str
=
gsha1
.
Encrypt
(
str
)
str
=
gmd5
.
MustEncryptString
(
str
)
res
=
gstr
.
ToUpper
(
str
)
return
}
type
CommonRes
struct
{
Code
int
`json:"code"`
Msg
string
`json:"msg"`
}
This diff is collapsed.
Click to expand it.
upstream/yunzmall/yunzmall_goods.go
0 → 100644
浏览文件 @
255d9542
package
yunzmall
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type
goodsLogic
struct
{
}
var
Goods
=
goodsLogic
{}
type
GoodsCursorListReq
struct
{
Cursor
int
`json:"cursor,omitempty"`
//游标
PageSize
int
`json:"pageSize"`
//每页个数
}
type
GoodsCursorListRes
struct
{
CommonRes
Data
struct
{
List
[]
struct
{
Id
int
`json:"id"`
Title
string
`json:"title"`
ImageUrl
string
`json:"image_url"`
Source
int
`json:"source"`
Category1Id
int
`json:"category_1_id"`
Category2Id
int
`json:"category_2_id"`
Category3Id
int
`json:"category_3_id"`
BrandId
int
`json:"brand_id"`
AgreementPrice
int
`json:"agreement_price"`
GuidePrice
int
`json:"guide_price"`
ActivityPrice
int
`json:"activity_price"`
MarketPrice
int
`json:"market_price"`
SalePrice
int
`json:"sale_price"`
CostPrice
int
`json:"cost_price"`
OriginRate
float64
`json:"origin_rate"`
ActivityRate
float64
`json:"activity_rate"`
MarketRate
int
`json:"market_rate"`
Profit
int
`json:"profit"`
ProfitRate
float64
`json:"profit_rate"`
IsDisplay
int
`json:"is_display"`
IsRecommend
int
`json:"is_recommend"`
IsNew
int
`json:"is_new"`
IsHot
int
`json:"is_hot"`
Stock
int
`json:"stock"`
Sales
int
`json:"sales"`
Unit
string
`json:"unit"`
IsPromotion
int
`json:"is_promotion"`
MinPrice
int
`json:"min_price"`
MaxPrice
int
`json:"max_price"`
CreatedAt
int
`json:"created_at"`
SupplierId
int
`json:"supplier_id"`
GatherSupplierId
int
`json:"gather_supplier_id"`
FreightType
int
`json:"freight_type"`
RecommendBrandStr
string
`json:"recommend_brand_str"`
RecommendCategoryStr
string
`json:"recommend_category_str"`
SupplierName
string
`json:"supplier_name"`
UpdatedAt
int
`json:"updated_at"`
Sort
int
`json:"sort"`
IsPlugin
int
`json:"is_plugin"`
Level1Price
int
`json:"level_1_price"`
Level2Price
int
`json:"level_2_price"`
Level3Price
int
`json:"level_3_price"`
Level4Price
int
`json:"level_4_price"`
Level5Price
int
`json:"level_5_price"`
Level6Price
int
`json:"level_6_price"`
Level7Price
int
`json:"level_7_price"`
Level8Price
int
`json:"level_8_price"`
Level9Price
int
`json:"level_9_price"`
Level10Price
int
`json:"level_10_price"`
Level1Profit
int
`json:"level_1_profit"`
Level2Profit
int
`json:"level_2_profit"`
Level3Profit
int
`json:"level_3_profit"`
Level4Profit
int
`json:"level_4_profit"`
Level5Profit
int
`json:"level_5_profit"`
Level6Profit
int
`json:"level_6_profit"`
Level7Profit
int
`json:"level_7_profit"`
Level8Profit
int
`json:"level_8_profit"`
Level9Profit
int
`json:"level_9_profit"`
Level10Profit
int
`json:"level_10_profit"`
Barcode
string
`json:"barcode"`
ImportApps
string
`json:"import_apps"`
IsBill
int
`json:"is_bill"`
SingleOption
int
`json:"single_option"`
SmallShopIdString
string
`json:"small_shop_id_string"`
SupplyLine
string
`json:"supply_line"`
IsVideoShop
int
`json:"is_video_shop"`
}
`json:"list"`
Total
int
`json:"total"`
Cursor
int
`json:"cursor"`
PageSize
int
`json:"pageSize"`
}
`json:"data"`
}
// CursorList 选品列表API(全量,cursor)
func
(
s
goodsLogic
)
CursorList
(
ctx
context
.
Context
,
req
GoodsCursorListReq
)
(
res
*
GoodsCursorListRes
,
err
error
)
{
var
method
=
"/app/product/storage/cursorList"
result
,
err
:=
post
(
ctx
,
method
,
gconv
.
Map
(
req
))
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
GoodsDetailItem
struct
{
Id
int
`json:"id"`
CreatedAt
int
`json:"created_at"`
UpdatedAt
int
`json:"updated_at"`
Title
string
`json:"title"`
OriginPrice
int
`json:"origin_price"`
GuidePrice
int
`json:"guide_price"`
Price
int
`json:"price"`
CostPrice
int
`json:"cost_price"`
ActivityPrice
int
`json:"activity_price"`
MinBuyQty
int
`json:"min_buy_qty"`
Stock
int
`json:"stock"`
Sales
int
`json:"sales"`
FeedbackRate
int
`json:"feedback_rate"`
Sn
string
`json:"sn"`
Code
string
`json:"code"`
IsNew
int
`json:"is_new"`
IsRecommend
int
`json:"is_recommend"`
IsHot
int
`json:"is_hot"`
IsPromotion
int
`json:"is_promotion"`
IsDisplay
int
`json:"is_display"`
IsDisplayMsg
string
`json:"is_display_msg"`
StatusLock
int
`json:"status_lock"`
SingleOption
int
`json:"single_option"`
Desc
string
`json:"desc"`
ImageUrl
string
`json:"image_url"`
VideoUrl
string
`json:"video_url"`
Unit
string
`json:"unit"`
Barcode
string
`json:"barcode"`
Long
int
`json:"long"`
Wide
int
`json:"wide"`
High
int
`json:"high"`
Volume
int
`json:"volume"`
Freight
int
`json:"freight"`
FreightType
int
`json:"freight_type"`
MaxPrice
int
`json:"maxPrice"`
MinPrice
int
`json:"minPrice"`
MaxCostPrice
int
`json:"maxCostPrice"`
MinCostPrice
int
`json:"minCostPrice"`
MaxOriginPrice
int
`json:"maxOriginPrice"`
MinOriginPrice
int
`json:"minOriginPrice"`
Gallery
[]
struct
{
Type
int
`json:"type"`
Src
string
`json:"src"`
}
`json:"gallery"`
Qualifications
interface
{}
`json:"qualifications"`
DetailImages
string
`json:"detail_images"`
Attrs
[]
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
}
`json:"attrs"`
BrandId
int
`json:"brand_id"`
SupplierId
int
`json:"supplier_id"`
GatherSupplyId
int
`json:"gather_supply_id"`
Category1Id
int
`json:"category1_id"`
Category2Id
int
`json:"category2_id"`
Category3Id
int
`json:"category3_id"`
FreightTemplateId
int
`json:"freight_template_id"`
Source
int
`json:"source"`
Sort
int
`json:"sort"`
SourceGoodsId
int
`json:"source_goods_id"`
SourceGoodsIdString
string
`json:"source_goods_id_string"`
LocationId
int
`json:"location_id"`
Freeze
int
`json:"freeze"`
ShopLevel
int
`json:"shop_level"`
DesLevel
int
`json:"des_level"`
ExpressLevel
int
`json:"express_level"`
Level
int
`json:"level"`
ChildTitle
string
`json:"child_title"`
BillPosition
int
`json:"bill_position"`
IsBill
int
`json:"is_bill"`
Md5
string
`json:"md5"`
TaxCode
string
`json:"tax_code"`
TaxProductName
string
`json:"tax_product_name"`
TaxShortName
string
`json:"tax_short_name"`
TaxOption
string
`json:"tax_option"`
TaxUnit
string
`json:"tax_unit"`
FavorablePolicy
string
`json:"favorable_policy"`
IsFavorablePolicy
int
`json:"is_favorable_policy"`
FreeOfTax
int
`json:"free_of_tax"`
ShortCode
string
`json:"short_code"`
TaxMeasurePrice
int
`json:"tax_measure_price"`
TaxRate
int
`json:"tax_rate"`
IsTaxLogo
int
`json:"is_tax_logo"`
IsPlugin
int
`json:"is_plugin"`
PluginId
int
`json:"plugin_id"`
IsSingleOrder
int
`json:"is_single_order"`
SupplierSourceId
int
`json:"supplier_source_id"`
SupplierSourceCategoryId
int
`json:"supplier_source_category_id"`
ProfitRate
int
`json:"profit_rate"`
JushuitanBind
int
`json:"jushuitan_bind"`
JushuitanDistributorSupplierName
string
`json:"jushuitan_distributor_supplier_name"`
JushuitanDistributorCoId
string
`json:"jushuitan_distributor_co_id"`
JushuitanUploadStatus
int
`json:"jushuitan_upload_status"`
SupplyLine
string
`json:"supply_line"`
IsSupplyLine
int
`json:"is_supply_line"`
IsVideoShop
int
`json:"is_video_shop"`
ShopName
string
`json:"shop_name"`
Skus
[]
struct
{
Id
int
`json:"id"`
CreatedAt
int
`json:"created_at"`
UpdatedAt
int
`json:"updated_at"`
Title
string
`json:"title"`
Price
int
`json:"price"`
CostPrice
int
`json:"cost_price"`
OriginPrice
int
`json:"origin_price"`
GuidePrice
int
`json:"guide_price"`
ActivityPrice
int
`json:"activity_price"`
Stock
int
`json:"stock"`
Weight
int
`json:"weight"`
IsDisplay
int
`json:"is_display"`
ProductId
int
`json:"product_id"`
SupplierId
int
`json:"supplier_id"`
Code
string
`json:"code"`
Sn
string
`json:"sn"`
Barcode
string
`json:"barcode"`
ImageUrl
string
`json:"image_url"`
Options
[]
struct
{
SpecName
string
`json:"spec_name"`
SpecItemName
string
`json:"spec_item_name"`
}
`json:"options"`
OriginalSkuId
int
`json:"original_sku_id"`
SpecId
string
`json:"specId"`
Describe
string
`json:"describe"`
TaxCode
string
`json:"tax_code"`
TaxProductName
string
`json:"tax_product_name"`
TaxShortName
string
`json:"tax_short_name"`
TaxOption
string
`json:"tax_option"`
TaxUnit
string
`json:"tax_unit"`
FavorablePolicy
string
`json:"favorable_policy"`
IsFavorablePolicy
int
`json:"is_favorable_policy"`
FreeOfTax
int
`json:"free_of_tax"`
ShortCode
string
`json:"short_code"`
TaxMeasurePrice
int
`json:"tax_measure_price"`
TaxRate
int
`json:"tax_rate"`
IsTaxLogo
int
`json:"is_tax_logo"`
ProfitRate
int
`json:"profit_rate"`
JushuitanBind
int
`json:"jushuitan_bind"`
JushuitanUploadStatus
int
`json:"jushuitan_upload_status"`
Number
int
`json:"number"`
}
`json:"skus"`
Supplier
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
IsSelfSupport
int
`json:"is_self_support"`
}
`json:"supplier"`
GatherSupply
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
Key
string
`json:"key"`
CategoryId
int
`json:"category_id"`
}
`json:"gather_supply"`
AliProduct
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
ProductId
int
`json:"product_id"`
SkuId
int
`json:"sku_id"`
AliSkuId
string
`json:"ali_sku_id"`
AliProductId
int
`json:"ali_product_id"`
AutoPay
int
`json:"auto_pay"`
ShopId
string
`json:"shop_id"`
}
`json:"ali_product"`
ProductVerify
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
ProductId
int
`json:"product_id"`
SupplierId
int
`json:"supplier_id"`
Status
int
`json:"status"`
IsDisplay
int
`json:"is_display"`
}
`json:"product_verify"`
Brand
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
}
`json:"brand"`
Category1
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
Image
string
`json:"image"`
Level
int
`json:"level"`
ParentId
int
`json:"parent_id"`
}
`json:"category_1"`
Category2
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
Image
string
`json:"image"`
Level
int
`json:"level"`
ParentId
int
`json:"parent_id"`
}
`json:"category_2"`
Category3
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
Image
string
`json:"image"`
Level
int
`json:"level"`
ParentId
int
`json:"parent_id"`
}
`json:"category_3"`
AgreementPrice
int
`json:"agreement_price"`
MarketPrice
int
`json:"market_price"`
SalePrice
int
`json:"sale_price"`
}
type
GoodsDetailRes
struct
{
CommonRes
Data
struct
{
List
[]
GoodsDetailItem
`json:"list"`
}
`json:"data"`
}
// Detail 商品详情
func
(
s
goodsLogic
)
Detail
(
ctx
context
.
Context
,
req
interface
{})
(
res
*
GoodsDetailRes
,
err
error
)
{
var
method
=
"/app/product/storage/detailList"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"ids"
:
gconv
.
Ints
(
req
),
})
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
GoodsListReq
struct
{
Title
string
`json:"title,omitempty"`
//商品名称
IsDisplay
int
`json:"is_display,omitempty"`
//0下架1上架
RangeType
string
`json:"range_type,omitempty"`
//筛选类型:agreement_price 协议价格 origin_rate常规利润率 activity_price 营销价格 guide_price 指导价格 activity_rate 营销利润率
RangeTypeFrom
int
`json:"range_type.from,omitempty"`
//区间开始
RangeTo
int
`json:"range.to,omitempty"`
//区间结束
CategoryID1
int
`json:"category_1_id,omitempty"`
//一级分类id
CategoryID2
int
`json:"category_2_id,omitempty"`
//二级分类id
CategoryID3
int
`json:"category_3_id,omitempty"`
//三级分类id
FreightType
int
`json:"freight_type,omitempty"`
//运费类型1包邮2不包邮
Source
int
`json:"source,omitempty"`
// 0中台自营 1云仓(云仓) 2京东 6阿里 7天猫 8苏宁 11华南一仓 98中台云仓 99永源 100YZH 101中台供应链 102跨境 103DWD 108YHZ新版
SupplierName
string
`json:"supplier_name,omitempty"`
//供应商名称
SupplierID
int
`json:"supplier_id,omitempty"`
//供应商ID
Type
int
`json:"type,omitempty"`
// created_at:最新上架agreement_price:协议价格, guide_price指导价 activity_price营销价格 origin_rate常规利率 activity_rate营销利率
Sort
bool
`json:"sort,omitempty"`
// false 倒叙 true正序
Page
int
`json:"page"`
// 请求页数
PageSize
int
`json:"pageSize"`
// 每页个数(最大值50)
IsNew
int
`json:"is_new,omitempty"`
// 新品:1是0否
IsHot
int
`json:"is_hot,omitempty"`
// 热卖:1是0否
IsPromotion
int
`json:"is_promotion,omitempty"`
// 促销:1是0否
IsImport
int
`json:"is_import,omitempty"`
// 是否导入(当前配置是否导入过):1是2否
}
type
GoodsListRes
struct
{
CommonRes
Data
struct
{
List
[]
struct
{
Id
int
`json:"id"`
Title
string
`json:"title"`
ImageUrl
string
`json:"image_url"`
Source
int
`json:"source"`
Category1Id
int
`json:"category_1_id"`
Category2Id
int
`json:"category_2_id"`
Category3Id
int
`json:"category_3_id"`
BrandId
int
`json:"brand_id"`
AgreementPrice
int
`json:"agreement_price"`
GuidePrice
int
`json:"guide_price"`
ActivityPrice
int
`json:"activity_price"`
MarketPrice
int
`json:"market_price"`
SalePrice
int
`json:"sale_price"`
CostPrice
int
`json:"cost_price"`
OriginRate
int
`json:"origin_rate"`
ActivityRate
int
`json:"activity_rate"`
MarketRate
int
`json:"market_rate"`
Profit
int
`json:"profit"`
ProfitRate
float64
`json:"profit_rate"`
IsDisplay
int
`json:"is_display"`
IsRecommend
int
`json:"is_recommend"`
IsNew
int
`json:"is_new"`
IsHot
int
`json:"is_hot"`
Stock
int
`json:"stock"`
Sales
int
`json:"sales"`
Unit
string
`json:"unit"`
IsPromotion
int
`json:"is_promotion"`
MinPrice
int
`json:"min_price"`
MaxPrice
int
`json:"max_price"`
CreatedAt
int
`json:"created_at"`
SupplierId
int
`json:"supplier_id"`
GatherSupplierId
int
`json:"gather_supplier_id"`
FreightType
int
`json:"freight_type"`
RecommendBrandStr
string
`json:"recommend_brand_str"`
RecommendCategoryStr
string
`json:"recommend_category_str"`
SupplierName
string
`json:"supplier_name"`
UpdatedAt
int
`json:"updated_at"`
Sort
int
`json:"sort"`
IsPlugin
int
`json:"is_plugin"`
Level1Price
int
`json:"level_1_price"`
Level2Price
int
`json:"level_2_price"`
Level3Price
int
`json:"level_3_price"`
Level4Price
int
`json:"level_4_price"`
Level5Price
int
`json:"level_5_price"`
Level6Price
int
`json:"level_6_price"`
Level7Price
int
`json:"level_7_price"`
Level8Price
int
`json:"level_8_price"`
Level9Price
int
`json:"level_9_price"`
Level10Price
int
`json:"level_10_price"`
Level1Profit
int
`json:"level_1_profit"`
Level2Profit
int
`json:"level_2_profit"`
Level3Profit
int
`json:"level_3_profit"`
Level4Profit
int
`json:"level_4_profit"`
Level5Profit
int
`json:"level_5_profit"`
Level6Profit
int
`json:"level_6_profit"`
Level7Profit
int
`json:"level_7_profit"`
Level8Profit
int
`json:"level_8_profit"`
Level9Profit
int
`json:"level_9_profit"`
Level10Profit
int
`json:"level_10_profit"`
Barcode
string
`json:"barcode"`
ImportApps
string
`json:"import_apps"`
IsBill
int
`json:"is_bill"`
SingleOption
int
`json:"single_option"`
SmallShopIdString
string
`json:"small_shop_id_string"`
SupplyLine
string
`json:"supply_line"`
IsVideoShop
int
`json:"is_video_shop"`
}
`json:"list"`
Total
int
`json:"total"`
Page
int
`json:"page"`
PageSize
int
`json:"pageSize"`
NextUrl
string
`json:"next_url"`
SeverRatio
int
`json:"sever_ratio"`
}
`json:"data"`
}
// List 商品列表
func
(
s
goodsLogic
)
List
(
ctx
context
.
Context
,
req
GoodsListReq
)
(
res
*
GoodsListRes
,
err
error
)
{
var
method
=
"/app/product/storage/list"
result
,
err
:=
post
(
ctx
,
method
,
gconv
.
Map
(
req
))
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
This diff is collapsed.
Click to expand it.
upstream/yunzmall/yunzmall_order.go
0 → 100644
浏览文件 @
255d9542
package
yunzmall
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type
orderLogic
struct
{
}
var
Order
=
orderLogic
{}
type
OrderAddress
struct
{
Area
string
`json:"area"`
City
string
`json:"city"`
Consignee
string
`json:"consignee"`
Description
string
`json:"description"`
Phone
string
`json:"phone"`
Province
string
`json:"province"`
Street
string
`json:"street"`
}
type
OrderSpu
struct
{
Number
int
`json:"number"`
Sku
int
`json:"sku"`
}
type
OrderBeforeReq
struct
{
Address
OrderAddress
`json:"address"`
Spu
[]
OrderSpu
`json:"spu"`
}
type
OrderBeforeRes
struct
{
CommonRes
Data
struct
{
Desc
string
`json:"desc"`
Freight
string
`json:"freight"`
}
`json:"data"`
}
// Before 前置校验
func
(
s
orderLogic
)
Before
(
ctx
context
.
Context
,
req
OrderBeforeReq
)
(
res
*
OrderBeforeRes
,
err
error
)
{
var
method
=
"/app/order/beforeCheck"
result
,
err
:=
post
(
ctx
,
method
,
gconv
.
Map
(
req
))
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
OrderCreateReq
struct
{
OrderSn
string
`json:"order_sn"`
Spu
[]
*
OrderSpu
`json:"spu"`
Address
OrderAddress
`json:"address"`
}
type
OrderCreateRes
struct
{
CommonRes
Data
struct
{
Orders
[]
struct
{
Id
int
`json:"id"`
CreatedAt
int
`json:"created_at"`
UpdatedAt
int
`json:"updated_at"`
OrderSn
int64
`json:"order_sn"`
ThirdOrderSn
string
`json:"third_order_sn"`
GatherSupplySn
string
`json:"gather_supply_sn"`
GatherSupplyMsg
string
`json:"gather_supply_msg"`
GatherSupplyType
int
`json:"gather_supply_type"`
Key
string
`json:"key"`
Title
string
`json:"title"`
Status
int
`json:"status"`
Amount
int
`json:"amount"`
RefundAmount
int
`json:"refund_amount"`
ItemAmount
int
`json:"item_amount"`
SupplyAmount
int
`json:"supply_amount"`
CostAmount
int
`json:"cost_amount"`
Freight
int
`json:"freight"`
ServiceFee
int
`json:"service_fee"`
GoodsCount
int
`json:"goods_count"`
SendStatus
int
`json:"send_status"`
RefundStatus
int
`json:"refund_status"`
Remark
string
`json:"remark"`
Note
string
`json:"note"`
TechnicalServicesFee
int
`json:"technical_services_fee"`
PaidAt
interface
{}
`json:"paid_at"`
SentAt
interface
{}
`json:"sent_at"`
ReceivedAt
interface
{}
`json:"received_at"`
ClosedAt
interface
{}
`json:"closed_at"`
UserId
int
`json:"user_id"`
SupplierId
int
`json:"supplier_id"`
GatherSupplyId
int
`json:"gather_supply_id"`
ApplicationId
int
`json:"application_id"`
TradeId
int
`json:"trade_id"`
PayTypeId
int
`json:"pay_type_id"`
PayInfoId
int
`json:"pay_info_id"`
ShippingMethodId
int
`json:"shipping_method_id"`
ShippingAddressId
int
`json:"shipping_address_id"`
SendTypeId
int
`json:"send_type_id"`
CommentStatus
int
`json:"comment_status"`
CanRefund
int
`json:"can_refund"`
Lock
int
`json:"lock"`
IsConnection
int
`json:"is_connection"`
AmountDetail
struct
{
Title
string
`json:"title"`
Amount
int
`json:"amount"`
Qty
int
`json:"qty"`
Desc
string
`json:"desc"`
AmountItems
[]
struct
{
Title
string
`json:"title"`
Amount
int
`json:"amount"`
Qty
int
`json:"qty"`
Desc
string
`json:"desc"`
AmountItems
interface
{}
`json:"amount_items"`
}
`json:"amount_items"`
}
`json:"amount_detail"`
OrderItems
[]
struct
{
Id
int
`json:"id"`
CreatedAt
int
`json:"created_at"`
UpdatedAt
int
`json:"updated_at"`
Key
string
`json:"key"`
Title
string
`json:"title"`
SkuTitle
string
`json:"sku_title"`
Unit
string
`json:"unit"`
Qty
int
`json:"qty"`
Amount
int
`json:"amount"`
RefundAmount
int
`json:"refund_amount"`
DiscountAmount
int
`json:"discount_amount"`
DeductionAmount
int
`json:"deduction_amount"`
CostAmount
int
`json:"cost_amount"`
PaymentAmount
int
`json:"payment_amount"`
SupplyAmount
int
`json:"supply_amount"`
ImageUrl
string
`json:"image_url"`
SendStatus
int
`json:"send_status"`
RefundStatus
int
`json:"refund_status"`
TradeId
int
`json:"trade_id"`
SupplierId
int
`json:"supplier_id"`
UserId
int
`json:"user_id"`
OrderId
int
`json:"order_id"`
ProductId
int
`json:"product_id"`
SkuId
int
`json:"sku_id"`
OriginalSkuId
int
`json:"original_sku_id"`
CanRefund
int
`json:"can_refund"`
CommentStatus
int
`json:"comment_status"`
AmountDetail
struct
{
Title
string
`json:"title"`
Amount
int
`json:"amount"`
Qty
int
`json:"qty"`
Desc
string
`json:"desc"`
AmountItems
[]
struct
{
Title
string
`json:"title"`
Amount
int
`json:"amount"`
Qty
int
`json:"qty"`
Desc
string
`json:"desc"`
AmountItems
[]
interface
{}
`json:"amount_items"`
}
`json:"amount_items"`
}
`json:"amount_detail"`
Options
[]
struct
{
SpecName
string
`json:"spec_name"`
SpecItemName
string
`json:"spec_item_name"`
}
`json:"options"`
Sku
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
Title
string
`json:"title"`
Price
int
`json:"price"`
CostPrice
int
`json:"cost_price"`
OriginPrice
int
`json:"origin_price"`
GuidePrice
int
`json:"guide_price"`
ActivityPrice
int
`json:"activity_price"`
Stock
int
`json:"stock"`
Weight
int
`json:"weight"`
IsDisplay
int
`json:"is_display"`
ProductId
int
`json:"product_id"`
SupplierId
int
`json:"supplier_id"`
Code
string
`json:"code"`
Sn
string
`json:"sn"`
Barcode
string
`json:"barcode"`
ImageUrl
string
`json:"image_url"`
Options
interface
{}
`json:"options"`
OriginalSkuId
int
`json:"original_sku_id"`
Describe
string
`json:"describe"`
TaxCode
string
`json:"tax_code"`
TaxProductName
string
`json:"tax_product_name"`
TaxShortName
string
`json:"tax_short_name"`
TaxOption
string
`json:"tax_option"`
TaxUnit
string
`json:"tax_unit"`
FavorablePolicy
string
`json:"favorable_policy"`
IsFavorablePolicy
int
`json:"is_favorable_policy"`
FreeOfTax
int
`json:"free_of_tax"`
ShortCode
string
`json:"short_code"`
TaxMeasurePrice
int
`json:"tax_measure_price"`
TaxRate
int
`json:"tax_rate"`
IsTaxLogo
int
`json:"is_tax_logo"`
}
`json:"sku"`
Product
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
Title
string
`json:"title"`
OriginPrice
int
`json:"origin_price"`
GuidePrice
int
`json:"guide_price"`
Price
int
`json:"price"`
CostPrice
int
`json:"cost_price"`
ActivityPrice
int
`json:"activity_price"`
MinBuyQty
int
`json:"min_buy_qty"`
Stock
int
`json:"stock"`
Sales
int
`json:"sales"`
FeedbackRate
int
`json:"feedback_rate"`
Sn
string
`json:"sn"`
Code
string
`json:"code"`
IsNew
int
`json:"is_new"`
IsRecommend
int
`json:"is_recommend"`
IsHot
int
`json:"is_hot"`
IsPromotion
int
`json:"is_promotion"`
IsDisplay
int
`json:"is_display"`
StatusLock
int
`json:"status_lock"`
SingleOption
int
`json:"single_option"`
Desc
string
`json:"desc"`
ImageUrl
string
`json:"image_url"`
VideoUrl
string
`json:"video_url"`
Unit
string
`json:"unit"`
Barcode
string
`json:"barcode"`
Long
int
`json:"long"`
Wide
int
`json:"wide"`
High
int
`json:"high"`
Volume
int
`json:"volume"`
Freight
int
`json:"freight"`
FreightType
int
`json:"freight_type"`
MaxPrice
int
`json:"maxPrice"`
MinPrice
int
`json:"minPrice"`
MaxCostPrice
int
`json:"maxCostPrice"`
MinCostPrice
int
`json:"minCostPrice"`
MaxOriginPrice
int
`json:"maxOriginPrice"`
MinOriginPrice
int
`json:"minOriginPrice"`
Gallery
interface
{}
`json:"gallery"`
Qualifications
interface
{}
`json:"qualifications"`
DetailImages
string
`json:"detail_images"`
Attrs
interface
{}
`json:"attrs"`
Supplier
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
}
`json:"supplier"`
GatherSupply
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
Key
string
`json:"key"`
CategoryId
int
`json:"category_id"`
}
`json:"gather_supply"`
AliProduct
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
ProductId
int
`json:"product_id"`
SkuId
int
`json:"sku_id"`
AliSkuId
string
`json:"ali_sku_id"`
AliProductId
int
`json:"ali_product_id"`
ShopId
string
`json:"shop_id"`
}
`json:"ali_product"`
BrandId
int
`json:"brand_id"`
Brand
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
Name
string
`json:"name"`
}
`json:"brand"`
SupplierId
int
`json:"supplier_id"`
GatherSupplyId
int
`json:"gather_supply_id"`
Category1Id
int
`json:"category1_id"`
Category2Id
int
`json:"category2_id"`
Category3Id
int
`json:"category3_id"`
FreightTemplateId
int
`json:"freight_template_id"`
Source
int
`json:"source"`
Sort
int
`json:"sort"`
SourceGoodsId
int
`json:"source_goods_id"`
LocationId
int
`json:"location_id"`
Freeze
int
`json:"freeze"`
ShopLevel
int
`json:"shop_level"`
DesLevel
int
`json:"des_level"`
ExpressLevel
int
`json:"express_level"`
Level
int
`json:"level"`
ChildTitle
string
`json:"child_title"`
BillPosition
int
`json:"bill_position"`
Md5
string
`json:"md5"`
TaxCode
string
`json:"tax_code"`
TaxProductName
string
`json:"tax_product_name"`
TaxShortName
string
`json:"tax_short_name"`
TaxOption
string
`json:"tax_option"`
TaxUnit
string
`json:"tax_unit"`
FavorablePolicy
string
`json:"favorable_policy"`
IsFavorablePolicy
int
`json:"is_favorable_policy"`
FreeOfTax
int
`json:"free_of_tax"`
ShortCode
string
`json:"short_code"`
TaxMeasurePrice
int
`json:"tax_measure_price"`
TaxRate
int
`json:"tax_rate"`
IsTaxLogo
int
`json:"is_tax_logo"`
ProductVerify
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
ProductId
int
`json:"product_id"`
SupplierId
int
`json:"supplier_id"`
Status
int
`json:"status"`
IsDisplay
int
`json:"is_display"`
}
`json:"product_verify"`
IsPlugin
int
`json:"is_plugin"`
IsSingleOrder
int
`json:"is_single_order"`
SupplierSourceId
int
`json:"supplier_source_id"`
SupplierSourceCategoryId
int
`json:"supplier_source_category_id"`
}
`json:"product"`
AfterSales
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
AfterSaleSn
string
`json:"after_sale_sn"`
UserId
int
`json:"user_id"`
Amount
int
`json:"amount"`
TechnicalServicesFee
int
`json:"technical_services_fee"`
Freight
int
`json:"freight"`
PracticalAmount
int
`json:"practical_amount"`
ReasonType
int
`json:"reason_type"`
Reason
string
`json:"reason"`
Description
string
`json:"description"`
OrderId
int
`json:"order_id"`
OrderItemId
int
`json:"order_item_id"`
SkuId
int
`json:"sku_id"`
ProductId
int
`json:"product_id"`
ShippingAddressId
int
`json:"shipping_address_id"`
IsReceived
int
`json:"is_received"`
PayMethod
int
`json:"pay_method"`
ReturnOrderExpressId
int
`json:"return_order_express_id"`
Status
int
`json:"status"`
Type
int
`json:"type"`
DetailImages
interface
{}
`json:"detail_images"`
Logs
interface
{}
`json:"logs"`
AfterSalesAudit
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
AfterSalesId
int
`json:"after_sales_id"`
AdminId
int
`json:"admin_id"`
ReasonType
int
`json:"reason_type"`
Reason
string
`json:"reason"`
Status
int
`json:"status"`
Cause
string
`json:"cause"`
StatusName
string
`json:"status_name"`
RefundName
string
`json:"refund_name"`
}
`json:"after_sales_audit"`
ReturnOrderExpress
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
AfterSalesId
int
`json:"after_sales_id"`
CompanyName
string
`json:"company_name"`
CompanyCode
string
`json:"company_code"`
ExpressNo
string
`json:"express_no"`
}
`json:"return_order_express"`
RefundReasonName
string
`json:"refund_reason_name"`
SuccessAt
interface
{}
`json:"success_at"`
StatusName
string
`json:"status_name"`
}
`json:"after_sales"`
}
`json:"order_items"`
OrderExpress
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
OrderId
int
`json:"order_id"`
CompanyCode
string
`json:"company_code"`
ExpressNo
string
`json:"express_no"`
OrderItems
interface
{}
`json:"order_items"`
IsEmpty
int
`json:"is_empty"`
FinalSend
int
`json:"final_send"`
}
`json:"order_express"`
ShippingAddress
struct
{
Id
int
`json:"id"`
Realname
string
`json:"realname"`
Mobile
string
`json:"mobile"`
CountryId
int
`json:"country_id"`
ProvinceId
int
`json:"province_id"`
CityId
int
`json:"city_id"`
CountyId
int
`json:"county_id"`
TownId
int
`json:"town_id"`
Province
string
`json:"province"`
City
string
`json:"city"`
County
string
`json:"county"`
Town
string
`json:"town"`
Detail
string
`json:"detail"`
Lng
string
`json:"lng"`
Lat
string
`json:"lat"`
}
`json:"shipping_address"`
OrderBill
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
Type
int
`json:"type"`
AccountType
int
`json:"account_type"`
PersonName
string
`json:"person_name"`
Mobile
string
`json:"mobile"`
CompanyName
string
`json:"company_name"`
CompanyCode
string
`json:"company_code"`
Email
string
`json:"email"`
SignAddress
string
`json:"sign_address"`
SignMobile
string
`json:"sign_mobile"`
OpeningBank
string
`json:"opening_bank"`
BankAccount
string
`json:"bank_account"`
DetailType
int
`json:"detail_type"`
Amount
int
`json:"amount"`
AddressId
int
`json:"address_id"`
Applicant
string
`json:"applicant"`
OrderId
int
`json:"order_id"`
BillId
int
`json:"bill_id"`
Status
int
`json:"status"`
Drawer
int
`json:"drawer"`
}
`json:"order_bill"`
TechnologyFeeBill
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
OrderId
int
`json:"order_id"`
BillId
int
`json:"bill_id"`
Amount
int
`json:"amount"`
Status
int
`json:"status"`
}
`json:"technology_fee_bill"`
IsUpdateShippingAddress
int
`json:"is_update_shipping_address"`
IsCps
int
`json:"is_cps"`
}
`json:"Orders"`
}
`json:"data"`
}
// Create 下单
func
(
s
orderLogic
)
Create
(
ctx
context
.
Context
,
req
OrderCreateReq
)
(
res
*
OrderCreateRes
,
err
error
)
{
var
method
=
"/app/order"
result
,
err
:=
post
(
ctx
,
method
,
gconv
.
Map
(
req
))
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
OrderAvailableReq
struct
{
Spu
[]
*
OrderSpu
`json:"spu"`
Address
OrderAddress
`json:"address"`
}
type
OrderAvailableRes
struct
{
Code
int
`json:"code"`
Data
struct
{
Available
[]
int
`json:"available"`
Ban
[]
int
`json:"ban"`
}
`json:"data"`
Msg
string
`json:"msg"`
}
// Available 可售检测
func
(
s
orderLogic
)
Available
(
ctx
context
.
Context
,
req
OrderAvailableReq
)
(
res
*
OrderAvailableRes
,
err
error
)
{
var
method
=
"/app/order/availableCheck"
result
,
err
:=
post
(
ctx
,
method
,
gconv
.
Map
(
req
))
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
OrderDetailRes
struct
{
CommonRes
Data
struct
{
Read
struct
{
Id
int
`json:"id"`
CreatedAt
int
`json:"created_at"`
UpdatedAt
int
`json:"updated_at"`
OrderSn
int64
`json:"order_sn"`
Status
int
`json:"status"`
StatusName
string
`json:"status_name"`
Title
string
`json:"title"`
Freight
int
`json:"freight"`
Amount
int
`json:"amount"`
ItemAmount
int
`json:"item_amount"`
TechnicalServicesFee
int
`json:"technical_services_fee"`
Remark
string
`json:"remark"`
Note
string
`json:"note"`
GoodsCount
int
`json:"goods_count"`
UserId
int
`json:"user_id"`
ShippingAddressId
int
`json:"shipping_address_id"`
ShippingMethod
string
`json:"shipping_method"`
ShippingMethodId
int
`json:"shipping_method_id"`
CommentStatus
int
`json:"comment_status"`
OrderItems
[]
struct
{
Id
int
`json:"id"`
OrderId
int
`json:"order_id"`
Title
string
`json:"title"`
SkuTitle
string
`json:"sku_title"`
Unit
string
`json:"unit"`
Qty
int
`json:"qty"`
Amount
int
`json:"amount"`
Price
int
`json:"price"`
ImageUrl
string
`json:"image_url"`
ProductId
int
`json:"product_id"`
SupplyAmount
int
`json:"supply_amount"`
SkuId
int
`json:"sku_id"`
OrderExpressId
int
`json:"order_express_id"`
CommentStatus
int
`json:"comment_status"`
Options
[]
struct
{
SpecName
string
`json:"spec_name"`
SpecItemName
string
`json:"spec_item_name"`
}
`json:"options"`
}
`json:"order_items"`
OrderExpress
[]
interface
{}
`json:"order_express"`
ShippingAddress
struct
{
Id
int
`json:"id"`
Realname
string
`json:"realname"`
Mobile
string
`json:"mobile"`
CountryId
int
`json:"country_id"`
ProvinceId
int
`json:"province_id"`
CityId
int
`json:"city_id"`
CountyId
int
`json:"county_id"`
TownId
int
`json:"town_id"`
Province
string
`json:"province"`
City
string
`json:"city"`
County
string
`json:"county"`
Town
string
`json:"town"`
Detail
string
`json:"detail"`
Lng
string
`json:"lng"`
Lat
string
`json:"lat"`
}
`json:"shipping_address"`
User
struct
{
Id
int
`json:"id"`
CreatedAt
int
`json:"created_at"`
UpdatedAt
int
`json:"updated_at"`
Mobile
string
`json:"mobile"`
Avatar
string
`json:"avatar"`
Username
string
`json:"username"`
Nickname
string
`json:"nickname"`
Status
int
`json:"status"`
Uuid
string
`json:"uuid"`
LevelId
int
`json:"level_id"`
ParentId
int
`json:"parent_id"`
QrCode
string
`json:"qr_code"`
InviteCode
string
`json:"invite_code"`
WxUsername
string
`json:"wx_username"`
UserLevel
struct
{
Id
int
`json:"id"`
CreatedAt
interface
{}
`json:"created_at"`
UpdatedAt
interface
{}
`json:"updated_at"`
Discount
int
`json:"discount"`
Name
string
`json:"name"`
}
`json:"user_level"`
}
`json:"user"`
AmountDetail
struct
{
Title
string
`json:"title"`
Amount
int
`json:"amount"`
Qty
int
`json:"qty"`
Desc
string
`json:"desc"`
AmountItems
[]
struct
{
Title
string
`json:"title"`
Amount
int
`json:"amount"`
Qty
int
`json:"qty"`
Desc
string
`json:"desc"`
AmountItems
interface
{}
`json:"amount_items"`
}
`json:"amount_items"`
}
`json:"amount_detail"`
PaidAt
int
`json:"paid_at"`
SentAt
interface
{}
`json:"sent_at"`
ReceivedAt
interface
{}
`json:"received_at"`
ClosedAt
interface
{}
`json:"closed_at"`
Button
[]
struct
{
Title
string
`json:"title"`
Url
string
`json:"url"`
}
`json:"button"`
}
`json:"read"`
}
`json:"data"`
}
func
(
s
orderLogic
)
Detail
(
ctx
context
.
Context
,
req
string
)
(
res
*
OrderDetailRes
,
err
error
)
{
var
method
=
"/app/order/orderDetail"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"order_sn"
:
req
,
})
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
This diff is collapsed.
Click to expand it.
upstream/yunzmall/yunzmall_refund.go
0 → 100644
浏览文件 @
255d9542
package
yunzmall
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type
refundLogic
struct
{
}
var
Refund
=
refundLogic
{}
type
RefundBeforeRes
struct
{
CommonRes
Data
map
[
string
]
string
`json:"data"`
}
func
(
s
refundLogic
)
Before
(
ctx
context
.
Context
,
req
string
)
(
res
*
RefundBeforeRes
,
err
error
)
{
var
method
=
"/app/afterSales/getAfterSalesTypeNameMap"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"order_item_id"
:
req
,
})
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
RefundDetailRes
struct
{
CommonRes
Data
struct
{
Id
int
`json:"id"`
Contacts
string
`json:"contacts"`
Tel
string
`json:"tel"`
Plane
string
`json:"plane"`
Country
string
`json:"country"`
Province
int
`json:"province"`
City
int
`json:"city"`
District
int
`json:"district"`
Address
string
`json:"address"`
AddressType
[]
string
`json:"address_type"`
IsDefault
int
`json:"is_default"`
SupplierId
int
`json:"supplier_id"`
ProvinceName
struct
{
Id
int
`json:"id"`
ParentId
int
`json:"parent_id"`
Name
string
`json:"name"`
Level
int
`json:"level"`
}
`json:"province_name"`
CityName
struct
{
Id
int
`json:"id"`
ParentId
int
`json:"parent_id"`
Name
string
`json:"name"`
Level
int
`json:"level"`
}
`json:"city_name"`
DistrictName
struct
{
Id
int
`json:"id"`
ParentId
int
`json:"parent_id"`
Name
string
`json:"name"`
Level
int
`json:"level"`
}
`json:"district_name"`
Supplier
struct
{
Id
int
`json:"id"`
Name
string
`json:"name"`
Supplier
string
`json:"supplier"`
}
`json:"supplier"`
}
`json:"data"`
}
// Detail 详情
func
(
s
refundLogic
)
Detail
(
ctx
context
.
Context
,
req
string
)
(
res
*
RefundDetailRes
,
err
error
)
{
var
method
=
"/app/supplier/findShopAddressByOrderId"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"after_sales_id"
:
req
,
})
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
// Reason 售后原因
func
(
s
refundLogic
)
Reason
(
ctx
context
.
Context
,
afterSaleType
,
isReceived
int
)
(
res
*
RefundDetailRes
,
err
error
)
{
var
method
=
"/app/afterSales/reason/list"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"after_sale_type"
:
afterSaleType
,
"is_received"
:
isReceived
,
})
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
RefundCreateReq
struct
{
OrderId
int
`json:"order_id,omitempty"`
//订单id
ThirdOrderSn
string
`json:"third_order_sn,omitempty"`
//采购端订单号
OrderItemId
int
`json:"order_item_id"`
//子订单id
ReasonType
int
`json:"reason_type"`
//售后原因
Description
string
`json:"description"`
//描述
Reason
string
`json:"reason"`
//售后原因是 其他的的时候填写
RefundType
int
`json:"refund_type"`
//退款还是退货退款
IsReceived
int
`json:"is_received"`
//是否收到货 1是0否
DetailImages
[]
string
`json:"detail_images,omitempty"`
//图片凭证
RefundWay
int
`json:"refund_way,omitempty"`
//退款方式
Num
int
`json:"num"`
//退款商品个数
BarterSkuId
int
`json:"barter_sku_id,omitempty"`
//换货中台规格id
BarterNum
int
`json:"barter_num,omitempty"`
//换货数量
}
type
RefundCreateRes
struct
{
CommonRes
Data
int
`json:"data"`
}
// Create 申请售后
func
(
s
refundLogic
)
Create
(
ctx
context
.
Context
,
req
RefundCreateReq
)
(
res
*
RefundCreateRes
,
err
error
)
{
var
method
=
"/app/afterSales/create"
result
,
err
:=
post
(
ctx
,
method
,
gconv
.
Map
(
req
))
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
This diff is collapsed.
Click to expand it.
upstream/yunzmall/yunzmall_storage.go
0 → 100644
浏览文件 @
255d9542
package
yunzmall
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type
storageLogic
struct
{
}
var
Storage
=
storageLogic
{}
// Add 添加选品库商品
func
(
s
storageLogic
)
Add
(
ctx
context
.
Context
,
req
interface
{})
(
res
*
CommonRes
,
err
error
)
{
var
method
=
"/app/product/storage/addStorage"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"ids"
:
gconv
.
Ints
(
req
),
})
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
// Delete 删除选品库商品
func
(
s
storageLogic
)
Delete
(
ctx
context
.
Context
,
req
interface
{})
(
res
*
CommonRes
,
err
error
)
{
var
method
=
"/app/product/storage/deleteStorage"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"ids"
:
gconv
.
Ints
(
req
),
})
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
This diff is collapsed.
Click to expand it.
upstream/yunzmall/yunzmall_token.go
0 → 100644
浏览文件 @
255d9542
package
yunzmall
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/errors/gerror"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
)
type
tokenLogic
struct
{
}
var
Token
=
tokenLogic
{}
type
TokenGetRes
struct
{
Code
int
`json:"code"`
Data
struct
{
Token
string
`json:"token"`
ExpiresAt
int64
`json:"expiresAt"`
}
`json:"data"`
Msg
string
`json:"msg"`
}
func
(
s
tokenLogic
)
Get
(
ctx
context
.
Context
)
(
res
*
TokenGetRes
,
err
error
)
{
var
method
=
"/app/application/getToken"
result
,
err
:=
post
(
ctx
,
method
,
g
.
Map
{
"app_key"
:
server
.
AppKey
,
"app_secret"
:
server
.
AppSecret
,
},
true
)
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
if
err
!=
nil
{
return
}
return
}
func
(
s
tokenLogic
)
Refresh
(
ctx
context
.
Context
)
(
res
string
,
err
error
)
{
var
conn
=
g
.
Redis
()
.
Conn
()
defer
func
()
{
_
=
conn
.
Close
()
}()
_
,
_
=
conn
.
DoVar
(
"SELECT"
,
server
.
DB
)
var
result
*
TokenGetRes
result
,
err
=
s
.
Get
(
ctx
)
if
err
!=
nil
{
err
=
gerror
.
New
(
"获取token失败"
)
return
}
if
result
.
Code
!=
0
{
err
=
gerror
.
New
(
"获取token失败"
)
return
}
res
=
result
.
Data
.
Token
_
,
_
=
conn
.
Do
(
"HMSET"
,
CacheKey
,
"Token"
,
result
.
Data
.
Token
,
"ExpiresAt"
,
result
.
Data
.
ExpiresAt
)
return
}
type
TokenCacheRes
struct
{
Token
string
ExpiresAt
int64
}
func
(
s
tokenLogic
)
Access
(
ctx
context
.
Context
)
(
res
string
,
err
error
)
{
var
conn
=
g
.
Redis
()
.
Conn
()
defer
func
()
{
_
=
conn
.
Close
()
}()
_
,
_
=
conn
.
DoVar
(
"SELECT"
,
server
.
DB
)
cache
,
_
:=
conn
.
DoVar
(
"HGETALL"
,
CacheKey
)
g
.
Log
()
.
Line
(
true
)
.
Info
(
cache
.
String
())
if
cache
.
IsEmpty
()
{
return
s
.
Refresh
(
ctx
)
}
var
cacheRes
*
TokenCacheRes
_
=
gjson
.
New
(
cache
)
.
Scan
(
&
cacheRes
)
if
cacheRes
.
ExpiresAt
<
gtime
.
TimestampMilli
()
{
return
s
.
Refresh
(
ctx
)
}
res
=
cacheRes
.
Token
return
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论