From 4b2c52b17abef8521f9211b4865e1cad0288b12a Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期六, 21 十月 2023 17:47:50 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm

---
 model/enterpriseScale.go    |   36 +
 model/clientType.go         |   34 +
 model/enterpriseNature.go   |   37 +
 model/RefundType.go         |  148 ++++++
 model/bankAccount.go        |   34 +
 model/request/RefundType.go |   18 
 model/clientOrigin.go       |   36 +
 docs/swagger.yaml           |  114 +++++
 service/RefundType.go       |   64 ++
 model/status.go             |   32 +
 router/RefundType.go        |   17 
 model/industry.go           |   36 +
 model/saleChance.go         |    3 
 docs/docs.go                |  183 ++++++++
 model/registeredCapital.go  |   35 +
 docs/swagger.json           |  183 ++++++++
 model/possibilities.go      |   40 +
 api/v1/RefundType.go        |  112 +++++
 model/paymentType.go        |   38 +
 model/salesRefund.go        |    2 
 model/index.go              |   15 
 model/clientLevel.go        |   34 +
 router/index.go             |    1 
 model/contactInformation.go |   33 +
 model/saleType.go           |   32 +
 25 files changed, 1,289 insertions(+), 28 deletions(-)

diff --git a/api/v1/RefundType.go b/api/v1/RefundType.go
new file mode 100644
index 0000000..469e511
--- /dev/null
+++ b/api/v1/RefundType.go
@@ -0,0 +1,112 @@
+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, &params)
+	if !ok {
+		return
+	}
+
+	errCode := service.NewRefundTypeService().AddRefundType(&params.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, &params)
+	if !ok {
+		return
+	}
+	if params.Id == 0 {
+		ctx.Fail(ecode.ParamsErr)
+	}
+	params.RefundType.Id = params.Id
+
+	errCode := service.NewRefundTypeService().UpdateRefundType(&params.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, &params)
+	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,
+	})
+}
diff --git a/docs/docs.go b/docs/docs.go
index e8e2612..c49c09a 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -5689,6 +5689,142 @@
                 }
             }
         },
+        "/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": [
@@ -11699,6 +11835,17 @@
                 }
             }
         },
+        "model.RefundType": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "model.Region": {
             "type": "object",
             "properties": {
@@ -11902,7 +12049,7 @@
                     "type": "string"
                 },
                 "status_id": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.Status"
                 },
                 "threats": {
                     "type": "string"
@@ -12126,6 +12273,14 @@
         "model.SalesRefund": {
             "type": "object",
             "properties": {
+                "RefundType": {
+                    "description": "閫�娆炬柟寮�",
+                    "allOf": [
+                        {
+                            "$ref": "#/definitions/model.RefundType"
+                        }
+                    ]
+                },
                 "Source": {
                     "$ref": "#/definitions/model.SalesReturn"
                 },
@@ -12188,6 +12343,10 @@
                 },
                 "refundDate": {
                     "type": "string"
+                },
+                "refundTypeId": {
+                    "description": "閫�娆炬柟寮廔D",
+                    "type": "integer"
                 },
                 "sourceId": {
                     "description": "婧愬崟id",
@@ -13887,6 +14046,17 @@
                 "name"
             ],
             "properties": {
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.AddRefundType": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
                 "name": {
                     "type": "string"
                 }
@@ -17073,6 +17243,17 @@
                 }
             }
         },
+        "request.UpdateRefundType": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "request.UpdateRegion": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index b6ef544..6b3e9f0 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -5677,6 +5677,142 @@
                 }
             }
         },
+        "/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": [
@@ -11687,6 +11823,17 @@
                 }
             }
         },
