Merge branch 'sdk' into online
This commit is contained in:
commit
95d889cf58
@ -23,6 +23,7 @@ import (
|
|||||||
proto "server/msg"
|
proto "server/msg"
|
||||||
"server/pkg/github.com/name5566/leaf/log"
|
"server/pkg/github.com/name5566/leaf/log"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 处理玩家异步请求
|
// 处理玩家异步请求
|
||||||
@ -420,6 +421,11 @@ func GoogleVerify(p *Player, OrderSn, ProduceId, Token string) (*db.SqlChargeOrd
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// 将输出转换为字符串
|
||||||
|
outputStr := string(output)
|
||||||
|
|
||||||
|
// 替换单引号为双引号
|
||||||
|
outputStr = strings.Replace(outputStr, "'", "\"", -1)
|
||||||
type VerifyData struct {
|
type VerifyData struct {
|
||||||
PurchaseState int `json:"purchaseState"`
|
PurchaseState int `json:"purchaseState"`
|
||||||
DeveloperPayload string `json:"developerPayload"`
|
DeveloperPayload string `json:"developerPayload"`
|
||||||
@ -427,7 +433,14 @@ func GoogleVerify(p *Player, OrderSn, ProduceId, Token string) (*db.SqlChargeOrd
|
|||||||
ConsumptionState int `json:"consumptionState"`
|
ConsumptionState int `json:"consumptionState"`
|
||||||
}
|
}
|
||||||
r := &VerifyData{}
|
r := &VerifyData{}
|
||||||
json.Unmarshal(output, r)
|
err = json.Unmarshal([]byte(outputStr), &r)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("output %s", string(output))
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if r.DeveloperPayload != OrderSn {
|
||||||
|
return nil, fmt.Errorf("订单号不匹配")
|
||||||
|
}
|
||||||
if r.ConsumptionState != 1 {
|
if r.ConsumptionState != 1 {
|
||||||
return nil, fmt.Errorf("订单未消费")
|
return nil, fmt.Errorf("订单未消费")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
"server/conf"
|
"server/conf"
|
||||||
"server/db"
|
"server/db"
|
||||||
"server/msg"
|
"server/msg"
|
||||||
|
"server/pkg/github.com/name5566/leaf/log"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,9 +22,15 @@ func TriggerShippingOrder(player *Player, req *msg.ReqShippingOrder) {
|
|||||||
}
|
}
|
||||||
OrderData := &db.SqlChargeOrderStruct{}
|
OrderData := &db.SqlChargeOrderStruct{}
|
||||||
var err error
|
var err error
|
||||||
|
n := 0
|
||||||
for {
|
for {
|
||||||
|
n++
|
||||||
|
if n > 5 {
|
||||||
|
break
|
||||||
|
}
|
||||||
OrderData, err = GoogleVerify(player, OrderSn, req.ProduceId, req.Token)
|
OrderData, err = GoogleVerify(player, OrderSn, req.ProduceId, req.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug("GoogleVerify err:%v", err)
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -34,7 +41,12 @@ func TriggerShippingOrder(player *Player, req *msg.ReqShippingOrder) {
|
|||||||
if OrderData.PayStatus == MergeConst.ORDER_STATUS_PAY {
|
if OrderData.PayStatus == MergeConst.ORDER_STATUS_PAY {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if OrderData == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Debug("[order verify success] Uid:%d;OrderSn:%s;PayOrder:%s;", player.M_DwUin, OrderData.OrderId, OrderData.PayChannelOrderId)
|
||||||
player.lock.Lock()
|
player.lock.Lock()
|
||||||
defer player.lock.Unlock()
|
defer player.lock.Unlock()
|
||||||
Charge(player, int(OrderData.ProductId))
|
Charge(player, int(OrderData.ProductId))
|
||||||
@ -53,4 +65,5 @@ func TriggerShippingOrder(player *Player, req *msg.ReqShippingOrder) {
|
|||||||
"PayType": OrderData.PayType,
|
"PayType": OrderData.PayType,
|
||||||
}
|
}
|
||||||
player.Kafka("pay", orderDataMap)
|
player.Kafka("pay", orderDataMap)
|
||||||
|
player.SendClientRes()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user