From bf9d36e5474301bcfe571606d9caaa7ceefa8192 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 21 七月 2023 11:41:26 +0800
Subject: [PATCH] add

---
 api/v1/index.go               |    2 
 router/refundMethod.go        |   20 +
 api/v1/refundMethod.go        |  113 +++++++
 service/dataServer.go         |    5 
 model/request/refundMethod.go |   15 +
 pkg/ecode/code.go             |   25 +
 service/refundMethod.go       |   69 ++++
 docs/swagger.yaml             |  118 +++++++
 docs/docs.go                  |  188 ++++++++++++
 docs/swagger.json             |  188 ++++++++++++
 model/response/response.go    |    8 
 model/serviceFollowup.go      |    1 
 service/index.go              |    1 
 model/index.go                |    1 
 router/index.go               |    2 
 model/refundMethod.go         |   85 +++++
 16 files changed, 830 insertions(+), 11 deletions(-)

diff --git a/api/v1/index.go b/api/v1/index.go
index c0462e3..99416d6 100644
--- a/api/v1/index.go
+++ b/api/v1/index.go
@@ -5,6 +5,7 @@
 )
 
 type Group struct {
+    RefundMethodApi
     ServiceContractTypeApi
     ServiceContractStatusApi
     OrderTypeApi
@@ -114,4 +115,5 @@
    orderTypeService    = service.ServiceGroup.OrderTypeService
    serviceContractStatusService    = service.ServiceGroup.ServiceContractStatusService
    serviceContractTypeService    = service.ServiceGroup.ServiceContractTypeService
+   refundMethodService    = service.ServiceGroup.RefundMethodService
 )
\ No newline at end of file
diff --git a/api/v1/refundMethod.go b/api/v1/refundMethod.go
new file mode 100644
index 0000000..38206c1
--- /dev/null
+++ b/api/v1/refundMethod.go
@@ -0,0 +1,113 @@
+
+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, &params)
+	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, &params)
+	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,
+	})
+}
diff --git a/docs/docs.go b/docs/docs.go
index 2c7bb37..3a94799 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -3064,6 +3064,125 @@
                 }
             }
         },
+        "/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": [
@@ -6796,6 +6915,17 @@
                 }
             }
         },
+        "model.RefundMethod": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "model.Region": {
             "type": "object",
             "properties": {
@@ -7927,6 +8057,17 @@
                     "type": "integer"
                 },
                 "validity_date": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.AddRefundMethod": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
                     "type": "string"
                 }
             }
@@ -9693,6 +9834,35 @@
                 }
             }
         },
+        "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": {
@@ -10690,6 +10860,13 @@
                         "$ref": "#/definitions/model.Province"
                     }
                 },
+                "refundMethod": {
+                    "description": "閫�娆炬柟寮�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RefundMethod"
+                    }
+                },
                 "region": {
                     "description": "鍖哄煙鏁版嵁",
                     "type": "array",
@@ -10948,6 +11125,17 @@
                 }
             }
         },
+        "response.RefundMethodResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RefundMethod"
+                    }
+                }
+            }
+        },
         "response.RegisteredCapitalResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index b95b3d4..d23d994 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -3052,6 +3052,125 @@
                 }
             }
         },
+        "/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": [
@@ -6784,6 +6903,17 @@
                 }
             }
         },
+        "model.RefundMethod": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "model.Region": {
             "type": "object",
             "properties": {
@@ -7915,6 +8045,17 @@
                     "type": "integer"
                 },
                 "validity_date": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.AddRefundMethod": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
                     "type": "string"
                 }
             }
@@ -9681,6 +9822,35 @@
                 }
             }
         },
+        "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": {
@@ -10678,6 +10848,13 @@
                         "$ref": "#/definitions/model.Province"
                     }
                 },
+                "refundMethod": {
+                    "description": "閫�娆炬柟寮�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RefundMethod"
+                    }
+                },
                 "region": {
                     "description": "鍖哄煙鏁版嵁",
                     "type": "array",
@@ -10936,6 +11113,17 @@
                 }
             }
         },
+        "response.RefundMethodResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.RefundMethod"
+                    }
+                }
+            }
+        },
         "response.RegisteredCapitalResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 86d519f..e35ef28 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -544,6 +544,13 @@
       validity_date:
         type: string
     type: object
+  model.RefundMethod:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+    type: object
   model.Region:
     properties:
       id:
@@ -1298,6 +1305,13 @@
         type: integer
       validity_date:
         type: string
+    type: object
+  request.AddRefundMethod:
+    properties:
+      name:
+        type: string
+    required:
+    - name
     type: object
   request.AddRegion:
     properties:
@@ -2491,6 +2505,25 @@
       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:
@@ -3159,6 +3192,11 @@
         items:
           $ref: '#/definitions/model.Province'
         type: array
