| | |
| | | package constvar |
| | | |
| | | type ReceiptQueryClass string |
| | | |
| | | const ( |
| | |
| | | const ( |
| | | ReceiptKeywordCustomerName ReceiptKeywordType = "" |
| | | ) |
| | | |
| | | type ReceiptSourceType int //来源类型(1销售明细单2服务合同3销售发票4收款计划5出库单) |
| | | |
| | | const ( |
| | | ReceiptSourceTypeSalesDetails ReceiptSourceType = 1 |
| | | ReceiptSourceTypeServiceContract ReceiptSourceType = 2 |
| | | ReceiptSourceTypeInvoice ReceiptSourceType = 3 |
| | | ReceiptSourceTypeCollectionPlan ReceiptSourceType = 4 |
| | | ReceiptSourceTypeChuKuDan ReceiptSourceType = 5 |
| | | ) |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "添加服务单状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddServiceOrderStatus" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "删除服务单状态", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "获取服务单状态列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "type": "string", |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusKeywordCustomerName" |
| | | ], |
| | | "name": "keywordType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "type": "string", |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusQueryClassExpireLessThen60Days" |
| | | ], |
| | | "name": "queryClass", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceOrderStatus" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "更新服务单状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateServiceOrderStatus" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceType/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "ServiceOrderQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.ServiceOrderStatusKeywordType": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusKeywordCustomerName" |
| | | ] |
| | | }, |
| | | "constvar.ServiceOrderStatusQueryClass": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.UserType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | "model.Receipt": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "收款金额", |
| | | "type": "string" |
| | | }, |
| | | "bankAccountId": { |
| | | "description": "账户id", |
| | | "type": "integer" |
| | |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "contact": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | }, |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "type": "string" |
| | | }, |
| | | "carFare": { |
| | | "description": "交通费", |
| | | "description": "交通费 // 交通费", |
| | | "type": "number" |
| | | }, |
| | | "chargeAmount": { |
| | | "description": "收费金额", |
| | | "description": "收费金额 // 收费金额", |
| | | "type": "number" |
| | | }, |
| | | "client": { |
| | |
| | | "description": "服务单编号", |
| | | "type": "string" |
| | | }, |
| | | "serviceOrderStatus": { |
| | | "$ref": "#/definitions/model.ServiceOrderStatus" |
| | | }, |
| | | "serviceType": { |
| | | "$ref": "#/definitions/model.ServiceType" |
| | | }, |
| | |
| | | "timeSpentId": { |
| | | "description": "花费时间", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceOrderStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "request.AddReceipt": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "收款金额", |
| | | "type": "string" |
| | | }, |
| | | "bankAccountId": { |
| | | "description": "账户id", |
| | | "type": "integer" |
| | |
| | | "timeSpentId": { |
| | | "description": "花费时间", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddServiceOrderStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "request.UpdateReceipt": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "收款金额", |
| | | "type": "string" |
| | | }, |
| | | "bankAccountId": { |
| | | "description": "账户id", |
| | | "type": "integer" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceOrderStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceType": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "添加服务单状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddServiceOrderStatus" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "删除服务单状态", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "获取服务单状态列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "type": "string", |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusKeywordCustomerName" |
| | | ], |
| | | "name": "keywordType", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "type": "string", |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusQueryClassExpireLessThen60Days" |
| | | ], |
| | | "name": "queryClass", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceOrderStatus" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceOrderStatus/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "服务单状态" |
| | | ], |
| | | "summary": "更新服务单状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateServiceOrderStatus" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceType/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "ServiceOrderQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.ServiceOrderStatusKeywordType": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusKeywordCustomerName" |
| | | ] |
| | | }, |
| | | "constvar.ServiceOrderStatusQueryClass": { |
| | | "type": "string", |
| | | "enum": [ |
| | | "" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "ServiceOrderStatusQueryClassExpireLessThen60Days" |
| | | ] |
| | | }, |
| | | "constvar.UserType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | "model.Receipt": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "收款金额", |
| | | "type": "string" |
| | | }, |
| | | "bankAccountId": { |
| | | "description": "账户id", |
| | | "type": "integer" |
| | |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "contact": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | }, |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "type": "string" |
| | | }, |
| | | "carFare": { |
| | | "description": "交通费", |
| | | "description": "交通费 // 交通费", |
| | | "type": "number" |
| | | }, |
| | | "chargeAmount": { |
| | | "description": "收费金额", |
| | | "description": "收费金额 // 收费金额", |
| | | "type": "number" |
| | | }, |
| | | "client": { |
| | |
| | | "description": "服务单编号", |
| | | "type": "string" |
| | | }, |
| | | "serviceOrderStatus": { |
| | | "$ref": "#/definitions/model.ServiceOrderStatus" |
| | | }, |
| | | "serviceType": { |
| | | "$ref": "#/definitions/model.ServiceType" |
| | | }, |
| | |
| | | "timeSpentId": { |
| | | "description": "花费时间", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceOrderStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "request.AddReceipt": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "收款金额", |
| | | "type": "string" |
| | | }, |
| | | "bankAccountId": { |
| | | "description": "账户id", |
| | | "type": "integer" |
| | |
| | | "timeSpentId": { |
| | | "description": "花费时间", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddServiceOrderStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "request.UpdateReceipt": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "收款金额", |
| | | "type": "string" |
| | | }, |
| | | "bankAccountId": { |
| | | "description": "账户id", |
| | | "type": "integer" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceOrderStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceType": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | type: string |
| | | x-enum-varnames: |
| | | - ServiceOrderQueryClassExpireLessThen60Days |
| | | constvar.ServiceOrderStatusKeywordType: |
| | | enum: |
| | | - "" |
| | | type: string |
| | | x-enum-varnames: |
| | | - ServiceOrderStatusKeywordCustomerName |
| | | constvar.ServiceOrderStatusQueryClass: |
| | | enum: |
| | | - "" |
| | | type: string |
| | | x-enum-varnames: |
| | | - ServiceOrderStatusQueryClassExpireLessThen60Days |
| | | constvar.UserType: |
| | | enum: |
| | | - 1 |
| | |
| | | type: object |
| | | model.Receipt: |
| | | properties: |
| | | amount: |
| | | description: 收款金额 |
| | | type: string |
| | | bankAccountId: |
| | | description: 账户id |
| | | type: integer |
| | |
| | | $ref: '#/definitions/model.Client' |
| | | clientId: |
| | | type: integer |
| | | contact: |
| | | $ref: '#/definitions/model.Contact' |
| | | contactId: |
| | | type: integer |
| | | endTime: |
| | |
| | | description: 预约上门时间 |
| | | type: string |
| | | carFare: |
| | | description: 交通费 |
| | | description: 交通费 // |
| | | 交通费 |
| | | type: number |
| | | chargeAmount: |
| | | description: 收费金额 |
| | | description: 收费金额 // |
| | | 收费金额 |
| | | type: number |
| | | client: |
| | | $ref: '#/definitions/model.Client' |
| | |
| | | serviceNumber: |
| | | description: 服务单编号 |
| | | type: string |
| | | serviceOrderStatus: |
| | | $ref: '#/definitions/model.ServiceOrderStatus' |
| | | serviceType: |
| | | $ref: '#/definitions/model.ServiceType' |
| | | serviceTypeId: |
| | |
| | | timeSpentId: |
| | | description: 花费时间 |
| | | type: integer |
| | | type: object |
| | | model.ServiceOrderStatus: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.ServiceType: |
| | | properties: |
| | |
| | | type: object |
| | | request.AddReceipt: |
| | | properties: |
| | | amount: |
| | | description: 收款金额 |
| | | type: string |
| | | bankAccountId: |
| | | description: 账户id |
| | | type: integer |
| | |
| | | timeSpentId: |
| | | description: 花费时间 |
| | | type: integer |
| | | type: object |
| | | request.AddServiceOrderStatus: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | request.AddServiceType: |
| | | properties: |
| | |
| | | type: object |
| | | request.UpdateReceipt: |
| | | properties: |
| | | amount: |
| | | description: 收款金额 |
| | | type: string |
| | | bankAccountId: |
| | | description: 账户id |
| | | type: integer |
| | |
| | | timeSpentId: |
| | | description: 花费时间 |
| | | type: integer |
| | | type: object |
| | | request.UpdateServiceOrderStatus: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | request.UpdateServiceType: |
| | | properties: |
| | |
| | | summary: 更新服务单 |
| | | tags: |
| | | - 服务单管理 |
| | | /api/serviceOrderStatus/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddServiceOrderStatus' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加服务单状态 |
| | | tags: |
| | | - 服务单状态 |
| | | /api/serviceOrderStatus/delete/{id}: |
| | | delete: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 删除服务单状态 |
| | | tags: |
| | | - 服务单状态 |
| | | /api/serviceOrderStatus/list: |
| | | get: |
| | | parameters: |
| | | - in: query |
| | | name: keyword |
| | | type: string |
| | | - enum: |
| | | - "" |
| | | in: query |
| | | name: keywordType |
| | | type: string |
| | | x-enum-varnames: |
| | | - ServiceOrderStatusKeywordCustomerName |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | - enum: |
| | | - "" |
| | | in: query |
| | | name: queryClass |
| | | type: string |
| | | x-enum-varnames: |
| | | - ServiceOrderStatusQueryClassExpireLessThen60Days |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/response.ListResponse' |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/model.ServiceOrderStatus' |
| | | type: array |
| | | type: object |
| | | summary: 获取服务单状态列表 |
| | | tags: |
| | | - 服务单状态 |
| | | /api/serviceOrderStatus/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateServiceOrderStatus' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新服务单状态 |
| | | tags: |
| | | - 服务单状态 |
| | | /api/serviceType/add: |
| | | post: |
| | | parameters: |
| | |
| | | ) |
| | | |
| | | type MoneyAdder interface { |
| | | AmountReceivableAdd(*gorm.DB, decimal.Decimal) |
| | | AmountReceivedAdd(*gorm.DB, decimal.Decimal) |
| | | AmountInvoicedAdd(*gorm.DB, decimal.Decimal) |
| | | AmountNotInvoicedAdd(*gorm.DB, decimal.Decimal) |
| | | AmountReceivableAdd(tx *gorm.DB, id int, amount decimal.Decimal) error |
| | | AmountReceivedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error |
| | | AmountInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error |
| | | AmountNotInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error |
| | | } |
| | |
| | | "aps_crm/pkg/mysqlx" |
| | | "errors" |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | |
| | | // Receipt 收款单 |
| | | Receipt struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `gorm:"client_id" json:"clientId"` // 客户id |
| | | SourceType int `gorm:"source_type" json:"sourceType"` // 来源类型(1销售明细单2服务合同3销售发票4收款计划5出库单) |
| | | SourceId int `gorm:"source_id" json:"sourceId"` // 源单id |
| | | PrincipalId int `gorm:"principal_id" json:"principalId"` // 负责人id |
| | | ReceiptDate string `gorm:"receipt_date" json:"receiptDate"` // 收款日期 |
| | | MoneyType string `gorm:"money_type" json:"moneyType"` // 币种 |
| | | PaymentTypeId int `gorm:"payment_type_id" json:"paymentTypeId"` // 收款方式ID |
| | | BankAccountId int `gorm:"bank_account_id" json:"bankAccountId"` // 账户id |
| | | Remark string `gorm:"remark" json:"remark"` // 备注 |
| | | FileId int `gorm:"file_id" json:"fileId"` // 附件id |
| | | ClientId int `gorm:"column:client_id;type:int;not null;default 0;comment:客户id" json:"clientId"` // 客户id |
| | | SourceType constvar.ReceiptSourceType `gorm:"column:source_type;type:int;not null;default 0;comment:来源类型(1销售明细单2服务合同3销售发票4收款计划5出库单)" json:"sourceType"` // 来源类型(1销售明细单2服务合同3销售发票4收款计划5出库单) |
| | | 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 |
| | | ReceiptDate string `gorm:"column:receipt_date;type:varchar(255);not null;default '';comment:收款日期" json:"receiptDate"` // 收款日期 |
| | | MoneyType string `gorm:"column:money_type;type:varchar(255);not null;default '';comment:币种" json:"moneyType"` // 币种 |
| | | Amount decimal.Decimal `gorm:"column:amount;type:decimal(12,2);not null;default '0.00';comment:收款金额" json:"amount"` // 收款金额 |
| | | PaymentTypeId int `gorm:"column:payment_type_id;type:int;not null;default 0;comment:收款方式ID" json:"paymentTypeId"` // 收款方式ID |
| | | BankAccountId int `gorm:"column:bank_account_id;type:int;not null;default 0;comment:账户id" json:"bankAccountId"` // 账户id |
| | | Remark string `gorm:"column:remark;type:varchar(255);not null;default '';comment:备注" json:"remark"` // 备注 |
| | | FileId int `gorm:"column:file_id;type:int;not null;default 0;comment:附件id" json:"fileId"` // 附件id |
| | | gorm.Model `json:"-"` |
| | | } |
| | | |
| | | // ReceiptSearch 收款单搜索条件 |
| | |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) SetOrm(tx *gorm.DB) *SalesDetailsSearch { |
| | | slf.Orm = tx |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SalesDetailsSearch) AmountReceivableAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountReceivable.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_receivable": amount}) |
| | | } |
| | | func (slf *SalesDetailsSearch) AmountReceivedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountReceived.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_received": amount}) |
| | | } |
| | | func (slf *SalesDetailsSearch) AmountInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountInvoiced.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_invoiced": amount}) |
| | | } |
| | | func (slf *SalesDetailsSearch) AmountNotInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountUnInvoiced.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_not_invoiced": amount}) |
| | | } |
| | |
| | | |
| | | return record, nil |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) AmountReceivableAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountReceivable.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_receivable": amount}) |
| | | } |
| | | func (slf *ServiceContractSearch) AmountReceivedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountReceived.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_received": amount}) |
| | | } |
| | | func (slf *ServiceContractSearch) AmountInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountInvoiced.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_invoiced": amount}) |
| | | } |
| | | func (slf *ServiceContractSearch) AmountNotInvoicedAdd(tx *gorm.DB, id int, amount decimal.Decimal) error { |
| | | slf.Orm = tx |
| | | record, err := slf.SetId(id).First() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | amount = record.AmountUnInvoiced.Add(amount) |
| | | return slf.UpdateByMap(map[string]interface{}{"amount_not_invoiced": amount}) |
| | | } |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ReceiptService struct{} |
| | |
| | | } |
| | | |
| | | func (ReceiptService) AddReceipt(receipt *model.Receipt) int { |
| | | err := model.NewReceiptSearch().Create(receipt) |
| | | var moneyAdder model.MoneyAdder |
| | | switch receipt.SourceType { |
| | | case constvar.ReceiptSourceTypeSalesDetails: |
| | | moneyAdder = model.NewSalesDetailsSearch() |
| | | case constvar.ReceiptSourceTypeServiceContract: |
| | | moneyAdder = model.NewServiceContractSearch() |
| | | } |
| | | err := model.WithTransaction(func(db *gorm.DB) error { |
| | | err := model.NewReceiptSearch().SetOrm(db).Create(receipt) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | return moneyAdder.AmountReceivableAdd(db, receipt.SourceId, decimal.Zero.Sub(receipt.Amount).Round(2)) |
| | | }) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ReceiptService) DeleteReceipt(id int) int { |
| | | receipt, err := model.NewReceiptSearch().SetId(id).First() |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | var moneyAdder model.MoneyAdder |
| | | switch receipt.SourceType { |
| | | case constvar.ReceiptSourceTypeSalesDetails: |
| | | moneyAdder = model.NewSalesDetailsSearch() |
| | | case constvar.ReceiptSourceTypeServiceContract: |
| | | moneyAdder = model.NewServiceContractSearch() |
| | | } |
| | | err = model.WithTransaction(func(db *gorm.DB) error { |
| | | err := model.NewReceiptSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | return moneyAdder.AmountReceivableAdd(db, receipt.SourceId, receipt.Amount.Round(2)) |
| | | }) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | |
| | | return ecode.DBErr |
| | | } |
| | | |
| | | err = model.NewReceiptSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | |
| | | }) |
| | | err = model.NewReceiptSearch().SetId(v.Id).Updates(map[string]interface{}{}) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | |
| | | } |
| | | |
| | | func (ReceiptService) UpdateReceipt(receipt *model.Receipt) int { |
| | | old, err := model.NewReceiptSearch().SetId(receipt.Id).First() |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | var moneyAdder model.MoneyAdder |
| | | switch receipt.SourceType { |
| | | case constvar.ReceiptSourceTypeSalesDetails: |
| | | moneyAdder = model.NewSalesDetailsSearch() |
| | | case constvar.ReceiptSourceTypeServiceContract: |
| | | moneyAdder = model.NewServiceContractSearch() |
| | | } |
| | | err = model.WithTransaction(func(db *gorm.DB) error { |
| | | err := model.NewReceiptSearch().SetId(receipt.Id).Save(receipt) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | diffAmount := receipt.Amount.Sub(old.Amount) |
| | | return moneyAdder.AmountReceivableAdd(db, receipt.SourceId, diffAmount.Round(2)) |
| | | }) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | return ecode.OK |