Browse Source

恢复性别和手机号字段

boweniac 5 days ago
parent
commit
ff50655149
1 changed files with 66 additions and 62 deletions
  1. 66 62
      crontask/contact_form.go

+ 66 - 62
crontask/contact_form.go

@@ -41,19 +41,19 @@ type FormData struct {
 func (l *CronTask) analyze() {
 	usageDetails := make(map[string]map[string]string)
 	contactFieldTemplates := make(map[string][]custom_types.ContactFieldTemplate)
-	//template_type_text := "text"
-	//template_type_radio := "radio"
+	template_type_text := "text"
+	template_type_radio := "radio"
 	//template_type_date := "date"
-	//template_sex_id := "sex"
-	//template_sex_label := "性别"
-	//template_sex_options_man_label := "男"
-	//template_sex_options_man_value := "男"
-	//template_sex_options_woman_label := "女"
-	//template_sex_options_woman_value := "男"
-	//
-	//template_phone_id := "phone"
-	//template_phone_label := "手机号"
-	//
+	template_sex_id := "sex"
+	template_sex_label := "性别"
+	template_sex_options_man_label := "男"
+	template_sex_options_man_value := "男"
+	template_sex_options_woman_label := "女"
+	template_sex_options_woman_value := "男"
+
+	template_phone_id := "phone"
+	template_phone_label := "手机号"
+
 	//template_name_id := "name"
 	//template_name_label := "姓名"
 	//
@@ -74,54 +74,56 @@ func (l *CronTask) analyze() {
 	//
 	//template_title_id := "title"
 	//template_title_label := "称呼"
-	//contactBasicFieldTemplates := []custom_types.ContactFieldTemplate{
-	//	{
-	//		Label: &template_sex_label,
-	//		Id:    &template_sex_id,
-	//		Type:  &template_type_radio,
-	//		Options: []custom_types.ContactFieldTemplateOptions{
-	//			{
-	//				Label: &template_sex_options_man_label,
-	//				Value: &template_sex_options_man_value,
-	//			}, {
-	//				Label: &template_sex_options_woman_label,
-	//				Value: &template_sex_options_woman_value,
-	//			},
-	//		},
-	//	}, {
-	//		Label: &template_phone_label,
-	//		Id:    &template_phone_id,
-	//		Type:  &template_type_text,
-	//	}, {
-	//		Label: &template_name_label,
-	//		Id:    &template_name_id,
-	//		Type:  &template_type_text,
-	//	}, {
-	//		Label: &template_age_label,
-	//		Id:    &template_age_id,
-	//		Type:  &template_type_text,
-	//	}, {
-	//		Label: &template_area_label,
-	//		Id:    &template_area_id,
-	//		Type:  &template_type_text,
-	//	}, {
-	//		Label: &template_birthday_label,
-	//		Id:    &template_birthday_id,
-	//		Type:  &template_type_date,
-	//	}, {
-	//		Label: &template_birtharea_label,
-	//		Id:    &template_birtharea_id,
-	//		Type:  &template_type_text,
-	//	}, {
-	//		Label: &template_idcard_no_label,
-	//		Id:    &template_idcard_no_id,
-	//		Type:  &template_type_text,
-	//	}, {
-	//		Label: &template_title_label,
-	//		Id:    &template_title_id,
-	//		Type:  &template_type_text,
-	//	},
-	//}
+	contactBasicFieldTemplates := []custom_types.ContactFieldTemplate{
+		{
+			Label: &template_sex_label,
+			Id:    &template_sex_id,
+			Type:  &template_type_radio,
+			Options: []custom_types.ContactFieldTemplateOptions{
+				{
+					Label: &template_sex_options_man_label,
+					Value: &template_sex_options_man_value,
+				}, {
+					Label: &template_sex_options_woman_label,
+					Value: &template_sex_options_woman_value,
+				},
+			},
+		},
+		{
+			Label: &template_phone_label,
+			Id:    &template_phone_id,
+			Type:  &template_type_text,
+		},
+		//{
+		//	Label: &template_name_label,
+		//	Id:    &template_name_id,
+		//	Type:  &template_type_text,
+		//}, {
+		//	Label: &template_age_label,
+		//	Id:    &template_age_id,
+		//	Type:  &template_type_text,
+		//}, {
+		//	Label: &template_area_label,
+		//	Id:    &template_area_id,
+		//	Type:  &template_type_text,
+		//}, {
+		//	Label: &template_birthday_label,
+		//	Id:    &template_birthday_id,
+		//	Type:  &template_type_date,
+		//}, {
+		//	Label: &template_birtharea_label,
+		//	Id:    &template_birtharea_id,
+		//	Type:  &template_type_text,
+		//}, {
+		//	Label: &template_idcard_no_label,
+		//	Id:    &template_idcard_no_id,
+		//	Type:  &template_type_text,
+		//}, {
+		//	Label: &template_title_label,
+		//	Id:    &template_title_id,
+		//	Type:  &template_type_text,
+		//},
+	}
 
 	var predicates []predicate.UsageDetail
 	predicates = append(predicates, usagedetail.TypeIn(1, 3, 4, 6))
@@ -164,8 +166,10 @@ func (l *CronTask) analyze() {
 	logx.Info("contactFieldTemplates: ", contactFieldTemplates)
 	logx.Info("usageDetails: ", usageDetails)
 	for botID, template := range contactFieldTemplates {
-		if template == nil || len(template) == 0 {
-			continue
+		if template == nil {
+			template = contactBasicFieldTemplates
+		} else {
+			template = append(template, contactBasicFieldTemplates...)
 		}
 		for receiverID, messages := range usageDetails[botID] {
 			result, _ := l.openaiRequest(messages, template)