deploy: rebuild 202604191454

This commit is contained in:
MaDaLei 2026-04-19 14:54:38 +08:00
parent 979c2a99e0
commit 01e04064cb
3 changed files with 39 additions and 3 deletions

View File

@ -55,7 +55,11 @@ public class ReportLeadController {
data.put("unsubscribeToken", lead.getUnsubscribeToken()); data.put("unsubscribeToken", lead.getUnsubscribeToken());
data.put("wechatBound", outcome.wechatBound()); data.put("wechatBound", outcome.wechatBound());
data.put("repeatSubmit", outcome.repeatSubmit()); data.put("repeatSubmit", outcome.repeatSubmit());
return Map.of("code", 200, "data", data); data.put("alreadySubmitted", outcome.repeatSubmit());
String message = outcome.repeatSubmit()
? "该手机号已登记过本报告的提醒,信息已更新"
: "提交成功";
return Map.of("code", 200, "message", message, "data", data);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return Map.of("code", 400, "message", e.getMessage()); return Map.of("code", 400, "message", e.getMessage());
} }

View File

@ -8,12 +8,17 @@ import java.time.LocalDateTime;
/** /**
* 宠主在报告页留下的联系方式 + 下次服务提醒 * 宠主在报告页留下的联系方式 + 下次服务提醒
* 一约可多条宠主可以改手机号重新留资status 用于软退订与去重 * 同一报告下同一手机号仅一条数据库唯一约束换手机号可再留一条
* remind_status 等用于软退订与发送状态
*/ */
@Data @Data
@Entity @Entity
@Table( @Table(
name = "t_report_lead", name = "t_report_lead",
uniqueConstraints = @UniqueConstraint(
name = "uk_lead_report_phone",
columnNames = {"report_id", "phone"}
),
indexes = { indexes = {
@Index(name = "idx_lead_report_id", columnList = "report_id"), @Index(name = "idx_lead_report_id", columnList = "report_id"),
@Index(name = "idx_lead_store_status_remind", columnList = "store_id,remind_status,remind_date"), @Index(name = "idx_lead_store_status_remind", columnList = "store_id,remind_status,remind_date"),

View File

@ -10,6 +10,7 @@ import com.petstore.mapper.ServiceIntervalMapper;
import com.petstore.mapper.UserMapper; import com.petstore.mapper.UserMapper;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
@ -128,6 +129,7 @@ public class ReportLeadService {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
ReportLead lead = reportLeadMapper.findFirstByReportIdAndPhone(report.getId(), phone).orElse(null); ReportLead lead = reportLeadMapper.findFirstByReportIdAndPhone(report.getId(), phone).orElse(null);
boolean repeatSubmit = lead != null; boolean repeatSubmit = lead != null;
final boolean insertingNew = lead == null;
if (lead == null) { if (lead == null) {
lead = new ReportLead(); lead = new ReportLead();
lead.setReportId(report.getId()); lead.setReportId(report.getId());
@ -170,7 +172,32 @@ public class ReportLeadService {
lead.setWechatUnionid(uid); lead.setWechatUnionid(uid);
} }
try {
lead = reportLeadMapper.save(lead); lead = reportLeadMapper.save(lead);
} catch (DataIntegrityViolationException ex) {
if (!insertingNew) {
throw ex;
}
ReportLead existing = reportLeadMapper.findFirstByReportIdAndPhone(report.getId(), phone).orElse(null);
if (existing == null) {
throw ex;
}
lead = existing;
repeatSubmit = true;
lead.setReminderType(reminderType);
lead.setRemindDate(remindDate);
lead.setRemindStatus("pending");
lead.setConsentAt(now);
lead.setConsentIp(consentIp);
lead.setUpdateTime(now);
if (oid != null && !oid.isBlank()) {
lead.setWechatOpenid(oid);
}
if (uid != null && !uid.isBlank()) {
lead.setWechatUnionid(uid);
}
lead = reportLeadMapper.save(lead);
}
boolean wechatBound = false; boolean wechatBound = false;
if (oid != null && !oid.isBlank()) { if (oid != null && !oid.isBlank()) {