|
@@ -1,6 +1,7 @@
|
|
|
package model
|
|
|
|
|
|
import (
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
|
|
|
pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
@@ -33,7 +34,6 @@ func (e *EventSale) TableName() string {
|
|
|
}
|
|
|
|
|
|
func NewEventSale(pastureId int64, dealerInfo *SaleDealer, cowIds string, req *pasturePb.EventCowSale, operationUser, currUser *SystemUser) *EventSale {
|
|
|
-
|
|
|
return &EventSale{
|
|
|
PastureId: pastureId,
|
|
|
DealerId: dealerInfo.Id,
|
|
@@ -53,3 +53,58 @@ func NewEventSale(pastureId int64, dealerInfo *SaleDealer, cowIds string, req *p
|
|
|
MessageName: currUser.Name,
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+type EventSaleSlice []*EventSale
|
|
|
+
|
|
|
+func (e EventSaleSlice) ToPB(eventSaleCarMap map[int64][]*EventSaleCar) []*pasturePb.EventCowSale {
|
|
|
+ res := make([]*pasturePb.EventCowSale, len(e))
|
|
|
+ for i, v := range e {
|
|
|
+ cowIds := make([]int32, 0)
|
|
|
+ if len(v.CowIds) > 0 {
|
|
|
+ for _, cowIdStr := range strings.Split(v.CowIds, ",") {
|
|
|
+ cowId, _ := strconv.Atoi(cowIdStr)
|
|
|
+ cowIds = append(cowIds, int32(cowId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ saleVehicleItems := make([]*pasturePb.SaleVehicleItem, 0)
|
|
|
+ eventSaleCarItems, ok := eventSaleCarMap[v.Id]
|
|
|
+ if ok {
|
|
|
+
|
|
|
+ for _, item := range eventSaleCarItems {
|
|
|
+ carCowIds := make([]int32, 0)
|
|
|
+ if len(item.CowIds) > 0 {
|
|
|
+ for _, cowIdStr := range strings.Split(item.CowIds, ",") {
|
|
|
+ carCowId, _ := strconv.Atoi(cowIdStr)
|
|
|
+ carCowIds = append(carCowIds, int32(carCowId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ saleVehicleItems = append(saleVehicleItems, &pasturePb.SaleVehicleItem{
|
|
|
+ CarNumber: item.CarNumber,
|
|
|
+ CowCount: item.CowCount,
|
|
|
+ CowWeight: float32(item.CowWeight) / 1000,
|
|
|
+ OutboundTicket: item.OutboundTicket,
|
|
|
+ WeighbridgePhotos: strings.Split(item.WeighbridgePhotos, ","),
|
|
|
+ VehiclePhotos: strings.Split(item.CarPhotos, ","),
|
|
|
+ CowIds: carCowIds,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res[i] = &pasturePb.EventCowSale{
|
|
|
+ DealerId: v.DealerId,
|
|
|
+ DealerName: v.DealerName,
|
|
|
+ SaleAt: int32(v.SaleAt),
|
|
|
+ CowIds: cowIds,
|
|
|
+ SaleAllWeight: float32(v.SaleAllWeight) / 1000,
|
|
|
+ SaleAllPrice: float32(v.SaleAllAmount),
|
|
|
+ SalePrice: float32(v.SalePrice),
|
|
|
+ OperationId: int32(v.OperationId),
|
|
|
+ OperationName: v.OperationName,
|
|
|
+ Remarks: v.Remarks,
|
|
|
+ SaleTicket: strings.Split(v.SaleTicker, ","),
|
|
|
+ QuarantineReport: strings.Split(v.QuarantineReport, ","),
|
|
|
+ SaleVehicleItems: nil,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|