vo.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package ordersrv
  2. import (
  3. "Cold_Logistic/internal/pkg/common/constant"
  4. "Cold_Logistic/internal/pkg/common/global"
  5. "Cold_Logistic/internal/server/infra/models"
  6. validation "github.com/go-ozzo/ozzo-validation/v4"
  7. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
  8. )
  9. type AddressVO struct {
  10. AddressId int `json:"addressId"` // 地址id
  11. Name string `json:"name"` // 姓名
  12. Phone string `json:"phone"` // 联系电话
  13. ProvinceId int `json:"provinceId"` // 省Id
  14. ProvinceName string `json:"provinceName"` // 省中文名
  15. CityId int `json:"cityId"` // 市Id
  16. CityName string `json:"cityName"` // 市中文名
  17. RegionId int `json:"regionId"` // 区Id
  18. RegionName string `json:"regionName"` // 区中文名
  19. Address string `json:"address"` // 详细地址
  20. IsDefault int `json:"isDefault"` // 是否默认:1-是 2-否
  21. }
  22. func (r *AddressVO) Validate() error {
  23. if r.AddressId > 0 {
  24. return nil
  25. }
  26. return validation.ValidateStruct(r,
  27. validation.Field(&r.Name, validation.Required),
  28. validation.Field(&r.Phone, validation.Required),
  29. validation.Field(&r.ProvinceId, validation.Required),
  30. validation.Field(&r.CityId, validation.Required),
  31. validation.Field(&r.Address, validation.Required),
  32. validation.Field(&r.IsDefault, validation.In(constant.YES, constant.NO)),
  33. )
  34. }
  35. func ConvertAddressReqVO(ent models.AddressBook) (ret AddressVO) {
  36. ret.AddressId = ent.Id
  37. ret.Name = ent.Name
  38. ret.Phone = ent.Phone
  39. ret.ProvinceId = ent.ProvinceId
  40. ret.ProvinceName = ent.ProvinceName
  41. ret.CityId = ent.CityId
  42. ret.CityName = ent.CityName
  43. ret.RegionId = ent.RegionId
  44. ret.RegionName = ent.RegionName
  45. ret.Address = ent.Address
  46. ret.IsDefault = ent.IsDefault
  47. return ret
  48. }
  49. type PlaceOrderReqVO struct {
  50. LogisticId int `json:"logisticId"` // 物流ID
  51. LogisticPid int `json:"logisticPid"` // 公司ID
  52. LogisticPidName string `json:"LogisticPidName"` // 公司名称
  53. Sender AddressVO `json:"sender"` // 寄件人
  54. Consignee AddressVO `json:"consignee"` // 收件人
  55. CargoType string `json:"cargoType"` // 货物类型
  56. TemperatureInterval string `json:"temperatureInterval"` // 温度区间
  57. CargoNumber int `json:"cargoNumber"` // 货物数量
  58. DeliveryCondition string `json:"deliveryCondition"` // 配送要求
  59. DeliveryRemark string `json:"deliveryRemark"` // 运输备注
  60. TimeLimit int `json:"timeLimit"` // 时效
  61. PickupTime models.MyTime `json:"pickupTime"` // 取货时间
  62. IsWeekendPickup int `json:"isWeekendPickup"` // 周末是否取货:1-是 2-否
  63. IsInsuredValue int `json:"isInsuredValue"` // 是否保价
  64. }
  65. func (r *PlaceOrderReqVO) Validate() error {
  66. return validation.ValidateStruct(r,
  67. validation.Field(&r.LogisticId, validation.When(r.LogisticPid <= 0, validation.Required)),
  68. validation.Field(&r.LogisticPid, validation.When(r.LogisticId <= 0, validation.Required)),
  69. validation.Field(&r.LogisticPidName, validation.When(r.LogisticPid > 0, validation.Required)),
  70. validation.Field(&r.Sender),
  71. validation.Field(&r.Consignee),
  72. validation.Field(&r.CargoType, validation.Required),
  73. validation.Field(&r.TemperatureInterval, validation.Required),
  74. validation.Field(&r.DeliveryCondition, validation.Required),
  75. validation.Field(&r.TimeLimit, validation.Required),
  76. validation.Field(&r.PickupTime, validation.Required),
  77. )
  78. }
  79. type PlaceOrderRespVO struct {
  80. OrderNo string
  81. PlaceOrderTime models.MyTime
  82. }
  83. type OrderDetailReqVO struct {
  84. OrderId int `json:"orderId"` // 订单ID
  85. }
  86. func (r *OrderDetailReqVO) Validate() error {
  87. return validation.ValidateStruct(r, validation.Field(&r.OrderId, validation.Required))
  88. }
  89. type OrderDetailRespVO struct {
  90. OrderId int `json:"orderId"` // 订单ID
  91. OrderNo string `json:"orderNo"` // 单号
  92. LogisticName string `json:"logisticName"` // 物流公司
  93. OrderStatus int `json:"orderStatus"` // 订单状态
  94. Sender AddressVO `json:"sender"` // 发货人
  95. Consignee AddressVO `json:"consigneeAddressId"` // 收货人
  96. CargoType string `json:"cargoType"` // 货物类型
  97. TemperatureInterval string `json:"temperatureInterval"` // 温度区间
  98. CargoNumber int `json:"cargoNumber"` // 货物数量
  99. DeliveryCondition string `json:"deliveryCondition"` // 配送要求
  100. DeliveryRemark string `json:"deliveryRemark"` // 运输备注
  101. TimeLimit int `json:"timeLimit"` // 时效
  102. PickupTime models.MyTime `json:"pickupTime"` // 取货时间
  103. IsWeekendPickup int `json:"isWeekendPickup"` // 周末是否取货:1-是 2-否
  104. IsInsuredValue int `json:"isInsuredValue"` // 是否保价
  105. }
  106. type OrderLogisticDetailReqVO struct {
  107. OrderId int `json:"orderId"` // 订单ID
  108. }
  109. func (r *OrderLogisticDetailReqVO) Validate() error {
  110. return validation.ValidateStruct(r, validation.Field(&r.OrderId, validation.Required))
  111. }
  112. type QueryExpressOrderReqVO struct {
  113. OrderNo string `json:"orderNo"` // 运单号
  114. }
  115. func (r *QueryExpressOrderReqVO) Validate() error {
  116. return validation.ValidateStruct(r, validation.Field(&r.OrderNo, validation.Required, validation.RuneLength(1, 30)))
  117. }
  118. type QueryExpressOrderRespVO struct {
  119. OrderId int `json:"orderId"` //
  120. OrderNo string `json:"orderNo"` // 单号
  121. OrderStatus int `json:"orderStatus"` // 订单状态
  122. LogisticName string `json:"logisticName"` // 物流名称
  123. LatestLocation LocationInfoVO `json:"LatestLocation"` // 最近一次定位信息
  124. }
  125. type OrderLogisticDetailRespVO struct {
  126. OrderId int `json:"orderId"` // 运单ID
  127. LogisticLink []LocationInfoVO `json:"logisticLink"` // 物流链
  128. Sender AddressVO `json:"sender"` // 发件人
  129. Consignee AddressVO `json:"consignee"` // 收件人
  130. }
  131. // LocationInfoVO 定位信息
  132. type LocationInfoVO struct {
  133. LocationTime models.MyTime `json:"locationTime"` // 到达时间
  134. Location string `json:"location"` // 位置
  135. ContactPerson string `json:"contactPerson"` // 联系人
  136. ContactPhone string `json:"contactPhone"` // 联系电话
  137. Extend string `json:"extend"`
  138. SnCode string `json:"snCode"`
  139. }
  140. type ManageOrderPageReqVO struct {
  141. Page core.Page `json:"page"`
  142. Search struct {
  143. OrderNo string `json:"orderNo"`
  144. OrderStatus int `json:"orderStatus"`
  145. } `json:"search"`
  146. }
  147. type AssignOrderReqVO struct {
  148. OrderId int `json:"orderId"` // 运单ID
  149. Freight int `json:"freight"` // 运费分
  150. Driver global.ClodAccount `json:"driver"`
  151. Destination string `json:"destination"` // 目的地:dest-终点 transit-中转
  152. }
  153. func (r *AssignOrderReqVO) Validate() error {
  154. return validation.ValidateStruct(r,
  155. validation.Field(&r.OrderId, validation.Required),
  156. validation.Field(&r.Destination, validation.Required),
  157. validation.Field(&r.Driver),
  158. )
  159. }
  160. type AssignOrderRespVO struct {
  161. OrderId int `json:"orderId"` // 运单ID
  162. }
  163. type WarehousePageReqVO struct {
  164. Page core.Page `json:"page"`
  165. Search struct {
  166. Name string `json:"name"`
  167. SnCode string `json:"snCode"`
  168. } `json:"search"`
  169. }