add
RefundMethod 退款方式
add, Delete, update, lis
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | RefundMethodApi |
| | | ServiceContractTypeApi |
| | | ServiceContractStatusApi |
| | | OrderTypeApi |
| | |
| | | orderTypeService = service.ServiceGroup.OrderTypeService |
| | | serviceContractStatusService = service.ServiceGroup.ServiceContractStatusService |
| | | serviceContractTypeService = service.ServiceGroup.ServiceContractTypeService |
| | | refundMethodService = service.ServiceGroup.RefundMethodService |
| | | ) |
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 RefundMethodApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags RefundMethod |
| | | // @Summary 添加退款方式 |
| | | // @Produce application/json |
| | | // @Param object body request.AddRefundMethod true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/refundMethod/add [post] |
| | | func (s *RefundMethodApi) Add(c *gin.Context) { |
| | | var params request.AddRefundMethod |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | refundMethod := new(model.RefundMethod) |
| | | refundMethod.Name = params.Name |
| | | |
| | | errCode := refundMethodService.AddRefundMethod(refundMethod) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags RefundMethod |
| | | // @Summary 删除退款方式 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/refundMethod/delete/{id} [delete] |
| | | func (s *RefundMethodApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := refundMethodService.DeleteRefundMethod(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags RefundMethod |
| | | // @Summary 更新退款方式 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateRefundMethods true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/refundMethod/update [put] |
| | | func (s *RefundMethodApi) Update(c *gin.Context) { |
| | | var params request.UpdateRefundMethods |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := refundMethodService.UpdateRefundMethod(params.RefundMethods) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags RefundMethod |
| | | // @Summary 获取退款方式列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.RefundMethodResponse} |
| | | // @Router /api/refundMethod/list [get] |
| | | func (s *RefundMethodApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | refundMethods, errCode := refundMethodService.GetRefundMethodList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.RefundMethodResponse{ |
| | | List: refundMethods, |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "添加退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddRefundMethod" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "删除退款方式", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "获取退款方式列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.RefundMethodResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "更新退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateRefundMethods" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/region/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.RefundMethod": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Region": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "integer" |
| | | }, |
| | | "validity_date": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddRefundMethod": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRefundMethod": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRefundMethods": { |
| | | "type": "object", |
| | | "required": [ |
| | | "refund_method" |
| | | ], |
| | | "properties": { |
| | | "refund_method": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateRefundMethod" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRegion": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.Province" |
| | | } |
| | | }, |
| | | "refundMethod": { |
| | | "description": "退款方式", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.RefundMethod" |
| | | } |
| | | }, |
| | | "region": { |
| | | "description": "区域数据", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.RefundMethodResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.RefundMethod" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.RegisteredCapitalResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "添加退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddRefundMethod" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "删除退款方式", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "获取退款方式列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.RefundMethodResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundMethod/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "RefundMethod" |
| | | ], |
| | | "summary": "更新退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateRefundMethods" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/region/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.RefundMethod": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Region": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "integer" |
| | | }, |
| | | "validity_date": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddRefundMethod": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRefundMethod": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRefundMethods": { |
| | | "type": "object", |
| | | "required": [ |
| | | "refund_method" |
| | | ], |
| | | "properties": { |
| | | "refund_method": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateRefundMethod" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRegion": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.Province" |
| | | } |
| | | }, |
| | | "refundMethod": { |
| | | "description": "退款方式", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.RefundMethod" |
| | | } |
| | | }, |
| | | "region": { |
| | | "description": "区域数据", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.RefundMethodResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.RefundMethod" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.RegisteredCapitalResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | validity_date: |
| | | type: string |
| | | type: object |
| | | model.RefundMethod: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.Region: |
| | | properties: |
| | | id: |
| | |
| | | type: integer |
| | | validity_date: |
| | | type: string |
| | | type: object |
| | | request.AddRefundMethod: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddRegion: |
| | | properties: |
| | |
| | | validity_date: |
| | | type: string |
| | | type: object |
| | | request.UpdateRefundMethod: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateRefundMethods: |
| | | properties: |
| | | refund_method: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateRefundMethod' |
| | | type: array |
| | | required: |
| | | - refund_method |
| | | type: object |
| | | request.UpdateRegion: |
| | | properties: |
| | | id: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Province' |
| | | type: array |
| | | refundMethod: |
| | | description: 退款方式 |
| | | items: |
| | | $ref: '#/definitions/model.RefundMethod' |
| | | type: array |
| | | region: |
| | | description: 区域数据 |
| | | items: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Quotation' |
| | | type: array |
| | | type: object |
| | | response.RefundMethodResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.RefundMethod' |
| | | type: array |
| | | type: object |
| | | response.RegisteredCapitalResponse: |
| | |
| | | summary: 更新报价单 |
| | | tags: |
| | | - Quotation |
| | | /api/refundMethod/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddRefundMethod' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加退款方式 |
| | | tags: |
| | | - RefundMethod |
| | | /api/refundMethod/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: |
| | | - RefundMethod |
| | | /api/refundMethod/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.RefundMethodResponse' |
| | | type: object |
| | | summary: 获取退款方式列表 |
| | | tags: |
| | | - RefundMethod |
| | | /api/refundMethod/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateRefundMethods' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新退款方式 |
| | | tags: |
| | | - RefundMethod |
| | | /api/region/add: |
| | | post: |
| | | parameters: |
| | |
| | | OrderType{}, |
| | | ServiceContractStatus{}, |
| | | ServiceContractType{}, |
| | | RefundMethod{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // RefundMethod 商机阶段 |
| | | RefundMethod struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | RefundMethodSearch struct { |
| | | RefundMethod |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (RefundMethod) TableName() string { |
| | | return "refund_method" |
| | | } |
| | | |
| | | func NewRefundMethodSearch() *RefundMethodSearch { |
| | | return &RefundMethodSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&RefundMethod{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) Create(record *RefundMethod) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&RefundMethod{}).Error |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) Update(record *RefundMethod) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) Find() (*RefundMethod, error) { |
| | | var db = slf.build() |
| | | var record = new(RefundMethod) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) FindAll() ([]*RefundMethod, error) { |
| | | var db = slf.build() |
| | | var records = make([]*RefundMethod, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) SetId(id int) *RefundMethodSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) SetName(name string) *RefundMethodSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *RefundMethodSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddRefundMethod struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateRefundMethod struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateRefundMethods struct { |
| | | RefundMethods []*UpdateRefundMethod `json:"refund_method" binding:"required"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 退款方式 |
| | | RefundMethod []*model.RefundMethod `json:"refundMethod"` |
| | | |
| | | |
| | | // 服务合同类型 |
| | | ServiceContractType []*model.ServiceContractType `json:"serviceContractType"` |
| | | |
| | |
| | | ServiceContractTypeResponse struct { |
| | | List []*model.ServiceContractType `json:"list"` |
| | | } |
| | | |
| | | RefundMethodResponse struct { |
| | | List []*model.RefundMethod `json:"list"` |
| | | } |
| | | ) |
| | |
| | | return slf |
| | | } |
| | | |
| | | // 合同类型 合同状态(服务合同) |
| | | // 付款方式 是否开票 账户(销售退款单) |
| | | // 退入仓库 状态(销售退货单) |
| | | // 报价单状态 (报价单) |
| | |
| | | OrderTypeSetErr = 4700004 // 设置工单类型失败 |
| | | OrderTypeUpdateErr = 4700005 // 更新工单类型失败 |
| | | |
| | | |
| | | ServiceContractStatusExist = 4400001 // 服务合同状态已存在 |
| | | ServiceContractStatusExist = 4800001 // 服务合同状态已存在 |
| | | ServiceContractStatusNotExist = 4400002 // 服务合同状态不存在 |
| | | ServiceContractStatusListErr = 4400003 // 获取服务合同状态列表失败 |
| | | ServiceContractStatusSetErr = 4400004 // 设置服务合同状态失败 |
| | | ServiceContractStatusUpdateErr = 4400005 // 更新服务合同状态失败 |
| | | ServiceContractStatusListErr = 4800003 // 获取服务合同状态列表失败 |
| | | ServiceContractStatusSetErr = 4800004 // 设置服务合同状态失败 |
| | | ServiceContractStatusUpdateErr = 4800005 // 更新服务合同状态失败 |
| | | |
| | | ServiceContractTypeExist = 4900001 // 服务合同类型已存在 |
| | | ServiceContractTypeNotExist = 4900002 // 服务合同类型不存在 |
| | | ServiceContractTypeListErr = 4900003 // 获取服务合同类型列表失败 |
| | | ServiceContractTypeSetErr = 4900004 // 设置服务合同类型失败 |
| | | ServiceContractTypeUpdateErr = 4900005 // 更新服务合同类型失败 |
| | | |
| | | |
| | | ServiceContractTypeExist = 4400001 // 服务合同类型已存在 |
| | | ServiceContractTypeNotExist = 4400002 // 服务合同类型不存在 |
| | | ServiceContractTypeListErr = 4400003 // 获取服务合同类型列表失败 |
| | | ServiceContractTypeSetErr = 4400004 // 设置服务合同类型失败 |
| | | ServiceContractTypeUpdateErr = 4400005 // 更新服务合同类型失败 |
| | | RefundMethodExist = 5000001 // 退款方式已存在 |
| | | RefundMethodNotExist = 5000002 // 退款方式不存在 |
| | | RefundMethodListErr = 5000003 // 获取退款方式列表失败 |
| | | RefundMethodSetErr = 5000004 // 设置退款方式失败 |
| | | RefundMethodUpdateErr = 5000005 // 更新退款方式失败 |
| | | |
| | | ) |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | RefundMethodRouter |
| | | ServiceContractTypeRouter |
| | | ServiceContractStatusRouter |
| | | OrderTypeRouter |
| | |
| | | routerGroup.InitOrderTypeRouter(PrivateGroup) |
| | | routerGroup.InitServiceContractStatusRouter(PrivateGroup) |
| | | routerGroup.InitServiceContractTypeRouter(PrivateGroup) |
| | | routerGroup.InitRefundMethodRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type RefundMethodRouter struct{} |
| | | |
| | | func (s *RefundMethodRouter) InitRefundMethodRouter(router *gin.RouterGroup) { |
| | | refundMethodRouter := router.Group("refundMethod") |
| | | refundMethodApi := v1.ApiGroup.RefundMethodApi |
| | | { |
| | | refundMethodRouter.POST("add", refundMethodApi.Add) // 添加$CName$ |
| | | refundMethodRouter.DELETE("delete/:id", refundMethodApi.Delete) // 删除$CName$ |
| | | refundMethodRouter.PUT("update", refundMethodApi.Update) // 更新$CName$ |
| | | refundMethodRouter.GET("list", refundMethodApi.List) // 获取$CName$列表 |
| | | } |
| | | } |
| | |
| | | data.ServiceContractType = serviceContractTypeList |
| | | |
| | | |
| | | // get RefundMethod list |
| | | refundMethodList, _ := ServiceGroup.GetRefundMethodList() |
| | | data.RefundMethod = refundMethodList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | |
| | | OrderTypeService |
| | | ServiceContractStatusService |
| | | ServiceContractTypeService |
| | | RefundMethodService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type RefundMethodService struct{} |
| | | |
| | | func (RefundMethodService) AddRefundMethod(refundMethod *model.RefundMethod) int { |
| | | err := model.NewRefundMethodSearch().Create(refundMethod) |
| | | if err != nil { |
| | | return ecode.RefundMethodExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (RefundMethodService) DeleteRefundMethod(id int) int { |
| | | _, err := model.NewRefundMethodSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.RefundMethodNotExist |
| | | } |
| | | |
| | | err = model.NewRefundMethodSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.RefundMethodNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (RefundMethodService) GetRefundMethodList() ([]*model.RefundMethod, int) { |
| | | list, err := model.NewRefundMethodSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.RefundMethodListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (RefundMethodService) UpdateRefundMethod(refundMethods []*request.UpdateRefundMethod) int { |
| | | for _, v := range refundMethods { |
| | | // check refundMethod exist |
| | | _, err := model.NewRefundMethodSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.RefundMethodNotExist |
| | | } |
| | | |
| | | err = model.NewRefundMethodSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.RefundMethodSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (RefundMethodService) GetRefundMethodDetail(id int) (*model.RefundMethod, int) { |
| | | refundMethod, err := model.NewRefundMethodSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.RefundMethodNotExist |
| | | } |
| | | |
| | | return refundMethod, ecode.OK |
| | | } |