冲突解决

This commit is contained in:
苏尹岚
2020-02-04 17:44:17 +08:00
2 changed files with 30 additions and 15 deletions

View File

@@ -32,6 +32,8 @@ const (
sigTypeKey = "sign_type"
sigTypeMd5 = "MD5"
sigTypeSha256 = "HMAC-SHA256"
specialAction = "mmpaymkttransfers/promotion/transfers"
)
const (
@@ -59,9 +61,13 @@ type API struct {
type RequestBase struct {
XMLName xml.Name `json:"-" xml:"xml"`
AppID string `json:"appid" xml:"appid"`
AppID string `json:"appid" xml:"appid,omitempty"`
MchID string `json:"mch_id" xml:"mch_id,omitempty"`
// 企业付款基础参数不一样
AppID2 string `json:"mch_appid,omitempty" xml:"mch_appid,omitempty"`
MchID2 string `json:"mchid,omitempty" xml:"mchid,omitempty"`
DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"`
MchID string `json:"mch_id" xml:"mch_id"`
NonceStr string `json:"nonce_str" xml:"nonce_str"`
Sign string `json:"sign" xml:"sign"`
SignType string `json:"sign_type,omitempty" xml:"sign_type,omitempty"`
@@ -79,19 +85,27 @@ type RequestBase2 struct {
}
type IRequestBase interface {
SetAppID(appID string)
SetMchID(mchID string)
SetAppID(action, appID string)
SetMchID(action, mchID string)
SetNonceStr(nonceStr string)
SetSign(sign string)
SetSignType(signType string)
}
func (r *RequestBase) SetAppID(appID string) {
r.AppID = appID
func (r *RequestBase) SetAppID(action, appID string) {
if action != specialAction {
r.AppID = appID
} else {
r.AppID2 = appID
}
}
func (r *RequestBase) SetMchID(mchID string) {
r.MchID = mchID
func (r *RequestBase) SetMchID(action, mchID string) {
if action != specialAction {
r.MchID = mchID
} else {
r.MchID2 = mchID
}
}
func (r *RequestBase) SetNonceStr(nonceStr string) {
@@ -385,8 +399,8 @@ func mustMarshalXML(obj interface{}) []byte {
}
func (a *API) AccessAPI(action string, requestParam IRequestBase) (retVal map[string]interface{}, err error) {
requestParam.SetAppID(a.appID)
requestParam.SetMchID(a.mchID)
requestParam.SetAppID(action, a.appID)
requestParam.SetMchID(action, a.mchID)
requestParam.SetNonceStr(utils.GetUUID())
sigType := sigTypeSha256
// sigType := sigTypeMd5