| | |
| | | File: contract.File, |
| | | CodeStandID: contract.CodeStandID, |
| | | ContractName: contract.ContractName, |
| | | SendTime: contract.SendTime, |
| | | } |
| | | |
| | | return ecode.OK, contractModel |
| | |
| | | salesDetailsModel.LogisticCost = salesDetails.LogisticCost |
| | | salesDetailsModel.CodeStandID = salesDetails.CodeStandID |
| | | salesDetailsModel.DeliverType = salesDetails.DeliverType |
| | | salesDetailsModel.QuotationId = salesDetails.QuotationId |
| | | |
| | | return ecode.OK, salesDetailsModel |
| | | } |
| | |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "type": "string" |
| | | }, |
| | | "serviceContractStatus": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "description": "发货时间", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "description": "发货时间", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "type": "string" |
| | | }, |
| | | "serviceContractStatus": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | }, |
| | |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "description": "发货时间", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | |
| | | "type": "integer" |
| | | }, |
| | | "sendTime": { |
| | | "description": "发货时间s", |
| | | "description": "发货时间", |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | |
| | | $ref: '#/definitions/model.Quotation' |
| | | quotationId: |
| | | type: integer |
| | | sendTime: |
| | | type: string |
| | | serviceContractStatus: |
| | | $ref: '#/definitions/model.ServiceContractStatus' |
| | | statusId: |
| | |
| | | quotation_id: |
| | | type: integer |
| | | sendTime: |
| | | description: 发货时间s |
| | | description: 发货时间 |
| | | type: string |
| | | status_id: |
| | | type: integer |
| | |
| | | quotation_id: |
| | | type: integer |
| | | sendTime: |
| | | description: 发货时间s |
| | | description: 发货时间 |
| | | type: string |
| | | status_id: |
| | | type: integer |
| | |
| | | type ( |
| | | // SalesReturnProduct 服务合同和产品关联 |
| | | SalesReturnProduct struct { |
| | | SalesReturnId int `json:"id" gorm:"column:service_contract_id;type:int;primary_key;not null;default:0"` |
| | | SalesReturnId int `json:"id" gorm:"column:sales_return_id;type:int;primary_key;not null;default:0"` |
| | | ProductId uint `json:"name" gorm:"primary_key;column:product_id;type:int;not null;default:0;comment:产品id"` |
| | | } |
| | | |
| | | // SalesReturnProductSearch 销售明细和产品关联搜索条件 |
| | | SalesReturnProductSearch struct { |
| | | SalesReturnProduct |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | ProductIds []uint |
| | | } |
| | | ) |
| | | |
| | | func (SalesReturnProduct) TableName() string { |
| | | return "service_contract_product" |
| | | return "sales_return_product" |
| | | } |
| | | |
| | | func NewSalesReturnProductSearch() *SalesReturnProductSearch { |
| | |
| | | |
| | | func (slf *SalesReturnProductSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&SalesReturnProduct{}) |
| | | if len(slf.ProductIds) > 0 { |
| | | db = db.Where("product_id in (?)", slf.ProductIds) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *SalesReturnProductSearch) SetProductIds(ids []uint) *SalesReturnProductSearch { |
| | | slf.ProductIds = ids |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SalesReturnProductSearch) Create(record *SalesReturnProduct) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | |
| | | File string `json:"file" gorm:"column:file;type:varchar(255);comment:合同文件"` |
| | | CreatedAt *CustomTime `json:"created_at" gorm:"column:created_at;type:datetime;comment:创建时间"` |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | //SendTime string `json:"sendTime" gorm:"column:send_time;type:varchar(255);comment:发货时间"` |
| | | SendTime string `json:"sendTime" gorm:"column:send_time;type:varchar(255);comment:发货时间"` |
| | | gormModel |
| | | } |
| | | |
| | |
| | | StatusId int `json:"status_id"` |
| | | File string `json:"file"` |
| | | CodeStandID string `json:"codeStandID"` //编码id |
| | | SendTime string `json:"sendTime"` //发货时间s |
| | | SendTime string `json:"sendTime"` //发货时间 |
| | | } |
| | | |
| | | type UpdateContract struct { |
| | |
| | | |
| | | type SalesDetails struct { |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售子单号"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售明细单号"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | SaleType int `json:"saleType" gorm:"column:sale_type;type:int;comment:销售类型"` |
| | | SignTime string `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签单时间"` |
| | |
| | | Keyword string `json:"keyword"` |
| | | SaleChanceId int `json:"saleChanceId"` //销售机会id |
| | | ClientId int `json:"clientId"` //客户id |
| | | Number string `json:"number"` //销售子单号 |
| | | Number string `json:"number"` //销售明细单号 |
| | | } |
| | |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售子单号"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:销售明细单号"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | SaleChance SaleChance `json:"saleChance" gorm:"foreignKey:SaleChanceId"` |
| | | SaleType int `json:"saleType" gorm:"column:sale_type;type:int;comment:销售类型"` |
| | |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | ProductIds []uint |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | func (slf *SalesDetailsProductSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&SalesDetailsProduct{}) |
| | | if len(slf.ProductIds) > 0 { |
| | | db = db.Where("product_id in (?)", slf.ProductIds) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *SalesDetailsProductSearch) SetProductIds(ids []uint) *SalesDetailsProductSearch { |
| | | slf.ProductIds = ids |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SalesDetailsProductSearch) Create(record *SalesDetailsProduct) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | |
| | | salesDetails.AmountTotal = salesDetails.AmountTotal.Round(2) |
| | | salesDetails.AmountReceivable = salesDetails.AmountTotal |
| | | salesDetails.AmountUnInvoiced = salesDetails.AmountTotal |
| | | for _, product := range salesDetails.Products { |
| | | product.Id = 0 |
| | | } |
| | | err := model.NewSalesDetailsSearch().Create(salesDetails) |
| | | if err != nil { |
| | | return ecode.SalesDetailsExist |
| | |
| | | salesReturn.AmountTotal = decimal.Zero |
| | | for _, product := range salesReturn.Products { |
| | | salesReturn.AmountTotal = salesReturn.AmountTotal.Add(product.Amount.Mul(product.Price)) |
| | | product.Id = 0 |
| | | } |
| | | salesReturn.AmountShouldRefund = salesReturn.AmountTotal |
| | | err := model.NewSalesReturnSearch().Create(salesReturn) |