소스 검색

feat: MAH支付-提交结算

李学松 2 년 전
부모
커밋
ef290fdbe0

+ 1 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/entity/input/WmScorePackageSettleInput.java

@@ -30,7 +30,7 @@ public class WmScorePackageSettleInput implements Serializable {
 	private String id;
 
 	// 发票类目
-	@NotNull(message = "发票类目必填")
+//	@NotNull(message = "发票类目必填")
 	private Integer invoiceCategory;
 
 	@NotBlank(message = "结算token必填")

+ 34 - 6
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmPayOffServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qunzhixinxi.hnqz.admin.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONObject;
@@ -370,8 +371,20 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
 		List<WmScorePackageSettleNote> notes = input.getNotes();
 		SubjectLocation location = input.getSubjectLocation();
 
-		// 校验是否配置了结算限制
 		Integer deptId = SecurityUtils.getUser().getDeptId();
+		if (SubjectLocation.MAH_SETTLE.equals(input.getSubjectLocation())) {
+			// 默认在当前企业,取一个结算渠道
+			SysDeptSub condition = new SysDeptSub();
+			condition.setDeptId(deptId);
+			condition.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
+			List<SysDeptSub> deptSubs = sysDeptSubService.list(Wrappers.query(condition));
+			if (CollUtil.isEmpty(deptSubs)) {
+				return R.failed("结算渠道不存在");
+			}
+			location = deptSubs.get(0).getSubjectLocation();
+		}
+
+		// 校验是否配置了结算限制
 		SysDeptSub queryDeptSub = sysDeptSubService.getOne(Wrappers.<SysDeptSub>lambdaQuery()
 				.eq(SysDeptSub::getDeptId, SecurityUtils.getUser().getDeptId())
 				.eq(SysDeptSub::getSubjectLocation, location)
@@ -389,11 +402,12 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
 		BigDecimal total = monitoringIndicatorService.settleMonitoringIndicator(notes, location);
 
 		LocalDateTime now = LocalDateTime.now();
+		SubjectLocation finalLocation = location;
 		notes.forEach(note -> {
 			note.setUpdateTime(now);
 			note.setSubTime(now);
-			note.setSubType(String.valueOf(location.getGigType().getCode()));
-			note.setSubjectLocation(input.getSubjectLocation());
+			note.setSubType(String.valueOf(finalLocation.getGigType().getCode()));
+			note.setSubjectLocation(finalLocation);
 			note.setInvoiceType(input.getInvoiceCategory());
 			note.setCategoryName(input.getCategoryName());
 			if (null == note.getId()) {
@@ -408,7 +422,7 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
 		updateEntity.setSettleStatus(DingEnum.SETTLE_STATUS_WAIT.getType());
 		updateEntity.setScorePackageStatus("5");
 		updateEntity.setDescription(input.getDescription());
-		updateEntity.setSubType(String.valueOf(location.getGigType().getCode()));
+		updateEntity.setSubType(String.valueOf(input.getSubjectLocation().getGigType().getCode()));
 		updateEntity.setLocation(input.getSubjectLocation());
 		updateEntity.setSettlementDate(LocalDateTime.now());
 		if (SubjectLocation.MAH_SETTLE.equals(input.getSubjectLocation())) {
@@ -444,7 +458,21 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
 	public R<?> settleSave(WmScorePackageSettleInput input) {
 
 		List<WmScorePackageSettleNote> notes = input.getNotes();
-		SubjectLocation location = input.getSubjectLocation();
+		SubjectLocation location;
+
+		if (SubjectLocation.MAH_SETTLE.equals(input.getSubjectLocation())) {
+			// 默认在当前企业,取一个结算渠道
+			SysDeptSub condition = new SysDeptSub();
+			condition.setDeptId(SecurityUtils.getUser().getDeptId());
+			condition.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
+			List<SysDeptSub> deptSubs = sysDeptSubService.list(Wrappers.query(condition));
+			if (CollUtil.isEmpty(deptSubs)) {
+				return R.failed("结算渠道不存在");
+			}
+			location = deptSubs.get(0).getSubjectLocation();
+		} else {
+			location = input.getSubjectLocation();
+		}
 
 		// 校验人员信息
 		Set<Integer> userIds = notes.stream().map(WmScorePackageSettleNote::getUserId).map(Integer::valueOf).collect(Collectors.toSet());
@@ -458,7 +486,7 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
 			note.setUpdateTime(now);
 			note.setSubTime(now);
 			note.setSubType(String.valueOf(location.getGigType().getCode()));
-			note.setSubjectLocation(input.getSubjectLocation());
+			note.setSubjectLocation(location);
 			note.setInvoiceType(input.getInvoiceCategory());
 			note.setCategoryName(input.getCategoryName());
 			if (null == note.getId()) {

+ 27 - 9
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmScorePackageSettleNoteServiceImpl.java

@@ -362,10 +362,22 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
 			return R.failed(user.getRealname() + "人员结算渠道不存在,不能结算");
 		}
 
+		if (SubjectLocation.MAH_SETTLE.equals(note.getSubjectLocation())) {
+			// 默认在当前企业,取一个结算渠道
+			SysDeptSub condition = new SysDeptSub();
+			condition.setDeptId(user.getDeptId());
+			condition.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
+			List<SysDeptSub> deptSubs = sysDeptSubService.list(Wrappers.query(condition));
+			if (CollUtil.isEmpty(deptSubs)) {
+				return R.failed("结算渠道不存在");
+			}
+			location = deptSubs.get(0).getSubjectLocation();
+		}
+
 		String subType = String.valueOf(note.getSubjectLocation().getGigType().getCode());
 
 		SysUserSub userSub = sysUserSubMapper.selectOne(Wrappers.<SysUserSub>lambdaQuery()
-				.eq(SysUserSub::getSubjectLocation, note.getSubjectLocation())
+				.eq(SysUserSub::getSubjectLocation, location)
 				.eq(SysUserSub::getDeptId, user.getDeptId())
 				.eq(SysUserSub::getUserId, user.getUserId())
 		);
@@ -376,7 +388,7 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
 		SysDeptSub condition = new SysDeptSub();
 		condition.setDeptId(user.getDeptId());
 		condition.setSubjectType(subType);
-		condition.setSubjectLocation(note.getSubjectLocation());
+		condition.setSubjectLocation(location);
 		condition.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
 		SysDeptSub sysDeptSub = sysDeptSubService.getOne(Wrappers.query(condition));
 
@@ -455,7 +467,7 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
 			updateEntity = new WmScorePackageSettleNote();
 			updateEntity.setId(note.getId());
 			updateEntity.setSubType(subType);
-			updateEntity.setSubjectLocation(note.getSubjectLocation());
+			updateEntity.setSubjectLocation(location);
 			updateEntity.setInvoiceType(note.getInvoiceType());
 			updateEntity.setCategoryName(note.getCategoryName());
 			updateEntity.setSettleAmount(note.getSettleAmount());
@@ -469,13 +481,16 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
 
 			WmScorePackage wmScorePackage = wmScorePackageMapper.selectById(settleNote.getPackageId());
 			wmScorePackage.setSettlementDate(LocalDateTime.now());
-			wmScorePackage.setMahSettleDeptId(note.getMahSettleDeptId());
+			if (SubjectLocation.MAH_SETTLE.equals(note.getSubjectLocation())) {
+				wmScorePackage.setMahSettleDeptId(note.getMahSettleDeptId());
+				wmScorePackage.setLocation(note.getSubjectLocation());
+			}
 			wmScorePackageMapper.updateById(wmScorePackage);
 			return R.ok();
 		} else {
 			WmScorePackageSettleNote entity = new WmScorePackageSettleNote();
 			entity.setSubType(subType);
-			entity.setSubjectLocation(note.getSubjectLocation());
+			entity.setSubjectLocation(location);
 			entity.setInvoiceType(note.getInvoiceType());
 			entity.setCategoryName(note.getCategoryName());
 			entity.setSettleAmount(note.getSettleAmount());
@@ -495,10 +510,13 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
 
 			this.baseMapper.insert(entity);
 
-			// 更新 MAH结算-药企deptId
-			wmScorePackageMapper.update(null, Wrappers.<WmScorePackage>lambdaUpdate()
-					.eq(WmScorePackage::getId, note.getPackageId())
-					.set(WmScorePackage::getMahSettleDeptId, note.getMahSettleDeptId()));
+			if (SubjectLocation.MAH_SETTLE.equals(note.getSubjectLocation())) {
+				// 更新 MAH结算-药企deptId
+				wmScorePackageMapper.update(null, Wrappers.<WmScorePackage>lambdaUpdate()
+						.eq(WmScorePackage::getId, note.getPackageId())
+						.set(WmScorePackage::getLocation, note.getSubjectLocation())
+						.set(WmScorePackage::getMahSettleDeptId, note.getMahSettleDeptId()));
+			}
 		}
 
 		return R.ok();

+ 3 - 0
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/WmScorePackageMapper.xml

@@ -1432,6 +1432,9 @@
 		FROM wm_score_package p, sys_dept d
 		WHERE
 		p.send_package_dept_id = d.dept_id
+		<if test="query.mahSettleDeptId != null">
+			AND p.mah_settle_dept_id = #{query.mahSettleDeptId}
+		</if>
 		<if test="query.sendPackageDeptId != null and query.sendPackageDeptId != ''">
 			AND p.send_package_dept_id= #{query.sendPackageDeptId}
 		</if>