From 6aa75c2a266a2522ae713b13dc702b5ad0a08f87 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期二, 24 十月 2023 13:50:23 +0800
Subject: [PATCH] 编码规则需求功能开发

---
 model/request/masterOrder.go     |   17 
 model/request/salesDetails.go    |   39 
 docs/swagger.yaml                |   87 +--
 api/v1/salesReturn.go            |   18 
 model/request/serviceOrder.go    |   58 +-
 model/request/contract.go        |   19 
 api/v1/salesRefund.go            |   18 
 api/v1/salesLeads.go             |   16 
 model/util.go                    |    2 
 model/request/salesReturn.go     |    2 
 model/subOrder.go                |   34 +
 model/salesReturn.go             |   32 +
 model/salesLeads.go              |   33 +
 api/v1/masterOrder.go            |   18 
 model/request/saleChance.go      |   64 +-
 api/v1/code.go                   |   63 ++
 docs/docs.go                     |  132 +---
 model/followRecord.go            |   39 +
 constvar/const.go                |   32 
 model/serviceOrder.go            |   32 +
 model/request/salesRefund.go     |    2 
 api/v1/serviceFollowup.go        |   17 
 model/request/quotation.go       |   26 
 api/v1/client.go                 |   23 
 model/contract.go                |   34 +
 model/request/subOrder.go        |   14 
 api/v1/contract.go               |   18 
 api/v1/quotation.go              |   18 
 model/masterOrder.go             |   33 +
 model/serviceFollowup.go         |   32 +
 model/request/serviceFollowup.go |   30 
 api/v1/salesDetails.go           |   19 
 model/client.go                  |   25 
 model/request/followRecord.go    |   33 
 model/request/salesLeads.go      |   22 
 api/v1/subOrder.go               |   17 
 model/saleChance.go              |   18 
 model/request/client.go          |   35 
 model/quotation.go               |   33 +
 api/v1/serviceOrder.go           |   17 
 docs/swagger.json                |  132 +---
 model/serviceContract.go         |   34 +
 api/v1/saleChance.go             |   27 
 model/salesDetails.go            |   25 
 api/v1/serviceContract.go        |   42 -
 model/request/serviceContract.go |   40 
 model/salesRefund.go             |   32 +
 router/index.go                  |    3 
 api/v1/followRecord.go           |   17 
 49 files changed, 969 insertions(+), 604 deletions(-)

diff --git a/api/v1/client.go b/api/v1/client.go
index 37016eb..bca5872 100644
--- a/api/v1/client.go
+++ b/api/v1/client.go
@@ -41,25 +41,20 @@
 		return
 	}
 
-	//CreatorId, b := c.Get("claims")
-	//if !b {
-	//	ctx.Fail(ecode.JWTParseErr)
-	//	return
-	//}
-	//
-	//client.CreatorId = CreatorId.(int)
+	count, err := model.NewClientSearch(nil).SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
 
 	errCode = clientService.AddClient(client, params.SalesLeadsId)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(client.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewClientSearch(nil).SetId(client.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/code.go b/api/v1/code.go
index bb8ae8b..2514e44 100644
--- a/api/v1/code.go
+++ b/api/v1/code.go
@@ -2,6 +2,8 @@
 
 import (
 	"aps_crm/conf"
+	"aps_crm/constvar"
+	"aps_crm/model"
 	"aps_crm/model/request"
 	"aps_crm/model/response"
 	"aps_crm/pkg/contextx"
@@ -71,3 +73,64 @@
 		Count: list.Total,
 	})
 }
+
+// GetAutoCode
+//
+// @Tags		缂栫爜
+// @Summary	鑾峰彇鑷姩缂栫爜
+// @Produce	application/json
+// @Param		object	body		code.CodeStandard	true	"鍙傛暟"
+// @Success	200	{object}	response.ListResponse
+//
+//	@Router		/api/code/getAutoCode [post]
+func (ca *CodeApi) GetAutoCode(c *gin.Context) {
+	var params code.CodeStandard
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+	var (
+		id  = 0
+		err error
+	)
+	switch constvar.CodeStandardType(params.Type) {
+	case constvar.CodeStandardTypeSaleKey:
+		id, err = model.NewSaleChanceSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeSaleLead:
+		id, err = model.NewSalesLeadsSearch(nil).MaxAutoIncr()
+	case constvar.CodeStandardTypeCustom:
+		id, err = model.NewClientSearch(nil).MaxAutoIncr()
+	case constvar.CodeStandardTypeFollowRecord:
+		id, err = model.NewFollowRecordSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeQuotation:
+		id, err = model.NewQuotationSearch(nil).MaxAutoIncr()
+	case constvar.CodeStandardTypeSaleTotalOrder:
+		id, err = model.NewMasterOrderSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeSaleSuborder:
+		id, err = model.NewSubOrderSearch(nil).MaxAutoIncr()
+	case constvar.CodeStandardTypeSaleDetail:
+		id, err = model.NewSalesDetailsSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeSaleReturnGoods:
+		id, err = model.NewSalesReturnSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeSaleRefund:
+		id, err = model.NewSalesRefundSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeContract:
+		id, err = model.NewContractSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeServerContract:
+		id, err = model.NewServiceContractSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeCustomServer:
+		id, err = model.NewServiceOrderSearch().MaxAutoIncr()
+	case constvar.CodeStandardTypeServerFollow:
+		id, err = model.NewServiceFollowupSearch().MaxAutoIncr()
+	default:
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜瑙勫垯涓嶅瓨鍦�")
+		return
+	}
+	if err != nil {
+		logx.Errorf("GetAutoCode err: %v", err.Error())
+		ctx.FailWithMsg(ecode.UnknownErr, "鑾峰彇鏈�澶у�煎け璐�")
+		return
+	}
+	autoCode := model.GetAutoCode(id, &params)
+	ctx.OkWithDetailed(autoCode)
+}
diff --git a/api/v1/contract.go b/api/v1/contract.go
index 8041742..a2cc756 100644
--- a/api/v1/contract.go
+++ b/api/v1/contract.go
@@ -35,6 +35,16 @@
 		return
 	}
 
