forked from panjjo/ppp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
235 lines (204 loc) · 4.91 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package ppp
import (
"gopkg.in/mgo.v2/bson"
)
type Status int
const (
Succ = 0 //成功
AuthErr = 9001 //授权错误
AuthErrNotSigned = 9002 //未签约
SysErrParams = 1001 //参数错误
SysErrVerify = 1002 //验签错误
PayErr = 2000 //支付失败
PayErrPayed = 2001 //重复支付
PayErrCode = 2002 //支付码无效
TradeErr = 3000 //交易错误
TradeErrNotFound = 3001 //交易不存在
TradeErrStatus = 3002 //交易状态错误
RefundErr = 4000 //退款错误
RefundErrAmount = 4001 //退款金额错误
RefundErrExpire = 4002 //退款以超期
TradeQueryErr = 5000 //查询失败
UserErrBalance = 6001 //账户余额错误
UserErrRegisted = 6002 //账户已存在
UserErrNotFount = 6003 //账户不存在
TradeStatusWaitPay Status = 0 //未支付
TradeStatusClose Status = -1 //取消/退款
TradeStatusRefund Status = -2 //取消/退款
TradeStatusSucc Status = 1 //成功结束
UserWaitVerify Status = 0 //等待审核或等待授权签约
UserFreeze Status = -1 //冻结
UserSucc Status = 1 //正常
AuthStatusSucc Status = 1
AuthStatusWaitSigned Status = 0
APPPAYPARAMS string = "APP"
WAPPAYPARAMS string = "WAP"
JSPAYPARAMS string = "JS"
)
const (
PAYTYPE_ALIPAY = "alipay"
PAYTYPE_WXPAY = "wxpay"
PAYTYPE_WXPAYSG = "wxpaysg"
PAYTYPE_PPP = "ppp"
)
type rsys struct {
retry int
time int64
mchid string
}
//条码支付请求
type BarCodePayRequest struct {
OutTradeId string //商户交易ID 唯一
TradeName string //名称
Amount int64 //交易总额,单位分
ItemDes string //商品表述
AuthCode string //授权码
UserId string //收款方对应的userid
ShopId string //店铺ID
IPAddr string
r rsys
}
//网页支付请求参数
type WapPayRequest struct {
ReturnUrl string //回调地址,非异步通知地址
OutTradeId string //商户交易ID 唯一
TradeName string //名称
Amount int64 //交易总额,单位分
ItemDes string //商品表述
ShopId string //店铺ID
Ex string //共用回传参数
UserId string
IPAddr string
Scene Scene //场景
r rsys
OpenId string //与sub_openid二选一 公众号支付必传,openid为在服务商公众号的id
SubOpenId string //与openid 二选一 公众号支付必传,sub_openid为在子商户公众号的id
TradeType string //订单类型,网页支付公众号支付:JSAPI,扫码支付:NATIVE,app支付:APP
}
type Scene struct {
//详情看wxpay的统一下单中的scene
Url string //请求地址
Name string //请求名称
}
//支付单详情
type TradeRequest struct {
OutTradeId string //交易ID
TradeId string //第三方交易ID
UserId string //权限对应的UserId
DisSync bool //是否禁用同步
r rsys
}
//支付单详情
type Trade struct {
TradeId string //第三方ID
OutTradeId string //自定义ID
Status Status //1:完成, -1:取消
Type int //1:入账,-1:出账
Amount int64
Source string // alipay,wxpay
ParentId string //来源主ID
PayTime int64
UpTime int64
Ex interface{}
Id string // PPPID
Memo string
}
//支付单返回
type TradeResult struct {
Data Trade
SourceData string
Code int
}
//退款请求
type RefundRequest struct {
Memo string
Amount int64
OutTradeId string
TradeId string
RefundId string
OutRefundId string
UserId string
r rsys
}
//刷新token
type Token struct {
Code string //获取时需要传入兑换码"`
MchId string //微信使
refresh bool
r rsys
}
//授权
type authBase struct {
Id string
Token string
ExAt int64 //token失效日期
ReToken string //refresh_token
Status Status
MchId string
Type string
Account string
AppId string //微信子商户appid
}
type Auth struct {
Id string
MchId string
Type string
Status Status
}
type AuthRequest struct {
Id string
MchId string
Status Status
Account string
AppId string //微信子商户公众号Appid
}
type AuthResult struct {
Data Auth
SourceData string
Code int
}
//账户
type User struct {
Id string
UserId string //外部用户id
MchId string //第三方id
Status Status
Amount int64 //账户余额
Type string
}
//用户返回
type AccountResult struct {
Data User
SourceData string
Code int
}
//用户授权
type AccountAuth struct {
UserId string
MchId string
Type string
}
//通用返回
type Response struct {
SourceData string
Code int
}
//列表查询
type ListRequest struct {
Query bson.M
Skip, Limit int
Sort string
r rsys
}
//总数返回
type CountResult struct {
Data int
Code int
SourceData string
}
//对账单列表
type TradeListResult struct {
Code int
Data []Trade
SourceData string
}