ljl 4 months ago
parent c38d4683d3
commit 4bf949e748

@ -131,7 +131,35 @@ func Revoke(c *gin.Context) {
return return
} }
fmt.Println(param) revokeData := zking.RevokeCallbackData{}
err = json.Unmarshal([]byte(param.Data), &revokeData)
if err != nil {
fmt.Println(err.Error())
result["code"] = 201
result["msg"] = "data异常"
c.JSON(200, result)
return
}
global.DB.Model(&model.Revoke{}).Where("policy_no", revokeData.PolicyNo).UpdateColumns(model.Revoke{Status: revokeData.Status, Msg: revokeData.Msg})
fmt.Println("revokeData", revokeData)
callbackParam := suixing.RevokeCallbackParam{}
callbackParam.AppID = global.Config.Suixing.AppID
callbackParam.RequestID = utils.GenerateNo("requestId")
callbackParam.Version = "1.0.0"
callbackParam.Timestamp = strconv.Itoa(int(time.Now().Unix()))
callbackData := suixing.RevokeCallbackData{
PolicyNo: revokeData.PolicyNo,
Msg: revokeData.Msg,
Status: revokeData.Status,
}
callbackParam.Data = callbackData
callbackRet, err := suixing.SuixingApi.RevokeCallback(callbackParam)
fmt.Println(callbackRet)
c.JSON(200, result)
return
} }
func Claim(c *gin.Context) { func Claim(c *gin.Context) {
@ -152,4 +180,34 @@ func Claim(c *gin.Context) {
return return
} }
fmt.Println(param) fmt.Println(param)
claimData := zking.ClaimCallbackData{}
err = json.Unmarshal([]byte(param.Data), &claimData)
if err != nil {
fmt.Println(err.Error())
result["code"] = 201
result["msg"] = "data异常"
c.JSON(200, result)
return
}
global.DB.Model(&model.Claim{}).Where("policy_no", claimData.PolicyNo).UpdateColumns(model.Claim{Status: claimData.Status, Msg: claimData.Msg})
fmt.Println("claimData", claimData)
callbackParam := suixing.ClaimCallbackParam{}
callbackParam.AppID = global.Config.Suixing.AppID
callbackParam.RequestID = utils.GenerateNo("requestId")
callbackParam.Version = "1.0.0"
callbackParam.Timestamp = strconv.Itoa(int(time.Now().Unix()))
callbackData := suixing.ClaimCallbackData{
PolicyNo: claimData.PolicyNo,
Msg: claimData.Msg,
Status: claimData.Status,
}
callbackParam.Data = callbackData
callbackRet, err := suixing.SuixingApi.ClaimCallback(callbackParam)
fmt.Println(callbackRet)
c.JSON(200, result)
return
} }

@ -41,6 +41,52 @@ func (api *suixingApi) CreateOrderCallback(param CreateCallbackParam) (*Result,
return &result, nil return &result, nil
} }
func (api *suixingApi) ClaimCallback(param ClaimCallbackParam) (*Result, error) {
paramBytes, err := json.Marshal(param)
if err != nil {
return nil, err
}
dataRet := gjson.Get(string(paramBytes), "data")
err = api.Sign(&param.CommonParam, dataRet.String())
if err != nil {
return nil, err
}
res, err := api.post("/CallBack/claimGuarantee", param)
if err != nil {
return nil, err
}
result := Result{}
err = json.Unmarshal(res, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func (api *suixingApi) RevokeCallback(param RevokeCallbackParam) (*Result, error) {
paramBytes, err := json.Marshal(param)
if err != nil {
return nil, err
}
dataRet := gjson.Get(string(paramBytes), "data")
err = api.Sign(&param.CommonParam, dataRet.String())
if err != nil {
return nil, err
}
res, err := api.post("/CallBack/revokeGuarantee", param)
if err != nil {
return nil, err
}
result := Result{}
err = json.Unmarshal(res, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func (api *suixingApi) Sign(param *CommonParam, data string) error { func (api *suixingApi) Sign(param *CommonParam, data string) error {
//vals, err := utils.StructToURLValues(param) //vals, err := utils.StructToURLValues(param)
fmt.Println("data: " + data) fmt.Println("data: " + data)

@ -0,0 +1,7 @@
package suixing
type ClaimCallbackData struct {
PolicyNo string `json:"policyNo" form:"policyNo"`
Status string `json:"status" form:"status"`
Msg string `json:"msg" form:"msg"`
}

@ -0,0 +1,6 @@
package suixing
type ClaimCallbackParam struct {
CommonParam
Data ClaimCallbackData `json:"data" form:"data"`
}

@ -0,0 +1,7 @@
package suixing
type RevokeCallbackData struct {
PolicyNo string `json:"policyNo" form:"policyNo"`
Status string `json:"status" form:"status"`
Msg string `json:"msg" form:"msg"`
}

@ -0,0 +1,6 @@
package suixing
type RevokeCallbackParam struct {
CommonParam
Data RevokeCallbackData `json:"data" form:"data"`
}
Loading…
Cancel
Save