From 8be40ffd79c4dcdb4dc00bef359ccf48a6b031f3 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 28 十月 2023 15:56:26 +0800
Subject: [PATCH] 若干接口支持查看下属数据

---
 api/v1/client.go |   37 ++++++++++++++++++++++---------------
 1 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/api/v1/client.go b/api/v1/client.go
index 40375c9..d7dc42e 100644
--- a/api/v1/client.go
+++ b/api/v1/client.go
@@ -28,31 +28,33 @@
 		return
 	}
 
+	if params.MemberId == 0 {
+		userInfo := utils.GetUserInfo(c)
+		if userInfo.UserType == constvar.UserTypeSub {
+			params.MemberId = userInfo.CrmUserId
+		}
+	}
+
 	errCode, client := checkClientParams(params.Client)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
 		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, &params.CodeRule)
-		m := map[string]interface{}{
-			"number": autoCode,
-		}
-		_ = model.NewClientSearch(nil).SetId(client.Id).UpdateByMap(m)
 	}
 
 	ctx.Ok()
@@ -114,7 +116,12 @@
 	client.Business.IndustryId = params.IndustryId
 	client.Business.EnterpriseNatureId = params.EnterpriseNatureId
 	client.Business.EnterpriseScaleId = params.EnterpriseScaleId
-	client.MemberId = params.MemberId
+	//閿�鍞礋璐d汉涓虹┖鏃朵负鍏捣瀹㈡埛
+	if params.MemberId == 0 {
+		client.MemberId = 1
+	} else {
+		client.MemberId = params.MemberId
+	}
 	client.CodeStandID = params.CodeStandID
 
 	//if params.Contact.Name != "" {

--
Gitblit v1.8.0