From 73a67aa21af4f547efefe2bdfd469632a81f90d1 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Sat, 7 Oct 2023 17:31:24 +0800 Subject: [PATCH] fix --- model/gmodel/fs_order_logic.go | 1 + service/repositories/order.go | 41 +++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/model/gmodel/fs_order_logic.go b/model/gmodel/fs_order_logic.go index 9398e5a8..824543bc 100644 --- a/model/gmodel/fs_order_logic.go +++ b/model/gmodel/fs_order_logic.go @@ -113,6 +113,7 @@ type OrderProduct struct { FittingInfo *OrderProductFittingInfo `json:"fitting_info"` IsHighlyCustomized int64 `json:"is_highly_customized"` RenderImage string `json:"render_image"` + SelectColorIndex int64 `json:"select_color_index"` } type PurchaseQuantity struct { Current interface{} `json:"current"` diff --git a/service/repositories/order.go b/service/repositories/order.go index b03ee1e2..1192dc2d 100644 --- a/service/repositories/order.go +++ b/service/repositories/order.go @@ -209,28 +209,35 @@ func (d *defaultOrder) CloseList(ctx context.Context, in *CloseListReq) (res *Cl } for _, orderInfo := range orderList { var ntime = time.Now().UTC() - var cptime = orderInfo.Ctime.UTC().Add(time.Minute * 30) - var dtime time.Duration + var cptime = orderInfo.Ctime.Add(time.Minute * 30) var dd = ntime.Unix() - cptime.Unix() - if dd > 0 { - dtime = time.Second * 0 - } else { - dtime = time.Second * time.Duration(math.Abs(float64(dd))) - } if in.Type == 1 { - // 延时任务 - time.AfterFunc(dtime, func() { - orderSn := orderInfo.OrderSn - fmt.Println("延时任务: OrderSn--", orderSn) + fmt.Println("未支付超时时间: dd--", dd) + if dd >= 0 { + orderSn := *orderInfo.OrderSn + fmt.Println("即时任务: OrderSn--", orderSn) ctx := context.Background() logc.Infof(ctx, "order CloseList, orderSn: %s", orderSn) d.Close(ctx, &CloseReq{ - OrderSn: *orderSn, + OrderSn: orderSn, Type: 1, }) - }) + } else { + ddd := math.Abs(float64(dd)) + // 延时任务 + time.AfterFunc(time.Second*time.Duration(ddd), func() { + orderSn := *orderInfo.OrderSn + fmt.Println("延时任务: OrderSn--", orderSn) + ctx := context.Background() + logc.Infof(ctx, "order CloseList, orderSn: %s", orderSn) + d.Close(ctx, &CloseReq{ + OrderSn: orderSn, + Type: 1, + }) + }) + } } } return nil, nil @@ -1385,6 +1392,7 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel var orderProductList []gmodel.OrderProduct for _, productValue := range orderProduct { + var selectColorIndex int64 var shoppingCartSnapshotData gmodel.FsShoppingCartData for _, shoppingCartSnapshotValue := range shoppingCartSnapshot { if productValue.CartId == shoppingCartSnapshotValue.Id { @@ -1409,6 +1417,12 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel shoppingCartSnapshotData.Ctime = shoppingCartSnapshotValue.Ctime shoppingCartSnapshotData.Utime = shoppingCartSnapshotValue.Utime shoppingCartSnapshotData.Snapshot = &snapshot + + selectColorIndexV, selectColorIndexE := snapshot["select_color_index"] + if selectColorIndexE { + selectColorIndex = selectColorIndexV.(int64) + } + } } @@ -1429,6 +1443,7 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel FittingInfo: productValue.FittingInfo, IsHighlyCustomized: productValue.IsHighlyCustomized, RenderImage: productValue.RenderImage, + SelectColorIndex: selectColorIndex, } orderProductList = append(orderProductList, orderProductItem)