|
@@ -12,12 +12,14 @@ import com.bz.smart_city.dto.LoginUser;
|
|
|
import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
|
|
|
import com.bz.smart_city.dto.pay.PayBaseConfigDto;
|
|
|
import com.bz.smart_city.entity.pay.PayAccountSurvey;
|
|
|
+import com.bz.smart_city.entity.pay.PayTransactionSurvey;
|
|
|
import com.bz.smart_city.service.pay.BaseClosingAccountInfoService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -125,16 +127,20 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
|
|
|
int state = list.get(i).getState();
|
|
|
if(state == 1){
|
|
|
//把历史结账数据存进去,但不包含本期未结账的
|
|
|
- this.insertAccountNumber(list.get(i).getYear(),list.get(i).getMonth());
|
|
|
+ //this.insertAccountNumber(list.get(i).getYear(),list.get(i).getMonth());
|
|
|
+ //历史交易数据
|
|
|
+ this.insertTransaction(list.get(i).getYear(),list.get(i).getMonth());
|
|
|
}
|
|
|
}
|
|
|
}else if(count > 0){
|
|
|
//存储本期未结账数据
|
|
|
- this.insertAccountNumber(year,month);
|
|
|
+ //this.insertAccountNumber(year,month);
|
|
|
+ //本期交易未结账数据
|
|
|
+ this.insertTransaction(year,month);
|
|
|
}
|
|
|
|
|
|
// 更新本账期
|
|
|
- String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
|
|
|
+ /*String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
|
|
|
baseClosingAccountInfoDto.setEndTime(new Date());
|
|
|
baseClosingAccountInfoDto.setRemarks(msg2);
|
|
|
baseClosingAccountInfoDto.setState(1);
|
|
@@ -158,7 +164,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
|
|
|
baseClosingAccountInfoDto.setMonth(1);
|
|
|
}
|
|
|
baseClosingAccountInfoDto.setName(baseClosingAccountInfoDto.getYear()+"年"+String.format("%02d", baseClosingAccountInfoDto.getMonth())+"月");
|
|
|
- this.add(baseClosingAccountInfoDto);
|
|
|
+ this.add(baseClosingAccountInfoDto);*/
|
|
|
}else{
|
|
|
message.setStatus(-707);
|
|
|
message.setMsg(msg);
|
|
@@ -168,6 +174,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
|
|
|
return message;
|
|
|
}
|
|
|
|
|
|
+ //添加客户概况信息
|
|
|
public void insertAccountNumber(Integer year,Integer month){
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
|
|
@@ -177,57 +184,173 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
|
|
|
//查询上月总数
|
|
|
Integer lastYear = null;
|
|
|
Integer lastMonth = null;
|
|
|
- if(month == 1){
|
|
|
- lastYear = year-1;
|
|
|
- lastMonth = 12;
|
|
|
- }else{
|
|
|
- lastYear = year;
|
|
|
- lastMonth = month -1;
|
|
|
+ try {
|
|
|
+ if(month == 1){
|
|
|
+ lastYear = year-1;
|
|
|
+ lastMonth = 12;
|
|
|
+ }else{
|
|
|
+ lastYear = year;
|
|
|
+ lastMonth = month -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据账期查找历史客户数(仅统计状态为欠费与正常的客户总数之和)
|
|
|
+ Integer accountNumber = payChargeSurveyMapper.getAccountNumber
|
|
|
+ (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+ //根据账期查找历史水表数(仅统计状态为已开户的水表总数)
|
|
|
+ Integer meterNumber = payChargeSurveyMapper.getMeterNumber
|
|
|
+ (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+ //根据账期查找历史开户数(仅统计状态为正常的开户总数)
|
|
|
+ Integer customerNumber = payChargeSurveyMapper.getCustomerNumber
|
|
|
+ (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+
|
|
|
+ //上一账期汇总
|
|
|
+ PayAccountSurvey lastAccount = payChargeSurveyMapper.getlastNumber(lastYear,lastMonth,
|
|
|
+ BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+
|
|
|
+ PayAccountSurvey account = new PayAccountSurvey();
|
|
|
+ if(lastAccount != null){
|
|
|
+ //上月总数赋值
|
|
|
+ account.setLastAccountNumber(lastAccount.getAccountNumber() != null ? lastAccount.getAccountNumber() : 0);
|
|
|
+ account.setLastMeterNumber(lastAccount.getMeterNumber() != null ? lastAccount.getMeterNumber() : 0);
|
|
|
+ account.setLastCustomerNumber(lastAccount.getCustomerNumber() != null ? lastAccount.getCustomerNumber() : 0);
|
|
|
+ }else{
|
|
|
+ account.setLastAccountNumber( 0);
|
|
|
+ account.setLastMeterNumber( 0);
|
|
|
+ account.setLastCustomerNumber( 0);
|
|
|
+ }
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime ldt = LocalDateTime.parse(start+" 00:00:00",df);
|
|
|
+ account.setPeriodDate(ldt);
|
|
|
+ account.setId(Util.createUUIDId());
|
|
|
+ account.setAccountNumber(accountNumber);
|
|
|
+ account.setMeterNumber(meterNumber);
|
|
|
+ account.setCustomerNumber(customerNumber);
|
|
|
+ account.setYear(year);
|
|
|
+ account.setMonth(month);
|
|
|
+ account.setDelFlag("0");
|
|
|
+ account.setRemarks("");
|
|
|
+ account.setCreateBy(loginUser.getCreateBy());
|
|
|
+ account.setCreateDate(LocalDateTime.now());
|
|
|
+ account.setUpdateBy(loginUser.getCreateBy());
|
|
|
+ account.setUpdateDate(LocalDateTime.now());
|
|
|
+ account.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
+ account.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+ //保存记录
|
|
|
+ payChargeSurveyMapper.insertAccountNumber(account);
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //根据账期查找历史客户数(仅统计状态为欠费与正常的客户总数之和)
|
|
|
- Integer accountNumber = payChargeSurveyMapper.getAccountNumber
|
|
|
- (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
- //根据账期查找历史水表数(仅统计状态为已开户的水表总数)
|
|
|
- Integer meterNumber = payChargeSurveyMapper.getMeterNumber
|
|
|
- (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
- //根据账期查找历史开户数(仅统计状态为正常的开户总数)
|
|
|
- Integer customerNumber = payChargeSurveyMapper.getCustomerNumber
|
|
|
- (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
-
|
|
|
- PayAccountSurvey lastAccount = payChargeSurveyMapper.getlastNumber(lastYear,lastMonth,
|
|
|
- BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
-
|
|
|
- PayAccountSurvey account = new PayAccountSurvey();
|
|
|
- if(lastAccount != null){
|
|
|
- //上月总数赋值
|
|
|
- account.setLastAccountNumber(lastAccount.getAccountNumber() != null ? lastAccount.getAccountNumber() : 0);
|
|
|
- account.setLastMeterNumber(lastAccount.getMeterNumber() != null ? lastAccount.getMeterNumber() : 0);
|
|
|
- account.setLastCustomerNumber(lastAccount.getCustomerNumber() != null ? lastAccount.getCustomerNumber() : 0);
|
|
|
- }else{
|
|
|
- account.setLastAccountNumber( 0);
|
|
|
- account.setLastMeterNumber( 0);
|
|
|
- account.setLastCustomerNumber( 0);
|
|
|
+ /**
|
|
|
+ * 添加交易汇总数据
|
|
|
+ * @param year
|
|
|
+ * @param month
|
|
|
+ */
|
|
|
+ public void insertTransaction(Integer year,Integer month){
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
|
|
|
+ BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
|
|
|
+ String start = year+"-"+(String.format("%02d",month))+"-01";
|
|
|
+ String end = year+"-"+(String.format("%02d",month))+"-31";
|
|
|
+ //查询上月总数
|
|
|
+ Integer lastYear = null;
|
|
|
+ Integer lastMonth = null;
|
|
|
+
|
|
|
+ PayTransactionSurvey transactionSurver= new PayTransactionSurvey();
|
|
|
+ try {
|
|
|
+ if(month == 1){
|
|
|
+ lastYear = year-1;
|
|
|
+ lastMonth = 12;
|
|
|
+ }else{
|
|
|
+ lastYear = year;
|
|
|
+ lastMonth = month -1;
|
|
|
+ }
|
|
|
+ //根据账期查找历史数据(现金、微信支付、支付宝、银行)
|
|
|
+ BigDecimal bigDecimalStr = new BigDecimal("0.0");
|
|
|
+ BigDecimal cuttentAmount = payChargeSurveyMapper.getCurrentTran(year,month,siteId,customerId);
|
|
|
+ cuttentAmount = cuttentAmount != null ? cuttentAmount : bigDecimalStr;
|
|
|
+ //上一账期
|
|
|
+ BigDecimal lastAmount = payChargeSurveyMapper.getCurrentTran(lastYear,lastMonth,siteId,customerId);
|
|
|
+ lastAmount = lastAmount != null ? lastAmount : bigDecimalStr;
|
|
|
+ //当前账期按支付方式划分
|
|
|
+ List<PayTransactionSurvey> tranList = payChargeSurveyMapper.getPayAmountList(year,month,siteId,customerId);
|
|
|
+ //上一账期按支付方式划分
|
|
|
+ List<PayTransactionSurvey> lasttranList = payChargeSurveyMapper.getPayAmountList(lastYear,lastMonth,siteId,customerId);
|
|
|
+
|
|
|
+ transactionSurver.setIncomeNumber(cuttentAmount);
|
|
|
+ transactionSurver.setLastIncomeNumber(lastAmount);
|
|
|
+ BigDecimal cashIncome = bigDecimalStr;//现金
|
|
|
+ BigDecimal wechatIncome = bigDecimalStr;//微信
|
|
|
+ BigDecimal alipayIncome = bigDecimalStr;//支付宝
|
|
|
+ BigDecimal bankIncome = bigDecimalStr;//银行
|
|
|
+ //当前账期
|
|
|
+ for(int i=0; i<tranList.size(); i++){
|
|
|
+ Integer payway = tranList.get(i).getPayway();
|
|
|
+ if(payway == 1){
|
|
|
+ //支付宝
|
|
|
+ alipayIncome = tranList.get(i).getIncomeNumber();
|
|
|
+ }else if(payway == 2){
|
|
|
+ //微信
|
|
|
+ wechatIncome = tranList.get(i).getIncomeNumber();
|
|
|
+ }else if (payway == 3) {
|
|
|
+ //银行
|
|
|
+ bankIncome = tranList.get(i).getIncomeNumber();
|
|
|
+ }else if (payway == 4) {
|
|
|
+ //现金
|
|
|
+ cashIncome = tranList.get(i).getIncomeNumber();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ transactionSurver.setAlipayIncome(alipayIncome);
|
|
|
+ transactionSurver.setWechatIncome(wechatIncome);
|
|
|
+ transactionSurver.setBankIncome(bankIncome);
|
|
|
+ transactionSurver.setCashIncome(cashIncome);
|
|
|
+ BigDecimal lastAlipayIncome = bigDecimalStr;
|
|
|
+ BigDecimal lastWechatIncome = bigDecimalStr;
|
|
|
+ BigDecimal lastBankIncome = bigDecimalStr;
|
|
|
+ BigDecimal lastCashIncome = bigDecimalStr;
|
|
|
+ //上一账期
|
|
|
+ for(int i=0; i<lasttranList.size(); i++){
|
|
|
+ Integer payway = lasttranList.get(i).getPayway();
|
|
|
+ if(payway == 1){
|
|
|
+ //支付宝
|
|
|
+ lastAlipayIncome = lasttranList.get(i).getIncomeNumber();
|
|
|
+ }else if(payway == 2){
|
|
|
+ //微信
|
|
|
+ lastWechatIncome = lasttranList.get(i).getIncomeNumber();
|
|
|
+ }else if (payway == 3) {
|
|
|
+ //银行
|
|
|
+ lastBankIncome = lasttranList.get(i).getIncomeNumber();
|
|
|
+ }else if (payway == 4) {
|
|
|
+ //现金
|
|
|
+ lastCashIncome = lasttranList.get(i).getIncomeNumber();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ transactionSurver.setLastAlipayIncome(lastCashIncome);
|
|
|
+ transactionSurver.setLastWechatIncome(lastWechatIncome);
|
|
|
+ transactionSurver.setLastBankIncome(lastBankIncome);
|
|
|
+ transactionSurver.setLastCashIncome(lastCashIncome);
|
|
|
+
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime ldt = LocalDateTime.parse(start+" 00:00:00",df);
|
|
|
+ transactionSurver.setPeriodDate(ldt);
|
|
|
+ transactionSurver.setId(Util.createUUIDId());
|
|
|
+ transactionSurver.setYear(year);
|
|
|
+ transactionSurver.setMonth(month);
|
|
|
+ transactionSurver.setDelFlag("0");
|
|
|
+ transactionSurver.setRemarks("");
|
|
|
+ transactionSurver.setCreateBy(loginUser.getCreateBy());
|
|
|
+ transactionSurver.setCreateDate(LocalDateTime.now());
|
|
|
+ transactionSurver.setUpdateBy(loginUser.getCreateBy());
|
|
|
+ transactionSurver.setUpdateDate(LocalDateTime.now());
|
|
|
+ transactionSurver.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
+ transactionSurver.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+
|
|
|
+ payChargeSurveyMapper.insertTransaction(transactionSurver);
|
|
|
+
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- LocalDateTime ldt = LocalDateTime.parse(start+" 00:00:00",df);
|
|
|
- account.setPeriodDate(ldt);
|
|
|
- account.setId(Util.createUUIDId());
|
|
|
- account.setAccountNumber(accountNumber);
|
|
|
- account.setMeterNumber(meterNumber);
|
|
|
- account.setCustomerNumber(customerNumber);
|
|
|
- account.setYear(year);
|
|
|
- account.setMonth(month);
|
|
|
- account.setDelFlag("0");
|
|
|
- account.setRemarks("");
|
|
|
- account.setCreateBy(loginUser.getCreateBy());
|
|
|
- account.setCreateDate(LocalDateTime.now());
|
|
|
- account.setUpdateBy(loginUser.getCreateBy());
|
|
|
- account.setUpdateDate(LocalDateTime.now());
|
|
|
- account.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
- account.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
- //保存记录
|
|
|
- payChargeSurveyMapper.insertAccountNumber(account);
|
|
|
}
|
|
|
|
|
|
@Override
|