From 2f5ce8dd778db81c55391f75810a30904455afa6 Mon Sep 17 00:00:00 2001 From: Hiven Date: Thu, 20 Jul 2023 17:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/gmodel/fs_order_logic.go | 5 +-- .../internal/logic/userorderlistlogic.go | 36 +++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/model/gmodel/fs_order_logic.go b/model/gmodel/fs_order_logic.go index eda7880c..d63c2e80 100755 --- a/model/gmodel/fs_order_logic.go +++ b/model/gmodel/fs_order_logic.go @@ -87,13 +87,14 @@ func (o *FsOrderModel) FindPageListByPage(ctx context.Context, rowBuilder *gorm. type FsOrderRel struct { FsOrder - FsOrderDetails []FsOrderDetails `gorm:"foreignKey:order_id;references:id"` + FsOrderDetails []FsOrderDetails `gorm:"foreignKey:order_id;references:id"` + FsOrderAffiliateInfo FsOrderAffiliate `gorm:"foreignKey:order_id;references:id"` } type FsOrderDetails struct { FsOrderDetail FsOrderDetailTemplateInfo FsOrderDetailTemplate `gorm:"foreignKey:id;references:order_detail_template_id"` - FsProductInfo FsProduct `gorm:"foreignKey:id;references:product_id"` + FsProductInfo FsProduct `gorm:"foreignKey:id;references:product_id"` } func (m *FsOrderModel) RowSelectBuilder(selectData []string) *gorm.DB { diff --git a/server/home-user-auth/internal/logic/userorderlistlogic.go b/server/home-user-auth/internal/logic/userorderlistlogic.go index 9b51e532..9e4af349 100644 --- a/server/home-user-auth/internal/logic/userorderlistlogic.go +++ b/server/home-user-auth/internal/logic/userorderlistlogic.go @@ -8,6 +8,7 @@ import ( "fusenapi/utils/basic" "fusenapi/utils/format" "math" + "time" "context" @@ -47,7 +48,11 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo var page = req.Page var pageSize = req.PageSize var listRes []*gmodel.FsOrderRel - rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId).Where("status =?", req.Status) + rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId) + + if req.Status != -1 { + rowBuilder = rowBuilder.Where("status = ?", req.Status) + } // 查询总数 total, err := orderModel.FindCount(l.ctx, rowBuilder, nil) @@ -61,7 +66,7 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo // 查询数据 if total > 0 { - rowBuilder = rowBuilder.Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB { + rowBuilder = rowBuilder.Preload("FsOrderAffiliateInfo").Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB { return dbPreload.Table(orderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo").Preload("FsProductInfo") }) listRes, err = orderModel.FindPageListByPage(l.ctx, rowBuilder, &page, &pageSize, nil, "") @@ -125,9 +130,34 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo pbData.ProductList = productList } + var surplusAt int64 + surplusAt = (*item.Ctime + constants.CANCLE_ORDER_EXPIRE) - time.Now().Unix() + if surplusAt < 0 { + surplusAt = 0 + } + //fsOrderAffiliateInfo := item.FsOrderAffiliateInfo + + // 流程控制 + // statusTime := make([]*types.StatusTime,8) + // statusTime[0] = &types.StatusTime{ + // Key: 1,Time:*fsOrderAffiliateInfo.SureTime, + // } + // statusTime[1] = &types.StatusTime{ + // Key: 1,Time:*ifsOrderAffiliateInfo.ProductTime, + // } + + // `sure_time` int(10) unsigned DEFAULT '0' COMMENT '确认时间', + // `product_time` int(10) unsigned DEFAULT '0' COMMENT '生产时间', + // `product_endtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '生成完成时间', + // `deliver_time` int(10) unsigned DEFAULT '0' COMMENT '发货时间', + // `ups_deliver_time` int(10) unsigned DEFAULT '0' COMMENT 'ups发货时间', + // `ups_time` int(10) unsigned DEFAULT '0' COMMENT 'UPS提货时间', + // `arrival_time` int(10) unsigned DEFAULT '0' COMMENT '到达云仓的时间', + // `recevie_time` int(10) unsigned DEFAULT '0' COMMENT '云仓收货时间', + pbData.PcsBox = pcsBox pbData.Pcs = pcs - pbData.SurplusAt = *item.Ctime + constants.CANCLE_ORDER_EXPIRE + pbData.SurplusAt = surplusAt pbData.LogisticsStatus = 1 pbData.Deposit = *item.TotalAmount / 2 pbData.Remaining = pbData.Deposit