| @@ -401,6 +401,39 @@ public class WxEnergyController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("计费标准记录导出") | |||
| @GetMapping("feesShopExport") | |||
| public void feesShopExport(@ModelAttribute WxEnergyFeesShop record, HttpServletRequest request, HttpServletResponse response) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||
| if (StringUtils.isNotBlank(record.getFeesIdsStr())) { | |||
| String[] fss = record.getFeesIdsStr().split(","); | |||
| if (null != fss && fss.length > 0 ) { | |||
| List<Long> feesIdList = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < fss.length ; i ++) { | |||
| feesIdList.add(Long.parseLong(fss[i])); | |||
| } | |||
| record.setFeesIds(feesIdList); | |||
| } | |||
| } | |||
| wxEnergyService.exportFeesShop(record, request, response); | |||
| } | |||
| @ApiOperation("科目抄表计算记录导入") | |||
| @PostMapping(value = "/importFeesShop", consumes = "multipart/*") | |||
| public void importFeesShop(@RequestParam("file") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { | |||
| try { | |||
| //得到当前用户ID | |||
| MallUserInfo user = getUser(); | |||
| //request.getParameter("timeId"); | |||
| wxEnergyService.importReading(mFile, user, request, response); | |||
| } catch (Exception e) { | |||
| logger.error("importReading error.",e); | |||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("费用区间所属年月") | |||
| @GetMapping("periodList") | |||
| public ResultData periodList() { | |||
| @@ -665,6 +698,16 @@ public class WxEnergyController extends BaseController { | |||
| public ResultData readingCalcuteResultList(@ModelAttribute WxEnergyReadingCalcuteResult record, Integer pageNum, Integer pageSize) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||
| if(StringUtils.isNotBlank(record.getFeesIdsStr())) { | |||
| String[] shids = record.getFeesIdsStr().split(","); | |||
| if (null != shids ) { | |||
| List<Long> sids = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < shids.length ; i ++) { | |||
| sids.add(Long.parseLong(shids[i])); | |||
| } | |||
| record.setFeesIds(sids); | |||
| } | |||
| } | |||
| PageInfo<WxEnergyReadingCalcuteResult> page = wxEnergyService.readingCalcuteResultListAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -7,6 +7,7 @@ import com.iformall.enums.EnumEnergyMeterPhysicsType; | |||
| import com.iformall.enums.EnumEnergyMeterType; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @@ -23,9 +24,11 @@ public class WxEnergyFeesShop extends TenantEntity { | |||
| private static final long serialVersionUID = 7009117540201976664L; | |||
| @Excel(name = "ID", width = 20, orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value="id",name="id") | |||
| private Long id; | |||
| @Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss", width = 20, orderNum = "13") | |||
| @io.swagger.annotations.ApiModelProperty(value="createTime",name="createTime") | |||
| private Date createTime; | |||
| @@ -34,15 +37,30 @@ public class WxEnergyFeesShop extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="科目编号",name="feesId") | |||
| private Long feesId; | |||
| @Excel(name = "科目", width = 20, orderNum = "2") | |||
| @TableField(exist = false) | |||
| private String feesName; | |||
| @Excel(name = "是否公摊", replace = {"是公摊_1", "不是公摊_0"}, width = 20, orderNum = "8") | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否公摊", name = "isPublic") | |||
| private Integer isPublic; | |||
| @Excel(name = "单价", width = 20, orderNum = "7") | |||
| @io.swagger.annotations.ApiModelProperty(value = "单价", name = "price") | |||
| private String price; | |||
| @Excel(name = "店铺ID", width = 20, orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value = "店铺编号", name = "shopId") | |||
| private Long shopId; | |||
| @Excel(name = "店铺号", width = 20, orderNum = "4") | |||
| @TableField(exist = false) | |||
| private String shopName; | |||
| @Excel(name = "楼栋", width = 20, orderNum = "5") | |||
| @TableField(exist = false) | |||
| private String buildingName; | |||
| @Excel(name = "楼层", width = 20, orderNum = "6") | |||
| @TableField(exist = false) | |||
| private String floorName; | |||
| @io.swagger.annotations.ApiModelProperty(value = "公摊计算公司", name = "formula") | |||
| private String formula; | |||
| @@ -68,8 +86,7 @@ public class WxEnergyFeesShop extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private List<Long> shopIds; | |||
| @TableField(exist = false) | |||
| private String feesName; | |||
| @TableField(exist = false) | |||
| private String feesIdsStr; | |||
| private List<Long> feesIds; | |||
| @@ -77,6 +77,9 @@ public class WxEnergyMeter extends TenantEntity { | |||
| return null; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否参与计费", name = "hasFee") | |||
| private Integer hasFee; | |||
| @TableField(exist = false) | |||
| private String treeType="meter"; | |||
| @TableField(exist = false) | |||
| @@ -64,6 +64,9 @@ public class WxEnergyReadingCalcuteResult extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private String feesName; | |||
| @io.swagger.annotations.ApiModelProperty(value="科目单价",name="feesPrice") | |||
| private String feesPrice; | |||
| @io.swagger.annotations.ApiModelProperty(value="费用标准ID",name="feesCalcuteId") | |||
| private Long feesShopId; | |||
| @@ -77,6 +80,10 @@ public class WxEnergyReadingCalcuteResult extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private List<Long> shopIds; | |||
| @TableField(exist = false) | |||
| private List<Long> feesIds; | |||
| @TableField(exist = false) | |||
| private String feesIdsStr; | |||
| public WxAllBill generateBill(WxEnergyReadingCalcute calcute,WxMerchant merchant,WxShop shop,MallUserInfo user,String needPay,String detail,String remark) { | |||
| WxAllBill daily = new WxAllBill(); | |||
| @@ -149,6 +149,9 @@ public class WxShop extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "租金单位", name = "rentUnit") | |||
| private Integer rentUnit; | |||
| @io.swagger.annotations.ApiModelProperty(value = "租金单位", name = "rentUnit") | |||
| private String pulicRate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "树里面的类型", name = "treeType") | |||
| @TableField(exist = false) | |||
| private String treeType = "shop"; | |||
| @@ -64,6 +64,8 @@ public interface WxEnergyService { | |||
| WxEnergyFeesShop getFeesShop(Long id,String tenantId); | |||
| void updateFeesShop(WxEnergyFeesShop record); | |||
| PageInfo<WxEnergyFeesShop> feesShopListAsPage(WxEnergyFeesShop record, Integer pageIndex, Integer pageSize); | |||
| void exportFeesShop(WxEnergyFeesShop record,HttpServletRequest request, HttpServletResponse response); | |||
| void importFeesShop(MultipartFile mFile, MallUserInfo user, HttpServletRequest request, HttpServletResponse response); | |||
| //抄表数据 | |||
| PageInfo<WxEnergyMeterReading> readingListAsPage(WxEnergyMeterReading record, Integer pageIndex, Integer pageSize); | |||
| @@ -132,7 +132,11 @@ public class WxEnergyHelper { | |||
| } | |||
| } | |||
| formula = formula.replaceAll("#totalArea#", totalArea.toPlainString()); | |||
| formula = formula.replaceAll("#shopPublicRax#", shop.getBuildArea()); | |||
| if (StringUtils.isBlank(shop.getPulicRate())) { | |||
| formula = formula.replaceAll("#shopPublicRax#", "0"); | |||
| }else { | |||
| formula = formula.replaceAll("#shopPublicRax#", shop.getPulicRate()); | |||
| } | |||
| return formula; | |||
| } | |||
| @@ -195,7 +199,7 @@ public class WxEnergyHelper { | |||
| } | |||
| String formula = replaceFormulaData(shopfee.getFormula(),totalArea,shop,buildingAreaMap,floorAreaMap,meterNumberMap); | |||
| if (null != formula) { | |||
| return new BigDecimal(FormulaParser.evaluate(formula)).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||
| return new BigDecimal(FormulaParser.evaluate(formula)).multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||
| } | |||
| return "0"; | |||
| }else { | |||
| @@ -187,8 +187,8 @@ public class WxRentContractHelper { | |||
| List<String[]> retList = new ArrayList<String[]>(); | |||
| //租金的年调整 | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||
| integers.add(0, 0); | |||
| List<String> integers = JSONArray.parseArray(adjustRatio, String.class); | |||
| integers.add(0, "0"); | |||
| int size = integers.size(); | |||
| String[] priceArrs = new String[size]; | |||
| @@ -346,8 +346,8 @@ public class WxRentContractHelper { | |||
| //合铺计算某项计费 | |||
| private static String[] calcuteRatioByJoin(Integer decimalSize,Integer ratioWay,String ratio,String ratioFirstYearPrice,String rentArea) { | |||
| List<Integer> integers = JSONArray.parseArray(ratio, Integer.class); | |||
| integers.add(0, 0); | |||
| List<String> integers = JSONArray.parseArray(ratio, String.class); | |||
| integers.add(0, "0"); | |||
| int size = integers.size(); | |||
| String[] priceArrs = new String[size]; | |||
| priceArrs[0] = ratioFirstYearPrice; | |||
| @@ -677,55 +677,6 @@ public class WxRentContractHelper { | |||
| return validDays; | |||
| } | |||
| public static void main(String[] args) { | |||
| Date start = DateUtils.str2Date("2024-08-14 00:00:00").getTime(); | |||
| Date end = DateUtils.str2Date("2024-10-30 00:00:00").getTime(); | |||
| Date startFirstDay = DateUtils.getFirstDayForCurrMonth(start); | |||
| Date endLastDay = DateUtils.getLastDayForMonth(end); | |||
| int[] rdiffs = DateUtils.getDiff(startFirstDay, endLastDay); | |||
| // int[] diffs = DateUtils.getDiff(start, end); | |||
| System.out.println(rdiffs[0]+">>>"+rdiffs[1]); | |||
| // System.out.println(DateUtils.daysBetween(start, end)+1); | |||
| // | |||
| // Date d1 = DateUtils.str2Date("2026-08-09 00:00:00").getTime(); | |||
| // Date d2 = DateUtils.str2Date("2026-09-08 00:00:00").getTime(); | |||
| // List<Date> f1 = DateUtils.getAllDays(d1, d2); | |||
| // | |||
| // Date endMonthDate = DateUtils.getDaySet(start, Calendar.MONTH, 2); | |||
| // System.out.println(DateUtils.date2String(endMonthDate)); | |||
| // Date d3 = DateUtils.str2Date("2024-09-01 00:00:00").getTime(); | |||
| // Date d4 = DateUtils.str2Date("2024-09-30 00:00:00").getTime(); | |||
| // f1.addAll(DateUtils.getAllDays(d3, d4)); | |||
| // System.out.println(getValidDays(start,end,f1)); | |||
| // Date start = DateUtils.str2Date("2024-08-05 00:00:00").getTime(); | |||
| // Date end = DateUtils.str2Date("2025-11-04 23:59:59").getTime(); | |||
| // | |||
| // Date d1 = DateUtils.str2Date("2024-07-31 00:00:00").getTime(); | |||
| // Date d2 = DateUtils.str2Date("2024-08-03 00:00:00").getTime(); | |||
| // Date d3 = DateUtils.str2Date("2024-08-06 00:00:00").getTime(); | |||
| // Date d4 = DateUtils.str2Date("2024-08-31 00:00:00").getTime(); | |||
| // Date d5 = DateUtils.str2Date("2024-09-01 00:00:00").getTime(); | |||
| // Date d6 = DateUtils.str2Date("2024-09-11 00:00:00").getTime(); | |||
| // Date d7 = DateUtils.str2Date("2024-09-30 00:00:00").getTime(); | |||
| // | |||
| // List<Date> freeDays = new ArrayList<Date>(); | |||
| // freeDays.add(d1); | |||
| // freeDays.add(d2); | |||
| // freeDays.add(d3); | |||
| // freeDays.add(d4); | |||
| // freeDays.add(d5); | |||
| // freeDays.add(d6); | |||
| // freeDays.add(d7); | |||
| // System.out.println(DateUtils.getDaySet(d1, Calendar.DATE, -1)); | |||
| //String dayMoney = getNeedPay(freeDays, 2, new BigDecimal(10), start, end, EnumRentDayPriceCalcute.AVERAGE_DAYS, 30); | |||
| //System.out.println(dayMoney); | |||
| //String monthMoney = getMonthNeedPay(freeDays, 2, new BigDecimal(2000), start, end, EnumContractReceivePeriodUnit.QUARTER.getCode(), 1, EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode(), 30); | |||
| //System.out.println(monthMoney); | |||
| } | |||
| //查询当前月内的金额 | |||
| private static NeedPayDTO getCurrentMonthPay(Date start,Date end, BigDecimal priceMonth,Integer decimalSize,List<Date> validDays,Integer dayPriceCalcute,Integer monthAvageDays) { | |||
| NeedPayDTO np = new NeedPayDTO(); | |||
| @@ -629,6 +629,9 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| fq.updateTenantInfo(record); | |||
| fq.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| Map<Long, WxEnergyFees> feesMap = this.getFeesMap(fq); | |||
| Map<Long, String> floorMap = wxMallFloorService.getFloorMap(record); | |||
| Map<Long, String> buildingMap = wxMallBuildingService.getBuildingMap(record); | |||
| List<Long> shopIdList = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < page.getList().size() ; i++) { | |||
| WxEnergyFeesShop fs = page.getList().get(i); | |||
| if (null != feesMap && null != fs.getFeesId()) { | |||
| @@ -637,11 +640,71 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| fs.setFeesName(fee.getName()); | |||
| } | |||
| } | |||
| shopIdList.add(fs.getShopId()); | |||
| } | |||
| Map<Long, WxShop> shopMap = null; | |||
| if (shopIdList.size() > 0 ) { | |||
| WxShop sq = new WxShop(); | |||
| sq.updateTenantInfo(record); | |||
| sq.setIds(shopIdList); | |||
| shopMap = wxShopService.findShopMap(sq); | |||
| } | |||
| for (int i = 0 ; i < page.getList().size(); i++) { | |||
| WxEnergyFeesShop c = page.getList().get(i); | |||
| if (null != shopMap && null != c.getShopId()) { | |||
| WxShop s = shopMap.get(c.getShopId()); | |||
| if (null != s) { | |||
| c.setShopName(s.getShopNumber()); | |||
| if (null != floorMap) { | |||
| c.setFloorName(floorMap.get(s.getFloor())); | |||
| } | |||
| if (null != buildingMap) { | |||
| c.setBuildingName(buildingMap.get(s.getBuilding())); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return page; | |||
| } | |||
| @Override | |||
| public void exportFeesShop(WxEnergyFeesShop record, HttpServletRequest request, HttpServletResponse response) { | |||
| PageInfo<WxEnergyFeesShop> page = feesShopListAsPage(record, 1, 10000); | |||
| excelService.exportExcel(page.getList(), null, "计算标准", WxEnergyFeesShop.class, "计算标准.xlsx", response, false); | |||
| } | |||
| @Override | |||
| public void importFeesShop(MultipartFile mFile, MallUserInfo user, HttpServletRequest request, | |||
| HttpServletResponse response) { | |||
| File file = handlerImportFile(mFile,"energyFeesShopImport"); | |||
| // 需要验证 | |||
| String[] needFields = new String[]{"ID", "科目","店铺ID", "单价"}; | |||
| String[] allFields = new String[] {"ID","科目","店铺ID","店铺号","楼栋","楼层","单价","是否公摊","创建时间"}; | |||
| ExcelImportResult<WxEnergyFeesShop> datalist = handleImportFile(file,WxEnergyFeesShop.class,allFields,needFields,new ReadingExcelHandler()); | |||
| if (null == datalist) { | |||
| return ; | |||
| } | |||
| List<WxEnergyFeesShop> successList = datalist.getList(); | |||
| if(successList.size() > 0) { | |||
| boolean allSuccess = true; | |||
| try { | |||
| successList.parallelStream().forEach(reading -> { | |||
| WxEnergyFeesShop r = new WxEnergyFeesShop(); | |||
| r.updateTenantInfo(user); | |||
| r.setId(reading.getId()); | |||
| r.setPrice(reading.getPrice()); | |||
| r.setUpdateTime(new Date()); | |||
| wxEnergyFeesShopMapper.updateById(r); | |||
| }); | |||
| } catch (Exception e) { | |||
| logger.error("导入模板失败:"+e.getMessage(),e); | |||
| allSuccess = false; | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public List<Long> getAdvanceSetoffFeesids(WxEnergyFeesSetoff setoff) { | |||
| return wxEnergyFeesSetoffMapper.findFeesIdList(setoff); | |||
| @@ -956,6 +1019,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| mq.updateTenantInfo(record); | |||
| mq.setType(fees.getType()); | |||
| mq.setPhysicsType(EnumEnergyMeterPhysicsType.USER.getCode()); | |||
| mq.setHasFee(EnumYesOrNo.YES.getCode()); | |||
| List<Long> meterList = wxEnergyMeterMapper.findIdList(mq); | |||
| //查询公摊表 | |||
| Map<Long,List<Long>> summaryMeterMap = null; | |||
| @@ -1024,6 +1088,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { | |||
| cs.setCreateTime(new Date()); | |||
| cs.setUpdateTime(new Date()); | |||
| cs.setFeesId(shopfee.getFeesId()); | |||
| cs.setFeesPrice(shopfee.getPrice()); | |||
| cs.setFeesShopId(shopfee.getId()); | |||
| StringBuffer sb = new StringBuffer(); | |||
| cs.setMoney(wxEnergyHelper.calcuteMoney(sb,totalArea,shop,time, fees, shopfee,meterList,summaryMeterMap,buildingAreaMap,floorAreaMap)); | |||
| @@ -1019,7 +1019,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| String price = wxRentContract.getPrice(); | |||
| if(EnumContractOperationType.JINMAO.getCode().equals(wxRentContract.getOperationType())){ | |||
| Date startDate = wxRentContract.getStartDate(); | |||
| rentList = buildRentJinmao(user, wxRentContract, receivePeriod, lease, startDate, price, isPreview,saveDb); | |||
| //rentList = buildRentJinmao(user, wxRentContract, receivePeriod, lease, startDate, price, isPreview,saveDb); | |||
| }else{ | |||
| rentList = buildRentMonth(user, wxRentContract, receivePeriod, lease, rentalStartDate, isPreview,saveDb); | |||
| } | |||
| @@ -1067,106 +1067,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return resultList; | |||
| } | |||
| public List<WxAllBill> buildRentJinmao(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview, boolean saveDb) { | |||
| int size = 0; | |||
| String[] priceArrs = null; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode())){ | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| JSONArray array = JSONArray.parseArray(adjustRatio); | |||
| List<Integer> integers = new ArrayList<>(); | |||
| if(array != null && array.size() > 0){ | |||
| for (int i=0;i<array.size();i++){ | |||
| JSONObject jsonObject = array.getJSONObject(i); | |||
| String increasingProportion = jsonObject.getString("increasingProportion"); | |||
| if(StringUtils.isNotBlank(increasingProportion) && !"0".equals(increasingProportion)){ | |||
| int ratio = new BigDecimal(increasingProportion).multiply(new BigDecimal(100)).intValue(); | |||
| integers.add(ratio); | |||
| }else{ | |||
| integers.add(0); | |||
| } | |||
| } | |||
| } | |||
| integers.add(0, 0); | |||
| size = integers.size(); | |||
| priceArrs = new String[size]; | |||
| priceArrs[0] = price; | |||
| BigDecimal priceD = new BigDecimal(price); | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | |||
| logger.info("价格算法------递增前价格:"+priceD.doubleValue()+" 递增率:"+integers.get(i)+" 递增价格:"+divide.doubleValue()); | |||
| priceD = priceD.add(divide); | |||
| priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||
| } | |||
| } | |||
| }else if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_CUSTOMIZE.getCode())) { | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| JSONArray array = JSONArray.parseArray(adjustRatio); | |||
| if(array != null && array.size() > 0){ | |||
| priceArrs = new String[array.size()]; | |||
| size = array.size(); | |||
| for (int i=0;i<array.size();i++){ | |||
| JSONObject jsonObject = array.getJSONObject(i); | |||
| String perMonthMoney = jsonObject.getString("perMonthMoney"); | |||
| if(StringUtils.isNotBlank(perMonthMoney) && !"0".equals(perMonthMoney)){ | |||
| BigDecimal priceD = new BigDecimal(perMonthMoney); | |||
| priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||
| }else{ | |||
| priceArrs[i] = "0"; | |||
| } | |||
| } | |||
| }else { | |||
| size = 1; | |||
| priceArrs = new String[size]; | |||
| priceArrs[0] = "0"; | |||
| } | |||
| }else{ | |||
| return new ArrayList<>(); | |||
| } | |||
| int month = 12; | |||
| // int divide = lease / month; | |||
| // int mod = lease % month; | |||
| // int[] leaseArr = new int[size]; | |||
| // for (int i = 0; i < divide; i++) { | |||
| // leaseArr[i] = month; | |||
| // } | |||
| // if (mod > 0) { | |||
| // leaseArr[divide] = mod; | |||
| // } | |||
| int billcount = 0; | |||
| List<WxAllBill> resultList = new ArrayList<WxAllBill>(); | |||
| List<Date> yearList = new ArrayList<>(); | |||
| for (int i = 0; i < size; i++) { | |||
| Calendar instance = Calendar.getInstance(); | |||
| Date startDate; | |||
| //自然月 | |||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | |||
| if(i == 0){ //第一期 | |||
| startDate = rentalStartDate; | |||
| }else{ | |||
| instance.setTime(rentalStartDate); | |||
| instance.add(Calendar.MONTH, month * i); | |||
| startDate = DateUtils.getFirstDayForCurrMonth(instance.getTime()); | |||
| } | |||
| }else{ | |||
| instance.setTime(rentalStartDate); | |||
| instance.add(Calendar.MONTH, month * i); | |||
| startDate = instance.getTime(); | |||
| } | |||
| yearList.add(startDate); | |||
| } | |||
| String shopInfoStr = getShopInfoStr(wxRentContract); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,null,null, yearList, Calendar.MONTH, wxRentContract, user, billcount, isPreview, shopInfoStr,saveDb); | |||
| List<WxAllBill> billRentList = (List<WxAllBill>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| } | |||
| public String getShopInfoStr(WxRentContract wxRentContract){ | |||
| String shopInfoStr = null; | |||
| // if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||
| @@ -1748,143 +1648,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| } | |||
| public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | |||
| String[] priceArrs = new String[]{}; | |||
| List<String> adjustRatioList = new ArrayList<>(); | |||
| adjustRatioList.add(0, "0"); | |||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||
| String rentInfo = wxRentContract.getRentInfo(); | |||
| JSONArray objects = JSONArray.parseArray(rentInfo); | |||
| JSONObject jsonObject = objects.getJSONObject(0); | |||
| JSONArray adjustRatio = jsonObject.getJSONArray("adjustRatio"); | |||
| for (int i = 0, size = adjustRatio.size(); i < size; i++) { | |||
| StringBuffer adjustRatioStr = new StringBuffer(); | |||
| for (int j = 0, shopSize = objects.size(); j < shopSize; j++) { | |||
| JSONObject shopObject = objects.getJSONObject(j); | |||
| JSONArray adjustRatioArr = shopObject.getJSONArray("adjustRatio"); | |||
| String shopNumber = shopObject.getString("shopNumber"); | |||
| adjustRatioStr.append(shopNumber).append("[").append(adjustRatioArr.getString(i)).append("]"); | |||
| } | |||
| adjustRatioList.add(adjustRatioStr.toString()); | |||
| } | |||
| List<String[]> priceList = WxRentContractHelper.computeRentPriceByShop(wxRentContract); | |||
| int size = priceList.size(); | |||
| priceArrs = new String[size]; | |||
| for (int i = 0; i < size; i++) { | |||
| String[] priceInt = priceList.get(i); | |||
| BigDecimal sum = new BigDecimal(0); | |||
| for (String p : priceInt) { | |||
| sum = sum.add(new BigDecimal(p)); | |||
| } | |||
| priceArrs[i] = sum.toPlainString(); | |||
| } | |||
| } else { | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||
| for (int i = 0, size = integers.size(); i < size; i++) { | |||
| double ratioStr = new BigDecimal(integers.get(i)).divide(new BigDecimal(100)).doubleValue(); | |||
| adjustRatioList.add(String.valueOf(ratioStr)); | |||
| } | |||
| } | |||
| String payRatioStr = "0"; | |||
| if (wxRentContract.getPayRatio() != null) { | |||
| payRatioStr = new BigDecimal(wxRentContract.getPayRatio()).divide(new BigDecimal(100)).toPlainString(); | |||
| } | |||
| //常规租期 | |||
| for (int i = 0; i <= count; i++) { | |||
| //开始时间 | |||
| Calendar instance = Calendar.getInstance(); | |||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||
| instance.add(Calendar.MONTH, lease * i); | |||
| Date starttime = instance.getTime(); | |||
| String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); | |||
| result.put("rentalStartDate" + i, startdate); | |||
| result.put("rentalStartDateYear" + i, startdate.substring(0, 4)); | |||
| result.put("rentalStartDateMonth" + i, startdate.substring(5, 7)); | |||
| result.put("rentalStartDateDay" + i, startdate.substring(8)); | |||
| //结束时间 | |||
| instance.clear(); | |||
| instance.setTime(starttime); | |||
| instance.add(Calendar.MONTH, lease); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| Date endtime = instance.getTime(); | |||
| String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); | |||
| result.put("rentalEndDate" + i, enddate); | |||
| result.put("rentalEndDateYear" + i, enddate.substring(0, 4)); | |||
| result.put("rentalEndDateMonth" + i, enddate.substring(5, 7)); | |||
| result.put("rentalEndDateDay" + i, enddate.substring(8)); | |||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||
| rentPrice = new BigDecimal(priceArrs[i]).divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||
| result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue())); | |||
| result.put("priceRent" + i, rentPrice.toPlainString()); | |||
| result.put("adjustRatio" + i, adjustRatioList.get(i)); | |||
| } else { | |||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(i))) | |||
| .add(rentPrice).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||
| result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue())); | |||
| result.put("priceRent" + i, rentPrice.toPlainString()); | |||
| result.put("adjustRatio" + i, adjustRatioList.get(i)); | |||
| } | |||
| result.put("payRatio" + i, payRatioStr); | |||
| result.put("adjustPeriod" + i, wxRentContract.getAdjustPeriod()); | |||
| } | |||
| if (extracount > 0) { | |||
| //额外租期 | |||
| //开始时间 | |||
| Calendar instance = Calendar.getInstance(); | |||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||
| instance.add(Calendar.MONTH, lease * count); | |||
| Date starttime = instance.getTime(); | |||
| String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); | |||
| result.put("rentalStartDate" + count, startdate); | |||
| result.put("rentalStartDateYear" + count, startdate.substring(0, 4)); | |||
| result.put("rentalStartDateMonth" + count, startdate.substring(5, 7)); | |||
| result.put("rentalStartDateDay" + count, startdate.substring(8)); | |||
| //结束时间 | |||
| instance.clear(); | |||
| instance.setTime(starttime); | |||
| instance.add(Calendar.MONTH, extralease); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| Date endtime = instance.getTime(); | |||
| String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); | |||
| result.put("rentalEndDate" + count, enddate); | |||
| result.put("rentalEndDateYear" + count, enddate.substring(0, 4)); | |||
| result.put("rentalEndDateMonth" + count, enddate.substring(5, 7)); | |||
| result.put("rentalEndDateDay" + count, enddate.substring(8)); | |||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||
| rentPrice = new BigDecimal(priceArrs[count]).divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||
| result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue())); | |||
| result.put("priceRent" + count, rentPrice.toPlainString()); | |||
| } else { | |||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(count))) | |||
| .add(rentPrice).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||
| result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue())); | |||
| result.put("priceRent" + count, rentPrice.toPlainString()); | |||
| } | |||
| } | |||
| //无数据租期 | |||
| for (int i = paycount; i <= 10; i++) { | |||
| result.put("rentalStartDate" + i, "/"); | |||
| result.put("rentalStartDateYear" + i, "/"); | |||
| result.put("rentalStartDateMonth" + i, "/"); | |||
| result.put("rentalStartDateDay" + i, "/"); | |||
| result.put("rentalEndDate" + i, "/"); | |||
| result.put("rentalEndDateYear" + i, "/"); | |||
| result.put("rentalEndDateMonth" + i, "/"); | |||
| result.put("rentalEndDateDay" + i, "/"); | |||
| result.put("priceRentUpper" + i, "/"); | |||
| result.put("priceRent" + i, "/"); | |||
| result.put("adjustRatio" + i, "/"); | |||
| result.put("payRatio" + i, "/"); | |||
| result.put("adjustPeriod" + i, "/"); | |||
| } | |||
| } | |||
| @Override | |||
| public void updateApplyStatus(WxRentContract wxRentContract) { | |||
| wxRentContractMapper.updateApplyStatus(wxRentContract); | |||
| @@ -2351,8 +2114,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| public List<WxRentContractYearsVo> getRentContractYears(WxRentContract rentContract) { | |||
| String adjustRatio = rentContract.getAdjustRatio(); | |||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||
| integers.add(0, 0); | |||
| List<String> integers = JSONArray.parseArray(adjustRatio, String.class); | |||
| integers.add(0, "0"); | |||
| int years = integers.size(); | |||
| //合同以什么日期来计算开始计租日期 | |||
| if(rentContract.getRentStartType()!=null &&rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| @@ -2598,6 +2361,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return unitPropertyPrice; | |||
| } | |||
| public static void main(String[] args) { | |||
| Date startDate = DateUtils.stringToDate("2024-08-01 00:00:00", DateUtils.DATE_TIME_PATTERN); | |||
| Date endDate = DateUtils.stringToDate("2024-09-11 23:59:59", DateUtils.DATE_TIME_PATTERN); | |||
| Date realEndStart = DateUtils.getDaySet(endDate, Calendar.SECOND, 1); | |||
| int[] diffs = DateUtils.getDiff(startDate, realEndStart); | |||
| Date preextraStartDay = DateUtils.getTimeAfterMonths(diffs[0], startDate); | |||
| int predays = DateUtils.daysBetween(preextraStartDay, endDate)+1; | |||
| System.out.println(diffs[0]+">>>>" +diffs[1]+ ">>>>"+predays); | |||
| } | |||
| private BigDecimal[] calcuteReveneuJump(BigDecimal sales,WxRentContract rentcontract,Date startDate,Date endDate,List<Date> freePeriods) { | |||
| BigDecimal revenueDecimal = new BigDecimal(0); | |||
| @@ -2623,7 +2395,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if (!isFull) { | |||
| Date realEndStart = DateUtils.getDaySet(endDate, Calendar.SECOND, 1); | |||
| int[] diffs = DateUtils.getDiff(startDate, realEndStart); | |||
| if (diffs[0] <= 0 ) { | |||
| if (diffs[0] <= 0 || (diffs[0] == 1 && diffs[1] <= 0 )) { | |||
| if (rentcontract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { | |||
| sales = sales.multiply(new BigDecimal(validDates.size())).divide(new BigDecimal(30),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| }else { | |||
| @@ -2631,8 +2403,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| }else { | |||
| Date preextraStartDay = DateUtils.getTimeAfterMonths(diffs[0], startDate); | |||
| Date extraStartDayMonthEnd = DateUtils.getLastDayForMonth(preextraStartDay); | |||
| int predays = DateUtils.daysBetween(preextraStartDay, extraStartDayMonthEnd)+1; | |||
| int predays = DateUtils.daysBetween(preextraStartDay, endDate)+1; | |||
| if (rentcontract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { | |||
| BigDecimal days = new BigDecimal(diffs[0]).multiply(new BigDecimal(30)).add(new BigDecimal(predays)); | |||
| sales = sales.multiply(new BigDecimal(validDates.size())).divide(days,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| @@ -3198,8 +2969,4 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return wxRentContractRevenueJumpMapper.findList(jump); | |||
| } | |||
| public static void main(String[] args) { | |||
| Date date = DateUtils.stringToDate("2025-04-01 00:00:00",DateUtils.DATE_TIME_PATTERN); | |||
| System.out.println(date.getTime()); | |||
| } | |||
| } | |||
| @@ -13,10 +13,11 @@ | |||
| <result column="rate" jdbcType="VARCHAR" property="rate"/> | |||
| <result column="physics_type" jdbcType="INTEGER" property="physicsType"/> | |||
| <result column="shop_type" jdbcType="INTEGER" property="shopType"/> | |||
| <result column="has_fee" jdbcType="INTEGER" property="hasFee"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`type`,`rate`,`physics_type`,`shop_type` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`type`,`rate`,`physics_type`,`shop_type`,`has_fee` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -34,6 +35,7 @@ | |||
| <if test=" null != shopType ">and `shop_type` = #{shopType}</if> | |||
| <if test=" null != name and '' != name ">and name like concat('%', #{name},'%')</if> | |||
| <if test=" null != isRealMeter ">and `physics_type` in (1,2) </if> | |||
| <if test=" null != hasFee ">and `has_fee` = #{hasFee}</if> | |||
| <if test=" null != physicsTypeList "> | |||
| and physics_type in | |||
| <foreach collection="physicsTypeList" index="index" item="ptidItem" open="(" separator="," close=")"> | |||
| @@ -10,6 +10,7 @@ | |||
| <result column="calcute_id" jdbcType="BIGINT" property="calcuteId"/> | |||
| <result column="shop_id" jdbcType="BIGINT" property="shopId"/> | |||
| <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | |||
| <result column="fees_price" jdbcType="VARCHAR" property="feesPrice" /> | |||
| <result column="fees_shop_id" jdbcType="BIGINT" property="feesShopId"/> | |||
| <result column="money" jdbcType="VARCHAR" property="money" /> | |||
| <result column="period" jdbcType="VARCHAR" property="period" /> | |||
| @@ -17,7 +18,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`calcute_id`,`shop_id`,`fees_id`,`fees_shop_id`,`money`,`period`,`money_deail` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`calcute_id`,`shop_id`,`fees_id`,`fees_price`,`fees_shop_id`,`money`,`period`,`money_deail` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -36,6 +37,12 @@ | |||
| <if test=" null != shopId ">and `shop_id` = #{shopId}</if> | |||
| <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | |||
| <if test=" null != feesShopId ">and `fees_shop_id` = #{feesShopId}</if> | |||
| <if test=" null != feesIds "> | |||
| and fees_id in | |||
| <foreach collection="feesIds" index="index" item="feidItem" open="(" separator="," close=")"> | |||
| #{feidItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -72,7 +79,7 @@ | |||
| <foreach collection="list" item="item" index="index" separator=","> | |||
| ( | |||
| #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.createTime},#{item.updateTime},#{item.calcuteId}, | |||
| #{item.shopId},#{item.feesId},#{item.feesShopId},#{item.money},#{item.period},#{item.moneyDeail} | |||
| #{item.shopId},#{item.feesId},#{item.feesPrice},#{item.feesShopId},#{item.money},#{item.period},#{item.moneyDeail} | |||
| ) | |||
| </foreach> | |||
| </insert> | |||
| @@ -33,13 +33,13 @@ | |||
| <result column="rent" property="rent"/> | |||
| <result column="rent_unit" property="rentUnit"/> | |||
| <result column="business_id" property="businessId"/> | |||
| <result column="pulic_rate" jdbcType="VARCHAR" property="pulicRate"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`,`floor`,`status`,`x`,`y`,`sid`,`addr`, | |||
| `baidu_poi`,`longitude`,`latitude`,`create_date`,`update_date`,`img_url`,`manager`,`manager_phone`, | |||
| `type`,`point_type`,`comments`,`is_del`,DATEDIFF(now(),create_date) freeDay,rent,rent_unit,business_id | |||
| `type`,`point_type`,`comments`,`is_del`,DATEDIFF(now(),create_date) freeDay,rent,rent_unit,business_id,pulic_rate | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||