|
@@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDictItem;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
@@ -18,6 +19,7 @@ import com.qunzhixinxi.hnqz.admin.entity.input.SettleNoteStatusOutput;
|
|
|
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.ScorePackageStatusEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.SettleStatusEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectLocation;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectTypeEnum;
|
|
@@ -420,13 +422,15 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
|
updateEntity.setSettleAmount(total);
|
|
|
updateEntity.setId(input.getId());
|
|
|
updateEntity.setSettleStatus(DingEnum.SETTLE_STATUS_WAIT.getType());
|
|
|
- updateEntity.setScorePackageStatus("5");
|
|
|
+ updateEntity.setScorePackageStatus(ScorePackageStatusEnum.SETTLEMENT_SUBMITTED.val());
|
|
|
updateEntity.setDescription(input.getDescription());
|
|
|
updateEntity.setSubType(String.valueOf(input.getSubjectLocation().getGigType().getCode()));
|
|
|
updateEntity.setLocation(input.getSubjectLocation());
|
|
|
updateEntity.setSettlementDate(LocalDateTime.now());
|
|
|
if (SubjectLocation.MAH_SETTLE.equals(input.getSubjectLocation())) {
|
|
|
updateEntity.setMahSettleDeptId(input.getMahSettleDeptId());
|
|
|
+ // MAH结算提交给上级业务结算的标记
|
|
|
+ updateEntity.setMahSettleStep(UpmsType.MahSettleStep.BUSINESS);
|
|
|
}
|
|
|
|
|
|
if (PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(wmScorePackage.getPackageType2())
|
|
@@ -448,6 +452,88 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
|
return R.ok(Boolean.TRUE);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 业务提交结算信息到财务-MAH(药企的个人承接-其他-结算)
|
|
|
+ *
|
|
|
+ * @param input 输入信息
|
|
|
+ * @return 提交结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R<?> settleSubmitForMah(WmScorePackageSettleInput input) {
|
|
|
+
|
|
|
+ WmScorePackage wmScorePackage = wmScorePackageService.getById(input.getId());
|
|
|
+
|
|
|
+ // 校验基本包状态
|
|
|
+ wmScorePackageService.checkPkgToSettle(wmScorePackage);
|
|
|
+
|
|
|
+ List<WmScorePackageSettleNote> notes = input.getNotes();
|
|
|
+ SubjectLocation location = input.getSubjectLocation();
|
|
|
+
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+
|
|
|
+ // 校验是否配置了结算限制
|
|
|
+ SysDeptSub queryDeptSub = sysDeptSubService.getOne(Wrappers.<SysDeptSub>lambdaQuery()
|
|
|
+ .eq(SysDeptSub::getDeptId, deptId)
|
|
|
+ .eq(SysDeptSub::getSubjectLocation, location)
|
|
|
+ .eq(SysDeptSub::getEnableFlag, SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode()));
|
|
|
+ if (!queryDeptSub.getSettleEnable()) {
|
|
|
+ log.info("{}企业配置了结算限制", deptId);
|
|
|
+ throw new RuntimeException("系统维护中,请联系管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验人员信息
|
|
|
+ Set<Integer> userIds = notes.stream().map(WmScorePackageSettleNote::getUserId).map(Integer::valueOf).collect(Collectors.toSet());
|
|
|
+ userService.checkUserInfoToSettle(userIds, location);
|
|
|
+
|
|
|
+ // 校验结算
|
|
|
+ BigDecimal total = monitoringIndicatorService.settleMonitoringIndicator(notes, location);
|
|
|
+
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ notes.forEach(note -> {
|
|
|
+ note.setUpdateTime(now);
|
|
|
+ note.setSubTime(now);
|
|
|
+ note.setSubType(String.valueOf(location.getGigType().getCode()));
|
|
|
+ note.setSubjectLocation(location);
|
|
|
+ note.setInvoiceType(input.getInvoiceCategory());
|
|
|
+ note.setCategoryName(input.getCategoryName());
|
|
|
+ if (null == note.getId()) {
|
|
|
+ note.setCreateTime(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ WmScorePackage updateEntity = new WmScorePackage();
|
|
|
+ updateEntity.setInvoiceCategory(input.getInvoiceCategory());
|
|
|
+ updateEntity.setSettleAmount(total);
|
|
|
+ updateEntity.setId(input.getId());
|
|
|
+ updateEntity.setSettleStatus(DingEnum.SETTLE_STATUS_WAIT.getType());
|
|
|
+ updateEntity.setScorePackageStatus(ScorePackageStatusEnum.SETTLEMENT_SUBMITTED.val());
|
|
|
+ updateEntity.setDescription(input.getDescription());
|
|
|
+ updateEntity.setSubType(String.valueOf(input.getSubjectLocation().getGigType().getCode()));
|
|
|
+ updateEntity.setLocation(input.getSubjectLocation());
|
|
|
+ updateEntity.setSettlementDate(LocalDateTime.now());
|
|
|
+ updateEntity.setMahSettleDeptId(input.getMahSettleDeptId());
|
|
|
+ // MAH提交到财务结算的标记
|
|
|
+ updateEntity.setMahSettleStep(UpmsType.MahSettleStep.FINANCE);
|
|
|
+
|
|
|
+ if (PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(wmScorePackage.getPackageType2())
|
|
|
+ && !StrUtil.equals(PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val(), wmScorePackage.getPackageType1())) {
|
|
|
+ updateEntity.setPackageFinishStatus("1");
|
|
|
+ updateEntity.setTaskAddFlag("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.equals(PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val(), wmScorePackage.getPackageType1())) {
|
|
|
+ // 多人承接积分包可以一直结算
|
|
|
+ updateEntity.setSettleFlag("0");
|
|
|
+ } else {
|
|
|
+ updateEntity.setSettleFlag("1");
|
|
|
+ }
|
|
|
+
|
|
|
+ wmScorePackageService.updateById(updateEntity);
|
|
|
+ noteService.saveOrUpdateBatch(notes);
|
|
|
+
|
|
|
+ return R.ok(Boolean.TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 业务保存操作
|
|
|
*
|
|
@@ -510,6 +596,51 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
|
return R.ok(Boolean.TRUE);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 业务保存操作-MAH(药企的个人承接-其他-结算)
|
|
|
+ *
|
|
|
+ * @param input 提交信息
|
|
|
+ * @return 保存结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R<?> settleSaveForMah(WmScorePackageSettleInput input) {
|
|
|
+
|
|
|
+ List<WmScorePackageSettleNote> notes = input.getNotes();
|
|
|
+ SubjectLocation location = input.getSubjectLocation();
|
|
|
+
|
|
|
+ // 校验人员信息
|
|
|
+ Set<Integer> userIds = notes.stream().map(WmScorePackageSettleNote::getUserId).map(Integer::valueOf).collect(Collectors.toSet());
|
|
|
+ userService.checkUserInfoToSettle(userIds, location);
|
|
|
+
|
|
|
+ // 校验结算
|
|
|
+ BigDecimal total = monitoringIndicatorService.settleMonitoringIndicator(notes, location);
|
|
|
+
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ notes.forEach(note -> {
|
|
|
+ note.setUpdateTime(now);
|
|
|
+ note.setSubTime(now);
|
|
|
+ note.setSubType(String.valueOf(location.getGigType().getCode()));
|
|
|
+ note.setSubjectLocation(location);
|
|
|
+ note.setInvoiceType(input.getInvoiceCategory());
|
|
|
+ note.setCategoryName(input.getCategoryName());
|
|
|
+ if (null == note.getId()) {
|
|
|
+ note.setCreateTime(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ WmScorePackage updateEntity = new WmScorePackage();
|
|
|
+ updateEntity.setInvoiceCategory(input.getInvoiceCategory());
|
|
|
+ updateEntity.setSettleAmount(total);
|
|
|
+ updateEntity.setId(input.getId());
|
|
|
+ updateEntity.setDescription(input.getDescription());
|
|
|
+ updateEntity.setSubType(String.valueOf(location.getGigType().getCode()));
|
|
|
+ updateEntity.setLocation(input.getSubjectLocation());
|
|
|
+
|
|
|
+ wmScorePackageService.updateById(updateEntity);
|
|
|
+ noteService.saveOrUpdateBatch(notes);
|
|
|
+
|
|
|
+ return R.ok(Boolean.TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 重新结算
|
|
|
*
|