客户信息补录
This commit is contained in:
@@ -7,6 +7,7 @@ import com.rj.common.AudioManagementConstants;
|
||||
import com.rj.common.DataEnrichmentUtil;
|
||||
import com.rj.entity.AudioManagement;
|
||||
import com.rj.entity.AudioManagementSegments;
|
||||
import com.rj.entity.CustomerManagement;
|
||||
import com.rj.service.*;
|
||||
import com.rj.dto.AsrRequest;
|
||||
import com.rj.dto.AsrResponse;
|
||||
@@ -46,10 +47,17 @@ public class AudioManagementController {
|
||||
private static final String SCENARIO_FURNITURE_SALE = "FURNITURE_SALE";
|
||||
private static final String SCENARIO_MEETING_SUMMARY = "MEETING_SUMMARY";
|
||||
private static final String SCENARIO_CAR_SALE = "CAR_SALE";
|
||||
private static final String SCENARIO_SPEAKING_TRAINING= "SPEAKING_TRAINING"; //租赁模式
|
||||
|
||||
|
||||
@Autowired
|
||||
private IAudioManagementService audioManagementService;
|
||||
|
||||
@Autowired
|
||||
private ICustomerManagementService customerManagementService;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private IFileUploadService fileUploadService;
|
||||
|
||||
@@ -440,6 +448,83 @@ public class AudioManagementController {
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/updateForCustomerInfo")
|
||||
@Operation(summary = "更新录音信息", description = "更新录音详细信息")
|
||||
public ResponseEntity<Map<String, Object>> updateAudioForCustomer(
|
||||
@Parameter(description = "录音信息", required = true)
|
||||
@RequestBody AudioManagement audioManagement) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (audioManagement.getId() == null || audioManagement.getId().trim().isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "录音ID不能为空");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
AudioManagement audioManagementDB = new AudioManagement();
|
||||
audioManagementDB.setUpdateTime(LocalDateTime.now());
|
||||
audioManagementDB.setCustomerName(audioManagement.getCustomerName());
|
||||
audioManagementDB.setCustomerPhone(audioManagement.getCustomerPhone());
|
||||
|
||||
audioManagementDB.setId(audioManagement.getId());
|
||||
|
||||
boolean success = audioManagementService.updateById(audioManagementDB);
|
||||
|
||||
if (success) {
|
||||
// 同步更新客户信息
|
||||
try {
|
||||
CustomerManagement customerToUpdate = null;
|
||||
|
||||
// 优先通过 customerId 查找客户
|
||||
if (audioManagement.getCustomerId() != null && !audioManagement.getCustomerId().trim().isEmpty()) {
|
||||
customerToUpdate = customerManagementService.getById(audioManagement.getCustomerId());
|
||||
}
|
||||
|
||||
// 如果通过 customerId 没找到,且提供了 customerPhone,则通过联系方式查找
|
||||
if (customerToUpdate == null && audioManagement.getCustomerPhone() != null && !audioManagement.getCustomerPhone().trim().isEmpty()) {
|
||||
LambdaQueryWrapper<CustomerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CustomerManagement::getContact, audioManagement.getCustomerPhone().trim());
|
||||
List<CustomerManagement> customers = customerManagementService.list(queryWrapper);
|
||||
if (customers != null && !customers.isEmpty()) {
|
||||
customerToUpdate = customers.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果找到了客户,更新客户信息
|
||||
if (customerToUpdate != null) {
|
||||
customerToUpdate.setCustomerName(audioManagement.getCustomerName());
|
||||
customerToUpdate.setContact(audioManagement.getCustomerPhone());
|
||||
customerToUpdate.setRemark(audioManagement.getRemarks());
|
||||
|
||||
customerToUpdate.setUpdateTime(LocalDateTime.now());
|
||||
customerManagementService.updateById(customerToUpdate);
|
||||
log.info("同步更新客户信息成功,客户ID: {}", customerToUpdate.getId());
|
||||
} else {
|
||||
log.warn("未找到对应的客户信息,无法同步更新。customerId: {}, customerPhone: {}",
|
||||
audioManagement.getCustomerId(), audioManagement.getCustomerPhone());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 客户信息更新失败不影响音频信息更新的结果,只记录日志
|
||||
log.error("同步更新客户信息时发生异常: {}", e.getMessage(), e);
|
||||
}
|
||||
|
||||
result.put("success", true);
|
||||
result.put("message", "录音信息更新成功");
|
||||
result.put("data", audioManagement);
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "录音信息更新失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "更新异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private com.rj.service.IAudioManagementSegmentsService audioManagementSegmentsService;
|
||||
|
||||
|
||||
@@ -77,6 +77,20 @@ public class CustomerManagementController {
|
||||
if (customerManagement.getId() == null || customerManagement.getId().trim().isEmpty()) {
|
||||
throw new IllegalStateException("客户ID为空,无法同步录音记录");
|
||||
}
|
||||
// 检查销售人员是否正在服务其他客户
|
||||
String salesPhone = customerManagement.getSalesPhone();
|
||||
if (salesPhone != null && !salesPhone.trim().isEmpty()) {
|
||||
LambdaQueryWrapper<AudioManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AudioManagement::getSalesPhone, salesPhone.trim())
|
||||
.eq(AudioManagement::getServiceStatus, AudioManagementConstants.SERVICE_STATUS_IN_SERVICE);
|
||||
long count = audioManagementService.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
result.put("success", true);
|
||||
result.put("message", isUpdate ? "客户信息更新成功" : "客户添加成功");
|
||||
result.put("message", "该销售人员正在服务其他客户,无法创建新的服务记录");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
AudioManagement audioRecord = buildAudioRecordFromCustomer(customerManagement, now);
|
||||
boolean audioSaved = audioManagementService.save(audioRecord);
|
||||
if (!audioSaved) {
|
||||
|
||||
@@ -136,8 +136,8 @@ public class DeviceManagementController {
|
||||
@RequestParam(required = false) String dealershipId,
|
||||
@Parameter(description = "绑定状态")
|
||||
@RequestParam(required = false) Boolean bindStatus,
|
||||
@Parameter(description = "充电状态")
|
||||
@RequestParam(required = false) String chargingStatus) {
|
||||
@Parameter(description = "电话")
|
||||
@RequestParam(required = false) String salesPhone) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
Page<DeviceManagement> page = new Page<>(current, size);
|
||||
@@ -153,8 +153,8 @@ public class DeviceManagementController {
|
||||
if (bindStatus != null) {
|
||||
queryWrapper.eq(DeviceManagement::getBindStatus, bindStatus);
|
||||
}
|
||||
if (chargingStatus != null && !chargingStatus.trim().isEmpty()) {
|
||||
queryWrapper.eq(DeviceManagement::getChargingStatus, chargingStatus);
|
||||
if (salesPhone != null && !salesPhone.trim().isEmpty()) {
|
||||
queryWrapper.eq(DeviceManagement::getSalesPhone, salesPhone);
|
||||
}
|
||||
|
||||
// 按getUpdateTime 时间倒序排列
|
||||
|
||||
Reference in New Issue
Block a user