1
This commit is contained in:
parent
1f0c2cb55c
commit
efc97aca55
@ -6,8 +6,10 @@ import (
|
||||
"game/base/platApi"
|
||||
"game/base/util"
|
||||
"game/config"
|
||||
"game/excel"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func QQPreOrder(w http.ResponseWriter, r *http.Request) {
|
||||
@ -40,8 +42,10 @@ func QQPreOrder(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (srv *PayServer) QQPayCallBack(w http.ResponseWriter, r *http.Request) {
|
||||
var data []byte
|
||||
ret := &platApi.QQPayCallBackRet{}
|
||||
defer func() {
|
||||
log.Info("QQPayCallBack ret:", ret)
|
||||
data, _ := json.Marshal(ret)
|
||||
w.Write(data)
|
||||
}()
|
||||
|
||||
@ -59,22 +63,47 @@ func (srv *PayServer) QQPayCallBack(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
log.Info(" req:", req)
|
||||
|
||||
ok := platApi.QQCallBackVerify(req, r.URL.Path, config.QQAppSecret)
|
||||
if !ok {
|
||||
ret.Code = 1
|
||||
ret.Msg = "签名检验失败"
|
||||
return
|
||||
}
|
||||
|
||||
ret := &platApi.QQPayCallBackRet{}
|
||||
//ret.Code=
|
||||
//ret.Msg =
|
||||
|
||||
log.Info("QQPayCallBack ret:", ret, " req:", req)
|
||||
data, err = json.Marshal(ret)
|
||||
if err != nil {
|
||||
extInfo := strings.Split(req.AppRemark, "-")
|
||||
if len(extInfo) != 3 {
|
||||
ret.Code = 2
|
||||
ret.Msg = "app_remark参数格式错误"
|
||||
return
|
||||
}
|
||||
|
||||
sid := util.StringToInt(extInfo[0])
|
||||
produce := util.StringToUint32(extInfo[1])
|
||||
uid := util.StringToUint64(extInfo[2])
|
||||
|
||||
info := excel.GetPlatformIdById(produce)
|
||||
msg := &RechargeCommonC2SMsg{
|
||||
RoleId: uid,
|
||||
Rmb: float32(info.Money),
|
||||
ChargeYb: info.Money * 10,
|
||||
GiftYb: 0,
|
||||
OrderId: r.FormValue("bill_no"),
|
||||
POrderId: r.FormValue("bill_no"),
|
||||
PlatformIp: r.Header.Get("X-Real_IP"),
|
||||
AttType: info.Type,
|
||||
AttValue: info.Index,
|
||||
}
|
||||
code, _ := srv.DeliverGood(sid, msg)
|
||||
if code == 1 || code == 1002 {
|
||||
ret.Code = 0
|
||||
} else {
|
||||
ret.Code = 3
|
||||
}
|
||||
log.Info("QQCallback DeliverRecv sid:", sid, " Role:", uid, " OrderId:", msg.OrderId, " POrderId:", msg.POrderId,
|
||||
" Money:", info.Money, " produce:", produce, " Code:", ret.Code, " code:", code, " err:", err)
|
||||
|
||||
//TODO 发货
|
||||
//var serverId uint64
|
||||
//var uid uint64
|
||||
|
@ -60,7 +60,7 @@ func QQPrePay(openid string, appid string, zone string, amt string, goodId strin
|
||||
value.Add("amt", amt)
|
||||
value.Add("goodid", goodId)
|
||||
value.Add("good_nun", util.Uint32ToString(goodNum))
|
||||
value.Add("app_remark", appid)
|
||||
value.Add("app_remark", zone + "-" + goodId + "-" + openid)
|
||||
|
||||
billNo, _ := util.NextId()
|
||||
value.Add("bill_no", util.Int64ToString(billNo))
|
||||
|
Loading…
x
Reference in New Issue
Block a user