event_sale.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package model
  2. import (
  3. "strings"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. type EventSale struct {
  7. Id int64 `json:"id"`
  8. PastureId int64 `json:"pastureId"`
  9. DealerId int32 `json:"dealerId"`
  10. DealerName string `json:"dealerName"`
  11. SalePrice float64 `json:"salePrice"`
  12. SaleAllWeight int32 `json:"saleAllWeight"`
  13. SaleAllAmount float64 `json:"saleAllAmount"`
  14. SaleCowCount int32 `json:"saleCowCount"`
  15. CowIds string `json:"cowIds"`
  16. SaleAt int64 `json:"saleAt"`
  17. SaleTicker string `json:"saleTicker"`
  18. QuarantineReport string `json:"quarantineReport"`
  19. Remarks string `json:"remarks"`
  20. OperationId int64 `json:"operationId"`
  21. OperationName string `json:"operationName"`
  22. MessageId int64 `json:"messageId"`
  23. MessageName string `json:"messageName"`
  24. CreatedAt int64 `json:"createdAt"`
  25. UpdatedAt int64 `json:"updatedAt"`
  26. }
  27. func (e *EventSale) TableName() string {
  28. return "event_sale"
  29. }
  30. func NewEventSale(pastureId int64, dealerInfo *SaleDealer, cowIds string, req *pasturePb.EventCowSale, operationUser, currUser *SystemUser) *EventSale {
  31. return &EventSale{
  32. PastureId: pastureId,
  33. DealerId: dealerInfo.Id,
  34. DealerName: dealerInfo.Name,
  35. SalePrice: float64(req.SalePrice),
  36. SaleAllWeight: int32(req.SaleAllWeight * 1000),
  37. SaleAllAmount: float64(req.SaleAllPrice),
  38. SaleCowCount: int32(len(req.CowIds)),
  39. CowIds: cowIds,
  40. SaleAt: int64(req.SaleAt),
  41. SaleTicker: strings.Join(req.SaleTicket, ","),
  42. QuarantineReport: strings.Join(req.QuarantineReport, ","),
  43. Remarks: req.Remarks,
  44. OperationId: operationUser.Id,
  45. OperationName: operationUser.Name,
  46. MessageId: currUser.Id,
  47. MessageName: currUser.Name,
  48. }
  49. }