diff --git a/models/customer_order.go b/models/customer_order.go index f5180c0..343e203 100644 --- a/models/customer_order.go +++ b/models/customer_order.go @@ -89,7 +89,7 @@ func (t *CustomerOrder) UpdateStatusBy(outTradeNo string, originStatus, status i func GetExpiredAtLiveCustomerOrder() ([]*CustomerOrder, error) { 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 { return nil, err } diff --git a/services/pay/handle.go b/services/pay/handle.go index 5b0f3a5..6a025b0 100644 --- a/services/pay/handle.go +++ b/services/pay/handle.go @@ -8,6 +8,7 @@ import ( "hudongzhuanjia/models" "hudongzhuanjia/services/im" "hudongzhuanjia/utils" + "hudongzhuanjia/utils/define" "time" ) @@ -167,10 +168,16 @@ func HandleGoodOrder() error { if v.Type != 1 || v.Status != 0 { 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) if err != nil { return err