@ -32,7 +32,7 @@ func UnifiedOrder(content, openId string, fee, goodType, userId, activityId, exp
body [ "nonce_str" ] = nonceStr
body [ "sign_type" ] = pay_core . SignType_MD5
body [ "openid" ] = openId
// body["time_expire"] = pay_core.FormatTime(time.Unix(expireAt, 0))
//body["time_expire"] = pay_core.FormatTime(time.Unix(expireAt, 0))
resp , err := pay . UnifiedOrder ( client , body )
if err != nil {
@ -106,6 +106,8 @@ func ReOrder(outTradeNo string) (map[string]interface{}, error) {
// Notify
type NotifyOrderParam struct {
XMLName struct { } ` xml:"xml" json:"-" `
ReturnCode string ` xml:"return_code,omitempty" json:"return_code,omitempty" `
ReturnMsg string ` xml:"return_msg,omitempty" json:"return_msg,omitempty" `
ResultCode string ` xml:"result_code,omitempty" json:"result_code,omitempty" `
@ -136,26 +138,23 @@ func NotifyOrder(body string) (*models.UserOrder, error) {
err := xml . Unmarshal ( [ ] byte ( body ) , & res )
if err != nil {
err = fmt . Errorf ( "xml unmarsal error:%+v" , err )
logger . Error ( err )
return nil , err
}
if res . ReturnCode != define . CODE_SUCCESS {
err = fmt . Errorf ( "network error, retrun_code: %+v and return_msg: %+v" , res . ReturnCode , res . ReturnMsg )
logger . Error ( err )
return nil , err
}
if res . ResultCode != define . CODE_SUCCESS {
err = fmt . Errorf ( "trade error, result_code: %+v and err_code: %+v and err_desc: %+v" ,
res . ResultCode , res . ErrCode , res . ErrCodeDes )
logger . Error ( err )
return nil , err
}
order := new ( models . UserOrder )
exist , err := order . GetByOutTradeNo ( res . OutTradeNo )
if err = = nil || ! exist {
if err ! = nil || ! exist {
err = fmt . Errorf ( "user order get by out_trade_no: %+v, error: %+v, exist: %+v" , res . OutTradeNo , err , exist )
return nil , err
}
@ -176,11 +175,6 @@ func NotifyOrder(body string) (*models.UserOrder, error) {
}
type OrderQueryResult struct {
Order * models . UserOrder
Query * pay . OrderQueryResponse
}
func OrderQuery ( outTradeNo string ) ( map [ string ] string , error ) {
client , err := Client ( )
if err != nil {
@ -278,6 +272,8 @@ func QueryRefund(outTradeNo string) (*pay.RefundQueryResponse, error) {
}
type NotifyRefundParam struct {
XMLName struct { } ` xml:"xml" json:"-" `
ReturnCode string ` xml:"return_code,omitempty" json:"return_code,omitempty" `
ReturnMsg string ` xml:"return_msg,omitempty" json:"return_msg,omitempty" `
ResultCode string ` xml:"result_code,omitempty" json:"result_code,omitempty" `