added todo for lead

This commit is contained in:
Pavel 2024-10-21 21:49:14 +03:00
parent b6d4ab132f
commit 9f99282f71

@ -164,6 +164,8 @@ func (wc *DealsWorker) startFetching(ctx context.Context) {
return return
} }
fmt.Println("DEALID", id)
err = wc.bitrixRepo.BitrixRepo.SaveDealBitrixStatus(ctx, bitrix.SaveDealBitrixDeps{ err = wc.bitrixRepo.BitrixRepo.SaveDealBitrixStatus(ctx, bitrix.SaveDealBitrixDeps{
DealID: id, DealID: id,
AnswerID: result.AnswerID, AnswerID: result.AnswerID,
@ -177,6 +179,7 @@ func (wc *DealsWorker) startFetching(ctx context.Context) {
} }
} }
// todo ОБДУМАТЬ ЛИДЫ ПОЧЕМУ ЛИД ПРЕВРАЩАЕТСЯ В СДЕЛКУ
func (wc *DealsWorker) constructField(ctx context.Context, request interface{}, allAnswers []model.ResultAnswer, result model.BitrixUsersTrueResults, performerIDInt int) (map[string]map[string]interface{}, error) { func (wc *DealsWorker) constructField(ctx context.Context, request interface{}, allAnswers []model.ResultAnswer, result model.BitrixUsersTrueResults, performerIDInt int) (map[string]map[string]interface{}, error) {
// id поля - ответ по типу поля // id поля - ответ по типу поля
entityFieldsMap := make(map[model.FieldsType]map[string]string) entityFieldsMap := make(map[model.FieldsType]map[string]string)
@ -192,6 +195,9 @@ func (wc *DealsWorker) constructField(ctx context.Context, request interface{},
entityRules[model.FieldTypeCompany] = result.FieldsRule.Company.QuestionID entityRules[model.FieldTypeCompany] = result.FieldsRule.Company.QuestionID
entityRules[model.FieldTypeContact] = result.FieldsRule.Contact.QuestionID entityRules[model.FieldTypeContact] = result.FieldsRule.Contact.QuestionID
fmt.Println("result.FieldsRule.Deal.QuestionID", result.FieldsRule.Deal.QuestionID)
fmt.Println("result.FieldsRule.Lead.QuestionID", result.FieldsRule.Lead.QuestionID)
for entityType, rule := range entityRules { for entityType, rule := range entityRules {
for _, data := range allAnswers { for _, data := range allAnswers {
if fieldID, ok := rule[int(data.QuestionID)]; ok { if fieldID, ok := rule[int(data.QuestionID)]; ok {
@ -365,10 +371,12 @@ func (wc *DealsWorker) constructField(ctx context.Context, request interface{},
var reqMap map[string]map[string]interface{} var reqMap map[string]map[string]interface{}
if result.LeadFlag { if result.LeadFlag {
fmt.Println("leadFields", leadFields)
leadReq.Fields.CompanyID = companyID leadReq.Fields.CompanyID = companyID
leadReq.Fields.ContactIDs = append(leadReq.Fields.ContactIDs, contactID) leadReq.Fields.ContactIDs = append(leadReq.Fields.ContactIDs, contactID)
reqMap = models.FormattingToMap(&leadReq, leadFields) reqMap = models.FormattingToMap(&leadReq, leadFields)
} else { } else {
fmt.Println("dealFields", dealFields)
dealReq.Fields.CompanyID = companyID dealReq.Fields.CompanyID = companyID
dealReq.Fields.ContactIDs = append(dealReq.Fields.ContactIDs, contactID) dealReq.Fields.ContactIDs = append(dealReq.Fields.ContactIDs, contactID)
reqMap = models.FormattingToMap(&dealReq, dealFields) reqMap = models.FormattingToMap(&dealReq, dealFields)