Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm
New file |
| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/service" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | ) |
| | | |
| | | type RefundTypeApi struct{} |
| | | |
| | | // Add |
| | | // @Tags 退款方式管理 |
| | | // @Summary 添加退款方式 |
| | | // @Produce application/json |
| | | // @Param object body request.AddRefundType true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/refundType/add [post] |
| | | func (s *RefundTypeApi) Add(c *gin.Context) { |
| | | var params request.AddRefundType |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := service.NewRefundTypeService().AddRefundType(¶ms.RefundType) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // @Tags 退款方式管理 |
| | | // @Summary 删除退款方式 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/refundType/delete/{id} [delete] |
| | | func (s *RefundTypeApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := service.NewRefundTypeService().DeleteRefundType(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // @Tags 退款方式管理 |
| | | // @Summary 更新退款方式 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateRefundType true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/refundType/update [put] |
| | | func (s *RefundTypeApi) Update(c *gin.Context) { |
| | | var params request.UpdateRefundType |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | if params.Id == 0 { |
| | | ctx.Fail(ecode.ParamsErr) |
| | | } |
| | | params.RefundType.Id = params.Id |
| | | |
| | | errCode := service.NewRefundTypeService().UpdateRefundType(¶ms.RefundType) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // @Tags 退款方式管理 |
| | | // @Summary 获取退款方式列表 |
| | | // @Produce application/json |
| | | // @Param object query request.GetRefundTypeList true "参数" |
| | | // @Success 200 {object} response.ListResponse{data=[]model.RefundType} |
| | | // @Router /api/refundType/list [get] |
| | | func (s *RefundTypeApi) List(c *gin.Context) { |
| | | var params request.GetRefundTypeList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | RefundType, total, errCode := service.NewRefundTypeService().GetRefundTypeList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ListResponse{ |
| | | Data: RefundType, |
| | | Count: total, |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundType/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "退款方式管理" |
| | | ], |
| | | "summary": "添加退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddRefundType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundType/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/refundType/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "退款方式管理" |
| | | ], |
| | | "summary": "获取退款方式列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.RefundType" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundType/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "退款方式管理" |
| | | ], |
| | | "summary": "更新退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateRefundType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/region/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.RefundType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Region": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | "$ref": "#/definitions/model.Status" |
| | | }, |
| | | "threats": { |
| | | "type": "string" |
| | |
| | | "model.SalesRefund": { |
| | | "type": "object", |
| | | "properties": { |
| | | "RefundType": { |
| | | "description": "退款方式", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/model.RefundType" |
| | | } |
| | | ] |
| | | }, |
| | | "Source": { |
| | | "$ref": "#/definitions/model.SalesReturn" |
| | | }, |
| | |
| | | }, |
| | | "refundDate": { |
| | | "type": "string" |
| | | }, |
| | | "refundTypeId": { |
| | | "description": "退款方式ID", |
| | | "type": "integer" |
| | | }, |
| | | "sourceId": { |
| | | "description": "源单id", |
| | |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddRefundType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRefundType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRegion": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundType/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "退款方式管理" |
| | | ], |
| | | "summary": "添加退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddRefundType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundType/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/refundType/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "退款方式管理" |
| | | ], |
| | | "summary": "获取退款方式列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/response.ListResponse" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.RefundType" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/refundType/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "退款方式管理" |
| | | ], |
| | | "summary": "更新退款方式", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateRefundType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/region/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.RefundType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Region": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "string" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | "$ref": "#/definitions/model.Status" |
| | | }, |
| | | "threats": { |
| | | "type": "string" |
| | |
| | | "model.SalesRefund": { |
| | | "type": "object", |
| | | "properties": { |
| | | "RefundType": { |
| | | "description": "退款方式", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/model.RefundType" |
| | | } |
| | | ] |
| | | }, |
| | | "Source": { |
| | | "$ref": "#/definitions/model.SalesReturn" |
| | | }, |
| | |
| | | }, |
| | | "refundDate": { |
| | | "type": "string" |
| | | }, |
| | | "refundTypeId": { |
| | | "description": "退款方式ID", |
| | | "type": "integer" |
| | | }, |
| | | "sourceId": { |
| | | "description": "源单id", |
| | |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddRefundType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRefundType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateRegion": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.RefundType: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.Region: |
| | | properties: |
| | | id: |
| | |
| | | solutions: |
| | | type: string |
| | | status_id: |
| | | type: integer |
| | | $ref: '#/definitions/model.Status' |
| | | threats: |
| | | type: string |
| | | whether_established: |
| | |
| | | type: object |
| | | model.SalesRefund: |
| | | properties: |
| | | RefundType: |
| | | allOf: |
| | | - $ref: '#/definitions/model.RefundType' |
| | | description: 退款方式 |
| | | Source: |
| | | $ref: '#/definitions/model.SalesReturn' |
| | | amountTotal: |
| | |
| | | type: string |
| | | refundDate: |
| | | type: string |
| | | refundTypeId: |
| | | description: 退款方式ID |
| | | type: integer |
| | | sourceId: |
| | | description: 源单id |
| | | type: integer |
| | |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddRefundType: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | request.AddRegion: |
| | | properties: |
| | |
| | | type: array |
| | | required: |
| | | - refund_method |
| | | type: object |
| | | request.UpdateRefundType: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | request.UpdateRegion: |
| | | properties: |
| | |
| | | summary: 更新退款方式 |
| | | tags: |
| | | - RefundMethod |
| | | /api/refundType/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddRefundType' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加退款方式 |
| | | tags: |
| | | - 退款方式管理 |
| | | /api/refundType/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/refundType/list: |
| | | get: |
| | | parameters: |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/response.ListResponse' |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/model.RefundType' |
| | | type: array |
| | | type: object |
| | | summary: 获取退款方式列表 |
| | | tags: |
| | | - 退款方式管理 |
| | | /api/refundType/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateRefundType' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新退款方式 |
| | | tags: |
| | | - 退款方式管理 |
| | | /api/region/add: |
| | | post: |
| | | parameters: |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "errors" |
| | | "fmt" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | | // RefundType 退款方式 |
| | | RefundType struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name"` |
| | | } |
| | | |
| | | // RefundTypeSearch 支付方式搜索条件 |
| | | RefundTypeSearch struct { |
| | | RefundType |
| | | Orm *gorm.DB |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | | func (RefundType) TableName() string { |
| | | return "refund_type" |
| | | } |
| | | |
| | | func NewRefundTypeSearch() *RefundTypeSearch { |
| | | return &RefundTypeSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&RefundType{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) Create(record *RefundType) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) CreateBatch(records []*RefundType) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&RefundType{}).Error |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) Update(record *RefundType) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) FindAll() ([]*RefundType, error) { |
| | | var db = slf.build() |
| | | var record = make([]*RefundType, 0) |
| | | err := db.Find(&record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) SetId(id int) *RefundTypeSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) SetOrm(tx *gorm.DB) *RefundTypeSearch { |
| | | slf.Orm = tx |
| | | return slf |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) First() (*RefundType, error) { |
| | | var db = slf.build() |
| | | var record = new(RefundType) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) Updates(values interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(values).Error |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) Save(record *RefundType) error { |
| | | if record.Id == 0 { |
| | | return errors.New("id为空") |
| | | } |
| | | var db = slf.build() |
| | | |
| | | if err := db.Save(record).Error; err != nil { |
| | | return fmt.Errorf("save err: %v, record: %+v", err, record) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *RefundTypeSearch) Find() ([]*RefundType, int64, error) { |
| | | var db = slf.build() |
| | | var records = make([]*RefundType, 0) |
| | | var total int64 |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return records, total, err |
| | | } |
| | | if slf.PageNum > 0 && slf.PageSize > 0 { |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | err := db.Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *RefundTypeSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*RefundType{ |
| | | {1, "原路返回"}, |
| | | {2, "线下"}, |
| | | {3, "支票"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | "errors" |
| | | "fmt" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | | // BankAccount 银行账户 |
| | | BankAccount struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name"` |
| | | Name string `json:"name" gorm:"column:name"` |
| | | } |
| | | |
| | | // BankAccountSearch 银行账户搜索条件 |
| | | BankAccountSearch struct { |
| | | BankAccount |
| | | Orm *gorm.DB |
| | | QueryClass constvar.BankAccountQueryClass |
| | | KeywordType constvar.BankAccountKeywordType |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | QueryClass constvar.BankAccountQueryClass |
| | | KeywordType constvar.BankAccountKeywordType |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *BankAccountSearch) InitDefaultData() error { |
| | | func (slf *BankAccountSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return err |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return nil |
| | | return |
| | | } |
| | | records := []*BankAccount{} |
| | | return slf.CreateBatch(records) |
| | | records := []*BankAccount{ |
| | | {1, "默认账户"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *ClientLevelSearch) CreateBatch(records []*ClientLevel) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *ClientLevelSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*ClientLevel{ |
| | | {1, "重点关注客户"}, |
| | | {2, "优质客户"}, |
| | | {3, "普通客户"}, |
| | | {4, "其他"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *ClientOriginSearch) CreateBatch(records []*ClientOrigin) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *ClientOriginSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*ClientOrigin{ |
| | | {1, "供应商资源"}, |
| | | {2, "客户介绍"}, |
| | | {3, "现有客户"}, |
| | | {4, "展会"}, |
| | | {5, "外出拜访客户"}, |
| | | {6, "其他"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *ClientTypeSearch) CreateBatch(records []*ClientType) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *ClientTypeSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*ClientType{ |
| | | {1, "代理商"}, |
| | | {2, "集成商"}, |
| | | {3, "合作伙伴"}, |
| | | {4, "其他"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ContactInformationSearch) CreateBatch(records []*ContactInformation) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *ContactInformationSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*ContactInformation{ |
| | | {1, "线下拜访"}, |
| | | {2, "电话联系"}, |
| | | {3, "会议"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *EnterpriseNatureSearch) CreateBatch(records []*EnterpriseNature) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *EnterpriseNatureSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*EnterpriseNature{ |
| | | {1, "国有企业"}, |
| | | {2, "集体企业"}, |
| | | {3, "私营企业"}, |
| | | {4, "个体工商户"}, |
| | | {5, "合伙企业"}, |
| | | {6, "联营企业"}, |
| | | {7, "股份合作制企业"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *EnterpriseScaleSearch) CreateBatch(records []*EnterpriseScale) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *EnterpriseScaleSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*EnterpriseScale{ |
| | | {1, "20人以下"}, |
| | | {2, "20-50人"}, |
| | | {3, "50-100人"}, |
| | | {4, "100-500人"}, |
| | | {5, "500-1000人"}, |
| | | {6, "1000人以上"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | InvoiceStatus{}, |
| | | InvoiceType{}, |
| | | Invoice{}, |
| | | RefundType{}, |
| | | ) |
| | | return err |
| | | } |
| | |
| | | NewQuotationStatusSearch(), |
| | | NewSalesSourcesSearch(), |
| | | NewClientStatusSearch(), |
| | | NewClientTypeSearch(), |
| | | NewClientOriginSearch(), |
| | | NewClientLevelSearch(), |
| | | NewIndustrySearch(), |
| | | NewRegisteredCapitalSearch(), |
| | | NewEnterpriseNatureSearch(), |
| | | NewEnterpriseScaleSearch(), |
| | | NewContactInformationSearch(), |
| | | NewSaleTypeSearch(), |
| | | NewPossibilitySearch(), |
| | | NewStatusSearch(), |
| | | NewPaymentTypeSearch(), |
| | | NewBankAccountSearch(), |
| | | NewRefundTypeSearch(), |
| | | } |
| | | |
| | | for _, model := range models { |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *IndustrySearch) CreateBatch(records []*Industry) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *IndustrySearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*Industry{ |
| | | {1, "制造业"}, |
| | | {2, "交通运输"}, |
| | | {3, "建筑业"}, |
| | | {4, "环境和公共设施管理业"}, |
| | | {5, "批发和零售业"}, |
| | | {6, "其他"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | "errors" |
| | | "fmt" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | | // PaymentType 支付方式 |
| | | PaymentType struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name"` |
| | | Name string `json:"name" gorm:"column:name"` |
| | | } |
| | | |
| | | // PaymentTypeSearch 支付方式搜索条件 |
| | | PaymentTypeSearch struct { |
| | | PaymentType |
| | | Orm *gorm.DB |
| | | QueryClass constvar.PaymentTypeQueryClass |
| | | KeywordType constvar.PaymentTypeKeywordType |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | QueryClass constvar.PaymentTypeQueryClass |
| | | KeywordType constvar.PaymentTypeKeywordType |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *PaymentTypeSearch) InitDefaultData() error { |
| | | func (slf *PaymentTypeSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return err |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return nil |
| | | return |
| | | } |
| | | records := []*PaymentType{} |
| | | return slf.CreateBatch(records) |
| | | |
| | | records := []*PaymentType{ |
| | | {1, "对公转账"}, |
| | | {2, "线下付款"}, |
| | | {3, "支票"}, |
| | | {4, "其他"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *PossibilitySearch) CreateBatch(records []*Possibility) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *PossibilitySearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*Possibility{ |
| | | {1, "100%"}, |
| | | {2, "90%"}, |
| | | {3, "80%"}, |
| | | {4, "70%"}, |
| | | {5, "60%"}, |
| | | {6, "50%"}, |
| | | {7, "40%"}, |
| | | {8, "30%"}, |
| | | {9, "20%"}, |
| | | {10, "10%"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *RegisteredCapitalSearch) CreateBatch(records []*RegisteredCapital) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *RegisteredCapitalSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*RegisteredCapital{ |
| | | {1, "50万以下"}, |
| | | {2, "50-100万"}, |
| | | {3, "100-500万"}, |
| | | {4, "500-1000万"}, |
| | | {5, "1000万以上"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | ) |
| | | |
| | | type AddRefundType struct { |
| | | model.RefundType |
| | | } |
| | | |
| | | type UpdateRefundType struct { |
| | | Id int `json:"id"` |
| | | model.RefundType |
| | | } |
| | | |
| | | type GetRefundTypeList struct { |
| | | PageInfo |
| | | } |
| | |
| | | Currency int `json:"currency" gorm:"column:currency;type:int(11);comment:币种"` |
| | | ExpectedTime *CustomTime `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:预计成交时间"` |
| | | StatusId int `json:"status_id" gorm:"column:status_id;type:int(11);comment:状态ID"` |
| | | Status Status `json:"status"` //状态 |
| | | PainPoints string `json:"pain_points" gorm:"column:pain_points;type:text;comment:痛点"` |
| | | WhetherEstablished string `json:"whether_established" gorm:"column:whether_established;type:text;comment:是否成立"` |
| | | CapitalBudget string `json:"capital_budget" gorm:"column:capital_budget;type:text;comment:资金预算"` |
| | |
| | | err := db.Preload("SaleType").Preload("RegularCustomers").Preload("SalesSources").Preload("Products"). |
| | | Preload("Member").Preload("SaleStage").Preload("Possibility"). |
| | | Preload("CollectionProjections").Preload("Client"). |
| | | Preload("Province").Preload("City").Preload("Contact").Order("id desc").Find(&records).Error |
| | | Preload("Province").Preload("City").Preload("Contact").Preload("Status").Order("id desc").Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *SaleTypeSearch) CreateBatch(records []*SaleType) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *SaleTypeSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*SaleType{ |
| | | {1, "新业务"}, |
| | | {2, "传统业务"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
| | |
| | | RefundDate string `json:"refundDate" gorm:"column:refund_date;type:varchar(255);comment:退款日期"` |
| | | PaymentTypeId int `gorm:"column:payment_type_id;type:int;not null;default 0;comment:收款方式ID" json:"paymentTypeId"` // 收款方式ID |
| | | PaymentType PaymentType `gorm:"foreignKey:PaymentTypeId" json:"paymentType"` |
| | | RefundTypeId int `gorm:"column:refund_type_id;type:int;not null;default 0;comment:收款方式ID" json:"refundTypeId"` // 退款方式ID |
| | | RefundType RefundType `gorm:"foreignKey:RefundTypeId" json:"RefundType"` //退款方式 |
| | | BankAccountId int `gorm:"column:bank_account_id;type:int;not null;default 0;comment:账户id" json:"bankAccountId"` // 账户id |
| | | BankAccount BankAccount `gorm:"foreignKey:BankAccountId" json:"bankAccount"` |
| | | IsInvoice string `json:"isInvoice" gorm:"column:is_invoice;type:varchar(255);comment:是否开票"` |
| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "sync" |
| | | ) |
| | | |
| | | type ( |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *StatusSearch) CreateBatch(records []*Status) error { |
| | | var db = slf.build() |
| | | return db.Create(records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *StatusSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | defer wg.Done() |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | if total != 0 { |
| | | return |
| | | } |
| | | records := []*Status{ |
| | | {1, "已成交"}, |
| | | {2, "未成交"}, |
| | | } |
| | | err := slf.CreateBatch(records) |
| | | if err != nil { |
| | | errCh <- err |
| | | return |
| | | } |
| | | } |
New file |
| | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | func InitRefundTypeRouter(router *gin.RouterGroup) { |
| | | RefundTypeRouter := router.Group("refundType") |
| | | RefundTypeApi := v1.RefundTypeApi{} |
| | | { |
| | | RefundTypeRouter.POST("add", RefundTypeApi.Add) // 添加退款方式 |
| | | RefundTypeRouter.DELETE("delete/:id", RefundTypeApi.Delete) // 删除退款方式 |
| | | RefundTypeRouter.PUT("update", RefundTypeApi.Update) // 更新退款方式 |
| | | RefundTypeRouter.GET("list", RefundTypeApi.List) // 获取退款方式列表 |
| | | } |
| | | } |
| | |
| | | InitReceiptRouter(PrivateGroup) |
| | | InitBankAccountRouter(PrivateGroup) |
| | | InitPaymentTypeRouter(PrivateGroup) |
| | | InitRefundTypeRouter(PrivateGroup) |
| | | InitFileRouter(PrivateGroup) |
| | | InitInvoiceRouter(PrivateGroup) |
| | | InitInvoiceStatusRouter(PrivateGroup) |
New file |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type RefundTypeService struct{} |
| | | |
| | | func NewRefundTypeService() RefundTypeService { |
| | | return RefundTypeService{} |
| | | } |
| | | |
| | | func (RefundTypeService) AddRefundType(RefundType *model.RefundType) int { |
| | | err := model.NewRefundTypeSearch().Create(RefundType) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (RefundTypeService) DeleteRefundType(id int) int { |
| | | err := model.NewRefundTypeSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (RefundTypeService) GetRefundTypeList() ([]*model.RefundType, int64, int) { |
| | | list, total, err := model.NewRefundTypeSearch().Find() |
| | | if err != nil { |
| | | return nil, 0, ecode.DBErr |
| | | } |
| | | |
| | | return list, total, ecode.OK |
| | | } |
| | | |
| | | func (RefundTypeService) UpdateRefundTypes(RefundTypes []*request.UpdateRefundType) int { |
| | | for _, v := range RefundTypes { |
| | | // check RefundType exist |
| | | _, err := model.NewRefundTypeSearch().SetId(v.Id).First() |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | |
| | | err = model.NewRefundTypeSearch().SetId(v.Id).Updates(map[string]interface{}{}) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (RefundTypeService) UpdateRefundType(RefundType *model.RefundType) int { |
| | | err := model.NewRefundTypeSearch().SetId(RefundType.Id).Update(RefundType) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |
| | | return ecode.OK |
| | | } |