+        "model.RefundType": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "model.Region": {
             "type": "object",
             "properties": {
@@ -11890,7 +12037,7 @@
                     "type": "string"
                 },
                 "status_id": {
-                    "type": "integer"
+                    "$ref": "#/definitions/model.Status"
                 },
                 "threats": {
                     "type": "string"
@@ -12114,6 +12261,14 @@
         "model.SalesRefund": {
             "type": "object",
             "properties": {
+                "RefundType": {
+                    "description": "閫�娆炬柟寮�",
+                    "allOf": [
+                        {
+                            "$ref": "#/definitions/model.RefundType"
+                        }
+                    ]
+                },
                 "Source": {
                     "$ref": "#/definitions/model.SalesReturn"
                 },
@@ -12176,6 +12331,10 @@
                 },
                 "refundDate": {
                     "type": "string"
+                },
+                "refundTypeId": {
+                    "description": "閫�娆炬柟寮廔D",
+                    "type": "integer"
                 },
                 "sourceId": {
                     "description": "婧愬崟id",
@@ -13875,6 +14034,17 @@
                 "name"
             ],
             "properties": {
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.AddRefundType": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
                 "name": {
                     "type": "string"
                 }
@@ -17061,6 +17231,17 @@
                 }
             }
         },
+        "request.UpdateRefundType": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "request.UpdateRegion": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index da4a29b..6cdd1f3 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1233,6 +1233,13 @@
       name:
         type: string
     type: object
+  model.RefundType:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+    type: object
   model.Region:
     properties:
       id:
@@ -1367,7 +1374,7 @@
       solutions:
         type: string
       status_id:
-        type: integer
+        $ref: '#/definitions/model.Status'
       threats:
         type: string
       whether_established:
@@ -1516,6 +1523,10 @@
     type: object
   model.SalesRefund:
     properties:
+      RefundType:
+        allOf:
+        - $ref: '#/definitions/model.RefundType'
+        description: 閫�娆炬柟寮�
       Source:
         $ref: '#/definitions/model.SalesReturn'
       amountTotal:
@@ -1559,6 +1570,9 @@
         type: string
       refundDate:
         type: string
+      refundTypeId:
+        description: 閫�娆炬柟寮廔D
+        type: integer
       sourceId:
         description: 婧愬崟id
         type: integer
@@ -2705,6 +2719,13 @@
         type: string
     required:
     - name
+    type: object
+  request.AddRefundType:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
     type: object
   request.AddRegion:
     properties:
@@ -4884,6 +4905,13 @@
         type: array
     required:
     - refund_method
+    type: object
+  request.UpdateRefundType:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
     type: object
   request.UpdateRegion:
     properties:
@@ -9763,6 +9791,90 @@
       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:
diff --git a/model/RefundType.go b/model/RefundType.go
new file mode 100644
index 0000000..43c1b87
--- /dev/null
+++ b/model/RefundType.go
@@ -0,0 +1,148 @@
+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
+	}
+}
diff --git a/model/bankAccount.go b/model/bankAccount.go
index 006e9b8..aba9f92 100644
--- a/model/bankAccount.go
+++ b/model/bankAccount.go
@@ -6,24 +6,25 @@
 	"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
 	}
 )
 
@@ -124,17 +125,26 @@
 }
 
 // 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
+	}
 }
diff --git a/model/clientLevel.go b/model/clientLevel.go
index ee24d24..23ce754 100644
--- a/model/clientLevel.go
+++ b/model/clientLevel.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -82,3 +83,36 @@
 	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
+	}
+}
diff --git a/model/clientOrigin.go b/model/clientOrigin.go
index 5d0b03e..67faf0d 100644
--- a/model/clientOrigin.go
+++ b/model/clientOrigin.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -89,3 +90,38 @@
 	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
+	}
+}
diff --git a/model/clientType.go b/model/clientType.go
index d940f39..9c617b1 100644
--- a/model/clientType.go
+++ b/model/clientType.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -91,3 +92,36 @@
 	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, "浠g悊鍟�"},
+		{2, "闆嗘垚鍟�"},
+		{3, "鍚堜綔浼欎即"},
+		{4, "鍏朵粬"},
+	}
+	err := slf.CreateBatch(records)
+	if err != nil {
+		errCh <- err
+		return
+	}
+}
diff --git a/model/contactInformation.go b/model/contactInformation.go
index 1ae901d..3fec063 100644
--- a/model/contactInformation.go
+++ b/model/contactInformation.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -78,3 +79,35 @@
 	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
+	}
+}
diff --git a/model/enterpriseNature.go b/model/enterpriseNature.go
index f210218..44379b8 100644
--- a/model/enterpriseNature.go
+++ b/model/enterpriseNature.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -84,3 +85,39 @@
 	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
+	}
+}
diff --git a/model/enterpriseScale.go b/model/enterpriseScale.go
index e8cf21e..9943537 100644
--- a/model/enterpriseScale.go
+++ b/model/enterpriseScale.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -86,3 +87,38 @@
 	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
+	}
+}
diff --git a/model/index.go b/model/index.go
index 854464c..d62248f 100644
--- a/model/index.go
+++ b/model/index.go
@@ -94,6 +94,7 @@
 		InvoiceStatus{},
 		InvoiceType{},
 		Invoice{},
+		RefundType{},
 	)
 	return err
 }
