Просмотр исходного кода

[账单导入][修改][付款日期非必填,付款金额大于0才创建缴款记录]

release_toaliyun_real
gongbiao 6 лет назад
Родитель
Сommit
f0cb0fc209
5 измененных файлов: 329 добавлений и 114 удалений
  1. +18
    -12
      mallinkAdmin/src/main/java/com/iformall/controller/mem/ImportTemplateTask.java
  2. +160
    -0
      mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java
  3. +2
    -1
      mallinkService/src/main/java/com/iformall/domain/vo/WxBillExcelTemplateOther.java
  4. +37
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumPowerBillBuildWay.java
  5. +112
    -101
      mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java

+ 18
- 12
mallinkAdmin/src/main/java/com/iformall/controller/mem/ImportTemplateTask.java Просмотреть файл

@@ -26,6 +26,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.File;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -153,7 +154,7 @@ public class ImportTemplateTask {
public void importBillDataOther(File file, MallUserInfo user, String importKey, String tenantId) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"商户名*", "费用类型*", "费用名称*", "费用所属期-开始时间*", "费用所属期-结束时间*", "实际应收金额(元)*", "收款金额(元)*", "收款日期*", "截止缴款日*", "收款方式"});
params.setImportFields(new String[]{"商户名*", "费用类型*", "费用名称*", "费用所属期-开始时间*", "费用所属期-结束时间*", "实际应收金额(元)*", "收款金额(元)*", "收款日期", "截止缴款日*", "收款方式"});
params.setNeedVerify(true);

