order.go
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package transform
import (
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg/models"
)
func TransformToOrderDomainModelFromPgModels(orderModel *models.Order) (*domain.Order, error) {
var currentStatus domain.OrderStatus
switch orderModel.OrderStatus {
case domain.ORDER_STATUS_UNSHIPPED:
currentStatus = &domain.UnShippedStatus{}
case domain.ORDER_STATUS_SHIPPING:
currentStatus = &domain.TransitStatus{}
default:
currentStatus = &domain.UnShippedStatus{}
}
return &domain.Order{
OrderId: orderModel.OrderId,
Buyer: orderModel.Buyer,
CompanyId: orderModel.CompanyId,
PartnerId: orderModel.PartnerId,
DeliveryCode: orderModel.DeliveryCode,
IsDisable: orderModel.IsDisable,
OrderNo: orderModel.OrderNo,
OrderDetail: orderModel.OrderDetail,
OrderDividend: orderModel.OrderDividend,
OrderDividendStatus: orderModel.OrderDividendStatus,
OrderGoods: orderModel.OrderGoods,
OrderSource: orderModel.OrderSource,
OrderType: orderModel.OrderType,
OrderStatus: orderModel.OrderStatus,
TotalPrice: orderModel.TotalPrice,
RegionInfo: orderModel.RegionInfo,
Remarks: orderModel.Remarks,
CreateAt: orderModel.CreateAt,
UpdateAt: orderModel.UpdateAt,
DeleteAt: orderModel.DeleteAt,
CurrentStatus: currentStatus,
}, nil
}