Merge branch 'feat-hjj-QuestionnaireSurvey' into dev

This commit is contained in:
jiaji.H 2026-03-13 13:20:15 +08:00
commit 9b056fe1d9

View File

@ -14,8 +14,27 @@ import (
"gorm.io/gorm"
)
// 电话号码映射表:原始号码 -> 目标号码
var phoneMapping = map[string]string{
"15863272183": "15624971336", //毕德瑞
"15039229900": "18803928946", //陈春芳
"13832480736": "17746107444", //程宝江
"19290778586": "13196080727", //董跃亭
"18710227028": "13954838868", //方民
"17801586080": "15233398990", //韩玉玲
}
// 使用示例:仅当号码在白名单中时才返回映射结果,否则返回原号码
func MapPhoneIfInList(phone string) string {
if phoneMapping[phone] != "" {
return phoneMapping[phone]
}
return phone
}
func SendQuestionnaireSurvey(req *bundle.SendQuestionnaireSurveyRequest) (resp *bundle.SendQuestionnaireSurveyResponse, err error) {
resp = new(bundle.SendQuestionnaireSurveyResponse)
phone := MapPhoneIfInList(req.UserTel)
userInfo := &model.UserInfo{}
err = app.ModuleClients.BundleDB.Raw(`
SELECT
@ -26,7 +45,7 @@ func SendQuestionnaireSurvey(req *bundle.SendQuestionnaireSurveyRequest) (resp *
from `+"`micro-account`.`user`"+` as mau
left join `+"`micro-account`.`real_name`"+` as marn on marn.id = mau.real_name_id and marn.deleted_at = 0
where mau.deleted_at = 0 and mau.tel_num = ?
`, req.UserTel).Scan(&userInfo).Error
`, phone).Scan(&userInfo).Error
if err != nil {
return resp, err
}
@ -45,7 +64,7 @@ func SendQuestionnaireSurvey(req *bundle.SendQuestionnaireSurveyRequest) (resp *
questionnaireInfo := &model.QuestionnaireSurvey{}
err = app.ModuleClients.BundleDB.Model(&model.QuestionnaireSurvey{}).
Where("user_tel = ? and deleted_at is null", req.UserTel).
Where("user_tel = ? and deleted_at is null", phone).
Order("created_at desc").
First(&questionnaireInfo).Error
if err != nil {
@ -133,8 +152,9 @@ func SendQuestionnaireSurvey(req *bundle.SendQuestionnaireSurveyRequest) (resp *
func GetQuestionnaireSurveyInfo(req *bundle.GetQuestionnaireSurveyInfoRequest) (data *model.QuestionnaireSurvey, err error) {
data = &model.QuestionnaireSurvey{}
phone := MapPhoneIfInList(req.UserTel)
err = app.ModuleClients.BundleDB.Model(&model.QuestionnaireSurvey{}).
Where("user_tel = ? and deleted_at is null", req.UserTel).
Where("user_tel = ? and deleted_at is null", phone).
Order("created_at desc").
First(&data).Error
if err != nil {
@ -147,6 +167,7 @@ func GetQuestionnaireSurveyInfo(req *bundle.GetQuestionnaireSurveyInfoRequest) (
}
func CreateQuestionnaireSurveyAnswer(req *bundle.CreateQuestionnaireSurveyAnswerRequest) (err error) {
phone := MapPhoneIfInList(req.UserTel)
surveyAnswer := &model.SurveyAnswer{
BundleAccountScore: req.SurveyAnswer.BundleAccountScore,
BundleVideoScore: req.SurveyAnswer.BundleVideoScore,
@ -162,7 +183,7 @@ func CreateQuestionnaireSurveyAnswer(req *bundle.CreateQuestionnaireSurveyAnswer
return err
}
err = app.ModuleClients.BundleDB.Model(&model.QuestionnaireSurvey{}).
Where("user_tel = ? and deleted_at is null", req.UserTel).
Where("user_tel = ? and deleted_at is null", phone).
Updates(map[string]interface{}{
"survey_answer": string(surveyAnswerJSON),
"merits_review": req.SurveyFeedback.MeritsReview,