@@ -383,7 +383,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
wxBillRentMapper.deletePreviewBill(record);
wxBillRentMapper.deletePreviewBill(record);
//重新生成
//重新生成
List<WxBillRent> resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode());
List<WxBillRent> resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true );
record.setPreviewBillRentList(resultList);
record.setPreviewBillRentList(resultList);
}
}
return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record);
return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record);
@@ -410,7 +410,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) {
//删除预账单,重新生成
//删除预账单,重新生成
wxBillRentMapper.deletePreviewBill(record);
wxBillRentMapper.deletePreviewBill(record);
resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode());
resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true );
}
}
}
}
@@ -800,7 +800,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
@Override
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional(rollbackFor = {Exception.class})
public List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview) {
public List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview,boolean saveDb ) {
List<WxBillRent> rentList = new ArrayList<>();
List<WxBillRent> rentList = new ArrayList<>();
//根据商户ID找出合同
//根据商户ID找出合同
WxRentContract wxRentContract;
WxRentContract wxRentContract;
@@ -824,7 +824,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
//按月计租
//按月计租
// if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())
// if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())
// ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) {
// ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) {
rentList = buildRentMonth(userId, wxRentContract, receivePeriod, lease, rentalStartDate, price, isPreview);
rentList = buildRentMonth(userId, wxRentContract, receivePeriod, lease, rentalStartDate, price, isPreview,saveDb );
// } else {
// } else {
// //如果按日
// //如果按日
// List<Date> yearList = new ArrayList<>();
// List<Date> yearList = new ArrayList<>();
@@ -889,7 +889,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return priceList;
return priceList;
}
}
public List<WxBillRent> buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview) {
public List<WxBillRent> buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview,boolean saveDb ) {
int size = 0;
int size = 0;
long[] priceArrs = null;
long[] priceArrs = null;
List<Map<String, Object>> shopInfos = new ArrayList<>();
List<Map<String, Object>> shopInfos = new ArrayList<>();
@@ -977,9 +977,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
yearList.add(startDate);
yearList.add(startDate);
}
}
String shopInfoStr = getShopInfoStr(wxRentContract);
String shopInfoStr = getShopInfoStr(wxRentContract);
Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr);
Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr,saveDb );
List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList");
List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList");
resultList.addAll(billRentList);
resultList.addAll(billRentList);
return resultList;
return resultList;
@@ -1001,7 +1000,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return shopInfoStr;
return shopInfoStr;
}
}
public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr) {
public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb ) {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Map<String,Object> resultMap = new HashedMap();
Map<String,Object> resultMap = new HashedMap();
List<WxBillRent> resultList = new ArrayList<>();
List<WxBillRent> resultList = new ArrayList<>();
@@ -1012,7 +1011,19 @@ public class WxRentContractServiceImpl implements WxRentContractService {
endDate = yearList.get(1);
endDate = yearList.get(1);
}
}
List<BillTimeVo> billTimeVoList = initBillTimeList(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),wxRentContract.getAdjustPeriod(),dayType,receivePeriod);
List<BillTimeVo> billTimeVoList = new ArrayList<>();
if(saveDb){
billTimeVoList = initBillTimeList(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),wxRentContract.getAdjustPeriod(),dayType,receivePeriod);
}else{
//预账单编辑账期,生成金额
for (WxBillRent rent:wxRentContract.getPreviewBillRentList()) {
BillTimeVo billTimeVo = new BillTimeVo();
billTimeVo.setStartDate(rent.getStarttime());
billTimeVo.setEndDate(rent.getEndtime());
billTimeVo.setReceiveDate(DateUtils.getDaySet(rent.getStarttime(),Calendar.DATE,-1));
billTimeVoList.add(billTimeVo);
}
}
int index = 0;
int index = 0;
for (int i = 0; i < billTimeVoList.size(); i++) {
for (int i = 0; i < billTimeVoList.size(); i++) {
@@ -1115,12 +1126,13 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillRent.setPeriod(++billcount);
wxBillRent.setPeriod(++billcount);
wxBillRent.setShopInfo(shopInfoStr);
wxBillRent.setShopInfo(shopInfoStr);
wxBillRent.setLatePayRatio(0);
wxBillRent.setLatePayRatio(0);
//wxBillRentMapper.insertSelective(wxBillRent);
resultList.add(wxBillRent);
resultList.add(wxBillRent);
}
}
//批量插入账单
//批量插入账单
wxBillRentMapper.insertBills(resultList);
if(saveDb) {
wxBillRentMapper.insertBills(resultList);
}
resultMap.put("billcount",billcount);
resultMap.put("billcount",billcount);
resultMap.put("billList",resultList);
resultMap.put("billList",resultList);
return resultMap;
return resultMap;