|
@@ -1,10 +1,31 @@
|
|
|
package com.rongwei.zhsw.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.zhsw.dao.SwBillManagementUnpaidDao;
|
|
|
import com.rongwei.zhsw.service.SwBillManagementUnpaidService;
|
|
|
+import com.rongwe.zhsw.domain.SwMeterReadingCorrectionDo;
|
|
|
+import com.rongwe.zhsw.domain.SwUserManagement;
|
|
|
+import com.rongwe.zhsw.domain.SwWaterUsageEntryDo;
|
|
|
+import com.rongwe.zhsw.dto.MeterReadingCorrectionDTO;
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import com.rongwei.zhsw.sys.dao.SwBillManagementUnpaidDao;
|
|
|
+import com.rongwei.zhsw.sys.service.SwBillManagementUnpaidService;
|
|
|
import com.rongwe.zhsw.domain.SwBillManagementUnpaidDo;
|
|
|
+import com.rongwei.zhsw.sys.service.SwMeterReadingCorrectionService;
|
|
|
+import com.rongwei.zhsw.sys.service.SwUserManagementService;
|
|
|
+import com.rongwei.zhsw.sys.service.SwWaterUsageEntryService;
|
|
|
+import com.rongwei.zhsw.utils.ZhswCommonUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+import static com.rongwei.zhsw.utils.SaveConstans.billReccord.HAVEREVISEDSTATUS;
|
|
|
|
|
|
/**
|
|
|
* 账单管理(按年分表)(预收,未缴)(SwBillManagementUnpaid)表服务实现类
|
|
@@ -13,7 +34,89 @@ import org.springframework.stereotype.Service;
|
|
|
* @since 2025-03-07 16:49:13
|
|
|
*/
|
|
|
@Service
|
|
|
-public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagementUnpaidDao, SwBillManagementUnpaidDo> implements SwBillManagementUnpaidService {
|
|
|
+public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagementUnpaidDao, SwBillManagementUnpaidDo>
|
|
|
+ implements SwBillManagementUnpaidService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SwUserManagementService swUserManagementService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SwWaterUsageEntryService swWaterUsageEntryService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SwBillManagementUnpaidService swBillManagementUnpaidService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SwMeterReadingCorrectionService swMeterReadingCorrectionService;
|
|
|
+ /**
|
|
|
+ * 抄表修正
|
|
|
+ * 1、将 对应抄表记录更新,本次抄表数 更新
|
|
|
+ * 2、将 对应用户表中 对应的【最近抄表读数】进行更新
|
|
|
+ * 3、将 对应的这笔账单的 相关计费信息更新
|
|
|
+ * @param meterReadId
|
|
|
+ * @param billId
|
|
|
+ * @param thisMeterReading
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R meterReadingCorrection(MeterReadingCorrectionDTO dto) {
|
|
|
+
|
|
|
+ String meterReadId = dto.getMeterReadId();
|
|
|
+ String billId = dto.getBillId();
|
|
|
+ BigDecimal thisMeterReading = dto.getThisMeterReading();
|
|
|
+
|
|
|
+ //当前用户
|
|
|
+ SysUserVo currentUser = ZhswCommonUtils.getCurrentUser();
|
|
|
+
|
|
|
+ //1. 更新抄表数据
|
|
|
+ SwWaterUsageEntryDo swWaterUsageEntryDo = swWaterUsageEntryService.getBaseMapper().selectById(meterReadId);
|
|
|
+
|
|
|
+ BigDecimal oldreading = swWaterUsageEntryDo.getThisreading();
|
|
|
+ swWaterUsageEntryDo.setThisreading(thisMeterReading)
|
|
|
+ .setModifyuserid(currentUser.getId()).setModifyusername(currentUser.getName()).setModifydate(new Date());
|
|
|
+
|
|
|
+ swWaterUsageEntryService.updateById(swWaterUsageEntryDo);
|
|
|
+
|
|
|
+ //2. 根据抄表户号查询用户修改最近读表数
|
|
|
+ SwUserManagement swUserManagement = swUserManagementService.getBaseMapper().selectOne(new LambdaQueryWrapper<SwUserManagement>().eq(SwUserManagement::getUsernumber, swWaterUsageEntryDo.getUsernumber()));
|
|
|
+ swUserManagement.setLastmeterreading(thisMeterReading);
|
|
|
+ swUserManagement.setModifyuserid(currentUser.getId());
|
|
|
+ swUserManagement.setModifyusername(currentUser.getName());
|
|
|
+ swUserManagement.setModifydate(new Date());
|
|
|
+ swUserManagementService.updateById(swUserManagement);
|
|
|
+
|
|
|
+ //更新账户表
|
|
|
+ SwBillManagementUnpaidDo unpaidDo = swBillManagementUnpaidService.getBaseMapper().selectById(billId);
|
|
|
+ //【本次抄表数】对应更新
|
|
|
+ unpaidDo.setThismeterreading(thisMeterReading);
|
|
|
+ //【当期用水量】=【更新后本次抄表数】-【上次抄表数】
|
|
|
+ unpaidDo.setCurrentwateruse(thisMeterReading.subtract(unpaidDo.getLastmeterreading()==null?BigDecimal.ZERO:unpaidDo.getLastmeterreading()));
|
|
|
+ //【原应缴】=【单价】*【当期用水量】
|
|
|
+ unpaidDo.setOughttohavepaid(unpaidDo.getUnitprice().multiply(unpaidDo.getCurrentwateruse()));
|
|
|
+ //更新未已修正状态
|
|
|
+ unpaidDo.setMeterreadingcorrectionstatus(HAVEREVISEDSTATUS)
|
|
|
+ .setModifyuserid(currentUser.getId()).setModifyusername(currentUser.getName()).setModifydate(new Date());
|
|
|
+
|
|
|
+ swBillManagementUnpaidService.updateById(unpaidDo);
|
|
|
+
|
|
|
+ //生成新的抄表修正记录
|
|
|
+ SwMeterReadingCorrectionDo swMeterReadingCorrectionDo = new SwMeterReadingCorrectionDo();
|
|
|
+ swMeterReadingCorrectionDo.setId(SecurityUtil.getUUID())
|
|
|
+ .setUsername(swWaterUsageEntryDo.getUsername())
|
|
|
+ .setUsernumber(swWaterUsageEntryDo.getUsernumber())
|
|
|
+ .setLastreading(oldreading)
|
|
|
+ .setThisreading(thisMeterReading)
|
|
|
+ .setBillid(billId)
|
|
|
+ .setMeterreading(swWaterUsageEntryDo.getId())
|
|
|
+ .setModifyuserid(currentUser.getId()).setModifyusername(currentUser.getName()).setModifydate(new Date());
|
|
|
+ swMeterReadingCorrectionService.getBaseMapper().insert(swMeterReadingCorrectionDo);
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|