+	count, err := model.NewContractSearch().SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if contract.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -46,14 +56,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(contract.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewContractSearch().SetId(contract.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/followRecord.go b/api/v1/followRecord.go
index d64b85a..1fe90dd 100644
--- a/api/v1/followRecord.go
+++ b/api/v1/followRecord.go
@@ -36,6 +36,16 @@
 		return
 	}
 
+	count, err := model.NewFollowRecordSearch().SetNumber(followRecord.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if followRecord.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -47,13 +57,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-	if params.FollowRecord.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(followRecord.Id, &params.FollowRecord.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewFollowRecordSearch().SetId(followRecord.Id).UpdateMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/masterOrder.go b/api/v1/masterOrder.go
index 373078f..af2fb9d 100644
--- a/api/v1/masterOrder.go
+++ b/api/v1/masterOrder.go
@@ -34,6 +34,16 @@
 		return
 	}
 
+	count, err := model.NewMasterOrderSearch().SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if masterOrder.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -45,14 +55,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(masterOrder.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewMasterOrderSearch().SetId(masterOrder.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/quotation.go b/api/v1/quotation.go
index 7beeb3b..3fd3552 100644
--- a/api/v1/quotation.go
+++ b/api/v1/quotation.go
@@ -34,6 +34,16 @@
 		return
 	}
 
+	count, err := model.NewQuotationSearch(nil).SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if quotation.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -45,14 +55,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(quotation.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewQuotationSearch(nil).SetId(quotation.Id).Updates(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/saleChance.go b/api/v1/saleChance.go
index 445b3c7..73bcdb0 100644
--- a/api/v1/saleChance.go
+++ b/api/v1/saleChance.go
@@ -33,16 +33,15 @@
 		ctx.Fail(errCode)
 		return
 	}
-	if params.CodeRule.Method != 1 {
-		count, err := model.NewSaleChanceSearch().SetNumber(saleChance.Number).Count()
-		if err != nil {
-			ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
-			return
-		}
-		if count > 0 {
-			ctx.FailWithMsg(ecode.UnknownErr, "閿�鍞満浼氱紪鐮佸凡瀛樺湪")
-			return
-		}
+
+	count, err := model.NewSaleChanceSearch().SetNumber(saleChance.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "閿�鍞満浼氱紪鐮佸凡瀛樺湪")
+		return
 	}
 
 	if saleChance.MemberId == 0 {
@@ -56,14 +55,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(saleChance.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewSaleChanceSearch().SetId(saleChance.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/salesDetails.go b/api/v1/salesDetails.go
index 350e9c2..f5c69eb 100644
--- a/api/v1/salesDetails.go
+++ b/api/v1/salesDetails.go
@@ -35,6 +35,16 @@
 		return
 	}
 
+	count, err := model.NewSalesDetailsSearch().SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if salesDetails.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -46,14 +56,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(salesDetails.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewSalesDetailsSearch().SetId(salesDetails.Id).UpdateByMap(m)
 	}
 
 	ctx.OkWithDetailed(salesDetails)
@@ -156,6 +158,7 @@
 	salesDetailsModel.LogisticNumber = salesDetails.LogisticNumber
 	salesDetailsModel.LogisticCost = salesDetails.LogisticCost
 	salesDetailsModel.CodeStandID = salesDetails.CodeStandID
+	salesDetailsModel.DeliverType = salesDetails.DeliverType
 
 	return ecode.OK, salesDetailsModel
 }
diff --git a/api/v1/salesLeads.go b/api/v1/salesLeads.go
index e35a85d..25e1692 100644
--- a/api/v1/salesLeads.go
+++ b/api/v1/salesLeads.go
@@ -40,18 +40,20 @@
 		ctx.Fail(errCode)
 		return
 	}
+	count, err := model.NewSalesLeadsSearch(nil).SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
 
 	errCode = salesLeadsService.AddSalesLeads(&salesLeads)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(salesLeads.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewSalesLeadsSearch(nil).SetId(salesLeads.Id).UpdateMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/salesRefund.go b/api/v1/salesRefund.go
index cbce386..2c30b99 100644
--- a/api/v1/salesRefund.go
+++ b/api/v1/salesRefund.go
@@ -36,6 +36,16 @@
 		return
 	}
 
+	count, err := model.NewSalesRefundSearch().SetNumber(salesRefund.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if salesRefund.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -47,14 +57,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.SalesRefund.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(salesRefund.Id, &params.SalesRefund.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewSalesRefundSearch().SetId(salesRefund.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/salesReturn.go b/api/v1/salesReturn.go
index bf1fdbd..4e21782 100644
--- a/api/v1/salesReturn.go
+++ b/api/v1/salesReturn.go
@@ -37,6 +37,16 @@
 		return
 	}
 
+	count, err := model.NewSalesReturnSearch().SetNumber(salesReturn.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if salesReturn.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -48,14 +58,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.SalesReturn.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(salesReturn.Id, &params.SalesReturn.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewSalesReturnSearch().SetId(salesReturn.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/serviceContract.go b/api/v1/serviceContract.go
index d6b13c1..1edad01 100644
--- a/api/v1/serviceContract.go
+++ b/api/v1/serviceContract.go
@@ -35,6 +35,16 @@
 		return
 	}
 
+	count, err := model.NewServiceContractSearch().SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if params.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -48,40 +58,8 @@
 		return
 	}
 
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(serviceContract.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewServiceContractSearch().SetId(serviceContract.Id).UpdateByMap(m)
-	}
-
 	ctx.Ok()
 }
-
-//// Delete
-////
-////	@Tags		ServiceContract
-////	@Summary	鍒犻櫎鏈嶅姟鍚堝悓
-////	@Produce	application/json
-////	@Param		object	body		request.DeleteServiceContract true	"鏌ヨ鍙傛暟"
-////	@Success	200	{object}	contextx.Response{}
-////	@Router		/api/serviceContract/delete [delete]
-//func (s *ServiceContractApi) Delete(c *gin.Context) {
-//	var params request.DeleteServiceContract
-//	ctx, ok := contextx.NewContext(c, &params)
-//	if !ok {
-//		return
-//	}
-//
-//	errCode := serviceContractService.DeleteServiceContract(params.Ids)
-//	if errCode != ecode.OK {
-//		ctx.Fail(errCode)
-//		return
-//	}
-//
-//	ctx.Ok()
-//}
 
 // BatchDelete
 // @Tags	ServiceContract
diff --git a/api/v1/serviceFollowup.go b/api/v1/serviceFollowup.go
index 39af767..d457ead 100644
--- a/api/v1/serviceFollowup.go
+++ b/api/v1/serviceFollowup.go
@@ -40,17 +40,20 @@
 		return
 	}
 
+	count, err := model.NewServiceFollowupSearch().SetNumber(serviceFollowup.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	errCode = serviceFollowupService.AddServiceFollowup(&serviceFollowup)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(serviceFollowup.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/serviceOrder.go b/api/v1/serviceOrder.go
index faef2d6..b2bd4f1 100644
--- a/api/v1/serviceOrder.go
+++ b/api/v1/serviceOrder.go
@@ -42,17 +42,20 @@
 		return
 	}
 
+	count, err := model.NewServiceOrderSearch().SetNumber(serviceOrder.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	errCode := service.NewServiceOrderService().AddServiceOrder(serviceOrder)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(serviceOrder.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"service_number": autoCode,
-		}
-		_ = model.NewServiceOrderSearch().SetId(serviceOrder.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
diff --git a/api/v1/subOrder.go b/api/v1/subOrder.go
index b4595ee..188e036 100644
--- a/api/v1/subOrder.go
+++ b/api/v1/subOrder.go
@@ -34,6 +34,16 @@
 		return
 	}
 
+	count, err := model.NewSubOrderSearch(nil).SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if subOrder.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -47,13 +57,6 @@
 		return
 	}
 
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(subOrder.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewSubOrderSearch(nil).SetId(subOrder.Id).UpdateByMap(m)
-	}
 	ctx.Ok()
 }
 
diff --git a/constvar/const.go b/constvar/const.go
index 98cfd24..cd33794 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -137,24 +137,26 @@
 type CodeStandardType string
 
 const (
-	CodeStandardTypeSaleLead       CodeStandardType = "閿�鍞嚎绱㈢紪鐮�"
-	CodeStandardTypeCustom         CodeStandardType = "瀹㈡埛缂栫爜"
-	CodeStandardTypeContact        CodeStandardType = "鑱旂郴浜虹紪鐮�"
-	CodeStandardTypeFollowRecord   CodeStandardType = "璺熻繘璁板綍缂栫爜"
-	CodeStandardTypeSaleKey        CodeStandardType = "閿�鍞満浼氱紪鐮�"
-	CodeStandardTypeQuotation      CodeStandardType = "鎶ヤ环缂栫爜"
-	CodeStandardTypeSaleTotalOrder CodeStandardType = "閿�鍞�诲崟缂栫爜"
-	CodeStandardTypeSaleSuborder   CodeStandardType = "閿�鍞瓙鍗曠紪鐮�"
-	CodeStandardTypeSaleRefund     CodeStandardType = "閿�鍞��娆剧紪鐮�"
-	CodeStandardTypeContract       CodeStandardType = "鍚堝悓缂栫爜"
-	CodeStandardTypeServerContract CodeStandardType = "鏈嶅姟鍚堝悓缂栫爜"
-	CodeStandardTypeServerFollow   CodeStandardType = "鏈嶅姟鍥炶缂栫爜"
+	CodeStandardTypeSaleLead        CodeStandardType = "閿�鍞嚎绱㈢紪鐮�"
+	CodeStandardTypeCustom          CodeStandardType = "瀹㈡埛缂栫爜"
+	CodeStandardTypeFollowRecord    CodeStandardType = "璺熻繘璁板綍缂栫爜"
+	CodeStandardTypeSaleKey         CodeStandardType = "閿�鍞満浼氱紪鐮�"
+	CodeStandardTypeQuotation       CodeStandardType = "鎶ヤ环缂栫爜"
+	CodeStandardTypeSaleTotalOrder  CodeStandardType = "閿�鍞�诲崟缂栫爜"
+	CodeStandardTypeSaleSuborder    CodeStandardType = "閿�鍞瓙鍗曠紪鐮�"
+	CodeStandardTypeSaleRefund      CodeStandardType = "閿�鍞��娆剧紪鐮�"
+	CodeStandardTypeContract        CodeStandardType = "鍚堝悓缂栫爜"
+	CodeStandardTypeServerContract  CodeStandardType = "鏈嶅姟鍚堝悓缂栫爜"
+	CodeStandardTypeServerFollow    CodeStandardType = "鏈嶅姟鍥炶缂栫爜"
+	CodeStandardTypeCustomServer    CodeStandardType = "瀹㈡埛鏈嶅姟缂栫爜"
+	CodeStandardTypeSaleInvoice     CodeStandardType = "閿�鍞彂绁ㄧ紪鐮�"
+	CodeStandardTypeSaleDetail      CodeStandardType = "閿�鍞槑缁嗙紪鐮�"
+	CodeStandardTypeSaleReturnGoods CodeStandardType = "閿�鍞��璐х紪鐮�"
 )
 
 func (t CodeStandardType) Valid() bool {
 	if t != CodeStandardTypeSaleLead &&
 		t != CodeStandardTypeCustom &&
-		t != CodeStandardTypeContact &&
 		t != CodeStandardTypeFollowRecord &&
 		t != CodeStandardTypeSaleKey &&
 		t != CodeStandardTypeQuotation &&
@@ -163,6 +165,10 @@
 		t != CodeStandardTypeSaleRefund &&
 		t != CodeStandardTypeContract &&
 		t != CodeStandardTypeServerContract &&
+		t != CodeStandardTypeCustomServer &&
+		t != CodeStandardTypeSaleInvoice &&
+		t != CodeStandardTypeSaleDetail &&
+		t != CodeStandardTypeSaleReturnGoods &&
 		t != CodeStandardTypeServerFollow {
 		return false
 	}
diff --git a/docs/docs.go b/docs/docs.go
index c49c09a..b6d87f1 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1199,6 +1199,36 @@
                 }
             }
         },
+        "/api/code/getAutoCode": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "缂栫爜"
+                ],
+                "summary": "鑾峰彇鑷姩缂栫爜",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/code.CodeStandard"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/response.ListResponse"
+                        }
+                    }
+                }
+            }
+        },
         "/api/code/getCodeList": {
             "get": {
                 "produces": [
@@ -12048,8 +12078,16 @@
                 "solutions": {
                     "type": "string"
                 },
+                "status": {
+                    "description": "鐘舵��",
+                    "allOf": [
+                        {
+                            "$ref": "#/definitions/model.Status"
+                        }
+                    ]
+                },
                 "status_id": {
-                    "$ref": "#/definitions/model.Status"
+                    "type": "integer"
                 },
                 "threats": {
                     "type": "string"
@@ -12133,6 +12171,9 @@
                 },
                 "creatorName": {
                     "type": "string"
+                },
+                "deliverType": {
+                    "type": "integer"
                 },
                 "deliveryDate": {
                     "type": "string"
@@ -13296,9 +13337,6 @@
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -13502,9 +13540,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -13773,9 +13808,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -13895,9 +13927,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -14133,9 +14162,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14266,15 +14292,16 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
                 },
                 "conditions": {
                     "type": "string"
+                },
+                "deliverType": {
+                    "description": "浜や粯绫诲瀷:1.涓�娆″彂璐�,2.澶氭鍙戣揣",
+                    "type": "integer"
                 },
                 "deliveryDate": {
                     "type": "string"
@@ -14325,9 +14352,6 @@
             "properties": {
                 "city_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -14452,9 +14476,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14563,9 +14584,6 @@
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14660,9 +14678,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14727,9 +14742,6 @@
                 "clientId": {
                     "description": "瀹㈡埛id",
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -14885,9 +14897,6 @@
             "properties": {
                 "clientId": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -15265,9 +15274,6 @@
                 },
                 "client_status_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "type": "string"
@@ -15846,15 +15852,16 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
                 },
                 "conditions": {
                     "type": "string"
+                },
+                "deliverType": {
+                    "description": "浜や粯绫诲瀷:1.涓�娆″彂璐�,2.澶氭鍙戣揣",
+                    "type": "integer"
                 },
                 "deliveryDate": {
                     "type": "string"
@@ -15914,9 +15921,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -15965,9 +15969,6 @@
             "properties": {
                 "clientId": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -16167,9 +16168,6 @@
                 "client_type_id": {
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -16459,9 +16457,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -16865,9 +16860,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -17048,9 +17040,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -17413,9 +17402,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -17589,9 +17575,6 @@
             "properties": {
                 "city_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -17846,9 +17829,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -17978,9 +17958,6 @@
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -18076,9 +18053,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -18146,9 +18120,6 @@
                 "clientId": {
                     "description": "瀹㈡埛id",
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -18343,9 +18314,6 @@
             "properties": {
                 "clientId": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
diff --git a/docs/swagger.json b/docs/swagger.json
index 6b3e9f0..29ed80e 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1187,6 +1187,36 @@
                 }
             }
         },
+        "/api/code/getAutoCode": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "缂栫爜"
+                ],
+                "summary": "鑾峰彇鑷姩缂栫爜",
+                "parameters": [
+                    {
+                        "description": "鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/code.CodeStandard"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/response.ListResponse"
+                        }
+                    }
+                }
+            }
+        },
         "/api/code/getCodeList": {
             "get": {
                 "produces": [
@@ -12036,8 +12066,16 @@
                 "solutions": {
                     "type": "string"
                 },
+                "status": {
+                    "description": "鐘舵��",
+                    "allOf": [
+                        {
+                            "$ref": "#/definitions/model.Status"
+                        }
+                    ]
+                },
                 "status_id": {
-                    "$ref": "#/definitions/model.Status"
+                    "type": "integer"
                 },
                 "threats": {
                     "type": "string"
@@ -12121,6 +12159,9 @@
                 },
                 "creatorName": {
                     "type": "string"
+                },
+                "deliverType": {
+                    "type": "integer"
                 },
                 "deliveryDate": {
                     "type": "string"
@@ -13284,9 +13325,6 @@
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -13490,9 +13528,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -13761,9 +13796,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -13883,9 +13915,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -14121,9 +14150,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14254,15 +14280,16 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
                 },
                 "conditions": {
                     "type": "string"
+                },
+                "deliverType": {
+                    "description": "浜や粯绫诲瀷:1.涓�娆″彂璐�,2.澶氭鍙戣揣",
+                    "type": "integer"
                 },
                 "deliveryDate": {
                     "type": "string"
@@ -14313,9 +14340,6 @@
             "properties": {
                 "city_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -14440,9 +14464,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14551,9 +14572,6 @@
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14648,9 +14666,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -14715,9 +14730,6 @@
                 "clientId": {
                     "description": "瀹㈡埛id",
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -14873,9 +14885,6 @@
             "properties": {
                 "clientId": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -15253,9 +15262,6 @@
                 },
                 "client_status_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "type": "string"
@@ -15834,15 +15840,16 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
                 },
                 "conditions": {
                     "type": "string"
+                },
+                "deliverType": {
+                    "description": "浜や粯绫诲瀷:1.涓�娆″彂璐�,2.澶氭鍙戣揣",
+                    "type": "integer"
                 },
                 "deliveryDate": {
                     "type": "string"
@@ -15902,9 +15909,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -15953,9 +15957,6 @@
             "properties": {
                 "clientId": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -16155,9 +16156,6 @@
                 "client_type_id": {
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -16447,9 +16445,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -16853,9 +16848,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -17036,9 +17028,6 @@
             "properties": {
                 "client_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -17401,9 +17390,6 @@
                 "client_id": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -17577,9 +17563,6 @@
             "properties": {
                 "city_id": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -17834,9 +17817,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -17966,9 +17946,6 @@
                     "description": "瀹㈡埛绫诲瀷ID",
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -18064,9 +18041,6 @@
                 "clientId": {
                     "type": "integer"
                 },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
-                },
                 "codeStandID": {
                     "description": "缂栫爜id",
                     "type": "string"
@@ -18134,9 +18108,6 @@
                 "clientId": {
                     "description": "瀹㈡埛id",
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
@@ -18331,9 +18302,6 @@
             "properties": {
                 "clientId": {
                     "type": "integer"
-                },
-                "codeRule": {
-                    "$ref": "#/definitions/code.CodeStandard"
                 },
                 "codeStandID": {
                     "description": "缂栫爜id",
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 6cdd1f3..1e7b9cb 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1373,8 +1373,12 @@
         type: integer
       solutions:
         type: string
+      status:
+        allOf:
+        - $ref: '#/definitions/model.Status'
+        description: 鐘舵��
       status_id:
-        $ref: '#/definitions/model.Status'
+        type: integer
       threats:
         type: string
       whether_established:
@@ -1431,6 +1435,8 @@
         type: integer
       creatorName:
         type: string
+      deliverType:
+        type: integer
       deliveryDate:
         type: string
       id:
@@ -2212,8 +2218,6 @@
       client_type_id:
         description: 瀹㈡埛绫诲瀷ID
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -2360,8 +2364,6 @@
     properties:
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -2538,8 +2540,6 @@
     properties:
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -2618,8 +2618,6 @@
     properties:
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -2773,8 +2771,6 @@
         type: integer
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -2861,13 +2857,14 @@
         type: string
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
       conditions:
         type: string
+      deliverType:
+        description: 浜や粯绫诲瀷:1.涓�娆″彂璐�,2.澶氭鍙戣揣
+        type: integer
       deliveryDate:
         type: string
       logisticCompany:
@@ -2901,8 +2898,6 @@
     properties:
       city_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -2984,8 +2979,6 @@
     properties:
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -3061,8 +3054,6 @@
       client_type_id:
         description: 瀹㈡埛绫诲瀷ID
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -3131,8 +3122,6 @@
     properties:
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -3178,8 +3167,6 @@
       clientId:
         description: 瀹㈡埛id
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -3289,8 +3276,6 @@
     properties:
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -3546,8 +3531,6 @@
         type: integer
       client_status_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         type: string
       contact_id:
@@ -3966,13 +3949,14 @@
         type: string
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
       conditions:
         type: string
+      deliverType:
+        description: 浜や粯绫诲瀷:1.涓�娆″彂璐�,2.澶氭鍙戣揣
+        type: integer
       deliveryDate:
         type: string
       logisticCompany:
@@ -4009,8 +3993,6 @@
         type: integer
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -4046,8 +4028,6 @@
     properties:
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -4183,8 +4163,6 @@
       client_type_id:
         description: 瀹㈡埛绫诲瀷ID
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -4387,8 +4365,6 @@
     properties:
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -4657,8 +4633,6 @@
     properties:
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -4778,8 +4752,6 @@
     properties:
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -5016,8 +4988,6 @@
         type: integer
       client_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -5135,8 +5105,6 @@
     properties:
       city_id:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -5305,8 +5273,6 @@
     properties:
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -5396,8 +5362,6 @@
       client_type_id:
         description: 瀹㈡埛绫诲瀷ID
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -5466,8 +5430,6 @@
     properties:
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -5515,8 +5477,6 @@
       clientId:
         description: 瀹㈡埛id
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -5652,8 +5612,6 @@
     properties:
       clientId:
         type: integer
-      codeRule:
-        $ref: '#/definitions/code.CodeStandard'
       codeStandID:
         description: 缂栫爜id
         type: string
@@ -7025,6 +6983,25 @@
       summary: 鏇存柊瀹㈡埛绫诲瀷
       tags:
       - ClientType
+  /api/code/getAutoCode:
+    post:
+      parameters:
+      - description: 鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/code.CodeStandard'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.ListResponse'
+      summary: 鑾峰彇鑷姩缂栫爜
+      tags:
+      - 缂栫爜
   /api/code/getCodeList:
     get:
       parameters:
diff --git a/model/client.go b/model/client.go
index ca7509a..a9a5e1c 100644
--- a/model/client.go
+++ b/model/client.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/constvar"
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 	"time"
 )
@@ -196,6 +197,30 @@
 	return db.Updates(data).Error
 }
 
+func (slf *ClientSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *ClientSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *ClientSearch) SetPage(page, size int) *ClientSearch {
 	slf.PageNum, slf.PageSize = page, size
 	return slf
diff --git a/model/contract.go b/model/contract.go
index 93519c3..4617805 100644
--- a/model/contract.go
+++ b/model/contract.go
@@ -2,6 +2,7 @@
 
 import (
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 )
 
@@ -50,6 +51,9 @@
 
 	if slf.Id != 0 {
 		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
 	}
 
 	if len(slf.SearchMap) > 0 {
@@ -123,6 +127,30 @@
 	return records, total, err
 }
 
+func (slf *ContractSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *ContractSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *ContractSearch) SetId(id int) *ContractSearch {
 	slf.Id = id
 	return slf
@@ -146,6 +174,12 @@
 	slf.Orm = slf.Orm.Where("id in (?)", ids)
 	return slf
 }
+
+func (slf *ContractSearch) SetNumber(number string) *ContractSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *ContractSearch) UpdateByMap(data map[string]interface{}) error {
 	var db = slf.build()
 	return db.Updates(data).Error
diff --git a/model/followRecord.go b/model/followRecord.go
index 58bbb30..afc27cb 100644
--- a/model/followRecord.go
+++ b/model/followRecord.go
@@ -2,6 +2,7 @@
 
 import (
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 )
 
@@ -61,6 +62,9 @@
 	}
 	if slf.ClientId != 0 {
 		db = db.Where("client_id = ?", slf.ClientId)
+	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
 	}
 
 	if len(slf.SearchMap) > 0 {
@@ -130,12 +134,6 @@
 	return records, total, err
 }
 
-func (slf *FollowRecordSearch) Count() (int64, error) {
-	var count int64
-	err := slf.build().Count(&count).Error
-	return count, err
-}
-
 func (slf *FollowRecordSearch) Page(page, pageSize int) ([]*FollowRecord, int64, error) {
 	var records = make([]*FollowRecord, 0)
 	var count int64
@@ -160,6 +158,30 @@
 func (slf *FollowRecordSearch) Delete() error {
 	var db = slf.build()
 	return db.Delete(&slf.FollowRecord).Error
+}
+
+func (slf *FollowRecordSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *FollowRecordSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
 }
 
 func (slf *FollowRecordSearch) SetId(id int) *FollowRecordSearch {
@@ -199,3 +221,8 @@
 	slf.Orm = tx
 	return slf
 }
+
+func (slf *FollowRecordSearch) SetNumber(number string) *FollowRecordSearch {
+	slf.Number = number
+	return slf
+}
diff --git a/model/masterOrder.go b/model/masterOrder.go
index ac02f01..112d16f 100644
--- a/model/masterOrder.go
+++ b/model/masterOrder.go
@@ -2,6 +2,7 @@
 
 import (
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 )
 
@@ -47,6 +48,9 @@
 	var db = slf.Orm.Model(&MasterOrder{})
 	if slf.Id != 0 {
 		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
 	}
 
 	if len(slf.SearchMap) > 0 {
@@ -112,6 +116,30 @@
 	return records, total, err
 }
 
+func (slf *MasterOrderSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *MasterOrderSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *MasterOrderSearch) SetId(id int) *MasterOrderSearch {
 	slf.Id = id
 	return slf
@@ -136,6 +164,11 @@
 	return slf
 }
 
+func (slf *MasterOrderSearch) SetNumber(number string) *MasterOrderSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *MasterOrderSearch) UpdateByMap(data map[string]interface{}) error {
 	var db = slf.build()
 	return db.Updates(data).Error
diff --git a/model/quotation.go b/model/quotation.go
index 4aff38e..969d34f 100644
--- a/model/quotation.go
+++ b/model/quotation.go
@@ -2,6 +2,7 @@
 
 import (
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 )
 
@@ -58,6 +59,9 @@
 	var db = slf.Orm.Model(&Quotation{})
 	if slf.Id != 0 {
 		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
 	}
 
 	if len(slf.SearchMap) > 0 {
@@ -128,6 +132,30 @@
 	return records, total, err
 }
 
+func (slf *QuotationSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *QuotationSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *QuotationSearch) SetId(id int) *QuotationSearch {
 	slf.Id = id
 	return slf
@@ -152,6 +180,11 @@
 	slf.SearchMap = searchMap
 	return slf
 }
+
+func (slf *QuotationSearch) SetNumber(number string) *QuotationSearch {
+	slf.Number = number
+	return slf
+}
 func (slf *QuotationSearch) SetIds(ids []int) *QuotationSearch {
 	slf.Orm = slf.Orm.Where("id in (?)", ids)
 	return slf
diff --git a/model/request/client.go b/model/request/client.go
index 08b32ea..089f98e 100644
--- a/model/request/client.go
+++ b/model/request/client.go
@@ -1,29 +1,26 @@
 package request
 
-import "aps_crm/proto/code"
-
 type AddClient struct {
 	Client
 }
 
 type Client struct {
-	Name              string            `json:"name"`                // 鍏徃鍚嶇О
-	Number            string            `json:"number"`              // 鍏徃缂栧彿
-	ClientStatusId    int               `json:"client_status_id"`    // 瀹㈡埛鐘舵�両D
-	ClientTypeId      int               `json:"client_type_id"`      // 瀹㈡埛绫诲瀷ID
-	ClientOriginId    int               `json:"client_origin_id"`    // 瀹㈡埛鏉ユ簮ID
-	ClientLevelId     int               `json:"client_level_id"`     // 瀹㈡埛绛夌骇ID
-	MemberId          int               `json:"member_id"`           // 閿�鍞礋璐d汉ID
-	ServiceMemberId   int               `json:"service_member_id"`   // 鏈嶅姟璐熻矗浜篒D
-	DetailAddress     string            `json:"detail_address"`      // 璇︾粏鍦板潃
-	Remark            string            `json:"remark"`              // 澶囨敞
-	NextVisitTime     string            `json:"next_visit_time"`     // 涓嬫鍥炶鏃堕棿
-	LatestServiceTime string            `json:"latest_service_time"` // 鏈�鏅氭湇鍔℃椂闂�
-	Contact           Contact           `json:"contact"`
-	SalesLeadsId      int               `json:"sales_leads_id"` // 閿�鍞嚎绱D
-	ContactId         int               `json:"contact_id"`     // 鑱旂郴浜篒D
-	CodeStandID       string            `json:"codeStandID"`    //缂栫爜id
-	CodeRule          code.CodeStandard `json:"codeRule"`
+	Name              string  `json:"name"`                // 鍏徃鍚嶇О
+	Number            string  `json:"number"`              // 鍏徃缂栧彿
+	ClientStatusId    int     `json:"client_status_id"`    // 瀹㈡埛鐘舵�両D
+	ClientTypeId      int     `json:"client_type_id"`      // 瀹㈡埛绫诲瀷ID
+	ClientOriginId    int     `json:"client_origin_id"`    // 瀹㈡埛鏉ユ簮ID
+	ClientLevelId     int     `json:"client_level_id"`     // 瀹㈡埛绛夌骇ID
+	MemberId          int     `json:"member_id"`           // 閿�鍞礋璐d汉ID
+	ServiceMemberId   int     `json:"service_member_id"`   // 鏈嶅姟璐熻矗浜篒D
+	DetailAddress     string  `json:"detail_address"`      // 璇︾粏鍦板潃
+	Remark            string  `json:"remark"`              // 澶囨敞
+	NextVisitTime     string  `json:"next_visit_time"`     // 涓嬫鍥炶鏃堕棿
+	LatestServiceTime string  `json:"latest_service_time"` // 鏈�鏅氭湇鍔℃椂闂�
+	Contact           Contact `json:"contact"`
+	SalesLeadsId      int     `json:"sales_leads_id"` // 閿�鍞嚎绱D
+	ContactId         int     `json:"contact_id"`     // 鑱旂郴浜篒D
+	CodeStandID       string  `json:"codeStandID"`    //缂栫爜id
 	Address
 	Business
 }
diff --git a/model/request/contract.go b/model/request/contract.go
index 8285425..9a939f8 100644
--- a/model/request/contract.go
+++ b/model/request/contract.go
@@ -1,21 +1,18 @@
 package request
 
-import "aps_crm/proto/code"
-
 type AddContract struct {
 	Contract
 }
 
 type Contract struct {
-	ContractName string            `json:"contractName"` //鍚堝悓鍚嶇О
-	ClientId     int               `json:"client_id"`
-	MemberId     int               `json:"member_id"`
-	Number       string            `json:"number"`
-	QuotationId  int               `json:"quotation_id"`
-	StatusId     int               `json:"status_id"`
-	File         string            `json:"file"`
-	CodeStandID  string            `json:"codeStandID"` //缂栫爜id
-	CodeRule     code.CodeStandard `json:"codeRule"`
+	ContractName string `json:"contractName"` //鍚堝悓鍚嶇О
+	ClientId     int    `json:"client_id"`
+	MemberId     int    `json:"member_id"`
+	Number       string `json:"number"`
+	QuotationId  int    `json:"quotation_id"`
+	StatusId     int    `json:"status_id"`
+	File         string `json:"file"`
+	CodeStandID  string `json:"codeStandID"` //缂栫爜id
 }
 
 type UpdateContract struct {
diff --git a/model/request/followRecord.go b/model/request/followRecord.go
index e84169d..ddd82ae 100644
--- a/model/request/followRecord.go
+++ b/model/request/followRecord.go
@@ -1,28 +1,25 @@
 package request
 
-import "aps_crm/proto/code"
-
 type AddFollowRecord struct {
 	FollowRecord FollowRecord `json:"follow_record" binding:"required"`
 }
 
 type FollowRecord struct {
-	ClientId             int               `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛id"`
-	ClientStatusId       int               `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:瀹㈡埛鐘舵�乮d"`
-	MemberId             int               `json:"member_id" gorm:"column:member_id;type:int(11);comment:璺熻繘浜篿d"`
-	Number               string            `json:"number" gorm:"column:number;type:varchar(255);comment:璺熻繘缂栧彿"`
-	ContactId            int               `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:鑱旂郴浜篿d"`
-	Topic                string            `json:"topic" gorm:"column:topic;type:varchar(255);comment:璺熻繘涓婚"`
-	Record               string            `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:璺熻繘璁板綍"`
-	SaleChanceId         int               `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:閿�鍞満浼歩d"`
-	SalesLeadsId         int               `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:閿�鍞嚎绱d"`
-	ContactInformationId int               `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:鑱旂郴鏂瑰紡id"`
-	FollowTime           string            `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:璺熻繘鏃堕棿"`
-	NextFollowTime       string            `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:涓嬫璺熻繘鏃堕棿"`
-	Purpose              string            `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:璺熻繘鐩殑"`
-	Content              string            `json:"content" gorm:"column:content;type:varchar(255);comment:璺熻繘鍐呭"`
-	CodeStandID          string            `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
-	CodeRule             code.CodeStandard `json:"codeRule"`
+	ClientId             int    `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛id"`
+	ClientStatusId       int    `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:瀹㈡埛鐘舵�乮d"`
+	MemberId             int    `json:"member_id" gorm:"column:member_id;type:int(11);comment:璺熻繘浜篿d"`
+	Number               string `json:"number" gorm:"column:number;type:varchar(255);comment:璺熻繘缂栧彿"`
+	ContactId            int    `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:鑱旂郴浜篿d"`
+	Topic                string `json:"topic" gorm:"column:topic;type:varchar(255);comment:璺熻繘涓婚"`
+	Record               string `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:璺熻繘璁板綍"`
+	SaleChanceId         int    `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:閿�鍞満浼歩d"`
+	SalesLeadsId         int    `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:閿�鍞嚎绱d"`
+	ContactInformationId int    `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:鑱旂郴鏂瑰紡id"`
+	FollowTime           string `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:璺熻繘鏃堕棿"`
+	NextFollowTime       string `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:涓嬫璺熻繘鏃堕棿"`
+	Purpose              string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:璺熻繘鐩殑"`
+	Content              string `json:"content" gorm:"column:content;type:varchar(255);comment:璺熻繘鍐呭"`
+	CodeStandID          string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
 }
 
 type UpdateFollowRecord struct {
diff --git a/model/request/masterOrder.go b/model/request/masterOrder.go
index 00317c8..22f8393 100644
--- a/model/request/masterOrder.go
+++ b/model/request/masterOrder.go
@@ -1,20 +1,17 @@
 package request
 
-import "aps_crm/proto/code"
-
 type AddMasterOrder struct {
 	MasterOrder
 }
 
 type MasterOrder struct {
-	Number      string            `json:"number"`
-	ClientId    int               `json:"client_id"`
-	MemberId    int               `json:"member_id"`
-	StartTime   string            `json:"start_time"`
-	EndTime     string            `json:"end_time"`
-	Money       float64           `json:"money"`
-	CodeStandID string            `json:"codeStandID"` //缂栫爜id
-	CodeRule    code.CodeStandard `json:"codeRule"`
+	Number      string  `json:"number"`
+	ClientId    int     `json:"client_id"`
+	MemberId    int     `json:"member_id"`
+	StartTime   string  `json:"start_time"`
+	EndTime     string  `json:"end_time"`
+	Money       float64 `json:"money"`
+	CodeStandID string  `json:"codeStandID"` //缂栫爜id
 }
 
 type UpdateMasterOrder struct {
diff --git a/model/request/quotation.go b/model/request/quotation.go
index a0d1425..87ea612 100644
--- a/model/request/quotation.go
+++ b/model/request/quotation.go
@@ -2,7 +2,6 @@
 
 import (
 	"aps_crm/model"
-	"aps_crm/proto/code"
 )
 
 type AddQuotation struct {
@@ -10,19 +9,18 @@
 }
 
 type Quotation struct {
-	QuotationName     string            `json:"quotationName"` //鎶ヤ环鍗曞悕绉�
-	ClientId          int               `json:"client_id"`
-	Number            string            `json:"number"`
-	QuotationStatusId int               `json:"quotation_status_id"`
-	ValidityDate      string            `json:"validity_date"`
-	ContactId         int               `json:"contact_id"`
-	MemberId          int               `json:"member_id"`
-	SaleChanceId      int               `json:"sale_chance_id"`
-	Conditions        string            `json:"conditions"`
-	File              string            `json:"file"`
-	CodeStandID       string            `json:"codeStandID"` //缂栫爜id
-	CodeRule          code.CodeStandard `json:"codeRule"`
-	Products          []model.Product   `json:"products"`
+	QuotationName     string          `json:"quotationName"` //鎶ヤ环鍗曞悕绉�
+	ClientId          int             `json:"client_id"`
+	Number            string          `json:"number"`
+	QuotationStatusId int             `json:"quotation_status_id"`
+	ValidityDate      string          `json:"validity_date"`
+	ContactId         int             `json:"contact_id"`
+	MemberId          int             `json:"member_id"`
+	SaleChanceId      int             `json:"sale_chance_id"`
+	Conditions        string          `json:"conditions"`
+	File              string          `json:"file"`
+	CodeStandID       string          `json:"codeStandID"` //缂栫爜id
+	Products          []model.Product `json:"products"`
 }
 
 type UpdateQuotation struct {
diff --git a/model/request/saleChance.go b/model/request/saleChance.go
index 34085de..05c8aa6 100644
--- a/model/request/saleChance.go
+++ b/model/request/saleChance.go
@@ -2,7 +2,6 @@
 
 import (
 	"aps_crm/model"
-	"aps_crm/proto/code"
 )
 
 type AddSaleChance struct {
@@ -10,38 +9,37 @@
 }
 
 type SaleChance struct {
-	Name               string            `json:"name"`
-	ClientId           int               `json:"client_id"`
-	Number             string            `json:"number"`
-	ContactId          int               `json:"contact_id"`
-	SalesSourcesId     int               `json:"sales_sources_id"`
-	SaleTypeId         int               `json:"sale_type_id"`
-	SaleStageId        int               `json:"sale_stage_id"`
-	MemberId           int               `json:"member_id"`
-	RegularCustomersId int               `json:"regular_customers_id"`
-	Competitors        string            `json:"competitors"`
-	Possibilities      int               `json:"possibilities"`
-	Budget             float64           `json:"budget"`
-	ProjectedAmount    float64           `json:"projected_amount"`
-	Currency           int               `json:"currency"`
-	ExpectedTime       string            `json:"expected_time"`
-	StatusId           int               `json:"status_id"`
-	PainPoints         string            `json:"pain_points"`
-	WhetherEstablished string            `json:"whether_established"`
-	CapitalBudget      string            `json:"capital_budget"`
-	KeyMaker           string            `json:"key_maker"`
-	KeyFactors         string            `json:"key_factors"`
-	Process            string            `json:"process"`
-	Solutions          string            `json:"solutions"`
-	Advantages         string            `json:"advantages"`
-	Disadvantages      string            `json:"disadvantages"`
-	Opportunities      string            `json:"opportunities"`
-	Threats            string            `json:"threats"`
-	Remark             string            `json:"remark"`
-	DetailAddress      string            `json:"detail_address"`
-	CodeStandID        string            `json:"codeStandID"` //缂栫爜id
-	CodeRule           code.CodeStandard `json:"codeRule"`
-	Products           []*model.Product  `json:"products" gorm:"many2many:SaleChance_Product;"`
+	Name               string           `json:"name"`
+	ClientId           int              `json:"client_id"`
+	Number             string           `json:"number"`
+	ContactId          int              `json:"contact_id"`
+	SalesSourcesId     int              `json:"sales_sources_id"`
+	SaleTypeId         int              `json:"sale_type_id"`
+	SaleStageId        int              `json:"sale_stage_id"`
+	MemberId           int              `json:"member_id"`
+	RegularCustomersId int              `json:"regular_customers_id"`
+	Competitors        string           `json:"competitors"`
+	Possibilities      int              `json:"possibilities"`
+	Budget             float64          `json:"budget"`
+	ProjectedAmount    float64          `json:"projected_amount"`
+	Currency           int              `json:"currency"`
+	ExpectedTime       string           `json:"expected_time"`
+	StatusId           int              `json:"status_id"`
+	PainPoints         string           `json:"pain_points"`
+	WhetherEstablished string           `json:"whether_established"`
+	CapitalBudget      string           `json:"capital_budget"`
+	KeyMaker           string           `json:"key_maker"`
+	KeyFactors         string           `json:"key_factors"`
+	Process            string           `json:"process"`
+	Solutions          string           `json:"solutions"`
+	Advantages         string           `json:"advantages"`
+	Disadvantages      string           `json:"disadvantages"`
+	Opportunities      string           `json:"opportunities"`
+	Threats            string           `json:"threats"`
+	Remark             string           `json:"remark"`
+	DetailAddress      string           `json:"detail_address"`
+	CodeStandID        string           `json:"codeStandID"` //缂栫爜id
+	Products           []*model.Product `json:"products" gorm:"many2many:SaleChance_Product;"`
 	Address
 }
 
diff --git a/model/request/salesDetails.go b/model/request/salesDetails.go
index 8acf6a8..08e425c 100644
--- a/model/request/salesDetails.go
+++ b/model/request/salesDetails.go
@@ -3,7 +3,6 @@
 import (
 	"aps_crm/constvar"
 	"aps_crm/model"
-	"aps_crm/proto/code"
 )
 
 type AddSalesDetails struct {
@@ -11,25 +10,25 @@
 }
 
 type SalesDetails struct {
-	ClientId            int               `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
-	Number              string            `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞瓙鍗曞彿"`
-	SaleChanceId        int               `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
-	SaleType            int               `json:"saleType" gorm:"column:sale_type;type:int;comment:閿�鍞被鍨�"`
-	SignTime            string            `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛惧崟鏃堕棿"`
-	MemberId            int               `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
-	DeliveryDate        string            `json:"deliveryDate" gorm:"column:delivery_date;type:datetime;comment:浜よ揣鏃ユ湡"`
-	WechatOrderStatusId int               `json:"wechatOrderStatusId" gorm:"column:wechat_order_status_id;type:int;comment:寰俊璁㈠崟鐘舵�乮d"`
-	Address             string            `json:"address" gorm:"column:address;type:varchar(255);comment:鍦板潃"`
-	Phone               string            `json:"phone" gorm:"column:phone;type:varchar(255);comment:鐢佃瘽"`
-	Addressee           string            `json:"addressee" gorm:"column:addressee;type:varchar(255);comment:鏀朵欢浜�"`
-	Conditions          string            `json:"conditions" gorm:"column:conditions;type:text;comment:鏉′欢"`
-	Remark              string            `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
-	Products            []*model.Product  `json:"products" gorm:"many2many:sales_details_product;"`
-	LogisticCompany     string            `json:"logisticCompany" gorm:"column:logistic_company;type:varchar(255);comment:鐗╂祦鍏徃"`
-	LogisticNumber      string            `json:"logisticNumber" gorm:"column:logistic_number;type:varchar(255);comment:鐗╂祦鍗曞彿"`
-	LogisticCost        float64           `json:"logisticCost" gorm:"column:logistic_cost;type:decimal(10,2);comment:鐗╂祦璐圭敤"`
-	CodeStandID         string            `json:"codeStandID"` //缂栫爜id
-	CodeRule            code.CodeStandard `json:"codeRule"`
+	ClientId            int              `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
+	Number              string           `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞瓙鍗曞彿"`
+	SaleChanceId        int              `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
+	SaleType            int              `json:"saleType" gorm:"column:sale_type;type:int;comment:閿�鍞被鍨�"`
+	SignTime            string           `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛惧崟鏃堕棿"`
+	MemberId            int              `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
+	DeliveryDate        string           `json:"deliveryDate" gorm:"column:delivery_date;type:datetime;comment:浜よ揣鏃ユ湡"`
+	WechatOrderStatusId int              `json:"wechatOrderStatusId" gorm:"column:wechat_order_status_id;type:int;comment:寰俊璁㈠崟鐘舵�乮d"`
+	Address             string           `json:"address" gorm:"column:address;type:varchar(255);comment:鍦板潃"`
+	Phone               string           `json:"phone" gorm:"column:phone;type:varchar(255);comment:鐢佃瘽"`
+	Addressee           string           `json:"addressee" gorm:"column:addressee;type:varchar(255);comment:鏀朵欢浜�"`
+	Conditions          string           `json:"conditions" gorm:"column:conditions;type:text;comment:鏉′欢"`
+	Remark              string           `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
+	Products            []*model.Product `json:"products" gorm:"many2many:sales_details_product;"`
+	LogisticCompany     string           `json:"logisticCompany" gorm:"column:logistic_company;type:varchar(255);comment:鐗╂祦鍏徃"`
+	LogisticNumber      string           `json:"logisticNumber" gorm:"column:logistic_number;type:varchar(255);comment:鐗╂祦鍗曞彿"`
+	LogisticCost        float64          `json:"logisticCost" gorm:"column:logistic_cost;type:decimal(10,2);comment:鐗╂祦璐圭敤"`
+	CodeStandID         string           `json:"codeStandID"` //缂栫爜id
+	DeliverType         int              `json:"deliverType"` //浜や粯绫诲瀷:1.涓�娆″彂璐�,2.澶氭鍙戣揣
 }
 
 type UpdateSalesDetails struct {
diff --git a/model/request/salesLeads.go b/model/request/salesLeads.go
index 821be06..3c4de2f 100644
--- a/model/request/salesLeads.go
+++ b/model/request/salesLeads.go
@@ -2,7 +2,6 @@
 
 import (
 	"aps_crm/constvar"
-	"aps_crm/proto/code"
 )
 
 type AddSalesLeads struct {
@@ -10,17 +9,16 @@
 }
 
 type SalesLeads struct {
-	Name            string            `json:"name"`             // 鍏徃鍚嶇О
-	Number          string            `json:"number"`           // 閿�鍞嚎绱㈢紪鍙�
-	ContactName     string            `json:"contact_name"`     // 鑱旂郴浜哄鍚�
-	ContactPhone    string            `json:"contact_phone"`    // 鑱旂郴浜虹數璇�
-	ContactPosition string            `json:"contact_position"` // 鑱旂郴浜鸿亴浣�
-	SalesSourcesId  int               `json:"sales_sources_id"` // 鍟嗘満鏉ユ簮ID
-	MemberId        int               `json:"member_id"`        // 閿�鍞礋璐d汉ID
-	Desc            string            `json:"desc"`             // 澶囨敞
-	DetailAddress   string            `json:"detail_address"`   // 璇︾粏鍦板潃
-	CodeStandID     string            `json:"codeStandID"`      //缂栫爜id
-	CodeRule        code.CodeStandard `json:"codeRule"`
+	Name            string `json:"name"`             // 鍏徃鍚嶇О
+	Number          string `json:"number"`           // 閿�鍞嚎绱㈢紪鍙�
+	ContactName     string `json:"contact_name"`     // 鑱旂郴浜哄鍚�
+	ContactPhone    string `json:"contact_phone"`    // 鑱旂郴浜虹數璇�
+	ContactPosition string `json:"contact_position"` // 鑱旂郴浜鸿亴浣�
+	SalesSourcesId  int    `json:"sales_sources_id"` // 鍟嗘満鏉ユ簮ID
+	MemberId        int    `json:"member_id"`        // 閿�鍞礋璐d汉ID
+	Desc            string `json:"desc"`             // 澶囨敞
+	DetailAddress   string `json:"detail_address"`   // 璇︾粏鍦板潃
+	CodeStandID     string `json:"codeStandID"`      //缂栫爜id
 	Address
 }
 
diff --git a/model/request/salesRefund.go b/model/request/salesRefund.go
index 4cfb4ee..ad162bb 100644
--- a/model/request/salesRefund.go
+++ b/model/request/salesRefund.go
@@ -3,7 +3,6 @@
 import (
 	"aps_crm/constvar"
 	"aps_crm/model"
-	"aps_crm/proto/code"
 )
 
 type AddSalesRefundRequest struct {
@@ -23,7 +22,6 @@
 	Reason        string                    `json:"reason"`
 	Products      []*model.Product          `json:"products"`
 	CodeStandID   string                    `json:"codeStandID"` //缂栫爜id
-	CodeRule      code.CodeStandard         `json:"codeRule"`
 }
 
 type UpdateSalesRefundRequest struct {
diff --git a/model/request/salesReturn.go b/model/request/salesReturn.go
index 3c85395..46d706d 100644
--- a/model/request/salesReturn.go
+++ b/model/request/salesReturn.go
@@ -3,7 +3,6 @@
 import (
 	"aps_crm/constvar"
 	"aps_crm/model"
-	"aps_crm/proto/code"
 )
 
 type AddSalesReturnRequest struct {
@@ -24,7 +23,6 @@
 	Reason              string                         `json:"reason" gorm:"column:reason;type:varchar(255);comment:閫�璐у師鍥�"`                     //閫�璐у師鍥�
 	Products            []*model.Product               `json:"products" gorm:"many2many:salesReturn_product;"`                                 //閫�璐т骇鍝�
 	CodeStandID         string                         `json:"codeStandID"`                                                                    //缂栫爜id
-	CodeRule            code.CodeStandard              `json:"codeRule"`
 }
 
 type UpdateSalesReturnRequest struct {
diff --git a/model/request/serviceContract.go b/model/request/serviceContract.go
index a8ea3b5..f3cb2fe 100644
--- a/model/request/serviceContract.go
+++ b/model/request/serviceContract.go
@@ -3,7 +3,6 @@
 import (
 	"aps_crm/constvar"
 	"aps_crm/model"
-	"aps_crm/proto/code"
 )
 
 type AddServiceContract struct {
@@ -11,26 +10,25 @@
 }
 
 type ServiceContract struct {
-	ClientId                int               `json:"clientId"`
-	Number                  string            `json:"number"`
-	MemberId                int               `json:"memberId" binding:"required"`
-	ContactId               int               `json:"contactId"`
-	SaleChanceId            int               `json:"saleChanceId"`
-	SalesDetailsId          int               `json:"salesDetailsId"`
-	QuotationId             int               `json:"quotationId"`
-	TypeId                  int               `json:"typeId"`
-	SignTime                string            `json:"signTime" binding:"datetime=2006-01-02"`
-	StartTime               string            `json:"startTime"`
-	EndTime                 string            `json:"endTime"`
-	StatusId                int               `json:"statusId"`
-	ServiceTimes            int               `json:"serviceTimes"`
-	Terms                   string            `json:"terms"`
-	Remark                  string            `json:"remark"`
-	Products                []*model.Product  `json:"products"`
-	ServiceContractTypeId   int               `json:"serviceContractTypeId"`
-	ServiceContractStatusId int               `json:"serviceContractStatusId"`
-	CodeStandID             string            `json:"codeStandID"` //缂栫爜id
-	CodeRule                code.CodeStandard `json:"codeRule"`
+	ClientId                int              `json:"clientId"`
+	Number                  string           `json:"number"`
+	MemberId                int              `json:"memberId" binding:"required"`
+	ContactId               int              `json:"contactId"`
+	SaleChanceId            int              `json:"saleChanceId"`
+	SalesDetailsId          int              `json:"salesDetailsId"`
+	QuotationId             int              `json:"quotationId"`
+	TypeId                  int              `json:"typeId"`
+	SignTime                string           `json:"signTime" binding:"datetime=2006-01-02"`
+	StartTime               string           `json:"startTime"`
+	EndTime                 string           `json:"endTime"`
+	StatusId                int              `json:"statusId"`
+	ServiceTimes            int              `json:"serviceTimes"`
+	Terms                   string           `json:"terms"`
+	Remark                  string           `json:"remark"`
+	Products                []*model.Product `json:"products"`
+	ServiceContractTypeId   int              `json:"serviceContractTypeId"`
+	ServiceContractStatusId int              `json:"serviceContractStatusId"`
+	CodeStandID             string           `json:"codeStandID"` //缂栫爜id
 }
 
 type UpdateServiceContract struct {
diff --git a/model/request/serviceFollowup.go b/model/request/serviceFollowup.go
index b5628e8..06b86e1 100644
--- a/model/request/serviceFollowup.go
+++ b/model/request/serviceFollowup.go
@@ -2,7 +2,6 @@
 
 import (
 	"aps_crm/constvar"
-	"aps_crm/proto/code"
 )
 
 type AddServiceFollowup struct {
@@ -10,21 +9,20 @@
 }
 
 type ServiceFollowup struct {
-	ClientId       int               `json:"clientId"`
-	Number         string            `json:"number"`
-	ContactId      int               `json:"contactId"`
-	ServiceOrderId int               `json:"serviceOrderId"`
-	MemberId       int               `json:"memberId"`
-	PlanId         int               `json:"planId"`
-	Satisfaction   int               `json:"satisfaction"`
-	TimelyRate     int               `json:"timelyRate"`
-	SolveRate      int               `json:"solveRate"`
-	IsVisit        int               `json:"isVisit"`
-	OldMemberId    int               `json:"oldMemberId"`
-	Remark         string            `json:"remark"`
-	File           string            `json:"file"`
-	CodeStandID    string            `json:"codeStandID"` //缂栫爜id
-	CodeRule       code.CodeStandard `json:"codeRule"`
+	ClientId       int    `json:"clientId"`
+	Number         string `json:"number"`
+	ContactId      int    `json:"contactId"`
+	ServiceOrderId int    `json:"serviceOrderId"`
+	MemberId       int    `json:"memberId"`
+	PlanId         int    `json:"planId"`
+	Satisfaction   int    `json:"satisfaction"`
+	TimelyRate     int    `json:"timelyRate"`
+	SolveRate      int    `json:"solveRate"`
+	IsVisit        int    `json:"isVisit"`
+	OldMemberId    int    `json:"oldMemberId"`
+	Remark         string `json:"remark"`
+	File           string `json:"file"`
+	CodeStandID    string `json:"codeStandID"` //缂栫爜id
 }
 
 type UpdateServiceFollowup struct {
diff --git a/model/request/serviceOrder.go b/model/request/serviceOrder.go
index 3b59202..a9641dc 100644
--- a/model/request/serviceOrder.go
+++ b/model/request/serviceOrder.go
@@ -2,39 +2,37 @@
 
 import (
 	"aps_crm/constvar"
-	"aps_crm/proto/code"
 )
 
 type AddServiceOrder struct {
-	ServiceNumber        string            `gorm:"service_number" json:"serviceNumber"`                                                                    // 鏈嶅姟鍗曠紪鍙�
-	ClientId             int               `gorm:"client_id" json:"clientId"`                                                                              // 瀹㈡埛id
-	ServiceContractId    int               `gorm:"service_contract_id" json:"serviceContractId"`                                                           // 鍚堝悓id
-	SalesDetailsId       int               `gorm:"sales_details_id" json:"salesDetailsId"`                                                                 // 閿�鍞鍗昳d
-	Subject              string            `gorm:"subject" json:"subject"`                                                                                 // 涓婚
-	ProductTypeName      string            `json:"productTypeName"`                                                                                        // 浜у搧鍒嗙被鍚嶇О
-	ProductName          string            `json:"productName"`                                                                                            // 浜у搧鍚嶇О
-	ServiceTypeId        int               `gorm:"service_type_id" json:"serviceTypeId"`                                                                   // 鏈嶅姟鏂瑰紡id
-	ServiceManId         int               `gorm:"service_man_id" json:"serviceManId"`                                                                     // 鏈嶅姟浜哄憳
-	ContactId            int               `gorm:"linkman_id" json:"contactId"`                                                                            // 鑱旂郴浜篿d
-	Address              string            `gorm:"address" json:"address"`                                                                                 // 涓婇棬鍦板潃
-	PriorityLevelId      int               `gorm:"priority_level_id" json:"priorityLevelId"`                                                               // 浼樺厛绾у埆id
-	AppointmentTime      string            `gorm:"appointment_time" json:"appointmentTime"`                                                                // 棰勭害涓婇棬鏃堕棿
-	SaleChanceId         int               `gorm:"sale_leads" json:"saleChanceId"`                                                                         // 閿�鍞満浼歩d
-	FaultTypeId          int               `gorm:"severity_id" json:"faultTypeId"`                                                                         // 鏁呴殰绫诲埆id
-	SeverityId           int               `gorm:"severity_id" json:"severity"`                                                                            // 涓ラ噸绋嬪害id
-	ServiceOrderStatusId int               `gorm:"column:service_order_status_id;type:int;not null;default:0;comment:鏈嶅姟鍗曠姸鎬乮d" json:"serviceOrderStatusId"` // 澶勭悊鐘舵��
-	ExpectTime           string            `gorm:"expect_time" json:"expectTime"`                                                                          // 甯屾湜澶勭悊鏃堕棿
-	RealTime             string            `gorm:"real_time" json:"realTime"`                                                                              // 瀹為檯澶勭悊鏃堕棿
-	CarFare              float64           `gorm:"car_fare" json:"carFare"`                                                                                // 浜ら�氳垂
-	ChargeAmount         float64           `gorm:"charge_amount" json:"chargeAmount"`                                                                      // 鏀惰垂閲戦
-	TimeSpentId          int               `gorm:"time_spent_id" json:"timeSpentId"`                                                                       // 鑺辫垂鏃堕棿
-	FaqId                int               `gorm:"problem_id" json:"faqId"`                                                                                // 甯歌闂id
-	ProblemDesc          string            `gorm:"problem_desc" json:"problemDesc"`                                                                        // 闂鎻忚堪
-	Solution             string            `gorm:"solution" json:"solution"`                                                                               // 瑙e喅鏂规硶
-	SolutionRemark       string            `gorm:"solution_remark" json:"solutionRemark"`                                                                  // 鍐呴儴澶囨敞
-	Remark               string            `gorm:"remark" json:"remark"`                                                                                   // 澶囨敞
-	CodeStandID          string            `json:"codeStandID"`                                                                                            //缂栫爜id
-	CodeRule             code.CodeStandard `json:"codeRule"`
+	ServiceNumber        string  `gorm:"service_number" json:"serviceNumber"`                                                                    // 鏈嶅姟鍗曠紪鍙�
+	ClientId             int     `gorm:"client_id" json:"clientId"`                                                                              // 瀹㈡埛id
+	ServiceContractId    int     `gorm:"service_contract_id" json:"serviceContractId"`                                                           // 鍚堝悓id
+	SalesDetailsId       int     `gorm:"sales_details_id" json:"salesDetailsId"`                                                                 // 閿�鍞鍗昳d
+	Subject              string  `gorm:"subject" json:"subject"`                                                                                 // 涓婚
+	ProductTypeName      string  `json:"productTypeName"`                                                                                        // 浜у搧鍒嗙被鍚嶇О
+	ProductName          string  `json:"productName"`                                                                                            // 浜у搧鍚嶇О
+	ServiceTypeId        int     `gorm:"service_type_id" json:"serviceTypeId"`                                                                   // 鏈嶅姟鏂瑰紡id
+	ServiceManId         int     `gorm:"service_man_id" json:"serviceManId"`                                                                     // 鏈嶅姟浜哄憳
+	ContactId            int     `gorm:"linkman_id" json:"contactId"`                                                                            // 鑱旂郴浜篿d
+	Address              string  `gorm:"address" json:"address"`                                                                                 // 涓婇棬鍦板潃
+	PriorityLevelId      int     `gorm:"priority_level_id" json:"priorityLevelId"`                                                               // 浼樺厛绾у埆id
+	AppointmentTime      string  `gorm:"appointment_time" json:"appointmentTime"`                                                                // 棰勭害涓婇棬鏃堕棿
+	SaleChanceId         int     `gorm:"sale_leads" json:"saleChanceId"`                                                                         // 閿�鍞満浼歩d
+	FaultTypeId          int     `gorm:"severity_id" json:"faultTypeId"`                                                                         // 鏁呴殰绫诲埆id
+	SeverityId           int     `gorm:"severity_id" json:"severity"`                                                                            // 涓ラ噸绋嬪害id
+	ServiceOrderStatusId int     `gorm:"column:service_order_status_id;type:int;not null;default:0;comment:鏈嶅姟鍗曠姸鎬乮d" json:"serviceOrderStatusId"` // 澶勭悊鐘舵��
+	ExpectTime           string  `gorm:"expect_time" json:"expectTime"`                                                                          // 甯屾湜澶勭悊鏃堕棿
+	RealTime             string  `gorm:"real_time" json:"realTime"`                                                                              // 瀹為檯澶勭悊鏃堕棿
+	CarFare              float64 `gorm:"car_fare" json:"carFare"`                                                                                // 浜ら�氳垂
+	ChargeAmount         float64 `gorm:"charge_amount" json:"chargeAmount"`                                                                      // 鏀惰垂閲戦
+	TimeSpentId          int     `gorm:"time_spent_id" json:"timeSpentId"`                                                                       // 鑺辫垂鏃堕棿
+	FaqId                int     `gorm:"problem_id" json:"faqId"`                                                                                // 甯歌闂id
+	ProblemDesc          string  `gorm:"problem_desc" json:"problemDesc"`                                                                        // 闂鎻忚堪
+	Solution             string  `gorm:"solution" json:"solution"`                                                                               // 瑙e喅鏂规硶
+	SolutionRemark       string  `gorm:"solution_remark" json:"solutionRemark"`                                                                  // 鍐呴儴澶囨敞
+	Remark               string  `gorm:"remark" json:"remark"`                                                                                   // 澶囨敞
+	CodeStandID          string  `json:"codeStandID"`                                                                                            //缂栫爜id
 }
 
 type UpdateServiceOrder struct {
diff --git a/model/request/subOrder.go b/model/request/subOrder.go
index 556f4e0..7db7ff3 100644
--- a/model/request/subOrder.go
+++ b/model/request/subOrder.go
@@ -2,7 +2,6 @@
 
 import (
 	"aps_crm/model"
-	"aps_crm/proto/code"
 )
 
 type AddSubOrder struct {
@@ -10,13 +9,12 @@
 }
 
 type SubOrder struct {
-	ClientId      int               `json:"clientId"`
-	MasterOrderId int               `json:"masterOrderId"`
-	Number        string            `json:"number"`
-	MemberId      int               `json:"memberId"`
-	Product       []model.Product   `json:"product"`
-	CodeStandID   string            `json:"codeStandID"` //缂栫爜id
-	CodeRule      code.CodeStandard `json:"codeRule"`
+	ClientId      int             `json:"clientId"`
+	MasterOrderId int             `json:"masterOrderId"`
+	Number        string          `json:"number"`
+	MemberId      int             `json:"memberId"`
+	Product       []model.Product `json:"product"`
+	CodeStandID   string          `json:"codeStandID"` //缂栫爜id
 }
 
 type UpdateSubOrder struct {
diff --git a/model/saleChance.go b/model/saleChance.go
index f136914..5f0f37c 100644
--- a/model/saleChance.go
+++ b/model/saleChance.go
@@ -2,6 +2,7 @@
 
 import (
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 )
 
@@ -213,3 +214,20 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *SaleChanceSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
diff --git a/model/salesDetails.go b/model/salesDetails.go
index b82e761..bf371e3 100644
--- a/model/salesDetails.go
+++ b/model/salesDetails.go
@@ -40,6 +40,7 @@
 		AmountUnInvoiced    decimal.Decimal   `gorm:"column:amount_not_invoiced;type:decimal(12,2);comment:鏈紑绁ㄩ噾棰�" json:"amountUnInvoiced"` // 鏈紑绁ㄩ噾棰�
 		AmountTotal         decimal.Decimal   `gorm:"column:amount_total;type:decimal(12,2);comment:浠风◣鍚堣" json:"amountTotal"`              // 浠风◣鍚堣
 		CodeStandID         string            `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
+		DeliverType         int               `json:"deliverType" gorm:"column:deliver_type;type:int;comment:浜や粯绫诲瀷(1.涓�娆″彂璐�,2.澶氭鍙戣揣)"`
 		CrmModel
 	}
 
@@ -133,6 +134,30 @@
 	return db.Updates(record).Error
 }
 
+func (slf *SalesDetailsSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *SalesDetailsSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *SalesDetailsSearch) SetId(id int) *SalesDetailsSearch {
 	slf.Id = id
 	return slf
diff --git a/model/salesLeads.go b/model/salesLeads.go
index f215ce4..4439bdb 100644
--- a/model/salesLeads.go
+++ b/model/salesLeads.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/constvar"
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 )
 
@@ -61,6 +62,9 @@
 	}
 	if slf.Name != "" {
 		db = db.Where("name = ?", slf.Name)
+	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
 	}
 
 	if len(slf.SearchMap) > 0 {
@@ -141,6 +145,30 @@
 	return records, total, err
 }
 
+func (slf *SalesLeadsSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *SalesLeadsSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *SalesLeadsSearch) SetId(id int) *SalesLeadsSearch {
 	slf.Id = id
 	return slf
@@ -176,6 +204,11 @@
 	return slf
 }
 
+func (slf *SalesLeadsSearch) SetNumber(number string) *SalesLeadsSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *SalesLeadsSearch) SetSearchMap(data map[string]interface{}) *SalesLeadsSearch {
 	slf.SearchMap = data
 	return slf
diff --git a/model/salesRefund.go b/model/salesRefund.go
index d4aadd8..9155fb5 100644
--- a/model/salesRefund.go
+++ b/model/salesRefund.go
@@ -116,6 +116,9 @@
 	if len(slf.MemberIds) > 0 {
 		db = db.Where("sales_refund.member_id in ?", slf.MemberIds)
 	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
+	}
 
 	return db
 }
@@ -169,6 +172,30 @@
 	return records, total, err
 }
 
+func (slf *SalesRefundSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *SalesRefundSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *SalesRefundSearch) SetId(id int) *SalesRefundSearch {
 	slf.Id = id
 	return slf
@@ -214,6 +241,11 @@
 	return slf
 }
 
+func (slf *SalesRefundSearch) SetNumber(number string) *SalesRefundSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *SalesRefundSearch) UpdateByMap(data map[string]interface{}) error {
 	var db = slf.build()
 	return db.Updates(data).Error
diff --git a/model/salesReturn.go b/model/salesReturn.go
index df99ba7..126b29a 100644
--- a/model/salesReturn.go
+++ b/model/salesReturn.go
@@ -114,6 +114,9 @@
 	if len(slf.MemberIds) > 0 {
 		db = db.Where("sales_return.member_id in ?", slf.MemberIds)
 	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
+	}
 
 	return db
 }
@@ -168,6 +171,30 @@
 	return records, err
 }
 
+func (slf *SalesReturnSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *SalesReturnSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *SalesReturnSearch) SetId(id int) *SalesReturnSearch {
 	slf.Id = id
 	return slf
@@ -217,6 +244,11 @@
 	return slf
 }
 
+func (slf *SalesReturnSearch) SetNumber(number string) *SalesReturnSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *SalesReturnSearch) UpdateByMap(data map[string]interface{}) error {
 	var db = slf.build()
 	return db.Updates(data).Error
diff --git a/model/serviceContract.go b/model/serviceContract.go
index 8c8db4e..61d8e5f 100644
--- a/model/serviceContract.go
+++ b/model/serviceContract.go
@@ -145,6 +145,9 @@
 	if slf.ContactId != 0 {
 		db = db.Where("contact_id = ?", slf.ContactId)
 	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
+	}
 	return db
 }
 
@@ -180,10 +183,39 @@
 		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
 	}
 
-	err := db.Order("id desc").Order("id desc").Find(&records).Error
+	err := db.Order("id desc").Find(&records).Error
 	return records, total, err
 }
 
+func (slf *ServiceContractSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *ServiceContractSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
+func (slf *ServiceContractSearch) SetNumber(number string) *ServiceContractSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *ServiceContractSearch) SetId(id int) *ServiceContractSearch {
 	slf.Id = id
 	return slf
diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go
index 0b62891..65ffa14 100644
--- a/model/serviceFollowup.go
+++ b/model/serviceFollowup.go
@@ -101,6 +101,9 @@
 	if len(slf.MemberIds) > 0 {
 		db = db.Where("service_followup.member_id in ?", slf.MemberIds)
 	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
+	}
 
 	return db
 }
@@ -142,6 +145,35 @@
 	return records, total, err
 }
 
+func (slf *ServiceFollowupSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *ServiceFollowupSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
+func (slf *ServiceFollowupSearch) SetNumber(number string) *ServiceFollowupSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch {
 	slf.Id = id
 	return slf
diff --git a/model/serviceOrder.go b/model/serviceOrder.go
index f593b5c..3440357 100644
--- a/model/serviceOrder.go
+++ b/model/serviceOrder.go
@@ -134,6 +134,9 @@
 	if len(slf.ServiceManIds) > 0 {
 		db = db.Where("service_man_id in ?", slf.ServiceManIds)
 	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
+	}
 
 	return db
 }
@@ -216,6 +219,11 @@
 	return slf
 }
 
+func (slf *ServiceOrderSearch) SetNumber(number string) *ServiceOrderSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *ServiceOrderSearch) First() (*ServiceOrder, error) {
 	var db = slf.build()
 	var record = new(ServiceOrder)
@@ -260,3 +268,27 @@
 	var db = slf.build()
 	return db.Updates(data).Error
 }
+
+func (slf *ServiceOrderSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *ServiceOrderSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
diff --git a/model/subOrder.go b/model/subOrder.go
index 0182500..930e672 100644
--- a/model/subOrder.go
+++ b/model/subOrder.go
@@ -2,6 +2,7 @@
 
 import (
 	"aps_crm/pkg/mysqlx"
+	"fmt"
 	"gorm.io/gorm"
 )
 
@@ -49,6 +50,9 @@
 
 	if slf.Id != 0 {
 		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.Number != "" {
+		db = db.Where("number = ?", slf.Number)
 	}
 
 	if len(slf.SearchMap) > 0 {
@@ -120,6 +124,30 @@
 	return records, total, err
 }
 
+func (slf *SubOrderSearch) Count() (int64, error) {
+	var db = slf.build()
+	var total int64
+	err := db.Count(&total).Error
+	return total, err
+}
+
+func (slf *SubOrderSearch) MaxAutoIncr() (int, error) {
+	type Result struct {
+		Max int
+	}
+
+	var (
+		result Result
+		db     = slf.build()
+	)
+
+	err := db.Select("MAX(id) as max").Scan(&result).Error
+	if err != nil {
+		return result.Max, fmt.Errorf("max err: %v", err)
+	}
+	return result.Max, nil
+}
+
 func (slf *SubOrderSearch) SetId(id int) *SubOrderSearch {
 	slf.Id = id
 	return slf
@@ -143,6 +171,12 @@
 	slf.Orm = slf.Orm.Where("id in (?)", ids)
 	return slf
 }
+
+func (slf *SubOrderSearch) SetNumber(number string) *SubOrderSearch {
+	slf.Number = number
+	return slf
+}
+
 func (slf *SubOrderSearch) UpdateByMap(data map[string]interface{}) error {
 	var db = slf.build()
 	return db.Updates(data).Error
diff --git a/model/util.go b/model/util.go
index 8ac7156..6c914a8 100644
--- a/model/util.go
+++ b/model/util.go
@@ -38,7 +38,7 @@
 	} else { // 鍥哄畾鍊�
 		prefixValue = codeStandard.AutoRule.PrefixValue
 	}
-	strMaxAutoIncr := strconv.Itoa(id)
+	strMaxAutoIncr := strconv.Itoa(id + 1)
 	count := int(codeStandard.AutoRule.AutoLength) - len(strMaxAutoIncr)
 	for i := 0; i < count; i++ {
 		strMaxAutoIncr = "0" + strMaxAutoIncr
diff --git a/router/index.go b/router/index.go
index 47df283..94aae0a 100644
--- a/router/index.go
+++ b/router/index.go
@@ -197,7 +197,8 @@
 	codeGroup := PrivateGroup.Group("code")
 	codeApi := v1.CodeApi{}
 	{
-		codeGroup.GET("getCodeList", codeApi.GetCodeList) //鑾峰彇缂栫爜鍒楄〃
+		codeGroup.GET("getCodeList", codeApi.GetCodeList)  //鑾峰彇缂栫爜鍒楄〃
+		codeGroup.POST("getAutoCode", codeApi.GetAutoCode) //鑾峰彇缂栫爜鍒楄〃
 	}
 	return Router
 }

--
Gitblit v1.8.0