-
Notifications
You must be signed in to change notification settings - Fork 0
/
detailquery.go
54 lines (46 loc) · 1.38 KB
/
detailquery.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
/**
* Created by GoLand.
* User: 姜伟
* Date: 2020/1/19 0019
* Time: 18:27
*/
package market
import (
"regexp"
"github.com/a07061625/gompf/mpf/api/alipay"
"github.com/a07061625/gompf/mpf/mpconstant/errorcode"
"github.com/a07061625/gompf/mpf/mperr"
"github.com/valyala/fasthttp"
)
// 查询单个门店信息接口
type detailQuery struct {
alipay.BaseAliPay
shopId string // 门店ID
}
func (dq *detailQuery) SetShopId(shopId string) {
match, _ := regexp.MatchString(`^[0-9]{1,32}$`, shopId)
if match {
dq.shopId = shopId
} else {
panic(mperr.NewAliPayMarket(errorcode.AliPayMarketParam, "门店ID不合法", nil))
}
}
func (dq *detailQuery) SetOpRole(opRole string) {
if (opRole == "MERCHANT") || (opRole == "PROVIDER") {
dq.BizContent["op_role"] = opRole
} else {
panic(mperr.NewAliPayMarket(errorcode.AliPayMarketParam, "操作人角色不合法", nil))
}
}
func (dq *detailQuery) CheckData() (*fasthttp.Client, *fasthttp.Request) {
if len(dq.shopId) == 0 {
panic(mperr.NewAliPayMarket(errorcode.AliPayMarketParam, "门店ID不能为空", nil))
}
dq.BizContent["shop_id"] = dq.shopId
return dq.GetRequest()
}
func NewDetailQuery(appId string) *detailQuery {
dq := &detailQuery{alipay.NewBase(appId), ""}
dq.SetMethod("alipay.offline.market.shop.querydetail")
return dq
}