adjust otherorder
This commit is contained in:
parent
ccaea82665
commit
5623c3e4aa
@ -128,7 +128,7 @@ func (iga *InGameApi) PayDone(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
sessionkey := q5.SafeToString(data["session_key"])
|
||||
sessionkey := q5.SafeToString(data["session_key"])
|
||||
|
||||
status := orderModel.Status
|
||||
rspObj := struct {
|
||||
@ -210,7 +210,7 @@ func (iga *InGameApi) ServerPrePurchase(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
sessionkey := q5.SafeToString(data["session_key"])
|
||||
sessionkey := q5.SafeToString(data["session_key"])
|
||||
|
||||
gameid := q5.SafeToInt64(data["gameid"])
|
||||
|
||||
@ -354,7 +354,7 @@ func (iga *InGameApi) OtherOrder(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
sessionkey := q5.SafeToString(data["session_key"])
|
||||
sessionkey := q5.SafeToString(data["session_key"])
|
||||
sessionkeytime := q5.SafeToInt64(data["update_time"])
|
||||
rspObj := struct {
|
||||
ErrorCode int32 `json:"errcode"`
|
||||
@ -379,7 +379,7 @@ func (iga *InGameApi) OtherOrder(c *gin.Context) {
|
||||
|
||||
errcode = service.Wxpay.QueryPay(openid, gameid, userip, sessionkey, int32(balance), order.OrderId)
|
||||
if errcode == constant.WX_ERRCODE_OK {
|
||||
order.GameId = int32(gameid)
|
||||
order.GameId = int32(gameid)
|
||||
order.Channel = q5.SafeToInt32(data["channel"])
|
||||
order.IP = iga.getIP(c)
|
||||
order.Status = 2
|
||||
@ -398,6 +398,10 @@ func (iga *InGameApi) OtherOrder(c *gin.Context) {
|
||||
rspObj.ErrMsg = "invalid session 2"
|
||||
}
|
||||
|
||||
if errcode == constant.WX_ERRCODE_OK {
|
||||
rspObj.Count += model.FindOtherCount(reqJson.AccountId)
|
||||
}
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
||||
@ -450,7 +454,7 @@ func (iga *InGameApi) QueryPay(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (iga *InGameApi) checkSessionData(c *gin.Context, accountId string) (data map[string]interface{}, ret bool){
|
||||
func (iga *InGameApi) checkSessionData(c *gin.Context, accountId string) (data map[string]interface{}, ret bool) {
|
||||
strs := strings.Split(accountId, "_")
|
||||
if len(strs) < 3 {
|
||||
f5.RspErr(c, 401, "params error1")
|
||||
|
@ -72,3 +72,22 @@ func (this *InAppOrder) FindByOrderId(orderId string) (error, bool) {
|
||||
return nil, result.RowsAffected > 0
|
||||
}
|
||||
}
|
||||
|
||||
func FindOtherCount(accountId string) (count int64) {
|
||||
db := f5.GetApp().GetOrmDb(constant.PAY_DB).Table("t_order").Where("account_id = ? and status = 1", accountId).Select("sum(sp_amount)")
|
||||
if db.Error == nil {
|
||||
rowcount := int64(0)
|
||||
if db.Count(&rowcount); rowcount > 0 {
|
||||
db.Scan(&count)
|
||||
}
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
db = f5.GetApp().GetOrmDb(constant.PAY_DB).Table("t_order").Where("account_id = ? and status = 1", accountId).Update("status", 2)
|
||||
if db.Error != nil {
|
||||
count = 0
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user