|
@@ -1,39 +1,40 @@
|
|
|
package model
|
|
|
|
|
|
import (
|
|
|
- "strconv"
|
|
|
"strings"
|
|
|
|
|
|
pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
)
|
|
|
|
|
|
type EventSale struct {
|
|
|
- Id int64 `json:"id"`
|
|
|
- PastureId int64 `json:"pastureId"`
|
|
|
- DealerId int32 `json:"dealerId"`
|
|
|
- DealerName string `json:"dealerName"`
|
|
|
- SalePrice float64 `json:"salePrice"`
|
|
|
- SaleAllWeight int32 `json:"saleAllWeight"`
|
|
|
- SaleAllAmount float64 `json:"saleAllAmount"`
|
|
|
- SaleCowCount int32 `json:"saleCowCount"`
|
|
|
- CowIds string `json:"cowIds"`
|
|
|
- SaleAt int64 `json:"saleAt"`
|
|
|
- SaleTicker string `json:"saleTicker"`
|
|
|
- QuarantineReport string `json:"quarantineReport"`
|
|
|
- Remarks string `json:"remarks"`
|
|
|
- OperationId int64 `json:"operationId"`
|
|
|
- OperationName string `json:"operationName"`
|
|
|
- MessageId int64 `json:"messageId"`
|
|
|
- MessageName string `json:"messageName"`
|
|
|
- CreatedAt int64 `json:"createdAt"`
|
|
|
- UpdatedAt int64 `json:"updatedAt"`
|
|
|
+ Id int64 `json:"id"`
|
|
|
+ PastureId int64 `json:"pastureId"`
|
|
|
+ DealerId int32 `json:"dealerId"`
|
|
|
+ DealerName string `json:"dealerName"`
|
|
|
+ SalePrice float64 `json:"salePrice"`
|
|
|
+ SaleAllWeight int32 `json:"saleAllWeight"`
|
|
|
+ SaleAllAmount float64 `json:"saleAllAmount"`
|
|
|
+ SaleCowCount int32 `json:"saleCowCount"`
|
|
|
+ SaleKind pasturePb.SalesType_Kind `json:"saleKind"`
|
|
|
+ OutReasonsKind pasturePb.OutReasons_Kind `json:"outReasonsKind"`
|
|
|
+ OutReasonsName string `json:"outReasonsName"`
|
|
|
+ SaleAt int64 `json:"saleAt"`
|
|
|
+ SaleTicker string `json:"saleTicker"`
|
|
|
+ QuarantineReport string `json:"quarantineReport"`
|
|
|
+ Remarks string `json:"remarks"`
|
|
|
+ OperationId int64 `json:"operationId"`
|
|
|
+ OperationName string `json:"operationName"`
|
|
|
+ MessageId int64 `json:"messageId"`
|
|
|
+ MessageName string `json:"messageName"`
|
|
|
+ CreatedAt int64 `json:"createdAt"`
|
|
|
+ UpdatedAt int64 `json:"updatedAt"`
|
|
|
}
|
|
|
|
|
|
func (e *EventSale) TableName() string {
|
|
|
return "event_sale"
|
|
|
}
|
|
|
|
|
|
-func NewEventSale(pastureId int64, dealerInfo *SaleDealer, cowIds string, req *pasturePb.EventCowSale, operationUser, currUser *SystemUser) *EventSale {
|
|
|
+func NewEventSale(pastureId int64, dealerInfo *SaleDealer, req *pasturePb.EventCowSale, operationUser, currUser *SystemUser) *EventSale {
|
|
|
return &EventSale{
|
|
|
PastureId: pastureId,
|
|
|
DealerId: dealerInfo.Id,
|
|
@@ -41,8 +42,10 @@ func NewEventSale(pastureId int64, dealerInfo *SaleDealer, cowIds string, req *p
|
|
|
SalePrice: float64(req.SalePrice),
|
|
|
SaleAllWeight: int32(req.SaleAllWeight * 1000),
|
|
|
SaleAllAmount: float64(req.SaleAllPrice),
|
|
|
- SaleCowCount: int32(len(req.CowIds)),
|
|
|
- CowIds: cowIds,
|
|
|
+ SaleCowCount: int32(len(req.EarNumbers)),
|
|
|
+ SaleKind: req.SalesType,
|
|
|
+ OutReasonsKind: req.OutReasonsKind,
|
|
|
+ OutReasonsName: req.OutReasonsName,
|
|
|
SaleAt: int64(req.SaleAt),
|
|
|
SaleTicker: strings.Join(req.SaleTicket, ","),
|
|
|
QuarantineReport: strings.Join(req.QuarantineReport, ","),
|
|
@@ -56,29 +59,15 @@ func NewEventSale(pastureId int64, dealerInfo *SaleDealer, cowIds string, req *p
|
|
|
|
|
|
type EventSaleSlice []*EventSale
|
|
|
|
|
|
-func (e EventSaleSlice) ToPB(eventSaleCarMap map[int64][]*EventSaleCar) []*pasturePb.EventCowSale {
|
|
|
+func (e EventSaleSlice) ToPB(eventSaleCarMap map[int64][]*EventSaleCar, eventSaleCowList []*EventSaleCow) []*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]
|
|
|
+ earNumbers := make([]string, 0)
|
|
|
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))
|
|
|
- }
|
|
|
- }
|
|
|
+ es := strings.Split(item.EarNumbers, ",")
|
|
|
saleVehicleItems = append(saleVehicleItems, &pasturePb.SaleVehicleItem{
|
|
|
CarNumber: item.CarNumber,
|
|
|
CowCount: item.CowCount,
|
|
@@ -86,15 +75,19 @@ func (e EventSaleSlice) ToPB(eventSaleCarMap map[int64][]*EventSaleCar) []*pastu
|
|
|
OutboundTicket: item.OutboundTicket,
|
|
|
WeighbridgePhotos: strings.Split(item.WeighbridgePhotos, ","),
|
|
|
VehiclePhotos: strings.Split(item.CarPhotos, ","),
|
|
|
- CowIds: carCowIds,
|
|
|
+ EarNumbers: es,
|
|
|
})
|
|
|
+ earNumbers = append(earNumbers, es...)
|
|
|
}
|
|
|
}
|
|
|
res[i] = &pasturePb.EventCowSale{
|
|
|
DealerId: v.DealerId,
|
|
|
DealerName: v.DealerName,
|
|
|
SaleAt: int32(v.SaleAt),
|
|
|
- CowIds: cowIds,
|
|
|
+ EarNumbers: earNumbers,
|
|
|
+ SalesType: v.SaleKind,
|
|
|
+ OutReasonsKind: v.OutReasonsKind,
|
|
|
+ OutReasonsName: v.OutReasonsName,
|
|
|
SaleAllWeight: float32(v.SaleAllWeight) / 1000,
|
|
|
SaleAllPrice: float32(v.SaleAllAmount),
|
|
|
SalePrice: float32(v.SalePrice),
|
|
@@ -103,7 +96,7 @@ func (e EventSaleSlice) ToPB(eventSaleCarMap map[int64][]*EventSaleCar) []*pastu
|
|
|
Remarks: v.Remarks,
|
|
|
SaleTicket: strings.Split(v.SaleTicker, ","),
|
|
|
QuarantineReport: strings.Split(v.QuarantineReport, ","),
|
|
|
- SaleVehicleItems: nil,
|
|
|
+ SaleVehicleItems: saleVehicleItems,
|
|
|
}
|
|
|
}
|
|
|
return res
|