- mtps cancel_reason_id is not mandatory,
- fix check mandatory bug.
This commit is contained in:
@@ -48,8 +48,8 @@ func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *
|
||||
}
|
||||
|
||||
for _, valueKey := range []string{"delivery_id", "mt_peisong_id", "order_id"} {
|
||||
baseapi.SugarLogger.Errorf("Missing mandatory param:%v", valueKey)
|
||||
if request.FormValue(valueKey) == "" {
|
||||
baseapi.SugarLogger.Errorf("Missing mandatory param:%v", valueKey)
|
||||
return &CallbackResponse{
|
||||
Code: -1,
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (a *API) GetOrderCallbackMsg(request *http.Request) (orderMsg *CallbackOrde
|
||||
Sign: request.FormValue("sign"),
|
||||
},
|
||||
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"),
|
||||
}
|
||||
return orderMsg, nil
|
||||
|
||||
@@ -116,10 +116,10 @@ func Bool2String(value bool) string {
|
||||
return "false"
|
||||
}
|
||||
|
||||
func Str2Int(str string) int {
|
||||
retVal, err := strconv.Atoi(str)
|
||||
func Str2Int64WithDefault(str string, defValue int64) int64 {
|
||||
retVal, err := strconv.ParseInt(str, 10, 64)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("error when convert %s to int", str)
|
||||
return defValue
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user