fix
This commit is contained in:
parent
6743f4dff1
commit
1f46911f51
|
@ -2,8 +2,8 @@ package constants
|
||||||
|
|
||||||
// 订单类型
|
// 订单类型
|
||||||
const (
|
const (
|
||||||
DELIVERYMETHODDIRECTMAIL int64 = 1
|
DELIVERYMETHODDIRECTMAIL int64 = 1 // 直邮
|
||||||
DELIVERYMETHODDSCLOUDSTORE int64 = 2
|
DELIVERYMETHODDSCLOUDSTORE int64 = 2 // 云仓
|
||||||
)
|
)
|
||||||
|
|
||||||
// 货币
|
// 货币
|
||||||
|
|
|
@ -55,18 +55,18 @@ func (l *CreateOrderLogic) CreateOrder(req *types.CreateOrderReq, userinfo *auth
|
||||||
}
|
}
|
||||||
|
|
||||||
// 延时任务
|
// 延时任务
|
||||||
l.svcCtx.DelayQueue.AddTask(time.Now().Add(time.Minute*30), constants.QUEUE_NAME_ORDER, func(args ...interface{}) {
|
// l.svcCtx.DelayQueue.AddTask(time.Now().Add(time.Minute*30), constants.QUEUE_NAME_ORDER, func(args ...interface{}) {
|
||||||
ctx := context.Background()
|
// ctx := context.Background()
|
||||||
orderSn := args[0].(string)
|
// orderSn := args[0].(string)
|
||||||
svcCtx := svc.ServiceContext{
|
// svcCtx := svc.ServiceContext{
|
||||||
Config: l.svcCtx.Config,
|
// Config: l.svcCtx.Config,
|
||||||
Repositories: l.svcCtx.Repositories,
|
// Repositories: l.svcCtx.Repositories,
|
||||||
}
|
// }
|
||||||
svcCtx.Repositories.NewOrder.Close(ctx, &repositories.CloseReq{
|
// svcCtx.Repositories.NewOrder.Close(ctx, &repositories.CloseReq{
|
||||||
OrderSn: orderSn,
|
// OrderSn: orderSn,
|
||||||
Type: 1,
|
// Type: 1,
|
||||||
})
|
// })
|
||||||
}, []interface{}{res.OrderSn})
|
// }, []interface{}{res.OrderSn})
|
||||||
|
|
||||||
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,7 +12,6 @@ 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"
|
||||||
|
@ -207,29 +206,29 @@ 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.Time
|
||||||
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.Now().Add(time.Second * 0)
|
||||||
} else {
|
// } else {
|
||||||
dtime = time.Now().Add(time.Second * time.Duration(math.Abs(float64(dd))))
|
// dtime = time.Now().Add(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{}) {
|
// d.DelayQueue.AddTask(dtime, constants.QUEUE_NAME_ORDER, func(args ...interface{}) {
|
||||||
ctx := context.Background()
|
// ctx := context.Background()
|
||||||
orderSn := args[0].(string)
|
// orderSn := args[0].(string)
|
||||||
logc.Infof(ctx, "order CloseList, orderSn: %s", orderSn)
|
// logc.Infof(ctx, "order CloseList, orderSn: %s", orderSn)
|
||||||
d.Close(ctx, &CloseReq{
|
// d.Close(ctx, &CloseReq{
|
||||||
OrderSn: orderSn,
|
// OrderSn: orderSn,
|
||||||
Type: 1,
|
// Type: 1,
|
||||||
})
|
// })
|
||||||
}, []interface{}{*orderInfo.OrderSn})
|
// }, []interface{}{*orderInfo.OrderSn})
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +686,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 {
|
||||||
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)
|
||||||
|
@ -740,7 +740,8 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create
|
||||||
var table = gmodel.NewAllModels(d.MysqlConn).FsOrder.TableName()
|
var table = gmodel.NewAllModels(d.MysqlConn).FsOrder.TableName()
|
||||||
var resUpdate *gorm.DB
|
var resUpdate *gorm.DB
|
||||||
if in.DeliveryMethod == constants.DELIVERYMETHODDIRECTMAIL {
|
if in.DeliveryMethod == constants.DELIVERYMETHODDIRECTMAIL {
|
||||||
resUpdate = d.MysqlConn.Exec(fmt.Sprintf("UPDATE %s SET `order_address` = JSON_MERGE_PATCH(`order_address`,?),`status_link` = JSON_MERGE_PATCH(`status_link`,?), `delivery_method` = ? , `utime` = ? WHERE `id` = ?", table), orderAddressByte, statusLinkByte, in.DeliveryMethod, ntime, orderInfo.Id)
|
var oosql = fmt.Sprintf("UPDATE %s SET `order_address` = JSON_MERGE_PATCH(`order_address`,?),`status_link` = JSON_MERGE_PATCH(`status_link`,?), `delivery_method` = ? , `utime` = ? WHERE `id` = ?", table)
|
||||||
|
resUpdate = d.MysqlConn.Exec(oosql, orderAddressByte, statusLinkByte, in.DeliveryMethod, ntime, orderInfo.Id)
|
||||||
} else {
|
} else {
|
||||||
resUpdate = d.MysqlConn.Exec(fmt.Sprintf("UPDATE %s SET `delivery_method` = ? , `utime` = ? WHERE `id` = ?", table), in.DeliveryMethod, ntime, orderInfo.Id)
|
resUpdate = d.MysqlConn.Exec(fmt.Sprintf("UPDATE %s SET `delivery_method` = ? , `utime` = ? WHERE `id` = ?", table), in.DeliveryMethod, ntime, orderInfo.Id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user