contract_service_amount.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package fms
  2. import (
  3. "hongze/fms_api/global"
  4. "hongze/fms_api/models/base"
  5. )
  6. // 合同套餐金额表
  7. type ContractServiceAmount struct {
  8. Id int `gorm:"primaryKey;column:id" json:"id"`
  9. ContractRegisterId int `gorm:"column:contract_register_id" json:"contract_register_id"` //登记ID
  10. ProductId int `gorm:"column:product_id" json:"product_id"` //产品ID
  11. ServiceAmount float64 `gorm:"column:service_amount" json:"service_amount"` //套餐总金额
  12. CurrencyUnit string `gorm:"column:currency_unit" json:"currency_unit"` //货币国际代码
  13. base.TimeBase
  14. }
  15. // ContractServiceAmountAddReq 新增合同套餐金额请求体
  16. type ContractServiceAmountAddReq struct {
  17. ProductId int `json:"product_id"` //产品ID
  18. ServiceAmount float64 `json:"service_amount"` //套餐总金额
  19. }
  20. func (c *ContractServiceAmount) TableName() string {
  21. return "contract_service_amount"
  22. }
  23. func (c *ContractServiceAmount) Create() (err error) {
  24. err = global.DEFAULT_MYSQL.Create(c).Error
  25. return
  26. }
  27. func (c *ContractServiceAmount) AddInBatches(list []*ContractServiceAmount) (err error) {
  28. err = global.DEFAULT_MYSQL.CreateInBatches(list, len(list)).Error
  29. return
  30. }
  31. type ContractServiceAmountItem struct {
  32. ContractRegisterId int `gorm:"column:contract_register_id" json:"contract_register_id"` //登记ID
  33. ProductId int `gorm:"column:product_id" json:"product_id"` //产品ID
  34. ServiceAmount float64 `gorm:"column:service_amount" json:"service_amount"` //套餐总金额
  35. CurrencyUnit string `gorm:"column:currency_unit" json:"currency_unit"` //货币国际代码
  36. }
  37. // GetContractServiceAmountByContractRegisterIds 根据登记id获取套餐金额列表数据
  38. func GetContractServiceAmountByContractRegisterIds(contractRegisterIds []int) (list []*ContractServiceAmount, err error) {
  39. err = global.DEFAULT_MYSQL.Model(ContractServiceAmount{}).
  40. Where("contract_register_id in (?)", contractRegisterIds).
  41. Find(&list).Error
  42. return
  43. }
  44. // GetContractServiceAmountByRegisterId 根据id获取合同套餐金额数据
  45. func GetContractServiceAmountByRegisterId(contractRegisterId int) (list []*ContractServiceAmount, err error) {
  46. err = global.DEFAULT_MYSQL.Model(ContractServiceAmount{}).
  47. Where("contract_register_id = ?", contractRegisterId).
  48. Find(&list).Error
  49. return
  50. }