This commit is contained in:
momo 2023-10-07 17:31:24 +08:00
parent f2226ff0e4
commit 73a67aa21a
2 changed files with 29 additions and 13 deletions

View File

@ -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"`

View File

@ -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)