From 2030ec81f18f4ec9ea1800f13046acafff6d50f7 Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期四, 26 九月 2024 00:48:59 +0800
Subject: [PATCH] 添加grpc方法:客户信息维护

---
 api/v1/contract.go |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/api/v1/contract.go b/api/v1/contract.go
index 8041742..a0228fc 100644
--- a/api/v1/contract.go
+++ b/api/v1/contract.go
@@ -35,6 +35,16 @@
 		return
 	}
 
+	count, err := model.NewContractSearch().SetNumber(params.Number).Count()
+	if err != nil {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触")
+		return
+	}
+	if count > 0 {
+		ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�")
+		return
+	}
+
 	if contract.MemberId == 0 {
 		userInfo := utils.GetUserInfo(c)
 		if userInfo.UserType == constvar.UserTypeSub {
@@ -46,14 +56,6 @@
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return
-	}
-
-	if params.CodeRule.Method == 1 {
-		autoCode := model.GetAutoCode(contract.Id, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewContractSearch().SetId(contract.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
@@ -138,6 +140,7 @@
 		File:         contract.File,
 		CodeStandID:  contract.CodeStandID,
 		ContractName: contract.ContractName,
+		SendTime:     contract.SendTime,
 	}
 
 	return ecode.OK, contractModel
@@ -158,15 +161,15 @@
 		return
 	}
 
+	if params.SearchMap == nil {
+		params.SearchMap = make(map[string]interface{}, 0)
+	}
 	userInfo := utils.GetUserInfo(c)
 	if userInfo.UserType == constvar.UserTypeSub {
-		if params.SearchMap == nil {
-			params.SearchMap = make(map[string]interface{}, 0)
-		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
-	contracts, total, errCode := contractService.GetContractList(params.Page, params.PageSize, params.SearchMap)
+	contracts, total, errCode := contractService.GetContractList(params.Page, params.PageSize, params.SearchMap, params.Keyword)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		return

--
Gitblit v1.8.0