- mtps cancel_reason_id is not mandatory,

- fix check mandatory bug.
This commit is contained in:
gazebo
2018-06-29 11:50:45 +08:00
parent 3aac71a84f
commit b10456dffe
2 changed files with 5 additions and 5 deletions

View File

@@ -48,8 +48,8 @@ func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *
} }
for _, valueKey := range []string{"delivery_id", "mt_peisong_id", "order_id"} { for _, valueKey := range []string{"delivery_id", "mt_peisong_id", "order_id"} {
baseapi.SugarLogger.Errorf("Missing mandatory param:%v", valueKey)
if request.FormValue(valueKey) == "" { if request.FormValue(valueKey) == "" {
baseapi.SugarLogger.Errorf("Missing mandatory param:%v", valueKey)
return &CallbackResponse{ return &CallbackResponse{
Code: -1, Code: -1,
} }
@@ -76,7 +76,7 @@ func (a *API) GetOrderCallbackMsg(request *http.Request) (orderMsg *CallbackOrde
Sign: request.FormValue("sign"), Sign: request.FormValue("sign"),
}, },
Status: int(utils.Str2Int64(request.FormValue("status"))), Status: int(utils.Str2Int64(request.FormValue("status"))),
CancelReasonId: int(utils.Str2Int64(request.FormValue("cancel_reason_id"))), CancelReasonId: int(utils.Str2Int64WithDefault(request.FormValue("cancel_reason_id"), 0)),
CancelReason: request.FormValue("cancel_reason"), CancelReason: request.FormValue("cancel_reason"),
} }
return orderMsg, nil return orderMsg, nil

View File

@@ -116,10 +116,10 @@ func Bool2String(value bool) string {
return "false" return "false"
} }
func Str2Int(str string) int { func Str2Int64WithDefault(str string, defValue int64) int64 {
retVal, err := strconv.Atoi(str) retVal, err := strconv.ParseInt(str, 10, 64)
if err != nil { if err != nil {
baseapi.SugarLogger.Errorf("error when convert %s to int", str) return defValue
} }
return retVal return retVal
} }