| | |
| | | // List
|
| | | //
|
| | | // @Tags ServiceContract
|
| | | // @Summary 生成计划列表
|
| | | // @Summary 服务合同列表 |
| | | // @Produce application/json
|
| | | // @Param object body request.GetServiceContractList true "参数"
|
| | | // @Success 200 {object} contextx.Response{data=response.ServiceContractsResponse}
|
| | |
| | | "tags": [ |
| | | "ServiceContract" |
| | | ], |
| | | "summary": "生成计划列表", |
| | | "summary": "服务合同列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | |
| | | "model.ServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "SaleChance": { |
| | | "$ref": "#/definitions/model.SaleChance" |
| | | }, |
| | | "amountInvoiced": { |
| | | "description": "已开票金额", |
| | | "type": "number" |
| | |
| | | "type": "integer" |
| | | }, |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | | "contractId": { |
| | | "type": "integer" |
| | | }, |
| | | "endTime": { |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotation": { |
| | | "$ref": "#/definitions/model.Quotation" |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetails": { |
| | | "$ref": "#/definitions/model.SalesDetails" |
| | | }, |
| | | "salesDetailsId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractStatus": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | }, |
| | | "serviceContractStatusId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractType": { |
| | | "$ref": "#/definitions/model.ServiceContractType" |
| | | }, |
| | | "serviceContractTypeId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "tags": [ |
| | | "ServiceContract" |
| | | ], |
| | | "summary": "生成计划列表", |
| | | "summary": "服务合同列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | |
| | | "model.ServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "SaleChance": { |
| | | "$ref": "#/definitions/model.SaleChance" |
| | | }, |
| | | "amountInvoiced": { |
| | | "description": "已开票金额", |
| | | "type": "number" |
| | |
| | | "type": "integer" |
| | | }, |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | | "contractId": { |
| | | "type": "integer" |
| | | }, |
| | | "endTime": { |
| | |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "quotation": { |
| | | "$ref": "#/definitions/model.Quotation" |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetails": { |
| | | "$ref": "#/definitions/model.SalesDetails" |
| | | }, |
| | | "salesDetailsId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractStatus": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | }, |
| | | "serviceContractStatusId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractType": { |
| | | "$ref": "#/definitions/model.ServiceContractType" |
| | | }, |
| | | "serviceContractTypeId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | type: object |
| | | model.ServiceContract: |
| | | properties: |
| | | SaleChance: |
| | | $ref: '#/definitions/model.SaleChance' |
| | | amountInvoiced: |
| | | description: 已开票金额 |
| | | type: number |
| | |
| | | type: integer |
| | | contactId: |
| | | type: integer |
| | | contractId: |
| | | type: integer |
| | | endTime: |
| | | type: string |
| | | id: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | quotation: |
| | | $ref: '#/definitions/model.Quotation' |
| | | quotationId: |
| | | type: integer |
| | | remark: |
| | | type: string |
| | | saleChanceId: |
| | | type: integer |
| | | salesDetails: |
| | | $ref: '#/definitions/model.SalesDetails' |
| | | salesDetailsId: |
| | | type: integer |
| | | serviceContractStatus: |
| | | $ref: '#/definitions/model.ServiceContractStatus' |
| | | serviceContractStatusId: |
| | | type: integer |
| | | serviceContractType: |
| | | $ref: '#/definitions/model.ServiceContractType' |
| | | serviceContractTypeId: |
| | | type: integer |
| | | serviceTimes: |
| | |
| | | data: |
| | | $ref: '#/definitions/response.ServiceContractsResponse' |
| | | type: object |
| | | summary: 生成计划列表 |
| | | summary: 服务合同列表 |
| | | tags: |
| | | - ServiceContract |
| | | /api/serviceContract/update: |
| | |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | ContractId int `json:"contractId" gorm:"column:contract_id;type:int;comment:合同id"` |
| | | SaleChance SaleChance `json:"SaleChance" gorm:"foreignKey:SaleChanceId"` |
| | | SalesDetailsId int `json:"salesDetailsId" gorm:"column:sales_details_id;type:int;comment:合同订单id"` |
| | | SalesDetails SalesDetails `json:"salesDetails" gorm:"foreignKey:SalesDetailsId"` |
| | | QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"` |
| | | Quotation Quotation `json:"quotation" gorm:"foreignKey:QuotationId"` |
| | | ServiceContractTypeId int `json:"serviceContractTypeId" gorm:"column:service_contract_type_id;type:int;comment:合同类型id"` |
| | | ServiceContractType ServiceContractType `json:"serviceContractType" gorm:"foreignKey:ServiceContractTypeId"` |
| | | SignTime time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签约时间"` |
| | | StartTime time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"` |
| | | EndTime time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"` |
| | | ServiceContractStatusId int `json:"serviceContractStatusId" gorm:"column:service_contract_status_id;type:int;comment:合同状态id"` |
| | | ServiceContractStatus ServiceContractStatus `json:"serviceContractStatus" gorm:"foreignKey:ServiceContractStatusId"` |
| | | ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:服务次数"` |
| | | Terms string `json:"terms" gorm:"column:terms;type:text;comment:条款"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | AmountReceivable decimal.Decimal `gorm:"amount_receivable" json:"amountReceivable"` // 应收金额 |
| | | AmountReceived decimal.Decimal `gorm:"amount_received" json:"amountReceived"` // 已收金额 |
| | | AmountInvoiced decimal.Decimal `gorm:"amount_invoiced" json:"amountInvoiced"` // 已开票金额 |
| | | Products []Product `json:"products" gorm:"many2many:serviceContract_product;"` |
| | | Products []Product `json:"products" gorm:"many2many:service_contract_product;"` |
| | | gorm.Model `json:"-"` |
| | | } |
| | | |
| | |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | Preload bool |
| | | } |
| | | ) |
| | | |
| | |
| | | //todo |
| | | |
| | | } |
| | | if slf.Preload { |
| | | db = db. |
| | | Preload("SaleChance"). |
| | | Preload("SalesDetails"). |
| | | Preload("Quotation"). |
| | | Preload("ServiceContractType"). |
| | | Preload("ServiceContractStatus"). |
| | | Preload("Products") |
| | | } |
| | | |
| | | return db |
| | | } |
| | |
| | | return db.Delete(&ServiceContract{}).Error |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) Find() (*ServiceContract, error) { |
| | | var db = slf.build() |
| | | var record = &ServiceContract{} |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) FindAll() ([]*ServiceContract, int64, error) { |
| | | func (slf *ServiceContractSearch) Find() ([]*ServiceContract, int64, error) { |
| | | var db = slf.build() |
| | | var records = make([]*ServiceContract, 0) |
| | | var total int64 |
| | |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | if slf.PageNum > 0 && slf.PageSize > 0 { |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | err := db.Preload("Products").Find(&records).Error |
| | | err := db.Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) SetPreload(preload bool) *ServiceContractSearch { |
| | | slf.Preload = preload |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.build() |
| | |
| | | |
| | | func (SContractService) UpdateServiceContract(serviceContract *model.ServiceContract) int { |
| | | // check serviceContract exist |
| | | _, err := model.NewServiceContractSearch().SetId(serviceContract.Id).Find() |
| | | _, err := model.NewServiceContractSearch().SetId(serviceContract.Id).First() |
| | | if err != nil { |
| | | return ecode.SContractNotExist |
| | | } |
| | |
| | | SetKeyword(keyword). |
| | | SetKeywordType(keywordType). |
| | | SetQueryClass(queryClass). |
| | | SetPage(page, pageSize).FindAll() |
| | | SetPage(page, pageSize). |
| | | SetPreload(true). |
| | | Find() |
| | | if err != nil { |
| | | return nil, 0, ecode.SContractListErr |
| | | } |