|
@@ -1,5 +1,6 @@
|
|
|
package com.bz.smart_city.service.impl.pay;
|
|
|
|
|
|
+import com.bz.smart_city.Utils.NumberToCN;
|
|
|
import com.bz.smart_city.commom.exception.ServiceException;
|
|
|
import com.bz.smart_city.commom.model.Pagination;
|
|
|
import com.bz.smart_city.commom.model.ResultStatus;
|
|
@@ -17,6 +18,7 @@ import com.bz.smart_city.entity.pay.PayPayReceived;
|
|
|
import com.bz.smart_city.service.pay.PayinvoiceService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -41,20 +43,21 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
public void insert(PayInvoice payInvoice) {
|
|
|
payInvoiceMapper.insert(payInvoice);
|
|
|
}
|
|
|
+
|
|
|
public PayInvoiceDto get(BigInteger id) {
|
|
|
return payInvoiceMapper.get(id);
|
|
|
}
|
|
|
|
|
|
public List<PayInvoiceDto> findList(String condition, Integer state, String startTime, String endTime) {
|
|
|
- LoginUser loginUser= UserUtil.getCurrentUser();
|
|
|
- PayInvoiceDto payInvoiceDto=new PayInvoiceDto();
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ PayInvoiceDto payInvoiceDto = new PayInvoiceDto();
|
|
|
payInvoiceDto.setCondition(condition);
|
|
|
payInvoiceDto.setState(state);
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
- if(StringUtils.isNotBlank(startTime)){
|
|
|
- payInvoiceDto.setStartTime( LocalDateTime.parse(startTime,df));
|
|
|
+ if (StringUtils.isNotBlank(startTime)) {
|
|
|
+ payInvoiceDto.setStartTime(LocalDateTime.parse(startTime, df));
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(endTime)){
|
|
|
+ if (StringUtils.isNotBlank(endTime)) {
|
|
|
payInvoiceDto.setEndTime(LocalDateTime.parse(endTime, df));
|
|
|
}
|
|
|
|
|
@@ -65,23 +68,23 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
return payInvoiceMapper.findList(payInvoiceDto);
|
|
|
}
|
|
|
|
|
|
- public Pagination<PayInvoiceDto> findListPage(String condition,Integer state, String startTime, String endTime, int pageNum, int pageSize) {
|
|
|
+ public Pagination<PayInvoiceDto> findListPage(String condition, Integer state, String startTime, String endTime, int pageNum, int pageSize) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
//分页
|
|
|
- PageHelper.startPage(pageNum,pageSize);
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
|
|
- PayInvoiceDto payInvoiceDto=new PayInvoiceDto();
|
|
|
+ PayInvoiceDto payInvoiceDto = new PayInvoiceDto();
|
|
|
payInvoiceDto.setCondition(condition);
|
|
|
payInvoiceDto.setState(state);
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
- if(StringUtils.isNotBlank(startTime)){
|
|
|
- payInvoiceDto.setStartTime( LocalDateTime.parse(startTime,df));
|
|
|
+ if (StringUtils.isNotBlank(startTime)) {
|
|
|
+ payInvoiceDto.setStartTime(LocalDateTime.parse(startTime, df));
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(endTime)){
|
|
|
+ if (StringUtils.isNotBlank(endTime)) {
|
|
|
payInvoiceDto.setEndTime(LocalDateTime.parse(endTime, df));
|
|
|
}
|
|
|
//站点为空则加入用户站点查询
|
|
|
- if( loginUser !=null){
|
|
|
+ if (loginUser != null) {
|
|
|
//站点权限
|
|
|
payInvoiceDto.setSiteId(loginUser.getSiteId());
|
|
|
//客户权限
|
|
@@ -94,11 +97,11 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
return new Pagination<>(list);
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor=Exception.class)
|
|
|
- public void savePrintInfo(String payseriesno,String invoiceno) {
|
|
|
- LoginUser loginUser=UserUtil.getCurrentUser();
|
|
|
- BigDecimal countReceivedamount=BigDecimal.ZERO;
|
|
|
- PayInvoice invoice=new PayInvoice();
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void savePrintInfo(String payseriesno, String invoiceno) {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ BigDecimal countReceivedamount = BigDecimal.ZERO;
|
|
|
+ PayInvoice invoice = new PayInvoice();
|
|
|
invoice.setInvoiceno(invoiceno);
|
|
|
|
|
|
invoice.setState(2);
|
|
@@ -113,10 +116,10 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
invoice.setRemarks("");
|
|
|
|
|
|
//获取同批次号的交易明细
|
|
|
- List<PayTransactiondetails> payTransactiondetailsList=payInvoiceMapper.findTransByPayseriesno(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
+ List<PayTransactiondetails> payTransactiondetailsList = payInvoiceMapper.findTransByPayseriesno(payseriesno, loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
|
|
|
- for(PayTransactiondetails payTransactiondetails:payTransactiondetailsList){
|
|
|
- if(payTransactiondetails.getInvoiceId()!=null){
|
|
|
+ for (PayTransactiondetails payTransactiondetails : payTransactiondetailsList) {
|
|
|
+ if (payTransactiondetails.getInvoiceId() != null) {
|
|
|
throw new ServiceException(ResultStatus.PAY_INVOICE_EXISTED);
|
|
|
}
|
|
|
invoice.setAccountId(payTransactiondetails.getAccountId());
|
|
@@ -126,16 +129,16 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
invoice.setYear(payTransactiondetails.getYear());
|
|
|
invoice.setMonth(payTransactiondetails.getMonth());
|
|
|
//转预存或充值金额
|
|
|
- if(payTransactiondetails.getPayway()!=5&&(payTransactiondetails.getTranstype()==1||payTransactiondetails.getTranstype()==4)){
|
|
|
- countReceivedamount = countReceivedamount.add(payTransactiondetails.getTransamount()!=null?payTransactiondetails.getTransamount():BigDecimal.ZERO);
|
|
|
+ if (payTransactiondetails.getPayway() != 5 && (payTransactiondetails.getTranstype() == 1 || payTransactiondetails.getTranstype() == 4)) {
|
|
|
+ countReceivedamount = countReceivedamount.add(payTransactiondetails.getTransamount() != null ? payTransactiondetails.getTransamount() : BigDecimal.ZERO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
//获取同批次号的实收信息
|
|
|
- List<PayPayReceived> Receiveds=payInvoiceMapper.findReceivedByPayseriesno(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
+ List<PayPayReceived> Receiveds = payInvoiceMapper.findReceivedByPayseriesno(payseriesno, loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
|
|
|
- for(PayPayReceived received:Receiveds){
|
|
|
- if(received.getInvoiceId()!=null){
|
|
|
+ for (PayPayReceived received : Receiveds) {
|
|
|
+ if (received.getInvoiceId() != null) {
|
|
|
throw new ServiceException(ResultStatus.PAY_INVOICE_EXISTED);
|
|
|
}
|
|
|
invoice.setAccountId(received.getAccountId());
|
|
@@ -145,8 +148,8 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
invoice.setYear(received.getYear());
|
|
|
invoice.setMonth(received.getMonth());
|
|
|
//非预存划扣(即支付金额抵扣)
|
|
|
- if(received.getPayway()!=5){
|
|
|
- countReceivedamount = countReceivedamount.add(received.getReceivedamount()!=null?received.getReceivedamount():BigDecimal.ZERO);
|
|
|
+ if (received.getPayway() != 5) {
|
|
|
+ countReceivedamount = countReceivedamount.add(received.getReceivedamount() != null ? received.getReceivedamount() : BigDecimal.ZERO);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -154,112 +157,113 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
invoice.setInvoiceamount(countReceivedamount);
|
|
|
//插入成功后返回id
|
|
|
payInvoiceMapper.insert(invoice);
|
|
|
- if(payTransactiondetailsList.size()>0){
|
|
|
+ if (payTransactiondetailsList.size() > 0) {
|
|
|
//修改明细的收据信息
|
|
|
- payInvoiceMapper.updatePrintInvoiceRecord(1, payseriesno, invoice.getId(),loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
+ payInvoiceMapper.updatePrintInvoiceRecord(1, payseriesno, invoice.getId(), loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
}
|
|
|
- if(Receiveds.size()>0){
|
|
|
+ if (Receiveds.size() > 0) {
|
|
|
//修改实收的收据信息
|
|
|
- payInvoiceMapper.updatePrintInvoiceRecord(2, payseriesno, invoice.getId(),loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
+ payInvoiceMapper.updatePrintInvoiceRecord(2, payseriesno, invoice.getId(), loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 打印收据——仅充值
|
|
|
+ *
|
|
|
* @param payseriesno
|
|
|
* @return
|
|
|
*/
|
|
|
- public PrintInvoiceData getPrintDataOfTrans(String payseriesno){
|
|
|
- LoginUser loginUser=UserUtil.getCurrentUser();
|
|
|
- PrintInvoiceData printInvoiceData=payInvoiceMapper.getPrintDataOfTran(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
- if(printInvoiceData!=null){
|
|
|
- PrintInvoiceData wateruserdData=payInvoiceMapper.getLastWaterUsedRecord(printInvoiceData.getAccountId(), printInvoiceData.getCreateDate(),loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
- if(wateruserdData!=null){
|
|
|
+ public PrintInvoiceData getPrintDataOfTrans(String payseriesno) {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ PrintInvoiceData printInvoiceData = payInvoiceMapper.getPrintDataOfTran(payseriesno, loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
+ if (printInvoiceData != null) {
|
|
|
+ PrintInvoiceData wateruserdData = payInvoiceMapper.getLastWaterUsedRecord(printInvoiceData.getAccountId(), printInvoiceData.getCreateDate(), loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
+ if (wateruserdData != null) {
|
|
|
printInvoiceData.setReading(wateruserdData.getReading());
|
|
|
printInvoiceData.setRecorddate(wateruserdData.getRecorddate());
|
|
|
}
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- if(printInvoiceData.getCreateDate()!=null){
|
|
|
+ if (printInvoiceData.getCreateDate() != null) {
|
|
|
printInvoiceData.setPaydate(df.format(printInvoiceData.getCreateDate()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printInvoiceData.setPaydate(df.format(LocalDateTime.now()));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new ServiceException(ResultStatus.OPERATE_RECORD_NOT_EXIT);
|
|
|
}
|
|
|
printInvoiceData.setPrintType(1);
|
|
|
printInvoiceData.setPayseriesno(payseriesno);
|
|
|
printInvoiceData.setInvoiceNo(
|
|
|
- DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
|
|
|
+ DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()) + "" + (int) (Math.random() * 1000));
|
|
|
return printInvoiceData;
|
|
|
}
|
|
|
|
|
|
- public PrintInvoiceData getPrintDataOfTransKailu(String payseriesno){
|
|
|
- PrintInvoiceData printInvoiceData=payInvoiceMapper.countTransactiondetails(payseriesno);
|
|
|
+ public PrintInvoiceData getPrintDataOfTransKailu(String payseriesno) {
|
|
|
+ PrintInvoiceData printInvoiceData = payInvoiceMapper.countTransactiondetails(payseriesno);
|
|
|
PrintInvoiceData printDataKailu;
|
|
|
- if(printInvoiceData!=null){
|
|
|
+ if (printInvoiceData != null) {
|
|
|
printDataKailu = payInvoiceMapper.getPrintDataKailu(printInvoiceData.getAccountId());
|
|
|
printDataKailu.setTransamount(printInvoiceData.getTransamount());
|
|
|
printDataKailu.setCreateBy(printInvoiceData.getCreateBy());
|
|
|
printDataKailu.setRemaining(printInvoiceData.getRemaining());
|
|
|
printDataKailu.setLastRemaining(printInvoiceData.getLastRemaining());
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- if(printInvoiceData.getCreateDate()!=null){
|
|
|
+ if (printInvoiceData.getCreateDate() != null) {
|
|
|
printDataKailu.setPaydate(df.format(printInvoiceData.getCreateDate()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printDataKailu.setPaydate(df.format(LocalDateTime.now()));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new ServiceException(ResultStatus.OPERATE_RECORD_NOT_EXIT);
|
|
|
}
|
|
|
printDataKailu.setPrintType(1);
|
|
|
printDataKailu.setPayseriesno(payseriesno);
|
|
|
printDataKailu.setInvoiceNo(
|
|
|
- DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
|
|
|
+ DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()) + "" + (int) (Math.random() * 1000));
|
|
|
return printDataKailu;
|
|
|
}
|
|
|
|
|
|
- public PrintInvoiceData getPrintDataOfTransGaizhou(String payseriesno){
|
|
|
+ public PrintInvoiceData getPrintDataOfTransGaizhou(String payseriesno) {
|
|
|
|
|
|
//查询交易
|
|
|
- PrintInvoiceData printInvoiceData=payInvoiceMapper.countTransactiondetails(payseriesno);
|
|
|
- if(printInvoiceData == null){
|
|
|
+ PrintInvoiceData printInvoiceData = payInvoiceMapper.countTransactiondetails(payseriesno);
|
|
|
+ if (printInvoiceData == null) {
|
|
|
//没有查询到交易信息
|
|
|
throw new ServiceException(ResultStatus.OPERATE_RECORD_NOT_EXIT);
|
|
|
}
|
|
|
- BigInteger accountId=printInvoiceData.getAccountId();
|
|
|
+ BigInteger accountId = printInvoiceData.getAccountId();
|
|
|
//查询账期信息
|
|
|
- PrintInvoiceData printInvoiceDataPeriod=payInvoiceMapper.getAmountPeriod(payseriesno);
|
|
|
+ PrintInvoiceData printInvoiceDataPeriod = payInvoiceMapper.getAmountPeriod(payseriesno);
|
|
|
Integer maxPeriod;
|
|
|
Integer minPeriod;
|
|
|
- if(printInvoiceDataPeriod != null){
|
|
|
- maxPeriod=printInvoiceDataPeriod.getMaxPeriod();
|
|
|
- minPeriod=printInvoiceDataPeriod.getMinPeriod();
|
|
|
- }else{
|
|
|
- maxPeriod=printInvoiceData.getMinPeriod();
|
|
|
- minPeriod=printInvoiceData.getMinPeriod();
|
|
|
+ if (printInvoiceDataPeriod != null) {
|
|
|
+ maxPeriod = printInvoiceDataPeriod.getMaxPeriod();
|
|
|
+ minPeriod = printInvoiceDataPeriod.getMinPeriod();
|
|
|
+ } else {
|
|
|
+ maxPeriod = printInvoiceData.getMinPeriod();
|
|
|
+ minPeriod = printInvoiceData.getMinPeriod();
|
|
|
}
|
|
|
//查询水量应收信息
|
|
|
- PrintInvoiceData printInvoiceDataReceivablefee=payInvoiceMapper.getAmountInfoAndReceivablefee(accountId,maxPeriod,minPeriod);
|
|
|
+ PrintInvoiceData printInvoiceDataReceivablefee = payInvoiceMapper.getAmountInfoAndReceivablefee(accountId, maxPeriod, minPeriod);
|
|
|
//查询客户基础信息
|
|
|
- PrintInvoiceData printInvoiceDataAccountBaseInfo=payInvoiceMapper.getAccountBaseInfo(accountId);
|
|
|
+ PrintInvoiceData printInvoiceDataAccountBaseInfo = payInvoiceMapper.getAccountBaseInfo(accountId);
|
|
|
|
|
|
//拼装数据
|
|
|
- if(printInvoiceDataReceivablefee != null){
|
|
|
+ if (printInvoiceDataReceivablefee != null) {
|
|
|
printInvoiceDataAccountBaseInfo.setReading(printInvoiceDataReceivablefee.getReading());
|
|
|
printInvoiceDataAccountBaseInfo.setRecorddate(printInvoiceDataReceivablefee.getRecorddate());
|
|
|
printInvoiceDataAccountBaseInfo.setLastreading(printInvoiceDataReceivablefee.getLastreading());
|
|
|
printInvoiceDataAccountBaseInfo.setLastrecorddate(printInvoiceDataReceivablefee.getLastrecorddate());
|
|
|
printInvoiceDataAccountBaseInfo.setPayamount(printInvoiceDataReceivablefee.getPayamount());
|
|
|
printInvoiceDataAccountBaseInfo.setReceivablefee(printInvoiceDataReceivablefee.getReceivablefee());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printInvoiceDataAccountBaseInfo.setReading(BigDecimal.ZERO);
|
|
|
printInvoiceDataAccountBaseInfo.setLastreading(BigDecimal.ZERO);
|
|
|
printInvoiceDataAccountBaseInfo.setPayamount(BigDecimal.ZERO);
|
|
|
printInvoiceDataAccountBaseInfo.setReceivablefee(BigDecimal.ZERO);
|
|
|
}
|
|
|
|
|
|
- if(printInvoiceData.getRemaining().compareTo(BigDecimal.ZERO) == 1 ){
|
|
|
+ if (printInvoiceData.getRemaining().compareTo(BigDecimal.ZERO) == 1) {
|
|
|
printInvoiceDataAccountBaseInfo.setRemaining(printInvoiceData.getRemaining());
|
|
|
}
|
|
|
printInvoiceDataAccountBaseInfo.setCreateBy(printInvoiceData.getCreateBy());
|
|
@@ -272,24 +276,91 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
printInvoiceDataAccountBaseInfo.setLastRemaining(lastRemaining);
|
|
|
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- if(printInvoiceData.getCreateDate()!=null){
|
|
|
+ if (printInvoiceData.getCreateDate() != null) {
|
|
|
printInvoiceDataAccountBaseInfo.setPaydate(df.format(printInvoiceData.getCreateDate()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printInvoiceDataAccountBaseInfo.setPaydate(df.format(LocalDateTime.now()));
|
|
|
}
|
|
|
|
|
|
printInvoiceDataAccountBaseInfo.setPrintType(1);
|
|
|
printInvoiceDataAccountBaseInfo.setPayseriesno(payseriesno);
|
|
|
printInvoiceDataAccountBaseInfo.setInvoiceNo(
|
|
|
- DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
|
|
|
+ DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()) + "" + (int) (Math.random() * 1000));
|
|
|
return printInvoiceDataAccountBaseInfo;
|
|
|
}
|
|
|
|
|
|
- public PrintInvoiceData getPrintDataOfTransLongquan(String payseriesno){
|
|
|
+ public PrintInvoiceData getPrintDataOfTransJK(String payseriesno) {
|
|
|
+ //查询交易
|
|
|
+ PrintInvoiceData printInvoiceData = payInvoiceMapper.countTransactiondetails(payseriesno);
|
|
|
+ if (printInvoiceData == null) {
|
|
|
+ //没有查询到交易信息
|
|
|
+ throw new ServiceException(ResultStatus.OPERATE_RECORD_NOT_EXIT);
|
|
|
+ }
|
|
|
+ BigInteger accountId = printInvoiceData.getAccountId();
|
|
|
+ //查询账期信息
|
|
|
+ PrintInvoiceData printInvoiceDataPeriod = payInvoiceMapper.getAmountPeriod(payseriesno);
|
|
|
+ Integer maxPeriod;
|
|
|
+ Integer minPeriod;
|
|
|
+ if (printInvoiceDataPeriod != null) {
|
|
|
+ maxPeriod = printInvoiceDataPeriod.getMaxPeriod();
|
|
|
+ minPeriod = printInvoiceDataPeriod.getMinPeriod();
|
|
|
+ } else {
|
|
|
+ maxPeriod = printInvoiceData.getMinPeriod();
|
|
|
+ minPeriod = printInvoiceData.getMinPeriod();
|
|
|
+ }
|
|
|
+ //查询水量应收信息
|
|
|
+ PrintInvoiceData printInvoiceDataReceivablefee = payInvoiceMapper.getAmountInfoAndReceivablefee(accountId, maxPeriod, minPeriod);
|
|
|
+ //查询客户基础信息
|
|
|
+ PrintInvoiceData printInvoiceDataAccountBaseInfo = payInvoiceMapper.getAccountBaseInfo(accountId);
|
|
|
+
|
|
|
+ //拼装数据
|
|
|
+ if (printInvoiceDataReceivablefee != null) {
|
|
|
+ printInvoiceDataAccountBaseInfo.setReading(printInvoiceDataReceivablefee.getReading());
|
|
|
+ printInvoiceDataAccountBaseInfo.setRecorddate(printInvoiceDataReceivablefee.getRecorddate());
|
|
|
+ printInvoiceDataAccountBaseInfo.setLastreading(printInvoiceDataReceivablefee.getLastreading());
|
|
|
+ printInvoiceDataAccountBaseInfo.setLastrecorddate(printInvoiceDataReceivablefee.getLastrecorddate());
|
|
|
+ printInvoiceDataAccountBaseInfo.setPayamount(printInvoiceDataReceivablefee.getPayamount());
|
|
|
+ printInvoiceDataAccountBaseInfo.setReceivablefee(printInvoiceDataReceivablefee.getReceivablefee());
|
|
|
+ } else {
|
|
|
+ printInvoiceDataAccountBaseInfo.setReading(BigDecimal.ZERO);
|
|
|
+ printInvoiceDataAccountBaseInfo.setLastreading(BigDecimal.ZERO);
|
|
|
+ printInvoiceDataAccountBaseInfo.setPayamount(BigDecimal.ZERO);
|
|
|
+ printInvoiceDataAccountBaseInfo.setReceivablefee(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (printInvoiceData.getRemaining().compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ printInvoiceDataAccountBaseInfo.setRemaining(printInvoiceData.getRemaining());
|
|
|
+ }
|
|
|
+ printInvoiceDataAccountBaseInfo.setCreateBy(printInvoiceData.getCreateBy());
|
|
|
+ printInvoiceDataAccountBaseInfo.setCreateDate(printInvoiceData.getCreateDate());
|
|
|
+ printInvoiceDataAccountBaseInfo.setTransamount(printInvoiceData.getTransamount().setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+
|
|
|
+ BigDecimal lastRemaining = printInvoiceDataAccountBaseInfo.getRemaining()
|
|
|
+ .add(printInvoiceDataAccountBaseInfo.getReceivablefee())
|
|
|
+ .subtract(printInvoiceDataAccountBaseInfo.getTransamount());
|
|
|
+ printInvoiceDataAccountBaseInfo.setLastRemaining(lastRemaining);
|
|
|
+
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ if (printInvoiceData.getCreateDate() != null) {
|
|
|
+ printInvoiceDataAccountBaseInfo.setPaydate(df.format(printInvoiceData.getCreateDate()));
|
|
|
+ } else {
|
|
|
+ printInvoiceDataAccountBaseInfo.setPaydate(df.format(LocalDateTime.now()));
|
|
|
+ }
|
|
|
+ //查询年用水量
|
|
|
+ printInvoiceDataAccountBaseInfo.setYearUsedAmount(payInvoiceMapper.getYearUsedAmount(accountId));
|
|
|
+ //金额转换为大写
|
|
|
+ printInvoiceDataAccountBaseInfo.setAmountBigFee(NumberToCN.number2CNMontrayUnit(printInvoiceData.getTransamount()));
|
|
|
+ printInvoiceDataAccountBaseInfo.setPrintType(1);
|
|
|
+ printInvoiceDataAccountBaseInfo.setPayseriesno(payseriesno);
|
|
|
+ printInvoiceDataAccountBaseInfo.setInvoiceNo(
|
|
|
+ DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()) + "" + (int) (Math.random() * 1000));
|
|
|
+ return printInvoiceDataAccountBaseInfo;
|
|
|
+ }
|
|
|
+ public PrintInvoiceData getPrintDataOfTransLongquan(String payseriesno) {
|
|
|
//获取缴费信息
|
|
|
- PrintInvoiceData printInvoiceData=payInvoiceMapper.countTransactiondetails(payseriesno);
|
|
|
+ PrintInvoiceData printInvoiceData = payInvoiceMapper.countTransactiondetails(payseriesno);
|
|
|
PrintInvoiceData printDataLongquan;
|
|
|
- if(printInvoiceData != null && printInvoiceData.getAccountId() != null){
|
|
|
+ if (printInvoiceData != null && printInvoiceData.getAccountId() != null) {
|
|
|
//获取用户信息
|
|
|
printDataLongquan = payInvoiceMapper.getAccountInfoPrint(printInvoiceData.getAccountId());
|
|
|
|
|
@@ -297,7 +368,7 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
PrintInvoiceData payInvoiceReceivable = payInvoiceMapper.getPayInvoiceReceivable(payseriesno);
|
|
|
//拼装数据
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- if(payInvoiceReceivable != null){
|
|
|
+ if (payInvoiceReceivable != null) {
|
|
|
printDataLongquan.setLastreading(payInvoiceReceivable.getLastreading());
|
|
|
printDataLongquan.setReading(payInvoiceReceivable.getReading());
|
|
|
printDataLongquan.setPayamount(payInvoiceReceivable.getPayamount());
|
|
@@ -308,127 +379,130 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
|
|
|
printDataLongquan.setPrice4(payInvoiceReceivable.getPrice4());
|
|
|
printDataLongquan.setReceivablefee4(payInvoiceReceivable.getReceivablefee4());
|
|
|
printDataLongquan.setReceivablefee(payInvoiceReceivable.getReceivablefee());
|
|
|
- if(printInvoiceData.getApprovetime()!=null){
|
|
|
+ if (printInvoiceData.getApprovetime() != null) {
|
|
|
printDataLongquan.setApproveDate(df.format(printInvoiceData.getApprovetime()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printDataLongquan.setApproveDate(df.format(LocalDateTime.now()));
|
|
|
}
|
|
|
}
|
|
|
//没有交易明细记录则取当前余额作为上期余额和本期余额
|
|
|
- if(printInvoiceData.getTransamount() != null){
|
|
|
+ if (printInvoiceData.getTransamount() != null) {
|
|
|
printDataLongquan.setRemaining(printInvoiceData.getRemaining());
|
|
|
}
|
|
|
- if(printInvoiceData.getTransamount() != null){
|
|
|
- printDataLongquan.setLastRemaining(printInvoiceData.getLastRemaining());
|
|
|
- }else{
|
|
|
- printDataLongquan.setLastRemaining(printDataLongquan.getRemaining());
|
|
|
+ if (printInvoiceData.getTransamount() != null) {
|
|
|
+ printDataLongquan.setLastRemaining(printInvoiceData.getLastRemaining().setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else {
|
|
|
+ printDataLongquan.setLastRemaining(printDataLongquan.getRemaining().setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
}
|
|
|
- printDataLongquan.setTransamount(printInvoiceData.getTransamount());
|
|
|
+ printDataLongquan.setTransamount(printInvoiceData.getTransamount().setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
printDataLongquan.setCreateBy(printInvoiceData.getCreateBy());
|
|
|
|
|
|
- if(printInvoiceData.getCreateDate()!=null){
|
|
|
+ if (printInvoiceData.getCreateDate() != null) {
|
|
|
printDataLongquan.setCreateDate(printInvoiceData.getCreateDate());
|
|
|
printDataLongquan.setPaydate(df.format(printInvoiceData.getCreateDate()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printDataLongquan.setCreateDate(LocalDateTime.now());
|
|
|
printDataLongquan.setPaydate(df.format(LocalDateTime.now()));
|
|
|
}
|
|
|
- if(payInvoiceReceivable != null && payInvoiceReceivable.getApprovetime() != null){
|
|
|
+ if (payInvoiceReceivable != null && payInvoiceReceivable.getApprovetime() != null) {
|
|
|
printDataLongquan.setApprovetime(payInvoiceReceivable.getApprovetime());
|
|
|
printDataLongquan.setApproveDate(df.format(payInvoiceReceivable.getApprovetime()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printDataLongquan.setApprovetime(LocalDateTime.now());
|
|
|
printDataLongquan.setApproveDate(df.format(LocalDateTime.now()));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new ServiceException(ResultStatus.OPERATE_RECORD_NOT_EXIT);
|
|
|
}
|
|
|
printDataLongquan.setPrintType(1);
|
|
|
printDataLongquan.setPayseriesno(payseriesno);
|
|
|
printDataLongquan.setInvoiceNo(
|
|
|
- DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
|
|
|
+ DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()) + "" + (int) (Math.random() * 1000));
|
|
|
return printDataLongquan;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 打印收据——缴纳欠费(transtype == null || (transtype ==2 ||transtype ==4))
|
|
|
+ *
|
|
|
* @param payseriesno
|
|
|
* @return
|
|
|
*/
|
|
|
- public PrintInvoiceData getPrintDataOfReceived(String payseriesno){
|
|
|
- LoginUser loginUser=UserUtil.getCurrentUser();
|
|
|
+ public PrintInvoiceData getPrintDataOfReceived(String payseriesno) {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
//收费区间信息和抄表信息
|
|
|
- PrintInvoiceData printInvoiceData=payInvoiceMapper.getDateRangeInfoPrint(payseriesno);
|
|
|
+ PrintInvoiceData printInvoiceData = payInvoiceMapper.getDateRangeInfoPrint(payseriesno);
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- if(printInvoiceData.getCreateDate()!=null){
|
|
|
+ if (printInvoiceData.getCreateDate() != null) {
|
|
|
printInvoiceData.setPaydate(df.format(printInvoiceData.getCreateDate()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printInvoiceData.setPaydate(df.format(LocalDateTime.now()));
|
|
|
}
|
|
|
printInvoiceData.setDateRange(
|
|
|
- printInvoiceData.getMaxPeriod()/12+""+String.format("%02d",printInvoiceData.getMaxPeriod()%12)+"——"+
|
|
|
- printInvoiceData.getMinPeriod()/12+""+String.format("%02d",printInvoiceData.getMinPeriod()%12) );
|
|
|
+ printInvoiceData.getMaxPeriod() / 12 + "" + String.format("%02d", printInvoiceData.getMaxPeriod() % 12) + "——" +
|
|
|
+ printInvoiceData.getMinPeriod() / 12 + "" + String.format("%02d", printInvoiceData.getMinPeriod() % 12));
|
|
|
|
|
|
|
|
|
//缴费用户信息
|
|
|
- PrintInvoiceData accountInfoPrint =payInvoiceMapper.getAccountInfoPrint(printInvoiceData.getAccountId());
|
|
|
+ PrintInvoiceData accountInfoPrint = payInvoiceMapper.getAccountInfoPrint(printInvoiceData.getAccountId());
|
|
|
printInvoiceData.setAccountname(accountInfoPrint.getAccountname());
|
|
|
printInvoiceData.setAccountnumber(accountInfoPrint.getAccountnumber());
|
|
|
printInvoiceData.setAddress(accountInfoPrint.getAddress());
|
|
|
printInvoiceData.setRemaining(accountInfoPrint.getRemaining());
|
|
|
|
|
|
//余额信息(/*--交易前后余额(先按批次号查询,没有再查询交易后第一条记录,还有没有就取预存账户余额)*/)
|
|
|
- PrintInvoiceData payfeeRemainingPrint= payInvoiceMapper.getPayfeeRemainingPrint(printInvoiceData.getAccountId(),null,payseriesno);
|
|
|
- if(payfeeRemainingPrint !=null && payfeeRemainingPrint.getRemaining() != null){
|
|
|
+ PrintInvoiceData payfeeRemainingPrint = payInvoiceMapper.getPayfeeRemainingPrint(printInvoiceData.getAccountId(), null, payseriesno);
|
|
|
+ if (payfeeRemainingPrint != null && payfeeRemainingPrint.getRemaining() != null) {
|
|
|
printInvoiceData.setRemaining(payfeeRemainingPrint.getRemaining());
|
|
|
printInvoiceData.setLastRemaining(payfeeRemainingPrint.getLastRemaining());
|
|
|
- }else{
|
|
|
- payfeeRemainingPrint= payInvoiceMapper.getPayfeeRemainingPrint(printInvoiceData.getAccountId(),printInvoiceData.getMaxPeriod(),null);
|
|
|
- if(payfeeRemainingPrint !=null && payfeeRemainingPrint.getRemaining() != null){
|
|
|
+ } else {
|
|
|
+ payfeeRemainingPrint = payInvoiceMapper.getPayfeeRemainingPrint(printInvoiceData.getAccountId(), printInvoiceData.getMaxPeriod(), null);
|
|
|
+ if (payfeeRemainingPrint != null && payfeeRemainingPrint.getRemaining() != null) {
|
|
|
printInvoiceData.setRemaining(payfeeRemainingPrint.getRemaining());
|
|
|
printInvoiceData.setLastRemaining(payfeeRemainingPrint.getRemaining());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
printInvoiceData.setLastRemaining(printInvoiceData.getRemaining());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//收费信息
|
|
|
- List<PrintReceivedInfo> payfeeInfoPrint = payInvoiceMapper.getPayfeeInfoPrint(printInvoiceData.getMinPeriod(),printInvoiceData.getMaxPeriod(),printInvoiceData.getAccountId());
|
|
|
+ List<PrintReceivedInfo> payfeeInfoPrint = payInvoiceMapper.getPayfeeInfoPrint(printInvoiceData.getMinPeriod(), printInvoiceData.getMaxPeriod(), printInvoiceData.getAccountId());
|
|
|
|
|
|
|
|
|
- BigDecimal receivedFee=BigDecimal.ZERO;
|
|
|
- BigDecimal debt=BigDecimal.ZERO;//缴纳的欠费
|
|
|
- BigDecimal autoReceivedamount=BigDecimal.ZERO;//划扣的欠费
|
|
|
+ BigDecimal receivedFee = BigDecimal.ZERO;
|
|
|
+ BigDecimal debt = BigDecimal.ZERO;//缴纳的欠费
|
|
|
+ BigDecimal autoReceivedamount = BigDecimal.ZERO;//划扣的欠费
|
|
|
//计算出缴纳的欠费金额
|
|
|
- for(PrintReceivedInfo receivedInfo:payfeeInfoPrint){
|
|
|
- debt=debt.add(receivedInfo.getReceivedamount());
|
|
|
- autoReceivedamount=autoReceivedamount.add(receivedInfo.getAutoReceivedamount());
|
|
|
+ for (PrintReceivedInfo receivedInfo : payfeeInfoPrint) {
|
|
|
+ debt = debt.add(receivedInfo.getReceivedamount());
|
|
|
+ autoReceivedamount = autoReceivedamount.add(receivedInfo.getAutoReceivedamount());
|
|
|
}
|
|
|
//计算出实收金额
|
|
|
- receivedFee= debt.add(autoReceivedamount).add(printInvoiceData.getRemaining()).subtract(printInvoiceData.getLastRemaining());
|
|
|
+ receivedFee = debt.add(autoReceivedamount).add(printInvoiceData.getRemaining()).subtract(printInvoiceData.getLastRemaining());
|
|
|
printInvoiceData.setReceivablefee(debt);
|
|
|
printInvoiceData.setTransamount(receivedFee);
|
|
|
printInvoiceData.setPrintReceivedInfo(payfeeInfoPrint);
|
|
|
printInvoiceData.setInvoiceNo(
|
|
|
- DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
|
|
|
+ DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()) + "" + (int) (Math.random() * 1000));
|
|
|
printInvoiceData.setPrintType(2);
|
|
|
printInvoiceData.setPayseriesno(payseriesno);
|
|
|
return printInvoiceData;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public String findPayseriesnoByPrint(BigInteger id,Integer type){
|
|
|
- return payInvoiceMapper.findPayseriesnoByPrint(id,type);
|
|
|
+ public String findPayseriesnoByPrint(BigInteger id, Integer type) {
|
|
|
+ return payInvoiceMapper.findPayseriesnoByPrint(id, type);
|
|
|
}
|
|
|
|
|
|
- public void cancelPrintInfo(BigInteger id){
|
|
|
- LoginUser loginUser=UserUtil.getCurrentUser();
|
|
|
+ public void cancelPrintInfo(BigInteger id) {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
payInvoiceMapper.deleteTransPrint(id);
|
|
|
payInvoiceMapper.deleteReceivedPrint(id);
|
|
|
- payInvoiceMapper.cancelPayInvoice(id,LocalDateTime.now(),BigInteger.valueOf(loginUser.getId()));
|
|
|
+ payInvoiceMapper.cancelPayInvoice(id, LocalDateTime.now(), BigInteger.valueOf(loginUser.getId()));
|
|
|
}
|
|
|
|
|
|
- public PrintInvoiceData getPayInvoiceType(String payseriesno){
|
|
|
+ public PrintInvoiceData getPayInvoiceType(String payseriesno) {
|
|
|
return payInvoiceMapper.getPayInvoiceType(payseriesno);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|