| @@ -290,17 +290,16 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| //查询主账单列表,排除其他标砖费用,包括一次性费用,非一次性费用 | //查询主账单列表,排除其他标砖费用,包括一次性费用,非一次性费用 | ||||
| WxAllBill wxBillRent = new WxAllBill(); | WxAllBill wxBillRent = new WxAllBill(); | ||||
| wxBillRent.setPropertyContractId(id); | wxBillRent.setPropertyContractId(id); | ||||
| wxBillRent.setSortColumns("starttime asc"); | |||||
| wxBillRent.updateTenantInfo(tenantEntity); | wxBillRent.updateTenantInfo(tenantEntity); | ||||
| //物业主账单 | //物业主账单 | ||||
| wxBillRent.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId()); | wxBillRent.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId()); | ||||
| List<WxAllBill> retList = wxAllBillMapper.findList(wxBillRent); | |||||
| List<WxAllBill> retList = wxAllBillMapper.findContractSamePeriodSum(wxBillRent); | |||||
| //获取非一次性的, | //获取非一次性的, | ||||
| wxBillRent.setEnergyFeesId(null); | wxBillRent.setEnergyFeesId(null); | ||||
| wxBillRent.setBillType(EnumBillAllType.PROPERTY.getCode()); | wxBillRent.setBillType(EnumBillAllType.PROPERTY.getCode()); | ||||
| wxBillRent.setHasParentBillId(EnumYesOrNo.YES.getCode()); | wxBillRent.setHasParentBillId(EnumYesOrNo.YES.getCode()); | ||||
| List<WxAllBill> unFixedList = wxAllBillMapper.findList(wxBillRent); | |||||
| List<WxAllBill> unFixedList = wxAllBillMapper.findContractSamePeriodSum(wxBillRent); | |||||
| Map<Long,List<WxAllBill>> childMap = null; | Map<Long,List<WxAllBill>> childMap = null; | ||||
| if (null != unFixedList && unFixedList.size() > 0 ) { | if (null != unFixedList && unFixedList.size() > 0 ) { | ||||
| childMap = new HashMap<Long,List<WxAllBill>>(); | childMap = new HashMap<Long,List<WxAllBill>>(); | ||||
| @@ -873,7 +872,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| 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<WxAllBill> propertyResultList = new ArrayList<WxAllBill>(); | List<WxAllBill> propertyResultList = new ArrayList<WxAllBill>(); | ||||
| List<WxAllBill> allResultList = new ArrayList<WxAllBill>(); | |||||
| List<WxAllBill> fixedResultList = new ArrayList<WxAllBill>(); | |||||
| Date endDate = null; | Date endDate = null; | ||||
| if(yearList.size() > 1){ | if(yearList.size() > 1){ | ||||
| @@ -997,72 +996,72 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| //设置科目 | //设置科目 | ||||
| property.setEnergyFeesId(svo.getFeeStandards().getId()); | property.setEnergyFeesId(svo.getFeeStandards().getId()); | ||||
| property.setFeesStandarsId(property.getEnergyFeesId());//合同动态表格需要。 | property.setFeesStandarsId(property.getEnergyFeesId());//合同动态表格需要。 | ||||
| allResultList.add(property); | |||||
| childList.add(property); | childList.add(property); | ||||
| } | } | ||||
| } | } | ||||
| wxBillProperty.setChildList(childList); | wxBillProperty.setChildList(childList); | ||||
| //主账单列表 | //主账单列表 | ||||
| propertyResultList.add(wxBillProperty); | propertyResultList.add(wxBillProperty); | ||||
| if (new BigDecimal(wxBillProperty.getReceivePay()).compareTo(new BigDecimal(0)) > 0 ) { | |||||
| allResultList.add(wxBillProperty); | |||||
| } | |||||
| } | } | ||||
| if (null != fixedList && fixedList.size() > 0 ) { | if (null != fixedList && fixedList.size() > 0 ) { | ||||
| for (int i = 0 ; i < fixedList.size(); i ++ ) { | for (int i = 0 ; i < fixedList.size(); i ++ ) { | ||||
| WxBillFeesStandardsListVo svo = fixedList.get(i); | WxBillFeesStandardsListVo svo = fixedList.get(i); | ||||
| WxAllBill property = generateBillPropertyByBillStandards(null,wxPayAccountBill,wxPropertyContract,isPreview,user,svo,billcount,shopInfo); | WxAllBill property = generateBillPropertyByBillStandards(null,wxPayAccountBill,wxPropertyContract,isPreview,user,svo,billcount,shopInfo); | ||||
| allResultList.add(property); | |||||
| fixedResultList.add(property); | |||||
| } | } | ||||
| } | } | ||||
| //批量生成预账单 | //批量生成预账单 | ||||
| if(saveDb && allResultList.size() > 0 ) { | |||||
| if(saveDb) { | |||||
| WxShopUsers suq = new WxShopUsers(); | WxShopUsers suq = new WxShopUsers(); | ||||
| suq.updateTenantInfo(wxPropertyContract); | suq.updateTenantInfo(wxPropertyContract); | ||||
| suq.setShopIds(shopIdList); | suq.setShopIds(shopIdList); | ||||
| suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); | suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); | ||||
| Map<Long,WxShopUsers> shopUserMap = wxShopService.getShopUserMap(suq); | Map<Long,WxShopUsers> shopUserMap = wxShopService.getShopUserMap(suq); | ||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| //根据店铺来拆分 | //根据店铺来拆分 | ||||
| List<WxAllBill> shopAllBillList = new ArrayList<WxAllBill>(); | List<WxAllBill> shopAllBillList = new ArrayList<WxAllBill>(); | ||||
| for (int i = 0 ; i < allResultList.size(); i++ ) { | |||||
| WxAllBill rb = allResultList.get(i); | |||||
| for (int g = 0 ; g < shopIdList.size(); g ++ ){ | |||||
| WxAllBill rs = new WxAllBill(); | |||||
| Long sid = shopIdList.get(g); | |||||
| BigDecimal shoprentArea = shopAreaRateMap.get(sid); | |||||
| BigDecimal shoprate = shoprentArea.divide(new BigDecimal(wxPropertyContract.getRentArea()),wxPropertyContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| try { | |||||
| BeanUtils.copyProperties(rs, rb); | |||||
| rs.setId(idWorker.nextId()); | |||||
| rs.setShopId(sid); | |||||
| rs.setNeedPay(new BigDecimal(rb.getNeedPay()).multiply(shoprate).toPlainString()); | |||||
| rs.setReceivePay(rs.getNeedPay()); | |||||
| rs.setShopId(sid); | |||||
| rs.setRentArea(shoprentArea.toPlainString()); | |||||
| if (null != shopUserMap ) { | |||||
| WxShopUsers wsu = shopUserMap.get(sid); | |||||
| if (null != wsu) { | |||||
| rs.setCusName(wsu.getName()); | |||||
| } | |||||
| }; | |||||
| shopAllBillList.add(rs); | |||||
| } catch (IllegalAccessException e) { | |||||
| logger.error("saveBill error.",e); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); | |||||
| } catch (InvocationTargetException e) { | |||||
| logger.error("saveBill error.",e); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); | |||||
| } | |||||
| } | |||||
| if (propertyResultList.size() > 0 ) { | |||||
| for (int i = 0 ; i < propertyResultList.size(); i++ ) { | |||||
| WxAllBill rb = propertyResultList.get(i); | |||||
| for (int g = 0 ; g < shopIdList.size(); g ++ ){ | |||||
| //主物业账单根据店铺拆分 | |||||
| Long sid = shopIdList.get(g); | |||||
| WxAllBill rs = new WxAllBill(); | |||||
| setNewsBills(wxPropertyContract, rs, rb, sid, shopAreaRateMap,shopUserMap); | |||||
| shopAllBillList.add(rs); | |||||
| //其他周期的费用账单也需要拆分,并关联parentBillId | |||||
| if (null != rb.getChildList() && rb.getChildList().size() > 0) { | |||||
| for (int h = 0 ; h < rb.getChildList().size(); h++ ) { | |||||
| WxAllBill ufb = rb.getChildList().get(h); | |||||
| WxAllBill ufbn = new WxAllBill(); | |||||
| setNewsBills(wxPropertyContract, ufbn, ufb, sid, shopAreaRateMap,shopUserMap); | |||||
| ufbn.setParentBillId(rs.getId()); | |||||
| shopAllBillList.add(rs); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| //一次性费用 | |||||
| if (fixedResultList.size() > 0 ) { | |||||
| for (int i = 0 ; i < fixedResultList.size(); i++ ) { | |||||
| WxAllBill rb = fixedResultList.get(i); | |||||
| for (int g = 0 ; g < shopIdList.size(); g ++ ){ | |||||
| Long sid = shopIdList.get(g); | |||||
| WxAllBill rs = new WxAllBill(); | |||||
| setNewsBills(wxPropertyContract, rs, rb, sid, shopAreaRateMap,shopUserMap); | |||||
| shopAllBillList.add(rs); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| wxAllBillMapper.insertBills(wxPropertyContract.getTenantId() ,shopAllBillList); | |||||
| if (shopAllBillList.size() > 0 ) { | |||||
| wxAllBillMapper.insertBills(wxPropertyContract.getTenantId() ,shopAllBillList); | |||||
| } | |||||
| //for (int i = 0 ; i < resultList.size() ; i++) { | //for (int i = 0 ; i < resultList.size() ; i++) { | ||||
| // wxBillPropertyMapper.insert(resultList.get(i)); | // wxBillPropertyMapper.insert(resultList.get(i)); | ||||
| //} | //} | ||||
| @@ -1072,6 +1071,33 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| return resultMap; | return resultMap; | ||||
| } | } | ||||
| private void setNewsBills(WxPropertyContract wxPropertyContract,WxAllBill newBill,WxAllBill oldBill,Long shopId,Map<Long, BigDecimal> shopAreaRateMap,Map<Long,WxShopUsers> shopUserMap) { | |||||
| BigDecimal shoprentArea = shopAreaRateMap.get(shopId); | |||||
| BigDecimal shoprate = shoprentArea.divide(new BigDecimal(wxPropertyContract.getRentArea()),wxPropertyContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| try { | |||||
| BeanUtils.copyProperties(newBill, oldBill); | |||||
| newBill.setId(idWorker.nextId()); | |||||
| newBill.setShopId(shopId); | |||||
| newBill.setNeedPay(new BigDecimal(oldBill.getNeedPay()).multiply(shoprate).toPlainString()); | |||||
| newBill.setReceivePay(newBill.getNeedPay()); | |||||
| newBill.setRentArea(shoprentArea.toPlainString()); | |||||
| if (null != shopUserMap ) { | |||||
| WxShopUsers wsu = shopUserMap.get(shopId); | |||||
| if (null != wsu) { | |||||
| newBill.setCusName(wsu.getName()); | |||||
| } | |||||
| }; | |||||
| } catch (IllegalAccessException e) { | |||||
| logger.error("saveBill error.",e); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); | |||||
| } catch (InvocationTargetException e) { | |||||
| logger.error("saveBill error.",e); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); | |||||
| } | |||||
| } | |||||
| private WxAllBill generateBillPropertyByBillStandards(WxAllBill wxBillProperty,WxPayAccountBill wxPayAccountBill,WxPropertyContract wxPropertyContract,Integer isPreview,MallUserInfo user,WxBillFeesStandardsListVo svo, | private WxAllBill generateBillPropertyByBillStandards(WxAllBill wxBillProperty,WxPayAccountBill wxPayAccountBill,WxPropertyContract wxPropertyContract,Integer isPreview,MallUserInfo user,WxBillFeesStandardsListVo svo, | ||||
| Integer billcount,Map<String, Object> shopInfo) { | Integer billcount,Map<String, Object> shopInfo) { | ||||