| | |
| | | return |
| | | } |
| | | |
| | | serviceCollectionPlan, total, errCode := service.NewServiceCollectionPlanService().GetServiceCollectionPlanList(params.ServiceContractId) |
| | | serviceCollectionPlan, total, errCode := service.NewServiceCollectionPlanService().GetServiceCollectionPlanList(params.SourceType, params.SourceId) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "服务合同id", |
| | | "name": "serviceContractId", |
| | | "in": "query" |
| | | "name": "sourceId", |
| | | "in": "query", |
| | | "required": true |
| | | }, |
| | | { |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "type": "integer", |
| | | "x-enum-comments": { |
| | | "CollectionSourceTypeSaleDetails": "销售明细", |
| | | "CollectionSourceTypeServiceContract": "服务合同" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "CollectionSourceTypeSaleDetails", |
| | | "CollectionSourceTypeServiceContract" |
| | | ], |
| | | "name": "sourceType", |
| | | "in": "query", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | "percent": { |
| | | "description": "比例", |
| | | "type": "number" |
| | | }, |
| | | "principal": { |
| | | "description": "收款负责人ID", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/model.User" |
| | | } |
| | | ] |
| | | }, |
| | | "principalId": { |
| | | "description": "收款负责人ID", |
| | |
| | | "description": "比例", |
| | | "type": "number" |
| | | }, |
| | | "principal": { |
| | | "description": "收款负责人ID", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/model.User" |
| | | } |
| | | ] |
| | | }, |
| | | "principalId": { |
| | | "description": "收款负责人ID", |
| | | "type": "integer" |
| | |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "服务合同id", |
| | | "name": "serviceContractId", |
| | | "in": "query" |
| | | "name": "sourceId", |
| | | "in": "query", |
| | | "required": true |
| | | }, |
| | | { |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "type": "integer", |
| | | "x-enum-comments": { |
| | | "CollectionSourceTypeSaleDetails": "销售明细", |
| | | "CollectionSourceTypeServiceContract": "服务合同" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "CollectionSourceTypeSaleDetails", |
| | | "CollectionSourceTypeServiceContract" |
| | | ], |
| | | "name": "sourceType", |
| | | "in": "query", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | "percent": { |
| | | "description": "比例", |
| | | "type": "number" |
| | | }, |
| | | "principal": { |
| | | "description": "收款负责人ID", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/model.User" |
| | | } |
| | | ] |
| | | }, |
| | | "principalId": { |
| | | "description": "收款负责人ID", |
| | |
| | | "description": "比例", |
| | | "type": "number" |
| | | }, |
| | | "principal": { |
| | | "description": "收款负责人ID", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/model.User" |
| | | } |
| | | ] |
| | | }, |
| | | "principalId": { |
| | | "description": "收款负责人ID", |
| | | "type": "integer" |
| | |
| | | percent: |
| | | description: 比例 |
| | | type: number |
| | | principal: |
| | | allOf: |
| | | - $ref: '#/definitions/model.User' |
| | | description: 收款负责人ID |
| | | principalId: |
| | | description: 收款负责人ID |
| | | type: integer |
| | |
| | | percent: |
| | | description: 比例 |
| | | type: number |
| | | principal: |
| | | allOf: |
| | | - $ref: '#/definitions/model.User' |
| | | description: 收款负责人ID |
| | | principalId: |
| | | description: 收款负责人ID |
| | | type: integer |
| | |
| | | /api/serviceCollectionPlan/list: |
| | | get: |
| | | parameters: |
| | | - description: 服务合同id |
| | | in: query |
| | | name: serviceContractId |
| | | - in: query |
| | | name: sourceId |
| | | required: true |
| | | type: integer |
| | | - enum: |
| | | - 1 |
| | | - 2 |
| | | in: query |
| | | name: sourceType |
| | | required: true |
| | | type: integer |
| | | x-enum-comments: |
| | | CollectionSourceTypeSaleDetails: 销售明细 |
| | | CollectionSourceTypeServiceContract: 服务合同 |
| | | x-enum-varnames: |
| | | - CollectionSourceTypeSaleDetails |
| | | - CollectionSourceTypeServiceContract |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | err := db.Preload("Principal").Preload("Client").Find(&records).Error |
| | | err := db.Preload("Principal").Preload("Client").Preload("PaymentType").Preload("BankAccount").Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |
| | |
| | | package request |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | ) |
| | | |
| | |
| | | } |
| | | |
| | | type GetServiceCollectionPlanList struct { |
| | | ServiceContractId int `gorm:"service_contract_id" form:"serviceContractId"` // 服务合同id |
| | | SourceType constvar.CollectionSourceType `json:"sourceType" form:"sourceType" binding:"required"` |
| | | SourceId int `json:"sourceId" form:"sourceId" binding:"required"` |
| | | } |
| | |
| | | SourceType constvar.CollectionSourceType `gorm:"column:source_type;type:tinyint;not null;default 0;comment:源单类型(1销售明细2服务合同3销售发票)" json:"sourceType"` // 源单类型(1销售明细2服务合同3销售发票) |
| | | SourceId int `gorm:"column:source_id;type:int;not null;default 0;comment:源单id" json:"sourceId"` // 源单id |
| | | PrincipalId int `gorm:"column:principal_id;type:int;not null;default 0;comment:收款负责人ID" json:"principalId"` // 收款负责人ID |
| | | Principal User `gorm:"foreignKey:PrincipalId" json:"principal"` // 收款负责人ID |
| | | Term int `gorm:"column:term;type:tinyint;not null;default 0;comment:期次" json:"term"` // 期次 |
| | | Percent decimal.Decimal `gorm:"column:percent;type:decimal(5,2);not null;default 0.00;comment:收款比例" gorm:"" json:"percent"` // 比例 |
| | | Amount decimal.Decimal `gorm:"column:amount;type:decimal(12,2);not null;default '0.00';comment:金额" gorm:"" json:"amount"` // 金额 |
| | |
| | | db = db.Where("source_id = ?", slf.SourceId) |
| | | } |
| | | |
| | | if slf.SourceType != 0 { |
| | | db = db.Where("source_type = ?", slf.SourceType) |
| | | } |
| | | |
| | | db = db.Preload("Client").Preload("Principal") |
| | | return db |
| | | } |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceCollectionPlanSearch) SetSourceType(sourceType constvar.CollectionSourceType) *ServiceCollectionPlanSearch { |
| | | slf.SourceType = sourceType |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceCollectionPlanSearch) First() (*ServiceCollectionPlan, error) { |
| | | var db = slf.build() |
| | | var record = new(ServiceCollectionPlan) |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceCollectionPlanService) GetServiceCollectionPlanList(sourceId int) ([]*model.ServiceCollectionPlan, int64, int) { |
| | | list, total, err := model.NewServiceCollectionPlanSearch().SetSourceId(sourceId).Find() |
| | | func (ServiceCollectionPlanService) GetServiceCollectionPlanList(sourceType constvar.CollectionSourceType, sourceId int) ([]*model.ServiceCollectionPlan, int64, int) { |
| | | list, total, err := model.NewServiceCollectionPlanSearch().SetSourceType(sourceType).SetSourceId(sourceId).Find() |
| | | if err != nil { |
| | | return nil, 0, ecode.DBErr |
| | | } |