order_service.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package myselfsrv
  2. import (
  3. "Cold_Logistic/internal/pkg/common/constant"
  4. "Cold_Logistic/internal/pkg/common/global"
  5. "Cold_Logistic/internal/server/infra/dao"
  6. "Cold_Logistic/internal/server/infra/models"
  7. "context"
  8. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
  9. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
  10. )
  11. // OrderPage 寄件列表
  12. func (srv *MyselfService) OrderPage(ctx context.Context, req OrderPageReqVO) (res core.PageListResponse, err error) {
  13. dto := dao.ExpressOrderPageDTO{
  14. Page: req.Page,
  15. OrderNo: req.Search.OrderNo,
  16. OrderStatus: req.Search.OrderStatus,
  17. }
  18. if req.Search.SearchDateTime != "" {
  19. dto.PlaceOrderStartTime.Time, dto.PlaceOrderEndTime.Time = req.Search.SearchDateTime.GetRangeTime()
  20. } else {
  21. dto.PlaceOrderStartTime = req.Search.PlaceOrderStartTime
  22. dto.PlaceOrderEndTime = req.Search.PlaceOrderEndTime
  23. }
  24. list, total, err := srv.store.ExpressOrder().MyPage(ctx, dto)
  25. if err != nil {
  26. return res, errors.WithStackOnce(err)
  27. }
  28. res.Total = total
  29. res.TotalPage = total / int64(req.Page.Size)
  30. res.Count = len(list)
  31. res.List = list
  32. return res, nil
  33. }
  34. func (srv *MyselfService) OrderSubNo(ctx context.Context, req OrderSubNoReqVO) (res OrderSubNoRespVO, err error) {
  35. order := models.ExpressOrder{}
  36. if err = srv.store.ExpressOrder().FirstById(ctx, &order, req.OrderId); err != nil {
  37. return res, errors.WithStackOnce(err)
  38. }
  39. var subNo string
  40. if order.OrderStatus == constant.OrderStatusWaitCar {
  41. subNo, err = global.CommonConnectRepoInst.Redis.Get(ctx, order.OrderNo).Result()
  42. if err != nil {
  43. return res, errors.WithStackOnce(err)
  44. }
  45. }
  46. res.OrderSubNo = subNo
  47. return res, nil
  48. }