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 4d18e2ee9..f2d3e6279 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -84,14 +84,22 @@ public class WxRentContractController extends BaseController { */ @GetMapping("buildBillPriceList") @SystemControllerLog(description = "租赁合同-生成账单列表金额") - public ResultData buildBillPriceList(@ModelAttribute WxRentContract wxRentContract) { + public ResultData buildBillPriceList(@ModelAttribute WxRentContract wxRentContract) throws Exception{ logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList"); //todo:test - wxRentContract.setId(312447858201595904l); - List previewBillRentList = new ArrayList<>(); - - wxRentContract.setPreviewBillRentList(previewBillRentList); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// wxRentContract.setId(312447858201595904l); +// List previewBillRentList = new ArrayList<>(); +// WxBillRent b = new WxBillRent(); +// b.setStarttime(sdf.parse("2019-07-10")); +// b.setEndtime(sdf.parse("2020-08-10")); +// previewBillRentList.add(b); +// b = new WxBillRent(); +// b.setStarttime(sdf.parse("2020-08-11")); +// b.setEndtime(sdf.parse("2021-07-30")); +// previewBillRentList.add(b); +// wxRentContract.setPreviewBillRentList(previewBillRentList); WxRentContract dbRent = wxRentContractMapper.selectByPrimaryKey(wxRentContract.getId()); dbRent.setPreviewBillRentList(wxRentContract.getPreviewBillRentList()); diff --git a/mallinkAdmin/src/main/resources/db/migration/V201907231512__L_ADD_MENU.sql b/mallinkAdmin/src/main/resources/db/migration/V201907231537__L_ADD_MENU.sql similarity index 95% rename from mallinkAdmin/src/main/resources/db/migration/V201907231512__L_ADD_MENU.sql rename to mallinkAdmin/src/main/resources/db/migration/V201907231537__L_ADD_MENU.sql index 2cb1538c5..d2804c3d8 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V201907231512__L_ADD_MENU.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V201907231537__L_ADD_MENU.sql @@ -1,7 +1,7 @@ INSERT INTO `mall_permission` (`id`,`name`, `parent_id`,`available`,`permission`,`resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`,`sort`) VALUES - (592, '短信管理', 50, 'Y', null, 0, null, null, 'dreamSend', 'icon-navicon-yhgl', 0, 592); + (592, '短信管理', 50, 'Y', null, 1, null, null, 'dreamSend', 'icon-navicon-dxgl', 0, 592); DROP TABLE IF EXISTS `mall_sale_type` ; CREATE TABLE `mall_sale_type` ( 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 4355ca1fc..cfb87491b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1028,6 +1028,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { int index = 0; for (int i = 0; i < billTimeVoList.size(); i++) { BillTimeVo billTimeVo = billTimeVoList.get(i); + //计算金额 + long needpay = 0; if(yearList.size() > 1) { if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { @@ -1040,16 +1042,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 logger.info("==========cross:"+sd.format(endDate)); - - - + //如果是计算账单金额&cross 拆分日期进行计算 + if(!saveDb) { + logger.info("==========s:"+sd.format(billTimeVo.getStartDate())); + logger.info("==========e:"+sd.format(billTimeVo.getEndDate())); + logger.info("==========:"+sd.format(endDate)); + long needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),billTimeVo.getEndDate(),i,billTimeVoList.size()); + long needpayAfter = getNeedPayMoney(wxRentContract,priceArrs[index],billTimeVo.getStartDate(),billTimeVo.getEndDate(),i,billTimeVoList.size()); + needpay = needpayFront+needpayAfter; + }else{ + //计算金额 + needpay = getNeedPayMoney(wxRentContract,priceArrs[index],billTimeVo.getStartDate(),billTimeVo.getEndDate(),i,billTimeVoList.size()); + } } } } - //获取price 、shopInfo - long price = priceArrs[index]; - WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setIsPreview(isPreview); wxBillRent.setId(idWorker.nextId()); @@ -1059,57 +1067,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxBillRent.setEndtime(billTimeVo.getEndDate()); wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); - long needpay; - //按日 - if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ - Double priceD = new Double(price); - double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,wxBillRent.getStarttime(),wxBillRent.getEndtime()); - needpay = new Double(needpayD).longValue(); - }else{ - //年 需要除12 - Double priceD = new Double(price); - if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){ - priceD = new Double(price)/12; - } - - SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); - if(i == billTimeVoList.size()-1){//最后 - if(isFirstDay(billTimeVo.getStartDate())){ - int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); - months++; - needpay = new Double(months * priceD).longValue(); - }else { - needpay = new Double(getMonthNeedPay(priceD, billTimeVo.getStartDate(), billTimeVo.getEndDate())).longValue(); - } - }else if(i == 0){//第一期 - if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ - if(isFirstDay(billTimeVo.getStartDate())){ - int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); - months++; - needpay = new Double(months * priceD).longValue(); - }else{ - needpay = new Double(getMonthNeedPay(priceD, billTimeVo.getStartDate(), billTimeVo.getEndDate())).longValue(); - } - }else{ - if(isFirstDay(billTimeVo.getStartDate())){ - int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); - if(isFirstDay(billTimeVo.getStartDate())){ - months++; - } - needpay = new Double(months * priceD).longValue(); - }else{ - needpay = new Double(getMonthNeedPay(priceD, billTimeVo.getStartDate(), billTimeVo.getEndDate())).longValue(); - } - } - }else{//中间 - int months = getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); - if(isFirstDay(billTimeVo.getStartDate())){ - months++; - } - needpay = new Double(months * priceD).longValue(); - } - } - wxBillRent.setNeedPay(needpay); wxBillRent.setOwe(needpay); wxBillRent.setReceivePay(needpay); @@ -1142,8 +1099,58 @@ public class WxRentContractServiceImpl implements WxRentContractService { return resultMap; } - public long getNeedPay(){ + public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize){ + long needpay; + //按日 + if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ + Double priceD = new Double(price); + double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,startDate,endDate); + needpay = new Double(needpayD).longValue(); + }else{ + //年 需要除12 + Double priceD = new Double(price); + if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){ + priceD = new Double(price)/12; + } + SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); + if(i == billTimeVoListSize - 1){//最后 + if(isFirstDay(startDate)){ + int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); + months++; + needpay = new Double(months * priceD).longValue(); + }else { + needpay = new Double(getMonthNeedPay(priceD, startDate, endDate)).longValue(); + } + }else if(i == 0){//第一期 + if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ + if(isFirstDay(startDate)){ + int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); + months++; + needpay = new Double(months * priceD).longValue(); + }else{ + needpay = new Double(getMonthNeedPay(priceD, startDate, endDate)).longValue(); + } + }else{ + if(isFirstDay(startDate)){ + int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); + if(isFirstDay(startDate)){ + months++; + } + needpay = new Double(months * priceD).longValue(); + }else{ + needpay = new Double(getMonthNeedPay(priceD, startDate, endDate)).longValue(); + } + } + }else{//中间 + int months = getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); + if(isFirstDay(startDate)){ + months++; + } + needpay = new Double(months * priceD).longValue(); + } + } + return needpay; } public void setExpiredDay(WxBillRent wxBillRent,int dayType, int receivePeriod){