| @@ -34,6 +34,7 @@ import com.iformall.enums.EnumRentContractAgileFeesType; | |||||
| import com.iformall.enums.EnumRentContractAppStatus; | import com.iformall.enums.EnumRentContractAppStatus; | ||||
| import com.iformall.enums.EnumRentContractStatus; | import com.iformall.enums.EnumRentContractStatus; | ||||
| import com.iformall.enums.EnumRentDayPriceCalcute; | import com.iformall.enums.EnumRentDayPriceCalcute; | ||||
| import com.iformall.enums.EnumShopUsersStatus; | |||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxAllBillMapper; | import com.iformall.mapper.WxAllBillMapper; | ||||
| @@ -282,18 +283,18 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| if (unDeposit.getSettingMethod() == EnumRentContractAgilSettingMethod.BY_CONTRACT.getCode()) { | if (unDeposit.getSettingMethod() == EnumRentContractAgilSettingMethod.BY_CONTRACT.getCode()) { | ||||
| validItem(unDeposit.getItems(), contract); | validItem(unDeposit.getItems(), contract); | ||||
| }else { | }else { | ||||
| Map<String,List<WxRentContractAgileUnDepositItem>> shopNumberUnDepositItems = new HashMap<String,List<WxRentContractAgileUnDepositItem>>(); | |||||
| Map<Long,List<WxRentContractAgileUnDepositItem>> shopNumberUnDepositItems = new HashMap<Long,List<WxRentContractAgileUnDepositItem>>(); | |||||
| for (int i = 0 ; i < unDeposit.getItems().size(); i++) { | for (int i = 0 ; i < unDeposit.getItems().size(); i++) { | ||||
| WxRentContractAgileUnDepositItem item = unDeposit.getItems().get(i); | WxRentContractAgileUnDepositItem item = unDeposit.getItems().get(i); | ||||
| List<WxRentContractAgileUnDepositItem> list = shopNumberUnDepositItems.get(item.getShopNumber()); | |||||
| List<WxRentContractAgileUnDepositItem> list = shopNumberUnDepositItems.get(item.getShopId()); | |||||
| if (null == list) { | if (null == list) { | ||||
| list = new ArrayList<WxRentContractAgileUnDepositItem>(); | list = new ArrayList<WxRentContractAgileUnDepositItem>(); | ||||
| } | } | ||||
| list.add(item); | list.add(item); | ||||
| } | } | ||||
| for (Iterator<String> it = shopNumberUnDepositItems.keySet().iterator(); it.hasNext();) { | |||||
| String shopNumber = it.next(); | |||||
| validItem(shopNumberUnDepositItems.get(shopNumber), contract); | |||||
| for (Iterator<Long> it = shopNumberUnDepositItems.keySet().iterator(); it.hasNext();) { | |||||
| Long sid = it.next(); | |||||
| validItem(shopNumberUnDepositItems.get(sid), contract); | |||||
| } | } | ||||
| } | } | ||||
| @@ -470,7 +471,14 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| WxRentContract contract = wxRentContractMapper.selectById(unDeposit.getRentContractId()); | WxRentContract contract = wxRentContractMapper.selectById(unDeposit.getRentContractId()); | ||||
| EnumRentDayPriceCalcute dayPriceCalcute = EnumRentDayPriceCalcute.getEnum(contract.getDayPriceCalcute()); | EnumRentDayPriceCalcute dayPriceCalcute = EnumRentDayPriceCalcute.getEnum(contract.getDayPriceCalcute()); | ||||
| List<Date> yearsBeginList = WxRentContractAgileHelper.getYearsBeginList(contract.getRentalStartDate(), contract.getRentalEndDate()); | List<Date> yearsBeginList = WxRentContractAgileHelper.getYearsBeginList(contract.getRentalStartDate(), contract.getRentalEndDate()); | ||||
| List<Long> shopIdList = contract.shopIdsByRentInfo(); | |||||
| Map<Long, BigDecimal> shopAreaMap = contract.getRentShopArea(); | |||||
| WxShopUsers suq = new WxShopUsers(); | |||||
| suq.updateTenantInfo(contract); | |||||
| suq.setShopIds(shopIdList); | |||||
| suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); | |||||
| Map<Long, WxShopUsers> shopUserMap = wxShopService.getShopUserMap(suq); | |||||
| List<WxAllBill> insertList = new ArrayList<WxAllBill>(); | List<WxAllBill> insertList = new ArrayList<WxAllBill>(); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -482,9 +490,9 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| if (timeUnit == EnumRentContractAgilTimeUnit.RENT_PERIOD) { | if (timeUnit == EnumRentContractAgilTimeUnit.RENT_PERIOD) { | ||||
| String needpay = WxRentContractAgileHelper.getNeedPayMoney(null, contract.getDecimalSize(), itemPriceUnit,item.getPrice(), item.getRentArea(), | String needpay = WxRentContractAgileHelper.getNeedPayMoney(null, contract.getDecimalSize(), itemPriceUnit,item.getPrice(), item.getRentArea(), | ||||
| item.getBeginTime(), item.getEndTime(), dayPriceCalcute, contract.getMonthAverageDays(), unDeposit.getTimePeriod(), timeUnit); | item.getBeginTime(), item.getEndTime(), dayPriceCalcute, contract.getMonthAverageDays(), unDeposit.getTimePeriod(), timeUnit); | ||||
| WxAllBill wxBillRent = generateUnDepositBill(idWorker,unDeposit,fees,item.getBeginTime(), | |||||
| item.getEndTime(),item.getBeginTime(),needpay,item,shopNumber,user); | |||||
| insertList.add(wxBillRent); | |||||
| List<WxAllBill> wxBillRent = generateUnDepositBill(shopIdList,shopAreaMap,shopUserMap,contract,idWorker,unDeposit,fees,item.getBeginTime(), | |||||
| item.getEndTime(),item.getBeginTime(),needpay,item,user); | |||||
| insertList.addAll(wxBillRent); | |||||
| }else { | }else { | ||||
| //根据每一个的开始日期,结束日期来生成账单 | //根据每一个的开始日期,结束日期来生成账单 | ||||
| List<BillTimeVo> timeVoList = WxRentContractAgileHelper.initBillTimeList(yearsBeginList, item.getBeginTime(), item.getEndTime(), creatRule, timeUnit, unDeposit.getTimePeriod(), unDeposit.getCalcuteTime()); | List<BillTimeVo> timeVoList = WxRentContractAgileHelper.initBillTimeList(yearsBeginList, item.getBeginTime(), item.getEndTime(), creatRule, timeUnit, unDeposit.getTimePeriod(), unDeposit.getCalcuteTime()); | ||||
| @@ -492,9 +500,9 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| BillTimeVo timeVo = timeVoList.get(j); | BillTimeVo timeVo = timeVoList.get(j); | ||||
| String needpay = WxRentContractAgileHelper.getNeedPayMoney(null, contract.getDecimalSize(), itemPriceUnit,item.getPrice(), item.getRentArea(), | String needpay = WxRentContractAgileHelper.getNeedPayMoney(null, contract.getDecimalSize(), itemPriceUnit,item.getPrice(), item.getRentArea(), | ||||
| timeVo.getStartDate(), timeVo.getEndDate(), dayPriceCalcute, contract.getMonthAverageDays(), unDeposit.getTimePeriod(), timeUnit); | timeVo.getStartDate(), timeVo.getEndDate(), dayPriceCalcute, contract.getMonthAverageDays(), unDeposit.getTimePeriod(), timeUnit); | ||||
| WxAllBill wxBillRent = generateUnDepositBill(idWorker,unDeposit,fees,timeVo.getStartDate(), | |||||
| timeVo.getEndDate(),timeVo.getReceiveDate(),needpay,item,shopNumber,user); | |||||
| insertList.add(wxBillRent); | |||||
| List<WxAllBill> wxBillRent = generateUnDepositBill(shopIdList,shopAreaMap,shopUserMap,contract,idWorker,unDeposit,fees,timeVo.getStartDate(), | |||||
| timeVo.getEndDate(),timeVo.getReceiveDate(),needpay,item,user); | |||||
| insertList.addAll(wxBillRent); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -510,29 +518,36 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| } | } | ||||
| } | } | ||||
| private List<WxAllBill> generateUnDepositBill(List<Long> shopIdList,Map<Long, BigDecimal> shopAreaRateMap,Map<Long, WxShopUsers> shopUserMap,final IdWorker idWorker,WxRentContractAgileUnDeposit unDeposit, | |||||
| WxEnergyFees fees,Date start,Date end,Date receiveDate,String needpay,WxRentContractAgileUnDepositItem item,MallUserInfo user) { | |||||
| private List<WxAllBill> generateUnDepositBill(List<Long> shopIdList,Map<Long, BigDecimal> shopAreaMap,Map<Long, WxShopUsers> shopUserMap,WxRentContract contract, | |||||
| final IdWorker idWorker,WxRentContractAgileUnDeposit unDeposit,WxEnergyFees fees,Date start,Date end,Date receiveDate,String needpay, | |||||
| WxRentContractAgileUnDepositItem item,MallUserInfo user) { | |||||
| List<WxAllBill> billList = new ArrayList<WxAllBill>(); | |||||
| //如果是按合同,则按照铺来分 | //如果是按合同,则按照铺来分 | ||||
| if (unDeposit.getSettingMethod() == EnumRentContractAgilSettingMethod.BY_CONTRACT.getCode()) { | if (unDeposit.getSettingMethod() == EnumRentContractAgilSettingMethod.BY_CONTRACT.getCode()) { | ||||
| for (int i = 0 ; i < shopIdList.size(); i++) { | for (int i = 0 ; i < shopIdList.size(); i++) { | ||||
| Long sid= shopIdList.get(i); | Long sid= shopIdList.get(i); | ||||
| BigDecimal shoprate = shopAreaRateMap.get(sid); | |||||
| BigDecimal shoprentArea = shopAreaMap.get(sid); | |||||
| BigDecimal shoprate = shoprentArea.divide(new BigDecimal(contract.getRentArea()),contract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| WxShopUsers su = shopUserMap.get(sid); | |||||
| String cusName = ""; | String cusName = ""; | ||||
| buildUnDepositBill(unDeposit,idWorker,unDeposit.getRentContractId(),fees,sid,cusName,start,end,receiveDate,needpay,item.getRentArea(),user); | |||||
| if (null != su) { | |||||
| cusName = su.getName(); | |||||
| } | |||||
| String money = new BigDecimal(needpay).multiply(shoprate).toPlainString(); | |||||
| WxAllBill bill = buildUnDepositBill(unDeposit,idWorker,contract.getId(),fees,sid,cusName,start,end,receiveDate,money,shoprentArea.toPlainString(),user); | |||||
| billList.add(bill); | |||||
| } | } | ||||
| }else { | }else { | ||||
| for (int i = 0 ; i < shopIdList.size(); i++) { | |||||
| Long sid= shopIdList.get(i); | |||||
| BigDecimal shoprate = shopAreaRateMap.get(sid); | |||||
| Long sid= item.getShopId(); | |||||
| WxShopUsers su = shopUserMap.get(sid); | |||||
| String cusName = ""; | String cusName = ""; | ||||
| buildUnDepositBill(unDeposit,idWorker,unDeposit.getRentContractId(),fees,item.getShopId(),cusName,start,end,receiveDate,needpay,item.getRentArea(),user); | |||||
| } | |||||
| if (null != su) { | |||||
| cusName = su.getName(); | |||||
| } | |||||
| WxAllBill bill = buildUnDepositBill(unDeposit,idWorker,contract.getId(),fees,sid,cusName,start,end,receiveDate,needpay,item.getRentArea(),user); | |||||
| billList.add(bill); | |||||
| } | } | ||||
| return wxBillRent; | |||||
| return billList; | |||||
| } | } | ||||
| private WxAllBill buildUnDepositBill(TenantEntity tenantEntity,final IdWorker idWorker,Long rentContractId,WxEnergyFees fees, | private WxAllBill buildUnDepositBill(TenantEntity tenantEntity,final IdWorker idWorker,Long rentContractId,WxEnergyFees fees, | ||||