1
This commit is contained in:
69
controllers/recharge_callback.go
Normal file
69
controllers/recharge_callback.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
beego "github.com/astaxie/beego/adapter"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type RechargeController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
type CallBackMsg struct {
|
||||
Sign string `json:"sign"` // 签名:大写( md5( md5(密码)+ 平台订单号+秘钥 ) )
|
||||
Msg string `json:"msg"` // 响应结果描述
|
||||
OrderNumber string `json:"order_number "` // 平台订单号
|
||||
UserOrdernum string `json:"user_ordernum"` // 商户订单号
|
||||
OrderStatus string `json:"order_status"` // 状态:0:未提交,1:充值中,2:已充值,-1:失败
|
||||
Mobile string `json:"mobile"` // 电话
|
||||
Ctime string `json:"ctime"` // ctime
|
||||
Voucher string `json:"voucher"` // 透传流水号
|
||||
}
|
||||
|
||||
func (c *RechargeController) Msg() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
data, err := ioutil.ReadAll(getUsefulRequest2(c.Ctx).Body)
|
||||
if err != nil {
|
||||
c.Abort("404")
|
||||
return
|
||||
}
|
||||
values, err := utils.HTTPBody2Values(data, false)
|
||||
if err != nil {
|
||||
c.Abort("404")
|
||||
return
|
||||
}
|
||||
mapData := utils.URLValues2Map(values)
|
||||
resultData := CallBackMsg{}
|
||||
if err := utils.Map2StructByJson(mapData, &resultData, false); err != nil {
|
||||
c.Abort("404")
|
||||
return
|
||||
}
|
||||
|
||||
if resultData.OrderStatus == "0" || resultData.OrderStatus == "1" {
|
||||
c.Data["json"] = "success"
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
// 获取平台订单
|
||||
order := &model.Order{
|
||||
OrderID: resultData.UserOrdernum,
|
||||
}
|
||||
if err = dao.GetEntity(dao.GetDB(), order, "OrderID"); err != nil {
|
||||
globals.SugarLogger.Debugf("本地加载订单错误,请查询:%s", err)
|
||||
c.Abort("404")
|
||||
return
|
||||
}
|
||||
order.RechargeStatus = utils.Str2Int(resultData.OrderStatus)
|
||||
|
||||
dao.UpdateEntity(dao.GetDB(), order, "RechargeStatus")
|
||||
c.Data["json"] = "success"
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
c.Abort("404")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user