|
|
@ -375,7 +375,18 @@ public class CrmVisitService extends MybatisBaseService<CrmVisitMapper, CrmVisit |
|
|
|
|
|
|
|
public ResultBean saveCrmVisit(AppCrmVisitDto appCrmVisitDto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
|
|
|
|
String userSid = appCrmVisitDto.getUserSid(); |
|
|
|
String staffSid = sysUserFeign.fetchBySid(userSid).getData().getStaffSid(); |
|
|
|
String orgSid = sysUserFeign.getSysUserByMobile(staffSid).getData().getOrgSid(); |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String customerSid = appCrmVisitDto.getCustomerSid(); |
|
|
|
String remind_day = appCrmVisitDto.getRemind_day(); |
|
|
|
String remind_remark = appCrmVisitDto.getRemind_remark(); |
|
|
|
String isOnRemind = appCrmVisitDto.getIsOnRemind(); |
|
|
|
String follow_state = appCrmVisitDto.getFollow_state(); |
|
|
|
String isOnRemindkey = appCrmVisitDto.getIsOnRemindkey(); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(isOnRemindkey)) { // 0 未开启 1 开启
|
|
|
|
String remindDay = "未设置提醒"; |
|
|
|
if (isOnRemindkey.equals("0")) { |
|
|
@ -394,65 +405,49 @@ public class CrmVisitService extends MybatisBaseService<CrmVisitMapper, CrmVisit |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
String customerSid = appCrmVisitDto.getCustomerSid(); |
|
|
|
String remind_day = appCrmVisitDto.getRemind_day(); |
|
|
|
String remind_remark = appCrmVisitDto.getRemind_remark(); |
|
|
|
String isOnRemind = appCrmVisitDto.getIsOnRemind(); |
|
|
|
String follow_state = appCrmVisitDto.getFollow_state(); |
|
|
|
int i = crmCustomerService.updateRemindAndByCustomerSid(customerSid, remind_day, remind_remark, isOnRemind, isOnRemindkey,follow_state); |
|
|
|
List<String> materialsList = appCrmVisitDto.getMaterialsList(); |
|
|
|
String visit_witness_materials = ""; |
|
|
|
int i = crmCustomerService.updateRemindAndByCustomerSid(customerSid, remind_day, remind_remark, isOnRemind, isOnRemindkey, follow_state); |
|
|
|
if (i > 0) { |
|
|
|
CrmVisit entity = new CrmVisit(); |
|
|
|
List<String> materialsList = appCrmVisitDto.getMaterialsList(); |
|
|
|
appCrmVisitDto.fillEntity(entity); |
|
|
|
entity.setCustomerSid(appCrmVisitDto.getCustomerSid()); |
|
|
|
entity.setStaffSid(staffSid); |
|
|
|
entity.setOrgSid(orgSid); |
|
|
|
entity.setPositionInformation(appCrmVisitDto.getLocationStr()); |
|
|
|
entity.setFollow_time(format.format(new Date())); |
|
|
|
if (materialsList.size() > 0) { |
|
|
|
String visit_witness_materials = ""; |
|
|
|
for (int j = 0; j < materialsList.size(); j++) { |
|
|
|
String url = materialsList.get(j); |
|
|
|
visit_witness_materials += url.replace(fileUploadComponent.getUrlPrefix(), "") + ","; |
|
|
|
} |
|
|
|
appCrmVisitDto.setVisit_witness_materials(visit_witness_materials.substring(0, visit_witness_materials.length() - 1)); |
|
|
|
} else { |
|
|
|
appCrmVisitDto.setVisit_witness_materials(""); |
|
|
|
} |
|
|
|
appCrmVisitDto.fillEntity(entity); |
|
|
|
String userSid = appCrmVisitDto.getUserSid(); |
|
|
|
String staffSid = sysUserFeign.fetchBySid(userSid).getData().getStaffSid(); |
|
|
|
String orgSid = sysUserFeign.getSysUserByMobile(staffSid).getData().getOrgSid(); |
|
|
|
entity.setSid(UUID.randomUUID().toString()); |
|
|
|
entity.setCustomerSid(appCrmVisitDto.getCustomerSid()); |
|
|
|
entity.setStaffSid(staffSid); |
|
|
|
entity.setOrgSid(orgSid); |
|
|
|
String location = appCrmVisitDto.getLocation(); |
|
|
|
if (location == null) { |
|
|
|
entity.setLongitude(""); |
|
|
|
entity.setLatitude(""); |
|
|
|
} |
|
|
|
String[] split = location.split(","); |
|
|
|
for (int i1 = 0; i1 < split.length; i1++) { |
|
|
|
entity.setLongitude(split[0]); |
|
|
|
entity.setLatitude(split[1]); |
|
|
|
} |
|
|
|
entity.setPositionInformation(appCrmVisitDto.getLocationStr()); |
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String follow_time = formatter.format(new Date()); |
|
|
|
entity.setFollow_time(follow_time); |
|
|
|
List<String> list = appCrmVisitDto.getMaterialsList(); |
|
|
|
if (list.size() > 0) { |
|
|
|
for (String s : list) { |
|
|
|
AppCommonAppendixDto appCommonAppendixDto = new AppCommonAppendixDto(); |
|
|
|
appCommonAppendixDto.setFilePath(appCrmVisitDto.getMaterialsList()); |
|
|
|
appCommonAppendixDto.setAttachType(CommonAttachTypeEnum.WITNESS.getAttachType()); |
|
|
|
appCommonAppendixDto.setLinkSid(entity.getSid()); |
|
|
|
commonAppendixFeign.saveOrUpdateAppAppendix(appCommonAppendixDto); |
|
|
|
// 取出详细地址经纬度
|
|
|
|
if (StringUtils.isNotBlank(appCrmVisitDto.getLocation())) { |
|
|
|
String[] split = appCrmVisitDto.getLocation().split(","); |
|
|
|
for (int i1 = 0; i1 < split.length; i1++) { |
|
|
|
entity.setLongitude(split[0]); |
|
|
|
entity.setLatitude(split[1]); |
|
|
|
} |
|
|
|
} |
|
|
|
String visitSid = entity.getSid(); |
|
|
|
//保存跟进材料附件
|
|
|
|
if (materialsList.size() > 0) { |
|
|
|
AppCommonAppendixDto appCommonAppendixDto = new AppCommonAppendixDto(); |
|
|
|
appCommonAppendixDto.setFilePath(materialsList); |
|
|
|
appCommonAppendixDto.setAttachType(CommonAttachTypeEnum.WITNESS.getAttachType()); |
|
|
|
appCommonAppendixDto.setLinkSid(entity.getSid()); |
|
|
|
commonAppendixFeign.saveOrUpdateAppAppendix(appCommonAppendixDto); |
|
|
|
} |
|
|
|
//客户需求车辆和跟进记录关联
|
|
|
|
List<CrmVehicledemandVo> crmVehicledemandVos = crmVehicledemandService.fetchByCustomerSid(customerSid); |
|
|
|
if (crmVehicledemandVos.size() > 0) { |
|
|
|
for (CrmVehicledemandVo crmVehicledemandVo : crmVehicledemandVos) { |
|
|
|
String demandSid = crmVehicledemandVo.getSid(); |
|
|
|
crmVisitDemandService.saveByVisit(visitSid, demandSid); |
|
|
|
crmVisitDemandService.saveByVisit(entity.getSid(), demandSid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int insert = baseMapper.insert(entity); |
|
|
|
if (insert > 0) { |
|
|
|
return rb.success().setMsg("添加成功"); |
|
|
|