From e8d604b28abd319c63c8efe398f602eff66aa5ef Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 16 十月 2023 11:12:51 +0800
Subject: [PATCH] 添加一级页面的记录时。负责人如果为空,且为普通用户,取当前用户id

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

diff --git a/api/v1/client.go b/api/v1/client.go
index 6e45eb2..bac72a8 100644
--- a/api/v1/client.go
+++ b/api/v1/client.go
@@ -28,6 +28,13 @@
 		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)
@@ -46,6 +53,13 @@
 	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()
@@ -108,6 +122,7 @@
 	client.Business.EnterpriseNatureId = params.EnterpriseNatureId
 	client.Business.EnterpriseScaleId = params.EnterpriseScaleId
 	client.MemberId = params.MemberId
+	client.CodeStandID = params.CodeStandID
 
 	//if params.Contact.Name != "" {
 	// assign the client's member id to contact when adding

--
Gitblit v1.8.0