ExcelImportResult<WxBillExcelTemplateOther> datalist = null;
@@ -199,19 +200,24 @@ public class ImportTemplateTask {
//3 计失败条数
List<WxBillExcelTemplateOther> billSuccessList = new ArrayList<>();
successList.parallelStream().forEach(s -> {
if (StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType()
boolean flag = StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType()
&& StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime()
&& null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr())
&& null != s.getPayDate() && null != s.getReceiveDate()
&& StringUtils.isNotEmpty(s.getReceivePayStr())) {
WxMerchant wxMerchant = merchantMap.get(s.getMerchantName());
if (wxMerchant != null) {
Long merchantId = wxMerchant.getId();
if (merchantId != null) {
s.setMerchantId(merchantId);
Integer type = wxMerchant.getType();
s.setMerchantType(type);
billSuccessList.add(s);
&& null != s.getReceiveDate() && StringUtils.isNotEmpty(s.getReceivePayStr());
if (flag) {
double pay = new BigDecimal(s.getPayStr()).doubleValue();
//付款大于0且付款日期不为空说明是更新账单 或者 付款为0且付款日期为空是新增账单 满足其一即可继续
flag = (pay > 0 && null != s.getPayDate()) || (pay == 0 && null == s.getPayDate());
if (flag) {
WxMerchant wxMerchant = merchantMap.get(s.getMerchantName());
if (wxMerchant != null) {
Long merchantId = wxMerchant.getId();
if (merchantId != null) {
s.setMerchantId(merchantId);
Integer type = wxMerchant.getType();
s.setMerchantType(type);
billSuccessList.add(s);
}
}
}
}


+ 160
- 0
mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java Просмотреть файл

@@ -0,0 +1,160 @@
package com.iformall.schedule;

import com.alibaba.fastjson.JSONObject;
import com.iformall.domain.po.*;
import com.iformall.enums.EnumBillDailyType;
import com.iformall.enums.EnumBillPayWay;
import com.iformall.enums.EnumDelStatus;
import com.iformall.enums.EnumPowerBillBuildWay;
import com.iformall.mapper.WxMerchantPowerBillConfigMapper;
import com.iformall.mapper.WxMerchantShopMapper;
import com.iformall.mapper.WxPowerBillAutoConfigMapper;
import com.iformall.service.WxBillDailyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author gongbiao
*/
@Component
public class PowerBillAutoBuildSchedule {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxPowerBillAutoConfigMapper wxPowerBillAutoConfigMapper;

@Autowired
private WxMerchantPowerBillConfigMapper wxMerchantPowerBillConfigMapper;

@Autowired
private WxBillDailyService wxBillDailyService;

@Autowired
private WxMerchantShopMapper wxMerchantShopMapper;

/**
* 每天5点执行
*/
@Scheduled(cron = "0 0 5 * * ?")
public void powerBillAutoConfigStart() {
logger.info("自动生成电费账单开始....");
int dayOfMonth = LocalDate.now().getDayOfMonth();
List<WxPowerBillAutoConfig> wxPowerBillAutoConfigs = wxPowerBillAutoConfigMapper.selectAll();
for (int i = 0; i < wxPowerBillAutoConfigs.size(); i++) {
WxPowerBillAutoConfig wxPowerBillAutoConfig = wxPowerBillAutoConfigs.get(i);
if (wxPowerBillAutoConfig.getBuildDay().equals(dayOfMonth)) {
merchantPowerBillConfigStart(wxPowerBillAutoConfig);
}
}
logger.info("自动生成电费账单结束....");
}

private void merchantPowerBillConfigStart(WxPowerBillAutoConfig wxPowerBillAutoConfig) {
WxMerchantPowerBillConfig wxMerchantPowerBillConfig = new WxMerchantPowerBillConfig();
wxMerchantPowerBillConfig.setTenantId(wxPowerBillAutoConfig.getTenantId());
List<WxMerchantPowerBillConfig> wxMerchantPowerBillConfigs = wxMerchantPowerBillConfigMapper.select(wxMerchantPowerBillConfig);
for (int i = 0; i < wxMerchantPowerBillConfigs.size(); i++) {
buildPowerBill(wxMerchantPowerBillConfigs.get(i), wxPowerBillAutoConfig);
}
}

private void buildPowerBill(WxMerchantPowerBillConfig wxMerchantPowerBillConfig, WxPowerBillAutoConfig wxPowerBillAutoConfig) {

String unitPrice = wxPowerBillAutoConfig.getUnitPrice();
Date startdate = getLastMonthDate().get("startdate");
Date enddate = getLastMonthDate().get("enddate");
MallUserInfo mallUserInfo = getMallUserInfo();
WxBillDaily wxBillDaily = getBillDaily(wxMerchantPowerBillConfig);
JSONObject priceDetal = new JSONObject();
Date receiveDate = getReceiveDate(Integer.parseInt(wxPowerBillAutoConfig.getReceiveDay()));
if (wxMerchantPowerBillConfig.getBuildWay().equals(EnumPowerBillBuildWay.METER.getCode())) {
//根据日期拉取电量 单价 * 电量 = 电费

} else {
String price = wxMerchantPowerBillConfig.getPrice();
priceDetal.put("unitPrice", unitPrice);
priceDetal.put("power", 0);
long receivePay = new BigDecimal(price).multiply(new BigDecimal(100)).longValue();
wxBillDaily.setReceivePay(receivePay);
wxBillDaily.setNeedPay(receivePay);
}

wxBillDaily.setReceiveDate(receiveDate);
wxBillDaily.setStarttime(startdate);
wxBillDaily.setEndtime(enddate);
wxBillDaily.setPriceDetail(priceDetal.toJSONString());
wxBillDailyService.saveOrUpdate(wxBillDaily, mallUserInfo);

}

private WxBillDaily getBillDaily(WxMerchantPowerBillConfig wxMerchantPowerBillConfig) {
WxBillDaily wxBillDaily = new WxBillDaily();
Long merchantId = wxMerchantPowerBillConfig.getMerchantId();
wxBillDaily.setShopId(getShopId(merchantId));
wxBillDaily.setTenantId(wxMerchantPowerBillConfig.getTenantId());
wxBillDaily.setMerchantId(merchantId);
wxBillDaily.setMerchantName(wxMerchantPowerBillConfig.getMerchantName());
wxBillDaily.setType(EnumBillDailyType.POWER.getCode());
wxBillDaily.setRentShopType(wxMerchantPowerBillConfig.getMerchantType());
wxBillDaily.setPay(0L);
wxBillDaily.setPayWay(EnumBillPayWay.OTHER.getCode());
return wxBillDaily;
}

private Map<String, Date> getLastMonthDate() {
ZoneId zoneId = ZoneOffset.systemDefault();
LocalDate now = LocalDate.now().minusMonths(1L);
now = now.with(TemporalAdjusters.firstDayOfMonth());
Instant start = now.atStartOfDay().atZone(zoneId).toInstant();
Date first = Date.from(start);
now = now.with(TemporalAdjusters.lastDayOfMonth());
Instant end = now.atStartOfDay().atZone(zoneId).toInstant();
Date last = Date.from(end);
Map<String, Date> dateMap = new HashMap<>(2);
dateMap.put("startdate", first);
dateMap.put("enddate", last);
return dateMap;
}

private Date getReceiveDate(Integer day) {
ZoneId zoneId = ZoneOffset.systemDefault();
LocalDate of = LocalDate.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), day);
Instant instant = of.atStartOfDay().atZone(zoneId).toInstant();
return Date.from(instant);
}

private Long getShopId(Long merchantId) {
WxMerchantShop wxMerchantShop = new WxMerchantShop();
wxMerchantShop.setMerchantId(merchantId);
wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode());
List<WxMerchantShop> select = wxMerchantShopMapper.select(wxMerchantShop);
if (!select.isEmpty()) {
return select.get(0).getShopId();
}
return 0L;
}

private MallUserInfo getMallUserInfo() {
MallUserInfo mallUserInfo = new MallUserInfo();
mallUserInfo.setId(0L);
mallUserInfo.setName("系统生成");
mallUserInfo.setPhone("0");
return mallUserInfo;
}

}

+ 2
- 1
mallinkService/src/main/java/com/iformall/domain/vo/WxBillExcelTemplateOther.java Просмотреть файл

@@ -25,13 +25,14 @@ public class WxBillExcelTemplateOther {

@Excel(name = "费用所属期-结束时间*", width = 20, orderNum = "5", format = "yyyy-MM-dd")
private Date endtime;

@Excel(name = "实际应收金额(元)*", width = 20, orderNum = "6")
private String receivePayStr;

@Excel(name = "收款金额(元)*", width = 20, orderNum = "7")
private String payStr;

@Excel(name = "收款日期*", width = 20, orderNum = "8", format = "yyyy-MM-dd")
@Excel(name = "收款日期", width = 20, orderNum = "8", format = "yyyy-MM-dd")
private Date payDate;

@Excel(name = "截止缴款日*", width = 20, orderNum = "9", format = "yyyy-MM-dd")


+ 37
- 0
mallinkService/src/main/java/com/iformall/enums/EnumPowerBillBuildWay.java Просмотреть файл

@@ -0,0 +1,37 @@
package com.iformall.enums;


/**
* @author gongbiao
*/

public enum EnumPowerBillBuildWay {

METER(1, "按电表"),
PRICE(2, "按固定金额"),;

public static EnumPowerBillBuildWay getEnum(Integer code) {
for (EnumPowerBillBuildWay value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumPowerBillBuildWay(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 112
- 101
mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java Просмотреть файл

@@ -182,40 +182,40 @@ public class WxBillAllServiceImpl implements WxBillAllService {
public void updateBill(Map<String, Object> bill) {
int billTypeValue = ((Long) bill.get("billTypeValue")).intValue();
logger.info(">>>>>>>>>>>>>>>>>>>>账单回调修改数据:" + JSONObject.toJSONString(bill));
if (billTypeValue==EnumBillTypeParam.RENT.getCode().intValue()) {
if (billTypeValue == EnumBillTypeParam.RENT.getCode().intValue()) {
logger.info("更新租金账单");
WxBillRent billRent = wxBillRentMapper.selectByPrimaryKey(bill.get("id"));
if(billRent!=null && !billRent.getStatus().equals(EnumBillRentStatus.PAID.getCode())){
if (billRent != null && !billRent.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillRent(bill);
}
} else if (billTypeValue==EnumBillTypeParam.RENT_DEPOSIT.getCode().intValue()) {
} else if (billTypeValue == EnumBillTypeParam.RENT_DEPOSIT.getCode().intValue()) {
logger.info("更新租金押金账单");
WxBillDeposit billDeposit = wxBillDepositMapper.selectByPrimaryKey(bill.get("id"));
if(billDeposit!=null && !billDeposit.getStatus().equals(EnumBillRentStatus.PAID.getCode())){
if (billDeposit != null && !billDeposit.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillRentDeposit(bill);
}
} else if (billTypeValue==EnumBillTypeParam.PROPERTY.getCode().intValue()) {
} else if (billTypeValue == EnumBillTypeParam.PROPERTY.getCode().intValue()) {
logger.info("更新物业账单");
WxBillProperty property = wxBillPropertyMapper.selectByPrimaryKey(bill.get("id"));
if(property!=null && !property.getStatus().equals(EnumBillRentStatus.PAID.getCode())){
if (property != null && !property.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillProperty(bill);
}
} else if (billTypeValue==EnumBillTypeParam.PROPERTY_DEPOSIT.getCode().intValue()) {
} else if (billTypeValue == EnumBillTypeParam.PROPERTY_DEPOSIT.getCode().intValue()) {
logger.info("更新物业押金账单");
WxBillPropertyDeposit wxBillPropertyDeposit = wxBillPropertyDepositMapper.selectByPrimaryKey(bill.get("id"));
if(wxBillPropertyDeposit!=null && !wxBillPropertyDeposit.getStatus().equals(EnumBillRentStatus.PAID.getCode())){
if (wxBillPropertyDeposit != null && !wxBillPropertyDeposit.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillPropertyDeposit(bill);
}
} else if (billTypeValue==EnumBillTypeParam.WATER.getCode().intValue()) {
} else if (billTypeValue == EnumBillTypeParam.WATER.getCode().intValue()) {
logger.info("更新水费账单");
WxBillDaily wxBillDaily = wxBillDailyMapper.selectByPrimaryKey(bill.get("id"));
if(wxBillDaily!=null && !wxBillDaily.getStatus().equals(EnumBillRentStatus.PAID.getCode())){
if (wxBillDaily != null && !wxBillDaily.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillDaily(bill);
}
} else if (billTypeValue==EnumBillTypeParam.POWER.getCode().intValue()) {
} else if (billTypeValue == EnumBillTypeParam.POWER.getCode().intValue()) {
logger.info("更新电费账单");
WxBillDaily wxBillDaily = wxBillDailyMapper.selectByPrimaryKey(bill.get("id"));
if(wxBillDaily!=null && !wxBillDaily.getStatus().equals(EnumBillRentStatus.PAID.getCode())){
if (wxBillDaily != null && !wxBillDaily.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillDaily(bill);
}
} else if (billTypeValue == EnumBillTypeParam.AIR_CONDITIONING.getCode().intValue()) {
@@ -224,10 +224,10 @@ public class WxBillAllServiceImpl implements WxBillAllService {
if (wxBillDaily != null && !wxBillDaily.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillDaily(bill);
}
} else if (billTypeValue==EnumBillTypeParam.ROUTINE.getCode().intValue()) {
} else if (billTypeValue == EnumBillTypeParam.ROUTINE.getCode().intValue()) {
logger.info("更新其他账单");
WxBillOther wxBillOther = wxBillOtherMapper.selectByPrimaryKey(bill.get("id"));
if(wxBillOther!=null && !wxBillOther.getStatus().equals(EnumBillRentStatus.PAID.getCode())){
if (wxBillOther != null && !wxBillOther.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
updateBillOther(bill);
}
} else if (billTypeValue == EnumBillTypeParam.ATHER_DEPOSIT.getCode().intValue()) {
@@ -313,16 +313,16 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}

private int updateBillOther(Map<String, Object> bill) {
logger.info("updateBillOther params:"+bill.toString());
logger.info("updateBillOther params:" + bill.toString());
Object id = bill.get("id");
WxBillOther wxBillOther = wxBillOtherMapper.selectByPrimaryKey(id);
if(wxBillOther==null){
if (wxBillOther == null) {
return 0;
}
Date date = new Date();
wxBillOther.setPayDate(date);
Long owe = (Long) bill.get("owe");
wxBillOther.setPay(wxBillOther.getPay()+owe);
wxBillOther.setPay(wxBillOther.getPay() + owe);
wxBillOther.setOwe(0L);
wxBillOther.setStatus(EnumBillDailyStatus.PAID.getCode());
wxBillOther.setPayDate(date);
@@ -357,16 +357,16 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}

private int updateBillDaily(Map<String, Object> bill) {
logger.info("updateBillDaily params:"+bill.toString());
logger.info("updateBillDaily params:" + bill.toString());
Object id = bill.get("id");
WxBillDaily wxBillDaily = wxBillDailyMapper.selectByPrimaryKey(id);
if(wxBillDaily==null){
if (wxBillDaily == null) {
return 0;
}
Date date = new Date();
wxBillDaily.setPayDate(date);
Long owe = (Long) bill.get("owe");
wxBillDaily.setPay(wxBillDaily.getPay()+owe);
wxBillDaily.setPay(wxBillDaily.getPay() + owe);
wxBillDaily.setOwe(0L);
wxBillDaily.setStatus(EnumBillDailyStatus.PAID.getCode());
wxBillDaily.setPayDate(date);
@@ -402,16 +402,16 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}

private int updateBillPropertyDeposit(Map<String, Object> bill) {
logger.info("updateBillPropertyDeposit params:"+bill.toString());
logger.info("updateBillPropertyDeposit params:" + bill.toString());
Object id = bill.get("id");
WxBillPropertyDeposit wxBillPropertyDeposit = wxBillPropertyDepositMapper.selectByPrimaryKey(id);
if(wxBillPropertyDeposit==null){
if (wxBillPropertyDeposit == null) {
return 0;
}
Date date = new Date();
wxBillPropertyDeposit.setPayDate(date);
Long owe = (Long) bill.get("owe");
wxBillPropertyDeposit.setPay(wxBillPropertyDeposit.getPay()+owe);
wxBillPropertyDeposit.setPay(wxBillPropertyDeposit.getPay() + owe);
wxBillPropertyDeposit.setOwe(0L);
wxBillPropertyDeposit.setStatus(EnumBillDailyStatus.PAID.getCode());
wxBillPropertyDeposit.setPayDate(date);
@@ -447,16 +447,16 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}

private int updateBillProperty(Map<String, Object> bill) {
logger.info("updateBillProperty params:"+bill.toString());
logger.info("updateBillProperty params:" + bill.toString());
Object id = bill.get("id");
WxBillProperty property = wxBillPropertyMapper.selectByPrimaryKey(id);
if(property==null){
if (property == null) {
return 0;
}
Date date = new Date();
property.setPayDate(date);
Long owe = (Long) bill.get("owe");
property.setPay(property.getPay()+owe);
property.setPay(property.getPay() + owe);
property.setOwe(0L);
property.setStatus(EnumBillDailyStatus.PAID.getCode());
property.setPayDate(date);
@@ -492,16 +492,16 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}

private int updateBillRentDeposit(Map<String, Object> bill) {
logger.info("updateBillRentDeposit params:"+bill.toString());
logger.info("updateBillRentDeposit params:" + bill.toString());
Object id = bill.get("id");
WxBillDeposit wxBillDeposit = wxBillDepositMapper.selectByPrimaryKey(id);
if(wxBillDeposit==null){
if (wxBillDeposit == null) {
return 0;
}
Date date = new Date();
wxBillDeposit.setPayDate(date);
Long owe = (Long) bill.get("owe");
wxBillDeposit.setPay(wxBillDeposit.getPay()+owe);
wxBillDeposit.setPay(wxBillDeposit.getPay() + owe);
wxBillDeposit.setOwe(0L);
wxBillDeposit.setStatus(EnumBillDailyStatus.PAID.getCode());
wxBillDeposit.setPayDate(date);
@@ -537,16 +537,16 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}

private int updateBillRent(Map<String, Object> bill) {
logger.info("updateBillRentDeposit params:"+bill.toString());
logger.info("updateBillRentDeposit params:" + bill.toString());
Object id = bill.get("id");
WxBillRent wxBillRent = wxBillRentMapper.selectByPrimaryKey(id);
if(wxBillRent==null){
if (wxBillRent == null) {
return 0;
}
Date date = new Date();
wxBillRent.setPayDate(date);
Long owe = (Long) bill.get("owe");
wxBillRent.setPay(wxBillRent.getPay()+owe);
wxBillRent.setPay(wxBillRent.getPay() + owe);
wxBillRent.setOwe(0L);
wxBillRent.setStatus(EnumBillDailyStatus.PAID.getCode());
wxBillRent.setPayDate(date);
@@ -781,11 +781,11 @@ public class WxBillAllServiceImpl implements WxBillAllService {
WxBillRent wxBillRent = new WxBillRent();
wxBillRent.setId(id);
wxBillRent.setUpdatetime(updateDate);
if(oldLatePrice != null){
if (oldLatePrice != null) {
wxBillRent.setLatePayPrice(newLatePrice);
wxBillRentMapper.updateByPrimaryKeySelective(wxBillRent);
addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY,id, oldLatePrice, newLatePrice, user);
}else{
addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user);
} else {
//租赁账单更新
wxBillRent.setReceivePay(newPrice);
wxBillRent.setOwe(newPrice - dbBill.getPay());
@@ -794,7 +794,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}
wxBillRentMapper.updateByPrimaryKeySelective(wxBillRent);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
}
} else if (billType.equals(EnumBillTypeParam.RENT_DEPOSIT.getCode())) {
WxBillDeposit dbBill = wxBillDepositMapper.selectByPrimaryKey(id);
@@ -809,18 +809,18 @@ public class WxBillAllServiceImpl implements WxBillAllService {
wxBillDeposit.setUpdatetime(updateDate);
wxBillDepositMapper.updateByPrimaryKeySelective(wxBillDeposit);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
} else if (billType.equals(EnumBillTypeParam.PROPERTY.getCode())) {
WxBillProperty dbBill = wxBillPropertyMapper.selectByPrimaryKey(id);
//物业账单更新
WxBillProperty wxBillProperty = new WxBillProperty();
wxBillProperty.setId(id);
wxBillProperty.setUpdatetime(updateDate);
if(oldLatePrice != null){
if (oldLatePrice != null) {
wxBillProperty.setLatePayPrice(newLatePrice);
wxBillPropertyMapper.updateByPrimaryKeySelective(wxBillProperty);
addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY,id, oldLatePrice, newLatePrice, user);
}else{
addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user);
} else {
wxBillProperty.setReceivePay(newPrice);
wxBillProperty.setOwe(newPrice - dbBill.getPay());
if (newPrice.equals(dbBill.getPay())) {
@@ -828,7 +828,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}
wxBillPropertyMapper.updateByPrimaryKeySelective(wxBillProperty);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
}
} else if (billType.equals(EnumBillTypeParam.PROPERTY_DEPOSIT.getCode())) {
WxBillPropertyDeposit dbBill = wxBillPropertyDepositMapper.selectByPrimaryKey(id);
@@ -843,22 +843,22 @@ public class WxBillAllServiceImpl implements WxBillAllService {
wxBillPropertyDeposit.setUpdatetime(updateDate);
wxBillPropertyDepositMapper.updateByPrimaryKeySelective(wxBillPropertyDeposit);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
} else if (billType.equals(EnumBillTypeParam.WATER.getCode())) {
//水费账单更新
updateDailyBill(id, newPrice, updateDate);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
} else if (billType.equals(EnumBillTypeParam.POWER.getCode())) {
//电费账单更新
updateDailyBill(id, newPrice, updateDate);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
} else if (billType.equals(EnumBillTypeParam.AIR_CONDITIONING.getCode())) {
//空调费账单更新
updateDailyBill(id, newPrice, updateDate);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
} else if (billType.equals(EnumBillTypeParam.ROUTINE.getCode())) {
WxBillOther dbBill = wxBillOtherMapper.selectByPrimaryKey(id);
//其他费用账单更新
@@ -872,7 +872,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
wxBillOther.setUpdatetime(updateDate);
wxBillOtherMapper.updateByPrimaryKeySelective(wxBillOther);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
} else if (billType.equals(EnumBillTypeParam.ATHER_DEPOSIT.getCode())) {
WxBillOtherDeposit dbBill = wxBillOtherDepositMapper.selectByPrimaryKey(id);
//其他押金账单更新
@@ -886,7 +886,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
wxBillOtherDeposit.setUpdatetime(updateDate);
wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillOtherDeposit);
//账单日志
addBillAction(EnumBillAction.UPDATE_BILL,id, oldPrice, newPrice, user);
addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user);
} else {
logger.info("未找到账单类型");
}
@@ -894,7 +894,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}

@Override
public void addBillAction(EnumBillAction billAction,Long billId, Long oldPrice, Long newPrice, MallUserInfo mallUserInfo) {
public void addBillAction(EnumBillAction billAction, Long billId, Long oldPrice, Long newPrice, MallUserInfo mallUserInfo) {
WxBillAction wxBillAction = new WxBillAction();
wxBillAction.setBillId(billId);
String oldPriceStr = new BigDecimal(oldPrice).divide(new BigDecimal(100)).toPlainString();
@@ -1035,7 +1035,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
dailyQuery.setReceiveDate(bill.getReceiveDate());
dailyQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode());
WxBillDaily daily = wxBillDailyMapper.selectOne(dailyQuery);
if (daily != null) {
if (daily != null && pay > 0) {
if (!daily.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
long allPay = new BigDecimal(daily.getPay()).add(new BigDecimal(pay)).longValueExact();
WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), receivePay, allPay, false);
@@ -1083,7 +1083,9 @@ public class WxBillAllServiceImpl implements WxBillAllService {
daily.setExpiredDay(expiredDayAndStatus.getExpiredDay());
daily.setStatus(expiredDayAndStatus.getStatus());
wxBillDailyMapper.insertSelective(daily);
addActionImport(daily.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
if (pay > 0) {
addActionImport(daily.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
}
}
}
} else if (billType.equals(EnumBillExcelTemplate.OTHER.getCode())) {
@@ -1094,7 +1096,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
otherQuery.setName(bill.getBillAttr());
otherQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode());
WxBillOther other = wxBillOtherMapper.selectOne(otherQuery);
if (other != null) {
if (other != null && pay > 0) {
if (!other.getStatus().equals(EnumBillRentStatus.PAID.getCode())) {
long allPay = new BigDecimal(other.getPay()).add(new BigDecimal(pay)).longValueExact();
WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), receivePay, allPay, false);
@@ -1145,7 +1147,9 @@ public class WxBillAllServiceImpl implements WxBillAllService {
other.setExpiredDay(expiredDayAndStatus.getExpiredDay());
other.setStatus(expiredDayAndStatus.getStatus());
wxBillOtherMapper.insertSelective(other);
addActionImport(other.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
if (pay > 0) {
addActionImport(other.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
}
}
}
} else if (billType.equals(EnumBillExcelTemplate.OTHER_DEPOSIT.getCode())) {
@@ -1156,7 +1160,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
otherDepositQuery.setComments(bill.getBillAttr());
otherDepositQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode());
WxBillOtherDeposit otherDeposit = wxBillOtherDepositMapper.selectOne(otherDepositQuery);
if (otherDeposit != null) {
if (otherDeposit != null && pay > 0) {
if (!otherDeposit.getStatus().equals(EnumBillRentStatus.PAID.getCode()) && !otherDeposit.getStatus().equals(EnumBillRentStatus.RETURN.getCode())) {
long allPay = new BigDecimal(otherDeposit.getPay()).add(new BigDecimal(pay)).longValueExact();
otherDeposit.setExpiredDay(0L);
@@ -1212,7 +1216,9 @@ public class WxBillAllServiceImpl implements WxBillAllService {
otherDeposit.setStatus(EnumBillRentStatus.WAIT_PAY.getCode());
}
wxBillOtherDepositMapper.insertSelective(otherDeposit);
addActionImport(otherDeposit.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
if (pay > 0) {
addActionImport(otherDeposit.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
}
}
}
} else {
@@ -1284,7 +1290,9 @@ public class WxBillAllServiceImpl implements WxBillAllService {
rent.setPayDate(bill.getPayDate());
rent.setReceiveDate(bill.getReceiveDate());
wxBillRentMapper.updateByPrimaryKey(rent);
addActionImport(rent.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
if (pay > 0) {
addActionImport(rent.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
}
}
} else if (billType.equals(EnumBillExcelTemplate.SHOP_PROPERTY.getCode()) || billType.equals(EnumBillExcelTemplate.POINT_PROPERTY.getCode())) {
WxBillProperty propertyQuery = new WxBillProperty();
@@ -1309,7 +1317,9 @@ public class WxBillAllServiceImpl implements WxBillAllService {
property.setPayDate(bill.getPayDate());
property.setReceiveDate(bill.getReceiveDate());
wxBillPropertyMapper.updateByPrimaryKey(property);
addActionImport(property.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
if (pay > 0) {
addActionImport(property.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr());
}
}
} else {
logger.error("账单导入失败");
@@ -1367,24 +1377,24 @@ public class WxBillAllServiceImpl implements WxBillAllService {

@Override
public Long hasOweBill(Long contractId, Integer type) {
if(type.intValue() == 1){
return wxBillRentMapper.oweBillCount(contractId);
}else if(type.intValue() == 2){
return wxBillPropertyMapper.oweBillCount(contractId);
if (type.intValue() == 1) {
return wxBillRentMapper.oweBillCount(contractId);
} else if (type.intValue() == 2) {
return wxBillPropertyMapper.oweBillCount(contractId);
}
return 0L;
}

public Map<Long, List<Map<String, Object>>> toMap(List<Map<String, Object>> mapList){
public Map<Long, List<Map<String, Object>>> toMap(List<Map<String, Object>> mapList) {
Map<Long, List<Map<String, Object>>> result = new HashMap<>();
for (Map<String, Object> bill:mapList) {
Long merchantId = (Long)bill.get("merchantId");
for (Map<String, Object> bill : mapList) {
Long merchantId = (Long) bill.get("merchantId");
List<Map<String, Object>> currList = result.get(merchantId);
if (currList == null) {
currList = new ArrayList<>();
}
currList.add(bill);
result.put(merchantId,currList);
result.put(merchantId, currList);
}
return result;
}
@@ -1393,19 +1403,19 @@ public class WxBillAllServiceImpl implements WxBillAllService {
public void sendWaitPayBillEmail() {
List<Map<String, Object>> waitBillListForEmail = wxBillAllMapper.getWaitPayBillForEmail();

if(CollectionUtils.isNotEmpty(waitBillListForEmail)) {
if (CollectionUtils.isNotEmpty(waitBillListForEmail)) {
Map<Long, List<Map<String, Object>>> merchantMap = toMap(waitBillListForEmail);
for (Long merchantId : merchantMap.keySet()) {
List<Map<String, Object>> mapList = merchantMap.get(merchantId);
if(CollectionUtils.isNotEmpty(mapList)){
String email = (String)mapList.get(0).get("email");
if(StringUtils.isBlank(email)){
if (CollectionUtils.isNotEmpty(mapList)) {
String email = (String) mapList.get(0).get("email");
if (StringUtils.isBlank(email)) {
continue;
}
String tenantId = (String)mapList.get(0).get("tenantId");
String receiveDate = (String)mapList.get(0).get("receiveDate");
String manager = (String)mapList.get(0).get("manager");
String managerPhone = (String)mapList.get(0).get("managerPhone");
String tenantId = (String) mapList.get(0).get("tenantId");
String receiveDate = (String) mapList.get(0).get("receiveDate");
String manager = (String) mapList.get(0).get("manager");
String managerPhone = (String) mapList.get(0).get("managerPhone");

String billListStr = "";
BigDecimal sumNeedPay = new BigDecimal(0);
@@ -1426,8 +1436,8 @@ public class WxBillAllServiceImpl implements WxBillAllService {
map.put("price", sumNeedPay.toString());
map.put("date", receiveDate);
map.put("billList", billListStr);
map.put("linkName",manager==null?"":manager);
map.put("linkPhone",managerPhone==null?"":managerPhone);
map.put("linkName", manager == null ? "" : manager);
map.put("linkPhone", managerPhone == null ? "" : managerPhone);
MailMsg mailMsg = new MailMsg();
mailMsg.setSubject("待缴账单通知");
mailMsg.setHtml(true);
@@ -1447,20 +1457,20 @@ public class WxBillAllServiceImpl implements WxBillAllService {
public void sendOweBillForEmail() {
List<Map<String, Object>> oweBillForEmail = wxBillAllMapper.getOweBillForEmail();

if(CollectionUtils.isNotEmpty(oweBillForEmail)) {
if (CollectionUtils.isNotEmpty(oweBillForEmail)) {
Map<Long, List<Map<String, Object>>> merchantMap = toMap(oweBillForEmail);
for (Long merchantId : merchantMap.keySet()) {
List<Map<String, Object>> mapList = merchantMap.get(merchantId);
if(CollectionUtils.isNotEmpty(mapList)){
String email = (String)mapList.get(0).get("email");
if(StringUtils.isBlank(email)){
if (CollectionUtils.isNotEmpty(mapList)) {
String email = (String) mapList.get(0).get("email");
if (StringUtils.isBlank(email)) {
continue;
}
String tenantId = (String)mapList.get(0).get("tenantId");
String receiveDate = (String)mapList.get(0).get("receiveDate");
String manager = (String)mapList.get(0).get("manager");
String managerPhone = (String)mapList.get(0).get("managerPhone");
Long expiredDay = (Long)mapList.get(0).get("expiredDay");
String tenantId = (String) mapList.get(0).get("tenantId");
String receiveDate = (String) mapList.get(0).get("receiveDate");
String manager = (String) mapList.get(0).get("manager");
String managerPhone = (String) mapList.get(0).get("managerPhone");
Long expiredDay = (Long) mapList.get(0).get("expiredDay");

String billListStr = "";
BigDecimal sumNeedPay = new BigDecimal(0);
@@ -1483,8 +1493,8 @@ public class WxBillAllServiceImpl implements WxBillAllService {
map.put("price", sumNeedPay.toString());
map.put("date", receiveDate);
map.put("billList", billListStr);
map.put("linkName",manager==null?"":manager);
map.put("linkPhone",managerPhone==null?"":managerPhone);
map.put("linkName", manager == null ? "" : manager);
map.put("linkPhone", managerPhone == null ? "" : managerPhone);
MailMsg mailMsg = new MailMsg();
mailMsg.setSubject("欠缴账单通知");
mailMsg.setHtml(true);
@@ -1505,12 +1515,12 @@ public class WxBillAllServiceImpl implements WxBillAllService {
public Map<String, Object> getOweBillAsPage(WxBillAll record, Integer pageNum, Integer pageSize) {
PageInfo<Map<String, Object>> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxBillAllMapper.getOweBillAsPage(record));
List<Map<String, Object>> list = pageInfo.getList();
for (Map<String, Object> map:list) {
map.put("rentOwe",subZeroAndDot(map.get("rentOwe").toString()));
map.put("propertyOwe",subZeroAndDot(map.get("propertyOwe").toString()));
map.put("depositOwe",subZeroAndDot(map.get("depositOwe").toString()));
map.put("otherOwe",subZeroAndDot(map.get("otherOwe").toString()));
map.put("totalOwe",subZeroAndDot(map.get("totalOwe").toString()));
for (Map<String, Object> map : list) {
map.put("rentOwe", subZeroAndDot(map.get("rentOwe").toString()));
map.put("propertyOwe", subZeroAndDot(map.get("propertyOwe").toString()));
map.put("depositOwe", subZeroAndDot(map.get("depositOwe").toString()));
map.put("otherOwe", subZeroAndDot(map.get("otherOwe").toString()));
map.put("totalOwe", subZeroAndDot(map.get("totalOwe").toString()));
}
pageInfo.setList(list);
Map<String, Object> result = new HashMap<>();
@@ -1520,11 +1530,12 @@ public class WxBillAllServiceImpl implements WxBillAllService {

/**
* 使用java正则表达式去掉多余的.与0
*
* @param s
* @return
*/
public static String subZeroAndDot(String s){
if(s.indexOf(".") > 0){
public static String subZeroAndDot(String s) {
if (s.indexOf(".") > 0) {
s = s.replaceAll("0+?$", "");//去掉多余的0
s = s.replaceAll("[.]$", "");//如最后一位是.则去掉
}
@@ -1535,11 +1546,11 @@ public class WxBillAllServiceImpl implements WxBillAllService {
public void exportOweMerchant(WxBillAll record, HttpServletRequest request, HttpServletResponse response) {
List<Map<String, Object>> data = wxBillAllMapper.getOweBillAsPage(record);
List<OweMerchantVo> list = new ArrayList<>();
for (Map<String, Object> map:data) {
for (Map<String, Object> map : data) {
OweMerchantVo oweMerchantVo = new OweMerchantVo();
oweMerchantVo.setLinkPerson((String)map.get("manager"));
oweMerchantVo.setName((String)map.get("merchantName"));
oweMerchantVo.setLinkPhone((String)map.get("managerPhone"));
oweMerchantVo.setLinkPerson((String) map.get("manager"));
oweMerchantVo.setName((String) map.get("merchantName"));
oweMerchantVo.setLinkPhone((String) map.get("managerPhone"));

oweMerchantVo.setDepositOwe(new BigDecimal(subZeroAndDot(map.get("depositOwe").toString())));
oweMerchantVo.setOtherOwe(new BigDecimal(subZeroAndDot(map.get("otherOwe").toString())));
@@ -1556,11 +1567,11 @@ public class WxBillAllServiceImpl implements WxBillAllService {
public void exportWaitMerchant(WxBillAll record, HttpServletRequest request, HttpServletResponse response) {
List<Map<String, Object>> data = wxBillAllMapper.getOweBillAsPage(record);
List<WaitMerchantVo> list = new ArrayList<>();
for (Map<String, Object> map:data) {
for (Map<String, Object> map : data) {
WaitMerchantVo oweMerchantVo = new WaitMerchantVo();
oweMerchantVo.setLinkPerson((String)map.get("manager"));
oweMerchantVo.setName((String)map.get("merchantName"));
oweMerchantVo.setLinkPhone((String)map.get("managerPhone"));
oweMerchantVo.setLinkPerson((String) map.get("manager"));
oweMerchantVo.setName((String) map.get("merchantName"));
oweMerchantVo.setLinkPhone((String) map.get("managerPhone"));

oweMerchantVo.setRentReceivePay(new BigDecimal(subZeroAndDot(map.get("rentReceivePay").toString())));
oweMerchantVo.setPropertyReceivePay(new BigDecimal(subZeroAndDot(map.get("propertyReceivePay").toString())));


Загрузка…
Отмена
Сохранить