|
@@ -14,7 +14,9 @@ import com.qunzhixinxi.hnqz.admin.config.UpmsConfig;
|
|
import com.qunzhixinxi.hnqz.admin.entity.*;
|
|
import com.qunzhixinxi.hnqz.admin.entity.*;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.SettleNoteStatusOutput;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.SettleNoteStatusOutput;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleInput;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleInput;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.PackageStatusEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.PackageTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.PackageTypeEnum;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.SettleStatusEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectLocation;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectLocation;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
@@ -56,6 +58,7 @@ import java.math.RoundingMode;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
+import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -157,7 +160,7 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
note.setPackageStatusId(String.valueOf(status.getId()));
|
|
note.setPackageStatusId(String.valueOf(status.getId()));
|
|
note.setPackageId(status.getPackageId());
|
|
note.setPackageId(status.getPackageId());
|
|
|
|
|
|
- if ("1".equals(wmScorePackage.getPackageType1())) {
|
|
|
|
|
|
+ if (StrUtil.equals(PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val(), wmScorePackage.getPackageType1())) {
|
|
|
|
|
|
note.setSettleAmount(StringUtils.isEmpty(status.getUserScore()) ? BigDecimal.ZERO : new BigDecimal(status.getUserScore(), mc));
|
|
note.setSettleAmount(StringUtils.isEmpty(status.getUserScore()) ? BigDecimal.ZERO : new BigDecimal(status.getUserScore(), mc));
|
|
|
|
|
|
@@ -235,6 +238,116 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
return R.ok(resultMap);
|
|
return R.ok(resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 多人承接-按积分值业务结算-查询
|
|
|
|
+ *
|
|
|
|
+ * @param taskIds 任务id
|
|
|
|
+ * @return 结算信息
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public R<?> settleInfoByTaskIds(String[] taskIds) {
|
|
|
|
+ // 查询任务
|
|
|
|
+ List<WmTask> taskList = wmTaskService.listByIds(Arrays.asList(taskIds));
|
|
|
|
+ Set<String> taskIdSet = taskList.stream().map(WmTask::getScorePackageId).collect(Collectors.toSet());
|
|
|
|
+ if (taskIdSet.size() > 1) {
|
|
|
|
+ return R.failed("所选任务不属于同一个积分包");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String scorePackageId = taskList.get(0).getScorePackageId();
|
|
|
|
+ WmScorePackage wmScorePackage = wmScorePackageService.getById(scorePackageId);
|
|
|
|
+
|
|
|
|
+ // user-taskList map
|
|
|
|
+ Map<String, List<WmTask>> userTaskMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getTaskUserId));
|
|
|
|
+
|
|
|
|
+ // 查询settleNote
|
|
|
|
+ List<WmScorePackageSettleNote> notes = noteService.list(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ .in(WmScorePackageSettleNote::getTaskId, Arrays.asList(taskIds))
|
|
|
|
+ .eq(WmScorePackageSettleNote::getPackageId, scorePackageId));
|
|
|
|
+
|
|
|
|
+ // 查询user
|
|
|
|
+ Set<String> allUserIdSet = new HashSet<>();
|
|
|
|
+ allUserIdSet.addAll(userTaskMap.keySet());
|
|
|
|
+ allUserIdSet.addAll(notes.stream().map(WmScorePackageSettleNote::getUserId).collect(Collectors.toSet()));
|
|
|
|
+ List<SysUser> sysUsers = sysUserMapper.selectBatchIds(allUserIdSet);
|
|
|
|
+ Map<Integer, SysUser> userMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isEmpty(notes) || notes.size() < taskIds.length) {
|
|
|
|
+ // 查询领包记录
|
|
|
|
+ List<WmScorePackageStatus> statusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
+ .eq(WmScorePackageStatus::getPackageId, scorePackageId)
|
|
|
|
+ .in(WmScorePackageStatus::getUserId, userTaskMap.keySet())
|
|
|
|
+ .eq(WmScorePackageStatus::getStatus, PackageStatusEnum.APPROVED.val()));
|
|
|
|
+ Map<String, WmScorePackageStatus> userPackageStatusMap = statusList.stream()
|
|
|
|
+ .collect(Collectors.toMap(WmScorePackageStatus::getUserId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ for (String userId : userPackageStatusMap.keySet()) {
|
|
|
|
+ WmScorePackageSettleNote note = new WmScorePackageSettleNote();
|
|
|
|
+ note.setSettleNo(IdUtil.fastSimpleUUID());
|
|
|
|
+ note.setPackageId(scorePackageId);
|
|
|
|
+
|
|
|
|
+ // 计算每个人的总任务积分
|
|
|
|
+ List<WmTask> userTasks = userTaskMap.get(userId);
|
|
|
|
+ Integer userTotalScore = userTasks.stream().map(WmTask::getScore).reduce(0, Integer::sum);
|
|
|
|
+ note.setSettleAmount(BigDecimal.valueOf(userTotalScore));
|
|
|
|
+ note.setDiscount(BigDecimal.ONE);
|
|
|
|
+ note.setUserId(userId);
|
|
|
|
+ note.setSettleNoteStatus(Integer.valueOf(SettleStatusEnum.SETTLE_STATUS_NOTSETTLE.getVal()));
|
|
|
|
+
|
|
|
|
+ SysUser noteUser = userMap.get(Integer.parseInt(userId));
|
|
|
|
+ note.setRealName(noteUser.getRealname());
|
|
|
|
+ note.setIdCardNumber(noteUser.getIdCardNumber());
|
|
|
|
+ notes.add(note);
|
|
|
|
+ }
|
|
|
|
+ if (wmScorePackage.getLocation() != null) {
|
|
|
|
+ wmScorePackage.setSubjectLocation(wmScorePackage.getLocation().name());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ notes.forEach(item -> {
|
|
|
|
+ SysUser user = userMap.get(Integer.parseInt(item.getUserId()));
|
|
|
|
+ item.setRealName(user.getRealname());
|
|
|
|
+ item.setIdCardNumber(user.getIdCardNumber());
|
|
|
|
+ if (item.getSubjectLocation() != null){
|
|
|
|
+ wmScorePackage.setSubjectLocation(item.getSubjectLocation().name());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isBlank(wmScorePackage.getSubjectLocation())){
|
|
|
|
+ return R.failed("结算积分包未勾选税源地");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>(3);
|
|
|
|
+ resultMap.put("wsp", wmScorePackage);
|
|
|
|
+ resultMap.put("notes", notes);
|
|
|
|
+ // 显示实际完成积分值
|
|
|
|
+// resultMap.put("finishScore", "0");
|
|
|
|
+
|
|
|
|
+// if (PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(wmScorePackage.getPackageType1()) || PackageTypeEnum.TYPE1_HCP_PACKAGE.val().equals(wmScorePackage.getPackageType1())) {
|
|
|
|
+//
|
|
|
|
+// List<WmTask> tasks = wmTaskService.list(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
+// .eq(WmTask::getRealFlag, "0")
|
|
|
|
+// .eq(WmTask::getScorePackageId, wmScorePackage.getId())
|
|
|
|
+// .eq(WmTask::getTaskStatus, "3"));
|
|
|
|
+//
|
|
|
|
+// BigDecimal total = BigDecimal.ZERO;
|
|
|
|
+//
|
|
|
|
+// for (WmTask task : tasks) {
|
|
|
|
+// total = total.add(new BigDecimal(task.getScore()));
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (PackageTypeEnum.TYPE1_HCP_PACKAGE.val().equals(wmScorePackage.getPackageType1())) {
|
|
|
|
+// // 如果是患者教育,则转换积分值 '分'->'元'
|
|
|
|
+// resultMap.put("finishScore", total.divide(new BigDecimal("100"), mc));
|
|
|
|
+// } else {
|
|
|
|
+// resultMap.put("finishScore", total.intValue());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ return R.ok(resultMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 业务提交结算信息到财务
|
|
* 业务提交结算信息到财务
|
|
*
|
|
*
|