From 1458fa40c07dd13932ab9760d07ed6d26cc0201d Mon Sep 17 00:00:00 2001 From: winter <664946893@qq.com> Date: Mon, 16 Dec 2024 22:28:53 +0800 Subject: [PATCH] fix --- .../impl/WxRentContractServiceImpl.java | 78 +++++++++++++------ 1 file changed, 53 insertions(+), 25 deletions(-) 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 c20ff16b2..86ae51922 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -2793,14 +2793,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { suq.setShopIds(shopIdList); suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); Map shopUserMap = wxShopService.getShopUserMap(suq); + WxShop sq = new WxShop(); + sq.updateTenantInfo(sq); + sq.setIds(shopIdList); + Map shopMap = wxShopService.findShopMap(sq); - List rentBill = generateRentBill(user,shopIdList,shopUserMap,shopAreaRateMap,rentcontract,rentBillList,rentneedpay,rentRate,startDate,endDate,createFrom); + List rentBill = generateRentBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract,rentBillList,rentneedpay,rentRate,startDate,endDate,createFrom); - List propeBill = generatePropertyBill(user,shopIdList,shopUserMap,shopAreaRateMap,rentcontract, propertyContractId,propertyBillList,startDate,endDate, needpay, propertyRate,createFrom); + List propeBill = generatePropertyBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract, propertyContractId,propertyBillList,startDate,endDate, needpay, propertyRate,createFrom); - List bmbill = generateManageBill(user,shopIdList,shopUserMap,shopAreaRateMap,rentcontract, startDate,endDate, needpay, bussinessRate, EnumBillAllType.RENT_BUSSINESS_MANAGE,createFrom); + List bmbill = generateManageBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract, startDate,endDate, needpay, bussinessRate, EnumBillAllType.RENT_BUSSINESS_MANAGE,createFrom); - List ombill = generateManageBill(user,shopIdList,shopUserMap,shopAreaRateMap,rentcontract, startDate,endDate, needpay, operaterRate, EnumBillAllType.RENT_OPERATION_MANAGE,createFrom); + List ombill = generateManageBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract, startDate,endDate, needpay, operaterRate, EnumBillAllType.RENT_OPERATION_MANAGE,createFrom); WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo(); vo.setTotal(needpay); @@ -2820,7 +2824,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public List generateManageBill(MallUserInfo user,List shopIds,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, + public List generateManageBill(MallUserInfo user,List shopIds,Map shopMap,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, Date starttime, Date endtime,String total,String rate,EnumBillAllType type,EnumBillExtraCreateFrom createFrom) { WxAllBill bussinessmanageBill = new WxAllBill(); bussinessmanageBill.updateTenantInfo(rentcontract); @@ -2832,12 +2836,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { bussinessmanageBill.setStarttimeEqual(starttime); bussinessmanageBill.setEndtimeEqual(endtime); List bmbillList = wxAllBillMapper.findList(bussinessmanageBill); - String bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); + BigDecimal bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).setScale(Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); if (null != bmbillList && bmbillList.size() > 0 ) { //查询每一个铺位的 for (int i = 0 ; i < bmbillList.size() ; i ++) { WxAllBill b = bmbillList.get(i); //把原有的账单应收金额变为0 + b.setNeedPay("0");//如不设置会影响减免统计 b.setReceivePay("0"); b.setBillRemark("账单金额重新计算生成新账单,原账单金额变为0"); b.setUpdatetime(new Date()); @@ -2846,14 +2851,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxAllBillMapper.updateById(b); } } - if (new BigDecimal(bussinessmoney).compareTo(new BigDecimal(0)) > 0 ) { + if (bussinessmoney.compareTo(new BigDecimal(0)) > 0 ) { List billList = new ArrayList(); for (int i = 0 ; i < shopIds.size(); i++) { Long sid = shopIds.get(i); BigDecimal shoprentArea = shopAreaRateMap.get(sid); - BigDecimal shoprate = shoprentArea.divide(new BigDecimal(rentcontract.getRentArea()),rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); + BigDecimal shoprate = shoprentArea.divide(new BigDecimal(rentcontract.getRentArea()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - String newmoney = new BigDecimal(bussinessmoney).multiply(shoprate).setScale(rentcontract.getDecimalSize()).toPlainString(); + String newmoney = bussinessmoney.multiply(shoprate).setScale(rentcontract.getDecimalSize()).toPlainString(); WxAllBill b = new WxAllBill(); final IdWorker idWorker = IdWorker.get(); b.setId(idWorker.nextId()); @@ -2886,10 +2891,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { b.setEndtime(endtime); b.setReceiveDate(starttime); b.setPeriod(WxRentContractHelper.getPeriod(starttime)); - b.setBillRemark(createFrom.getMessage()+"自动计算创建,科目总计分摊比率为:"+rate+",总应收金额为:"+bussinessmoney+"元,"+",本铺分担比例"+shoprate.toEngineeringString()); + b.setBillRemark(createFrom.getMessage()+"自动计算创建,科目总应收金额为:"+bussinessmoney.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toEngineeringString()); b.setExtraCreateFrom(createFrom.getCode()); - b.setMoneyChangeDetail("自动计算创建,科目总计分摊比率为:"+rate+",总应收金额为:"+bussinessmoney+"元,"+",本铺分担比例"+shoprate.toEngineeringString()); + b.setMoneyChangeDetail("自动计算创建,科目总应收金额为:"+bussinessmoney.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toEngineeringString()); wxAllBillMapper.insert(b); + if (null != shopMap) { + WxShop s = shopMap.get(sid); + if ( null != s) { + b.setShopNumber(s.getShopNumber()); + } + } billList.add(b); } return billList; @@ -2899,14 +2910,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { } @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public List generatePropertyBill(MallUserInfo user,List shopIds,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, + public List generatePropertyBill(MallUserInfo user,List shopIds,Map shopMap,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, Long propertyContractId,List propertyBillList,Date starttime,Date endtime,String total,String rate,EnumBillExtraCreateFrom createFrom) { - String bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); + BigDecimal bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).setScale(Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); if (null != propertyBillList ) { if (null != propertyBillList) { for (int i = 0 ; i < propertyBillList.size(); i++){ WxAllBill _rb = propertyBillList.get(i); //把原有的账单应收金额变为0 + _rb.setNeedPay("0"); _rb.setReceivePay("0"); _rb.setBillRemark("账单金额重新计算生成新账单,原账单金额变为0"); _rb.setUpdatetime(new Date()); @@ -2916,13 +2928,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } } - if (new BigDecimal(bussinessmoney).compareTo(new BigDecimal(0)) > 0 ) { + if (bussinessmoney.compareTo(new BigDecimal(0)) > 0 ) { List billList = new ArrayList(); for (int i = 0 ; i < shopIds.size() ; i ++) { Long sid = shopIds.get(i); BigDecimal shoprentArea = shopAreaRateMap.get(sid); - BigDecimal shoprate = shoprentArea.divide(new BigDecimal(rentcontract.getRentArea()),rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); + BigDecimal shoprate = shoprentArea.divide(new BigDecimal(rentcontract.getRentArea()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); + String newmoney = bussinessmoney.multiply(shoprate).setScale(rentcontract.getDecimalSize()).toPlainString(); WxAllBill bmbill = new WxAllBill(); final IdWorker idWorker = IdWorker.get(); bmbill.setId(idWorker.nextId()); @@ -2949,17 +2962,23 @@ public class WxRentContractServiceImpl implements WxRentContractService { bmbill.setUpdateBy(user.getId()); bmbill.setUpdateByName(user.getName()); bmbill.setPriceDetail(""); - bmbill.setNeedPay(bussinessmoney); - bmbill.setReceivePay(bussinessmoney); + bmbill.setNeedPay(newmoney); + bmbill.setReceivePay(newmoney); bmbill.setPay("0"); bmbill.setStarttime(starttime); bmbill.setEndtime(endtime); bmbill.setReceiveDate(starttime); bmbill.setPeriod(WxRentContractHelper.getPeriod(starttime)); - bmbill.setBillRemark(createFrom.getMessage()+".自动计算创建,科目分摊比率为:"+rate+",总应收金额为:"+bussinessmoney+"元,"+",本铺分担比例"+shoprate.toEngineeringString()); + bmbill.setBillRemark(createFrom.getMessage()+".自动计算创建,科目总应收金额为:"+bussinessmoney.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toEngineeringString()); bmbill.setExtraCreateFrom(createFrom.getCode()); - bmbill.setMoneyChangeDetail("自动计算创建,科目分摊比率为:"+rate+",总应收金额为:"+bussinessmoney+"元,"+",本铺分担比例"+shoprate.toEngineeringString()); + bmbill.setMoneyChangeDetail("自动计算创建,科目总应收金额为:"+bussinessmoney.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toEngineeringString()); wxAllBillMapper.insert(bmbill); + if (null != shopMap) { + WxShop s = shopMap.get(sid); + if ( null != s) { + bmbill.setShopNumber(s.getShopNumber()); + } + } billList.add(bmbill); } return billList; @@ -2969,7 +2988,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public List generateRentBill(MallUserInfo user,List shopIds,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, + public List generateRentBill(MallUserInfo user,List shopIds,Map shopMap,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, List rentBillList,String money,String rate,Date starttime,Date endtime,EnumBillExtraCreateFrom createFrom) { //rentBillList , 如果是多个房间,则就有几个租金账单 if (null != rentBillList && rentBillList.size() > 0 ) { @@ -2977,6 +2996,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { for (int i = 0 ; i < rentBillList.size() ; i ++) { WxAllBill b = rentBillList.get(i); //把原有的账单应收金额变为0 + b.setNeedPay("0");//如不设置会影响减免统计 b.setReceivePay("0"); b.setBillRemark("账单金额重新计算生成新账单,原账单金额变为0"); b.setUpdatetime(new Date()); @@ -2985,12 +3005,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxAllBillMapper.updateById(b); } } - + BigDecimal moneyb = new BigDecimal(money); List billList = new ArrayList(); for (int i = 0 ; i < shopIds.size(); i++) { Long sid = shopIds.get(i); BigDecimal shoprentArea = shopAreaRateMap.get(sid); - BigDecimal shoprate = shoprentArea.divide(new BigDecimal(rentcontract.getRentArea()),rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); + BigDecimal shoprate = shoprentArea.divide(new BigDecimal(rentcontract.getRentArea()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); + + String newmoney = moneyb.multiply(shoprate).setScale(rentcontract.getDecimalSize()).toPlainString(); WxAllBill bmbill = new WxAllBill(); final IdWorker idWorker = IdWorker.get(); bmbill.setId(idWorker.nextId()); @@ -3016,17 +3038,23 @@ public class WxRentContractServiceImpl implements WxRentContractService { bmbill.setUpdateBy(user.getId()); bmbill.setUpdateByName(user.getName()); bmbill.setPriceDetail(""); - bmbill.setNeedPay(new BigDecimal(money).multiply(shoprate).toPlainString()); + bmbill.setNeedPay(newmoney); bmbill.setReceivePay(bmbill.getNeedPay()); bmbill.setPay("0"); bmbill.setStarttime(starttime); bmbill.setEndtime(endtime); bmbill.setReceiveDate(starttime); bmbill.setPeriod(WxRentContractHelper.getPeriod(starttime)); - bmbill.setBillRemark(createFrom.getMessage()+".自动计算创建,科目分摊比例为"+rate+",计算总应收金额为:"+money+"元,"+",本铺分担比例"+shoprate.toEngineeringString()); + bmbill.setBillRemark(createFrom.getMessage()+".自动计算创建,科目总应收金额为:"+moneyb.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toEngineeringString()); bmbill.setExtraCreateFrom(createFrom.getCode()); - bmbill.setMoneyChangeDetail("自动计算创建,科目分摊比例为"+rate+",计算总应收金额为:"+money+"元,"+",本铺分担比例"+shoprate.toEngineeringString()); + bmbill.setMoneyChangeDetail("自动计算创建,自动计算创建,科目总应收金额为:"+moneyb.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toEngineeringString()); wxAllBillMapper.insert(bmbill); + if (null != shopMap) { + WxShop s = shopMap.get(sid); + if ( null != s) { + bmbill.setShopNumber(s.getShopNumber()); + } + } billList.add(bmbill); } return billList;