|
@@ -6,6 +6,8 @@ import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
@@ -22,11 +24,14 @@ import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleInput;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleOutput;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.model.excel.SettlementProofModel;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.model.excel.WmScorePackageSettleExcelModel;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.vo.SettleFinancialReviewSettleDetailVO;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.vo.SettleFinancialReviewVO;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.DeptPermissionEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.PackageFinishStatusEnum;
|
|
|
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.mapper.WmScorePackageMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDictItemService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
@@ -46,6 +51,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
|
|
import org.springframework.security.access.AccessDeniedException;
|
|
@@ -82,6 +88,7 @@ public class WmPayOffController {
|
|
|
|
|
|
private final WmPayOffService wmPayOffService;
|
|
|
private final WmScorePackageService wmScorePackageService;
|
|
|
+ private final WmScorePackageMapper wmScorePackageMapper;
|
|
|
private final WmScorePackageSettleNoteService wmScorePackageSettleNoteService;
|
|
|
private final SysDeptService sysDeptService;
|
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
@@ -321,6 +328,91 @@ public class WmPayOffController {
|
|
|
return R.ok(outputPage);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询财务结算复核汇总数据
|
|
|
+ *
|
|
|
+ * @param realname 姓名
|
|
|
+ * @param subjectLocation 结算渠道
|
|
|
+ * @return {@link R}<{@link ?}> 结果
|
|
|
+ */
|
|
|
+ @GetMapping("/list-financial-review")
|
|
|
+ public R<List<SettleFinancialReviewVO>> listFinancialReview(String realname, SubjectLocation subjectLocation, Boolean reviewFlag) {
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+
|
|
|
+ SettleFinancialReviewVO query = new SettleFinancialReviewVO();
|
|
|
+ query.setRealname(realname);
|
|
|
+ query.setSubjectLocation(subjectLocation);
|
|
|
+ query.setDeptId(deptId);
|
|
|
+ query.setReviewFlag(reviewFlag);
|
|
|
+ List<SettleFinancialReviewVO> voList = wmScorePackageMapper.listFinancialReview(query);
|
|
|
+
|
|
|
+ return R.ok(voList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询财务结算复核汇总数据
|
|
|
+ *
|
|
|
+ * @param page 分页参数
|
|
|
+ * @param settleNoteIds 结算id
|
|
|
+ * @return {@link R}<{@link ?}> 结果
|
|
|
+ */
|
|
|
+ @GetMapping("/page-financial-review-detail")
|
|
|
+ public R<IPage<WmScorePackageSettleOutput>> pageFinancialReviewDetail(Page<WmScorePackageSettleOutput> page,
|
|
|
+ @Param("userId") String[] settleNoteIds) {
|
|
|
+ SettleFinancialReviewVO query = new SettleFinancialReviewVO();
|
|
|
+ query.setSettleNoteIds(settleNoteIds);
|
|
|
+ IPage<WmScorePackageSettleOutput> detailPage = wmScorePackageService.pageFinancialReviewDetail(page, query);
|
|
|
+
|
|
|
+ return R.ok(detailPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询财务复核-批量结算列表数据
|
|
|
+ *
|
|
|
+ * @param settleNoteIds 结算id
|
|
|
+ * @return {@link R}<{@link List}<{@link WmScorePackageSettleOutput}>> 结果
|
|
|
+ */
|
|
|
+ @GetMapping("/list-financial-review_settle_detail")
|
|
|
+ public R<List<SettleFinancialReviewSettleDetailVO>> listFinancialReviewSettleDetail(String[] settleNoteIds) {
|
|
|
+ List<WmScorePackageSettleNote> settleNotes = wmScorePackageSettleNoteService.listByIds(Arrays.asList(settleNoteIds));
|
|
|
+
|
|
|
+ List<SysUser> sysUsers = sysUserService.listByIds(settleNotes.stream().map(WmScorePackageSettleNote::getUserId).collect(Collectors.toSet()));
|
|
|
+ Map<Integer, SysUser> userMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity()));
|
|
|
+
|
|
|
+ Set<String> packageIds = settleNotes.stream().map(WmScorePackageSettleNote::getPackageId).collect(Collectors.toSet());
|
|
|
+ List<WmScorePackage> scorePackages = wmScorePackageMapper.selectBatchIds(packageIds);
|
|
|
+ Map<String, WmScorePackage> packageMap = scorePackages.stream().collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
+
|
|
|
+ List<SettleFinancialReviewSettleDetailVO> outputList = new ArrayList<>();
|
|
|
+ settleNotes.forEach(settleNote -> {
|
|
|
+ SettleFinancialReviewSettleDetailVO output = new SettleFinancialReviewSettleDetailVO();
|
|
|
+ output.setNoteId(String.valueOf(settleNote.getId()));
|
|
|
+ output.setPackageId(settleNote.getPackageId());
|
|
|
+ output.setUserId(settleNote.getUserId());
|
|
|
+ output.setDeptId(settleNote.getSettleDeptId());
|
|
|
+ output.setDiscount(settleNote.getDiscount());
|
|
|
+ output.setSettleAmount(settleNote.getSettleAmount());
|
|
|
+ output.setActualAmount(settleNote.getActualAmount());
|
|
|
+ SysUser sysUser = userMap.get(Integer.parseInt(settleNote.getUserId()));
|
|
|
+ output.setUsername(sysUser.getUsername());
|
|
|
+ output.setRealname(sysUser.getRealname());
|
|
|
+
|
|
|
+ WmScorePackage scorePackage = packageMap.get(settleNote.getPackageId());
|
|
|
+ output.setSettleStatus(scorePackage.getSettleStatus());
|
|
|
+ if (scorePackage.getSettleStatus() != null) {
|
|
|
+ output.setSettleStatusName(SettleStatusEnum.resolve(String.valueOf(scorePackage.getSettleStatus())).getName2());
|
|
|
+ }
|
|
|
+ output.setSubjectLocation(settleNote.getSubjectLocation());
|
|
|
+ if (settleNote.getSubjectLocation() != null) {
|
|
|
+ output.setSubjectLocationName(settleNote.getSubjectLocation().getDescription());
|
|
|
+ }
|
|
|
+ output.setReviewStatus(settleNote.getReviewStatus());
|
|
|
+ outputList.add(output);
|
|
|
+ });
|
|
|
+
|
|
|
+ return R.ok(outputList);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 结算包结算导出
|
|
|
*
|
|
@@ -617,13 +709,13 @@ public class WmPayOffController {
|
|
|
@SysLog("结算-自由选择渠道")
|
|
|
@PostMapping("/settleIssueBySubType")
|
|
|
public R<?> settleIssueBySubType(@RequestBody WmScorePackageSettleInput input) {
|
|
|
-
|
|
|
+ log.info("结算-自由选择渠道参数:{}", input);
|
|
|
|
|
|
if (StrUtil.isBlank(input.getId()) || StrUtil.isBlank(input.getScorePackageName()) || input.getSubjectLocation() == null || CollUtil.isEmpty(input.getNotes()) || null == input.getInvoiceCategory()) {
|
|
|
return R.failed("数据异常");
|
|
|
}
|
|
|
|
|
|
- return wmPayOffService.settleIssueBySubType(input);
|
|
|
+ return wmPayOffService.financialSettle(input);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -636,6 +728,7 @@ public class WmPayOffController {
|
|
|
@PostMapping("/batch-financial-settle")
|
|
|
@SuppressWarnings("all")
|
|
|
public R<?> batchFinancialSettle(@RequestBody List<WmScorePackageSettleInput> inputList) {
|
|
|
+ log.info("批量财务结算参数:{}", inputList);
|
|
|
|
|
|
if (CollectionUtil.isEmpty(inputList)) {
|
|
|
return R.failed("数据异常");
|
|
@@ -667,7 +760,7 @@ public class WmPayOffController {
|
|
|
|
|
|
input.setNotes(notes);
|
|
|
// 调用单个结算
|
|
|
- R<?> settleR = wmPayOffService.settleIssueBySubType(input);
|
|
|
+ R<?> settleR = wmPayOffService.financialSettle(input);
|
|
|
boolean failFlag;
|
|
|
if (settleR.getCode() == 0) {
|
|
|
// 结算成功,不进行页面提示
|
|
@@ -695,6 +788,123 @@ public class WmPayOffController {
|
|
|
return R.ok(msgList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 财务复核(通过则直接发起结算)
|
|
|
+ *
|
|
|
+ * @param input 参数
|
|
|
+ * @return {@link R}<{@link ?}> 结果
|
|
|
+ */
|
|
|
+ @SysLog("财务复核")
|
|
|
+ @PostMapping("/financial-review")
|
|
|
+ public R<?> financialReview(@RequestBody WmScorePackageSettleInput input) {
|
|
|
+ log.info("财务复核参数:{}", input);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(input.getId()) || null == input.getReviewStatus()) {
|
|
|
+ return R.failed("必填参数为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询结算详情(用于拼接notes数据)
|
|
|
+ R<?> queryR = wmPayOffService.settleById(input.getId());
|
|
|
+
|
|
|
+ if (queryR.getCode() != 0) {
|
|
|
+ return R.failed("数据异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> queryData = (Map<String, Object>) queryR.getData();
|
|
|
+ List<WmScorePackageSettleNote> notes = (List<WmScorePackageSettleNote>) queryData.get("notes");
|
|
|
+ WmScorePackage wsp = (WmScorePackage) queryData.get("wsp");
|
|
|
+
|
|
|
+ WmScorePackageSettleNote settleNote = notes.get(0);
|
|
|
+
|
|
|
+ input.setSubjectLocation(settleNote.getSubjectLocation());
|
|
|
+ input.setInvoiceCategory(settleNote.getInvoiceType());
|
|
|
+ input.setScorePackageName(wsp.getScorePackageName());
|
|
|
+ input.setNotes(notes);
|
|
|
+
|
|
|
+ // 防止结算时,复核状态被更新
|
|
|
+ notes.forEach(n -> {
|
|
|
+ n.setReviewStatus(null);
|
|
|
+ n.setReviewUser(null);
|
|
|
+ n.setReviewTime(null);
|
|
|
+ });
|
|
|
+
|
|
|
+ return wmPayOffService.financialReview(input);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量财务复核(通过则直接发起结算)
|
|
|
+ *
|
|
|
+ * @param inputList 参数
|
|
|
+ * @return {@link R}<{@link ?}> 结果
|
|
|
+ */
|
|
|
+ @SysLog("批量财务复核")
|
|
|
+ @PostMapping("/batch-financial-review")
|
|
|
+ public R<?> batchFinancialReview(@RequestBody List<WmScorePackageSettleInput> inputList) {
|
|
|
+ log.info("批量财务复核参数:{}", inputList);
|
|
|
+
|
|
|
+ if (CollectionUtil.isEmpty(inputList)) {
|
|
|
+ return R.failed("参数为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, String>> msgList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (WmScorePackageSettleInput input : inputList) {
|
|
|
+ if (StringUtils.isEmpty(input.getId()) || null == input.getReviewStatus()) {
|
|
|
+ return R.failed("必填参数为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ WmScorePackage scorePackage = wmScorePackageMapper.selectById(input.getId());
|
|
|
+ // 查询结算详情(用于拼接notes数据)
|
|
|
+ R<?> queryR = wmPayOffService.settleById(input.getId());
|
|
|
+
|
|
|
+ if (queryR.getCode() == 0) {
|
|
|
+ Map<String, Object> queryData = (Map<String, Object>) queryR.getData();
|
|
|
+ List<WmScorePackageSettleNote> notes = (List<WmScorePackageSettleNote>) queryData.get("notes");
|
|
|
+
|
|
|
+ WmScorePackageSettleNote settleNote = notes.get(0);
|
|
|
+
|
|
|
+ input.setSubjectLocation(settleNote.getSubjectLocation());
|
|
|
+ input.setInvoiceCategory(settleNote.getInvoiceType());
|
|
|
+ input.setScorePackageName(scorePackage.getScorePackageName());
|
|
|
+ input.setNotes(notes);
|
|
|
+
|
|
|
+ // 防止结算时,复核状态被更新
|
|
|
+ notes.forEach(n -> {
|
|
|
+ n.setReviewStatus(null);
|
|
|
+ n.setReviewUser(null);
|
|
|
+ n.setReviewTime(null);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 调用单个复核
|
|
|
+ R<?> settleR = wmPayOffService.financialReview(input);
|
|
|
+ boolean failFlag;
|
|
|
+ if (settleR.getCode() == 0) {
|
|
|
+ // 结算成功,不进行页面提示
|
|
|
+ Optional<WmScorePackageSettleNote> any = notes.stream().filter(note -> !DingEnum.NOTE_STATUS_SUBMIT.getType().equals(note.getSettleNoteStatus())).findAny();
|
|
|
+ failFlag = any.isPresent();
|
|
|
+ } else {
|
|
|
+ failFlag = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (failFlag) {
|
|
|
+ Map<String, String> msgMap = new HashMap<>(2);
|
|
|
+ msgMap.put("packageName", scorePackage.getScorePackageName());
|
|
|
+ msgMap.put("reason", settleR.getMsg());
|
|
|
+ msgList.add(msgMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Map<String, String> msgMap = new HashMap<>(2);
|
|
|
+ msgMap.put("packageName", scorePackage.getScorePackageName());
|
|
|
+ msgMap.put("reason", queryR.getMsg());
|
|
|
+ msgList.add(msgMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// return R.ok(msgList);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 手动回调
|
|
|
*
|
|
@@ -742,7 +952,7 @@ public class WmPayOffController {
|
|
|
boolean updateSettleResult = wmScorePackageSettleNoteService.updateSettleNoteById(packageId, settleNoteId, settleNoteStatus, remark, notifyTime);
|
|
|
|
|
|
// 结束输出
|
|
|
- log.info("===== 手工回调开始 =====");
|
|
|
+ log.info("===== 手工回调结束 =====");
|
|
|
|
|
|
// 返回更新结果
|
|
|
return R.ok(updateSettleResult);
|