+      refundMethod:
+        description: 閫�娆炬柟寮�
+        items:
+          $ref: '#/definitions/model.RefundMethod'
+        type: array
       region:
         description: 鍖哄煙鏁版嵁
         items:
@@ -3328,6 +3366,13 @@
       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:
@@ -5343,6 +5388,79 @@
       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:
diff --git a/model/index.go b/model/index.go
index 1afdc62..5c19858 100644
--- a/model/index.go
+++ b/model/index.go
@@ -72,6 +72,7 @@
         OrderType{},
         ServiceContractStatus{},
         ServiceContractType{},
+        RefundMethod{},
 	)
 	return err
 }
\ No newline at end of file
diff --git a/model/refundMethod.go b/model/refundMethod.go
new file mode 100644
index 0000000..f9f0c92
--- /dev/null
+++ b/model/refundMethod.go
@@ -0,0 +1,85 @@
+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
+}
diff --git a/model/request/refundMethod.go b/model/request/refundMethod.go
new file mode 100644
index 0000000..612688c
--- /dev/null
+++ b/model/request/refundMethod.go
@@ -0,0 +1,15 @@
+
+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"`
+}
diff --git a/model/response/response.go b/model/response/response.go
index 6592a89..290110c 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -180,6 +180,10 @@
 
 	DataResponse struct {
 
+		// 閫�娆炬柟寮�
+		RefundMethod []*model.RefundMethod `json:"refundMethod"`
+
+
 		// 鏈嶅姟鍚堝悓绫诲瀷
 		ServiceContractType []*model.ServiceContractType `json:"serviceContractType"`
 
@@ -278,4 +282,8 @@
 	ServiceContractTypeResponse struct {
 		List []*model.ServiceContractType `json:"list"`
 	}
+
+	RefundMethodResponse struct {
+		List []*model.RefundMethod `json:"list"`
+	}
 )
\ No newline at end of file
diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go
index 0372909..ca4b9e5 100644
--- a/model/serviceFollowup.go
+++ b/model/serviceFollowup.go
@@ -85,7 +85,6 @@
 	return slf
 }
 
-// 鍚堝悓绫诲瀷 鍚堝悓鐘舵�侊紙鏈嶅姟鍚堝悓锛�
 // 浠樻鏂瑰紡 鏄惁寮�绁� 璐︽埛锛堥攢鍞��娆惧崟锛�
 // 閫�鍏ヤ粨搴� 鐘舵�侊紙閿�鍞��璐у崟锛�
 // 鎶ヤ环鍗曠姸鎬� 锛堟姤浠峰崟锛�
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index a1079f6..0a058bd 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -328,18 +328,23 @@
 	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 // 鏇存柊閫�娆炬柟寮忓け璐�
 
 )
\ No newline at end of file
diff --git a/router/index.go b/router/index.go
index dbe8532..fff931f 100644
--- a/router/index.go
+++ b/router/index.go
@@ -11,6 +11,7 @@
 )
 
 type Group struct {
+    RefundMethodRouter
     ServiceContractTypeRouter
     ServiceContractStatusRouter
     OrderTypeRouter
@@ -143,6 +144,7 @@
         routerGroup.InitOrderTypeRouter(PrivateGroup)
         routerGroup.InitServiceContractStatusRouter(PrivateGroup)
         routerGroup.InitServiceContractTypeRouter(PrivateGroup)
+        routerGroup.InitRefundMethodRouter(PrivateGroup)
 	}
 	return Router
 }
\ No newline at end of file
diff --git a/router/refundMethod.go b/router/refundMethod.go
new file mode 100644
index 0000000..97dd8d6
--- /dev/null
+++ b/router/refundMethod.go
@@ -0,0 +1,20 @@
+
+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$鍒楄〃
+	}
+}
\ No newline at end of file
diff --git a/service/dataServer.go b/service/dataServer.go
index 7487205..501fd7c 100644
--- a/service/dataServer.go
+++ b/service/dataServer.go
@@ -116,6 +116,11 @@
 	data.ServiceContractType = serviceContractTypeList
 
 
+	// get RefundMethod list
+	refundMethodList, _ := ServiceGroup.GetRefundMethodList()
+	data.RefundMethod = refundMethodList
+
+
 	errCode = ecode.OK
 
 	return
diff --git a/service/index.go b/service/index.go
index ec24cb1..d934cc0 100644
--- a/service/index.go
+++ b/service/index.go
@@ -53,6 +53,7 @@
     OrderTypeService
     ServiceContractStatusService
     ServiceContractTypeService
+    RefundMethodService
 }
 
 var ServiceGroup = new(Group)
\ No newline at end of file
diff --git a/service/refundMethod.go b/service/refundMethod.go
new file mode 100644
index 0000000..4b8b5e2
--- /dev/null
+++ b/service/refundMethod.go
@@ -0,0 +1,69 @@
+
+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
+}

--
Gitblit v1.8.0