|
@@ -21,7 +21,6 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.security.SecureRandom;
|
|
@@ -73,47 +72,25 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
|
|
|
public R windowPayment(PaymentRequestDTO paymentRequestDTO) throws Exception {
|
|
|
|
|
|
log.info("窗口缴费开始");
|
|
|
- if (paymentRequestDTO.getIds()==null || paymentRequestDTO.getIds().isEmpty()){
|
|
|
- log.debug("无账单缴费");
|
|
|
- windowPaymentNoBill(paymentRequestDTO);
|
|
|
- }else {
|
|
|
- log.debug("有账单缴费");
|
|
|
- windowPaymentHasBill(paymentRequestDTO);
|
|
|
- }
|
|
|
- log.info("窗口缴费结束");
|
|
|
+ if (paymentRequestDTO.getIds()!=null && !paymentRequestDTO.getIds().isEmpty()){
|
|
|
|
|
|
- return R.ok();
|
|
|
- }
|
|
|
+ // 查询待缴费账单
|
|
|
+ List<SwBillManagementUnpaidDo> unpaidBills = queryUnpaidBills(paymentRequestDTO.getIds());
|
|
|
|
|
|
- /**
|
|
|
- * 有账单生成 缴费记录
|
|
|
- *
|
|
|
- * @param paymentRequestDTO
|
|
|
- */
|
|
|
- private void windowPaymentHasBill(PaymentRequestDTO paymentRequestDTO) {
|
|
|
+ //生成缴费记录
|
|
|
+ addNewBillRecord(paymentRequestDTO,unpaidBills);
|
|
|
+ }else {
|
|
|
|
|
|
- List<String> ids = paymentRequestDTO.getIds();
|
|
|
- if(ids==null || ids.isEmpty()){
|
|
|
- throw new CustomException("参数异常");
|
|
|
+ //生成缴费记录
|
|
|
+ addNewBillRecord(paymentRequestDTO,null);
|
|
|
}
|
|
|
- // 查询待缴费账单
|
|
|
- List<SwBillManagementUnpaidDo> unpaidBills = queryUnpaidBills(paymentRequestDTO.getIds());
|
|
|
|
|
|
- //生成缴费记录
|
|
|
- addNewBillRecord(paymentRequestDTO,unpaidBills);
|
|
|
+ log.info("窗口缴费结束");
|
|
|
|
|
|
- //删除 待收账单数据
|
|
|
- deleteUnpaidBills(ids);
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 无账单生成缴费记录
|
|
|
|
|
|
- */
|
|
|
- private void windowPaymentNoBill(PaymentRequestDTO paymentRequestDTO) {
|
|
|
- //生成缴费记录
|
|
|
- addNewBillRecord(paymentRequestDTO,null);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 删除 待收账单数据
|
|
@@ -139,9 +116,11 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
|
|
|
}
|
|
|
|
|
|
// 提取公共字段设置
|
|
|
- private SwBillingRecordDo buildBaseBillingRecord( PaymentRequestDTO paymentRequestDTO, SysUserVo currentUser, SwUserManagementDo user) {
|
|
|
+ private SwBillingRecordDo buildBaseBillingRecord( SysUserVo currentUser, SwUserManagementDo user) {
|
|
|
SwBillingRecordDo record = new SwBillingRecordDo();
|
|
|
|
|
|
+ //缴费编号
|
|
|
+ generateBillingNumber(record);
|
|
|
|
|
|
return record.setId(SecurityUtil.getUUID())
|
|
|
.setChargedate(new Date())
|
|
@@ -161,8 +140,7 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
|
|
|
.setModifydate(new Date())
|
|
|
.setModifyuserid(currentUser.getId())
|
|
|
.setTenantid(currentUser.getTenantid())
|
|
|
- .setDatasource(paymentRequestDTO.getDatasource())
|
|
|
- .setPaidin(paymentRequestDTO.getPaidin())
|
|
|
+
|
|
|
.setModifyusername(currentUser.getName());
|
|
|
}
|
|
|
|
|
@@ -179,37 +157,60 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
|
|
|
|
|
|
SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
|
|
|
|
+ List<SwBillManagementPaidDo> bills =new ArrayList<>();
|
|
|
+
|
|
|
//根据户号获取 用户记录
|
|
|
SwUserManagementDo user = swUserManagementService.getBaseMapper().
|
|
|
selectOne(new LambdaQueryWrapper<SwUserManagementDo>().eq(SwUserManagementDo::getUsernumber, paymentRequestDTO.getUsernumber()));
|
|
|
+
|
|
|
if(user==null){
|
|
|
throw new CustomException("户号不存在");
|
|
|
}
|
|
|
|
|
|
- SwBillingRecordDo add = buildBaseBillingRecord(paymentRequestDTO,currentUser,user);
|
|
|
-
|
|
|
+ SwBillingRecordDo add = buildBaseBillingRecord(currentUser,user);
|
|
|
|
|
|
- // 生成缴费编号
|
|
|
- generateBillingNumber(add);
|
|
|
+ add.setDatasource(paymentRequestDTO.getDatasource());
|
|
|
+ add.setPaidin(paymentRequestDTO.getPaidin());
|
|
|
|
|
|
// 计算费用
|
|
|
- calculateFees(list, add,user);
|
|
|
-
|
|
|
+ calculateFees(list, add, user);
|
|
|
|
|
|
if(list!=null){
|
|
|
//生成已缴费账单
|
|
|
- createBills(list,add,currentUser);
|
|
|
+ bills = createBills(list, add);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ this.updateOrSaveData(add,user,bills,paymentRequestDTO.getIds());
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 存储,修改数据
|
|
|
+ * @param add
|
|
|
+ * @param user
|
|
|
+ * @param bills
|
|
|
+ * @param ids
|
|
|
+ */
|
|
|
+
|
|
|
+ public void updateOrSaveData(SwBillingRecordDo add, SwUserManagementDo user, List<SwBillManagementPaidDo> bills, List<String> ids){
|
|
|
+ //账单缴费记录生成
|
|
|
+ this.baseMapper.insert(add);
|
|
|
+ //已缴费账单生成
|
|
|
+ if (!bills.isEmpty()){
|
|
|
+ swBillManagementPaidService.saveBatch(bills);
|
|
|
+ }
|
|
|
+ if (ids!=null && !ids.isEmpty()){
|
|
|
+ //删除 待收账单数据
|
|
|
+ deleteUnpaidBills(ids);
|
|
|
+ }
|
|
|
|
|
|
//更新用户余额
|
|
|
updateUserBalance(add,user);
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- private void createBills(List<SwBillManagementUnpaidDo> list, SwBillingRecordDo add, SysUserVo currentUser) {
|
|
|
+ private List<SwBillManagementPaidDo> createBills(List<SwBillManagementUnpaidDo> list, SwBillingRecordDo add) {
|
|
|
List<SwBillManagementPaidDo> paidList = new ArrayList<>();
|
|
|
SwBillManagementPaidDo paid;
|
|
|
for (SwBillManagementUnpaidDo unpaid : list) {
|
|
@@ -219,11 +220,12 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
|
|
|
paid.setStatus(PAIDINSTATUS)
|
|
|
//缴费记录ID
|
|
|
.setPaymentrecordid(add.getId());
|
|
|
- ZHSWCommonUtils.initModelGeneralParameters(paid,currentUser);
|
|
|
+ ZHSWCommonUtils.initModelGeneralParameters(paid,null);
|
|
|
paidList.add(paid);
|
|
|
}
|
|
|
// 保存已缴费账单
|
|
|
- swBillManagementPaidService.saveBatch(paidList);
|
|
|
+
|
|
|
+ return paidList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -295,7 +297,7 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
|
|
|
//【实缴后余额(元)】=【账户余额】+【本次实缴(元-整)】- 原应缴 + 总减免 - 滞纳金
|
|
|
add.setAfterpaymentbalance(add.getPaidin().add(accountbalance).subtract(totalOught).add(totalWaivers).subtract(totalLateFees));
|
|
|
|
|
|
- swBillingRecordService.save(add);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|