This commit is contained in:
邹宗楠
2025-05-06 15:53:24 +08:00
parent c248d8e1d1
commit db1228637c
5 changed files with 50 additions and 38 deletions

View File

@@ -280,3 +280,32 @@ type OnLineOrderRefundResult struct {
Bankcode string `json:"bankcode"` // 所属银行
Sign string `json:"sign"` // 签名
}
// AddTermReq 添加采集设备
type AddTermReq struct {
Orgid string `json:"orgid"` // 集团/代理商商户号 是 共享集团号/代理商参数时必填
Cusid string `json:"cusid"` // 商户号实际交易的商户号 否
Appid string `json:"appid"` // 应用ID平台分配的APPID 否
Version string `json:"version"` // 版本号接口版本号 可
Termno string `json:"termno"` // 8位数字,商户下唯一 否
Devicetype string `json:"devicetype"` // 设备类型 否
Termsn string `json:"termsn"` // 终端序列号 终端类型device_type填写为 02、03、04、05、06、08、09 或 10时必须填写终端序列号。
Operation string `json:"operation"` // 本次操作标识取值范围00新增01修改02注销注销时仅需上送termno字段
Termstate string `json:"termstate"` // 取值范围00启用01注销终端注销时非必填
Termaddress string `json:"termaddress"` // 终端地址
Signtype string `json:"signtype"`
Sign string `json:"sign"`
}
// AddTermQuery 采集设备查询
type AddTermQuery struct {
Orgid string `json:"orgid"` // 集团/代理商商户号 是 共享集团号/代理商参数时必填
Cusid string `json:"cusid"` // 商户号实际交易的商户号 否
Appid string `json:"appid"` // 应用ID平台分配的APPID 否
Version string `json:"version"` // 版本号接口版本号 可
Termno string `json:"termno"` // 8位数字,商户下唯一 否
Signtype string `json:"signtype"`
Sign string `json:"sign"`
Querytype string `json:"querytype"`
}

View File

@@ -35,7 +35,8 @@ const (
OnlinePayUrl = `https://vsp.allinpay.com/apiweb/unitorder/scanqrpay` // 扫码支付
OnLineTransactionQuery = `https://vsp.allinpay.com/apiweb/tranx/query` // 交易查询,查询订单的支付状态
OnLineRefund = `https://vsp.allinpay.com/apiweb/tranx/refund` // 同一退款接口
OnLineAddterm = `https://vsp.allinpay.com/cusapi/merchantapi/addterm` // 添加设备终端
OnLineAddTerm = `https://vsp.allinpay.com/cusapi/merchantapi/addterm` // 添加设备终端
OnLineQuerYTerm = `https://vsp.allinpay.com/cusapi/merchantapi/qryterm` // 查询设备终端
)
const (
@@ -127,7 +128,7 @@ func (a *API) OrderRefund(param *OnLineOrderRefundParam) (statusCode, errRemake
// TLAddTerm 采集门店终端设备信息
func (a *API) TLAddTerm(param *AddTermReq) error {
onlineReq := utils.Struct2Map(param, "", false)
result, err := a.AccessAPI2(OnLineAddterm, onlineReq)
result, err := a.AccessAPI2(OnLineAddTerm, onlineReq)
if err != nil {
return err
}
@@ -137,51 +138,24 @@ func (a *API) TLAddTerm(param *AddTermReq) error {
return nil
}
type AddTermReq struct {
Orgid string `json:"orgid"` // 集团/代理商商户号 是 共享集团号/代理商参数时必填
Cusid string `json:"cusid"` // 商户号实际交易的商户号 否
Appid string `json:"appid"` // 应用ID平台分配的APPID 否
Version string `json:"version"` // 版本号接口版本号 可
Termno string `json:"termno"` // 8位数字,商户下唯一 否
Devicetype string `json:"devicetype"` // 设备类型 否
Termsn string `json:"termsn"` // 终端序列号 终端类型device_type填写为 02、03、04、05、06、08、09 或 10时必须填写终端序列号。
Operation string `json:"operation"` // 本次操作标识取值范围00新增01修改02注销注销时仅需上送termno字段
Termstate string `json:"termstate"` // 取值范围00启用01注销终端注销时非必填
Termaddress string `json:"termaddress"` // 终端地址
Signtype string `json:"signtype"`
Sign string `json:"sign"`
}
// TLQueryTerm 采集门店终端设备信息查询
func (a *API) TLQueryTerm(param *AddTermQuery) error {
func (a *API) TLQueryTerm(param *AddTermQuery) (string, error) {
onlineReq := utils.Struct2Map(param, "", false)
result, err := a.AccessAPI2("https://vsp.allinpay.com/cusapi/merchantapi/qryterm", onlineReq)
result, err := a.AccessAPI2(OnLineQuerYTerm, onlineReq)
if err != nil {
return err
return "", err
}
if result["retcode"].(string) != "SUCCESS" {
return fmt.Errorf(result["retmsg"].(string))
return "", fmt.Errorf(result["retmsg"].(string))
}
return nil
}
type AddTermQuery struct {
Orgid string `json:"orgid"` // 集团/代理商商户号 是 共享集团号/代理商参数时必填
Cusid string `json:"cusid"` // 商户号实际交易的商户号 否
Appid string `json:"appid"` // 应用ID平台分配的APPID 否
Version string `json:"version"` // 版本号接口版本号 可
Termno string `json:"termno"` // 8位数字,商户下唯一 否
Signtype string `json:"signtype"`
Sign string `json:"sign"`
Querytype string `json:"querytype"`
return fmt.Sprintf("微信报备:%s,阿里报备:%s", result["wxmsg"].(string), result["almsg"].(string)), nil
}
func (a *API) AccessAPI2(action string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
params := make(map[string]interface{})
params["appid"] = a.appID
params["cusid"] = a.cusID
if action != OnLineAddterm {
if action != OnLineAddTerm {
params["randomstr"] = utils.GetUUID()
}
params["version"] = "12"