| | |
| | | if !ok { |
| | | return |
| | | } |
| | | if params.Id == 0 { |
| | | ctx.Fail(ecode.ParamsErr) |
| | | } |
| | | params.Receipt.Id = params.Id |
| | | if params.Id == 0 { |
| | | ctx.Fail(ecode.ParamsErr) |
| | | } |
| | | params.Receipt.Id = params.Id |
| | | |
| | | errCode := service.NewReceiptService().UpdateReceipt(¶ms.Receipt) |
| | | if errCode != ecode.OK { |
| | |
| | | return |
| | | } |
| | | |
| | | receipt, total, errCode := service.NewReceiptService().GetReceiptList() |
| | | receipt, total, errCode := service.NewReceiptService().GetReceiptList(params) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ListResponse{ |
| | | Data: receipt, |
| | | Data: receipt, |
| | | Count: total, |
| | | }) |
| | | } |
| | |
| | | type ReceiptSourceType int //来源类型(1销售明细单2服务合同3销售发票4收款计划5出库单) |
| | | |
| | | const ( |
| | | ReceiptSourceTypeSalesDetails ReceiptSourceType = 1 |
| | | ReceiptSourceTypeServiceContract ReceiptSourceType = 2 |
| | | ReceiptSourceTypeInvoice ReceiptSourceType = 3 |
| | | ReceiptSourceTypeCollectionPlan ReceiptSourceType = 4 |
| | | ReceiptSourceTypeChuKuDan ReceiptSourceType = 5 |
| | | ReceiptSourceTypeSalesDetails ReceiptSourceType = 1 //销售明细单 |
| | | ReceiptSourceTypeServiceContract ReceiptSourceType = 2 //服务合同 |
| | | ReceiptSourceTypeInvoice ReceiptSourceType = 3 //销售发票 |
| | | ReceiptSourceTypeCollectionPlan ReceiptSourceType = 4 //收款计划 |
| | | ReceiptSourceTypeChuKuDan ReceiptSourceType = 5 //出库单it |
| | | ) |
| | |
| | | "summary": "获取收款单列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "type": "string", |
| | | "x-enum-varnames": [ |
| | | "ReceiptKeywordCustomerName" |
| | | ], |
| | | "name": "keywordType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "sourceId", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5 |
| | | ], |
| | | "type": "string", |
| | | "type": "integer", |
| | | "x-enum-comments": { |
| | | "ReceiptSourceTypeChuKuDan": "出库单it", |
| | | "ReceiptSourceTypeCollectionPlan": "收款计划", |
| | | "ReceiptSourceTypeInvoice": "销售发票", |
| | | "ReceiptSourceTypeSalesDetails": "销售明细单", |
| | | "ReceiptSourceTypeServiceContract": "服务合同" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "ReceiptQueryClassExpireLessThen60Days" |
| | | "ReceiptSourceTypeSalesDetails", |
| | | "ReceiptSourceTypeServiceContract", |
| | | "ReceiptSourceTypeInvoice", |
| | | "ReceiptSourceTypeCollectionPlan", |
| | | "ReceiptSourceTypeChuKuDan" |
| | | ], |
| | | "name": "queryClass", |
| | | "name": "sourceType", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "PaymentTypeQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.ReceiptKeywordType": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ReceiptKeywordCustomerName" |
| | | ] |
| | | }, |
| | | "constvar.ReceiptQueryClass": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ReceiptQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.ReceiptSourceType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | 4, |
| | | 5 |
| | | ], |
| | | "x-enum-comments": { |
| | | "ReceiptSourceTypeChuKuDan": "出库单it", |
| | | "ReceiptSourceTypeCollectionPlan": "收款计划", |
| | | "ReceiptSourceTypeInvoice": "销售发票", |
| | | "ReceiptSourceTypeSalesDetails": "销售明细单", |
| | | "ReceiptSourceTypeServiceContract": "服务合同" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "ReceiptSourceTypeSalesDetails", |
| | | "ReceiptSourceTypeServiceContract", |
| | |
| | | "summary": "获取收款单列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "type": "string", |
| | | "x-enum-varnames": [ |
| | | "ReceiptKeywordCustomerName" |
| | | ], |
| | | "name": "keywordType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "sourceId", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5 |
| | | ], |
| | | "type": "string", |
| | | "type": "integer", |
| | | "x-enum-comments": { |
| | | "ReceiptSourceTypeChuKuDan": "出库单it", |
| | | "ReceiptSourceTypeCollectionPlan": "收款计划", |
| | | "ReceiptSourceTypeInvoice": "销售发票", |
| | | "ReceiptSourceTypeSalesDetails": "销售明细单", |
| | | "ReceiptSourceTypeServiceContract": "服务合同" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "ReceiptQueryClassExpireLessThen60Days" |
| | | "ReceiptSourceTypeSalesDetails", |
| | | "ReceiptSourceTypeServiceContract", |
| | | "ReceiptSourceTypeInvoice", |
| | | "ReceiptSourceTypeCollectionPlan", |
| | | "ReceiptSourceTypeChuKuDan" |
| | | ], |
| | | "name": "queryClass", |
| | | "name": "sourceType", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | "PaymentTypeQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.ReceiptKeywordType": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ReceiptKeywordCustomerName" |
| | | ] |
| | | }, |
| | | "constvar.ReceiptQueryClass": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ReceiptQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.ReceiptSourceType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | 4, |
| | | 5 |
| | | ], |
| | | "x-enum-comments": { |
| | | "ReceiptSourceTypeChuKuDan": "出库单it", |
| | | "ReceiptSourceTypeCollectionPlan": "收款计划", |
| | | "ReceiptSourceTypeInvoice": "销售发票", |
| | | "ReceiptSourceTypeSalesDetails": "销售明细单", |
| | | "ReceiptSourceTypeServiceContract": "服务合同" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "ReceiptSourceTypeSalesDetails", |
| | | "ReceiptSourceTypeServiceContract", |
| | |
| | | type: string |
| | | x-enum-varnames: |
| | | - PaymentTypeQueryClassExpireLessThen60Days |
| | | constvar.ReceiptKeywordType: |
| | | enum: |
| | | - "" |
| | | type: string |
| | | x-enum-varnames: |
| | | - ReceiptKeywordCustomerName |
| | | constvar.ReceiptQueryClass: |
| | | enum: |
| | | - "" |
| | | type: string |
| | | x-enum-varnames: |
| | | - ReceiptQueryClassExpireLessThen60Days |
| | | constvar.ReceiptSourceType: |
| | | enum: |
| | | - 1 |
| | |
| | | - 4 |
| | | - 5 |
| | | type: integer |
| | | x-enum-comments: |
| | | ReceiptSourceTypeChuKuDan: 出库单it |
| | | ReceiptSourceTypeCollectionPlan: 收款计划 |
| | | ReceiptSourceTypeInvoice: 销售发票 |
| | | ReceiptSourceTypeSalesDetails: 销售明细单 |
| | | ReceiptSourceTypeServiceContract: 服务合同 |
| | | x-enum-varnames: |
| | | - ReceiptSourceTypeSalesDetails |
| | | - ReceiptSourceTypeServiceContract |
| | |
| | | /api/receipt/list: |
| | | get: |
| | | parameters: |
| | | - in: query |
| | | name: keyword |
| | | type: string |
| | | - enum: |
| | | - "" |
| | | in: query |
| | | name: keywordType |
| | | type: string |
| | | x-enum-varnames: |
| | | - ReceiptKeywordCustomerName |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | - in: query |
| | | name: sourceId |
| | | type: integer |
| | | - enum: |
| | | - "" |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | - 5 |
| | | in: query |
| | | name: queryClass |
| | | type: string |
| | | name: sourceType |
| | | type: integer |
| | | x-enum-comments: |
| | | ReceiptSourceTypeChuKuDan: 出库单it |
| | | ReceiptSourceTypeCollectionPlan: 收款计划 |
| | | ReceiptSourceTypeInvoice: 销售发票 |
| | | ReceiptSourceTypeSalesDetails: 销售明细单 |
| | | ReceiptSourceTypeServiceContract: 服务合同 |
| | | x-enum-varnames: |
| | | - ReceiptQueryClassExpireLessThen60Days |
| | | - ReceiptSourceTypeSalesDetails |
| | | - ReceiptSourceTypeServiceContract |
| | | - ReceiptSourceTypeInvoice |
| | | - ReceiptSourceTypeCollectionPlan |
| | | - ReceiptSourceTypeChuKuDan |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | } |
| | | } |
| | | |
| | | func (slf *ReceiptSearch) SetSourceType(sourceType constvar.ReceiptSourceType) *ReceiptSearch { |
| | | slf.SourceType = sourceType |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ReceiptSearch) SetSourceId(sourceId int) *ReceiptSearch { |
| | | slf.SourceId = sourceId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ReceiptSearch) SetPage(page, size int) *ReceiptSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ReceiptSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Receipt{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.SourceType != 0 { |
| | | db = db.Where("source_type = ?", slf.SourceType) |
| | | } |
| | | if slf.SourceId != 0 { |
| | | db = db.Where("source_id = ?", slf.SourceId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | |
| | | package request |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | ) |
| | | |
| | | type AddReceipt struct { |
| | |
| | | |
| | | type GetReceiptList struct { |
| | | PageInfo |
| | | QueryClass constvar.ReceiptQueryClass `json:"queryClass" form:"queryClass"` |
| | | KeywordType constvar.ReceiptKeywordType `json:"keywordType" form:"keywordType"` |
| | | Keyword string `json:"keyword" form:"keyword"` |
| | | SourceType constvar.ReceiptSourceType `json:"sourceType" form:"sourceType"` |
| | | SourceId int `json:"sourceId" form:"sourceId"` |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ReceiptService) GetReceiptList() ([]*model.Receipt, int64, int) { |
| | | list, total, err := model.NewReceiptSearch().Find() |
| | | func (ReceiptService) GetReceiptList(params request.GetReceiptList) ([]*model.Receipt, int64, int) { |
| | | list, total, err := model.NewReceiptSearch(). |
| | | SetPage(params.Page, params.PageSize). |
| | | SetSourceType(params.SourceType). |
| | | SetSourceId(params.SourceId). |
| | | Find() |
| | | if err != nil { |
| | | return nil, 0, ecode.DBErr |
| | | } |