diff --git a/controller/base/code.go b/controller/base/code.go index e6516e2f35702a7a2229ef33d82e9f18e860de27..60404eba01d6838c6d2ae35e08e4afe5671a36cf 100755 --- a/controller/base/code.go +++ b/controller/base/code.go @@ -6,11 +6,14 @@ package base const ( // Success 请求æˆåŠŸ - Success = 1000 + //Success = 1000 + Success = 0 // ServerError æœåŠ¡å™¨é”™è¯¯ - ServerError = 1100 + //ServerError = 1100 + ServerError = 9 // Warning è¦å‘Š - Warning = 1200 + //Warning = 1200 + Warning = 1 // FailedToObtainVerificationCode 验è¯ç 获å–失败 //FailedToObtainVerificationCode = 1001 @@ -19,7 +22,8 @@ const ( // VerificationCodeError 验è¯ç 错误 //VerificationCodeError = 1003 // AuthorizationEmpty token为空 - AuthorizationEmpty = 1004 + //AuthorizationEmpty = 1004 + AuthorizationEmpty = 4 // ThisAccountDoesNotHavePermission æ¤è´¦å·æ²¡æœ‰æƒé™ //ThisAccountDoesNotHavePermission = 1005 // ParameterValidationFailed 傿•°æ•ˆéªŒå¤±è´¥ diff --git a/controller/base/response.go b/controller/base/response.go index baf64d40aa6d276a98e238f7d16fcf58143c1c30..97061f5b2db653af836c01ddf0985eac3e3dcaeb 100755 --- a/controller/base/response.go +++ b/controller/base/response.go @@ -15,35 +15,61 @@ import ( */ // ResponseData ç»Ÿä¸€è¿”å›žæ•°æ® +//type ResponseData struct { +// Code int `json:"code"` +// Msg interface{} `json:"msg"` +// Data interface{} `json:"data,omitempty"` +//} type ResponseData struct { - Code int `json:"code"` - Msg interface{} `json:"msg"` - Data interface{} `json:"data,omitempty"` + Status int `json:"Status"` + Message interface{} `json:"Message"` + Data interface{} `json:"Data,omitempty"` } // ResponseErrorWithMsg 返回错误 +//func ResponseErrorWithMsg(c *gin.Context, code int) { +// c.JSON(http.StatusOK, &ResponseData{ +// Code: code, +// Msg: InternationalizedMsg(c, code), +// Data: nil, +// }) +//} func ResponseErrorWithMsg(c *gin.Context, code int) { c.JSON(http.StatusOK, &ResponseData{ - Code: code, - Msg: InternationalizedMsg(c, code), + Status: code, + Message: InternationalizedMsg(c, code), Data: nil, }) } // ResponseSuccess 返回æ£ç¡® +//func ResponseSuccess(c *gin.Context, data interface{}) { +// c.JSON(http.StatusOK, &ResponseData{ +// Code: Success, +// Msg: InternationalizedMsg(c, Success), +// Data: data, +// }) +//} func ResponseSuccess(c *gin.Context, data interface{}) { c.JSON(http.StatusOK, &ResponseData{ - Code: Success, - Msg: InternationalizedMsg(c, Success), + Status: Success, + Message: InternationalizedMsg(c, Success), Data: data, }) } // ResponseErrorMsg 直接返回msg +//func ResponseErrorMsg(c *gin.Context, msg string) { +// c.JSON(http.StatusOK, &ResponseData{ +// Code: Warning, +// Msg: msg, +// Data: nil, +// }) +//} func ResponseErrorMsg(c *gin.Context, msg string) { c.JSON(http.StatusOK, &ResponseData{ - Code: Warning, - Msg: msg, + Status: Warning, + Message: msg, Data: nil, }) } \ No newline at end of file diff --git a/repository/pay/pay.go b/repository/pay/pay.go index 38edce10ba6614e8f1ede182fc115f07ae819a91..a07433da8c90f103ec67f0eac197f0f45a0f6d97 100755 --- a/repository/pay/pay.go +++ b/repository/pay/pay.go @@ -18,16 +18,6 @@ import ( "time" ) -func RandomString(n int) string { - var letters = []byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") - result := make([]byte, n) - rand2.Seed(time.Now().Unix()) - for i := range result { - result[i] = letters[rand2.Intn(len(letters))] - } - return string(result) -} - // æ‹‰å¡æ‹‰æ”¯ä»˜ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) { @@ -41,6 +31,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) { //} //rtn := make(map[string]string) + fmt.Println("接å£è¾“入傿•°") + fmt.Println(input) + data := make(map[string]interface{}) data["req_time"] = "20220714160009" data["version"] = "3.0" @@ -64,6 +57,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) { // "extend_info": "自动化测试", // "callback_url": "" + input.NoticeURL = "https://test.pet-dbc.cn/uni/api/repayment/PayCallBack" + input.ReturnURL = "https://test.pet-dbc.cn" + data2 := make(map[string]interface{}) //data2["out_trade_no"] = "FD660E1FAA3A4470933CDEDAE1EC1DUU" data2["out_trade_no"] = RandomString(32) @@ -392,7 +388,6 @@ func lakala_post(url string, data_json []byte) (error, string) { temp2, _ := temp["resp_data"].(map[string]interface{}) if temp2["counter_url"]=="" { - fmt.Println(temp2) return errors.New("æ‹‰å¡æ‹‰è¿”回值「counter_urlã€ä¸ºç©ºé”™è¯¯"), "" } @@ -497,3 +492,14 @@ func genPriKey(privateKey []byte, privateKeyType int64) (*rsa.PrivateKey, error) } return priKey, nil } + +//ç”Ÿäº§éšæœºå—符串 +func RandomString(n int) string { + var letters = []byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") + result := make([]byte, n) + rand2.Seed(time.Now().Unix()) + for i := range result { + result[i] = letters[rand2.Intn(len(letters))] + } + return string(result) +} \ No newline at end of file