diff --git a/server/home-user-auth/internal/logic/userorderlistlogic.go b/server/home-user-auth/internal/logic/userorderlistlogic.go index b6d2b9a4..b43de13b 100644 --- a/server/home-user-auth/internal/logic/userorderlistlogic.go +++ b/server/home-user-auth/internal/logic/userorderlistlogic.go @@ -6,6 +6,7 @@ import ( "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" + "fusenapi/utils/configs" "fusenapi/utils/format" "fusenapi/utils/order" @@ -39,6 +40,9 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // userinfo 传入值时, 一定不为null + // 测试 + userinfo.UserId = 39 + orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn) orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn) rowBuilder := orderModel.RowSelectBuilder(nil) @@ -86,10 +90,10 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo var respList []types.Items if listResLen > 0 { // 获取订单时间配置 - // orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn) - // if err != nil { - // return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info") - // } + orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn) + if err != nil { + return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info") + } // 数据处理 for _, item := range listRes { @@ -121,9 +125,9 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo fsOrderAffiliateInfo := item.FsOrderAffiliateInfo - statusAndLogisticsRes := order.GetOrderStatusAndLogistics(order.GetOrderStatusAndLogisticsReq{ - OrderStatus: constants.Order(*item.Status), - DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod), + var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{ + OrderStatus: 1, + DeliveryMethod: 1, IsPayCompleted: *item.IsAllProductCompleted, SureTime: *fsOrderAffiliateInfo.SureTime, ProductTime: *fsOrderAffiliateInfo.SureTime, @@ -134,9 +138,11 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo ArrivalTime: *fsOrderAffiliateInfo.SureTime, RecevieTime: *fsOrderAffiliateInfo.SureTime, - OrderCtime: *item.Ctime, - //WebSetTimeInfo: orderTimeConfig, - }) + OrderCtime: *item.Ctime, + WebSetTimeInfo: orderTimeConfig, + } + + statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq) // 流程控制 statusTime := make([]*types.StatusTime, 5) diff --git a/utils/configs/order.go b/utils/configs/order.go index 291ac401..eb1f8d6b 100644 --- a/utils/configs/order.go +++ b/utils/configs/order.go @@ -1,8 +1,75 @@ package configs +import ( + "context" + "encoding/json" + "errors" + "fusenapi/constants" + "fusenapi/model/gmodel" + "strconv" + + "github.com/zeromicro/go-zero/core/logx" + "gorm.io/gorm" +) + type WebSetTimeInfo struct { ProductDay int64 FactoryDeliverDay int64 DeliverUpsDay int64 UpsTransDay int64 } + +type WebSetTimeInfoData struct { + ProductDay string `json:"product_day"` + FactoryDeliverDay string `json:"factory_deliver_day"` + DeliverUpsDay string `json:"deliver_ups_day"` + UpsTransDay string `json:"ups_trans_day"` +} + +func GetOrderTimeConfig(ctx context.Context, db *gorm.DB) (res WebSetTimeInfo, err error) { + resData, err := gmodel.NewFsWebSetModel(db).FindValueByKey(ctx, string(constants.WEBSET_TIME_INFO)) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + res.ProductDay = int64(constants.ORDER_PRODUCT_DAY) + res.FactoryDeliverDay = int64(constants.ORDER_FACTORY_DELIVER_DAY) + res.DeliverUpsDay = int64(constants.ORDER_DELIVER_UPS_DAY) + res.UpsTransDay = int64(constants.ORDER_UPS_TRANS_DAY) + return res, nil + } + logx.Error(err) + return res, err + } else { + var timeInfo WebSetTimeInfoData + err = json.Unmarshal([]byte(*resData.Value), &timeInfo) + if err != nil { + logx.Error(err) + return res, err + } + productDay, err := strconv.Atoi(timeInfo.ProductDay) + if err != nil { + logx.Error(err) + return res, err + } + factoryDeliverDay, err := strconv.Atoi(timeInfo.FactoryDeliverDay) + if err != nil { + logx.Error(err) + return res, err + } + deliverUpsDay, err := strconv.Atoi(timeInfo.DeliverUpsDay) + if err != nil { + logx.Error(err) + return res, err + } + upsTransDay, err := strconv.Atoi(timeInfo.UpsTransDay) + if err != nil { + logx.Error(err) + return res, err + } + res.ProductDay = int64(productDay) + res.FactoryDeliverDay = int64(factoryDeliverDay) + res.DeliverUpsDay = int64(deliverUpsDay) + res.UpsTransDay = int64(upsTransDay) + } + + return res, nil +} diff --git a/utils/order/order_status.go b/utils/order/order_status.go index e12af5a8..51bc8351 100644 --- a/utils/order/order_status.go +++ b/utils/order/order_status.go @@ -37,6 +37,8 @@ type GetOrderStatusAndLogisticsReq struct { OrderStatus constants.Order DeliveryMethod constants.DeliveryMethod IsPayCompleted int64 + OrderCtime int64 + SureTime int64 ProductTime int64 ProductEndtime int64 @@ -46,7 +48,7 @@ type GetOrderStatusAndLogisticsReq struct { ArrivalTime int64 RecevieTime int64 - OrderCtime int64 + WebSetTimeInfo configs.WebSetTimeInfo }