From 115bd9b51f5d8eade4658f844de37516486c60e7 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 18 十一月 2023 17:25:25 +0800 Subject: [PATCH] crm获取aps项目模块信息 --- api/v1/salesLeads.go | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 38 insertions(+), 11 deletions(-) diff --git a/api/v1/salesLeads.go b/api/v1/salesLeads.go index c1dc6e4..530a1bf 100644 --- a/api/v1/salesLeads.go +++ b/api/v1/salesLeads.go @@ -7,6 +7,7 @@ "aps_crm/model/response" "aps_crm/pkg/contextx" "aps_crm/pkg/ecode" + "aps_crm/utils" "github.com/gin-gonic/gin" ) @@ -27,9 +28,25 @@ return } + if params.MemberId == 0 { + userInfo := utils.GetUserInfo(c) + if userInfo.UserType == constvar.UserTypeSub { + params.MemberId = userInfo.CrmUserId + } + } + errCode, salesLeads := checkSalesLeadsParams(params.SalesLeads) if errCode != ecode.OK { 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 } @@ -37,13 +54,6 @@ 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() @@ -160,6 +170,14 @@ return } + userInfo := utils.GetUserInfo(c) + if userInfo.UserType == constvar.UserTypeSub { + if params.SearchMap == nil { + params.SearchMap = make(map[string]interface{}, 0) + } + params.SearchMap["member_ids"] = userInfo.SubUserIds + } + salesLeadss, total, errCode := salesLeadsService.GetSalesLeadsList(params.Page, params.PageSize, params.SearchMap) if errCode != ecode.OK { ctx.Fail(errCode) @@ -187,10 +205,19 @@ return } - errCode := salesLeadsService.PushSalesLeads(params.Id, params.Step, params.Reason) - if errCode != ecode.OK { - ctx.Fail(errCode) - return + if params.Step == constvar.SalesStatusFail { + errCode := salesLeadsService.DeleteSalesLeads([]int{params.Id}) + if errCode != ecode.OK { + ctx.Fail(errCode) + return + } + } else { + errCode := salesLeadsService.PushSalesLeads(params.Id, params.Step, params.Reason) + if errCode != ecode.OK { + ctx.Fail(errCode) + return + } } + ctx.Ok() } -- Gitblit v1.8.0