|
@@ -24,12 +24,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
import static com.rongwei.zhsw.system.utils.SaveConstans.billInfo.*;
|
|
|
import static com.rongwei.zhsw.system.utils.SaveConstans.billReccord.DATASOURCEBALANCEDEDUCTION;
|
|
|
import static com.rongwei.zhsw.system.utils.SaveConstans.billReccord.HAVEREVISEDSTATUS;
|
|
|
-import static sun.security.krb5.internal.KDCOptions.with;
|
|
|
|
|
|
/**
|
|
|
* 账单管理(按年分表)(预收,未缴)(SwBillManagementUnpaid)表服务实现类
|
|
@@ -90,19 +88,20 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
SwWaterUsageEntryDo swWaterUsageEntryDo = swWaterUsageEntryService.getBaseMapper().selectById(meterReadId);
|
|
|
|
|
|
BigDecimal oldreading = swWaterUsageEntryDo.getThisreading();
|
|
|
- SwWaterUsageEntryDo waterUsageUpdateDo= new SwWaterUsageEntryDo();
|
|
|
- waterUsageUpdateDo.setId(swWaterUsageEntryDo.getId());
|
|
|
- waterUsageUpdateDo.setThisreading(thisMeterReading);
|
|
|
- waterUsageUpdateDo.setModifyuserid(currentUser.getId());
|
|
|
- waterUsageUpdateDo.setModifyusername(currentUser.getName());
|
|
|
- waterUsageUpdateDo.setModifydate(new Date());
|
|
|
- swWaterUsageEntryService.updateById(waterUsageUpdateDo);
|
|
|
+
|
|
|
+ swWaterUsageEntryService.update(new LambdaUpdateWrapper<SwWaterUsageEntryDo>()
|
|
|
+ .eq(SwWaterUsageEntryDo::getId, 0)
|
|
|
+ .set(SwWaterUsageEntryDo::getThisreading, thisMeterReading)
|
|
|
+ .set(SwWaterUsageEntryDo::getModifyuserid, currentUser.getId())
|
|
|
+ .set(SwWaterUsageEntryDo::getModifyusername, currentUser.getName())
|
|
|
+ .set(SwWaterUsageEntryDo::getModifydate, new Date())
|
|
|
+ );
|
|
|
|
|
|
//2. 根据抄表户号查询用户修改最近读表数
|
|
|
SwUserManagementDo swUserManagement = swUserManagementService.getBaseMapper()
|
|
|
.selectOne(new LambdaQueryWrapper<SwUserManagementDo>()
|
|
|
.eq(SwUserManagementDo::getUsernumber, swWaterUsageEntryDo.getUsernumber()));
|
|
|
- SwUserManagementDo updateDo= new SwUserManagementDo();
|
|
|
+ SwUserManagementDo updateDo = new SwUserManagementDo();
|
|
|
updateDo.setLastmeterreading(thisMeterReading);
|
|
|
updateDo.setModifyuserid(currentUser.getId());
|
|
|
updateDo.setModifyusername(currentUser.getName());
|
|
@@ -114,15 +113,18 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
SwBillManagementUnpaidDo unpaidDo = swBillManagementUnpaidService.getBaseMapper().selectById(billId);
|
|
|
//【当期用水量】=【更新后本次抄表数】-【上次抄表数】
|
|
|
BigDecimal currentUsing = thisMeterReading.subtract(unpaidDo.getLastmeterreading() == null ? BigDecimal.ZERO : unpaidDo.getLastmeterreading());
|
|
|
+ // 原应缴
|
|
|
+ BigDecimal oughttohavepaid = unpaidDo.getUnitprice().multiply(currentUsing);
|
|
|
swBillManagementUnpaidService.update(new LambdaUpdateWrapper<SwBillManagementUnpaidDo>()
|
|
|
- .eq(SwBillManagementUnpaidDo::getId,billId)
|
|
|
- .set(SwBillManagementUnpaidDo::getThismeterreading,thisMeterReading)
|
|
|
- .set(SwBillManagementUnpaidDo::getCurrentwateruse,currentUsing)
|
|
|
- .set(SwBillManagementUnpaidDo::getOughttohavepaid,unpaidDo.getUnitprice().multiply(currentUsing))
|
|
|
- .set(SwBillManagementUnpaidDo::getMeterreadingcorrectionstatus,HAVEREVISEDSTATUS)
|
|
|
- .set(BaseDo::getModifyuserid,currentUser.getId())
|
|
|
- .set(BaseDo::getModifyusername,currentUser.getName())
|
|
|
- .set(BaseDo::getModifydate,new Date()));
|
|
|
+ .eq(SwBillManagementUnpaidDo::getId, billId)
|
|
|
+ .set(SwBillManagementUnpaidDo::getThismeterreading, thisMeterReading)
|
|
|
+ .set(SwBillManagementUnpaidDo::getCurrentwateruse, currentUsing)
|
|
|
+ .set(SwBillManagementUnpaidDo::getOughttohavepaid, oughttohavepaid)
|
|
|
+ .set(SwBillManagementUnpaidDo::getMeterreadingcorrectionstatus, HAVEREVISEDSTATUS)
|
|
|
+ .set(SwBillManagementUnpaidDo::getActualdue, oughttohavepaid.subtract(unpaidDo.getFeewaiver()).add(unpaidDo.getLatefees()))
|
|
|
+ .set(BaseDo::getModifyuserid, currentUser.getId())
|
|
|
+ .set(BaseDo::getModifyusername, currentUser.getName())
|
|
|
+ .set(BaseDo::getModifydate, new Date()));
|
|
|
|
|
|
//生成新的抄表修正记录
|
|
|
SwMeterReadingCorrectionDo swMeterReadingCorrectionDo = new SwMeterReadingCorrectionDo();
|
|
@@ -133,11 +135,13 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
.setThisreading(thisMeterReading)
|
|
|
.setBillid(billId)
|
|
|
.setMeterreading(swWaterUsageEntryDo.getId())
|
|
|
- .setModifyuserid(currentUser.getId()).setModifyusername(currentUser.getName()).setModifydate(new Date());
|
|
|
+ .setModifyuserid(currentUser.getId())
|
|
|
+ .setModifyusername(currentUser.getName())
|
|
|
+ .setModifydate(new Date());
|
|
|
swMeterReadingCorrectionService.getBaseMapper().insert(swMeterReadingCorrectionDo);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- log.error("抄表修正失败 {}",e.getMessage());
|
|
|
+ log.error("抄表修正失败 {}", e.getMessage());
|
|
|
return R.error("抄表修正失败");
|
|
|
}
|
|
|
|
|
@@ -146,12 +150,13 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
|
|
|
/**
|
|
|
* 转正式账单
|
|
|
+ *
|
|
|
* @param map
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public R transferAccount(Map<String, Object> map) {
|
|
|
+ public R transferAccount(Map<String, Object> map) {
|
|
|
try {
|
|
|
|
|
|
//获取账单数据 已根据户号 分组 创建时间正序
|
|
@@ -168,8 +173,8 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
// 保存处理结果
|
|
|
saveProcessedData(transferAccountDo);
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
- log.error("转正式账单数据保存失败 {}",e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("转正式账单数据保存失败 {}", e.getMessage());
|
|
|
return R.error("转正式账单数据保存失败");
|
|
|
}
|
|
|
|
|
@@ -177,7 +182,7 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
}
|
|
|
|
|
|
private Map<String, List<SwUserManagementDo>> getUserGroups(Set<String> usernumbers) {
|
|
|
- return swUserManagementService.list(new LambdaQueryWrapper<SwUserManagementDo>()
|
|
|
+ return swUserManagementService.list(new LambdaQueryWrapper<SwUserManagementDo>()
|
|
|
.eq(SwUserManagementDo::getDeleted, "0")
|
|
|
.in(SwUserManagementDo::getUsernumber, usernumbers)).stream().collect(Collectors.groupingBy(SwUserManagementDo::getUsernumber));
|
|
|
}
|
|
@@ -196,19 +201,19 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
.eq(SwBillManagementUnpaidDo::getDeleted, "0")
|
|
|
.eq(SwBillManagementUnpaidDo::getStatus, PRERECEIVEDSTATE));
|
|
|
|
|
|
- }else if ("select".equals(type)) {
|
|
|
+ } else if ("select".equals(type)) {
|
|
|
//根据ids 选择
|
|
|
List<String> ids = (List<String>) map.get("ids");
|
|
|
- if (ids.isEmpty()){
|
|
|
+ if (ids.isEmpty()) {
|
|
|
throw new CustomException("参数 ids 异常");
|
|
|
}
|
|
|
unpaidDoList = (List<SwBillManagementUnpaidDo>) swBillManagementUnpaidService.listByIds(ids);
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new CustomException("无效的查询类型");
|
|
|
}
|
|
|
|
|
|
- if (unpaidDoList.isEmpty()){
|
|
|
+ if (unpaidDoList.isEmpty()) {
|
|
|
throw new CustomException("预收账单数量为空!");
|
|
|
}
|
|
|
|
|
@@ -226,18 +231,14 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
|
|
|
|
|
|
/**
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
+ * /**
|
|
|
* //计算用户余额是否充足 直接生成缴费记录
|
|
|
*
|
|
|
* @param swBillManagementUnpaidDos
|
|
|
* @param user
|
|
|
-
|
|
|
*/
|
|
|
private void processUserBills(List<SwBillManagementUnpaidDo> swBillManagementUnpaidDos, SwUserManagementDo user,
|
|
|
- TransferAccountDo transferAccountDo ) {
|
|
|
+ TransferAccountDo transferAccountDo) {
|
|
|
|
|
|
// 初始化变量
|
|
|
BigDecimal accumulatedAmount = BigDecimal.ZERO;
|
|
@@ -245,8 +246,8 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
//是否累加值超出余额
|
|
|
boolean isBalanceExceeded = false;
|
|
|
|
|
|
- BigDecimal billAmount =BigDecimal.ZERO;
|
|
|
- List<SwBillManagementUnpaidDo> unpaidDos = new ArrayList<>();
|
|
|
+ BigDecimal billAmount = BigDecimal.ZERO;
|
|
|
+ List<SwBillManagementUnpaidDo> unpaidDos = new ArrayList<>();
|
|
|
SwBillManagementPaidDo paid;
|
|
|
|
|
|
|
|
@@ -256,16 +257,16 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
|
|
|
|
|
|
//合并并排序账单
|
|
|
- List<SwBillManagementUnpaidDo> sortedBills = mergeAndSortBills(swBillManagementUnpaidDos);
|
|
|
+ List<SwBillManagementUnpaidDo> sortedBills = mergeAndSortBills(swBillManagementUnpaidDos);
|
|
|
|
|
|
- for (SwBillManagementUnpaidDo unpaidDo:sortedBills){
|
|
|
+ for (SwBillManagementUnpaidDo unpaidDo : sortedBills) {
|
|
|
|
|
|
- if (unpaidDo ==null ){
|
|
|
+ if (unpaidDo == null) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (isBalanceExceeded ){
|
|
|
+ if (isBalanceExceeded) {
|
|
|
transferAccountDo.getOfficeIds().add(unpaidDo.getId());
|
|
|
continue;
|
|
|
}
|
|
@@ -273,7 +274,7 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
//当累计的账单的 【原应缴(元)】-【总减免(元)】 +【滞纳金(元)】 <= 账户余额,生成计费记录
|
|
|
billAmount = billAmount.add(unpaidDo.getOughttohavepaid()).subtract(unpaidDo.getFeewaiver()).add(unpaidDo.getLatefees());
|
|
|
|
|
|
- if (billAmount.compareTo(user.getAccountbalance()) <= 0){
|
|
|
+ if (billAmount.compareTo(user.getAccountbalance()) <= 0) {
|
|
|
//转正式账单后 生成缴费记录,生成 已缴费账单,删除待缴费记录,更新用户余额
|
|
|
|
|
|
// 记录待删除ID
|
|
@@ -283,21 +284,21 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
paid = new SwBillManagementPaidDo();
|
|
|
BeanUtils.copyProperties(unpaidDo, paid);
|
|
|
paid.setStatus(PAIDINSTATUS);
|
|
|
- paid .setPaymentrecordid(paymentBatchId);
|
|
|
- ZHSWCommonUtils.initModelGeneralParameters(paid,null);
|
|
|
+ paid.setPaymentrecordid(paymentBatchId);
|
|
|
+ ZHSWCommonUtils.initModelGeneralParameters(paid, null);
|
|
|
transferAccountDo.getPaidDoList().add(paid);
|
|
|
|
|
|
//整合要生成缴费记录的预收账单
|
|
|
unpaidDos.add(unpaidDo);
|
|
|
|
|
|
- }else{
|
|
|
- isBalanceExceeded =true;
|
|
|
+ } else {
|
|
|
+ isBalanceExceeded = true;
|
|
|
// 超出余额部分标记为正式账单
|
|
|
transferAccountDo.getOfficeIds().add(unpaidDo.getId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!unpaidDos.isEmpty()){
|
|
|
+ if (!unpaidDos.isEmpty()) {
|
|
|
//生成缴费记录
|
|
|
SwBillingRecordDo record = swBillingRecordService.buildBaseBillingRecord(currentUser, user);
|
|
|
record.setId(paymentBatchId);
|
|
@@ -320,6 +321,7 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
|
|
|
/**
|
|
|
* 原应缴(元)】-【总减免(元)】 +【滞纳金(元)】 是否小于等于 0 的数据先处理
|
|
|
+ *
|
|
|
* @param swBillManagementUnpaidDos
|
|
|
* @return
|
|
|
*/
|
|
@@ -347,16 +349,17 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
|
|
|
/**
|
|
|
* 保存数据
|
|
|
+ *
|
|
|
* @param transferAccountDo
|
|
|
*/
|
|
|
|
|
|
public void saveProcessedData(TransferAccountDo transferAccountDo) {
|
|
|
|
|
|
//转正式账单生成
|
|
|
- if(!transferAccountDo.getOfficeIds().isEmpty()){
|
|
|
+ if (!transferAccountDo.getOfficeIds().isEmpty()) {
|
|
|
swBillManagementUnpaidService.update(new LambdaUpdateWrapper<SwBillManagementUnpaidDo>()
|
|
|
- .in(SwBillManagementUnpaidDo::getId,transferAccountDo.getOfficeIds())
|
|
|
- .set(SwBillManagementUnpaidDo::getStatus,PENDINGSTATUS)
|
|
|
+ .in(SwBillManagementUnpaidDo::getId, transferAccountDo.getOfficeIds())
|
|
|
+ .set(SwBillManagementUnpaidDo::getStatus, PENDINGSTATUS)
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -368,8 +371,8 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
}
|
|
|
|
|
|
//生成已缴费账单
|
|
|
- if (!transferAccountDo.getPaidDoList().isEmpty()){
|
|
|
- swBillManagementPaidService.saveBatch(transferAccountDo.getPaidDoList(),200);
|
|
|
+ if (!transferAccountDo.getPaidDoList().isEmpty()) {
|
|
|
+ swBillManagementPaidService.saveBatch(transferAccountDo.getPaidDoList(), 200);
|
|
|
}
|
|
|
|
|
|
// 更新 用户余额
|
|
@@ -378,8 +381,8 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
}
|
|
|
|
|
|
//生成缴费
|
|
|
- if (!transferAccountDo.getRecordDoList().isEmpty()){
|
|
|
- swBillingRecordService.saveBatch(transferAccountDo.getRecordDoList(),200);
|
|
|
+ if (!transferAccountDo.getRecordDoList().isEmpty()) {
|
|
|
+ swBillingRecordService.saveBatch(transferAccountDo.getRecordDoList(), 200);
|
|
|
}
|
|
|
|
|
|
|