|
|
@@ -79,6 +79,7 @@ import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
|
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.gson.Gson;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -249,6 +250,12 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
//构建用户信息采集信息
|
|
|
FsUserInformationCollection fsUserInformationCollection = buildUserInfoCollection(param);
|
|
|
try {
|
|
|
+ if (validateRequiredRemarks(param.getAnswers(),param.getQuestionId())){
|
|
|
+ //用户采集信息问题完善状态 0-未完善 1-完善
|
|
|
+ fsUserInformationCollection.setCompleteStatus(1);
|
|
|
+ }else {
|
|
|
+ fsUserInformationCollection.setCompleteStatus(0);
|
|
|
+ }
|
|
|
baseMapper.insertFsUserInformationCollection(fsUserInformationCollection);
|
|
|
//构建采集进度信息
|
|
|
FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = buildUserInfoSchedule(fsUserInformationCollection);
|
|
|
@@ -324,12 +331,14 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
fsUserInformationCollection.setQuestionId(param.getQuestionId());
|
|
|
fsUserInformationCollection.setAmount(param.getAmount());
|
|
|
fsUserInformationCollection.setAge(param.getAge());
|
|
|
+ if (validateRequiredRemarks(param.getAnswers(),collection.getQuestionId())){
|
|
|
+ //用户采集信息问题完善状态 0-未完善 1-完善
|
|
|
+ fsUserInformationCollection.setCompleteStatus(1);
|
|
|
+ }else {
|
|
|
+ fsUserInformationCollection.setCompleteStatus(0);
|
|
|
+ }
|
|
|
//更新用户信息采集信息
|
|
|
int addResult = baseMapper.updateFsUserInformationCollection(fsUserInformationCollection);
|
|
|
- if (addResult>0){
|
|
|
- // 待后端校验逻辑完善了再执行
|
|
|
- // submitSalesInfoList(param,fsUserInformationCollection);
|
|
|
- }
|
|
|
return fsUserInformationCollection.getId();
|
|
|
}
|
|
|
|
|
|
@@ -351,6 +360,12 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
//构建用户信息采集对象
|
|
|
FsUserInformationCollection fsUserInformationCollection = buildUserInfoCollection(param);
|
|
|
try {
|
|
|
+ if (validateRequiredRemarks(param.getAnswers(),param.getQuestionId())){
|
|
|
+ //用户采集信息问题完善状态 0-未完善 1-完善
|
|
|
+ fsUserInformationCollection.setCompleteStatus(1);
|
|
|
+ }else {
|
|
|
+ fsUserInformationCollection.setCompleteStatus(0);
|
|
|
+ }
|
|
|
baseMapper.insertFsUserInformationCollection(fsUserInformationCollection);
|
|
|
//构建采集进度对象
|
|
|
FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = buildUserInfoSchedule(fsUserInformationCollection);
|
|
|
@@ -1422,11 +1437,12 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<FsUserInformationCollection> pendingSalesInfoList(PendingSalesInfoQueryDTO queryDto) {
|
|
|
+ public List<FsUserInformationCollectionOverviewVo> pendingSalesInfoList(PendingSalesInfoQueryDTO pendingSalesInfoQueryDTO) {
|
|
|
+ FsUserInformationCollectionOverviewDTO queryDto=new FsUserInformationCollectionOverviewDTO();
|
|
|
+ BeanUtils.copyProperties(pendingSalesInfoQueryDTO,queryDto);
|
|
|
queryDto.setCompleteStatus(0);//未完善信息标识
|
|
|
- FsUserInformationCollection fsUserInformationCollection=new FsUserInformationCollection();
|
|
|
- BeanUtils.copyProperties(queryDto,fsUserInformationCollection);
|
|
|
- List<FsUserInformationCollection> resultList=fsUserInformationCollectionMapper.selectFsUserInformationCollectionList(fsUserInformationCollection);
|
|
|
+ PageHelper.startPage(queryDto.getPageNum(), queryDto.getPageSize());
|
|
|
+ List<FsUserInformationCollectionOverviewVo> resultList=fsUserInformationCollectionMapper.selectUserInformationCollectionOverviewByPage(queryDto);
|
|
|
if (CollectionUtils.isEmpty(resultList)){
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
@@ -1434,25 +1450,91 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void submitSalesInfo(FsUserInformationCollectionParam param,FsUserInformationCollection sourceInfo) {
|
|
|
- if (sourceInfo==null){
|
|
|
- //如果传入的采集信息为空,则从数据库中查询
|
|
|
+ public void submitSalesInfo(FsUserInformationCollectionParam param, FsUserInformationCollection sourceInfo) {
|
|
|
+ if (sourceInfo == null) {
|
|
|
sourceInfo = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(param.getId());
|
|
|
}
|
|
|
- if (sourceInfo== null){
|
|
|
+ if (sourceInfo == null) {
|
|
|
log.error("完善采集信息-用户采集信息源不存在");
|
|
|
throw new CustomException("用户采集信息不存在");
|
|
|
}
|
|
|
- //提交销售完善的问题列表
|
|
|
List<AnswerVO> answers = param.getAnswers();
|
|
|
- //TODO 后续增加后端校验
|
|
|
- //更新采集信息的问题列表
|
|
|
sourceInfo.setId(param.getId());
|
|
|
sourceInfo.setJsonInfo(JSON.toJSONString(answers));
|
|
|
- sourceInfo.setCompleteStatus(1);//已完善标识
|
|
|
+ // 后端校验备注是否完整,返回 false 则校验失败
|
|
|
+ if (validateRequiredRemarks(answers, sourceInfo.getQuestionId())) {
|
|
|
+ sourceInfo.setCompleteStatus(1);
|
|
|
+ }else {
|
|
|
+ log.error("信息采集id:{}存在必填备注未填写,请完善后再提交", param.getId());//为了不影响业务正常执行这里暂时就不抛异常了
|
|
|
+ sourceInfo.setCompleteStatus(0);
|
|
|
+ }
|
|
|
fsUserInformationCollectionMapper.updateFsUserInformationCollection(sourceInfo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验必填备注:对于 open=true 且被勾选的选项,必须填写备注文本
|
|
|
+ *
|
|
|
+ * @param answers 提交的答案列表
|
|
|
+ * @param questionId 问答模板ID
|
|
|
+ * @return true 校验通过,false 校验失败
|
|
|
+ */
|
|
|
+ private boolean validateRequiredRemarks(List<AnswerVO> answers, Long questionId) {
|
|
|
+ if (CollectionUtils.isEmpty(answers)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询模板数据,获取选项的 open 配置
|
|
|
+ FsQuestionAndAnswerVO template = questionAndAnswerService.selectFsQuestionAndAnswerById(questionId);
|
|
|
+ if (template == null || CollectionUtils.isEmpty(template.getAnswers())) {
|
|
|
+ log.warn("未找到问题模板,无法校验备注,questionId={}", questionId);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建模板中每个问题下选项的 open 映射:title -> (optionValue -> open)
|
|
|
+ Map<String, Map<Integer, Boolean>> openConfigMap = template.getAnswers().stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ AnswerVO::getTitle,
|
|
|
+ ans -> ans.getOptions().stream()
|
|
|
+ .collect(Collectors.toMap(AnswerVO.Options::getValue, AnswerVO.Options::isOpen))
|
|
|
+ ));
|
|
|
+
|
|
|
+ // 遍历提交的答案进行校验
|
|
|
+ for (AnswerVO answer : answers) {
|
|
|
+ String title = answer.getTitle();
|
|
|
+ Map<Integer, Boolean> optionOpenMap = openConfigMap.get(title);
|
|
|
+ if (optionOpenMap == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> selectedValues = answer.getValue();
|
|
|
+ if (CollectionUtils.isEmpty(selectedValues)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建已选值的备注映射:optionValue -> remarkText
|
|
|
+ Map<Integer, String> remarkMap = new HashMap<>();
|
|
|
+ if (answer.getRemarksList() != null) {
|
|
|
+ for (AnswerVO.Remarks remark : answer.getRemarksList()) {
|
|
|
+ if (StringUtils.isNotBlank(remark.getText())) {
|
|
|
+ remarkMap.put(remark.getValue(), remark.getText().trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查每个被选中的、open=true 的选项是否有备注
|
|
|
+ for (Integer val : selectedValues) {
|
|
|
+ if (Boolean.TRUE.equals(optionOpenMap.get(val))) {
|
|
|
+ String text = remarkMap.get(val);
|
|
|
+ if (StringUtils.isBlank(text)) {
|
|
|
+ log.warn("必填备注缺失:title={}, optionValue={}", title, val);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
private List<AnswerVO> getAnswerVOs(List<AnswerVO> target, List<AnswerVO> source) {
|
|
|
// 1. 先对 target 中的每个 AnswerVO,从 source 中按 title 找到对应的模板,补充 options 的 open 字段
|
|
|
if (target != null && source != null) {
|