add
SalesRefund 销售退货单
add, Delete, update, list
| | |
| | | SubOrderApi |
| | | SalesDetailsApi |
| | | SalesReturnApi |
| | | SalesRefundApi |
| | | } |
| | | |
| | | var ApiGroup = new(Group) |
| | |
| | | subOrderService = service.ServiceGroup.SubOrderService |
| | | salesDetailsService = service.ServiceGroup.SalesDetailsService |
| | | salesReturnService = service.ServiceGroup.SalesReturnService |
| | | salesRefundService = service.ServiceGroup.SalesRefundService |
| | | ) |
New file |
| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | ) |
| | | |
| | | type SalesRefundApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags SalesRefund |
| | | // @Summary 添加销售退款 |
| | | // @Produce application/json |
| | | // @Param object body request.AddSalesRefundRequest true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesRefund/add [post] |
| | | func (s *SalesRefundApi) Add(c *gin.Context) { |
| | | var params request.AddSalesRefundRequest |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode, salesRefund := checkSalesRefundParams(params.SalesRefund) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | errCode = salesRefundService.AddSalesRefund(&salesRefund) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags SalesRefund |
| | | // @Summary 删除销售退款 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesRefund/delete/{id} [delete] |
| | | func (s *SalesRefundApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := salesRefundService.DeleteSalesRefund(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags SalesRefund |
| | | // @Summary 更新销售退款 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateSalesRefundRequest true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesRefund/update [put] |
| | | func (s *SalesRefundApi) Update(c *gin.Context) { |
| | | var params request.UpdateSalesRefundRequest |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode, salesRefund := checkSalesRefundParams(params.SalesRefund) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | salesRefund.Id = params.Id |
| | | |
| | | errCode = salesRefundService.UpdateSalesRefund(&salesRefund) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags SalesRefund |
| | | // @Summary 销售退款列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.SalesRefundResponse} |
| | | // @Router /api/salesRefund/list [get] |
| | | func (s *SalesRefundApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | list, errCode := salesRefundService.GetSalesRefundList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.SalesRefundResponse{ |
| | | List: list, |
| | | }) |
| | | |
| | | } |
| | | |
| | | func checkSalesRefundParams(salesRefund request.SalesRefund) (errCode int, salesRefundRes model.SalesRefund) { |
| | | if salesRefund.ClientId == 0 { |
| | | return ecode.InvalidParams, salesRefundRes |
| | | } |
| | | |
| | | if salesRefund.Number == "" { |
| | | return ecode.InvalidParams, salesRefundRes |
| | | } |
| | | |
| | | if salesRefund.MemberId == 0 { |
| | | return ecode.InvalidParams, salesRefundRes |
| | | } |
| | | |
| | | if salesRefund.RefundDate == "" { |
| | | return ecode.InvalidParams, salesRefundRes |
| | | } |
| | | |
| | | t, err := checkTimeFormat(salesRefund.RefundDate) |
| | | if err != nil { |
| | | return ecode.InvalidParams, salesRefundRes |
| | | } |
| | | salesRefundRes.RefundDate = t |
| | | salesRefundRes.ClientId = salesRefund.ClientId |
| | | salesRefundRes.Number = salesRefund.Number |
| | | salesRefundRes.MemberId = salesRefund.MemberId |
| | | salesRefundRes.RefundMethod = salesRefund.RefundMethod |
| | | salesRefundRes.AccountId = salesRefund.AccountId |
| | | salesRefundRes.IsInvoice = salesRefund.IsInvoice |
| | | salesRefundRes.Reason = salesRefund.Reason |
| | | salesRefundRes.Products = salesRefund.Products |
| | | |
| | | return ecode.OK, salesRefundRes |
| | | } |
| | |
| | | return |
| | | } |
| | | |
| | | salesReturn.Id = params.Id |
| | | |
| | | errCode = salesReturnService.UpdateSalesReturn(&salesReturn) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | |
| | | return |
| | | } |
| | | |
| | | subOrder.Id = params.Id |
| | | |
| | | errCode = subOrderService.UpdateSubOrder(&subOrder) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "添加销售退款", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSalesRefundRequest" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "删除销售退款", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "销售退款列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SalesRefundResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "更新销售退款", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSalesRefundRequest" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesReturn/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesRefund": { |
| | | "type": "object", |
| | | "properties": { |
| | | "accountId": { |
| | | "type": "integer" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "isInvoice": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "refundDate": { |
| | | "type": "string" |
| | | }, |
| | | "refundMethod": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesSources": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesRefundRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | | "salesRefund": { |
| | | "$ref": "#/definitions/request.SalesRefund" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesReturnRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | }, |
| | | "wechatOrderStatus": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.SalesRefund": { |
| | | "type": "object", |
| | | "properties": { |
| | | "accountId": { |
| | | "type": "integer" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "isInvoice": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "refundDate": { |
| | | "type": "string" |
| | | }, |
| | | "refundMethod": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesRefundRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "salesRefund": { |
| | | "$ref": "#/definitions/request.SalesRefund" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesReturnRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesRefundResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SalesRefund" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesSourceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "添加销售退款", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSalesRefundRequest" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "删除销售退款", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "销售退款列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SalesRefundResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesRefund/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SalesRefund" |
| | | ], |
| | | "summary": "更新销售退款", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSalesRefundRequest" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesReturn/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesRefund": { |
| | | "type": "object", |
| | | "properties": { |
| | | "accountId": { |
| | | "type": "integer" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "isInvoice": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "refundDate": { |
| | | "type": "string" |
| | | }, |
| | | "refundMethod": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SalesSources": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesRefundRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | | "salesRefund": { |
| | | "$ref": "#/definitions/request.SalesRefund" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSalesReturnRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | }, |
| | | "wechatOrderStatus": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.SalesRefund": { |
| | | "type": "object", |
| | | "properties": { |
| | | "accountId": { |
| | | "type": "integer" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "isInvoice": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "products": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Product" |
| | | } |
| | | }, |
| | | "reason": { |
| | | "type": "string" |
| | | }, |
| | | "refundDate": { |
| | | "type": "string" |
| | | }, |
| | | "refundMethod": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesRefundRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "salesRefund": { |
| | | "$ref": "#/definitions/request.SalesRefund" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSalesReturnRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesRefundResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SalesRefund" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SalesSourceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | sales_status: |
| | | $ref: '#/definitions/constvar.SalesStatus' |
| | | type: object |
| | | model.SalesRefund: |
| | | properties: |
| | | accountId: |
| | | type: integer |
| | | clientId: |
| | | type: integer |
| | | id: |
| | | type: integer |
| | | isInvoice: |
| | | type: integer |
| | | memberId: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | products: |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | reason: |
| | | type: string |
| | | refundDate: |
| | | type: string |
| | | refundMethod: |
| | | type: string |
| | | type: object |
| | | model.SalesSources: |
| | | properties: |
| | | id: |
| | |
| | | description: 商机来源ID |
| | | type: integer |
| | | type: object |
| | | request.AddSalesRefundRequest: |
| | | properties: |
| | | salesRefund: |
| | | $ref: '#/definitions/request.SalesRefund' |
| | | type: object |
| | | request.AddSalesReturnRequest: |
| | | properties: |
| | | salesReturn: |
| | |
| | | type: string |
| | | wechatOrderStatus: |
| | | type: integer |
| | | type: object |
| | | request.SalesRefund: |
| | | properties: |
| | | accountId: |
| | | type: integer |
| | | clientId: |
| | | type: integer |
| | | isInvoice: |
| | | type: integer |
| | | memberId: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | products: |
| | | items: |
| | | $ref: '#/definitions/model.Product' |
| | | type: array |
| | | reason: |
| | | type: string |
| | | refundDate: |
| | | type: string |
| | | refundMethod: |
| | | type: string |
| | | type: object |
| | | request.SalesReturn: |
| | | properties: |
| | |
| | | description: 商机来源ID |
| | | type: integer |
| | | type: object |
| | | request.UpdateSalesRefundRequest: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | salesRefund: |
| | | $ref: '#/definitions/request.SalesRefund' |
| | | type: object |
| | | request.UpdateSalesReturnRequest: |
| | | properties: |
| | | clientId: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SalesLeads' |
| | | type: array |
| | | type: object |
| | | response.SalesRefundResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SalesRefund' |
| | | type: array |
| | | type: object |
| | | response.SalesSourceResponse: |
| | |
| | | summary: 更新销售线索 |
| | | tags: |
| | | - SalesLeads |
| | | /api/salesRefund/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddSalesRefundRequest' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加销售退款 |
| | | tags: |
| | | - SalesRefund |
| | | /api/salesRefund/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: |
| | | - SalesRefund |
| | | /api/salesRefund/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.SalesRefundResponse' |
| | | type: object |
| | | summary: 销售退款列表 |
| | | tags: |
| | | - SalesRefund |
| | | /api/salesRefund/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateSalesRefundRequest' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新销售退款 |
| | | tags: |
| | | - SalesRefund |
| | | /api/salesReturn/add: |
| | | post: |
| | | parameters: |
| | |
| | | Product{}, |
| | | SalesDetails{}, |
| | | SalesReturn{}, |
| | | SalesRefund{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | import "aps_crm/model" |
| | | |
| | | type AddSalesRefundRequest struct { |
| | | SalesRefund SalesRefund `json:"salesRefund"` |
| | | } |
| | | |
| | | type SalesRefund struct { |
| | | ClientId int `json:"clientId"` |
| | | Number string `json:"number"` |
| | | MemberId int `json:"memberId"` |
| | | RefundDate string `json:"refundDate"` |
| | | RefundMethod string `json:"refundMethod"` |
| | | AccountId int `json:"accountId"` |
| | | IsInvoice int `json:"isInvoice"` |
| | | Reason string `json:"reason"` |
| | | Products []model.Product `json:"products"` |
| | | } |
| | | |
| | | type UpdateSalesRefundRequest struct { |
| | | Id int `json:"id"` |
| | | SalesRefund SalesRefund `json:"salesRefund"` |
| | | } |
| | |
| | | SalesReturnResponse struct { |
| | | List []*model.SalesReturn `json:"list"` |
| | | } |
| | | |
| | | SalesRefundResponse struct { |
| | | List []*model.SalesRefund `json:"list"` |
| | | } |
| | | ) |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | | SalesRefund struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:退款单号"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | RefundDate time.Time `json:"refundDate" gorm:"column:refund_date;type:datetime;comment:退款日期"` |
| | | RefundMethod string `json:"refundMethod" gorm:"column:refund_method;type:varchar(255);comment:退款方式"` |
| | | AccountId int `json:"accountId" gorm:"column:account_id;type:int;comment:账户"` |
| | | IsInvoice int `json:"isInvoice" gorm:"column:is_invoice;type:int;comment:是否开票"` |
| | | Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:退款原因"` |
| | | Products []Product `json:"products" gorm:"many2many:salesRefund_product;"` |
| | | } |
| | | |
| | | SalesRefundSearch struct { |
| | | SalesRefund |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (SalesRefund) TableName() string { |
| | | return "sales_refund" |
| | | } |
| | | |
| | | func NewSalesRefundSearch() *SalesRefundSearch { |
| | | return &SalesRefundSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&SalesRefund{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) Create(record *SalesRefund) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&SalesRefund{}).Error |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) Update(record *SalesRefund) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) Find() (*SalesRefund, error) { |
| | | var db = slf.build() |
| | | var record = new(SalesRefund) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) FindAll() ([]*SalesRefund, error) { |
| | | var db = slf.build() |
| | | var records = make([]*SalesRefund, 0) |
| | | err := db.Preload("Products").Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *SalesRefundSearch) SetId(id int) *SalesRefundSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | |
| | | SalesReturnUpdateErr = 2900005 // 更新销售退货单失败 |
| | | SalesReturnDeleteErr = 2900006 // 删除销售退货单失败 |
| | | |
| | | SalesRefundExist = 3000001 // 销售退款单已存在 |
| | | SalesRefundNotExist = 3000002 // 销售退款单不存在 |
| | | SalesRefundListErr = 3000003 // 获取销售退款单列表失败 |
| | | SalesRefundSetErr = 3000004 // 设置销售退款单失败 |
| | | SalesRefundUpdateErr = 3000005 // 更新销售退款单失败 |
| | | SalesRefundDeleteErr = 3000006 // 删除销售退款单失败 |
| | | ) |
| | |
| | | SubOrderRouter |
| | | SalesDetailsRouter |
| | | SalesReturnRouter |
| | | SalesRefundRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | routerGroup.InitSubOrderRouter(PrivateGroup) // 注册subOrder路由 |
| | | routerGroup.InitSalesDetailsRouter(PrivateGroup) // 注册salesDetails路由 |
| | | routerGroup.InitSalesReturnRouter(PrivateGroup) // 注册salesReturn路由 |
| | | routerGroup.InitSalesRefundRouter(PrivateGroup) // 注册salesRefund路由 |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type SalesRefundRouter struct{} |
| | | |
| | | func (s *SalesRefundRouter) InitSalesRefundRouter(router *gin.RouterGroup) { |
| | | salesRefundRouter := router.Group("salesRefund") |
| | | salesRefundApi := v1.ApiGroup.SalesRefundApi |
| | | { |
| | | salesRefundRouter.POST("add", salesRefundApi.Add) // 添加销售退款 |
| | | salesRefundRouter.DELETE("delete/:id", salesRefundApi.Delete) // 删除销售退款 |
| | | salesRefundRouter.PUT("update", salesRefundApi.Update) // 更新销售退款 |
| | | salesRefundRouter.GET("list", salesRefundApi.List) // 获取销售退款列表 |
| | | } |
| | | } |
| | |
| | | SubOrderService |
| | | SalesDetailsService |
| | | SalesReturnService |
| | | SalesRefundService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type SalesRefundService struct{} |
| | | |
| | | func (SalesRefundService) AddSalesRefund(salesRefund *model.SalesRefund) int { |
| | | err := model.NewSalesRefundSearch().Create(salesRefund) |
| | | if err != nil { |
| | | return ecode.SalesRefundExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesRefundService) DeleteSalesRefund(id int) int { |
| | | _, err := model.NewSalesRefundSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.SalesRefundNotExist |
| | | } |
| | | |
| | | err = model.NewSalesRefundSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.SalesRefundNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesRefundService) GetSalesRefundList() ([]*model.SalesRefund, int) { |
| | | list, err := model.NewSalesRefundSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.SalesRefundListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (SalesRefundService) UpdateSalesRefund(salesRefund *model.SalesRefund) int { |
| | | // check salesRefund exist |
| | | _, err := model.NewSalesRefundSearch().SetId(salesRefund.Id).Find() |
| | | if err != nil { |
| | | return ecode.SalesRefundNotExist |
| | | } |
| | | |
| | | err = model.NewSalesRefundSearch().SetId(salesRefund.Id).Update(salesRefund) |
| | | if err != nil { |
| | | return ecode.SalesRefundSetErr |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |