update after testing
This commit is contained in:
parent
f4b739015e
commit
63c0845d7a
@ -3,6 +3,7 @@ package models
|
||||
import (
|
||||
"github.com/rs/xid"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FieldsResponse struct {
|
||||
@ -41,6 +42,11 @@ type AddFields struct {
|
||||
func (a *AddFields) GenFieldName() {
|
||||
guid := xid.New()
|
||||
guidGen := guid.String()
|
||||
a.FieldName = guidGen
|
||||
a.XMLID = guidGen
|
||||
// todo и так и так работает обдумать стоит
|
||||
// https://dev.1c-bitrix.ru/rest_help/crm/cdeals/crm_deal_userfield_add.php
|
||||
//a.FieldName = guidGen[:13]
|
||||
//a.XMLID = guidGen[:13]
|
||||
|
||||
a.FieldName = strings.ToUpper(guidGen)
|
||||
a.XMLID = strings.ToUpper(guidGen)
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"go.uber.org/zap"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/internal/models"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/internal/tools"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/pkg/bitrixClient"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
@ -15,6 +16,7 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/repository/bitrix"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -217,11 +219,11 @@ func (wc *DealsWorker) constructField(ctx context.Context, request interface{},
|
||||
}
|
||||
|
||||
if fieldData.FieldType == model.StringCustomFieldsType {
|
||||
//content := strings.ReplaceAll(data.Content, " ", "")
|
||||
//if content == "" {
|
||||
// data.Content = "Пустая строка"
|
||||
//}
|
||||
entityFieldsMap[entityType][fieldData.FieldName] = data.Content
|
||||
content := strings.ReplaceAll(data.Content, " ", "")
|
||||
if content == "" {
|
||||
data.Content = "Пустая строка"
|
||||
}
|
||||
entityFieldsMap[entityType][fieldData.FieldName] = tools.EmojiUnicode(data.Content)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -643,11 +643,11 @@ func (m *Methods) CheckFieldRule(ctx context.Context, token string, msg models.K
|
||||
m.logger.Error("error adding fields to amo", zap.Any("type", entity), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
// todo
|
||||
// todo need checking in prod
|
||||
newFields = append(newFields, model.BitrixField{
|
||||
BitrixID: fmt.Sprintf("%d", createdID),
|
||||
EntityID: entity,
|
||||
FieldName: "UF_CRM_" + strings.ToUpper(field.FieldName),
|
||||
FieldName: "UF_CRM_" + field.FieldName,
|
||||
EditFromLabel: field.EditFormLabel,
|
||||
FieldType: field.UserTypeID,
|
||||
})
|
||||
@ -663,11 +663,11 @@ func (m *Methods) CheckFieldRule(ctx context.Context, token string, msg models.K
|
||||
continue
|
||||
}
|
||||
|
||||
// todo
|
||||
// todo need checking in prod
|
||||
newFields = append(newFields, model.BitrixField{
|
||||
BitrixID: fmt.Sprintf("%d", createdID),
|
||||
EntityID: model.FieldTypeContact,
|
||||
FieldName: "UF_CRM_" + strings.ToUpper(contactField.FieldName),
|
||||
FieldName: "UF_CRM_" + contactField.FieldName,
|
||||
EditFromLabel: contactField.EditFormLabel,
|
||||
FieldType: contactField.UserTypeID,
|
||||
})
|
||||
|
@ -48,7 +48,7 @@ func TestGetListFields(t *testing.T) {
|
||||
//}
|
||||
//
|
||||
fieldAnswer := make(map[string]string)
|
||||
fieldAnswer["UF_CRM_CSC0TEL6PVUM0J68N5RG"] = "field1"
|
||||
fieldAnswer["UF_CRM_1729669958"] = "хуйхуйхуйхухй"
|
||||
|
||||
//
|
||||
//createContactReq := models.CreateContactReq{
|
||||
@ -98,8 +98,8 @@ func TestGetListFields(t *testing.T) {
|
||||
Title: "ТЕСТ ОТ ГОУ АПИ 10/10",
|
||||
TypeID: "SALE",
|
||||
StageID: "NEW",
|
||||
CompanyID: 369,
|
||||
ContactIDs: []int32{211},
|
||||
CompanyID: 383,
|
||||
ContactIDs: []int32{235},
|
||||
Opened: "Y",
|
||||
AssignedByID: 1,
|
||||
CategoryID: 1,
|
||||
@ -113,7 +113,8 @@ func TestGetListFields(t *testing.T) {
|
||||
}
|
||||
//
|
||||
reqMap := models.FormattingToMap(&createDealReq, fieldAnswer)
|
||||
result, err := b.CreatingDeal(reqMap, "59161867007232200072541200000001000007a3be721d08cbf9f847b807c4eb79a73f", "b24-s5jg6c.bitrix24.ru")
|
||||
fmt.Println(reqMap)
|
||||
result, err := b.CreatingDeal(reqMap, "8ec218670000071b0072541200000001000007d0047b935d30b9acc0cbd5d0202b8711", "b24-s5jg6c.bitrix24.ru")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user