@@ -127,6 +128,20 @@
 		NewQuotationStatusSearch(),
 		NewSalesSourcesSearch(),
 		NewClientStatusSearch(),
+		NewClientTypeSearch(),
+		NewClientOriginSearch(),
+		NewClientLevelSearch(),
+		NewIndustrySearch(),
+		NewRegisteredCapitalSearch(),
+		NewEnterpriseNatureSearch(),
+		NewEnterpriseScaleSearch(),
+		NewContactInformationSearch(),
+		NewSaleTypeSearch(),
+		NewPossibilitySearch(),
+		NewStatusSearch(),
+		NewPaymentTypeSearch(),
+		NewBankAccountSearch(),
+		NewRefundTypeSearch(),
 	}
 
 	for _, model := range models {
diff --git a/model/industry.go b/model/industry.go
index 5d6ff03..3c01531 100644
--- a/model/industry.go
+++ b/model/industry.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -84,3 +85,38 @@
 	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
+	}
+}
diff --git a/model/paymentType.go b/model/paymentType.go
index e16a84a..0da5975 100644
--- a/model/paymentType.go
+++ b/model/paymentType.go
@@ -6,24 +6,25 @@
 	"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
 	}
 )
 
@@ -124,17 +125,30 @@
 }
 
 // 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
+	}
 }
diff --git a/model/possibilities.go b/model/possibilities.go
index ae0dce8..3480273 100644
--- a/model/possibilities.go
+++ b/model/possibilities.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -84,3 +85,42 @@
 	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
+	}
+}
diff --git a/model/registeredCapital.go b/model/registeredCapital.go
index fb682a0..7d1dd2e 100644
--- a/model/registeredCapital.go
+++ b/model/registeredCapital.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -82,3 +83,37 @@
 	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
+	}
+}
diff --git a/model/request/RefundType.go b/model/request/RefundType.go
new file mode 100644
index 0000000..556c00d
--- /dev/null
+++ b/model/request/RefundType.go
@@ -0,0 +1,18 @@
+package request
+
+import (
+	"aps_crm/model"
+)
+
+type AddRefundType struct {
+	model.RefundType
+}
+
+type UpdateRefundType struct {
+	Id int `json:"id"`
+	model.RefundType
+}
+
+type GetRefundTypeList struct {
+	PageInfo
+}
diff --git a/model/saleChance.go b/model/saleChance.go
index 751863b..f136914 100644
--- a/model/saleChance.go
+++ b/model/saleChance.go
@@ -30,6 +30,7 @@
 		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:鐘舵�両D"`
+		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:璧勯噾棰勭畻"`
@@ -164,7 +165,7 @@
 	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
 }
 
diff --git a/model/saleType.go b/model/saleType.go
index 8370ee7..03ffeec 100644
--- a/model/saleType.go
+++ b/model/saleType.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -82,3 +83,34 @@
 	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
+	}
+}
diff --git a/model/salesRefund.go b/model/salesRefund.go
index 380aa9a..d4aadd8 100644
--- a/model/salesRefund.go
+++ b/model/salesRefund.go
@@ -23,6 +23,8 @@
 		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"` // 閫�娆炬柟寮廔D
+		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:鏄惁寮�绁�"`
diff --git a/model/status.go b/model/status.go
index a8cb7f9..a9b0568 100644
--- a/model/status.go
+++ b/model/status.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -84,3 +85,34 @@
 	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
+	}
+}
diff --git a/router/RefundType.go b/router/RefundType.go
new file mode 100644
index 0000000..83a4744
--- /dev/null
+++ b/router/RefundType.go
@@ -0,0 +1,17 @@
+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)            // 鑾峰彇閫�娆炬柟寮忓垪琛�
+	}
+}
diff --git a/router/index.go b/router/index.go
index c9d55be..47df283 100644
--- a/router/index.go
+++ b/router/index.go
@@ -184,6 +184,7 @@
 		InitReceiptRouter(PrivateGroup)
 		InitBankAccountRouter(PrivateGroup)
 		InitPaymentTypeRouter(PrivateGroup)
+		InitRefundTypeRouter(PrivateGroup)
 		InitFileRouter(PrivateGroup)
 		InitInvoiceRouter(PrivateGroup)
 		InitInvoiceStatusRouter(PrivateGroup)
diff --git a/service/RefundType.go b/service/RefundType.go
new file mode 100644
index 0000000..3da996a
--- /dev/null
+++ b/service/RefundType.go
@@ -0,0 +1,64 @@
+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
+}

--
Gitblit v1.8.0