Browse Source

bug: 30s timeout

master
黄梓健 5 years ago
parent
commit
84744f50ad
  1. 2
      models/customer_order.go
  2. 13
      services/pay/handle.go

2
models/customer_order.go

@ -89,7 +89,7 @@ func (t *CustomerOrder) UpdateStatusBy(outTradeNo string, originStatus, status i
func GetExpiredAtLiveCustomerOrder() ([]*CustomerOrder, error) { func GetExpiredAtLiveCustomerOrder() ([]*CustomerOrder, error) {
orders := make([]*CustomerOrder, 0) orders := make([]*CustomerOrder, 0)
err := core.GetXormAuto().Where("type=1 and is_delete=0 and status=0 and expire_time <= ?", time.Now()).Find(&orders)
err := core.GetXormAuto().Where("type=1 and is_delete=0 and status=0 and expire_time <= ?", time.Now().Unix()).Find(&orders)
if err != nil { if err != nil {
return nil, err return nil, err
} }

13
services/pay/handle.go

@ -8,6 +8,7 @@ import (
"hudongzhuanjia/models" "hudongzhuanjia/models"
"hudongzhuanjia/services/im" "hudongzhuanjia/services/im"
"hudongzhuanjia/utils" "hudongzhuanjia/utils"
"hudongzhuanjia/utils/define"
"time" "time"
) )
@ -167,10 +168,16 @@ func HandleGoodOrder() error {
if v.Type != 1 || v.Status != 0 { if v.Type != 1 || v.Status != 0 {
continue continue
} }
_, err := OrderQuery(v.OutTradeNo)
if err == nil {
continue
res, err := OrderQuery(v.OutTradeNo)
if err != nil {
err = fmt.Errorf("订单查询出现错误: %v, out_trade_no: %v", err, v.OutTradeNo)
return err
} }
if res["trade_state"] != define.CODE_TRADE_NOTPAY {
err = fmt.Errorf("订单非未支付订单: %v, out_trade_no: %v", res["trade_state"], v.OutTradeNo)
return err
}
err = Close(v.OutTradeNo) err = Close(v.OutTradeNo)
if err != nil { if err != nil {
return err return err

Loading…
Cancel
Save