From fc4293b660512296405824d3598bbc30fab00ae8 Mon Sep 17 00:00:00 2001 From: luozukai Date: Fri, 19 Jul 2019 21:52:23 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B0=83=E6=95=B4=E9=A2=84=E8=A7=88=E8=B4=A6?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contract/WxRentContractController.java | 17 ++++++++++ .../service/WxRentContractService.java | 4 ++- .../impl/WxRentContractServiceImpl.java | 34 +++++++++++++------ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index 5abba7d9d..354694ced 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -7,6 +7,7 @@ import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.*; import com.iformall.enums.EnumFromType; +import com.iformall.enums.EnumIsPreview; import com.iformall.enums.EnumRentStartType; import com.iformall.exception.MallinkException; import com.iformall.mapper.WxRentContractMapper; @@ -28,6 +29,7 @@ import javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -78,6 +80,21 @@ public class WxRentContractController extends BaseController { return new ResultData(result); } + /** + * 预览账单展示,编辑账期,后端生成账单金额 + * @param wxRentContract + * @return + */ + @GetMapping("buildBillPriceList") + @SystemControllerLog(description = "租赁合同-生成账单列表金额") + public ResultData buildBillPriceList(@ModelAttribute WxRentContract wxRentContract) { + logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList"); + WxRentContract dbRent = wxRentContractMapper.selectByPrimaryKey(wxRentContract.getId()); + dbRent.setPreviewBillRentList(wxRentContract.getPreviewBillRentList()); + List result = wxRentContractService.buildRent(new WxMerchant(),getUserId(),dbRent, EnumIsPreview.YES.getCode(), false); + return new ResultData(result); + } + @PostMapping("add") @SystemControllerLog(description = "租赁合同-添加") public ResultData add(@RequestBody WxRentContract wxRentContract) { diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index b8348c372..fe95e3afb 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -74,7 +74,7 @@ public interface WxRentContractService { void updateApplyStatus(WxRentContract wxRentContract); - List buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview); + List buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview,boolean saveDb); void buildDeposit(WxMerchant wxMerchant, Long userId,Long rentContractId); @@ -93,4 +93,6 @@ public interface WxRentContractService { void updatePropertyPreviewBill(WxRentContract record); Map updateStatus(WxRentContract record); + + List buildBillPriceList(WxRentContract rentContract); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 1d71433a0..101dd12fd 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -383,7 +383,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) { wxBillRentMapper.deletePreviewBill(record); //重新生成 - List resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode()); + List resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true); record.setPreviewBillRentList(resultList); } return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record); @@ -410,7 +410,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) { //删除预账单,重新生成 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 @Transactional(rollbackFor = {Exception.class}) - public List buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview) { + public List buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview,boolean saveDb) { List rentList = new ArrayList<>(); //根据商户ID找出合同 WxRentContract wxRentContract; @@ -824,7 +824,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { //按月计租 // if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_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 { // //如果按日 // List yearList = new ArrayList<>(); @@ -889,7 +889,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { return priceList; } - public List buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview) { + public List buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview,boolean saveDb) { int size = 0; long[] priceArrs = null; List> shopInfos = new ArrayList<>(); @@ -977,9 +977,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { yearList.add(startDate); } - String shopInfoStr = getShopInfoStr(wxRentContract); - Map resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr); + Map resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr,saveDb); List billRentList = (List)resultMap.get("billList"); resultList.addAll(billRentList); return resultList; @@ -1001,7 +1000,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { return shopInfoStr; } - public Map buildRent(int receivePeriod, long[] priceArrs, List yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr) { + public Map buildRent(int receivePeriod, long[] priceArrs, List yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); Map resultMap = new HashedMap(); List resultList = new ArrayList<>(); @@ -1012,7 +1011,19 @@ public class WxRentContractServiceImpl implements WxRentContractService { endDate = yearList.get(1); } - List billTimeVoList = initBillTimeList(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),wxRentContract.getAdjustPeriod(),dayType,receivePeriod); + List 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; for (int i = 0; i < billTimeVoList.size(); i++) { @@ -1115,12 +1126,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxBillRent.setPeriod(++billcount); wxBillRent.setShopInfo(shopInfoStr); wxBillRent.setLatePayRatio(0); - //wxBillRentMapper.insertSelective(wxBillRent); resultList.add(wxBillRent); } //批量插入账单 - wxBillRentMapper.insertBills(resultList); + if(saveDb) { + wxBillRentMapper.insertBills(resultList); + } resultMap.put("billcount",billcount); resultMap.put("billList",resultList); return resultMap;