From 05582688724c78bc70a7bc860193c67677f6c8cf Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 28 十月 2023 10:46:37 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm
---
model/request/masterOrder.go | 17
model/severity.go | 2
model/request/salesDetails.go | 42
docs/swagger.yaml | 140 ++-
model/SalesReturnProduct.go | 21
api/v1/salesReturn.go | 18
model/request/serviceOrder.go | 58
model/request/contract.go | 20
api/v1/salesRefund.go | 20
api/v1/invoice.go | 9
api/v1/salesLeads.go | 16
model/util.go | 2
model/request/salesReturn.go | 2
model/invoice.go | 34
model/subOrder.go | 34
model/salesReturn.go | 32
model/salesLeads.go | 33
service/saleChance.go | 45 +
api/v1/masterOrder.go | 18
model/request/saleChance.go | 66
api/v1/code.go | 65 +
docs/docs.go | 207 +++--
service/invoice.go | 2
model/followRecord.go | 39
model/request/invoice.go | 56
constvar/const.go | 32
model/serviceOrder.go | 34
service/salesRefund.go | 14
model/request/salesRefund.go | 2
api/v1/serviceFollowup.go | 17
model/request/quotation.go | 26
service/salesDetails.go | 3
api/v1/client.go | 23
model/contract.go | 35
model/request/subOrder.go | 14
api/v1/contract.go | 19
api/v1/quotation.go | 18
model/masterOrder.go | 33
model/serviceFollowup.go | 32
conf/aps-crm.json | 4
model/request/serviceFollowup.go | 30
api/v1/salesDetails.go | 20
model/client.go | 28
model/request/followRecord.go | 33
service/salesReturn.go | 1
model/request/salesLeads.go | 22
api/v1/subOrder.go | 17
model/salesDetailsProduct.go | 9
model/saleChance.go | 25
model/request/client.go | 35
model/quotation.go | 33
api/v1/serviceOrder.go | 17
docs/swagger.json | 207 +++--
model/serviceContract.go | 34
api/v1/saleChance.go | 28
model/salesDetails.go | 32
model/saleChanceProduct.go | 114 +++
api/v1/serviceContract.go | 42
model/request/serviceContract.go | 40
model/salesRefund.go | 46 +
router/index.go | 3
api/v1/followRecord.go | 17
62 files changed, 1,461 insertions(+), 676 deletions(-)
diff --git a/api/v1/client.go b/api/v1/client.go
index 37016eb..d7dc42e 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(client.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, ¶ms.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..a94cb5a 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,66 @@
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, ¶ms)
+ 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()
+ case constvar.CodeStandardTypeSaleInvoice:
+ id, err = model.NewInvoiceSearch().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, ¶ms)
+ ctx.OkWithDetailed(autoCode)
+}
diff --git a/api/v1/contract.go b/api/v1/contract.go
index 8041742..5a0dcdd 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, ¶ms.CodeRule)
- m := map[string]interface{}{
- "number": autoCode,
- }
- _ = model.NewContractSearch().SetId(contract.Id).UpdateByMap(m)
}
ctx.Ok()
@@ -138,6 +140,7 @@
File: contract.File,
CodeStandID: contract.CodeStandID,
ContractName: contract.ContractName,
+ SendTime: contract.SendTime,
}
return ecode.OK, contractModel
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, ¶ms.FollowRecord.CodeRule)
- m := map[string]interface{}{
- "number": autoCode,
- }
- _ = model.NewFollowRecordSearch().SetId(followRecord.Id).UpdateMap(m)
}
ctx.Ok()
diff --git a/api/v1/invoice.go b/api/v1/invoice.go
index c451f3c..3c51eb3 100644
--- a/api/v1/invoice.go
+++ b/api/v1/invoice.go
@@ -34,6 +34,15 @@
ctx.Fail(ecode.ParamsErr)
return
}
+ count, err := model.NewInvoiceSearch().SetNumber(invoice.Number).Count()
+ if err != nil {
+ ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+ return
+ }
+ if count > 0 {
+ ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+ return
+ }
errCode := service.NewInvoiceService().AddInvoice(&invoice)
if errCode != ecode.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, ¶ms.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, ¶ms.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 791ce98..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, ¶ms.CodeRule)
- m := map[string]interface{}{
- "number": autoCode,
- }
- _ = model.NewSaleChanceSearch().SetId(saleChance.Id).UpdateByMap(m)
}
ctx.Ok()
@@ -208,6 +199,7 @@
sc.Address.CountryId = saleChance.Address.CountryId
sc.Address.ProvinceId = saleChance.Address.ProvinceId
sc.CodeStandID = saleChance.CodeStandID
+ sc.Products = saleChance.Products
return ecode.OK, sc
}
diff --git a/api/v1/salesDetails.go b/api/v1/salesDetails.go
index 350e9c2..1a1e37d 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, ¶ms.CodeRule)
- m := map[string]interface{}{
- "number": autoCode,
- }
- _ = model.NewSalesDetailsSearch().SetId(salesDetails.Id).UpdateByMap(m)
}
ctx.OkWithDetailed(salesDetails)
@@ -156,6 +158,8 @@
salesDetailsModel.LogisticNumber = salesDetails.LogisticNumber
salesDetailsModel.LogisticCost = salesDetails.LogisticCost
salesDetailsModel.CodeStandID = salesDetails.CodeStandID
+ salesDetailsModel.DeliverType = salesDetails.DeliverType
+ salesDetailsModel.QuotationId = salesDetails.QuotationId
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, ¶ms.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..00ce774 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, ¶ms.SalesRefund.CodeRule)
- m := map[string]interface{}{
- "number": autoCode,
- }
- _ = model.NewSalesRefundSearch().SetId(salesRefund.Id).UpdateByMap(m)
}
ctx.Ok()
@@ -158,7 +160,7 @@
salesRefundRes.Reason = salesRefund.Reason
salesRefundRes.Products = salesRefund.Products
salesRefundRes.SourceType = salesRefund.SourceType
- salesRefundRes.SourceId = salesRefund.SourceId
+ salesRefundRes.SalesReturnId = salesRefund.SourceId
salesRefundRes.CodeStandID = salesRefund.CodeStandID
return ecode.OK, salesRefundRes
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, ¶ms.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, ¶ms.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, ¶ms)
-// 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, ¶ms.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..e557bd7 100644
--- a/api/v1/serviceOrder.go
+++ b/api/v1/serviceOrder.go
@@ -42,17 +42,20 @@
return
}
+ count, err := model.NewServiceOrderSearch().SetNumber(serviceOrder.ServiceNumber).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, ¶ms.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, ¶ms.CodeRule)
- m := map[string]interface{}{
- "number": autoCode,
- }
- _ = model.NewSubOrderSearch(nil).SetId(subOrder.Id).UpdateByMap(m)
- }
ctx.Ok()
}
diff --git a/conf/aps-crm.json b/conf/aps-crm.json
index 9774105..eeb4146 100644
--- a/conf/aps-crm.json
+++ b/conf/aps-crm.json
@@ -48,8 +48,8 @@
"Issuer": "qmPlus"
},
"GrpcServiceAddr": {
- "Aps": "192.168.20.120:9091",
- "Admin": "192.168.20.120:50051"
+ "Aps": "192.168.20.119:9091",
+ "Admin": "192.168.20.119:50051"
}
}
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 bbd6e7c..8452e69 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": [
@@ -11120,6 +11150,9 @@
"quotationId": {
"type": "integer"
},
+ "sendTime": {
+ "type": "string"
+ },
"serviceContractStatus": {
"$ref": "#/definitions/model.ServiceContractStatus"
},
@@ -11321,6 +11354,9 @@
"description": "瀹㈡埛id",
"type": "integer"
},
+ "codeStandID": {
+ "type": "string"
+ },
"courierCompany": {
"$ref": "#/definitions/model.CourierCompany"
},
@@ -11356,6 +11392,9 @@
"invoiceTypeId": {
"description": "鍙戠エ绫诲瀷id",
"type": "integer"
+ },
+ "number": {
+ "type": "string"
},
"principalId": {
"description": "閿�鍞礋璐d汉id",
@@ -11997,6 +12036,12 @@
"process": {
"type": "string"
},
+ "products": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Product"
+ }
+ },
"projected_amount": {
"type": "number"
},
@@ -12042,8 +12087,16 @@
"solutions": {
"type": "string"
},
+ "status": {
+ "description": "鐘舵��",
+ "allOf": [
+ {
+ "$ref": "#/definitions/model.Status"
+ }
+ ]
+ },
"status_id": {
- "$ref": "#/definitions/model.Status"
+ "type": "integer"
},
"threats": {
"type": "string"
@@ -12128,6 +12181,9 @@
"creatorName": {
"type": "string"
},
+ "deliverType": {
+ "type": "integer"
+ },
"deliveryDate": {
"type": "string"
},
@@ -12157,6 +12213,12 @@
"items": {
"$ref": "#/definitions/model.Product"
}
+ },
+ "quotation": {
+ "$ref": "#/definitions/model.Quotation"
+ },
+ "quotationId": {
+ "type": "integer"
},
"remark": {
"type": "string"
@@ -12275,9 +12337,6 @@
}
]
},
- "Source": {
- "$ref": "#/definitions/model.SalesReturn"
- },
"amountTotal": {
"description": "浠风◣鍚堣",
"type": "number"
@@ -12341,6 +12400,9 @@
"refundTypeId": {
"description": "閫�娆炬柟寮廔D",
"type": "integer"
+ },
+ "salesReturn": {
+ "$ref": "#/definitions/model.SalesReturn"
},
"sourceId": {
"description": "婧愬崟id",
@@ -12960,6 +13022,10 @@
"severity": {
"$ref": "#/definitions/model.Severity"
},
+ "severityId": {
+ "description": "涓ラ噸绋嬪害id",
+ "type": "integer"
+ },
"solution": {
"description": "瑙e喅鏂规硶",
"type": "string"
@@ -13290,9 +13356,6 @@
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -13497,9 +13560,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -13519,6 +13579,10 @@
},
"quotation_id": {
"type": "integer"
+ },
+ "sendTime": {
+ "description": "鍙戣揣鏃堕棿",
+ "type": "string"
},
"status_id": {
"type": "integer"
@@ -13660,6 +13724,9 @@
"description": "瀹㈡埛id",
"type": "integer"
},
+ "codeStandID": {
+ "type": "string"
+ },
"courierCompanyId": {
"description": "鐗╂祦鍏徃",
"type": "integer"
@@ -13683,6 +13750,10 @@
"invoiceTypeId": {
"description": "鍙戠エ绫诲瀷id",
"type": "integer"
+ },
+ "number": {
+ "description": "鍙戠エ缂栧彿",
+ "type": "string"
},
"principalId": {
"description": "閿�鍞礋璐d汉id",
@@ -13766,9 +13837,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -13889,9 +13957,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -14127,9 +14192,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14181,6 +14243,12 @@
},
"process": {
"type": "string"
+ },
+ "products": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Product"
+ }
},
"projected_amount": {
"type": "number"
@@ -14254,15 +14322,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"
@@ -14291,6 +14360,9 @@
"$ref": "#/definitions/model.Product"
}
},
+ "quotationId": {
+ "type": "integer"
+ },
"remark": {
"type": "string"
},
@@ -14313,9 +14385,6 @@
"properties": {
"city_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -14440,9 +14509,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14551,9 +14617,6 @@
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14648,9 +14711,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14715,9 +14775,6 @@
"clientId": {
"description": "瀹㈡埛id",
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -14791,7 +14848,7 @@
"description": "鏈嶅姟鏂瑰紡id",
"type": "integer"
},
- "severity": {
+ "severityId": {
"description": "涓ラ噸绋嬪害id",
"type": "integer"
},
@@ -14873,9 +14930,6 @@
"properties": {
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -15253,9 +15307,6 @@
},
"client_status_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"type": "string"
@@ -15834,15 +15885,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"
@@ -15870,6 +15922,9 @@
"items": {
"$ref": "#/definitions/model.Product"
}
+ },
+ "quotationId": {
+ "type": "integer"
},
"remark": {
"type": "string"
@@ -15901,9 +15956,6 @@
},
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -15953,9 +16005,6 @@
"properties": {
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -16155,9 +16204,6 @@
"client_type_id": {
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -16448,9 +16494,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -16473,6 +16516,10 @@
},
"quotation_id": {
"type": "integer"
+ },
+ "sendTime": {
+ "description": "鍙戣揣鏃堕棿",
+ "type": "string"
},
"status_id": {
"type": "integer"
@@ -16711,6 +16758,9 @@
"description": "瀹㈡埛id",
"type": "integer"
},
+ "codeStandID": {
+ "type": "string"
+ },
"courierCompanyId": {
"description": "鐗╂祦鍏徃",
"type": "integer"
@@ -16737,6 +16787,10 @@
"invoiceTypeId": {
"description": "鍙戠エ绫诲瀷id",
"type": "integer"
+ },
+ "number": {
+ "description": "鍙戠エ缂栧彿",
+ "type": "string"
},
"principalId": {
"description": "閿�鍞礋璐d汉id",
@@ -16852,9 +16906,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -17036,9 +17087,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -17401,9 +17449,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -17458,6 +17503,12 @@
},
"process": {
"type": "string"
+ },
+ "products": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Product"
+ }
},
"projected_amount": {
"type": "number"
@@ -17571,9 +17622,6 @@
"properties": {
"city_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -17828,9 +17876,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -17960,9 +18005,6 @@
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -18058,9 +18100,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -18128,9 +18167,6 @@
"clientId": {
"description": "瀹㈡埛id",
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -18207,7 +18243,7 @@
"description": "鏈嶅姟鏂瑰紡id",
"type": "integer"
},
- "severity": {
+ "severityId": {
"description": "涓ラ噸绋嬪害id",
"type": "integer"
},
@@ -18325,9 +18361,6 @@
"properties": {
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
diff --git a/docs/swagger.json b/docs/swagger.json
index c326f5f..64bc3af 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": [
@@ -11108,6 +11138,9 @@
"quotationId": {
"type": "integer"
},
+ "sendTime": {
+ "type": "string"
+ },
"serviceContractStatus": {
"$ref": "#/definitions/model.ServiceContractStatus"
},
@@ -11309,6 +11342,9 @@
"description": "瀹㈡埛id",
"type": "integer"
},
+ "codeStandID": {
+ "type": "string"
+ },
"courierCompany": {
"$ref": "#/definitions/model.CourierCompany"
},
@@ -11344,6 +11380,9 @@
"invoiceTypeId": {
"description": "鍙戠エ绫诲瀷id",
"type": "integer"
+ },
+ "number": {
+ "type": "string"
},
"principalId": {
"description": "閿�鍞礋璐d汉id",
@@ -11985,6 +12024,12 @@
"process": {
"type": "string"
},
+ "products": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Product"
+ }
+ },
"projected_amount": {
"type": "number"
},
@@ -12030,8 +12075,16 @@
"solutions": {
"type": "string"
},
+ "status": {
+ "description": "鐘舵��",
+ "allOf": [
+ {
+ "$ref": "#/definitions/model.Status"
+ }
+ ]
+ },
"status_id": {
- "$ref": "#/definitions/model.Status"
+ "type": "integer"
},
"threats": {
"type": "string"
@@ -12116,6 +12169,9 @@
"creatorName": {
"type": "string"
},
+ "deliverType": {
+ "type": "integer"
+ },
"deliveryDate": {
"type": "string"
},
@@ -12145,6 +12201,12 @@
"items": {
"$ref": "#/definitions/model.Product"
}
+ },
+ "quotation": {
+ "$ref": "#/definitions/model.Quotation"
+ },
+ "quotationId": {
+ "type": "integer"
},
"remark": {
"type": "string"
@@ -12263,9 +12325,6 @@
}
]
},
- "Source": {
- "$ref": "#/definitions/model.SalesReturn"
- },
"amountTotal": {
"description": "浠风◣鍚堣",
"type": "number"
@@ -12329,6 +12388,9 @@
"refundTypeId": {
"description": "閫�娆炬柟寮廔D",
"type": "integer"
+ },
+ "salesReturn": {
+ "$ref": "#/definitions/model.SalesReturn"
},
"sourceId": {
"description": "婧愬崟id",
@@ -12948,6 +13010,10 @@
"severity": {
"$ref": "#/definitions/model.Severity"
},
+ "severityId": {
+ "description": "涓ラ噸绋嬪害id",
+ "type": "integer"
+ },
"solution": {
"description": "瑙e喅鏂规硶",
"type": "string"
@@ -13278,9 +13344,6 @@
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -13485,9 +13548,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -13507,6 +13567,10 @@
},
"quotation_id": {
"type": "integer"
+ },
+ "sendTime": {
+ "description": "鍙戣揣鏃堕棿",
+ "type": "string"
},
"status_id": {
"type": "integer"
@@ -13648,6 +13712,9 @@
"description": "瀹㈡埛id",
"type": "integer"
},
+ "codeStandID": {
+ "type": "string"
+ },
"courierCompanyId": {
"description": "鐗╂祦鍏徃",
"type": "integer"
@@ -13671,6 +13738,10 @@
"invoiceTypeId": {
"description": "鍙戠エ绫诲瀷id",
"type": "integer"
+ },
+ "number": {
+ "description": "鍙戠エ缂栧彿",
+ "type": "string"
},
"principalId": {
"description": "閿�鍞礋璐d汉id",
@@ -13754,9 +13825,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -13877,9 +13945,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -14115,9 +14180,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14169,6 +14231,12 @@
},
"process": {
"type": "string"
+ },
+ "products": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Product"
+ }
},
"projected_amount": {
"type": "number"
@@ -14242,15 +14310,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"
@@ -14279,6 +14348,9 @@
"$ref": "#/definitions/model.Product"
}
},
+ "quotationId": {
+ "type": "integer"
+ },
"remark": {
"type": "string"
},
@@ -14301,9 +14373,6 @@
"properties": {
"city_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -14428,9 +14497,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14539,9 +14605,6 @@
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14636,9 +14699,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -14703,9 +14763,6 @@
"clientId": {
"description": "瀹㈡埛id",
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -14779,7 +14836,7 @@
"description": "鏈嶅姟鏂瑰紡id",
"type": "integer"
},
- "severity": {
+ "severityId": {
"description": "涓ラ噸绋嬪害id",
"type": "integer"
},
@@ -14861,9 +14918,6 @@
"properties": {
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -15241,9 +15295,6 @@
},
"client_status_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"type": "string"
@@ -15822,15 +15873,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"
@@ -15858,6 +15910,9 @@
"items": {
"$ref": "#/definitions/model.Product"
}
+ },
+ "quotationId": {
+ "type": "integer"
},
"remark": {
"type": "string"
@@ -15889,9 +15944,6 @@
},
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -15941,9 +15993,6 @@
"properties": {
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -16143,9 +16192,6 @@
"client_type_id": {
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -16436,9 +16482,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -16461,6 +16504,10 @@
},
"quotation_id": {
"type": "integer"
+ },
+ "sendTime": {
+ "description": "鍙戣揣鏃堕棿",
+ "type": "string"
},
"status_id": {
"type": "integer"
@@ -16699,6 +16746,9 @@
"description": "瀹㈡埛id",
"type": "integer"
},
+ "codeStandID": {
+ "type": "string"
+ },
"courierCompanyId": {
"description": "鐗╂祦鍏徃",
"type": "integer"
@@ -16725,6 +16775,10 @@
"invoiceTypeId": {
"description": "鍙戠エ绫诲瀷id",
"type": "integer"
+ },
+ "number": {
+ "description": "鍙戠エ缂栧彿",
+ "type": "string"
},
"principalId": {
"description": "閿�鍞礋璐d汉id",
@@ -16840,9 +16894,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -17024,9 +17075,6 @@
"properties": {
"client_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -17389,9 +17437,6 @@
"client_id": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -17446,6 +17491,12 @@
},
"process": {
"type": "string"
+ },
+ "products": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.Product"
+ }
},
"projected_amount": {
"type": "number"
@@ -17559,9 +17610,6 @@
"properties": {
"city_id": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -17816,9 +17864,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -17948,9 +17993,6 @@
"description": "瀹㈡埛绫诲瀷ID",
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -18046,9 +18088,6 @@
"clientId": {
"type": "integer"
},
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
- },
"codeStandID": {
"description": "缂栫爜id",
"type": "string"
@@ -18116,9 +18155,6 @@
"clientId": {
"description": "瀹㈡埛id",
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
@@ -18195,7 +18231,7 @@
"description": "鏈嶅姟鏂瑰紡id",
"type": "integer"
},
- "severity": {
+ "severityId": {
"description": "涓ラ噸绋嬪害id",
"type": "integer"
},
@@ -18313,9 +18349,6 @@
"properties": {
"clientId": {
"type": "integer"
- },
- "codeRule": {
- "$ref": "#/definitions/code.CodeStandard"
},
"codeStandID": {
"description": "缂栫爜id",
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index c473c3e..a27c9b3 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -762,6 +762,8 @@
$ref: '#/definitions/model.Quotation'
quotationId:
type: integer
+ sendTime:
+ type: string
serviceContractStatus:
$ref: '#/definitions/model.ServiceContractStatus'
statusId:
@@ -895,6 +897,8 @@
clientId:
description: 瀹㈡埛id
type: integer
+ codeStandID:
+ type: string
courierCompany:
$ref: '#/definitions/model.CourierCompany'
courierCompanyId:
@@ -921,6 +925,8 @@
invoiceTypeId:
description: 鍙戠エ绫诲瀷id
type: integer
+ number:
+ type: string
principalId:
description: 閿�鍞礋璐d汉id
type: integer
@@ -1339,6 +1345,10 @@
$ref: '#/definitions/model.Possibility'
process:
type: string
+ products:
+ items:
+ $ref: '#/definitions/model.Product'
+ type: array
projected_amount:
type: number
province:
@@ -1369,8 +1379,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:
@@ -1427,6 +1441,8 @@
type: integer
creatorName:
type: string
+ deliverType:
+ type: integer
deliveryDate:
type: string
id:
@@ -1447,6 +1463,10 @@
items:
$ref: '#/definitions/model.Product'
type: array
+ quotation:
+ $ref: '#/definitions/model.Quotation'
+ quotationId:
+ type: integer
remark:
type: string
saleChance:
@@ -1523,8 +1543,6 @@
allOf:
- $ref: '#/definitions/model.RefundType'
description: 閫�娆炬柟寮�
- Source:
- $ref: '#/definitions/model.SalesReturn'
amountTotal:
description: 浠风◣鍚堣
type: number
@@ -1569,6 +1587,8 @@
refundTypeId:
description: 閫�娆炬柟寮廔D
type: integer
+ salesReturn:
+ $ref: '#/definitions/model.SalesReturn'
sourceId:
description: 婧愬崟id
type: integer
@@ -1986,6 +2006,9 @@
type: integer
severity:
$ref: '#/definitions/model.Severity'
+ severityId:
+ description: 涓ラ噸绋嬪害id
+ type: integer
solution:
description: 瑙e喅鏂规硶
type: string
@@ -2208,8 +2231,6 @@
client_type_id:
description: 瀹㈡埛绫诲瀷ID
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -2356,8 +2377,6 @@
properties:
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -2372,6 +2391,9 @@
type: string
quotation_id:
type: integer
+ sendTime:
+ description: 鍙戣揣鏃堕棿
+ type: string
status_id:
type: integer
type: object
@@ -2462,6 +2484,8 @@
clientId:
description: 瀹㈡埛id
type: integer
+ codeStandID:
+ type: string
courierCompanyId:
description: 鐗╂祦鍏徃
type: integer
@@ -2480,6 +2504,9 @@
invoiceTypeId:
description: 鍙戠エ绫诲瀷id
type: integer
+ number:
+ description: 鍙戠エ缂栧彿
+ type: string
principalId:
description: 閿�鍞礋璐d汉id
type: integer
@@ -2534,8 +2561,6 @@
properties:
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -2614,8 +2639,6 @@
properties:
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -2769,8 +2792,6 @@
type: integer
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -2806,6 +2827,10 @@
type: integer
process:
type: string
+ products:
+ items:
+ $ref: '#/definitions/model.Product'
+ type: array
projected_amount:
type: number
province_id:
@@ -2853,13 +2878,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:
@@ -2878,6 +2904,8 @@
items:
$ref: '#/definitions/model.Product'
type: array
+ quotationId:
+ type: integer
remark:
type: string
saleChanceId:
@@ -2893,8 +2921,6 @@
properties:
city_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -2976,8 +3002,6 @@
properties:
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -3053,8 +3077,6 @@
client_type_id:
description: 瀹㈡埛绫诲瀷ID
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -3123,8 +3145,6 @@
properties:
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -3170,8 +3190,6 @@
clientId:
description: 瀹㈡埛id
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -3226,7 +3244,7 @@
serviceTypeId:
description: 鏈嶅姟鏂瑰紡id
type: integer
- severity:
+ severityId:
description: 涓ラ噸绋嬪害id
type: integer
solution:
@@ -3281,8 +3299,6 @@
properties:
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -3538,8 +3554,6 @@
type: integer
client_status_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
type: string
contact_id:
@@ -3958,13 +3972,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:
@@ -3983,6 +3998,8 @@
items:
$ref: '#/definitions/model.Product'
type: array
+ quotationId:
+ type: integer
remark:
type: string
saleChanceId:
@@ -4001,8 +4018,6 @@
type: integer
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -4038,8 +4053,6 @@
properties:
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -4175,8 +4188,6 @@
client_type_id:
description: 瀹㈡埛绫诲瀷ID
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -4379,8 +4390,6 @@
properties:
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -4397,6 +4406,9 @@
type: string
quotation_id:
type: integer
+ sendTime:
+ description: 鍙戣揣鏃堕棿
+ type: string
status_id:
type: integer
type: object
@@ -4550,6 +4562,8 @@
clientId:
description: 瀹㈡埛id
type: integer
+ codeStandID:
+ type: string
courierCompanyId:
description: 鐗╂祦鍏徃
type: integer
@@ -4570,6 +4584,9 @@
invoiceTypeId:
description: 鍙戠エ绫诲瀷id
type: integer
+ number:
+ description: 鍙戠エ缂栧彿
+ type: string
principalId:
description: 閿�鍞礋璐d汉id
type: integer
@@ -4649,8 +4666,6 @@
properties:
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -4770,8 +4785,6 @@
properties:
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -5008,8 +5021,6 @@
type: integer
client_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -5047,6 +5058,10 @@
type: integer
process:
type: string
+ products:
+ items:
+ $ref: '#/definitions/model.Product'
+ type: array
projected_amount:
type: number
province_id:
@@ -5123,8 +5138,6 @@
properties:
city_id:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -5293,8 +5306,6 @@
properties:
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -5384,8 +5395,6 @@
client_type_id:
description: 瀹㈡埛绫诲瀷ID
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -5454,8 +5463,6 @@
properties:
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -5503,8 +5510,6 @@
clientId:
description: 瀹㈡埛id
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -5561,7 +5566,7 @@
serviceTypeId:
description: 鏈嶅姟鏂瑰紡id
type: integer
- severity:
+ severityId:
description: 涓ラ噸绋嬪害id
type: integer
solution:
@@ -5640,8 +5645,6 @@
properties:
clientId:
type: integer
- codeRule:
- $ref: '#/definitions/code.CodeStandard'
codeStandID:
description: 缂栫爜id
type: string
@@ -7013,6 +7016,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/SalesReturnProduct.go b/model/SalesReturnProduct.go
index 35bb297..07374d0 100644
--- a/model/SalesReturnProduct.go
+++ b/model/SalesReturnProduct.go
@@ -9,22 +9,23 @@
type (
// SalesReturnProduct 鏈嶅姟鍚堝悓鍜屼骇鍝佸叧鑱�
SalesReturnProduct struct {
- SalesReturnId int `json:"id" gorm:"column:service_contract_id;type:int;primary_key;not null;default:0"`
+ SalesReturnId int `json:"id" gorm:"column:sales_return_id;type:int;primary_key;not null;default:0"`
ProductId uint `json:"name" gorm:"primary_key;column:product_id;type:int;not null;default:0;comment:浜у搧id"`
}
// SalesReturnProductSearch 閿�鍞槑缁嗗拰浜у搧鍏宠仈鎼滅储鏉′欢
SalesReturnProductSearch struct {
SalesReturnProduct
- Orm *gorm.DB
- Keyword string
- PageNum int
- PageSize int
+ Orm *gorm.DB
+ Keyword string
+ PageNum int
+ PageSize int
+ ProductIds []uint
}
)
func (SalesReturnProduct) TableName() string {
- return "service_contract_product"
+ return "sales_return_product"
}
func NewSalesReturnProductSearch() *SalesReturnProductSearch {
@@ -35,10 +36,18 @@
func (slf *SalesReturnProductSearch) build() *gorm.DB {
var db = slf.Orm.Model(&SalesReturnProduct{})
+ if len(slf.ProductIds) > 0 {
+ db = db.Where("product_id in (?)", slf.ProductIds)
+ }
return db
}
+func (slf *SalesReturnProductSearch) SetProductIds(ids []uint) *SalesReturnProductSearch {
+ slf.ProductIds = ids
+ return slf
+}
+
func (slf *SalesReturnProductSearch) Create(record *SalesReturnProduct) error {
var db = slf.build()
return db.Create(record).Error
diff --git a/model/client.go b/model/client.go
index ca7509a..590c079 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"
)
@@ -69,6 +70,9 @@
}
if slf.Name != "" {
db.Where("name = ?", slf.Name)
+ }
+ if slf.Number != "" {
+ db.Where("number = ?", slf.Number)
}
if len(slf.SearchMap) > 0 {
@@ -196,6 +200,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..91e50e8 100644
--- a/model/contract.go
+++ b/model/contract.go
@@ -2,6 +2,7 @@
import (
"aps_crm/pkg/mysqlx"
+ "fmt"
"gorm.io/gorm"
)
@@ -21,6 +22,7 @@
File string `json:"file" gorm:"column:file;type:varchar(255);comment:鍚堝悓鏂囦欢"`
CreatedAt *CustomTime `json:"created_at" gorm:"column:created_at;type:datetime;comment:鍒涘缓鏃堕棿"`
CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
+ SendTime string `json:"sendTime" gorm:"column:send_time;type:varchar(255);comment:鍙戣揣鏃堕棿"`
gormModel
}
@@ -50,6 +52,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 +128,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 +175,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/invoice.go b/model/invoice.go
index 48ddcd2..0db64fa 100644
--- a/model/invoice.go
+++ b/model/invoice.go
@@ -12,6 +12,7 @@
// Invoice 閿�鍞彂绁�
Invoice struct {
Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍙戠エ缂栧彿"`
ClientId int `gorm:"client_id" json:"clientId"` // 瀹㈡埛id
Client Client `gorm:"foreignKey:ClientId"`
InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 鍙戠エ绫诲瀷id
@@ -29,6 +30,7 @@
CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 鐗╂祦鍏徃
CourierCompany CourierCompany `gorm:"foreignKey:CourierCompanyId"`
Products []*Product `json:"products" gorm:"many2many:invoice_product;"`
+ CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
}
// InvoiceSearch 閿�鍞彂绁ㄦ悳绱㈡潯浠�
@@ -76,6 +78,9 @@
if slf.SourceId > 0 {
db = db.Where("source_id = ?", slf.SourceId)
}
+ if slf.Number != "" {
+ db.Where("number = ?", slf.Number)
+ }
return db
}
@@ -107,6 +112,35 @@
return record, err
}
+func (slf *InvoiceSearch) Count() (int64, error) {
+ var db = slf.build()
+ var total int64
+ err := db.Count(&total).Error
+ return total, err
+}
+
+func (slf *InvoiceSearch) 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 *InvoiceSearch) SetNumber(number string) *InvoiceSearch {
+ slf.Number = number
+ return slf
+}
+
func (slf *InvoiceSearch) SetId(id int) *InvoiceSearch {
slf.Id = id
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..ef09ea2 100644
--- a/model/request/contract.go
+++ b/model/request/contract.go
@@ -1,21 +1,19 @@
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
+ SendTime string `json:"sendTime"` //鍙戣揣鏃堕棿
}
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/invoice.go b/model/request/invoice.go
index 4e7c7e6..fa08e2f 100644
--- a/model/request/invoice.go
+++ b/model/request/invoice.go
@@ -6,36 +6,40 @@
)
type AddInvoice struct {
- ClientId int `gorm:"client_id" json:"clientId"` // 瀹㈡埛id
- InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 鍙戠エ绫诲瀷id
- PrincipalId int `gorm:"principal_id" json:"principalId"` // 閿�鍞礋璐d汉id
- Subject string `gorm:"subject" json:"subject"` // 涓婚
- InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 鍙戠エ鐘舵�乮d
- SourceType constvar.InvoiceSourceType `gorm:"source_type" json:"sourceType"` // 婧愬崟绫诲瀷(1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓)
- SourceId int `gorm:"source_id" json:"sourceId"` // 婧愬崟id
- TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 绾崇◣璇嗗埆鍙�
- InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 鍙戠エ鍙风爜
- InvoiceDate string `gorm:"invoice_date" json:"invoiceDate"` // 寮�绁ㄦ棩鏈�
- CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 鐗╂祦鍗曞彿
- CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 鐗╂祦鍏徃
- Products []model.Product `json:"products"` //鍙戠エ瀵瑰簲浜у搧锛屼粠鐩稿簲婧愬崟閲岃幏鍙�
+ Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍙戠エ缂栧彿"` //鍙戠エ缂栧彿
+ ClientId int `gorm:"client_id" json:"clientId"` // 瀹㈡埛id
+ InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 鍙戠エ绫诲瀷id
+ PrincipalId int `gorm:"principal_id" json:"principalId"` // 閿�鍞礋璐d汉id
+ Subject string `gorm:"subject" json:"subject"` // 涓婚
+ InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 鍙戠エ鐘舵�乮d
+ SourceType constvar.InvoiceSourceType `gorm:"source_type" json:"sourceType"` // 婧愬崟绫诲瀷(1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓)
+ SourceId int `gorm:"source_id" json:"sourceId"` // 婧愬崟id
+ TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 绾崇◣璇嗗埆鍙�
+ InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 鍙戠エ鍙风爜
+ InvoiceDate string `gorm:"invoice_date" json:"invoiceDate"` // 寮�绁ㄦ棩鏈�
+ CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 鐗╂祦鍗曞彿
+ CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 鐗╂祦鍏徃
+ Products []model.Product `json:"products"` //鍙戠エ瀵瑰簲浜у搧锛屼粠鐩稿簲婧愬崟閲岃幏鍙�
+ CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
}
type UpdateInvoice struct {
Id int `json:"id" binding:"required"`
- ClientId int `gorm:"client_id" json:"clientId"` // 瀹㈡埛id
- InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 鍙戠エ绫诲瀷id
- PrincipalId int `gorm:"principal_id" json:"principalId"` // 閿�鍞礋璐d汉id
- Subject string `gorm:"subject" json:"subject"` // 涓婚
- InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 鍙戠エ鐘舵�乮d
- SourceType int `gorm:"source_type" json:"sourceType"` // 婧愬崟绫诲瀷(1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓)
- SourceId int `gorm:"source_id" json:"sourceId"` // 婧愬崟id
- TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 绾崇◣璇嗗埆鍙�
- InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 鍙戠エ鍙风爜
- InvoiceDate int `gorm:"invoice_date" json:"invoiceDate"` // 寮�绁ㄦ棩鏈�
- CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 鐗╂祦鍗曞彿
- CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 鐗╂祦鍏徃
- Products []model.Product `json:"products"` //鍙戠エ瀵瑰簲浜у搧锛屼粠鐩稿簲婧愬崟閲岃幏鍙�
+ Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍙戠エ缂栧彿"` //鍙戠エ缂栧彿
+ ClientId int `gorm:"client_id" json:"clientId"` // 瀹㈡埛id
+ InvoiceTypeId int `gorm:"invoice_type_id" json:"invoiceTypeId"` // 鍙戠エ绫诲瀷id
+ PrincipalId int `gorm:"principal_id" json:"principalId"` // 閿�鍞礋璐d汉id
+ Subject string `gorm:"subject" json:"subject"` // 涓婚
+ InvoiceStatusId int `gorm:"invoice_status_id" json:"invoiceStatusId"` // 鍙戠エ鐘舵�乮d
+ SourceType int `gorm:"source_type" json:"sourceType"` // 婧愬崟绫诲瀷(1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓)
+ SourceId int `gorm:"source_id" json:"sourceId"` // 婧愬崟id
+ TaxpayerIdNumber string `gorm:"taxpayer_id_number" json:"taxpayerIdNumber"` // 绾崇◣璇嗗埆鍙�
+ InvoiceNumber string `gorm:"invoice_number" json:"invoiceNumber"` // 鍙戠エ鍙风爜
+ InvoiceDate int `gorm:"invoice_date" json:"invoiceDate"` // 寮�绁ㄦ棩鏈�
+ CourierNumber string `gorm:"courier_number" json:"courierNumber"` // 鐗╂祦鍗曞彿
+ CourierCompanyId int `gorm:"courier_company_id" json:"courierCompanyId"` // 鐗╂祦鍏徃
+ Products []model.Product `json:"products"` //鍙戠エ瀵瑰簲浜у搧锛屼粠鐩稿簲婧愬崟閲岃幏鍙�
+ CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
}
type GetInvoiceList 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 20d4619..05c8aa6 100644
--- a/model/request/saleChance.go
+++ b/model/request/saleChance.go
@@ -1,43 +1,45 @@
package request
-import "aps_crm/proto/code"
+import (
+ "aps_crm/model"
+)
type AddSaleChance struct {
SaleChance
}
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"`
+ 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..71aa235 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,26 @@
}
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.澶氭鍙戣揣
+ QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"`
}
type UpdateSalesDetails struct {
@@ -43,5 +43,5 @@
Keyword string `json:"keyword"`
SaleChanceId int `json:"saleChanceId"` //閿�鍞満浼歩d
ClientId int `json:"clientId"` //瀹㈡埛id
- Number string `json:"number"` //閿�鍞瓙鍗曞彿
+ Number string `json:"number"` //閿�鍞槑缁嗗崟鍙�
}
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..4805c77 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:"severityId"` // 涓ラ噸绋嬪害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 9836705..5f0f37c 100644
--- a/model/saleChance.go
+++ b/model/saleChance.go
@@ -2,6 +2,7 @@
import (
"aps_crm/pkg/mysqlx"
+ "fmt"
"gorm.io/gorm"
)
@@ -48,6 +49,7 @@
CollectionProjections []CollectionProjection `json:"collection_projections" gorm:"foreignKey:SaleChanceId"`
SalesSources SalesSources `json:"sales_sources"`
CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"`
+ Products []*Product `json:"products" gorm:"many2many:SaleChanceProduct;"`
Address
gorm.Model `json:"-"`
}
@@ -134,7 +136,7 @@
func (slf *SaleChanceSearch) Update(record *SaleChance) (err error) {
var db = slf.build()
- err = db.Updates(record).Error
+ err = db.Preload("Products").Updates(record).Error
return
}
@@ -146,7 +148,7 @@
func (slf *SaleChanceSearch) Find() (record SaleChance, err error) {
var db = slf.build()
- err = db.First(&record).Error
+ err = db.Preload("Products").First(&record).Error
return
}
@@ -161,7 +163,7 @@
db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
}
- err := db.Preload("SaleType").Preload("RegularCustomers").Preload("SalesSources").
+ err := db.Preload("SaleType").Preload("RegularCustomers").Preload("SalesSources").Preload("Products").
Preload("Member").Preload("SaleStage").Preload("Possibility").
Preload("CollectionProjections").Preload("Client").
Preload("Province").Preload("City").Preload("Contact").Preload("Status").Order("id desc").Find(&records).Error
@@ -212,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/saleChanceProduct.go b/model/saleChanceProduct.go
new file mode 100644
index 0000000..0236b44
--- /dev/null
+++ b/model/saleChanceProduct.go
@@ -0,0 +1,114 @@
+package model
+
+import (
+ "aps_crm/pkg/mysqlx"
+ "fmt"
+ "gorm.io/gorm"
+)
+
+type (
+ // SaleChanceProduct 閿�鍞満浼氬拰浜у搧鍏宠仈
+ SaleChanceProduct struct {
+ SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;primary_key;not null;default:0"`
+ ProductId uint `json:"productId" gorm:"primary_key;column:product_id;type:int;not null;default:0;comment:浜у搧id"`
+ }
+
+ // SaleChanceProductSearch 閿�鍞満浼氬拰浜у搧鍏宠仈鎼滅储鏉′欢
+ SaleChanceProductSearch struct {
+ SaleChanceProduct
+ Orm *gorm.DB
+ Keyword string
+ PageNum int
+ PageSize int
+ }
+)
+
+func (SaleChanceProduct) TableName() string {
+ return "sale_chance_product"
+}
+
+func NewSaleChanceProductSearch() *SaleChanceProductSearch {
+ return &SaleChanceProductSearch{
+ Orm: mysqlx.GetDB(),
+ }
+}
+
+func (slf *SaleChanceProductSearch) build() *gorm.DB {
+ var db = slf.Orm.Model(&SaleChanceProduct{})
+
+ return db
+}
+
+func (slf *SaleChanceProductSearch) Create(record *SaleChanceProduct) error {
+ var db = slf.build()
+ return db.Create(record).Error
+}
+
+func (slf *SaleChanceProductSearch) CreateBatch(records []*SaleChanceProduct) error {
+ var db = slf.build()
+ return db.Create(records).Error
+}
+
+func (slf *SaleChanceProductSearch) Delete() error {
+ var db = slf.build()
+ return db.Delete(&SaleChanceProduct{}).Error
+}
+
+func (slf *SaleChanceProductSearch) Update(record *SaleChanceProduct) error {
+ var db = slf.build()
+ return db.Updates(record).Error
+}
+
+func (slf *SaleChanceProductSearch) FindAll() ([]*SaleChanceProduct, error) {
+ var db = slf.build()
+ var record = make([]*SaleChanceProduct, 0)
+ err := db.Find(&record).Error
+ return record, err
+}
+
+func (slf *SaleChanceProductSearch) SetPage(page, size int) *SaleChanceProductSearch {
+ slf.PageNum, slf.PageSize = page, size
+ return slf
+}
+
+func (slf *SaleChanceProductSearch) SetOrm(tx *gorm.DB) *SaleChanceProductSearch {
+ slf.Orm = tx
+ return slf
+}
+
+func (slf *SaleChanceProductSearch) First() (*SaleChanceProduct, error) {
+ var db = slf.build()
+ var record = new(SaleChanceProduct)
+ err := db.First(record).Error
+ return record, err
+}
+
+func (slf *SaleChanceProductSearch) Updates(values interface{}) error {
+ var db = slf.build()
+ return db.Updates(values).Error
+}
+
+func (slf *SaleChanceProductSearch) Save(record *SaleChanceProduct) error {
+ var db = slf.build()
+
+ if err := db.Save(record).Error; err != nil {
+ return fmt.Errorf("save err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
+func (slf *SaleChanceProductSearch) Find() ([]*SaleChanceProduct, int64, error) {
+ var db = slf.build()
+ var records = make([]*SaleChanceProduct, 0)
+ var total int64
+ if err := db.Count(&total).Error; err != nil {
+ return records, total, err
+ }
+ if slf.PageNum > 0 && slf.PageSize > 0 {
+ db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
+ }
+
+ err := db.Find(&records).Error
+ return records, total, err
+}
diff --git a/model/salesDetails.go b/model/salesDetails.go
index b82e761..10e89b5 100644
--- a/model/salesDetails.go
+++ b/model/salesDetails.go
@@ -14,7 +14,7 @@
Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
Client Client `json:"client" gorm:"foreignKey:ClientId"`
- Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞瓙鍗曞彿"`
+ Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞槑缁嗗崟鍙�"`
SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
SaleChance SaleChance `json:"saleChance" gorm:"foreignKey:SaleChanceId"`
SaleType int `json:"saleType" gorm:"column:sale_type;type:int;comment:閿�鍞被鍨�"`
@@ -40,6 +40,9 @@
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.澶氭鍙戣揣)"`
+ QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"`
+ Quotation Quotation `json:"quotation" gorm:"foreignKey:QuotationId"`
CrmModel
}
@@ -106,7 +109,8 @@
Preload("Member").
Preload("SaleChance").
Preload("WechatOrderStatus").
- Preload("Client")
+ Preload("Client").
+ Preload("Quotation")
}
return db
@@ -133,6 +137,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/salesDetailsProduct.go b/model/salesDetailsProduct.go
index a803e83..abaed56 100644
--- a/model/salesDetailsProduct.go
+++ b/model/salesDetailsProduct.go
@@ -23,6 +23,7 @@
Keyword string
PageNum int
PageSize int
+ ProductIds []uint
}
)
@@ -38,10 +39,18 @@
func (slf *SalesDetailsProductSearch) build() *gorm.DB {
var db = slf.Orm.Model(&SalesDetailsProduct{})
+ if len(slf.ProductIds) > 0 {
+ db = db.Where("product_id in (?)", slf.ProductIds)
+ }
return db
}
+func (slf *SalesDetailsProductSearch) SetProductIds(ids []uint) *SalesDetailsProductSearch {
+ slf.ProductIds = ids
+ return slf
+}
+
func (slf *SalesDetailsProductSearch) Create(record *SalesDetailsProduct) error {
var db = slf.build()
return db.Create(record).Error
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..e593902 100644
--- a/model/salesRefund.go
+++ b/model/salesRefund.go
@@ -16,8 +16,8 @@
Client Client `json:"client" gorm:"foreignKey:ClientId"`
Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閫�娆惧崟鍙�"`
SourceType constvar.RefundSourceType `gorm:"column:source_type;type:int;not null;default 0;comment:鏉ユ簮绫诲瀷锛�1閿�鍞��璐э級" json:"sourceType"` // 鏉ユ簮绫诲瀷锛�1閿�鍞��璐э級
- SourceId int `gorm:"column:source_id;type:int;not null;default 0;comment:婧愬崟id " json:"sourceId"` // 婧愬崟id
- Source SalesReturn `gorm:"foreignKey:SourceId" json:"Source"`
+ SalesReturnId int `gorm:"column:source_id;type:int;not null;default 0;comment:婧愬崟id " json:"sourceId"` // 婧愬崟id
+ SalesReturn SalesReturn `gorm:"foreignKey:SalesReturnId" json:"salesReturn"`
MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
Member User `json:"member" gorm:"foreignKey:MemberId"`
RefundDate string `json:"refundDate" gorm:"column:refund_date;type:varchar(255);comment:閫�娆炬棩鏈�"`
@@ -78,16 +78,16 @@
db = db.Where("source_type = ?", slf.SourceType)
}
- if slf.SourceId != 0 {
- db = db.Where("source_id = ?", slf.SourceId)
+ if slf.SalesReturnId != 0 {
+ db = db.Where("source_id = ?", slf.SalesReturnId)
}
if slf.Preload {
db = db.Preload("Client").
Preload("PaymentType").
Preload("BankAccount").
- Preload("Source").
- Preload("Products")
+ Preload("Products").
+ Preload("SalesReturn")
}
if slf.KeywordType != "" {
switch slf.KeywordType {
@@ -115,6 +115,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
@@ -185,7 +212,7 @@
}
func (slf *SalesRefundSearch) SetSourceId(id int) *SalesRefundSearch {
- slf.SourceId = id
+ slf.SalesReturnId = 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..c3d350b 100644
--- a/model/serviceOrder.go
+++ b/model/serviceOrder.go
@@ -38,7 +38,7 @@
SaleChance SaleChance `gorm:"foreignKey:SaleChanceId"`
FaultTypeId int `gorm:"column:severity_id;type:int;not null;default:0;comment:鏁呴殰绫诲埆id" json:"faultTypeId"` // 鏁呴殰绫诲埆id
FaultType FaultType `gorm:"foreignKey:FaultTypeId"`
- SeverityId int `gorm:"column:severity_id;type:int;not null;default:0;comment:涓ラ噸绋嬪害id" json:"severity"` // 涓ラ噸绋嬪害id
+ SeverityId int `gorm:"column:severity_order_id;type:int;not null;default:0;comment:涓ラ噸绋嬪害id" json:"severityId"` // 涓ラ噸绋嬪害id
Severity Severity `gorm:"foreignKey:SeverityId"`
ServiceOrderStatusId int `gorm:"column:service_order_status_id;type:int;not null;default:0;comment:鏈嶅姟鍗曠姸鎬乮d" json:"serviceOrderStatusId"` // 澶勭悊鐘舵��
ServiceOrderStatus ServiceOrderStatus `gorm:"foreignKey:ServiceOrderStatusId"`
@@ -134,6 +134,9 @@
if len(slf.ServiceManIds) > 0 {
db = db.Where("service_man_id in ?", slf.ServiceManIds)
}
+ if slf.ServiceNumber != "" {
+ db = db.Where("service_number = ?", slf.ServiceNumber)
+ }
return db
}
@@ -216,6 +219,11 @@
return slf
}
+func (slf *ServiceOrderSearch) SetNumber(number string) *ServiceOrderSearch {
+ slf.ServiceNumber = 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/severity.go b/model/severity.go
index bccf576..51284df 100644
--- a/model/severity.go
+++ b/model/severity.go
@@ -29,7 +29,7 @@
)
func (Severity) TableName() string {
- return "severity"
+ return "severity_order"
}
func NewSeveritySearch() *SeveritySearch {
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
}
diff --git a/service/invoice.go b/service/invoice.go
index edb207e..9aaf90f 100644
--- a/service/invoice.go
+++ b/service/invoice.go
@@ -43,7 +43,7 @@
if err != nil {
return ecode.DBErr
}
- } else if invoice.SourceType == constvar.InvoiceSourceTypeServiceContract { //鏇存柊閿�鍞槑缁嗗凡寮�绁ㄩ噾棰�
+ } else if invoice.SourceType == constvar.InvoiceSourceTypeSaleDetail { //鏇存柊閿�鍞槑缁嗗凡寮�绁ㄩ噾棰�
salesDetails, err := model.NewSalesDetailsSearch().SetId(invoice.SourceId).SetPreload(true).First()
if err != nil {
return ecode.DBErr
diff --git a/service/saleChance.go b/service/saleChance.go
index 1610c07..a8f419b 100644
--- a/service/saleChance.go
+++ b/service/saleChance.go
@@ -3,6 +3,7 @@
import (
"aps_crm/model"
"aps_crm/pkg/ecode"
+ "gorm.io/gorm"
)
type SaleChanceService struct{}
@@ -17,7 +18,49 @@
func (SaleChanceService) UpdateSaleChance(saleChange *model.SaleChance) int {
// update saleChange
- err := model.NewSaleChanceSearch().SetId(saleChange.Id).Update(saleChange)
+ old, err := model.NewSaleChanceSearch().SetId(saleChange.Id).Find()
+ if err != nil {
+ return ecode.SaleChanceNotExist
+ }
+ newProducts, removedProducts := NewProductsService().PickDiffProducts(saleChange.Products, old.Products)
+ err = model.WithTransaction(func(db *gorm.DB) error {
+ err = model.NewSaleChanceSearch().SetId(saleChange.Id).Update(saleChange)
+ if err != nil {
+ return err
+ }
+ if len(removedProducts) > 0 {
+ removedProductIds := make([]uint, 0, len(removedProducts))
+ for _, product := range removedProducts {
+ removedProductIds = append(removedProductIds, product.Id)
+ }
+ err = model.NewProductSearch(db).SetIds(removedProductIds).Delete()
+ if err != nil {
+ return err
+ }
+ }
+ if len(newProducts) > 0 {
+ for _, p := range newProducts {
+ p.Id = 0
+ }
+ err = model.NewProductSearch(db).CreateBatch(newProducts)
+ if err != nil {
+ return err
+ }
+ var rel []*model.SaleChanceProduct
+ for _, p := range newProducts {
+ rel = append(rel, &model.SaleChanceProduct{
+ SaleChanceId: saleChange.Id,
+ ProductId: p.Id,
+ })
+ }
+ err = model.NewSaleChanceProductSearch().CreateBatch(rel)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+ })
+
if err != nil {
return ecode.SaleChanceUpdateErr
}
diff --git a/service/salesDetails.go b/service/salesDetails.go
index 62653f1..dec2d36 100644
--- a/service/salesDetails.go
+++ b/service/salesDetails.go
@@ -22,6 +22,9 @@
salesDetails.AmountTotal = salesDetails.AmountTotal.Round(2)
salesDetails.AmountReceivable = salesDetails.AmountTotal
salesDetails.AmountUnInvoiced = salesDetails.AmountTotal
+ for _, product := range salesDetails.Products {
+ product.Id = 0
+ }
err := model.NewSalesDetailsSearch().Create(salesDetails)
if err != nil {
return ecode.SalesDetailsExist
diff --git a/service/salesRefund.go b/service/salesRefund.go
index c9897a1..52a4a88 100644
--- a/service/salesRefund.go
+++ b/service/salesRefund.go
@@ -12,7 +12,7 @@
type SalesRefundService struct{}
func (SalesRefundService) AddSalesRefund(salesRefund *model.SalesRefund) int {
- salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SourceId).SetPreload(true).First()
+ salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).SetPreload(true).First()
if err != nil {
return ecode.SalesReturnNotExist
}
@@ -37,7 +37,7 @@
return errors.New("閫�璐т骇鍝佸搴旀�讳环瓒呭嚭搴旈��鎬讳环")
}
salesReturnRecord.AmountShouldRefund = salesReturnRecord.AmountTotal.Sub(salesReturnRecord.AmountHasRefund).Round(2)
- err = model.NewSalesReturnSearch().SetId(salesRefund.SourceId).Update(salesReturnRecord)
+ err = model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).Update(salesReturnRecord)
if err != nil {
code = ecode.DBErr
return err
@@ -73,7 +73,7 @@
if err != nil {
return ecode.SalesRefundNotExist
}
- salesReturnRecord, err := model.NewSalesReturnSearch().SetId(refund.SourceId).SetPreload(true).First()
+ salesReturnRecord, err := model.NewSalesReturnSearch().SetId(refund.SalesReturnId).SetPreload(true).First()
if err != nil {
return ecode.SalesReturnNotExist
}
@@ -90,7 +90,7 @@
}
salesReturnRecord.AmountHasRefund = salesReturnRecord.AmountHasRefund.Sub(amount).Round(2)
salesReturnRecord.AmountShouldRefund = salesReturnRecord.AmountTotal.Sub(salesReturnRecord.AmountHasRefund).Round(2)
- err = model.NewSalesReturnSearch().SetId(refund.SourceId).Update(salesReturnRecord)
+ err = model.NewSalesReturnSearch().SetId(refund.SalesReturnId).Update(salesReturnRecord)
if err != nil {
return err
}
@@ -120,7 +120,7 @@
return ecode.SalesRefundNotExist
}
- salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SourceId).SetPreload(true).First()
+ salesReturnRecord, err := model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).SetPreload(true).First()
if err != nil {
return ecode.SalesReturnNotExist
}
@@ -153,7 +153,7 @@
return errors.New("閫�璐т骇鍝佸搴旀�讳环瓒呭嚭搴旈��鎬讳环")
}
- err = model.NewSalesReturnSearch().SetId(salesRefund.SourceId).Update(salesReturnRecord)
+ err = model.NewSalesReturnSearch().SetId(salesRefund.SalesReturnId).Update(salesReturnRecord)
if err != nil {
code = ecode.DBErr
return err
@@ -168,7 +168,7 @@
return ecode.OK
}
-func (SalesRefundService) GetSalesRefundList(page, pageSize int, keywordType constvar.SalesRefundKeywordType, keyword string, sourceId int, memberIds []int) ([]*model.SalesRefund, int64, int) {
+func (SalesRefundService) GetSalesRefundList(page, pageSize int, keywordType constvar.SalesRefundKeywordType, keyword string, sourceId int, memberIds []int) ([]*model.SalesRefund, int64, int) {
// get contact list
contacts, total, err := model.NewSalesRefundSearch().
SetKeywordType(keywordType).
diff --git a/service/salesReturn.go b/service/salesReturn.go
index b1177ea..ab8fef5 100644
--- a/service/salesReturn.go
+++ b/service/salesReturn.go
@@ -17,6 +17,7 @@
salesReturn.AmountTotal = decimal.Zero
for _, product := range salesReturn.Products {
salesReturn.AmountTotal = salesReturn.AmountTotal.Add(product.Amount.Mul(product.Price))
+ product.Id = 0
}
salesReturn.AmountShouldRefund = salesReturn.AmountTotal
err := model.NewSalesReturnSearch().Create(salesReturn)
--
Gitblit v1.8.0