Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
66acaa6095
|
@ -1,6 +1,7 @@
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/service/repositories"
|
"fusenapi/service/repositories"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
|
@ -68,6 +69,22 @@ func (l *CreateOrderLogic) CreateOrder(req *types.CreateOrderReq, userinfo *auth
|
||||||
// })
|
// })
|
||||||
// }, []interface{}{res.OrderSn})
|
// }, []interface{}{res.OrderSn})
|
||||||
|
|
||||||
|
// 延时任务
|
||||||
|
time.AfterFunc(time.Minute*30, func() {
|
||||||
|
orderSn := res.OrderSn
|
||||||
|
fmt.Println("延时任务: OrderSn--", orderSn)
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
svcCtx := svc.ServiceContext{
|
||||||
|
Config: l.svcCtx.Config,
|
||||||
|
Repositories: l.svcCtx.Repositories,
|
||||||
|
}
|
||||||
|
svcCtx.Repositories.NewOrder.Close(ctx, &repositories.CloseReq{
|
||||||
|
OrderSn: orderSn,
|
||||||
|
Type: 1,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
|
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
|
||||||
"order_sn": res.OrderSn,
|
"order_sn": res.OrderSn,
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"fusenapi/utils/order"
|
"fusenapi/utils/order"
|
||||||
"fusenapi/utils/pay"
|
"fusenapi/utils/pay"
|
||||||
"fusenapi/utils/queue"
|
"fusenapi/utils/queue"
|
||||||
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
|
@ -206,29 +207,32 @@ func (d *defaultOrder) CloseList(ctx context.Context, in *CloseListReq) (res *Cl
|
||||||
logc.Errorf(ctx, "order CloseList failed, err: %v", err)
|
logc.Errorf(ctx, "order CloseList failed, err: %v", err)
|
||||||
return nil, result.Error
|
return nil, result.Error
|
||||||
}
|
}
|
||||||
// for _, orderInfo := range orderList {
|
for _, orderInfo := range orderList {
|
||||||
// var ntime = time.Now().UTC()
|
var ntime = time.Now().UTC()
|
||||||
// var cptime = orderInfo.Ctime.UTC().Add(time.Minute * 30)
|
var cptime = orderInfo.Ctime.UTC().Add(time.Minute * 30)
|
||||||
// var dtime time.Time
|
var dtime time.Duration
|
||||||
// var dd = ntime.Unix() - cptime.Unix()
|
var dd = ntime.Unix() - cptime.Unix()
|
||||||
// if dd > 0 {
|
if dd > 0 {
|
||||||
// dtime = time.Now().Add(time.Second * 0)
|
dtime = time.Second * 0
|
||||||
// } else {
|
} else {
|
||||||
// dtime = time.Now().Add(time.Second * time.Duration(math.Abs(float64(dd))))
|
dtime = time.Second * time.Duration(math.Abs(float64(dd)))
|
||||||
// }
|
}
|
||||||
// if in.Type == 1 {
|
if in.Type == 1 {
|
||||||
// // 延时任务
|
// 延时任务
|
||||||
// d.DelayQueue.AddTask(dtime, constants.QUEUE_NAME_ORDER, func(args ...interface{}) {
|
time.AfterFunc(dtime, func() {
|
||||||
// ctx := context.Background()
|
orderSn := orderInfo.OrderSn
|
||||||
// orderSn := args[0].(string)
|
fmt.Println("延时任务: OrderSn--", orderSn)
|
||||||
// logc.Infof(ctx, "order CloseList, orderSn: %s", orderSn)
|
ctx := context.Background()
|
||||||
// d.Close(ctx, &CloseReq{
|
|
||||||
// OrderSn: orderSn,
|
logc.Infof(ctx, "order CloseList, orderSn: %s", orderSn)
|
||||||
// Type: 1,
|
d.Close(ctx, &CloseReq{
|
||||||
// })
|
OrderSn: *orderSn,
|
||||||
// }, []interface{}{*orderInfo.OrderSn})
|
Type: 1,
|
||||||
// }
|
})
|
||||||
// }
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,8 +690,8 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create
|
||||||
ntimeTimeOut := ntime.Unix()
|
ntimeTimeOut := ntime.Unix()
|
||||||
|
|
||||||
// 测试超时支付不限制
|
// 测试超时支付不限制
|
||||||
//if ctimeTimeOut < ntimeTimeOut {
|
if ctimeTimeOut < ntimeTimeOut {
|
||||||
if ctimeTimeOut == ntimeTimeOut {
|
// if ctimeTimeOut == ntimeTimeOut {
|
||||||
errorCode = *basic.CodeErrOrderCreatePrePaymentTimeout
|
errorCode = *basic.CodeErrOrderCreatePrePaymentTimeout
|
||||||
err = errors.New("order pay timeout")
|
err = errors.New("order pay timeout")
|
||||||
logc.Errorf(ctx, "create prePayment deposit failed, err: %v", err)
|
logc.Errorf(ctx, "create prePayment deposit failed, err: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user