diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java index c9f9c5d96..6a262bd98 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java @@ -84,6 +84,7 @@ public class WxAgileContractController extends WxContractBaseController { } PageInfo page = wxAgileContractService.getRentContractList(wxRentContract, pageNum, pageSize); Integer hasFlow = null; + Integer hasFlowValidEdit = null; if (null != page && null != page.getList()) { for (WxRentContract wrc: page.getList()) { if (null == hasFlow) { @@ -94,9 +95,17 @@ public class WxAgileContractController extends WxContractBaseController { } } wrc.setFlowHas(hasFlow); + + if (null == hasFlowValidEdit) { + if(rentContractHasEditValidWorkFlow(wrc)) { + hasFlowValidEdit = 1; + }else { + hasFlowValidEdit = 0; + } + } + wrc.setFlowHasValidEdit(hasFlowValidEdit); } } - return new ResultData(page); } @@ -138,64 +147,140 @@ public class WxAgileContractController extends WxContractBaseController { public ResultData saveOrUpdate(@RequestBody WxRentContract wxRentContract) { MallUserInfo user = getUser(); wxRentContract.updateTenantInfo(user); - //wxRentContract.setAgileType(EnumRentAgileType.AGILE.getCode()); - if (null == wxRentContract.getDayPriceCalcute()) { - return new ResultData(Result.ERROR,"请选择日均单价计费规则"); + + //如果是修改,并且合同是生效的,则不允许 + if (null != wxRentContract.getId()) { + WxRentContract r = wxAgileContractService.selectById(wxRentContract.getId()); + if (r.getStatus().intValue() == EnumRentContractStatus.DRAFT.getCode().intValue() || + r.getStatus().intValue() == EnumRentContractStatus.UNWRITE.getCode().intValue()) { + }else { + return new ResultData(Result.ERROR,"该状态不允许修改"); + } + } + + try { + handleSaveData(wxRentContract); + }catch(Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + + return wxAgileContractService.saveOrUpdate(wxRentContract, user); + } + + private void handleSaveData(WxRentContract wxRentContract) { + if (null == wxRentContract.getDayPriceCalcute()) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择日均单价计费规则"); } //以前合同必填的数据初始化 - wxRentContract.setDecimalSize(2); + //wxRentContract.setDecimalSize(2); if (null == wxRentContract.getRentalStartDate()) { - return new ResultData(Result.ERROR,"请选择合同开始日期"); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择合同开始日期"); } if (null == wxRentContract.getRentalEndDate()) { - return new ResultData(Result.ERROR,"请选择合同结束日期"); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择合同结束日期"); } int[] array = DateUtils.getDiff(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate()); wxRentContract.setLease(array[0]); if (null == wxRentContract.getSignDate()) { - return new ResultData(Result.ERROR,"请选择合同签约日期"); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择合同签约日期"); } - wxRentContract.setStartDate(wxRentContract.getRentalStartDate()); - wxRentContract.setEndDate(wxRentContract.getRentalEndDate()); String rentInfo = wxRentContract.getRentInfo(); if (StringUtils.isBlank(rentInfo)) { - return new ResultData(Result.ERROR,"请选择铺位"); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择铺位"); } JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); int size = rentInfoArray.size(); if (size == 0) { - return new ResultData(ErrorCode.SHOP_NOT_SELECTED); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择店铺"); } List shopList = Lists.newArrayList(); //查询rent_info 包括 shopId - String shopIdStr = ""; + //String shopIdStr = ""; BigDecimal rentAreaDecimal = new BigDecimal(0); for (int i = 0; i < size; i++) { JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); Long shopId = rentInfoObject.getLong("id"); - //wxRentContract.setShopId(shopId); - String shopNumber = rentInfoObject.getString("shopNumber"); + //String shopNumber = rentInfoObject.getString("shopNumber"); if (!shopList.contains(shopId)) { shopList.add(shopId); - shopIdStr = shopIdStr +","+ shopId; + //shopIdStr = shopIdStr +","+ shopId; } String rentArea = rentInfoObject.getString("operationArea"); if (StringUtils.isNotBlank(rentArea)) { rentAreaDecimal = rentAreaDecimal.add(new BigDecimal(rentArea)); } } + Collections.sort(shopList); wxRentContract.setRentArea(rentAreaDecimal.toPlainString()); - wxRentContract.setShopIdStr(shopIdStr); + wxRentContract.setShopIdStr(StringUtils.join(shopList,",")); try { rentContractValidShop(wxRentContract); } catch (Exception e) { - return new ResultData(Result.ERROR,e.getMessage()); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); } + } + + /** + * 生效中合同修改 + * @param wxRentContract + * @return + */ + @PostMapping("updateValidContract") + public ResultData updateValidContract(@RequestBody WxRentContract wxRentContract) { + MallUserInfo user = getUser(); + wxRentContract.updateTenantInfo(user); + //只能改生效的合同 + WxRentContract r = wxAgileContractService.selectById(wxRentContract.getId()); + if (!isValidContract(r)) { + return new ResultData(Result.ERROR,"该状态不允许修改"); + } - return wxAgileContractService.saveOrUpdate(wxRentContract, user); + try { + handleSaveData(wxRentContract); + }catch(Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + + //更新合同信息 + ResultData result = wxAgileContractService.saveOrUpdate(wxRentContract, user); + if (result.code != Result.SUCCESS) { + return new ResultData(result.code,result.message); + } + + //如果更改了合同时间,店铺,类型,每天计价规则,每月平均天数,计租面积,则需要重置 + if (isNeedRebuildBill(wxRentContract,r)) { + try { + wxAgileContractService.reSetContract(wxRentContract, user); + return new ResultData(); + }catch(Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + } + return new ResultData(); + } + + private boolean isValidContract(WxRentContract r) { + if (r.getStatus().intValue() == EnumRentContractStatus.READY_FOR_PAING.getCode().intValue() || + r.getStatus().intValue() == EnumRentContractStatus.PAING.getCode().intValue()) { + return true; + } + return false; + } + + private boolean isNeedRebuildBill(WxRentContract wxRentContract,WxRentContract dbContract) { + if (!wxRentContract.getRentalStartDate().equals(dbContract.getRentalStartDate()) + || !wxRentContract.getRentalEndDate().equals(dbContract.getRentalEndDate()) + || !wxRentContract.getShopIdStr().equals(dbContract.getShopIdStr()) + || !wxRentContract.getRentArea().equals(dbContract.getRentArea()) + || wxRentContract.getType().intValue() != dbContract.getType().intValue() + || wxRentContract.getDayPriceCalcute().intValue() != dbContract.getDayPriceCalcute().intValue() + || wxRentContract.getMonthAverageDays().intValue() != dbContract.getMonthAverageDays().intValue()) { + return true; + } + return false; } /** @@ -250,6 +335,16 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(Result.ERROR,"请至少增加一个"); } wxRentContract.updateTenantInfo(getTenantInfo()); + //如果是生效的合同变更,此时变更押金,则需要清空当前时间之后未处理的账单 + WxRentContract r = wxAgileContractService.selectById(wxRentContract.getId()); + if (isValidContract(r)) { + try { + wxAgileContractService.endContractDespoitBill(r,this.getUser()); + }catch(Exception e) { + return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); + } + } + try { wxAgileContractService.saveDeposit(wxRentContract,this.getUser()); }catch(Exception e) { @@ -344,6 +439,124 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(wxAgileContractService.findUnDepositList(unDeposit)); } + /** + * 删除非押金 + * @param unDeposit + * @return + */ + @PostMapping("deleteUnDeposit") + public ResultData deleteUnDeposit(@RequestBody WxRentContractAgileUnDeposit unDeposit) { + unDeposit.updateTenantInfo(getTenantInfo()); + if (null == unDeposit.getItems() || unDeposit.getItems().size() <= 0 ) { + return new ResultData(Result.ERROR,"无细项"); + } + //如果是生效的合同删除 + WxRentContract r = wxAgileContractService.selectById(unDeposit.getRentContractId()); + if (isValidContract(r)) { + wxAgileContractService.endContractUnDespositBill(unDeposit,this.getUser()); + } + try { + wxAgileContractService.deleteUnDeposit(unDeposit); + }catch(Exception e) { + return new ResultData(Result.ERROR,"保存账单失败:"+e.getMessage()); + } + return new ResultData(); + } + + /** + * 设置联营扣点 + */ + @PostMapping("setRenevue") + public ResultData setRenevue(@RequestBody WxRentContractAgileRenevue renevue) { + renevue.updateTenantInfo(getTenantInfo()); + if (null == renevue.getItems() || renevue.getItems().size() <= 0 ) { + return new ResultData(Result.ERROR,"无细项"); + } + if (null == renevue.getFees() || renevue.getFees().size() <= 0 ) { + return new ResultData(Result.ERROR,"请选择款项"); + } + //一个合同只能有一条记录 + WxRentContractAgileRenevue _ore = wxAgileContractService.findRenevueByContract(renevue.getRentContractId(),renevue); + if (null != _ore) { + renevue.setId(_ore.getId()); + } + + //如果是生效的合同变更 + WxRentContract r = wxAgileContractService.selectById(renevue.getRentContractId()); + if (isValidContract(r)) { + wxAgileContractService.endContractRenevueBill(renevue); + } + + try { + wxAgileContractService.saveRenuvue(renevue); + }catch(Exception e) { + return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); + } + return new ResultData(); + } + + /** + * 设置联营扣点跳点 + */ + @PostMapping("setRenevueJump") + public ResultData setRenevueJump(@RequestBody WxRentContract contract) { + contract.updateTenantInfo(getTenantInfo()); + if (null == contract.getRevenueJumps() || contract.getRevenueJumps().size() <= 0 ) { + return new ResultData(Result.ERROR,"无配置项"); + } + + //如果是生效的合同变更 + WxRentContract r = wxAgileContractService.selectById(contract.getId()); + if (isValidContract(r)) { + WxRentContractAgileRenevue renevue = wxAgileContractService.findRenevueByContract(contract.getId(), contract); + wxAgileContractService.endContractRenevueBill(renevue); + } + + try { + wxAgileContractService.saveRenuvueJumps(contract); + }catch(Exception e) { + return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); + } + return new ResultData(); + } + + /** + * 设置款项是否参与取高 + */ + @PostMapping("setFeesJoinRenevueUp") + public ResultData setFeesJoinRenevueUp(@RequestBody WxRentContractAgileUnDeposit unDeposit) { + unDeposit.updateTenantInfo(getTenantInfo()); + WxRentContractAgileUnDeposit und = wxAgileContractService.getUnDepositById(unDeposit.getId(),unDeposit); + + //计算周期等需要和扣点设置一致 + WxRentContractAgileRenevue _ore = wxAgileContractService.findRenevueByContract(unDeposit.getRentContractId(),unDeposit); + if (null == _ore) { + return new ResultData(Result.ERROR,"请先设置扣点信息"); + } + + if (und.getTimePeriod().intValue() != _ore.getTimePeriod().intValue() || + und.getTimeUnit().intValue() != _ore.getTimeUnit().intValue()) { + return new ResultData(Result.ERROR,"当前款项计费周期和扣点设置不一致。"); + } + + if (und.getFeesCreateRule().intValue() != _ore.getFeesCreateRule().intValue()) { + return new ResultData(Result.ERROR,"当前款项费用生成规则和扣点设置不一致。"); + } + + //如果是生效的合同变更 + WxRentContract r = wxAgileContractService.selectById(_ore.getRentContractId()); + if (isValidContract(r)) { + wxAgileContractService.endContractRenevueBill(_ore); + } + + try { + wxAgileContractService.setJoinRenevueUp(unDeposit); + }catch(Exception e) { + return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); + } + return new ResultData(); + } + @ApiOperation("分页列表接口") @GetMapping("billList") @@ -382,10 +595,6 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(Result.ERROR, "请选择租赁开始日期和截止日期"); } - if (null == wxRentContract.getStartDate()){ - return new ResultData(Result.ERROR, "请选择计租日期"); - } - if (null == wxRentContract.getSignDate()){ return new ResultData(Result.ERROR, "请选择签约日期"); } @@ -404,10 +613,6 @@ public class WxAgileContractController extends WxContractBaseController { rentContract.setRentalStartDate(wxRentContract.getRentalStartDate()); rentContract.setRentalEndDate(wxRentContract.getRentalEndDate()); rentContract.setSignDate(wxRentContract.getSignDate()); - rentContract.setStartDate(wxRentContract.getStartDate()); - rentContract.setEndDate(wxRentContract.getStartDate()); - rentContract.setFixStartDate(wxRentContract.getFixStartDate()); - rentContract.setFixEndDate(wxRentContract.getFixEndDate()); try { rentContractValidShop(rentContract); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java index a1015972d..45c32719f 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java @@ -89,18 +89,6 @@ public class WxContractBaseController extends BaseController{ } - protected boolean rentPropertyHasWorkFlow(WxRentPropertyContractVo rpvo) { - WxFlowModel wxFlowModel = new WxFlowModel(); - wxFlowModel.setFlowType(EnumFlowKey.NNEW_RENT_CONTRACT.getCode()); - wxFlowModel.updateTenantInfo(rpvo); - List flows = wxFlowService.getModelBybusiness(wxFlowModel); - if (null != flows && flows.size() > 0) { - return true; - } - return false; - - } - protected boolean rentContractHasWorkFlow(WxRentContract wxRentContract) { WxFlowModel wxFlowModel = new WxFlowModel(); wxFlowModel.setFlowType(EnumFlowKey.NEW_RENT_CONTRACT.getCode()); @@ -112,6 +100,17 @@ public class WxContractBaseController extends BaseController{ return false; } + protected boolean rentContractHasEditValidWorkFlow(WxRentContract wxRentContract) { + WxFlowModel wxFlowModel = new WxFlowModel(); + wxFlowModel.setFlowType(EnumFlowKey.NEW_EDIT_VALID_CONTRACT.getCode()); + wxFlowModel.updateTenantInfo(wxRentContract); + List flows = wxFlowService.getModelBybusiness(wxFlowModel); + if (null != flows && flows.size() > 0) { + return true; + } + return false; + } + public static boolean dateHasIntersection(Date startDate1, Date endDate1, Date startDate2, Date endDate2) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (startDate1.compareTo(endDate2) <= 0 && startDate2.compareTo(endDate1) <= 0) { 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 37f24db2b..8674bf896 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -10,12 +10,14 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.base.BaseEntity.SortField; +import com.iformall.domain.vo.BillTimeVo; import com.iformall.domain.vo.WxRentContractYearsVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.WxRentContractMapper; import com.iformall.service.*; import com.iformall.service.helper.WxBillAllHelper; +import com.iformall.service.helper.WxRentContractAgileHelper; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; import io.swagger.annotations.ApiImplicitParam; @@ -75,16 +77,6 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(map); } - /** - * 获取免租期 - */ - @GetMapping("getFreePeriod") - public ResultData getFreePeriod(@ModelAttribute WxRentContract wxRentContract) { - //查询 - WxRentContract contract = wxRentContractService.selectById(wxRentContract.getId()); - return new ResultData(wxRentContractService.getFreePeriods(contract)); - } - /** * 作废 * @param wxRentContract @@ -258,6 +250,12 @@ public class WxRentContractController extends WxContractBaseController { @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) public ResultData getRevenueContractList(@ModelAttribute WxRentContract wxRentContract, Integer pageNum, Integer pageSize) { if (null == wxRentContract) wxRentContract = new WxRentContract(); + WxUserDataRule dataRule = this.getCurrentDataFloors(); + if (null != dataRule) { + wxRentContract.setFloorForRule(dataRule.getFloorIds()); + wxRentContract.setBusinessForRule(dataRule.getBussinessIds()); + wxRentContract.setShopTypeForRule(dataRule.getShopTypes()); + } wxRentContract.updateTenantInfo(getTenantInfo()); List typeList = new ArrayList(); typeList.add(EnumRentContractType.RENT_BY_JOINT.getCode()); @@ -269,8 +267,7 @@ public class WxRentContractController extends WxContractBaseController { //statusList.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); wxRentContract.setStatuss(statusList); wxRentContract.setSortColumns(SortField.Createtime_DESC); - //return new ResultData(wxRentContractService.getRentContractList(wxRentContract, pageNum, pageSize)); - return new ResultData(); + return new ResultData(wxRentContractService.getRenevueContractList(wxRentContract, pageNum, pageSize)); } //查询联营扣点,联营取高的合同账单周期 @@ -292,40 +289,54 @@ public class WxRentContractController extends WxContractBaseController { } } - //查询所有时间区间,只查询租金的 - WxAllBill bq = wxBillAllHelper.generateRentContractQueryBill(sales,sales.getRentContractId(),null,null); - bq.setNoExtraCreateFrom(EnumYesOrNo.YES.getCode()); - List billList = wxAllBillService.getContractSamePeriodBillSumList(bq); - if (null == billList || billList.size() <= 0 ) { + //查询所有时间区间 + WxRentContractAgileRenevue renevue = wxAgileContractService.findRenevueByContract(sales.getRentContractId(), sales); + if (null == renevue) { + return new ResultData(); + } + List renevueItems = wxAgileContractService.findRenevueItemListByContract(sales.getRentContractId(), sales); + if (null == renevueItems || renevueItems.size() <= 0 ) { return new ResultData(); } List validBillList = new ArrayList(); - for (int i = 0 ; i < billList.size() ; i ++) { - WxAllBill bill = billList.get(i); - WxAllBill nbill = new WxAllBill(); - nbill.setStarttime(bill.getStarttime()); - nbill.setEndtime(bill.getEndtime());; - WxRentContractRevenueSales s = billSalesMap.get(bill.getStarttime()+"_"+bill.getEndtime()); - if (null != s) { - bill.setSales(s.getSaleMoney()); - bill.setSalesTime(s.getUpdateTime()); - //已锁定的不能再设置 - if (s.getIsConfirm() == EnumYesOrNo.YES.getCode()) { - // - //TODO 年度已经汇算的不能再设置 - //}else if() { - - }else { - validBillList.add(nbill); - } - }else { - validBillList.add(nbill); - } + EnumFeesShopTimeType creatRule = EnumFeesShopTimeType.getEnum(renevue.getFeesCreateRule()); + EnumRentContractAgilTimeUnit timeUnit = EnumRentContractAgilTimeUnit.getEnum(renevue.getTimeUnit()); + for (int i = 0 ; i < renevueItems.size(); i++) { + WxRentContractAgileRenevueItem item = renevueItems.get(i); + List timeVoList = WxRentContractAgileHelper.initBillTimeList(null, item.getBeginTime(), item.getEndTime(), creatRule, timeUnit, renevue.getTimePeriod(), renevue.getCalcuteTime()); + if (null != timeVoList && timeVoList.size() > 0 ) { + for (int j = 0 ; j < timeVoList.size(); j++) { + BillTimeVo tv = timeVoList.get(j); + WxAllBill nbill = new WxAllBill(); + nbill.setStarttime(tv.getStartDate()); + nbill.setEndtime(tv.getEndDate()); + WxRentContractRevenueSales s = billSalesMap.get(tv.getStartDate()+"_"+tv.getEndDate()); + if (null != s) { + nbill.setSales(s.getSaleMoney()); + nbill.setSalesTime(s.getUpdateTime()); + //已锁定的不能再设置 + if (s.getIsConfirm() == EnumYesOrNo.YES.getCode()) { + // + //TODO 年度已经汇算的不能再设置 + //}else if() { + + }else { + validBillList.add(nbill); + } + }else { + validBillList.add(nbill); + } + } + } } return new ResultData(validBillList); } - //查询联营扣点,联营取高的合同账单周期 + /** + * 查询联营扣点,联营取高的合同某一个周期的根据销售额录入生成的账单列表 + * @param sales + * @return + */ @GetMapping("revenueBillTimesSaleBills") public ResultData revenueBillTimesSaleBills(@ModelAttribute WxRentContractRevenueSales sales) { if (null == sales) sales = new WxRentContractRevenueSales(); @@ -361,32 +372,39 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(retMap); } -// //查询商户计租合同列表 -// @GetMapping("revenuePropertyContract") -// public ResultData revenuePropertyContract(@ModelAttribute WxRentContract rentContract) { -// if (null == rentContract) rentContract = new WxRentContract(); -// rentContract.updateTenantInfo(getTenantInfo()); -// WxRentContract contract = wxRentContractService.selectById(rentContract.getId()); -// //纯联营扣点方式,不能加物业费一起算 -// if (contract.getType().intValue() == EnumRentContractType.RENT_BY_JOINT.getCode()) { -// return new ResultData(); -// } -// WxPropertyContract bq = new WxPropertyContract(); -// bq.updateTenantInfo(rentContract); -// bq.setRentContractId(rentContract.getId()); -// bq.setOperationType(EnumContractOperationType.WHOLE.getCode()); -// //包括提前终止的,租金+物业合同是一对一的 -// List statusList = new ArrayList(); -// statusList.add(EnumRentContractStatus.PAING.getCode()); -// statusList.add(EnumRentContractStatus.TERMINATE.getCode()); -// //bq.setStatus(EnumRentContractStatus.PAING.getCode()); -// bq.setStatuss(statusList); -// List propertyList = wxPropertyContractService.findList(bq); -// if (null != propertyList && propertyList.size() > 0 ) { -// return new ResultData(propertyList.get(0)); -// } -// return new ResultData(); -// } + /** + * 查询取高合同里面参与取高款项的当期账单列表 + * @param sales + * @return + */ + @GetMapping("revenueUpFeesBills") + public ResultData revenueUpFeesBills(@ModelAttribute WxRentContractRevenueSales sales) { + sales.updateTenantInfo(getTenantInfo()); + WxRentContractAgileUnDeposit udq = new WxRentContractAgileUnDeposit(); + udq.updateTenantInfo(sales); + udq.setRentContractId(sales.getRentContractId()); + udq.setJoinRenevueUp(EnumYesOrNo.YES.getCode()); + List udlist = wxAgileContractService.findUnDepositList(udq); + if (null != udlist && udlist.size() > 0 ) { + List billlist = new ArrayList(); + for (int i = 0 ; i < udlist.size() ; i ++) { + WxRentContractAgileUnDeposit ad = udlist.get(i); + WxAllBill bq = new WxAllBill(); + bq.updateTenantInfo(sales); + bq.setRentContractId(sales.getRentContractId()); + bq.setEnergyFeesId(ad.getFeesId()); + bq.setIsPreview(EnumYesOrNo.NO.getCode()); + bq.setStarttimeEqual(sales.getStarttime()); + bq.setEndtimeEqual(sales.getEndtime()); + PageInfo billPage = wxAllBillService.listAsPage(bq,1,100); + if (null != billPage && null != billPage.getList() && billPage.getList().size() > 0 ) { + billlist.addAll(billPage.getList()); + } + } + return new ResultData(billlist); + } + return new ResultData(); + } /** * 扣点设置销售额重新计算 @@ -405,13 +423,13 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(wxRentContractService.setRevenueSales(this.getUser(),rentContract,wxRentContract.getSalesMoney(),wxRentContract.getSalesStartTime(),wxRentContract.getSalesEndTime())); } -// //查询合同年限 -// @GetMapping("getContractYears") -// public ResultData getContractYears(@ModelAttribute WxRentContract wxRentContract) { -// if (null == wxRentContract) wxRentContract = new WxRentContract(); -// WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); -// return new ResultData(wxRentContractService.getRentContractYears(rentContract)); -// } + //查询合同年限 + @GetMapping("getContractYears") + public ResultData getContractYears(@ModelAttribute WxRentContract wxRentContract) { + if (null == wxRentContract) wxRentContract = new WxRentContract(); + WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); + return new ResultData(wxAgileContractService.getRentContractYears(rentContract)); + } //查询合同年限已输入销售额情况 @PostMapping("getContractYearsSales") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java index d8f95ede7..058408051 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java @@ -217,14 +217,6 @@ public class WxAllBill extends TenantEntity { @Excel(name = "状态", replace = {"欠缴_1", "待缴_2", "已结清_3", "未到期_4", "已退还_5", "失效_6", "坏账_7", "退租待结算_8","预收待抵扣_9"}, width = 20, orderNum = "10") @io.swagger.annotations.ApiModelProperty(value = "账单状态EnumBillStatus", name = "status") public Integer status; -// @TableField(exist = false) -// private String statusName; -// public String getStatusName() { -// if (null != status) { -// return EnumBillStatus.getEnum(status).getMessage(); -// } -// return null; -// } @TableField(exist = false) public List statusList; @@ -273,9 +265,6 @@ public class WxAllBill extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="自定义合同费用类型EnumRentContractAgileFeesType",name="rentContractAgileFeesType") public Integer rentContractAgileFeesType; - @io.swagger.annotations.ApiModelProperty(value="物业合同ID",name="propertyContractId") - public Long propertyContractId; - @io.swagger.annotations.ApiModelProperty(value="主物账单ID(针对合同里面的自定义科目账单)",name="parentBillId") public Long parentBillId; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java index f754f4ae6..f699b8704 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java @@ -214,6 +214,6 @@ public class WxCouponOrder extends TenantEntity { @TableField(exist = false) private Long endCreateDateTimes; @TableField(exist = false) - private Date createDateLike; + private String createDateLike; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index e46c23fb5..ee84996b7 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -60,37 +60,18 @@ public class WxRentContract extends TenantEntity { private Date rentalStartDate; @io.swagger.annotations.ApiModelProperty(value = "祖赁截止时间", name = "rentalEndDate") private Date rentalEndDate; - @io.swagger.annotations.ApiModelProperty(value = "计租开始日期", name = "startDate") - private Date startDate; - @io.swagger.annotations.ApiModelProperty(value = "计租截止日期", name = "endDate") - private Date endDate; @io.swagger.annotations.ApiModelProperty(value = "施工图纸", name = "designFile") private String designFile; - @io.swagger.annotations.ApiModelProperty(value = "装修期开始时间", name = "fixStartDate") - private Date fixStartDate; - @io.swagger.annotations.ApiModelProperty(value = "装修期结束时间", name = "fixEndDate") - private Date fixEndDate; @io.swagger.annotations.ApiModelProperty(value = "租期总月数(月)", name = "lease") private Integer lease; - @io.swagger.annotations.ApiModelProperty(value = "来源ID,针对续签,从哪个合同续签", name = "fromId") private Long fromId; - - //地址 + //联系地址 private String linkAddress; - @io.swagger.annotations.ApiModelProperty(value = "联系人", name = "linkPerson") private String linkPerson; - @io.swagger.annotations.ApiModelProperty(value = "联系电话", name = "linkPhone") private String linkPhone; - - @io.swagger.annotations.ApiModelProperty(value = "付款账号", name = "payAccount") - private String payAccount; - - @io.swagger.annotations.ApiModelProperty(value = "开户行", name = "bankName") - private String bankName; - @io.swagger.annotations.ApiModelProperty(value = "金额小数点位数", name = "decimalSize") private Integer decimalSize = Constant.default_short_decimal_size ; @TableField(exist = false) @@ -98,6 +79,8 @@ public class WxRentContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "合同文件路径", name = "filepath") private String filepath; + @io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames") + private String fileNames; @io.swagger.annotations.ApiModelProperty(value = "EnumRentContractStatus", name = "status") private Integer status; @TableField(exist = false) @@ -113,7 +96,6 @@ public class WxRentContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "押金金额详细", name = "cashtypeContentLsit") private String cashtypeContentLsit; - @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = "isDel") private Integer isDel; @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updatetime") @@ -130,64 +112,22 @@ public class WxRentContract extends TenantEntity { private String createByName; @io.swagger.annotations.ApiModelProperty(value = "计租面积", name = "rentArea") private String rentArea; - @io.swagger.annotations.ApiModelProperty(value = "店铺编号串", name = "shopIdStr") private String shopIdStr; - - @io.swagger.annotations.ApiModelProperty(value = "类型EnumRentContractType", name = "type") + @io.swagger.annotations.ApiModelProperty(value = "类型EnumAgileContractType", name = "type") private Integer type; - @TableField(exist = false) - private String typeName; - @TableField(exist = false) - private List typeList; - -// @io.swagger.annotations.ApiModelProperty(value = "取高时保底方式EnumRentRenevueMinimunMethod", name = "revenueMinimumMethod") -// private Integer revenueMinimumMethod; - - @io.swagger.annotations.ApiModelProperty(value = "审核状态, 0未审核 1审核中 2审核通过 3驳回", name = "applyStatus") + @io.swagger.annotations.ApiModelProperty(value = "审核状态, 0未审核 1审核中 2审核通过 3驳回EnumRentContractAppStatus", name = "applyStatus") private Integer applyStatus; - @io.swagger.annotations.ApiModelProperty(value = "终止时间", name = "endContractTime") private Date endContractTime; - - @TableField(exist = false) - @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") - private Map flowParams; - - @TableField(exist = false) - @io.swagger.annotations.ApiModelProperty(value = "租赁合同预账单列表", name = "previewBillRentList") - private List previewBillRentList; - @io.swagger.annotations.ApiModelProperty(value = "审批说明", name = "remark") private String remark; - @io.swagger.annotations.ApiModelProperty(value = "租金信息", name = "rentInfo") private String rentInfo; - - @io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames") - private String fileNames; - @io.swagger.annotations.ApiModelProperty(value = "每天价格计算规则EnumRentDayPriceCalcute", name = "dayPriceCalcute") private Integer dayPriceCalcute; @io.swagger.annotations.ApiModelProperty(value = "每月平均天数", name = "monthAverageDays") private Integer monthAverageDays; - - @io.swagger.annotations.ApiModelProperty(value = "是否有工作流 1:有 0:无", name = "flowHas") - @TableField(exist = false) - private Integer flowHas; - - //联营扣点跳点设置 - @TableField(exist = false) - private List revenueJumps; - @io.swagger.annotations.ApiModelProperty(value = "联营跳点设置说明", name = "revenueJumpsRemark") - private String revenueJumpsRemark; - - @io.swagger.annotations.ApiModelProperty(value = "免租期说明", name = "freePeriodRemark") - private String freePeriodRemark; - -// @io.swagger.annotations.ApiModelProperty(value = "合同类型EnumRentAgileType", name = "agileType") -// private Integer agileType = EnumRentAgileType.AGILE.getCode(); - public List shopIdsByRentInfo() { List shopList = Lists.newArrayList(); @@ -261,31 +201,6 @@ public class WxRentContract extends TenantEntity { return null; } - -// public Map getDepositEnergyFees(Map feesMap) { -// String dsdstr = this.getCashtypeContentLsit(); -// if (!StringUtils.isBlank(dsdstr)) { -// Map retMap = new HashMap(); -// JSONArray rentInfoArray = JSONArray.parseArray(dsdstr); -// int size = rentInfoArray.size(); -// for (int i = 0; i < size; i++) { -// JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); -// String depositType = rentInfoObject.getString("value"); -// String deposit = rentInfoObject.getString("deposit"); -// Long dt = Long.parseLong(depositType); -// WxEnergyFees fees = feesMap.get(dt); -// WxEnergyFees nfees = new WxEnergyFees(); -// nfees.setId(fees.getId()); -// nfees.setName(fees.getName()); -// nfees.setCalcuteUnit(fees.getCalcuteUnit()); -// nfees.setPrice(deposit); -// retMap.put(dt, nfees); -// } -// return retMap; -// } -// return null; -// } - @TableField(exist = false) private List freePeriods; public void setFreeVo(List freePeriods) { @@ -309,6 +224,27 @@ public class WxRentContract extends TenantEntity { this.setFreePeriods(voList); } } + + //是否有工作流 1:有 0:无" + @TableField(exist = false) + private Integer flowHas; + //是否有修改履约中工作流 1:有 0:无" + @TableField(exist = false) + private Integer flowHasValidEdit; + //联营扣点跳点设置 + @TableField(exist = false) + private List revenueJumps; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") + private Map flowParams; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value = "租赁合同预账单列表", name = "previewBillRentList") + private List previewBillRentList; + + @TableField(exist = false) + private String typeName; + @TableField(exist = false) + private List typeList; @TableField(exist = false) private String building; @TableField(exist = false) @@ -372,5 +308,7 @@ public class WxRentContract extends TenantEntity { private List calcuteShopIds; @TableField(exist = false) private Integer calcuteIsProperty; + @TableField(exist = false) + private String shopNumber; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevue.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevue.java new file mode 100644 index 000000000..83a0b73a3 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevue.java @@ -0,0 +1,75 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumFeesShopTimeType; +import com.iformall.enums.EnumRentContractAgilPriceUnit; +import com.iformall.enums.EnumRentContractAgilSettingMethod; +import com.iformall.enums.EnumRentContractAgilTimeUnit; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import java.util.Date; +import java.util.List; + +/** + */ +@TableName(value = "wx_rent_contract_agile_renevue") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxRentContractAgileRenevue extends TenantEntity { + + private static final long serialVersionUID = 7009117540201976664L; + + @io.swagger.annotations.ApiModelProperty(value="id",name="id") + private Long id; + + @io.swagger.annotations.ApiModelProperty(value="合同编号",name="rentContractId") + private Long rentContractId; + + @io.swagger.annotations.ApiModelProperty(value="计费周期",name="timePeriod") + private Integer timePeriod; + + @io.swagger.annotations.ApiModelProperty(value="计费周期单位EnumRentContractAgilTimeUnit",name="timeUnit") + private Integer timeUnit; + @TableField(exist = false) + private String timeUnitName; + public String getTimeUnitName() { + if (null != timeUnit) { + return EnumRentContractAgilTimeUnit.getEnum(timeUnit).getMessage(); + } + return null; + } + + @io.swagger.annotations.ApiModelProperty(value="收费周期",name="calcuteTime") + private Integer calcuteTime; + + @io.swagger.annotations.ApiModelProperty(value="费用生成规则EnumFeesShopTimeType",name="feesCreateRule") + private Integer feesCreateRule; + @TableField(exist = false) + private String feesCreateRuleName; + public String getFeesCreateRuleName() { + if (null != feesCreateRule) { + return EnumFeesShopTimeType.getEnum(feesCreateRule).getMessage(); + } + return null; + } + + @io.swagger.annotations.ApiModelProperty(value="createTime",name="createTime") + private Date createtime; + + @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") + private Date updatetime; + + @io.swagger.annotations.ApiModelProperty(value="最低扣点销售额",name="limitRevenue") + private String limitRevenue; + + @TableField(exist = false) + private List items; + + @TableField(exist = false) + private List fees; +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevueFees.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevueFees.java new file mode 100644 index 000000000..cbd015f1d --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevueFees.java @@ -0,0 +1,48 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumFeesShopTimeType; +import com.iformall.enums.EnumRentContractAgilPriceUnit; +import com.iformall.enums.EnumRentContractAgilSettingMethod; +import com.iformall.enums.EnumRentContractAgilTimeUnit; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import java.util.Date; +import java.util.List; + +/** + */ +@TableName(value = "wx_rent_contract_agile_renevue_fees") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxRentContractAgileRenevueFees extends TenantEntity { + + private static final long serialVersionUID = 7009117540201976664L; + + @io.swagger.annotations.ApiModelProperty(value="id",name="id") + private Long id; + + @io.swagger.annotations.ApiModelProperty(value="合同编号",name="rentContractId") + private Long rentContractId; + + @io.swagger.annotations.ApiModelProperty(value="WxRentContractAgileRenevue编号",name="agileRenevueId") + private Long agileRenevueId; + + @io.swagger.annotations.ApiModelProperty(value="createTime",name="createTime") + private Date createtime; + + @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") + private Date updatetime; + + @io.swagger.annotations.ApiModelProperty(value="款项编号",name="feesId") + private Long feesId; + + @io.swagger.annotations.ApiModelProperty(value="占比比率%,默认100",name="rate") + private String rate; + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevueItem.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevueItem.java new file mode 100644 index 000000000..9f170f36a --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileRenevueItem.java @@ -0,0 +1,62 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumFeesShopTimeType; +import com.iformall.enums.EnumRentContractAgilPriceUnit; +import com.iformall.enums.EnumRentContractAgilSettingMethod; +import com.iformall.enums.EnumRentContractAgilTimeUnit; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import java.util.Date; +import java.util.List; + +/** + */ +@TableName(value = "wx_rent_contract_agile_renevue_item") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxRentContractAgileRenevueItem extends TenantEntity { + + private static final long serialVersionUID = 7009117540201976664L; + + @io.swagger.annotations.ApiModelProperty(value="id",name="id") + private Long id; + + @io.swagger.annotations.ApiModelProperty(value="合同编号",name="rentContractId") + private Long rentContractId; + + @io.swagger.annotations.ApiModelProperty(value="费用编号",name="renevueId") + private Long renevueId; + + @io.swagger.annotations.ApiModelProperty(value="beginTime",name="beginTime") + private Date beginTime; + + @io.swagger.annotations.ApiModelProperty(value="endTime",name="endTime") + private Date endTime; + + @io.swagger.annotations.ApiModelProperty(value="抽成比率%",name="rate") + private String rate; + + @io.swagger.annotations.ApiModelProperty(value="createTime",name="createTime") + private Date createtime; + + @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") + private Date updatetime; + + @io.swagger.annotations.ApiModelProperty(value="是否免租期",name="isFree") + private Integer isFree; + + @io.swagger.annotations.ApiModelProperty(value="页面用的字段",name="isFree") + private Integer isFather; + + @TableField(exist = false) + private Date validBeginTime; + @TableField(exist = false) + private Date validEndTime; + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java index 08688bbb0..49dfe2499 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractAgileUnDeposit.java @@ -46,20 +46,6 @@ public class WxRentContractAgileUnDeposit extends TenantEntity { @TableField(exist = false) private String feesName; - @io.swagger.annotations.ApiModelProperty(value="单价",name="price") - private String price; - - @io.swagger.annotations.ApiModelProperty(value="单价单位EnumRentContractAgilPriceUnit",name="priceUnit") - private Integer priceUnit; - @TableField(exist = false) - private String priceUnitName; - public String getPriceUnitName() { - if (null != priceUnit) { - return EnumRentContractAgilPriceUnit.getEnum(priceUnit).getMessage(); - } - return null; - } - @io.swagger.annotations.ApiModelProperty(value="计费周期",name="timePeriod") private Integer timePeriod; @@ -94,6 +80,9 @@ public class WxRentContractAgileUnDeposit extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") private Date updatetime; + @io.swagger.annotations.ApiModelProperty(value="是否参与联营扣点取高EnumYesOrNo",name="joinRenevueUp") + private Integer joinRenevueUp; + @TableField(exist = false) private List items; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java index 1c0594e8f..7c2c11b60 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java @@ -27,12 +27,9 @@ public class WxRentContractRevenueSales extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") private Date updateTime; - @io.swagger.annotations.ApiModelProperty(value = "租金合同编号", name = "rentContractId") + @io.swagger.annotations.ApiModelProperty(value = "合同编号", name = "rentContractId") private Long rentContractId; - @io.swagger.annotations.ApiModelProperty(value = "物业合同编号", name = "propertyContractId") - private Long propertyContractId; - @io.swagger.annotations.ApiModelProperty(value = "账单开始日期", name = "starttime") private Date starttime; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumAgileContractType.java b/mallinkService/src/main/java/com/iformall/enums/EnumAgileContractType.java new file mode 100644 index 000000000..65d26c270 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumAgileContractType.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + + +/** + */ + +public enum EnumAgileContractType { + + AREA(1, "面积"), + RENEVUE(2, "联营扣点"), + RENEVUE_UP(3, "面积与联营扣点取高") + ; + + public static EnumAgileContractType getEnum(Integer code) { + for (EnumAgileContractType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumAgileContractType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java b/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java index 3404c1c76..69abe38a8 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java @@ -9,10 +9,9 @@ public enum EnumFlowKey { BILL(2, "end_bill_flow"),//账单审批 END_CONTRACT(3, "end_contract_flow"),//终止合同审批 - NEW_RENT_CONTRACT(4, "租金合同签约"), - //NEW_SHOP_CONTRACT(5, "多经点位租金合同签约"), - NEW_RENT_END_CONTRACT(6, "租金合同终止"), - //NEW_SHOP_END_CONTRACT(7, "多经点位租金合同终止"), + NEW_RENT_CONTRACT(4, "合同签约"), + NEW_EDIT_VALID_CONTRACT(5, "履约中合同修改"), + NEW_RENT_END_CONTRACT(6, "合同终止"), NEW_BILL_CHANGE(8, "账单应收金额变更"), @@ -26,16 +25,6 @@ public enum EnumFlowKey { NEW_COUPON_DISTRIBUTION_UPLINE(25,"配送商品审批"), NEW_COUPON_CREDIT_UPLINE(26,"积分券审批"), - NEW_PRO_CONTRACT(13, "物业合同签约"), - NEW_PRO_END(14, "物业合同终止"), - //NEW_PRO_POINT_CONTRACT(15, "多经点位物业合同签约"), - //NEW_PRO_POINT_CONTRACT_END(16, "多经点位物业合同终止"), - - NNEW_RENT_CONTRACT(17, "租金+物业合同签约"), - NEW_RENT_END(18, "租金+物业合同合同终止"), - //NEW_RENT_POINT_CONTRACT(19, "多经点位商铺租金+物业合同签约"), - //NEW_RENT_POINT_CONTRACT_END(20, "多经点位商铺租金+物业合同终止"), - SETTLE(21,"结算单审批"), BILL_FINISH(30,"商户账单完结审批"), diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java index 2277505fa..cd594a975 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java @@ -55,5 +55,7 @@ public interface WxAllBillMapper extends CommonMapper { void updateContractCusName(WxAllBill wxBillRent); void transferCusName(WxAllBill wxBillRent); + + BigDecimal getReceivePaySum(WxAllBill wxBillRent); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueFeesMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueFeesMapper.java new file mode 100644 index 000000000..255a204ac --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueFeesMapper.java @@ -0,0 +1,22 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxRentContractAgileRenevue; +import com.iformall.domain.po.WxRentContractAgileRenevueFees; + +import org.apache.ibatis.annotations.Param; +import java.util.List; + +/** + */ +public interface WxRentContractAgileRenevueFeesMapper extends CommonMapper { + + List findList(WxRentContractAgileRenevueFees wxBillRent); + + WxRentContractAgileRenevueFees selectById(@Param("id")Long id,@Param("tenantId")String tenantId); + + List findIdList(WxRentContractAgileRenevueFees wxBillRent); + + void deleteByRenevue(WxRentContractAgileRenevueFees wxBillRent); + +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueItemMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueItemMapper.java new file mode 100644 index 000000000..407793b50 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueItemMapper.java @@ -0,0 +1,21 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxRentContractAgileRenevueItem; + +import org.apache.ibatis.annotations.Param; +import java.util.List; + +/** + */ +public interface WxRentContractAgileRenevueItemMapper extends CommonMapper { + + List findList(WxRentContractAgileRenevueItem wxBillRent); + + WxRentContractAgileRenevueItem selectById(@Param("id")Long id,@Param("tenantId")String tenantId); + + List findIdList(WxRentContractAgileRenevueItem wxBillRent); + + void deleteByRenevue(WxRentContractAgileRenevueItem wxBillRent); + +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueMapper.java new file mode 100644 index 000000000..2d7becdc8 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileRenevueMapper.java @@ -0,0 +1,19 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxRentContractAgileRenevue; + +import org.apache.ibatis.annotations.Param; +import java.util.List; + +/** + */ +public interface WxRentContractAgileRenevueMapper extends CommonMapper { + + List findList(WxRentContractAgileRenevue wxBillRent); + + WxRentContractAgileRenevue selectById(@Param("id")Long id,@Param("tenantId")String tenantId); + + List findIdList(WxRentContractAgileRenevue wxBillRent); + +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileUnDepositMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileUnDepositMapper.java index dec85939e..9dfb859ee 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileUnDepositMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractAgileUnDepositMapper.java @@ -15,5 +15,11 @@ public interface WxRentContractAgileUnDepositMapper extends CommonMapper findIdList(WxRentContractAgileUnDeposit wxBillRent); + + List findFeesIdList(WxRentContractAgileUnDeposit wxBillRent); + + void updateJoinRenevueUp(WxRentContractAgileUnDeposit wxBillRent); + + void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java index bf6382643..7ae04b87c 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java @@ -6,8 +6,13 @@ import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxContractCustomers; import com.iformall.domain.po.WxRentContract; import com.iformall.domain.po.WxRentContractAgileDeposit; +import com.iformall.domain.po.WxRentContractAgileRenevue; +import com.iformall.domain.po.WxRentContractAgileRenevueFees; +import com.iformall.domain.po.WxRentContractAgileRenevueItem; import com.iformall.domain.po.WxRentContractAgileUnDeposit; +import com.iformall.domain.po.WxRentContractRevenueSales; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.WxRentContractYearsVo; import java.math.BigDecimal; import java.util.Date; @@ -33,10 +38,30 @@ public interface WxAgileContractService { WxRentContractAgileUnDeposit findUnDepositDetail(WxRentContractAgileUnDeposit unDeposit); + WxRentContractAgileUnDeposit getUnDepositById(Long id,TenantEntity tenantEntity); + List findUnDepositList(WxRentContractAgileUnDeposit unDeposit); + void deleteUnDeposit(WxRentContractAgileUnDeposit unDeposit); + + List findUnDepositFeesIdList(WxRentContractAgileUnDeposit unDeposit); + void createUnDepositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user); + WxRentContractAgileRenevue findRenevueByContract(Long rentContractId,TenantEntity tenantEntity); + + void saveRenuvue(WxRentContractAgileRenevue renevue); + + void saveRenuvueJumps(WxRentContract contract); + + void setJoinRenevueUp(WxRentContractAgileUnDeposit unDeposit); + + List findRenevueItemListByContract(Long rentContractId,TenantEntity tenantEntity); + + List findRenevueFeesListByContract(Long rentContractId,TenantEntity tenantEntity); + + WxRentContractAgileRenevueItem findOneRenevueItemByTime(Long rentContractId,TenantEntity tenantEntity,Date begin,Date end); + List findBuildingFloorContractIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,List shopIds,Integer shopDel); List findShopContractIds(TenantEntity tenantEntity,List shopIds); @@ -50,4 +75,11 @@ public interface WxAgileContractService { void renewalAgile(WxRentContract wxRentContract,MallUserInfo user); void transfer(WxRentContract wxRentContract,MallUserInfo user); + + List getRentContractYears(WxRentContract rentContract); + + void reSetContract(WxRentContract wxRentContract,MallUserInfo user); + void endContractDespoitBill(WxRentContract wxRentContract,MallUserInfo user); + void endContractUnDespositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user); + void endContractRenevueBill(WxRentContractAgileRenevue renevue); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index c7067908d..a0d9282f3 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -51,21 +51,6 @@ public interface WxRentContractService { //Map getById(Long id,Integer noBillList); WxRentContract selectById(Long id); - /** - * 保存或更新实体 - * @param record - * @param userId - * @param userName - * @return - */ - //ResultData save(WxRentContract record,MallUserInfo user,String userName,Date oldRentStartDate); - - //ResultData update(WxRentContract record, MallUserInfo user,String userName,int from,Date oldRentStartDate,boolean writeComplate,boolean setRevenJumps); - - //ResultData updateOneStep(WxRentContract record, MallUserInfo user,String userName,int from,Date oldRentStartDate,boolean writeComplate); - - //ResultData updateRentStartTime(WxRentContract record, MallUserInfo user); - /** * 根据Id删除实体 * @@ -76,15 +61,9 @@ public interface WxRentContractService { void download(HttpServletRequest request, HttpServletResponse response); - //Object getRentContractStatusInfo(WxRentContract record); - ResultData updateRentContract(WxRentContract wxRentContract); - //PageInfo getRentContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); - - //void exportContract(HttpServletRequest request, HttpServletResponse response, Long rentId,Long propertyId); - - //ResultData updateFile(WxRentContract wxRentContract, MallUserInfo user,String userName,boolean writeComplate); + PageInfo getRenevueContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); ResultData updateRentContractStatus(Long id,boolean buildPropertyBill); @@ -92,46 +71,18 @@ public interface WxRentContractService { void updateApplyStatus(WxRentContract wxRentContract); - List getYearList(int years,int month,Date rentalStartDate,Date endContractTime ); - //List buildRent(MallUserInfo user,WxRentContract rentContract,Integer isPreview,boolean saveDb); - - //void buildDeposit( TenantEntity tenantEntity,MallUserInfo user,Long rentContractId); - - //void updateInvalidContract(Long rentContractId); - - //ResultData hasRentStatus(WxRentContract wxRentContract); - - //ResultData hasContractNumber(WxRentContract wxRentContract); - - //Integer getShopType(WxRentContract wxRentContract); - ResultData endContract(WxRentContract wxRentContract,MallUserInfo userInfo); - //void updatePropertyPreviewBill(WxRentContract record); - - //Map updateStatus(WxRentContract record); - WxRentContract getByBill(WxAllBill billRent); - //Map selectRentContractByShopIds(Collection shopIds, String shopIdsRegexp, TenantEntity tenantEntity); - - //int selectContractCountByShopId(WxRentContract wxRentContract); - - //ResultData getContractByContractNumber(WxRentContract wxRentContract); - ResultData apply(WxRentContract wxRentContract,MallUserInfo user); - void renewal(WxRentContract wxRentContract,MallUserInfo user); - /** * 合同正常到期 * @param */ void outDateContract(WxMall wxMall); - //查询还有多少天到期的合同 - //List findToOutDateContracts(TenantEntity tenantEntity); - /** * 已签约未计租 变为计租中 * @param wxMall @@ -146,14 +97,8 @@ public interface WxRentContractService { List findToEndContractList(WxRentContract record); - void calcuteByTradeDaily(WxRentContract wxRentContract); - void deletePrewBill(WxRentContract wxRentContract); - List getFreePeriods(WxRentContract wxRentContract); - - //void saveFreePeriods(WxRentContract wxRentContract); - List getContractSales(WxRentContract wxRentContract); WxRentContractRevenueSetSalesVo setRevenueSales(MallUserInfo user,WxRentContract rentcontract,String sales,Date startime, Date endtime); @@ -164,8 +109,4 @@ public interface WxRentContractService { List findJumpList(WxRentContractRevenueJump jump); - //List getRentContractYears(WxRentContract rentContract); - - BigDecimal calcuteContractUsedShopArea(WxRentContract wxRentContract,Long shopId); - } diff --git a/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractAgileHelper.java b/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractAgileHelper.java index c2439957b..bd092ccd1 100644 --- a/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractAgileHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractAgileHelper.java @@ -274,7 +274,7 @@ public class WxRentContractAgileHelper { * @param end * @return */ - private static String getMonthNeedPay(List freeDays,Integer decimalSize,BigDecimal price,Date start,Date end, + public static String getMonthNeedPay(List freeDays,Integer decimalSize,BigDecimal price,Date start,Date end, EnumRentContractAgilTimeUnit timeUnit,int time,EnumRentDayPriceCalcute dayPriceRule,Integer monthAvageDays){ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java index 392a8d9ca..e4e8d854d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java @@ -17,6 +17,9 @@ import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxRentContract; import com.iformall.domain.po.WxRentContractAgileDeposit; import com.iformall.domain.po.WxRentContractAgileDepositShop; +import com.iformall.domain.po.WxRentContractAgileRenevue; +import com.iformall.domain.po.WxRentContractAgileRenevueFees; +import com.iformall.domain.po.WxRentContractAgileRenevueItem; import com.iformall.domain.po.WxRentContractAgileUnDeposit; import com.iformall.domain.po.WxRentContractAgileUnDepositItem; import com.iformall.domain.po.WxRentContractRevenueJump; @@ -24,6 +27,7 @@ import com.iformall.domain.po.WxShop; import com.iformall.domain.po.WxShopUsers; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.BillTimeVo; +import com.iformall.domain.vo.WxRentContractYearsVo; import com.iformall.enums.EnumBillExtraCreateFrom; import com.iformall.enums.EnumContractCustomersStatus; import com.iformall.enums.EnumFeesShopTimeType; @@ -45,10 +49,14 @@ import com.iformall.mapper.WxContractShopMapper; import com.iformall.mapper.WxMerchantMapper; import com.iformall.mapper.WxRentContractAgileDepositMapper; import com.iformall.mapper.WxRentContractAgileDepositShopMapper; +import com.iformall.mapper.WxRentContractAgileRenevueFeesMapper; +import com.iformall.mapper.WxRentContractAgileRenevueItemMapper; +import com.iformall.mapper.WxRentContractAgileRenevueMapper; import com.iformall.mapper.WxRentContractAgileUnDepositItemMapper; import com.iformall.mapper.WxRentContractAgileUnDepositMapper; import com.iformall.mapper.WxRentContractFreePeriodMapper; import com.iformall.mapper.WxRentContractMapper; +import com.iformall.mapper.WxRentContractRevenueJumpMapper; import com.iformall.mapper.WxShopMapper; import com.iformall.service.SysConfigService; import com.iformall.service.WxAgileContractService; @@ -72,6 +80,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -101,6 +110,18 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { @Autowired WxRentContractAgileUnDepositItemMapper wxRentContractAgileUnDepositItemMapper; + @Autowired + WxRentContractAgileRenevueMapper wxRentContractAgileRenevueMapper; + + @Autowired + WxRentContractRevenueJumpMapper wxRentContractRevenueJumpMapper; + + @Autowired + WxRentContractAgileRenevueFeesMapper wxRentContractAgileRenevueFeesMapper; + + @Autowired + WxRentContractAgileRenevueItemMapper wxRentContractAgileRenevueItemMapper; + @Autowired WxRentContractFreePeriodMapper wxRentContractFreePeriodMapper; @@ -511,6 +532,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { return ud; } + @Override + public WxRentContractAgileUnDeposit getUnDepositById(Long id,TenantEntity tenantEntity) { + return wxRentContractAgileUnDepositMapper.selectById(id, tenantEntity.getTenantId()); + } + + @Override public List findUnDepositList(WxRentContractAgileUnDeposit unDeposit) { List list = wxRentContractAgileUnDepositMapper.findList(unDeposit); @@ -530,6 +557,29 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { } return list; } + + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + @Override + public void deleteUnDeposit(WxRentContractAgileUnDeposit unDeposit) { + wxRentContractAgileUnDepositMapper.deleteById(unDeposit.getId(),unDeposit.getTenantId()); + WxRentContractAgileUnDepositItem itemdel = new WxRentContractAgileUnDepositItem(); + itemdel.updateTenantInfo(unDeposit); + itemdel.setUnDepositId(unDeposit.getId()); + wxRentContractAgileUnDepositItemMapper.deleteByUnDeposit(itemdel); + //删除账单 + WxAllBill wxBillDel = new WxAllBill(); + wxBillDel.updateTenantInfo(unDeposit); + wxBillDel.setRentContractId(unDeposit.getRentContractId()); + wxBillDel.setIsPreview(EnumYesOrNo.YES.getCode()); + wxBillDel.setRentContractAgileFeesType(EnumRentContractAgileFeesType.UN_DEPOSIT.getCode()); + wxBillDel.setEnergyFeesId(unDeposit.getFeesId()); + wxAllBillMapper.deletePreviewBill(wxBillDel); + } + + @Override + public List findUnDepositFeesIdList(WxRentContractAgileUnDeposit unDeposit) { + return wxRentContractAgileUnDepositMapper.findFeesIdList(unDeposit); + } @Override @@ -764,6 +814,158 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { return wxBillRent; } + @Override + public WxRentContractAgileRenevue findRenevueByContract(Long rentContractId,TenantEntity tenantEntity) { + WxRentContractAgileRenevue rq = new WxRentContractAgileRenevue(); + rq.updateTenantInfo(tenantEntity); + rq.setRentContractId(rentContractId);; + List list = wxRentContractAgileRenevueMapper.findList(rq); + if (null == list || list.size() <= 0 ) { + return null; + } + return list.get(0); + } + + + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + @Override + public void saveRenuvue(WxRentContractAgileRenevue renevue) { + final IdWorker idWorker = IdWorker.get(); + boolean isCreate = false; + if (null == renevue.getId() ) { + //保存租赁合同信息 + renevue.setId(idWorker.nextId()); + isCreate = true; + renevue.setCreatetime(new Date()); + } + WxRentContract contract = wxRentContractMapper.selectById(renevue.getRentContractId()); + + renevue.setUpdatetime(new Date()); + if (isCreate) { + wxRentContractAgileRenevueMapper.insert(renevue); + }else { + wxRentContractAgileRenevueMapper.updateById(renevue); + + WxRentContractAgileRenevueItem itemdel = new WxRentContractAgileRenevueItem(); + itemdel.updateTenantInfo(renevue); + itemdel.setRenevueId(renevue.getId()); + wxRentContractAgileRenevueItemMapper.deleteByRenevue(itemdel); + + WxRentContractAgileRenevueFees feesDel = new WxRentContractAgileRenevueFees(); + feesDel.updateTenantInfo(renevue); + feesDel.setAgileRenevueId(renevue.getId()); + wxRentContractAgileRenevueFeesMapper.deleteByRenevue(feesDel); + } + + validRenevueItem(renevue.getItems(), contract); + + for (int i = 0 ; i < renevue.getItems().size(); i++) { + WxRentContractAgileRenevueItem item = renevue.getItems().get(i); + item.setRentContractId(renevue.getRentContractId()); + item.setRenevueId(renevue.getId()); + item.setId(idWorker.nextId()); + item.updateTenantInfo(contract); + item.setCreatetime(new Date()); + item.setUpdatetime(new Date()); + wxRentContractAgileRenevueItemMapper.insert(item); + } + + for (int i = 0 ; i < renevue.getFees().size(); i++) { + WxRentContractAgileRenevueFees item = renevue.getFees().get(i); + item.setRentContractId(renevue.getRentContractId()); + item.setAgileRenevueId(renevue.getId()); + item.setId(idWorker.nextId()); + item.updateTenantInfo(contract); + item.setCreatetime(new Date()); + item.setUpdatetime(new Date()); + wxRentContractAgileRenevueFeesMapper.insert(item); + } + } + + private void validRenevueItem(List itemList,WxRentContract contract) { + Date lastEndDate = null; + for (int i = 0 ; i < itemList.size(); i++) { + WxRentContractAgileRenevueItem item = itemList.get(i); + //判断时间是不是连这的 + if (i == 0) { + lastEndDate = item.getEndTime(); + if (!item.getBeginTime().equals(contract.getRentalStartDate())) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"开始时间需要和合同开始时间一致"); + } + }else { + Date _curr = DateUtils.getSecondsTimeAfter(1, lastEndDate); + if (!_curr.equals(item.getBeginTime())) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"时间区间需要严格连接"); + } + } + + if (i == itemList.size()-1) { + if (!item.getEndTime().equals(contract.getRentalEndDate())) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"结尾时间需要和合同结束时间一致"); + } + } + lastEndDate = item.getEndTime(); + } + } + + @Override + public void saveRenuvueJumps(WxRentContract contract) { + if (null != contract.getRevenueJumps()) { + final IdWorker idWorker = IdWorker.get(); + List jlist = new ArrayList(); + for (int i = 0 ; i < contract.getRevenueJumps().size(); i++) { + WxRentContractRevenueJump jp = contract.getRevenueJumps().get(i); + if (StringUtils.isNotBlank(jp.getMinMoney())) { + jp.updateTenantInfo(contract); + jp.setId(idWorker.nextId()); + jp.setRentContractId(contract.getId()); + jp.setCreateTime(new Date()); + jp.setUpdateTime(new Date()); + jlist.add(jp); + } + } + if (jlist.size() > 0 ) { + wxRentContractRevenueJumpMapper.inertJumps(contract.getTenantId(), jlist); + } + } + } + + @Override + public void setJoinRenevueUp(WxRentContractAgileUnDeposit unDeposit) { + wxRentContractAgileUnDepositMapper.updateJoinRenevueUp(unDeposit); + } + + @Override + public List findRenevueItemListByContract(Long rentContractId,TenantEntity tenantEntity) { + WxRentContractAgileRenevueItem iq = new WxRentContractAgileRenevueItem(); + iq.updateTenantInfo(tenantEntity); + iq.setRentContractId(rentContractId); + iq.setSortColumn("begin_time asc"); + return wxRentContractAgileRenevueItemMapper.findList(iq); + } + + @Override + public List findRenevueFeesListByContract(Long rentContractId,TenantEntity tenantEntity) { + WxRentContractAgileRenevueFees iq = new WxRentContractAgileRenevueFees(); + iq.updateTenantInfo(tenantEntity); + iq.setRentContractId(rentContractId); + return wxRentContractAgileRenevueFeesMapper.findList(iq); + } + + @Override + public WxRentContractAgileRenevueItem findOneRenevueItemByTime(Long rentContractId,TenantEntity tenantEntity,Date begin,Date end) { + WxRentContractAgileRenevueItem iq = new WxRentContractAgileRenevueItem(); + iq.updateTenantInfo(tenantEntity); + iq.setRentContractId(rentContractId); + iq.setValidBeginTime(begin); + iq.setValidEndTime(end);; + iq.setSortColumn("begin_time asc"); + List items = wxRentContractAgileRenevueItemMapper.findList(iq); + if (null == items || items.size() <= 0 ) { + return null; + } + return items.get(0); + } @Override public List findBuildingFloorContractIds(TenantEntity tenantEntity, String floorRule, Long building, @@ -847,8 +1049,6 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { } } - //WxContractCustomers ccq = new WxContractCustomers(); - WxRentContractAgileDeposit cadq = new WxRentContractAgileDeposit(); cadq.updateTenantInfo(rentContract); cadq.setRentContractId(rentContract.getId()); @@ -908,6 +1108,57 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { } } + WxRentContractAgileRenevue rq = new WxRentContractAgileRenevue(); + rq.updateTenantInfo(rentContract); + rq.setRentContractId(rentContract.getId()); + List renevueList = wxRentContractAgileRenevueMapper.findList(rq); + Long renevueId = null; + if (null != renevueList && renevueList.size() > 0 ) { + for (int i = 0 ; i < renevueList.size() ; i++) { + WxRentContractAgileRenevue ar = renevueList.get(i); + ar.setRentContractId(newContractId); + ar.setId(idWorker.nextId()); + ar.setCreatetime(new Date()); + ar.setUpdatetime(new Date()); + wxRentContractAgileRenevueMapper.insert(ar); + renevueId = ar.getId(); + } + } + if (null != renevueId) { + WxRentContractAgileRenevueItem ari = generateRenevueItem(idWorker, rentContract, newContractId, renevueId); + wxRentContractAgileRenevueItemMapper.insert(ari); + } + WxRentContractAgileRenevueFees fq = new WxRentContractAgileRenevueFees(); + fq.updateTenantInfo(rentContract); + fq.setRentContractId(rentContract.getId()); + List renevueFeesList = wxRentContractAgileRenevueFeesMapper.findList(fq); + if (null != renevueFeesList && renevueFeesList.size() > 0 && null != renevueId ) { + for (int i = 0 ; i < renevueFeesList.size() ; i++) { + WxRentContractAgileRenevueFees arf = renevueFeesList.get(i); + arf.setRentContractId(newContractId); + arf.setAgileRenevueId(renevueId); + arf.setId(idWorker.nextId()); + arf.setCreatetime(new Date()); + arf.setUpdatetime(new Date()); + wxRentContractAgileRenevueFeesMapper.insert(arf); + } + } + + WxRentContractRevenueJump crjq = new WxRentContractRevenueJump(); + crjq.updateTenantInfo(rentContract); + crjq.setRentContractId(rentContract.getId()); + List jumpList = wxRentContractRevenueJumpMapper.findList(crjq); + if ( null != jumpList && jumpList.size() > 0 ) { + for (int i = 0 ; i < jumpList.size(); i++) { + WxRentContractRevenueJump rj = jumpList.get(i); + rj.setRentContractId(newContractId); + rj.setId(idWorker.nextId()); + rj.setCreateTime(new Date()); + rj.setUpdateTime(new Date()); + wxRentContractRevenueJumpMapper.insert(rj); + } + } + rentContract.setId(newContractId); rentContract.setCreatetime(new Date()); rentContract.setCreateBy(user.getId()); @@ -915,20 +1166,28 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { rentContract.setUpdatetime(new Date()); rentContract.setUpdateBy(user.getId()); rentContract.setUpdateByName(user.getName()); - rentContract.setStatus(EnumRentContractStatus.DRAFT.getCode()); + rentContract.setStatus(EnumRentContractStatus.UNWRITE.getCode()); rentContract.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); rentContract.setEndContractTime(null); - //rentContract.setFirstBillDateStart(null); - //rentContract.setFirstBillDateEnd(null); - //rentContract.setFirstBillReceiveDate(null); int[] array = DateUtils.getDiff(rentContract.getRentalStartDate(),rentContract.getRentalEndDate()); rentContract.setLease(array[0]); - //rentContract.setAdjustRatio(); - //rentContract.setRevenueRatioSet(); - //rentContract.set wxRentContractMapper.insert(rentContract); } + private WxRentContractAgileRenevueItem generateRenevueItem(IdWorker idWorker,WxRentContract rentContract,Long newContractId,Long renevueId) { + WxRentContractAgileRenevueItem ari = new WxRentContractAgileRenevueItem(); + ari.setRentContractId(newContractId); + ari.setRenevueId(renevueId); + ari.setBeginTime(rentContract.getRentalStartDate()); + ari.setBeginTime(rentContract.getRentalEndDate()); + ari.setRate("0"); + ari.setIsFree(EnumYesOrNo.NO.getCode()); + ari.setIsFather(EnumYesOrNo.YES.getCode()); + ari.setId(idWorker.nextId()); + ari.setCreatetime(new Date()); + ari.setUpdatetime(new Date()); + return ari; + } private WxRentContractAgileUnDepositItem generateUnDepositItem(IdWorker idWorker,WxRentContract rentContract,Long undepositId,Long feesId,Long shopId) { WxRentContractAgileUnDepositItem raudi = new WxRentContractAgileUnDepositItem(); @@ -967,5 +1226,167 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { wxAllBillMapper.transferCusName(bill); } + + @Override + public List getRentContractYears(WxRentContract rentContract) { + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); + int [] diffs = DateUtils.getDiff(rentContract.getRentalStartDate(),rentContract.getRentalEndDate()); + int months = diffs[0]; + int days = diffs[1]; + int ext = months % 12; + int years = months/12; + if (ext > 0 ) { + years = years + 1; + }else { + if (days > 0 ) { + years = years + 1; + } + } + //如果有撤铺日 + Date endcontract = rentContract.getEndContractTime(); + if (null != endcontract) { + endcontract = DateUtils.getDayEnd(endcontract); + } + List yearList = this.getYearList(years, 12, rentContract.getRentalStartDate(),endcontract); + List retList = new ArrayList(); + if (null != yearList && yearList.size() > 0) { + if (yearList.size() == 1) { + WxRentContractYearsVo vo = new WxRentContractYearsVo(); + vo.setStart(yearList.get(0)); + vo.setEnd(rentContract.getRentalEndDate()); + vo.setRemark("第1年度"); + vo.setYearIndex(1); + retList.add(vo); + }else { + Date begin = null; + for (int i = 0 ; i < yearList.size()-1 ; i ++) { + int yearindex = i+1; + begin = yearList.get(i); + Date end = yearList.get(i+1); + Date realEnd = DateUtils.getDaySet(end, Calendar.SECOND, -1); + WxRentContractYearsVo vo = new WxRentContractYearsVo(); + vo.setStart(begin); + vo.setEnd(realEnd); + vo.setRemark("第"+yearindex+"年度"); + vo.setYearIndex(yearindex); + retList.add(vo); + begin = end; + } + WxRentContractYearsVo vo = new WxRentContractYearsVo(); + vo.setStart(yearList.get(yearList.size()-1)); + vo.setEnd(rentContract.getRentalEndDate()); + vo.setRemark("第"+yearList.size()+"年度"); + vo.setYearIndex(yearList.size()); + retList.add(vo); + } + } + if (retList.size() > 0 ) { + return retList; + } + return null; + } + + private List getYearList(int years,int month,Date rentalStartDate,Date endContractTime ) { + List yearList = new ArrayList(); + for (int i = 0; i < years; i++) { + Calendar instance = Calendar.getInstance(); + instance.setTime(rentalStartDate); + instance.set(Calendar.MILLISECOND, 0); + instance.add(Calendar.MONTH, month * i); + Date startDate = instance.getTime(); + if (null != endContractTime && endContractTime.before(startDate)) { + yearList.add(endContractTime); + break; + }else { + yearList.add(startDate); + } + } + return yearList; + } + + @Transactional(rollbackFor = {Exception.class}) + @Override + public void reSetContract(WxRentContract wxRentContract, MallUserInfo user) { + //当前时间之后的未处理过的账单,全部删除,之前的账单,还有以后已经处理过的账单,不处理。需财务手工处理这些账单 + WxAllBill bq = new WxAllBill(); + bq.updateTenantInfo(wxRentContract); + bq.setRentContractId(wxRentContract.getId()); + bq.setShopEndtime(new Date()); + wxAllBillMapper.deleteNoNeedPayBill(bq); + //原来所有的非押金,扣点都默认设置为按合同,然后时间设置为合同开始时间和结束时间,单价为0 + WxRentContractAgileUnDeposit udq = new WxRentContractAgileUnDeposit(); + udq.updateTenantInfo(wxRentContract); + udq.setRentContractId(wxRentContract.getId()); + List udList = wxRentContractAgileUnDepositMapper.findList(udq); + final IdWorker idWorker = IdWorker.get(); + if (null != udList && udList.size() > 0 ) { + for (int i = 0 ; i < udList.size(); i++ ) { + WxRentContractAgileUnDeposit ud = udList.get(i); + WxRentContractAgileUnDepositItem udid = new WxRentContractAgileUnDepositItem(); + udid.updateTenantInfo(wxRentContract); + udid.setUnDepositId(ud.getId()); + wxRentContractAgileUnDepositItemMapper.deleteByUnDeposit(udid); + generateUnDepositItem(idWorker, wxRentContract, ud.getId(), ud.getFeesId(), null); + } + } + WxRentContractAgileRenevue arq = new WxRentContractAgileRenevue(); + arq.updateTenantInfo(wxRentContract); + arq.setRentContractId(wxRentContract.getId()); + List arList = wxRentContractAgileRenevueMapper.findList(arq); + if (null != arList && arList.size() > 0 ) { + for (int i = 0 ; i < arList.size(); i++ ) { + WxRentContractAgileRenevue ud = arList.get(i); + WxRentContractAgileRenevueItem arid = new WxRentContractAgileRenevueItem(); + arid.updateTenantInfo(wxRentContract); + arid.setRentContractId(wxRentContract.getId()); + arid.setRenevueId(ud.getId()); + wxRentContractAgileRenevueItemMapper.deleteByRenevue(arid); + generateRenevueItem(idWorker, wxRentContract, wxRentContract.getId(), ud.getId()); + } + } + } + + @Override + public void endContractDespoitBill(WxRentContract wxRentContract, MallUserInfo user) { + //当前时间之后的未处理过的账单,全部删除,之前的账单,还有以后已经处理过的账单,不处理。需财务手工处理这些账单 + WxAllBill bq = new WxAllBill(); + bq.updateTenantInfo(wxRentContract); + bq.setRentContractId(wxRentContract.getId()); + bq.setShopEndtime(new Date()); + List feesIds = new ArrayList(); + for (int i = 0 ; i < wxRentContract.getContractDepositList().size(); i++) { + WxRentContractAgileDeposit deposit = wxRentContract.getContractDepositList().get(i); + if (!feesIds.contains(deposit.getFeesId())) { + feesIds.add(deposit.getFeesId()); + } + } + bq.setEnergyFeesIds(feesIds); + bq.setRentContractAgileFeesType(EnumRentContractAgileFeesType.DEPOSIT.getCode()); + wxAllBillMapper.deleteNoNeedPayBill(bq); + } + + @Override + public void endContractUnDespositBill(WxRentContractAgileUnDeposit unDeposit, MallUserInfo user) { + WxAllBill bq = new WxAllBill(); + bq.updateTenantInfo(unDeposit); + bq.setRentContractId(unDeposit.getRentContractId()); + bq.setShopEndtime(new Date()); + bq.setEnergyFeesId(unDeposit.getFeesId()); + bq.setRentContractAgileFeesType(EnumRentContractAgileFeesType.UN_DEPOSIT.getCode()); + wxAllBillMapper.deleteNoNeedPayBill(bq); + } + + @Transactional(rollbackFor = {Exception.class}) + @Override + public void endContractRenevueBill(WxRentContractAgileRenevue renevue) { + WxAllBill bq = new WxAllBill(); + bq.updateTenantInfo(renevue); + bq.setRentContractId(renevue.getRentContractId()); + bq.setShopEndtime(new Date()); + bq.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_REVENUE_SALES.getCode()); + wxAllBillMapper.deleteNoNeedPayBill(bq); + bq.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN.getCode()); + wxAllBillMapper.deleteNoNeedPayBill(bq); + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index 515dd0c35..117afcbff 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -177,11 +177,7 @@ public class WxFlowServiceImpl implements WxFlowService { contractType = Integer.parseInt(str); } - if(EnumFlowKey.CONTRACT.getCode().equals(flowType) || - EnumFlowKey.NEW_RENT_CONTRACT.getCode().equals(flowType) || - EnumFlowKey.NEW_PRO_CONTRACT.getCode().equals(flowType)|| - EnumFlowKey.NNEW_RENT_CONTRACT.getCode().equals(flowType) - ){ + if(EnumFlowKey.CONTRACT.getCode().equals(flowType) || EnumFlowKey.NEW_RENT_CONTRACT.getCode().equals(flowType)){ // 1租赁合同 2点位合同 3物业 4点位物业合同 5 合并合同-店铺 6 合并合同-多经点位 if (EnumFlowContractType.RENT.getCode().equals(contractType) || EnumFlowContractType.WHOLE_SHOP.getCode().equals(contractType)) { @@ -239,11 +235,7 @@ public class WxFlowServiceImpl implements WxFlowService { }else if(EnumFlowContractType.PROPERTY.getCode().equals(contractType)){ } - }else if(EnumFlowKey.END_CONTRACT.getCode().equals(flowType) - || EnumFlowKey.NEW_RENT_END_CONTRACT.getCode().equals(flowType) - || EnumFlowKey.NEW_PRO_END.getCode().equals(flowType) - || EnumFlowKey.NEW_RENT_END.getCode().equals(flowType) - ){ + }else if(EnumFlowKey.END_CONTRACT.getCode().equals(flowType) || EnumFlowKey.NEW_RENT_END_CONTRACT.getCode().equals(flowType)){ if(EnumFlowContractType.RENT.getCode().equals(contractType) || EnumFlowContractType.WHOLE_SHOP.getCode().equals(contractType)) { WxRentContract rent = new WxRentContract(); @@ -722,10 +714,6 @@ public class WxFlowServiceImpl implements WxFlowService { ||EnumFlowKey.END_CONTRACT.getCode().equals(flowType) || EnumFlowKey.NEW_RENT_CONTRACT.getCode().equals(flowType) || EnumFlowKey.NEW_RENT_END_CONTRACT.getCode().equals(flowType) - || EnumFlowKey.NEW_PRO_CONTRACT.getCode().equals(flowType) - || EnumFlowKey.NEW_PRO_END.getCode().equals(flowType) - || EnumFlowKey.NNEW_RENT_CONTRACT.getCode().equals(flowType) - || EnumFlowKey.NEW_RENT_END.getCode().equals(flowType) ){ return true; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 64a2172bf..928d40777 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -806,7 +806,7 @@ public class WxOrderServiceImpl implements WxOrderService { } //限购频次 if (counpon.getUseLimitFrequency().intValue() == EnumCouponUseLimitFrequency.PERDAY.getCode().intValue()) { - couponOrderQ.setCreateDateLike(new Date()); + couponOrderQ.setCreateDateLike(DateUtils.date2String(new Date(), DateUtils.DATE_PATTERN)); } return wxCouponOrderMapper.findProductCount(couponOrderQ)+couponNumber; } catch(MallinkException e1) { 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 31b0a829c..c27c68977 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -24,6 +24,10 @@ import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchantTradeDaily; import com.iformall.domain.po.WxPayAccountBill; import com.iformall.domain.po.WxRentContract; +import com.iformall.domain.po.WxRentContractAgileRenevue; +import com.iformall.domain.po.WxRentContractAgileRenevueFees; +import com.iformall.domain.po.WxRentContractAgileRenevueItem; +import com.iformall.domain.po.WxRentContractAgileUnDeposit; import com.iformall.domain.po.WxRentContractFreePeriod; import com.iformall.domain.po.WxRentContractRevenueJump; import com.iformall.domain.po.WxRentContractRevenueSales; @@ -38,6 +42,7 @@ import com.iformall.domain.vo.WxBillSum; import com.iformall.domain.vo.WxRentContractRevenueSetSalesVo; import com.iformall.domain.vo.WxRentContractYearsSumVo; import com.iformall.domain.vo.WxRentContractYearsVo; +import com.iformall.enums.EnumAgileContractType; import com.iformall.enums.EnumBillAction; import com.iformall.enums.EnumBillExtraCreateFrom; import com.iformall.enums.EnumBillStatus; @@ -56,6 +61,8 @@ import com.iformall.enums.EnumPriceUnit; import com.iformall.enums.EnumRentAgileType; import com.iformall.enums.EnumRentContractAdjustPeriod; import com.iformall.enums.EnumRentContractAdjustRatioWay; +import com.iformall.enums.EnumRentContractAgilPriceUnit; +import com.iformall.enums.EnumRentContractAgilTimeUnit; import com.iformall.enums.EnumRentContractAgileFeesType; import com.iformall.enums.EnumRentContractAppStatus; import com.iformall.enums.EnumRentContractManageFeeType; @@ -64,6 +71,7 @@ import com.iformall.enums.EnumRentContractType; import com.iformall.enums.EnumRentDayPriceCalcute; import com.iformall.enums.EnumRentShopType; import com.iformall.enums.EnumRentStartType; +import com.iformall.enums.EnumShopStatus; import com.iformall.enums.EnumShopUsersStatus; import com.iformall.enums.EnumShopUsersType; import com.iformall.enums.EnumSystemUserType; @@ -247,217 +255,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { return wxRentContractMapper.findIdList(record); } -// @Override -// public Map getById(Long id,Integer noBillList) { -// Map result = new HashMap<>(); -// WxRentContract wxRentContract = wxRentContractMapper.selectById(id); -// if (wxRentContract == null) { -// throw new MallinkException(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); -// } -// -// WxContractCustomers customers = wxContractCustomersMapper.selectById(wxRentContract.getCustomersId(),wxRentContract.getTenantId()); -// wxRentContract.setCustomerType(customers.getPrincipalType()); -// wxRentContract.setCustomerLinkPerson(customers.getLinkPerson()); -// wxRentContract.setCustomerName(customers.getName()); -// wxRentContract.setCustomerPhone(customers.getPhone()); -// wxRentContract.setCustomerLegalPerson(customers.getLegalPerson()); -// -// //init dateDiff -// if(wxRentContract.getRentalStartDate() != null && wxRentContract.getRentalEndDate() != null){ -// //加1天 -// Date newEndDate = DateUtils.getDaySet(wxRentContract.getRentalEndDate(),Calendar.DATE,1); -// int[] array = DateUtils.getDiff(wxRentContract.getRentalStartDate(),newEndDate); -// result.put("totalPeriodMonth",array[0]); -// result.put("totalPeriodDay",array[1]); -// } -// -// //init 租赁单价 -// String rentInfo = wxRentContract.getRentInfo(); -// if(StringUtils.isNotBlank(rentInfo)){ -// JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); -// int size = rentInfoArray.size(); -// //查询rent_info 包括shopId -// for (int i = 0; i < size; i++) { -// JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); -// BigDecimal rentPrice = rentInfoObject.getBigDecimal("rentPrice"); -// //wxRentContract.setShopId(rentInfoObject.getLong("shopId")); -// String price = wxRentContract.getPrice(); -// if(rentPrice == null){ -// if(StringUtils.isNotBlank(wxRentContract.getRentArea()) && !"0".equals(wxRentContract.getRentArea()) && !"0.00".equals(wxRentContract.getRentArea()) && !"0.0".equals(wxRentContract.getRentArea()) ) { -// Double rentArea = Double.parseDouble(wxRentContract.getRentArea()); -// rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea),wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); -// rentInfoObject.put("rentPrice", rentPrice); -// } -// } -// } -// wxRentContract.setRentInfo(rentInfoArray.toJSONString()); -// }else{ -// if(wxRentContract.getRentPrice() == null || "0".equals(wxRentContract.getRentPrice())){ -// if(StringUtils.isNotBlank(wxRentContract.getRentArea()) && !"0".equals(wxRentContract.getRentArea()) && !"0.00".equals(wxRentContract.getRentArea()) && !"0.0".equals(wxRentContract.getRentArea()) ) { -// String price = wxRentContract.getPrice(); -// Double rentArea = Double.parseDouble(wxRentContract.getRentArea()); -// BigDecimal rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea),wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); -// if(rentPrice.compareTo(new BigDecimal(0)) > 0){ -// wxRentContract.setRentPrice(rentPrice.toString()); -// }else{ -// wxRentContract.setRentPrice("0"); -// } -// } -// -// } -// } -// if(wxRentContract.getPriceUnit() == null){ -// wxRentContract.setPriceUnit(EnumPriceUnit.M.getCode()); -// } -// if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){ -// wxRentContract.setAdjustPeriod(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()); -// wxRentContract.setPriceUnit(EnumPriceUnit.D.getCode()); -// } -// -// //商场信息 -// WxMall wxMall = new WxMall(); -// wxMall.setTenantInfo(wxRentContract); -// List mallList = wxMallService.findList(wxMall); -// if (!mallList.isEmpty()) { -// result.put("mall", mallList.get(0)); -// } -// wxRentContract.setPrice(StringUtils.isNotBlank(wxRentContract.getPrice()) ? wxRentContract.getPrice() : "0"); -// wxRentContract.setDeposit(StringUtils.isNotBlank(wxRentContract.getDeposit()) ? wxRentContract.getDeposit() : "0"); -// -// //免租期 -// WxRentContractFreePeriod fpq = new WxRentContractFreePeriod(); -// fpq.updateTenantInfo(wxRentContract); -// fpq.setRentContractId(wxRentContract.getId()); -// fpq.setSortColumn("year_index asc,start_date asc"); -// List freePeroids = wxRentContractFreePeriodMapper.findList(fpq); -// wxRentContract.setFreeVo(freePeroids); -// -// //跳点设置 -// WxRentContractRevenueJump jq = new WxRentContractRevenueJump(); -// jq.updateTenantInfo(wxRentContract); -// jq.setRentContractId(wxRentContract.getId()); -// wxRentContract.setRevenueJumps(wxRentContractRevenueJumpMapper.findList(jq)); -// result.put("wxRentContract", wxRentContract); -// //关联的店铺 -// if (wxRentContract.shopIdsByRentInfo().size()> 0) { -// WxShop record = new WxShop(); -// //record.setId(wxRentContract.getShopId()); -// record.setIds(wxRentContract.shopIdsByRentInfo()); -// record.updateTenantInfo(wxRentContract); -// PageInfo> shopPageInfo = wxShopService.findListMap(record,1,10000); -// List> list = shopPageInfo.getList(); -// result.put("wxShops", list); -// } else { -// result.put("wxShops", Collections.EMPTY_LIST); -// } -// //设置审批流程状态 -// result.put("applyStatus", wxRentContract.getApplyStatus()); -// -// //发起人备注 -// WxFlowRecord wxFlowRecord = new WxFlowRecord(); -// wxFlowRecord.setBusinessId(String.valueOf(id)); -// wxFlowRecord.setStatus(EnumFlowRecordStatus.NEW.getCode()); -// List flowRecordList = wxFlowRecordService.findList(wxFlowRecord); -// if(!CollectionUtils.isEmpty(flowRecordList)){ -// result.put("remark",flowRecordList.get(0).getRemark()); -// } -// -// //查询预账单用于展示 -// if (null != noBillList && EnumYesOrNo.YES.getCode().intValue() == noBillList.intValue()) { -// }else { -// WxAllBill wxBillRent = new WxAllBill(); -// wxBillRent.setRentContractId(id); -// wxBillRent.updateTenantInfo(wxRentContract); -// wxBillRent.setBillType(EnumBillAllType.RENT.getCode()); -// List resultList = wxAllBillMapper.findContractSamePeriodSum(wxBillRent); -// result.put("previewBillRentList",resultList); -// } -// -// return result; -// } - @Override public WxRentContract selectById(Long id) { return wxRentContractMapper.selectById(id); } -// @Transactional(rollbackFor = {Exception.class}) -// @Override -// public ResultData save(WxRentContract record,MallUserInfo user,String userName,Date oldRentStartDate) { -// //保存租赁合同信息 -// final IdWorker idWorker = IdWorker.get(); -// record.setId(idWorker.nextId()); -// int dayType = record.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; -// //计租开始时间 -// Calendar instance = Calendar.getInstance(); -// instance.setTime(record.getRentalStartDate()); -// instance.add(dayType, record.getLease()); -// instance.add(Calendar.DAY_OF_MONTH, -1); -// //计租结束时间 -// if (!record.getStartDate().equals(record.getRentalStartDate())) { -// instance.clear(); -// instance.setTime(record.getRentalStartDate()); -// instance.add(Calendar.DAY_OF_MONTH, -1); -// record.setEndDate(instance.getTime()); -// } else { -// record.setEndDate(record.getStartDate()); -// } -// -// if (StringUtils.isEmpty(record.getPrice())) { -// record.setPrice("0"); -// } -// if (StringUtils.isEmpty(record.getDeposit())) { -// record.setDeposit("0"); -// } -// -// Date date = new Date(); -// record.setCreatetime(date); -// record.setCreateBy(user.getId()); -// record.setCreateByName(user.getName()); -// record.setUpdatetime(date); -// record.setUpdateBy(user.getId()); -// record.setUpdateByName(user.getName()); -// -// List shopList = Lists.newArrayList(); -// String rentInfo = record.getRentInfo(); -// JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); -// int size = rentInfoArray.size(); -// if (size == 0) { -// return new ResultData(ErrorCode.SHOP_NOT_SELECTED); -// } -// //查询rent_info 包括 shopId -// String shopIdStr = ""; -// BigDecimal rentArea = new BigDecimal(0); -// for (int i = 0; i < size; i++) { -// JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); -// Long shopId = rentInfoObject.getLong("id"); -// rentArea = rentArea.add(new BigDecimal(rentInfoObject.getString("operationArea"))); -// if (!shopList.contains(shopId)) { -// shopList.add(shopId); -// shopIdStr = shopIdStr +","+ shopId; -// } -// } -// record.setRentArea(rentArea.toPlainString()); -// setShops(record,shopList); -// //关联客户 -// setCustomers(record); -// try { -// record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); -// record.setStatus(EnumRentContractStatus.UNWRITE.getCode()); -// Date tempDate = record.getRentalStartDate(); -// record.setRentalStartDate(oldRentStartDate); -// record.setShopIdStr(shopIdStr); -// record.setAgileType(EnumRentAgileType.STANDARDS_YEAR.getCode()); -// wxRentContractMapper.insert(record); -// record.setRentalStartDate(tempDate); -// } catch (Exception e) { -// logger.error("保存租赁合同信息失败,e:" + e.getMessage()); -// throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); -// } -// -// return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record); -// } - public void setCustomers(WxRentContract record) { WxContractCustomers cq = new WxContractCustomers(); cq.updateTenantInfo(record); @@ -522,510 +324,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { return record.shopIdsByRentInfo(); } - //@Transactional(rollbackFor = {Exception.class}) -// @Override -// public ResultData update(WxRentContract record, MallUserInfo user,String userName,int from,Date oldRentStartDate,boolean writeComplate,boolean setRevenJumps) { -// //查询预账单用于展示 -// WxAllBill wxBillRent = new WxAllBill(); -// wxBillRent.setRentContractId(record.getId()); -// wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); -// wxBillRent.updateTenantInfo(record); -// List resultList = wxAllBillMapper.findList(wxBillRent); -// -// //更新 -// ResultData resultData = getResultDataForUpdate(record, user,from,oldRentStartDate,writeComplate,setRevenJumps); -// if (resultData.code != Result.SUCCESS) { -// return resultData; -// } -// -// boolean saveBill = true; -// if(CollectionUtils.isEmpty(record.getPreviewBillRentList())) { -// if (record.getReceivePeriod() != null && record.getLease() != null -// && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) { -// deletePrewBill(record); -// //联营扣点,不设置保底营业额,不生成账单 -// //if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(record.getType()) && record.getRevenueRatio().equals(0)) { -// //do nothing -// // saveBill = false; -// //}else { -// resultList = buildRent(user, record, EnumIsPreview.YES.getCode(),true); -// //} -// } -// } -// -// WxRentContract wxRentContract = (WxRentContract)resultData.data; -// wxRentContract.setPreviewBillRentList(resultList); -// return new ResultData(wxRentContract); -// } - -// @Transactional(rollbackFor = {Exception.class}) -// @Override -// public ResultData updateOneStep(WxRentContract record, MallUserInfo user,String userName,int from,Date oldRentStartDate,boolean writeComplate) { -// //查询预账单用于展示 -// WxAllBill wxBillRent = new WxAllBill(); -// wxBillRent.setRentContractId(record.getId()); -// wxBillRent.setSortColumns("starttime asc"); -// wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); -// wxBillRent.updateTenantInfo(record); -// List resultList = wxAllBillMapper.findList(wxBillRent); -// -// //更新 -// setCustomers(record); -// ResultData resultData = getResultDataForUpdate(record, user,from,oldRentStartDate,writeComplate,false); -// if (resultData.code != Result.SUCCESS) { -// return resultData; -// } -// WxRentContract wxRentContract = (WxRentContract)resultData.data; -// wxRentContract.setPreviewBillRentList(resultList); -// -// WxRentContractRevenueJump jq = new WxRentContractRevenueJump(); -// jq.updateTenantInfo(record); -// jq.setRentContractId(record.getId()); -// wxRentContract.setRevenueJumps(wxRentContractRevenueJumpMapper.findList(jq)); -// return new ResultData(wxRentContract); -// } - -// @Override -// public ResultData updateRentStartTime(WxRentContract record, MallUserInfo user) { -// //查询预账单用于展示 -// WxAllBill wxBillRent = new WxAllBill(); -// wxBillRent.setRentContractId(record.getId()); -// wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); -// wxBillRent.updateTenantInfo(record); -// List resultList = wxAllBillMapper.findList(wxBillRent); -// -// //更新 -// WxRentContract contractUpdate = new WxRentContract(); -// contractUpdate.setId(record.getId()); -// contractUpdate.updateTenantInfo(record); -// contractUpdate.setRentStartType(record.getRentStartType()); -// contractUpdate.setUpdatetime(new Date()); -// contractUpdate.setUpdateBy(user.getId()); -// contractUpdate.setUpdateByName(user.getName()); -// wxRentContractMapper.updateById(record); -// -// -// WxRentContract rentContract = wxRentContractMapper.selectById(record.getId()); -// Date oldDate = record.getRentalStartDate(); -// rentContract.setAdjustPeriodHandle(); -// if(rentContract.getRentStartType()!=null && rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ -// rentContract.setRentalStartDate(rentContract.getStartDate()); -// } -// -// deletePrewBill(record); -// resultList = buildRent(user, rentContract, EnumIsPreview.YES.getCode(),true); -// rentContract.setPreviewBillRentList(resultList); -// rentContract.setRentalStartDate(oldDate); -// return new ResultData(rentContract); -// } - -// public ResultData getResultDataForUpdate(WxRentContract record, MallUserInfo user,int from,Date oldRentStartDate,boolean writeFinal,boolean setRevenJumps) { -// //更新租赁合同信息 -// WxRentContract wxRentContract = wxRentContractMapper.selectById(record.getId()); -// if (wxRentContract == null) { -// return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); -// } -// wxRentContract.setPayRatio(record.getPayRatio()); -// -// int dayType = wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; -// -// Calendar instance = Calendar.getInstance(); -// instance.setTime(record.getRentalStartDate()); -// instance.add(dayType, record.getLease()); -// instance.add(Calendar.DAY_OF_MONTH, -1); -// -// if(!EnumFromType.SWITCH.getCode().equals(from)){ -// //如果是联营扣点,或者联营取高,需要根据保底营业额来计算 -// if (record.getType() != null) { -// //联营扣点 -// if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { -// String revenue = record.getRevenue(); -// if (StringUtils.isBlank(revenue)) { -// revenue = "0"; -// }else { -// if (StringUtils.isNotBlank(record.getLimitRevenue()) && new BigDecimal(record.getLimitRevenue()).compareTo(new BigDecimal(revenue)) > 0) { -// revenue = "0"; -// } -// } -// record.setPrice(new BigDecimal(record.getPayRatio()).multiply(new BigDecimal(revenue)).divide(new BigDecimal(100),Constant.default_long_decimal_size,RoundingMode.HALF_UP).toPlainString()); -// }else if (record.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { -// BigDecimal rentPrice = null; -// //联营取高,如果是固定金额的话,取固定金额. 不固定的金额,会传price. -// if (null != record.getRevenueFixedRentPrice() && record.getRevenueFixedRentPrice().intValue() == EnumYesOrNo.YES.getCode()){ -// rentPrice = new BigDecimal(record.getRevenueRentPrice()); -// }else { -// rentPrice = new BigDecimal(record.getPrice()); -// } -// record.setPrice(rentPrice.toPlainString()); -// } -// } -// } -// -// if (StringUtils.isEmpty(record.getPrice())) { -// record.setPrice("0"); -// } -// if (StringUtils.isEmpty(record.getDeposit())) { -// record.setDeposit("0"); -// } -// List shopList = Lists.newArrayList(); -// record.setUpdatetime(new Date()); -// record.setUpdateBy(user.getId()); -// record.setUpdateByName(user.getName()); -// String rentInfo = record.getRentInfo(); -// JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); -// int size = rentInfoArray.size(); -// if (size == 0) { -// return new ResultData(ErrorCode.SHOP_NOT_SELECTED); -// } -// //查询rent_info 包括 shopId -// String shopIdStr = ""; -// BigDecimal rentArea = new BigDecimal(0); -// for (int i = 0; i < size; i++) { -// JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); -// WxRentContract wxRentContractQuery = new WxRentContract(); -// wxRentContractQuery.updateTenantInfo(record); -// Long shopId = rentInfoObject.getLong("id"); -// String shopNumber = rentInfoObject.getString("shopNumber"); -// if (shopId == null) { -// return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除"); -// } -// rentArea = rentArea.add(new BigDecimal(rentInfoObject.getString("operationArea"))); -// wxRentContractQuery.setId(record.getId()); -// if (!shopList.contains(shopId)) { -// shopList.add(shopId); -// shopIdStr = shopIdStr +","+shopId; -// } -// } -// setShops(record,shopList); -// record.setRentArea(rentArea.toPlainString()); -// try { -// Date tempDate = record.getRentalStartDate(); -// record.setRentalStartDate(oldRentStartDate); -// record.setShopIdStr(shopIdStr); -// if (writeFinal) { -// record.setStatus(EnumRentContractStatus.DRAFT.getCode()); -// }else { -// record.setStatus(wxRentContract.getStatus()); -// } -// record.setApplyStatus(wxRentContract.getApplyStatus()); -// if (StringUtils.isBlank(record.getOperatingManagementFee())){ -// record.setOperatingManagementFee(null); -// } -// if (StringUtils.isBlank(record.getBussinessManagementFee())){ -// record.setBussinessManagementFee(null); -// } -// wxRentContractMapper.updateById(record); -// record.setRentalStartDate(tempDate); -// -// if (setRevenJumps) { -// WxRentContractRevenueJump jumpsDel = new WxRentContractRevenueJump(); -// jumpsDel.updateTenantInfo(record); -// jumpsDel.setRentContractId(record.getId()); -// wxRentContractRevenueJumpMapper.deleteByContract(jumpsDel); -// -// if (null != record.getRevenueJumps()) { -// final IdWorker idWorker = IdWorker.get(); -// List jlist = new ArrayList(); -// for (int i = 0 ; i < record.getRevenueJumps().size(); i++) { -// WxRentContractRevenueJump jp = record.getRevenueJumps().get(i); -// if (StringUtils.isNotBlank(jp.getMinMoney())) { -// jp.updateTenantInfo(record); -// jp.setId(idWorker.nextId()); -// jp.setRentContractId(record.getId()); -// jp.setCreateTime(new Date()); -// jp.setUpdateTime(new Date()); -// jlist.add(jp); -// } -// } -// if (jlist.size() > 0 ) { -// wxRentContractRevenueJumpMapper.inertJumps(record.getTenantId(), jlist); -// } -// } -// } -// -// } catch (Exception e) { -// logger.error("更新租赁合同信息失败,e:" + e.getMessage()); -// throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); -// } -// //重新查一次 -// wxRentContract = wxRentContractMapper.selectById(record.getId()); -// return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", wxRentContract); -// } - - - @Transactional(rollbackFor = {Exception.class}) -// @Override -// public void buildDeposit( TenantEntity tenantEntity,MallUserInfo user,Long rentContractId) { -// WxRentContract wxRentContract = wxRentContractMapper.selectById(rentContractId); -// if (wxRentContract != null && StringUtils.isNotBlank(wxRentContract.getDeposit()) -// && new BigDecimal(wxRentContract.getDeposit()).compareTo(new BigDecimal(0)) > 0 ) { -// -// List shopIdList = wxRentContract.shopIdsByRentInfo(); -// -// WxShopUsers suq = new WxShopUsers(); -// suq.updateTenantInfo(wxRentContract); -// suq.setShopIds(shopIdList); -// suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); -// Map shopUserMap = wxShopService.getShopUserMap(suq); -// -// WxEnergyFees fq = new WxEnergyFees(); -// fq.updateTenantInfo(tenantEntity); -// fq.setBillType(EnumBillAllType.RENT_DEPOSIT.getCode()); -// Map typeMap = wxEnergyService.getFeesMap(fq); -// -// //根据不同的科目生成不同的押金账单 -// Map feesMap = wxRentContract.getDepositEnergyFees(typeMap); -// Map shopAreaRateMap = wxRentContract.getRentShopArea(); -// if (null == shopAreaRateMap) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无店铺信息"); -// } -// List insertList = new ArrayList(); -// -// for (Iterator it = feesMap.keySet().iterator();it.hasNext();){ -// Long energyFeesId = it.next(); -// WxEnergyFees depositFee = feesMap.get(energyFeesId); -// WxEnergyFees fees = typeMap.get(energyFeesId); -// final IdWorker idWorker = IdWorker.get(); -// -// for (int i = 0 ; i < shopIdList.size(); i++ ) { -// Long sid = shopIdList.get(i); -// BigDecimal shoprentArea = shopAreaRateMap.get(sid); -// BigDecimal shoprate = shoprentArea.divide(new BigDecimal(wxRentContract.getRentArea()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); -// String cusName = null; -// if (null != shopUserMap) { -// WxShopUsers su = shopUserMap.get(sid); -// if (null != su) { -// cusName = su.getName(); -// } -// } -// -// WxAllBill wxBillDeposit = new WxAllBill(); -// wxBillDeposit.setId(idWorker.nextId()); -// wxBillDeposit.setRentContractId(wxRentContract.getId()); -// wxBillDeposit.setBillType(EnumBillAllType.RENT_DEPOSIT.getCode()); -// wxBillDeposit.setIsPreview(EnumYesOrNo.NO.getCode()); -// wxBillDeposit.setCanEdit(EnumYesOrNo.NO.getCode()); -// //if (null != fees) { -// // wxBillDeposit.setPriceDetail("合同押金项["+fees.getName()+"]"+depositFee.getPrice()+"元"+"/"+fees.getCalcuteUnitName()); -// //} -// wxBillDeposit.setPay("0"); -// String needpay = depositFee.getPrice(); -// -// // String count = "1"; -// // if (null != depositFee.getCalcuteUnit() && depositFee.getCalcuteUnit().intValue() == EnumFeesStandardsCalcuteUnit.MM.getCode().intValue()) { -// // count = wxRentContract.getRentArea(); -// // } -// // String needpay = depositFee.calcuteTotalMoney(wxRentContract.getDecimalSize(), null, null, count, true, null, null); -// wxBillDeposit.setReceivePay(new BigDecimal(needpay).multiply(shoprate).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()); -// wxBillDeposit.setNeedPay(wxBillDeposit.getReceivePay()); -// //wxBillDeposit.setOwe(needpay); -// //找到计租方式 -// //int dayType = wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; -// int dayType = Calendar.MONTH; -// Date date = new Date(); -// wxBillDeposit.setStarttime(wxRentContract.getFirstBillDateStart()); -// wxBillDeposit.setEndtime(wxRentContract.getFirstBillDateEnd()); -// wxBillDeposit.setReceiveDate(wxRentContract.getFirstBillReceiveDate()); -// wxBillDeposit.setPeriod(WxRentContractHelper.getPeriod(wxRentContract.getFirstBillReceiveDate())); -// //wxBillDeposit.setExpiredDay(0L); -// wxBillDeposit.updateTenantInfo(wxRentContract); -// //wxBillDeposit.setIsDel(0); -// wxBillDeposit.setShopNumber(wxRentContract.getRentInfoShopNumber()); -// if (null != user) { -// //wxBillDeposit.setUserId(user.getId()); -// } -// wxBillDeposit.setShopId(sid); -// wxBillDeposit.setCusName(cusName); -// wxBillDeposit.setRentArea(shoprentArea.toPlainString()); -// wxBillDeposit.setCreatetime(date); -// if (null != user) { -// wxBillDeposit.setCreateBy(user.getId()); -// wxBillDeposit.setCreateByName(user.getName()); -// } -// wxBillDeposit.setUpdatetime(date); -// if (null != user) { -// wxBillDeposit.setUpdateBy(user.getId()); -// wxBillDeposit.setUpdateByName(user.getName()); -// } -// //wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); -// String rentInfo = wxRentContract.getRentInfo(); -// if (rentInfo != null) { -// JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); -// Map shopInfo = new HashMap<>(); -// for (int j = 0, size = rentInfoArray.size(); j < size; j++) { -// JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); -// shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("deposit")); -// } -// wxBillDeposit.setShopInfo(JSONObject.toJSONString(shopInfo)); -// } -// wxBillDeposit.setEnergyFeesId(energyFeesId); -// wxBillDeposit.setCreateBy(wxRentContract.getCreateBy()); -// wxBillDeposit.setUpdateBy(wxRentContract.getCreateBy()); -// wxBillDeposit.setCreateByName(wxRentContract.getCreateByName()); -// wxBillDeposit.setUpdateByName(wxRentContract.getCreateByName()); -// -// insertList.add(wxBillDeposit); -// } -// } -// -// try { -// if (insertList.size() > 0 ) { -// wxAllBillMapper.insertBills(tenantEntity.getTenantId(),insertList); -// } -// } catch (Exception e) { -// logger.error("添加押金账单失败,e:" + e.getMessage()); -// throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); -// } -// } -// } - -// @Override -// public ResultData hasRentStatus(WxRentContract record) { -// String rentInfo = record.getRentInfo(); -// if (StringUtils.isEmpty(rentInfo)) { -// return new ResultData(ErrorCode.SHOP_NOT_SELECTED); -// } -// String[] split = rentInfo.split(","); -// int size = split.length; -// //查询rent_info 包括 shopId -// for (int i = 0; i < size; i++) { -// String shopId = split[i]; -// WxShop wxShop = wxShopMapper.selectById(shopId); -// WxRentContract wxRentContractQuery = new WxRentContract(); -// wxRentContractQuery.updateTenantInfo(record); -// String shopNumber = wxShop.getShopNumber(); -// if (shopId == null) { -// return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除"); -// } -// //wxRentContractQuery.setShopId(Long.valueOf(shopId)); -// int count = wxRentContractMapper.selectRentContractCountByShopId(wxRentContractQuery.getTenantId(),wxRentContractQuery.getParentTenantId(),Long.valueOf(shopId),wxRentContractQuery.getId()); -// if (count > 0) { -// return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + shopNumber + " 已出租"); -// } -// } -// return new ResultData(Result.SUCCESS, "操作成功"); -// } - -// @Override -// public ResultData hasContractNumber(WxRentContract wxRentContract) { -// int count = wxRentContractMapper.hasContractNumber(wxRentContract); -// return new ResultData(Result.SUCCESS, "操作成功", count > 0 ? true : false); -// } - - public void updateInvalidStatus(WxRentContract record) { - Long id = record.getId(); - //审核流程中止 - try { - // 修改合同审核状态 - WxRentContract rentContract = record; - rentContract.setId(id); - rentContract.setApplyStatus(EnumRentContractAppStatus.CANCLE.getCode()); - updateApplyStatus(rentContract); - - //修改flowRecord - WxFlowRecord fr = new WxFlowRecord(); - fr.setBusinessId(String.valueOf(id)); - fr.setCurrStatus(EnumRentContractAppStatus.CANCLE.getCode()); - wxFlowRecordMapper.updateCurrStatus(fr); - - logger.info("合同id:{},开始停止...", id); - //结束审批流 by luozukai - WxFlowModel flowModel = wxFlowService.getModelByType(EnumFlowKey.NEW_RENT_CONTRACT.getCode().intValue(),record); - - WxFlowModel flowModel_pro = wxFlowService.getModelByType(EnumFlowKey.NEW_PRO_CONTRACT.getCode().intValue(),record); - - WxFlowModel flowModel_rent = wxFlowService.getModelByType(EnumFlowKey.NNEW_RENT_CONTRACT.getCode().intValue(),record); - - List keyList = new ArrayList<>(); - if(flowModel != null){ - keyList.add(flowModel.getFlowId()); - } - if(flowModel_pro != null){ - keyList.add(flowModel_pro.getFlowId()); - } - if(flowModel_rent != null){ - keyList.add(flowModel_rent.getFlowId()); - } - keyList.add(EnumFlowKey.CONTRACT.getMessage()); - List tasks = taskService.createTaskQuery() - .processDefinitionKeyIn(keyList) - .processVariableValueEquals("businessId", id+"").list(); - if (!CollectionUtils.isEmpty(tasks)) { - for (Task task : tasks) { - logger.info("合同id:{},taskid:{}", id, task.getId()); - runtimeService.deleteProcessInstance(task.getProcessInstanceId(), "合同作废"); - - // 保存审批历史入 - MallUserInfo mallUserInfo = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); - WxFlowRecord updateRecord = new WxFlowRecord(); - updateRecord.setBusinessId(String.valueOf(id)); - updateRecord.setStatus(EnumFlowRecordStatus.CANCLE.getCode()); - updateRecord.setBusinessType(1); - updateRecord.setUserId(mallUserInfo.getId()); - updateRecord.setProcessInstanceId(task.getProcessInstanceId()); - wxFlowRecordService.saveOrUpdate(updateRecord); - } - } - - } catch (Exception e) { - logger.error("deleteProcessInstance error", e); - } - } - -// @Override -// @Transactional(rollbackFor = {Exception.class}) -// public List buildRent(MallUserInfo user,WxRentContract wxRentContract,Integer isPreview,boolean saveDb) { -// List rentList = new ArrayList<>(); -// if (wxRentContract != null) { -// int receivePeriod = wxRentContract.getReceivePeriod().intValue(); -// Integer lease = wxRentContract.getLease(); -// Date rentalStartDate = wxRentContract.getRentalStartDate(); -// String price = wxRentContract.getPrice(); -// rentList = buildRentMonth(user, wxRentContract, receivePeriod, lease, rentalStartDate, isPreview,saveDb); -// } -// return rentList; -// } - - @Override - public List getYearList(int years,int month,Date rentalStartDate,Date endContractTime ) { - List yearList = new ArrayList(); - for (int i = 0; i < years; i++) { - Calendar instance = Calendar.getInstance(); - instance.setTime(rentalStartDate); - instance.set(Calendar.MILLISECOND, 0); - instance.add(Calendar.MONTH, month * i); - Date startDate = instance.getTime(); - if (null != endContractTime && endContractTime.before(startDate)) { - yearList.add(endContractTime); - break; - }else { - yearList.add(startDate); - } - } - return yearList; - } - -// public List buildRentMonth(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate,Integer isPreview, boolean saveDb) { -// int years = 0; -// //计算租金每年的计费基数 -// String[] priceArrs = WxRentContractHelper.calcuteRentPrice(wxRentContract); -// //计算商业管理费 -// String[] bussinessManagerPriceArrs = WxRentContractHelper.calcuteBussinessManagementFee(wxRentContract); -// //计算运营管理费 -// String[] operationManagerPriceArrs = WxRentContractHelper.calcuteOperatingManagementFee(wxRentContract); -// int month = 12; -// int billcount = 0; -// List resultList = new ArrayList(); -// years = priceArrs.length; -// List yearList = getYearList(years,month,rentalStartDate,null); -// -// String shopInfoStr = getShopInfoStr(wxRentContract); -// Map resultMap = buildRent(receivePeriod, priceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs, yearList, wxRentContract.getReceivePeriodUnit(), wxRentContract, user, billcount, isPreview, shopInfoStr,saveDb); -// List billRentList = (List)resultMap.get("billList"); -// resultList.addAll(billRentList); -// return resultList; -// } - public String getShopInfoStr(WxRentContract wxRentContract){ String shopInfoStr = null; // if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { @@ -1042,412 +340,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { return shopInfoStr; } -// private static Date getCurrentYearRentDate(Date yearEndDate,Date rentDate){ -// Calendar calendar = Calendar.getInstance(); -// calendar.setTime(yearEndDate); -// -// Calendar rentCalendar = Calendar.getInstance(); -// rentCalendar.setTime(rentDate); -// -// calendar.set(Calendar.DAY_OF_MONTH,rentCalendar.get(Calendar.DAY_OF_MONTH)); -// calendar.set(Calendar.MONTH, rentCalendar.get(Calendar.MONTH)); -// return calendar.getTime(); -// } - - private List getFreeDays(WxRentContract wxRentContract) { - //免租期 - WxRentContractFreePeriod fpq = new WxRentContractFreePeriod(); - fpq.updateTenantInfo(wxRentContract); - fpq.setRentContractId(wxRentContract.getId()); - fpq.setSortColumn("start_date asc"); - List freePeriods = wxRentContractFreePeriodMapper.findList(fpq); - if (null == freePeriods || freePeriods.size() <= 0 ) { - return null; - } - List allDate = new ArrayList(); - for (int i = 0 ; i < freePeriods.size() ; i ++) { - WxRentContractFreePeriod fp = freePeriods.get(i); - List dates = DateUtils.getAllDays(fp.getStartDate(), fp.getEndDate()); - if (null != dates && dates.size() > 0 ) { - allDate.removeAll(dates); - allDate.addAll(dates); - } - } - if (allDate.size() <= 0 ) { - return null; - } - return allDate; - } - -// public Map buildRent(int receivePeriod, String[] priceArrs,String[] bussinessManagerPriceArrs,String[] operationManagerPriceArrs, List yearList, int dayType, WxRentContract wxRentContract, MallUserInfo user, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { -// WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); -// SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); -// Map resultMap = new HashedMap(); -// List resultList = new ArrayList(); -// List manageList = new ArrayList(); -// final IdWorker idWorker = IdWorker.get(); -// -// Date endDate = null;//每年的截止日期 -// if(yearList.size() > 1){ -// endDate = yearList.get(1); -// } -// -// List billTimeVoList = new ArrayList<>(); -// if(saveDb){ -// billTimeVoList = initBillTimeList(yearList,wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),null,dayType,receivePeriod,wxRentContract.getPayPeriodRate()); -// }else{ -// //预账单编辑账期,生成金额 -// for (WxAllBill rent:wxRentContract.getPreviewBillRentList()) { -// BillTimeVo billTimeVo = new BillTimeVo(); -// billTimeVo.setStartDate(rent.getStarttime()); -// billTimeVo.setEndDate(rent.getEndtime()); -// billTimeVo.setReceiveDate(DateUtils.getDaySet(rent.getStarttime(),Calendar.DATE,-1)); -// billTimeVoList.add(billTimeVo); -// } -// } -// -// if (null != billTimeVoList && billTimeVoList.size() > 0 ) { -// BillTimeVo firstBillTime = billTimeVoList.get(0); -// WxRentContract cupdate = new WxRentContract(); -// cupdate.updateTenantInfo(wxRentContract); -// cupdate.setId(wxRentContract.getId()); -// cupdate.setFirstBillDateStart(firstBillTime.getStartDate()); -// cupdate.setFirstBillDateEnd(firstBillTime.getEndDate()); -// cupdate.setFirstBillReceiveDate(firstBillTime.getReceiveDate()); -// cupdate.setDecimalSize(null);//去掉默认的,避免更新 -// wxRentContractMapper.updateById(cupdate); -// } -// -// List shopIdList = wxRentContract.shopIdsByRentInfo(); -// Map shopAreaRateMap = wxRentContract.getRentShopArea(); -// if (null == shopAreaRateMap) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无店铺信息"); -// } -// -// //免租期 -// List freePeriods = getFreeDays(wxRentContract); -// -// int index = 0; -// for (int i = 0; i < billTimeVoList.size(); i++) { -// BillTimeVo billTimeVo = billTimeVoList.get(i); -// //计算金额 -// String needpay = "0"; -// //商业管理费 -// String bussinessManageFeeNeedpay = "0"; -// //营业管理费 -// String operatingManageFeeNeedpay = "0"; -// -// boolean flag = false; -// //此处逻辑处理这一年和下一年交接那一期账单。 -// if(yearList.size() > 1) { -// if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { -// if(yearList.size() > 1) { -// if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { -// //logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); -// -// index++; -// //如果是计算账单金额&cross 拆分日期进行计算 -// if(billTimeVo.getEndDate().after(endDate)) { -// String needpayFront = "0"; -// String needpayAfter = "0"; -// -// //商业管理费 -// String bussinessManageFeeNeedpayFront = "0"; -// String bussinessManageFeeNeedpayAfter = "0"; -// -// //营业管理费 -// String operatingManageFeeNeedpayFront = "0"; -// String operatingManageFeeNeedpayAfter = "0"; -// -// //同一天,算一天 -// if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ -// needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod); -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { -// bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract,bussinessManagerPriceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod); -// } -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { -// operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract,operationManagerPriceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod); -// } -// }else{ -// //这一年到期和下一年开始的期间,从这一年到期时间分开来进行计算。因为涉及到年租金调整等 TODO 如何把这两块单独生成账单 -// if(billTimeVo.getStartDate().before(endDate)){ -// if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType()) && EnumMissTimeType.PERIOD.getCode().equals(0)) { -// //设置跳点率为年周期 price不变 -// needpayFront = priceArrs[index - 1]; -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { -// bussinessManageFeeNeedpayFront = bussinessManagerPriceArrs[index - 1]; -// } -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { -// operatingManageFeeNeedpayFront = operationManagerPriceArrs[index - 1]; -// } -// }else { -// needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.SECOND, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// needpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { -// bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.SECOND, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// bussinessManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// } -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { -// operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.SECOND, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// operatingManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// } -// } -// //下一年的第一天 -// }else if (billTimeVo.getStartDate().equals(endDate)) { -// needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { -// bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); -// } -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { -// operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); -// } -// }else{ -// //如果是按自然月,则这一年和下一年交叉部分需要重新计算 -// if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { -// Date currentYearRentDate = getCurrentYearRentDate(endDate,wxRentContract.getRentalStartDate()); -// needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// needpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { -// bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// bussinessManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// } -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { -// operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index - 1],endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// operatingManageFeeNeedpayAfter = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index],currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod); -// } -// }else { -// //按账单日 -// needpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0) { -// bussinessManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); -// } -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { -// operatingManageFeeNeedpayFront = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod); -// } -// } -// } -// } -// needpay = new BigDecimal(needpayFront).add(new BigDecimal(needpayAfter)).toPlainString(); -// bussinessManageFeeNeedpay = new BigDecimal(bussinessManageFeeNeedpayFront).add(new BigDecimal(bussinessManageFeeNeedpayAfter)).toPlainString(); -// operatingManageFeeNeedpay = new BigDecimal(operatingManageFeeNeedpayFront).add(new BigDecimal(operatingManageFeeNeedpayAfter)).toPlainString(); -// flag = true; -// } -// if(index >= yearList.size()-1){ -// endDate = null; -// }else{ -// endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 -// //logger.info("==========cross:"+sd.format(endDate)); -// } -// } -// } -// } -// } -// -// //计算金额 -// if(!flag){ -// needpay = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, priceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod); -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0 ) { -// bussinessManageFeeNeedpay = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, bussinessManagerPriceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod); -// } -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0) { -// operatingManageFeeNeedpay = WxRentContractHelper.getNeedPayMoney(freePeriods,wxRentContract, operationManagerPriceArrs[index],billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod); -// } -// } -// -// -// WxAllBill wxBillRent = new WxAllBill(); -// wxBillRent.setIsPreview(isPreview); -// wxBillRent.setId(idWorker.nextId()); -// wxBillRent.setRentContractId(wxRentContract.getId()); -// wxBillRent.setBillType(EnumBillAllType.RENT.getCode()); -// wxBillRent.setPay("0"); -// wxBillRent.setStarttime(billTimeVo.getStartDate()); -// wxBillRent.setEndtime(billTimeVo.getEndDate()); -// wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); -// wxBillRent.setPeriod(WxRentContractHelper.getPeriod(billTimeVo.getReceiveDate())); -// wxBillRent.setCanEdit(EnumYesOrNo.NO.getCode());; -// //wxBillRent.setContractNeedPay(needpay); -// //wxBillRent.setRentPriceInfo(getRentPriceInfo(wxRentContract,new BigDecimal(needpay))); -// wxBillRent.setNeedPay(needpay); -// //wxBillRent.setOwe(needpay); -// wxBillRent.setReceivePay(needpay); -// logger.debug(">>>>"+DateUtils.date2String(billTimeVo.getStartDate())+">>>>"+DateUtils.date2String(billTimeVo.getEndDate())+">>>>"+needpay); -// //商业管理费 -// wxBillRent.setBussinessManageFeeNeedPay(bussinessManageFeeNeedpay); -// //运营管理费 -// wxBillRent.setOperatingManageFeeNeedPay(operatingManageFeeNeedpay); -// //截止收租日在当前时间之前 -// Date date = new Date(); -// //setExpiredDay(wxBillRent,dayType,receivePeriod); -// //wxBillRent.setRevenue("0"); -// wxBillRent.updateTenantInfo(wxRentContract); -// //wxBillRent.setUserId(user.getId()); -// if (null != wxRentContract.shopIdsByRentInfo() && wxRentContract.shopIdsByRentInfo().size() == 1) { -// wxBillRent.setShopId(wxRentContract.shopIdsByRentInfo().get(0)); -// } -// wxBillRent.setShopNumber(wxRentContract.getRentInfoShopNumber()); -// wxBillRent.setRentArea(wxRentContract.getRentArea()); -// wxBillRent.setCreatetime(date); -// wxBillRent.setCreateBy(user.getId()); -// wxBillRent.setCreateByName(user.getName()); -// wxBillRent.setUpdatetime(date); -// wxBillRent.setUpdateBy(user.getId()); -// wxBillRent.setUpdateByName(user.getName());; -// //wxBillRent.setIsDel(EnumDelStatus.NOT_DEL.getCode()); -// //wxBillRent.setPeriod(++billcount); -// wxBillRent.setShopInfo(shopInfoStr); -// //wxBillRent.setLatePayRatio(0); -// wxBillRent.calcuteTotalFee(wxRentContract.getDecimalSize()); -// wxBillRent.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId()); -// -// //计算手续费 -// //BigDecimal servicePay = new BigDecimal(wxBillRent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())) -// // .divide(new BigDecimal(10000), wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); -// //wxBillRent.setServiceChargePay(servicePay.toPlainString()); -// //wxBillRent.setOwe(new BigDecimal(wxBillRent.getReceivePay()).add(new BigDecimal(wxBillRent.getServiceChargePay())).toPlainString()); -// //wxBillRent.setOwe(new BigDecimal(wxBillRent.getReceivePay()).toPlainString()); -// resultList.add(wxBillRent); -// -// -// //商业管理费账单 -// if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0 && new BigDecimal(bussinessManageFeeNeedpay).compareTo(new BigDecimal(0)) > 0) { -// manageList.add(setManageRent(wxRentContract.getDecimalSize(),wxBillRent,EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE,bussinessManageFeeNeedpay,wxPayAccountBill.getServiceChargeRate(),dayType,receivePeriod)); -// } -// //营业管理费账单 -// if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0 && new BigDecimal(operatingManageFeeNeedpay).compareTo(new BigDecimal(0)) > 0 ) { -// manageList.add(setManageRent(wxRentContract.getDecimalSize(),wxBillRent,EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE,operatingManageFeeNeedpay,wxPayAccountBill.getServiceChargeRate(),dayType,receivePeriod)); -// } -// } -// -// //批量插入账单 -// if(saveDb) { -// -// WxShopUsers suq = new WxShopUsers(); -// suq.updateTenantInfo(wxRentContract); -// suq.setShopIds(shopIdList); -// suq.setStatus(EnumShopUsersStatus.LIVE.getCode()); -// Map shopUserMap = wxShopService.getShopUserMap(suq); -// -// List rblist = new ArrayList(); -// for (int k = 0 ; k < resultList.size(); k++) { -// WxAllBill rb = resultList.get(k); -// 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(wxRentContract.getRentArea()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); -// try { -// BeanUtils.copyProperties(rs, rb); -// rs.setId(idWorker.nextId()); -// rs.setShopId(sid); -// rs.setNeedPay(new BigDecimal(rb.getNeedPay()).multiply(shoprate).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()); -// rs.setReceivePay(rs.getNeedPay()); -// rs.setShopId(sid); -// rs.setRentArea(shoprentArea.toPlainString()); -// if (StringUtils.isNotBlank(rb.getBussinessManageFeeNeedPay())) { -// rs.setBussinessManageFeeNeedPay(new BigDecimal(rb.getBussinessManageFeeNeedPay()).multiply(shoprate).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()); -// } -// if (StringUtils.isNotBlank(rb.getOperatingManageFeeNeedPay())) { -// rs.setOperatingManageFeeNeedPay(new BigDecimal(rb.getOperatingManageFeeNeedPay()).multiply(shoprate).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()); -// } -// if (null != shopUserMap ) { -// WxShopUsers wsu = shopUserMap.get(sid); -// if (null != wsu) { -// rs.setCusName(wsu.getName()); -// } -// } -// rblist.add(rs); -// } catch (IllegalAccessException e) { -// logger.error("savePreviewBill error.",e); -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); -// } catch (InvocationTargetException e) { -// logger.error("savePreviewBill error.",e); -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); -// } -// } -// } -// wxAllBillMapper.insertBills(wxRentContract.getTenantId(),rblist); -// if (manageList.size() > 0 ) { -// List mblist = new ArrayList(); -// for (int k = 0 ; k < manageList.size(); k++) { -// WxAllBill rb = manageList.get(k); -// 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(wxRentContract.getRentArea()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); -// try { -// BeanUtils.copyProperties(rs, rb); -// rs.setId(idWorker.nextId()); -// rs.setShopId(sid); -// rs.setNeedPay(new BigDecimal(rb.getNeedPay()).multiply(shoprate).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).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()); -// } -// } -// mblist.add(rs); -// } catch (IllegalAccessException e) { -// logger.error("savePreviewBill error.",e); -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); -// } catch (InvocationTargetException e) { -// logger.error("savePreviewBill error.",e); -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"创建账单失败"); -// } -// } -// } -// -// wxAllBillMapper.insertBills(wxRentContract.getTenantId(),mblist); -// } -// } -// resultMap.put("billcount",billcount); -// resultMap.put("billList",resultList); -// return resultMap; -// } - -// private WxAllBill setManageRent(Integer decimalSize,WxAllBill wxBillRent,EnumRentContractManageFeeType feeType,String needPay,Integer serviceChargeRate,int dayType,int receivePeriod) { -// WxAllBill manage = new WxAllBill(); -// manage.setRentContractId(wxBillRent.getRentContractId()); -// manage.setPay(wxBillRent.getPay()); -// manage.setStarttime(wxBillRent.getStarttime()); -// manage.setEndtime(wxBillRent.getEndtime()); -// manage.setReceiveDate(wxBillRent.getReceiveDate()); -// manage.setPeriod(wxBillRent.getPeriod()); -// manage.updateTenantInfo(wxBillRent); -// manage.setIsPreview(wxBillRent.getIsPreview()); -// manage.setCreatetime(wxBillRent.getCreatetime()); -// manage.setCreateBy(wxBillRent.getCreateBy()); -// manage.setCreateByName(wxBillRent.getCreateByName()); -// manage.setUpdateBy(wxBillRent.getUpdateBy()); -// manage.setUpdatetime(wxBillRent.getUpdatetime()); -// manage.setUpdateByName(wxBillRent.getUpdateByName()); -// manage.setRentArea(wxBillRent.getRentArea()); -// manage.setShopNumber(wxBillRent.getShopNumber()); -// manage.setCanEdit(EnumYesOrNo.NO.getCode()); -// manage.setCusName(wxBillRent.getCusName()); -// if (feeType.getCode().intValue() == EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode().intValue()){ -// manage.setEnergyFeesId(EnumBillAllType.RENT_BUSSINESS_MANAGE.getEnergyFeesId()); -// manage.setBillType(EnumBillAllType.RENT_BUSSINESS_MANAGE.getCode()); -// }else if (feeType.getCode().intValue() == EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode().intValue()) { -// manage.setEnergyFeesId(EnumBillAllType.RENT_OPERATION_MANAGE.getEnergyFeesId()); -// manage.setBillType(EnumBillAllType.RENT_OPERATION_MANAGE.getCode()); -// } -// final IdWorker idWorker = IdWorker.get(); -// wxBillRent.setId(idWorker.nextId()); -// manage.setNeedPay(needPay); -// manage.setReceivePay(needPay); -// //计算手续费 -// //BigDecimal servicePay = new BigDecimal(needPay).multiply(new BigDecimal(serviceChargeRate)).divide(new BigDecimal(10000), decimalSize, BigDecimal.ROUND_HALF_UP); -// //manage.setServiceChargePay(servicePay.toPlainString()); -// //manage.setOwe(new BigDecimal(needPay).add(new BigDecimal(manage.getServiceChargePay())).toPlainString()); -// //manage.setOwe(new BigDecimal(needPay).toPlainString()); -// return manage; -// } - @Transactional(rollbackFor = {Exception.class}) @Override public ResultData deleteById(String id) { @@ -1524,124 +416,86 @@ public class WxRentContractServiceImpl implements WxRentContractService { return new ResultData(Result.SUCCESS, "操作成功"); } -// @Override -// public PageInfo getRentContractList(WxRentContract rentContract, Integer pageIndex, Integer pageSize) { -// if (StringUtils.isNotBlank(rentContract.getFloorForRule()) || StringUtils.isNotBlank(rentContract.getQueryShopIdStr())) { -// List shopIdList = null; -// if (StringUtils.isNotBlank(rentContract.getQueryShopIdStr())) { -// String[] qsids = rentContract.getQueryShopIdStr().split(","); -// if (null != qsids && qsids.length > 0 ) { -// shopIdList = new ArrayList(); -// for (int i = 0 ; i < qsids.length ; i ++) { -// String qsid = qsids[i]; -// if (StringUtils.isNotBlank(qsid)) { -// shopIdList.add(Long.parseLong(qsid)); -// } -// } -// if (shopIdList.size() <= 0 ) { -// shopIdList = null; -// } -// } -// } -// -// List contractIds = wxAgileContractService.findBuildingFloorContractIds(rentContract, rentContract.getFloorForRule(), null, null, shopIdList, 0); -// //List mids = wxMerchantService.getFloorBuildMerchantIds(rentContract, rentContract.getFloorForRule() , null, null,rentContract.getShopTypeForRule(), 0, 0,null); -// if (null == contractIds || contractIds.size() <= 0 ) { -// rentContract.setId(-1L); -// } else { -// rentContract.setIds(contractIds); -// } -// } -// //根据客户名称查询 -// if (StringUtils.isNotBlank(rentContract.getMerchantName())) { -// WxContractCustomers ccq = new WxContractCustomers(); -// ccq.updateTenantInfo(rentContract); -// ccq.setName(rentContract.getMerchantName()); -// List customersIdList = wxContractCustomersMapper.findIdList(ccq); -// if (null != customersIdList && customersIdList.size() > 0 ) { -// rentContract.setCustomersIdList(customersIdList); -// }else { -// rentContract.setId(-1L); -// } -// } -// -// //PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.getRentContractList(rentContract)); -// PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.findList(rentContract)); -// if (null != pageInfo && null != pageInfo.getList()) { -// List customersIdList = new ArrayList(); -// for (int i = 0 ; i < pageInfo.getList().size(); i ++ ){ -// WxRentContract contract = pageInfo.getList().get(i); -// if (null != contract.getCustomersId()) { -// customersIdList.add(contract.getCustomersId()); -// } -// } -// -// Map customersMap = getContractCustomersMap(rentContract,customersIdList); -// -// for (int i = 0 ; i < pageInfo.getList().size(); i ++ ) { -// WxRentContract contract = pageInfo.getList().get(i); -// String merchantName = ""; -// if (null != customersMap && null != contract.getCustomersId()) { -// WxContractCustomers cc = customersMap.get(contract.getCustomersId()); -// if (null != cc) { -// merchantName = merchantName + cc.getName(); -// } -// } -// contract.setMerchantName(merchantName); -// } -// -// } -// return pageInfo; -// } -// -// private Map getContractCustomersMap(TenantEntity tenantEntity,List customerIds) { -// if (null == customerIds || customerIds.size() <= 0 ) { -// return null; -// } -// WxContractCustomers ccq = new WxContractCustomers(); -// ccq.updateTenantInfo(tenantEntity); -// ccq.setIds(customerIds); -// List cclist = wxContractCustomersMapper.findList(ccq); -// if (null != cclist && cclist.size() > 0 ){ -// Map map = new HashMap(); -// for (int i = 0 ; i < cclist.size() ; i ++ ) { -// WxContractCustomers cc = cclist.get(i); -// if (null != cc) { -// map.put(cc.getId(),cc); -// } -// } -// return map; -// } -// return null; -// } - -// @Override -// @Transactional(rollbackFor = {Exception.class}) -// public ResultData updateFile(WxRentContract record, MallUserInfo user,String userName,boolean writeComplate) { -// -// WxRentContract wxRentContract = wxRentContractMapper.selectById(record.getId()); -// if (null == wxRentContract) { -// return new ResultData(Result.ERROR,"id查询不到合同"); -// } -// WxRentContract rc = new WxRentContract(); -// rc.setId(record.getId()); -// rc.setDecimalSize(wxRentContract.getDecimalSize()); -// if (writeComplate) { -// rc.setStatus(EnumRentContractStatus.DRAFT.getCode()); -// }else { -// rc.setStatus(wxRentContract.getStatus()); -// } -// rc.setFileNames(record.getFileNames()); -// rc.setRemark(record.getRemark()); -// wxRentContractMapper.updateById(rc); -// if (null != wxRentContract.getOperationType() && EnumContractOperationType.WHOLE.getCode().equals(wxRentContract.getOperationType())) { -// WxPropertyContract pc = wxPropertyContractMapper.findOneByRentId(wxRentContract); -// if (null != pc) { -// wxRentContract.setPropertyContractId(pc.getId()); -// } -// } -// return new ResultData(wxRentContract); -// } + @Override + public PageInfo getRenevueContractList(WxRentContract rentContract, Integer pageIndex, Integer pageSize) { + if (StringUtils.isNotBlank(rentContract.getFloorForRule()) || StringUtils.isNotBlank(rentContract.getShopNumber())) { + List shopIdList = null; + if (StringUtils.isNotBlank(rentContract.getShopNumber())) { + WxShop sq = new WxShop(); + sq.updateTenantInfo(rentContract); + sq.setShopNumber(rentContract.getShopNumber()); + sq.setIsDel(EnumYesOrNo.NO.getCode()); + shopIdList = wxShopMapper.findIdList(sq); + } + + List contractIds = wxAgileContractService.findBuildingFloorContractIds(rentContract, rentContract.getFloorForRule(), null, null, shopIdList, 0); + if (null == contractIds || contractIds.size() <= 0 ) { + rentContract.setId(-1L); + } else { + rentContract.setIds(contractIds); + } + } + //根据客户名称查询 + if (StringUtils.isNotBlank(rentContract.getMerchantName())) { + WxContractCustomers ccq = new WxContractCustomers(); + ccq.updateTenantInfo(rentContract); + ccq.setName(rentContract.getMerchantName()); + List customersIdList = wxContractCustomersMapper.findIdList(ccq); + if (null != customersIdList && customersIdList.size() > 0 ) { + rentContract.setCustomersIdList(customersIdList); + }else { + rentContract.setId(-1L); + } + } + + PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.findList(rentContract)); + if (null != pageInfo && null != pageInfo.getList()) { + List customersIdList = new ArrayList(); + for (int i = 0 ; i < pageInfo.getList().size(); i ++ ){ + WxRentContract contract = pageInfo.getList().get(i); + if (null != contract.getCustomersId()) { + customersIdList.add(contract.getCustomersId()); + } + } + + Map customersMap = getContractCustomersMap(rentContract,customersIdList); + + for (int i = 0 ; i < pageInfo.getList().size(); i ++ ) { + WxRentContract contract = pageInfo.getList().get(i); + String merchantName = ""; + if (null != customersMap && null != contract.getCustomersId()) { + WxContractCustomers cc = customersMap.get(contract.getCustomersId()); + if (null != cc) { + merchantName = merchantName + cc.getName(); + } + } + contract.setMerchantName(merchantName); + } + + } + return pageInfo; + } + + private Map getContractCustomersMap(TenantEntity tenantEntity,List customerIds) { + if (null == customerIds || customerIds.size() <= 0 ) { + return null; + } + WxContractCustomers ccq = new WxContractCustomers(); + ccq.updateTenantInfo(tenantEntity); + ccq.setIds(customerIds); + List cclist = wxContractCustomersMapper.findList(ccq); + if (null != cclist && cclist.size() > 0 ){ + Map map = new HashMap(); + for (int i = 0 ; i < cclist.size() ; i ++ ) { + WxContractCustomers cc = cclist.get(i); + if (null != cc) { + map.put(cc.getId(),cc); + } + } + return map; + } + return null; + } @Override @Transactional(rollbackFor = {Exception.class}) @@ -1763,113 +617,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxRentContractMapper.updateApplyStatus(wxRentContract); } -// @Override -// public Integer getShopType(WxRentContract wxRentContract) { -// return wxRentContractMapper.getShopType(wxRentContract); -// } - - //yearList,每年的合同截止日期,到这个截止日之前之后,需要拆开时间 -// public static List initBillTimeList(List yearList,Date start,Date end,Integer adjustPeriod,Integer dayType,int receivePeriod,int payPeriod){ -// if (null == adjustPeriod) { -// adjustPeriod = EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode(); -// } -// List list = new ArrayList<>(); -// int count = 0; -// List yearsEndList = new ArrayList(); -// yearsEndList.addAll(yearList); -// if (yearsEndList.size() > 0) { -// yearsEndList.remove(0); -// } -// BillTimeVo receiveDate = null; -// while (true) { -// BillTimeVo timeVo = new BillTimeVo(); -// -// //账单日 -// Calendar instance = Calendar.getInstance(); -// instance.setTime(start); -// instance.set(Calendar.MILLISECOND, 0); -// //开始时间 -// timeVo.setStartDate(instance.getTime()); -// -// //结束时间 -// instance.clear(); -// instance.setTime(start); -// instance.set(Calendar.MILLISECOND, 0); -// instance = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod, dayType); -// //instance.add(dayType, receivePeriod); -// //instance.add(Calendar.DATE, -1); -// timeVo.setEndDate(instance.getTime()); -// -// //自然月,应该是从本月开始到本月结束 -// if(adjustPeriod.equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ -// timeVo.setEndDate(EnumContractReceivePeriodUnit.getAfterCalendarNarDay(timeVo.getStartDate(), receivePeriod, dayType)); -// } -// -// //如果是到了每年的截止时间,第一年忽略(是开始时间) -// boolean isYearCut = false;//是不是有截断 -// if (null != yearsEndList && yearsEndList.size() > 0 ) { -// Date yearEndDateStart = yearsEndList.get(0); -// //如果开始时间到了年的截止 -// if (timeVo.getStartDate().equals(yearEndDateStart)) { -// yearsEndList.remove(yearEndDateStart); -// }else if (timeVo.getStartDate().after(yearEndDateStart)) { -// //do nothing -// }else if (timeVo.getStartDate().before(yearEndDateStart)) { -// Date yearEndDateEnd = DateUtils.getDayEnd(yearEndDateStart); -// if (timeVo.getEndDate().after(yearEndDateEnd)) { -// timeVo.setEndDate(DateUtils.getDaySet(yearEndDateEnd,Calendar.DATE,-1)); -// yearsEndList.remove(yearEndDateStart); -// isYearCut = true; -// }else if(timeVo.getEndDate().equals(yearEndDateEnd)) { -// yearsEndList.remove(yearEndDateStart); -// } -// } -// } -// -// if(timeVo.getEndDate().after(end)){ -// Calendar endinstance = Calendar.getInstance(); -// endinstance.setTime(end); -// endinstance.set(Calendar.MILLISECOND, 0); -// timeVo.setEndDate(endinstance.getTime()); -// } -// -// list.add(timeVo); -// -// receiveDate = WxRentContractHelper.getReceiveDate(receiveDate,timeVo.getStartDate(), timeVo.getEndDate(), payPeriod,adjustPeriod,receivePeriod,dayType); -// timeVo.setReceiveDate(receiveDate.getStartDate()); -// -// -// //next -// start = DateUtils.getDaySet(timeVo.getEndDate(),Calendar.SECOND,1); -// -// if(start.after(end)) { -// break; -// } -// count ++; -// -// //预警 -// if(count >= 1000){ -// Logger logger = LoggerFactory.getLogger(WxRentContractServiceImpl.class); -// logger.error("initBillTimeList() warnCount max error !!!"); -// break; -// } -// } -// return list; -// } - - @Override public WxRentContract getByBill(WxAllBill billRent) { return wxRentContractMapper.getByBill(billRent); } - -// @Override -// public ResultData getContractByContractNumber(WxRentContract rentContract) { -// WxRentContract wxRentContract = wxRentContractMapper.selectOne(new QueryWrapper<>(rentContract)); -// return new ResultData(wxRentContract); -// } - @Override public ResultData apply(WxRentContract rentContract,MallUserInfo user) { //如果存在审批中的合同,不允许提交审批 @@ -1915,69 +667,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } - @Override - @Transactional(rollbackFor = {Exception.class}) - public void renewal(WxRentContract rentContract,MallUserInfo user) { - final IdWorker idWorker = IdWorker.get(); - Long newContractId = idWorker.nextId(); - //拷贝 - WxContractShop csq = new WxContractShop(); - csq.updateTenantInfo(rentContract); - csq.setContractId(rentContract.getId()); - List csqlist = wxContractShopMapper.findList(csq); - if (null != csqlist && csqlist.size() > 0 ){ - for ( int i = 0 ; i< csqlist.size() ; i ++) { - WxContractShop cs = csqlist.get(i); - cs.setId(idWorker.nextId()); - cs.setContractId(newContractId); - cs.setCreateDate(new Date()); - cs.setUpdateDate(new Date()); - wxContractShopMapper.insert(cs); - } - } - - //WxContractCustomers ccq = new WxContractCustomers(); - - WxRentContractRevenueJump crjq = new WxRentContractRevenueJump(); - crjq.updateTenantInfo(rentContract); - crjq.setRentContractId(rentContract.getId()); - List jumpList = wxRentContractRevenueJumpMapper.findList(crjq); - if ( null != jumpList && jumpList.size() > 0 ) { - for (int i = 0 ; i < jumpList.size(); i++) { - WxRentContractRevenueJump rj = jumpList.get(i); - rj.setRentContractId(newContractId); - rj.setId(idWorker.nextId()); - rj.setCreateTime(new Date()); - rj.setUpdateTime(new Date()); - wxRentContractRevenueJumpMapper.insert(rj); - } - } - - //WxRentContractFreePeriod cfpq = new WxRentContractFreePeriod(); - - Long oldId = rentContract.getId(); - rentContract.setId(newContractId); - rentContract.setCreatetime(new Date()); - rentContract.setCreateBy(user.getId()); - rentContract.setCreateByName(user.getName()); - rentContract.setUpdatetime(new Date()); - rentContract.setUpdateBy(user.getId()); - rentContract.setUpdateByName(user.getName()); - rentContract.setStatus(EnumRentContractStatus.UNWRITE.getCode()); - rentContract.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); - rentContract.setEndContractTime(null); - //rentContract.setFirstBillDateStart(null); - //rentContract.setFirstBillDateEnd(null); - //rentContract.setFirstBillReceiveDate(null); - int[] array = DateUtils.getDiff(rentContract.getRentalStartDate(),rentContract.getRentalEndDate()); - rentContract.setLease(array[0]); - //rentContract.setAdjustRatio(); - //rentContract.setRevenueRatioSet(); - //rentContract.set - wxRentContractMapper.insert(rentContract); - - } - @Override public void outDateContract(WxMall wxMall) { try { @@ -2043,18 +732,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { return wxRentContractMapper.findToEndContractList(record); } -// @Override -// public List findToOutDateContracts(TenantEntity tenantEntity) { -// WxRentContract wrc = new WxRentContract(); -// wrc.setStatus(EnumRentContractStatus.PAING.getCode()); -// wrc.setOutDateNofity(1); -// return wxRentContractMapper.findList(wrc); -// } - - @Override - public void calcuteByTradeDaily(WxRentContract wxRentContract) { - } - private BigDecimal sumTradeDailyBySameMonthDay(Integer decimalSize,TenantEntity tenantEntity,Long merchantId,Date begin ,Date end) { //如果有按月的,则取按月来算 WxMerchantTradeDaily tdq = new WxMerchantTradeDaily(); @@ -2096,166 +773,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { public void deletePrewBill(WxRentContract record) { //删除预账单,重新生成 wxAllBillMapper.deleteBillByContract(record); - //删除商业管理费账单 - //WxAllBill wxBillRentManage = new WxAllBill(); - //wxBillRentManage.setRentContractId(record.getId()); - //wxBillRentManage.setManageFeeType(EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode()); - //wxBillRentManage.updateTenantInfo(record); - //wxAllBillMapper.deletePreviewBill(wxBillRentManage); - //删除营业管理费账单 - //wxBillRentManage.setManageFeeType(EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode()); - //wxBillRentManageMapper.deletePreviewBill(wxBillRentManage); - } - - @Override - public List getFreePeriods(WxRentContract wxRentContract) { - int[] array = DateUtils.getDiff(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate()); - int months = array[0]; - int years = 0; - if ( months % 12 == 0) { - years = months / 12; - }else { - years = months / 12 + 1; - } - if (years == 0) { - years = 1; - } - Date start = wxRentContract.getRentalStartDate(); - List volist = new ArrayList(); - for (int i = 0 ; i < years; i ++) { - RentContractFreePeriodVo vo = new RentContractFreePeriodVo(); - vo.setYearIndex(i+1); - vo.setStart(start); - if (i == years-1) { - vo.setEnd(wxRentContract.getRentalEndDate()); - }else { - start = DateUtils.getTimeAfterDays(365*(i+1)+1,wxRentContract.getRentalStartDate()); - vo.setEnd(start); - } - WxRentContractFreePeriod fpq = new WxRentContractFreePeriod(); - fpq.updateTenantInfo(wxRentContract); - fpq.setRentContractId(wxRentContract.getId()); - fpq.setYearIndex(i+1); - fpq.setSortColumn("start_date asc"); - vo.setPeriods(wxRentContractFreePeriodMapper.findList(fpq)); - volist.add(vo); - } - return volist; } -// @Override -// public void saveFreePeriods(WxRentContract wxRentContract) { -// WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); -// List yearsVo = getRentContractYears(rentContract); -// if (null == yearsVo) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无缴费年限"); -// } -// Map yearsMap = new HashMap(); -// for (int i = 0 ; i < yearsVo.size() ; i++) { -// WxRentContractYearsVo vo = yearsVo.get(i); -// yearsMap.put(vo.getYearIndex(), vo); -// } -// -// WxRentContractFreePeriod del = new WxRentContractFreePeriod(); -// del.updateTenantInfo(wxRentContract); -// del.setRentContractId(wxRentContract.getId()); -// wxRentContractFreePeriodMapper.deleteByContract(del); -// List volist = wxRentContract.getFreePeriods(); -// if (null != volist && volist.size() > 0 ) { -// List fpList = new ArrayList(); -// for (int i = 0 ; i < volist.size() ; i ++) { -// RentContractFreePeriodVo vo = volist.get(i); -// if (null != vo.getPeriods()) { -// for (int j = 0 ; j < vo.getPeriods().size(); j++ ){ -// WxRentContractFreePeriod fp = vo.getPeriods().get(j); -// WxRentContractYearsVo yearVo = yearsMap.get(vo.getYearIndex()); -// if ((fp.getStartDate().after(yearVo.getStart()) || fp.getStartDate().equals(yearVo.getStart()) ) && -// (fp.getEndDate().before(yearVo.getEnd()) || fp.getEndDate().equals(yearVo.getEnd()))) { -// final IdWorker idWorker = IdWorker.get(); -// fp.setId(idWorker.nextId()); -// fp.updateTenantInfo(wxRentContract); -// fp.setYearIndex(vo.getYearIndex()); -// fp.setCreateTime(new Date()); -// fp.setUpdateTime(new Date()); -// fp.setRentContractId(rentContract.getId()); -// fpList.add(fp); -// }else { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"第"+vo.getYearIndex()+"年度有时间选择有误,不能超过该年度时间范围"); -// } -// } -// } -// } -// wxRentContractFreePeriodMapper.inertPeriods(wxRentContract.getTenantId(), fpList); -// } -// } - -// @Override -// public List getRentContractYears(WxRentContract rentContract) { -// //String adjustRatio = rentContract.getAdjustRatio(); -// //List integers = JSONArray.parseArray(adjustRatio, String.class); -// //integers.add(0, "0"); -// //int years = integers.size(); -// SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); -// int [] diffs = DateUtils.getDiff(rentContract.getRentalStartDate(),rentContract.getRentalEndDate()); -// int months = diffs[0]; -// int days = diffs[1]; -// int ext = months % 12; -// int years = months/12; -// if (ext > 0 ) { -// years = years + 1; -// }else { -// if (days > 0 ) { -// years = years + 1; -// } -// } -// //合同以什么日期来计算开始计租日期 -// if(rentContract.getRentStartType()!=null &&rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ -// rentContract.setRentalStartDate(rentContract.getStartDate()); -// } -// //如果有撤铺日 -// Date endcontract = rentContract.getEndContractTime(); -// if (null != endcontract) { -// endcontract = DateUtils.getDayEnd(endcontract); -// } -// List yearList = this.getYearList(years, 12, rentContract.getRentalStartDate(),endcontract); -// List retList = new ArrayList(); -// if (null != yearList && yearList.size() > 0) { -// if (yearList.size() == 1) { -// WxRentContractYearsVo vo = new WxRentContractYearsVo(); -// vo.setStart(yearList.get(0)); -// vo.setEnd(rentContract.getRentalEndDate()); -// vo.setRemark("第1年度"); -// vo.setYearIndex(1); -// retList.add(vo); -// }else { -// Date begin = null; -// for (int i = 0 ; i < yearList.size()-1 ; i ++) { -// int yearindex = i+1; -// begin = yearList.get(i); -// Date end = yearList.get(i+1); -// Date realEnd = DateUtils.getDaySet(end, Calendar.SECOND, -1); -// WxRentContractYearsVo vo = new WxRentContractYearsVo(); -// vo.setStart(begin); -// vo.setEnd(realEnd); -// vo.setRemark("第"+yearindex+"年度"); -// vo.setYearIndex(yearindex); -// retList.add(vo); -// begin = end; -// } -// WxRentContractYearsVo vo = new WxRentContractYearsVo(); -// vo.setStart(yearList.get(yearList.size()-1)); -// vo.setEnd(rentContract.getRentalEndDate()); -// vo.setRemark("第"+yearList.size()+"年度"); -// vo.setYearIndex(yearList.size()); -// retList.add(vo); -// } -// } -// if (retList.size() > 0 ) { -// return retList; -// } -// return null; -// } - @Override public List getContractSales(WxRentContract wxRentContract) { WxRentContractRevenueSales sales = new WxRentContractRevenueSales(); @@ -2272,200 +791,71 @@ public class WxRentContractServiceImpl implements WxRentContractService { return wxRentContractRevenueSalesMapper.findList(sales); } - private BigDecimal calcuteUnitPrice(Date startDate,Date endDate,BigDecimal salesDeciaml,Integer priceUnit, - Integer dayPriceCalcute,Integer mothAverageDays,Integer adjustPeriod,Integer receivePeriodUnit) { - BigDecimal unitPrice = new BigDecimal(0); - - if (null == adjustPeriod) { - adjustPeriod = EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode(); - } - - Date realEndStart = DateUtils.getDaySet(endDate, Calendar.SECOND, 1); - int[] diffs = DateUtils.getDiff(startDate, realEndStart); - if (priceUnit.equals(EnumPriceUnit.D.getCode())){ - int allDays = 0; - if (dayPriceCalcute.intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { - allDays = diffs[0]*mothAverageDays + diffs[1]; - }else { - allDays = DateUtils.daysBetween(startDate, endDate)+1; - } - //每一天的单价 - unitPrice = salesDeciaml.divide(new BigDecimal(allDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - }else if(EnumPriceUnit.Y.getCode().equals(priceUnit)) { - //按照当前金额,当前时间区间,计算每一年的单价 - //当前时间有多少个月 - int months = diffs[0]; - int lastdays = diffs[1]; - if (lastdays > 0) { - //计算当前区间算多少年 - if (dayPriceCalcute.intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { - Date lastmonthStartDate = DateUtils.getTimeAfterMonths(diffs[0], startDate); - int days = DateUtils.daysBetween(lastmonthStartDate, endDate)+1; - BigDecimal _months = new BigDecimal(days).divide(new BigDecimal(mothAverageDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).add(new BigDecimal(months)); - unitPrice = salesDeciaml.multiply(new BigDecimal(12)).divide(_months,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - }else { - BigDecimal _months = getMonthsByRealDays(months,startDate,endDate,adjustPeriod,receivePeriodUnit); - unitPrice = salesDeciaml.multiply(new BigDecimal(12)).divide(_months,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - } - }else { - unitPrice = salesDeciaml.multiply(new BigDecimal(12)).divide(new BigDecimal(months),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - } - }else if(EnumPriceUnit.M.getCode().equals(priceUnit)) { - //每一月的单价 - BigDecimal months = new BigDecimal(diffs[0]); - int lastdays = diffs[1]; - if (lastdays > 0) { - if (dayPriceCalcute.intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { - Date lastmonthStartDate = DateUtils.getTimeAfterMonths(diffs[0], startDate); - int days = DateUtils.daysBetween(lastmonthStartDate, endDate)+1; - months = months.add(new BigDecimal(days).divide(new BigDecimal(mothAverageDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - }else { - months = getMonthsByRealDays(diffs[0],startDate,endDate,adjustPeriod,receivePeriodUnit); - } - } - unitPrice = salesDeciaml.divide(months,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - } - return unitPrice; - } - - private BigDecimal getMonthsByRealDays(int months,Date startDate,Date endDate,Integer adjustPeriod,Integer receivePeriodUnit) { - BigDecimal _months = new BigDecimal(0); - //如果是自然月或者自然季度,则是到月底 - if (adjustPeriod == EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode() || - receivePeriodUnit == EnumContractReceivePeriodUnit.QUARTER.getCode()) { - //需要查询到真实的自然月份有多少 - Date startFirstDay = DateUtils.getFirstDayForCurrMonth(startDate); - Date endLastStartDay = DateUtils.getLastDayForMonth(endDate); - int[] rdiffs = DateUtils.getDiff(startFirstDay, endLastStartDay); - int rmonths = rdiffs[0]; - if (rmonths > 0 ) { - //第一个个月是start到月底,最后一个是1号到end - Date startLastDay = DateUtils.getLastDayForMonth(startDate); - int firstdays = DateUtils.daysBetween(startDate, startLastDay)+1; - int firstmonthdays = DateUtils.daysBetween(startFirstDay, startLastDay)+1; - _months = _months.add(new BigDecimal(firstdays).divide(new BigDecimal(firstmonthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - if (rmonths == 1) { - Date endFirstDay = DateUtils.getDaySet(startLastDay, Calendar.SECOND, 1); - int enddays = DateUtils.daysBetween(endFirstDay, endDate)+1; - Date endlastday = DateUtils.getLastDayForMonth(endDate); - int endmonthdays = DateUtils.daysBetween(endFirstDay, endlastday)+1; - _months = _months.add(new BigDecimal(enddays).divide(new BigDecimal(endmonthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - }else { - _months = _months.add(new BigDecimal(rmonths-1)); - Date endFirstDay = DateUtils.getDaySet(DateUtils.getDaySet(startLastDay, Calendar.MONTH, rmonths-1), Calendar.SECOND, 1); - int enddays = DateUtils.daysBetween(endFirstDay, endDate)+1; - Date endlastday = DateUtils.getLastDayForMonth(endDate); - int endmonthdays = DateUtils.daysBetween(endFirstDay, endlastday)+1; - _months = _months.add(new BigDecimal(enddays).divide(new BigDecimal(endmonthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - } - }else { - //相当于在同一个月份 - int days = DateUtils.daysBetween(startDate, endDate)+1; - Date startLastDay = DateUtils.getLastDayForMonth(startDate); - int monthdays = DateUtils.daysBetween(startDate, startLastDay)+1; - _months = _months.add(new BigDecimal(days).divide(new BigDecimal(monthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - } - }else { - _months = _months.add(new BigDecimal(months)); - Date prelastMonthStartDate = DateUtils.getDaySet(startDate, Calendar.MONTH, months); - Date extraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(prelastMonthStartDate); - Date extraStartDayMonthEnd = DateUtils.getLastDayForMonth(prelastMonthStartDate); - int premonthDays = DateUtils.daysBetween(extraStartDayMonthStart, extraStartDayMonthEnd)+1; - int prelastdays = 0; - if (extraStartDayMonthEnd.after(endDate) || extraStartDayMonthEnd.equals(endDate)) { - prelastdays = DateUtils.daysBetween(prelastMonthStartDate, endDate)+1; - _months = _months.add(new BigDecimal(prelastdays).divide(new BigDecimal(premonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - }else { - prelastdays = DateUtils.daysBetween(prelastMonthStartDate, extraStartDayMonthEnd)+1; - _months = _months.add(new BigDecimal(prelastdays).divide(new BigDecimal(premonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - //跨月 - Date lastMonthStart = DateUtils.getDaySet(extraStartDayMonthEnd, Calendar.SECOND, 1); - int lastdays = DateUtils.daysBetween(lastMonthStart, endDate)+1; - Date lastextraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(lastMonthStart); - Date lastextraStartDayMonthEnd = DateUtils.getLastDayForMonth(lastMonthStart); - int lastmonthDays = DateUtils.daysBetween(lastextraStartDayMonthStart, lastextraStartDayMonthEnd)+1; - _months = _months.add(new BigDecimal(lastdays).divide(new BigDecimal(lastmonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); - } - } - return _months; - } - -// //根据租金合同来计算附加物业费 -// private BigDecimal calcuteRentPropertyPrice(WxRentContract rentcontract,Date startDate,Date endDate,BigDecimal money) { -// //计算物业费的单价 -// BigDecimal unitPropertyPrice = calcuteUnitPrice(startDate, endDate,money, -// propertyContract.getPriceUnit(),propertyContract.getDayPriceCalcute(),propertyContract.getMonthAverageDays(),propertyContract.getAdjustPeriod(),propertyContract.getReceivePeriodUnit()); -// //如果租金是按天计算 -// if (rentcontract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ -// //物业也是按天 -// if (propertyContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) { -// return unitPropertyPrice; -// }else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) { -// if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { -// return unitPropertyPrice.divide(new BigDecimal(12*propertyContract.getMonthAverageDays()), -// Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); +// private BigDecimal getMonthsByRealDays(int months,Date startDate,Date endDate,Integer adjustPeriod,Integer receivePeriodUnit) { +// BigDecimal _months = new BigDecimal(0); +// //如果是自然月或者自然季度,则是到月底 +// if (adjustPeriod == EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode() || +// receivePeriodUnit == EnumContractReceivePeriodUnit.QUARTER.getCode()) { +// //需要查询到真实的自然月份有多少 +// Date startFirstDay = DateUtils.getFirstDayForCurrMonth(startDate); +// Date endLastStartDay = DateUtils.getLastDayForMonth(endDate); +// int[] rdiffs = DateUtils.getDiff(startFirstDay, endLastStartDay); +// int rmonths = rdiffs[0]; +// if (rmonths > 0 ) { +// //第一个个月是start到月底,最后一个是1号到end +// Date startLastDay = DateUtils.getLastDayForMonth(startDate); +// int firstdays = DateUtils.daysBetween(startDate, startLastDay)+1; +// int firstmonthdays = DateUtils.daysBetween(startFirstDay, startLastDay)+1; +// _months = _months.add(new BigDecimal(firstdays).divide(new BigDecimal(firstmonthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); +// if (rmonths == 1) { +// Date endFirstDay = DateUtils.getDaySet(startLastDay, Calendar.SECOND, 1); +// int enddays = DateUtils.daysBetween(endFirstDay, endDate)+1; +// Date endlastday = DateUtils.getLastDayForMonth(endDate); +// int endmonthdays = DateUtils.daysBetween(endFirstDay, endlastday)+1; +// _months = _months.add(new BigDecimal(enddays).divide(new BigDecimal(endmonthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); // }else { -// return unitPropertyPrice.divide(new BigDecimal(365),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); +// _months = _months.add(new BigDecimal(rmonths-1)); +// Date endFirstDay = DateUtils.getDaySet(DateUtils.getDaySet(startLastDay, Calendar.MONTH, rmonths-1), Calendar.SECOND, 1); +// int enddays = DateUtils.daysBetween(endFirstDay, endDate)+1; +// Date endlastday = DateUtils.getLastDayForMonth(endDate); +// int endmonthdays = DateUtils.daysBetween(endFirstDay, endlastday)+1; +// _months = _months.add(new BigDecimal(enddays).divide(new BigDecimal(endmonthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); // } -// }else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) { -// if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { -// return unitPropertyPrice.divide(new BigDecimal(propertyContract.getMonthAverageDays()), -// Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); -// }else { -// int allDays = DateUtils.daysBetween(startDate, endDate)+1; -// return money.divide(new BigDecimal(allDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); -// } -// } -// }else if (rentcontract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) { -// if (propertyContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) { -// if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { -// return unitPropertyPrice.multiply(new BigDecimal(12*propertyContract.getMonthAverageDays())); -// }else { -// return unitPropertyPrice.multiply(new BigDecimal(365)); -// } -// }else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) { -// return unitPropertyPrice; -// }else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) { -// return unitPropertyPrice.multiply(new BigDecimal(12)); -// } -// }else if (rentcontract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) { -// if (propertyContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) { -// if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) { -// return unitPropertyPrice.multiply(new BigDecimal(propertyContract.getMonthAverageDays())); -// }else { -// //此处就无法计算月了。 -// //计算月份值。 -// Date realEndStart = DateUtils.getDaySet(endDate, Calendar.SECOND, 1); -// int[] diffs = DateUtils.getDiff(startDate, realEndStart); -// BigDecimal months = new BigDecimal(diffs[0]); -// Date preextraStartDay = DateUtils.getTimeAfterMonths(diffs[0], startDate); -// Date extraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(preextraStartDay); -// Date extraStartDayMonthEnd = DateUtils.getLastDayForMonth(preextraStartDay); -// int monthDays = DateUtils.daysBetween(extraStartDayMonthStart, extraStartDayMonthEnd)+1; -// int predays = DateUtils.daysBetween(preextraStartDay, extraStartDayMonthEnd)+1; -// months = months.add(new BigDecimal(predays).divide(new BigDecimal(monthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); -// //有可能会跨月 -// if (extraStartDayMonthEnd.before(endDate)) { -// Date lastMonthStart = DateUtils.getDaySet(extraStartDayMonthEnd, Calendar.SECOND, 1); -// int lastdays = DateUtils.daysBetween(lastMonthStart, endDate)+1; -// Date lastextraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(lastMonthStart); -// Date lastextraStartDayMonthEnd = DateUtils.getLastDayForMonth(lastMonthStart); -// int lastmonthDays = DateUtils.daysBetween(lastextraStartDayMonthStart, lastextraStartDayMonthEnd)+1; -// months = months.add(new BigDecimal(lastdays).divide(new BigDecimal(lastmonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); -// } -// return unitPropertyPrice.multiply(months); -// } -// }else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) { -// return unitPropertyPrice.divide(new BigDecimal(12),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); -// }else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) { -// return unitPropertyPrice; +// }else { +// //相当于在同一个月份 +// int days = DateUtils.daysBetween(startDate, endDate)+1; +// Date startLastDay = DateUtils.getLastDayForMonth(startDate); +// int monthdays = DateUtils.daysBetween(startDate, startLastDay)+1; +// _months = _months.add(new BigDecimal(days).divide(new BigDecimal(monthdays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); // } +// }else { +// _months = _months.add(new BigDecimal(months)); +// Date prelastMonthStartDate = DateUtils.getDaySet(startDate, Calendar.MONTH, months); +// Date extraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(prelastMonthStartDate); +// Date extraStartDayMonthEnd = DateUtils.getLastDayForMonth(prelastMonthStartDate); +// int premonthDays = DateUtils.daysBetween(extraStartDayMonthStart, extraStartDayMonthEnd)+1; +// int prelastdays = 0; +// if (extraStartDayMonthEnd.after(endDate) || extraStartDayMonthEnd.equals(endDate)) { +// prelastdays = DateUtils.daysBetween(prelastMonthStartDate, endDate)+1; +// _months = _months.add(new BigDecimal(prelastdays).divide(new BigDecimal(premonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); +// }else { +// prelastdays = DateUtils.daysBetween(prelastMonthStartDate, extraStartDayMonthEnd)+1; +// _months = _months.add(new BigDecimal(prelastdays).divide(new BigDecimal(premonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); +// //跨月 +// Date lastMonthStart = DateUtils.getDaySet(extraStartDayMonthEnd, Calendar.SECOND, 1); +// int lastdays = DateUtils.daysBetween(lastMonthStart, endDate)+1; +// Date lastextraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(lastMonthStart); +// Date lastextraStartDayMonthEnd = DateUtils.getLastDayForMonth(lastMonthStart); +// int lastmonthDays = DateUtils.daysBetween(lastextraStartDayMonthStart, lastextraStartDayMonthEnd)+1; +// _months = _months.add(new BigDecimal(lastdays).divide(new BigDecimal(lastmonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP)); +// } // } -// return unitPropertyPrice; +// return _months; // } private BigDecimal[] calcuteReveneuJump(BigDecimal sales,WxRentContract rentcontract,Date startDate,Date endDate,List freePeriods) { BigDecimal revenueDecimal = new BigDecimal(0); + //每个档次后面的最低保底金额 BigDecimal rentDecimal = new BigDecimal(0); //根据免租期来计算 List validDates = WxRentContractHelper.getValidDays(startDate, endDate, freePeriods); @@ -2528,14 +918,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } } - //根据时间区间计算 - //固定租金需要再计算,因为跳点设置的租金是单价 - String rentNeedpay = "0"; - if (rentDecimal.compareTo(new BigDecimal(0)) > 0 ) { +// String rentNeedpay = "0"; +// if (rentDecimal.compareTo(new BigDecimal(0)) > 0 ) { +// //根据时间来计算真实的 // rentNeedpay = WxRentContractAgileHelper.getNeedPayMoney(freePeriods,rentcontract.getDecimalSize(), rentDecimal.toPlainString(),startDate, // endDate,0,0,false,rentcontract.getReceivePeriodUnit(),rentcontract.getReceivePeriod()); - } - rentDecimal = new BigDecimal(rentNeedpay); +// } +// rentDecimal = new BigDecimal(rentNeedpay); BigDecimal[] bs = new BigDecimal[] {revenueDecimal,rentDecimal,sales}; return bs; } @@ -2543,174 +932,131 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) @Override public WxRentContractRevenueSetSalesVo setRevenueSales(MallUserInfo user,WxRentContract rentcontract, String sales, Date startime, Date endtime) { -// //如果账单存在缴费,付款,减免,冲抵,等情况,则不允许。 -// WxAllBill bq = wxBillAllHelper.generateRentContractQueryBill(rentcontract, rentcontract.getId(),startime,endtime); -// List rentBillList = wxAllBillMapper.findList(bq); -// if (null == rentBillList || rentBillList.size() <= 0 ) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"未查询到账单"); -// } -// for (int i = 0 ; i < rentBillList.size() ; i ++) { -// WxAllBill rentBill = rentBillList.get(i); -// if ((StringUtils.isNotBlank(rentBill.getPay()) && new BigDecimal(rentBill.getPay()).compareTo(new BigDecimal(0)) > 0 ) -// || (StringUtils.isNotBlank(rentBill.getSetOff()) && new BigDecimal(rentBill.getSetOff()).compareTo(new BigDecimal(0)) > 0 ) -// || (StringUtils.isNotBlank(rentBill.getReturnPay()) && new BigDecimal(rentBill.getReturnPay()).compareTo(new BigDecimal(0)) > 0 ) -// || (StringUtils.isNotBlank(rentBill.getUseMoney()) && new BigDecimal(rentBill.getUseMoney()).compareTo(new BigDecimal(0)) > 0 ) ) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"租金账单存在已经已经缴费或付款,扣减,减免,冲抵的情况,不允许操作"); -// } -// } -// -// BigDecimal salesDeciaml = new BigDecimal(sales); -// -// //删除自动创建的账单 -// WxAllBill billDel = new WxAllBill(); -// billDel.updateTenantInfo(rentcontract); -// billDel.setRentContractId(rentcontract.getId()); -// billDel.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_REVENUE_SALES.getCode()); -// billDel.setStarttimeEqual(startime); -// wxAllBillMapper.deleteByRentReveneuSales(billDel); -// -// //上面删除掉生成的账单之后,再重新查询,只剩下主账单 -// rentBillList = wxAllBillMapper.findList(bq); -// -// //加上物业 -// List propertyBillList = null; -// BigDecimal propertyPrice = new BigDecimal(0); -//// WxPropertyContract propertyContract = null; -//// if (null != propertyContractId) { -//// WxAllBill propertyBillq = new WxAllBill(); -//// propertyBillq.updateTenantInfo(rentcontract); -//// propertyBillq.setPropertyContractId(propertyContractId); -//// propertyBillq.setBillType(EnumBillAllType.PROPERTY.getCode()); -//// propertyBillq.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId()); -//// propertyBillq.setIsPreview(EnumYesOrNo.NO.getCode()); -//// propertyBillq.setNoExtraCreateFrom(EnumYesOrNo.YES.getCode()); -//// propertyBillq.setStarttimeEqual(startime); -//// propertyBillq.setEndtimeEqual(endtime); -//// propertyBillList = wxAllBillMapper.findList(propertyBillq); -//// for (int i = 0 ; i < propertyBillList.size() ; i ++) { -//// WxAllBill propertyBill = propertyBillList.get(i); -//// if ((StringUtils.isNotBlank(propertyBill.getPay()) && new BigDecimal(propertyBill.getPay()).compareTo(new BigDecimal(0)) > 0 ) -//// || (StringUtils.isNotBlank(propertyBill.getSetOff()) && new BigDecimal(propertyBill.getSetOff()).compareTo(new BigDecimal(0)) > 0 ) -//// || (StringUtils.isNotBlank(propertyBill.getReturnPay()) && new BigDecimal(propertyBill.getReturnPay()).compareTo(new BigDecimal(0)) > 0 ) -//// || (StringUtils.isNotBlank(propertyBill.getUseMoney()) && new BigDecimal(propertyBill.getUseMoney()).compareTo(new BigDecimal(0)) > 0 ) ) { -//// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"物业账单存在已经已经缴费或付款,扣减,减免,冲抵的情况,不允许操作"); -//// } -//// } -//// } -// -// //根据销售额来计算平均每计费周期营业额,相当于设置联营扣点保底营业额 -// BigDecimal unitRevenuePrice = new BigDecimal(0); -// //如果没达到最低扣点销售额,则不重新计算 -// if (StringUtils.isNotBlank(rentcontract.getLimitRevenue()) && new BigDecimal(rentcontract.getLimitRevenue()).compareTo(salesDeciaml) > 0 ){ -// //保存销售额 -// addRevenueSales(rentcontract,startime,endtime,"0",sales,salesDeciaml,propertyContractId); -// WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo(); -// vo.setTotal("0"); -// return vo; -// }else { -// unitRevenuePrice = calcuteUnitPrice(startime, endtime,salesDeciaml, -// rentcontract.getPriceUnit(),rentcontract.getDayPriceCalcute(),rentcontract.getMonthAverageDays(),null,rentcontract.getReceivePeriodUnit()); -// //设置保底营业额 -// rentcontract.setRevenue(unitRevenuePrice.toPlainString()); -// //联营扣点 -// if (rentcontract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { -// rentcontract.setPrice(new BigDecimal(rentcontract.getPayRatio()).multiply(unitRevenuePrice).divide(new BigDecimal(100), -// Constant.default_long_decimal_size,RoundingMode.HALF_UP).toPlainString()); -// }else if (rentcontract.getType().intValue() == EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode()) { -// //取高才能加上物业费 -// if (null != propertyContractId && null != propertyBillList) { -// //propertyContract = wxPropertyContractMapper.selectById(propertyContractId); -// //有可能物业的单价时间跟租金的不一致,需要根据物业的单价重新计算 -// //propertyPrice = calcuteRentPropertyPrice(rentcontract, propertyContract, rentBill.getStarttime(), rentBill.getEndtime(), -// //new BigDecimal(propertyBill.getNeedPay())); -// } -// } -// //计算每一年的基数 -// List priceArrs = WxRentContractHelper.calcuteRentAndRevenuePrice(rentcontract); -// String[] rentPriceArrs = priceArrs.get(0); -// String[] revenuePriceArrs = priceArrs.get(1); -// //计算商业管理费 -// String[] bussinessManagerPriceArrs = WxRentContractHelper.calcuteBussinessManagementFee(rentcontract); -// //计算运营管理费 -// String[] operationManagerPriceArrs = WxRentContractHelper.calcuteOperatingManagementFee(rentcontract); -// -// //物业费单价 -// String[] propertyContractArrs = null; -//// if (null != propertyContract) { -//// propertyContractArrs = WxRentContractHelper.calcutePropertyPrice(propertyContract); -//// } -// List yearList = this.getYearList(rentPriceArrs.length, 12, rentcontract.getRentalStartDate(),null); -// int yearIndex = 0; -// for( int i = 0 ; i < yearList.size() ; i ++) { -// Date yearStartDate = yearList.get(i); -// Date yearEndDate = DateUtils.getTimeAfterMonths(12, yearStartDate); -// if (startime.equals(yearStartDate) || -// (startime.after(yearStartDate) && (endtime.before(yearEndDate) || endtime.equals(yearEndDate)) )) { -// yearIndex = i; -// break; -// } -// } -// if (yearIndex <= 0 ) { -// yearIndex = 0; -// } -// -// //租金+营业管理费+商业管理费+物业 和扣点相比取高。 -// BigDecimal rentTotal = new BigDecimal(rentPriceArrs[yearIndex]); -// if (null != bussinessManagerPriceArrs) { -// rentTotal = rentTotal.add(new BigDecimal(bussinessManagerPriceArrs[yearIndex])); -// } -// if (null != operationManagerPriceArrs) { -// rentTotal = rentTotal.add(new BigDecimal(operationManagerPriceArrs[yearIndex])); -// } -// //此处需要物业合同合租金合同的计费周期一致,严谨的需要用到上面计算的propertyPrice -// if (null != propertyContractArrs) { -// rentTotal = rentTotal.add(new BigDecimal(propertyContractArrs[yearIndex])); -// } -// -// //跟扣点相比较 -// BigDecimal priceDecimal = rentTotal; -// if (null != revenuePriceArrs && null != revenuePriceArrs[yearIndex]) { -// BigDecimal revenuePrice = new BigDecimal(revenuePriceArrs[yearIndex]); -// if (revenuePrice.compareTo(rentTotal) > 0 ) { -// priceDecimal = revenuePrice; -// } -// } -// -// //免租期 -// List freePeriods = getFreeDays(rentcontract); -// -// //根据扣点规则和租赁相关费用取高来计算费用 -// String needpay = WxRentContractHelper.getNeedPayMoney(freePeriods,rentcontract, priceDecimal.toPlainString(),startime, -// endtime,0,0,false,rentcontract.getReceivePeriodUnit(),rentcontract.getReceivePeriod()); -// -// //计算跳点。 -// BigDecimal[] jumppays = calcuteReveneuJump(salesDeciaml, rentcontract,startime, endtime,freePeriods); -// BigDecimal jumpRevenuePay = jumppays[0]; -// BigDecimal jumpRentPay = jumppays[1]; -// BigDecimal saleDecimalValid = jumppays[2]; -// BigDecimal jumppay = new BigDecimal(0); -// if (jumpRevenuePay.compareTo(jumpRentPay) > 0 ) { -// jumppay = jumppay.add(jumpRevenuePay); -// }else { -// jumppay = jumppay.add(jumpRentPay); -// } -// StringBuffer sb = new StringBuffer("有效销售额:"+saleDecimalValid.toPlainString()+","); -// if (jumppay.compareTo(new BigDecimal(needpay)) > 0 ) { -// sb.append("跳点规则计算金额:"+jumppay.toPlainString()+",合同租金扣点规则计算金额:"+needpay+"."); -// needpay = jumppay.toPlainString(); -// }else { -// sb.append("跳点规则计算金额:"+jumppay.toPlainString()+",合同租金扣点规则计算金额:"+needpay+"."); -// } -// sb.append("取高后总金额为:["+needpay+"]."); -// //保存销售额 -// addRevenueSales(rentcontract,startime,endtime,needpay,sales,saleDecimalValid,propertyContractId); -// return handleBills(user,sb,rentcontract,propertyContractId,needpay,rentBillList,startime,endtime,EnumBillExtraCreateFrom.RNET_REVENUE_SALES,propertyBillList,rentPriceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs,propertyContractArrs,yearIndex); -// -// } -return null; + WxRentContractAgileRenevue renevue = wxAgileContractService.findRenevueByContract(rentcontract.getId(), rentcontract); + if (null == renevue) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"未查询到扣点配置"); + } + //根据时间来获取抽成比例 + WxRentContractAgileRenevueItem renevueItem = wxAgileContractService.findOneRenevueItemByTime(rentcontract.getId(), renevue,startime,endtime); + if (null == renevueItem) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"时间区间未匹配到规则"); + } + + //如果账单存在缴费,付款,减免,冲抵,等情况,则不允许。 + WxAllBill bq = wxBillAllHelper.generateRentContractQueryBill(rentcontract, rentcontract.getId(),startime,endtime); + List rentBillList = wxAllBillMapper.findList(bq); + if (null == rentBillList || rentBillList.size() <= 0 ) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"未查询到账单"); + } + for (int i = 0 ; i < rentBillList.size() ; i ++) { + WxAllBill rentBill = rentBillList.get(i); + if ((StringUtils.isNotBlank(rentBill.getPay()) && new BigDecimal(rentBill.getPay()).compareTo(new BigDecimal(0)) > 0 ) + || (StringUtils.isNotBlank(rentBill.getSetOff()) && new BigDecimal(rentBill.getSetOff()).compareTo(new BigDecimal(0)) > 0 ) + || (StringUtils.isNotBlank(rentBill.getReturnPay()) && new BigDecimal(rentBill.getReturnPay()).compareTo(new BigDecimal(0)) > 0 ) + || (StringUtils.isNotBlank(rentBill.getUseMoney()) && new BigDecimal(rentBill.getUseMoney()).compareTo(new BigDecimal(0)) > 0 ) ) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"租金账单存在已经已经缴费或付款,扣减,减免,冲抵的情况,不允许操作"); + } + } + + //删除自动创建的账单 + WxAllBill billDel = new WxAllBill(); + billDel.updateTenantInfo(rentcontract); + billDel.setRentContractId(rentcontract.getId()); + billDel.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_REVENUE_SALES.getCode()); + billDel.setStarttimeEqual(startime); + wxAllBillMapper.deleteByRentReveneuSales(billDel); + + //上面删除掉生成的账单之后,再重新查询,只剩下主账单 + //rentBillList = wxAllBillMapper.findList(bq); + + + BigDecimal salesDeciaml = new BigDecimal(sales); + //如果没达到最低扣点销售额,则不重新计算 + if (StringUtils.isNotBlank(renevue.getLimitRevenue()) && new BigDecimal(renevue.getLimitRevenue()).compareTo(salesDeciaml) > 0 ){ + //保存销售额 + addRevenueSales(rentcontract,startime,endtime,"0",sales,salesDeciaml); + WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo(); + vo.setTotal("0"); + return vo; + }else { + if (renevueItem.getIsFree().intValue() == EnumYesOrNo.YES.getCode()){ + addRevenueSales(rentcontract,startime,endtime,"0",sales,salesDeciaml); + WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo(); + vo.setTotal("0"); + return vo; + } + + //计算总提成 + BigDecimal renevuePrice = new BigDecimal(renevueItem.getRate()).divide(new BigDecimal(100)).multiply(salesDeciaml); + EnumRentDayPriceCalcute dayPriceCalcute = EnumRentDayPriceCalcute.getEnum(rentcontract.getDayPriceCalcute()); + EnumRentContractAgilTimeUnit timeUnit = EnumRentContractAgilTimeUnit.getEnum(renevue.getTimeUnit()); + //根据实际天数来计算提成 + String needpay = WxRentContractAgileHelper.getMonthNeedPay(null, rentcontract.getDecimalSize(),renevuePrice, startime, endtime, timeUnit, renevue.getTimePeriod(), dayPriceCalcute, rentcontract.getMonthAverageDays()); + + //计算跳点。 + BigDecimal[] jumppays = calcuteReveneuJump(salesDeciaml, rentcontract,startime, endtime,null); + BigDecimal jumpRevenuePay = jumppays[0]; + BigDecimal jumpRentPay = jumppays[1]; + BigDecimal saleDecimalValid = jumppays[2]; + BigDecimal jumppay = new BigDecimal(0); + if (jumpRevenuePay.compareTo(jumpRentPay) > 0 ) { + jumppay = jumppay.add(jumpRevenuePay); + }else { + jumppay = jumppay.add(jumpRentPay); + } + StringBuffer sb = new StringBuffer("有效销售额:"+saleDecimalValid.toPlainString()+","); + if (jumppay.compareTo(new BigDecimal(needpay)) > 0 ) { + sb.append("跳点规则计算金额:"+jumppay.toPlainString()+",扣点规则计算金额:"+needpay+"."); + needpay = jumppay.toPlainString(); + }else { + sb.append("跳点规则计算金额:"+jumppay.toPlainString()+",扣点规则计算金额:"+needpay+"."); + } + BigDecimal uneedPay = getJoinRenevueUpFeesReceivePayTotal(rentcontract,startime,endtime,true); + if (null != uneedPay && uneedPay.compareTo(new BigDecimal(0)) > 0 ){ + sb.append("参与取高款项计算金额:"+uneedPay.toPlainString()); + if (uneedPay.compareTo(new BigDecimal(needpay)) > 0 ) { + needpay = uneedPay.toPlainString(); + } + } + + sb.append("取高后总金额为:["+needpay+"]."); + //保存销售额 + addRevenueSales(rentcontract,startime,endtime,needpay,sales,saleDecimalValid); + return handleBills(user,sb,rentcontract,needpay,startime,endtime,EnumBillExtraCreateFrom.RNET_REVENUE_SALES); + + } } - private void addRevenueSales(WxRentContract rentcontract,Date starttime,Date endtime,String needpay,String sales,BigDecimal saleDecimalValid,Long propertyContractId) { + private BigDecimal getJoinRenevueUpFeesReceivePayTotal(WxRentContract rentcontract,Date begin,Date end,boolean isEqualTime) { + //如果是取高的,则取高计算 + if (rentcontract.getType().intValue() == EnumAgileContractType.RENEVUE_UP.getCode().intValue()) { + //查询所有参与取高的款项的账单 + WxRentContractAgileUnDeposit udq = new WxRentContractAgileUnDeposit(); + udq.updateTenantInfo(rentcontract); + udq.setRentContractId(rentcontract.getId()); + udq.setJoinRenevueUp(EnumYesOrNo.YES.getCode()); + List udlist = wxAgileContractService.findUnDepositFeesIdList(udq); + if (null != udlist && udlist.size() > 0 ){ + WxAllBill udbill = new WxAllBill(); + udbill.updateTenantInfo(rentcontract); + udbill.setRentContractId(rentcontract.getId()); + udbill.setIsPreview(EnumYesOrNo.NO.getCode()); + udbill.setEnergyFeesIds(udlist); + if (isEqualTime) { + udbill.setStarttimeEqual(begin); + udbill.setEndtimeEqual(end); + }else { + udbill.setStarttime(rentcontract.getYearsBegin()); + udbill.setEndtime(rentcontract.getYearsEnd()); + }; + BigDecimal uneedPay = wxAllBillMapper.getReceivePaySum(udbill); + return uneedPay; + } + } + return null; + } + + private void addRevenueSales(WxRentContract rentcontract,Date starttime,Date endtime,String needpay,String sales,BigDecimal saleDecimalValid) { WxRentContractRevenueSales rs = new WxRentContractRevenueSales(); rs.updateTenantInfo(rentcontract); rs.setRentContractId(rentcontract.getId()); @@ -2735,57 +1081,19 @@ return null; sale.setSaleMoney(sales); sale.setSaleMoneyValid(saleDecimalValid.toPlainString()); sale.setCalcuteMoney(needpay); - sale.setPropertyContractId(propertyContractId); sale.setCreateTime(new Date()); sale.setUpdateTime(new Date()); wxRentContractRevenueSalesMapper.insert(sale); } } - private WxRentContractRevenueSetSalesVo handleBills(MallUserInfo user,StringBuffer sb,WxRentContract rentcontract,Long propertyContractId, String needpay,List rentBillList,Date startDate,Date endDate, - EnumBillExtraCreateFrom createFrom,List propertyBillList,String[] rentPriceArrs,String[] bussinessManagerPriceArrs,String[] operationManagerPriceArrs,String[] propertyContractArrs,int yearIndex) { - - //计算资金分摊的比例 租金,商业管理费,营业管理费,物业费。每个科目税点不一样,这样分摊能降低成本 - String[] moneyShareRates = new String[4]; - BigDecimal rentPriceDecimal = new BigDecimal(rentPriceArrs[yearIndex]); - BigDecimal bussinessPriceDecimal = new BigDecimal(0); - if (null != bussinessManagerPriceArrs && null != bussinessManagerPriceArrs[yearIndex]) { - bussinessPriceDecimal = new BigDecimal(bussinessManagerPriceArrs[yearIndex]); - } - BigDecimal operaterPriceDecimal = new BigDecimal(0); - if (null != operationManagerPriceArrs && null != operationManagerPriceArrs[yearIndex]) { - operaterPriceDecimal = new BigDecimal(operationManagerPriceArrs[yearIndex]); - } - if (null != rentPriceArrs && null != bussinessManagerPriceArrs && null != operationManagerPriceArrs - && rentPriceDecimal.compareTo(new BigDecimal(0)) > 0 && bussinessPriceDecimal.compareTo(new BigDecimal(0)) > 0 && operaterPriceDecimal.compareTo(new BigDecimal(0)) > 0) { - BigDecimal total = rentPriceDecimal.add(bussinessPriceDecimal).add(operaterPriceDecimal); - BigDecimal property = new BigDecimal(0); - if (null != propertyContractArrs) { - property = new BigDecimal(propertyContractArrs[yearIndex]); - } - total = total.add(property); - moneyShareRates[0] = rentPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString(); - moneyShareRates[1] = bussinessPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString(); - moneyShareRates[2] = operaterPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString(); - moneyShareRates[3] = property.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString(); - }else { - SysConfig shareConfig = sysConfigService.getByKey(SysConfigConstant.rent_share_bill_rate, rentcontract); - if (null == shareConfig || StringUtils.isBlank(shareConfig.getConfigItemValue())) { - throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"系统配置"+SysConfigConstant.rent_share_bill_rate+"未配置。"); - } - moneyShareRates = shareConfig.getConfigItemValue().split(","); - moneyShareRates[0] = new BigDecimal(moneyShareRates[0]).divide(new BigDecimal(100)).toPlainString(); - moneyShareRates[1] = new BigDecimal(moneyShareRates[1]).divide(new BigDecimal(100)).toPlainString(); - moneyShareRates[2] = new BigDecimal(moneyShareRates[2]).divide(new BigDecimal(100)).toPlainString(); - moneyShareRates[3] = new BigDecimal(moneyShareRates[3]).divide(new BigDecimal(100)).toPlainString(); - } - - String rentRate = moneyShareRates[0]; - String bussinessRate = moneyShareRates[1]; - String operaterRate = moneyShareRates[2]; - String propertyRate = moneyShareRates[3]; - //更新账单费用 - String rentneedpay = new BigDecimal(needpay).multiply(new BigDecimal(rentRate)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); + private WxRentContractRevenueSetSalesVo handleBills(MallUserInfo user,StringBuffer sb,WxRentContract rentcontract, String needpay,Date startDate,Date endDate, + EnumBillExtraCreateFrom createFrom) { + //根据设置的比例海生成对应的账单. + List fees = wxAgileContractService.findRenevueFeesListByContract(rentcontract.getId(), rentcontract); + if (null == fees) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"没有设置扣点款项"); + } List shopIdList = rentcontract.shopIdsByRentInfo(); Map shopAreaRateMap = rentcontract.getRentShopArea(); WxShopUsers suq = new WxShopUsers(); @@ -2798,240 +1106,24 @@ return null; sq.setIds(shopIdList); Map shopMap = wxShopService.findShopMap(sq); - List rentBill = generateRentBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract,rentBillList,rentneedpay,rentRate,startDate,endDate,createFrom); - - List propeBill = generatePropertyBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract, propertyContractId,propertyBillList,startDate,endDate, needpay, propertyRate,createFrom); - - //List bmbill = generateManageBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract, startDate,endDate, needpay, bussinessRate, EnumBillAllType.RENT_BUSSINESS_MANAGE,createFrom); - - //List ombill = generateManageBill(user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract, startDate,endDate, needpay, operaterRate, EnumBillAllType.RENT_OPERATION_MANAGE,createFrom); + List allbill = new ArrayList(); + for (int i = 0 ; i < fees.size(); i++ ) { + WxRentContractAgileRenevueFees fee = fees.get(i); + //更新账单费用 + BigDecimal fneedpay = new BigDecimal(needpay).multiply(new BigDecimal(fee.getRate()).divide(new BigDecimal(100))).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); + List renBill = generateRenevueBill(fee.getFeesId(),user,shopIdList,shopMap,shopUserMap,shopAreaRateMap,rentcontract,fneedpay,fee.getRate(),startDate,endDate,createFrom); + allbill.addAll(renBill); + } WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo(); vo.setTotal(needpay); - List blist = new ArrayList(); - blist.addAll(rentBill); - if (null != propeBill) { - blist.addAll(propeBill); - } -// if (null != bmbill) { -// blist.addAll(bmbill); -// } -// if (null != ombill) { -// blist.addAll(ombill); -// } - vo.setBillList(blist);; + vo.setBillList(allbill);; return vo; } - - private void createBillAction(WxAllBill bill,String oldMoney,String newMoney,MallUserInfo user) { - WxBillAction wxBillAction = new WxBillAction(); - wxBillAction.setBillId(bill.getId()); - //wxBillAction.setBillType(bill.getBillType()); - wxBillAction.setOldMoney(oldMoney); - wxBillAction.setNewMoney(newMoney); - wxBillAction.setDetails(EnumBillAction.UPDATE_BILL.getDescription(oldMoney, newMoney,null,null,null,null)); - wxBillAction.setAction(EnumBillAction.UPDATE_BILL.getCode()); - wxBillAction.setRemark(bill.getBillRemark()); - wxBillAction.setUserType(EnumSystemUserType.ADMIN.getCode()); - wxBillActionService.modifyBill(wxBillAction, user); - } - - @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public List generateManageBill(MallUserInfo user,List shopIds,Map shopMap,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, - Date starttime, Date endtime,String total,String rate,EnumBillExtraCreateFrom createFrom) { - WxAllBill bussinessmanageBill = new WxAllBill(); - bussinessmanageBill.updateTenantInfo(rentcontract); - //bussinessmanageBill.setBillType(type.getCode()); - //bussinessmanageBill.setEnergyFeesId(type.getEnergyFeesId()); - bussinessmanageBill.setRentContractId(rentcontract.getId()); - bussinessmanageBill.setIsPreview(EnumYesOrNo.NO.getCode()); - bussinessmanageBill.setNoExtraCreateFrom(EnumYesOrNo.YES.getCode()); - bussinessmanageBill.setStarttimeEqual(starttime); - bussinessmanageBill.setEndtimeEqual(endtime); - List bmbillList = wxAllBillMapper.findList(bussinessmanageBill); - 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); - String oldMoney = b.getReceivePay(); - //把原有的账单应收金额变为0 - b.setHistoryReceivePay(oldMoney); - b.setNeedPay("0");//如不设置会影响减免统计 - b.setReceivePay("0"); - b.setBillRemark("账单金额重新计算生成新账单,原账单金额变为0"); - b.setUpdatetime(new Date()); - b.setUpdateBy(user.getId()); - b.setUpdateByName(user.getName()); - wxAllBillMapper.updateById(b); - - createBillAction(b,oldMoney,"0",user); - } - } - 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()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - - String newmoney = bussinessmoney.multiply(shoprate).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); - WxAllBill b = new WxAllBill(); - final IdWorker idWorker = IdWorker.get(); - b.setId(idWorker.nextId()); - b.updateTenantInfo(rentcontract); - //b.setBillType(type.getCode()); - //b.setEnergyFeesId(type.getEnergyFeesId()); - b.setRentContractId(rentcontract.getId()); - b.setIsPreview(EnumYesOrNo.NO.getCode()); - b.setCanEdit(EnumYesOrNo.NO.getCode()); - b.setShopId(sid); - String cusName = null; - if (null != shopUserMap) { - WxShopUsers su = shopUserMap.get(sid); - if (null != su) { - cusName = su.getName(); - } - } - b.setCusName(cusName); - b.setCreatetime(new Date()); - b.setCreateBy(user.getId()); - b.setCreateByName(user.getName()); - b.setUpdatetime(new Date()); - b.setUpdateBy(user.getId()); - b.setUpdateByName(user.getName()); - b.setPriceDetail(""); - b.setNeedPay(newmoney); - b.setReceivePay(newmoney); - b.setPay("0"); - b.setStarttime(starttime); - b.setEndtime(endtime); - b.setReceiveDate(starttime); - b.setPeriod(WxRentContractHelper.getPeriod(starttime)); - 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("自动计算创建,科目总应收金额为:"+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; - } - return null; - - } - - @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - 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) { - 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 - String oldMoney = _rb.getReceivePay(); - _rb.setHistoryReceivePay(_rb.getReceivePay()); - _rb.setNeedPay("0"); - _rb.setReceivePay("0"); - _rb.setBillRemark("账单金额重新计算生成新账单,原账单金额变为0"); - _rb.setUpdatetime(new Date()); - _rb.setUpdateBy(user.getId()); - _rb.setUpdateByName(user.getName()); - wxAllBillMapper.updateById(_rb); - - createBillAction(_rb,oldMoney,"0",user); - } - } - } - 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()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); - - String newmoney = bussinessmoney.multiply(shoprate).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString(); - WxAllBill bmbill = new WxAllBill(); - final IdWorker idWorker = IdWorker.get(); - bmbill.setId(idWorker.nextId()); - bmbill.updateTenantInfo(rentcontract); - //bmbill.setBillType(EnumBillAllType.PROPERTY.getCode()); - //bmbill.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId()); - bmbill.setRentContractId(rentcontract.getId()); - bmbill.setPropertyContractId(propertyContractId); - bmbill.setIsPreview(EnumYesOrNo.NO.getCode()); - bmbill.setCanEdit(EnumYesOrNo.NO.getCode()); - bmbill.setShopId(sid); - String cusName = null; - if (null != shopUserMap) { - WxShopUsers su = shopUserMap.get(sid); - if (null != su) { - cusName = su.getName(); - } - } - bmbill.setCusName(cusName); - bmbill.setCreatetime(new Date()); - bmbill.setCreateBy(user.getId()); - bmbill.setCreateByName(user.getName()); - bmbill.setUpdatetime(new Date()); - bmbill.setUpdateBy(user.getId()); - bmbill.setUpdateByName(user.getName()); - bmbill.setPriceDetail(""); - 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()+".自动计算创建,科目总应收金额为:"+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("自动计算创建,科目总应收金额为:"+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; - } - return null; - - } - @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - 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 ) { - //查询每一个铺位的 - for (int i = 0 ; i < rentBillList.size() ; i ++) { - WxAllBill b = rentBillList.get(i); - //把原有的账单应收金额变为0 - String oldMoney = b.getReceivePay(); - b.setHistoryReceivePay(oldMoney);//设置此值,供录入销售额的页面显示应收金额 - b.setNeedPay("0");//如不设置会影响减免统计 - b.setReceivePay("0"); - b.setBillRemark("账单金额重新计算生成新账单,原账单金额变为0"); - b.setUpdatetime(new Date()); - b.setUpdateBy(user.getId()); - b.setUpdateByName(user.getName()); - wxAllBillMapper.updateById(b); - - createBillAction(b,oldMoney,"0",user); - } - } - BigDecimal moneyb = new BigDecimal(money); + public List generateRenevueBill(Long feesId,MallUserInfo user,List shopIds,Map shopMap,Map shopUserMap,Map shopAreaRateMap,WxRentContract rentcontract, + BigDecimal moneyb,String rate,Date starttime,Date endtime,EnumBillExtraCreateFrom createFrom) { List billList = new ArrayList(); for (int i = 0 ; i < shopIds.size(); i++) { Long sid = shopIds.get(i); @@ -3043,8 +1135,7 @@ return null; final IdWorker idWorker = IdWorker.get(); bmbill.setId(idWorker.nextId()); bmbill.updateTenantInfo(rentcontract); - //bmbill.setBillType(EnumBillAllType.RENT.getCode()); - //bmbill.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId()); + bmbill.setEnergyFeesId(feesId); bmbill.setRentContractId(rentcontract.getId()); bmbill.setIsPreview(EnumYesOrNo.NO.getCode()); bmbill.setCanEdit(EnumYesOrNo.NO.getCode()); @@ -3071,9 +1162,9 @@ return null; bmbill.setEndtime(endtime); bmbill.setReceiveDate(starttime); bmbill.setPeriod(WxRentContractHelper.getPeriod(starttime)); - bmbill.setBillRemark(createFrom.getMessage()+".自动计算创建,科目总应收金额为:"+moneyb.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).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("自动计算创建,科目总应收金额为:"+moneyb.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString()+"元[科目分摊比率为:"+rate+"]。"+"本铺分担比例"+shoprate.setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).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); @@ -3149,27 +1240,12 @@ return null; } } - BigDecimal receivepay = new BigDecimal(0); - //查询合同租金所有应收的账单 - //查询所有租金+营业管理费+商业管理费账单的信息,因为设置销售额会自动的创建或者更新对应的账单 - WxAllBill rentBillq = new WxAllBill(); - rentBillq.updateTenantInfo(rentcontract); - rentBillq.setRentContractId(rentcontract.getId()); - List feesIdList = new ArrayList(); - //feesIdList.add(EnumBillAllType.RENT.getEnergyFeesId()); - //feesIdList.add(EnumBillAllType.RENT_BUSSINESS_MANAGE.getEnergyFeesId()); - //feesIdList.add(EnumBillAllType.RENT_OPERATION_MANAGE.getEnergyFeesId()); - rentBillq.setEnergyFeesIds(feesIdList); - rentBillq.setIsPreview(EnumYesOrNo.NO.getCode()); - rentBillq.setStarttime(rentcontract.getYearsBegin()); - rentBillq.setEndtime(rentcontract.getYearsEnd()); - WxBillSum rentBillSum = wxAllBillMapper.getBillMonthSum(rentBillq); - if (null != rentBillSum) { - receivepay = receivepay.add(rentBillSum.getNeedPayNumber()); + //查询所有参与取高的账单金额 + BigDecimal receivepay = getJoinRenevueUpFeesReceivePayTotal(rentcontract,rentcontract.getYearsBegin(),rentcontract.getYearsEnd(),false); + if (null == receivepay ){ + receivepay = new BigDecimal(0); } - //查询对应的物业账单,包括录入销售额自动生成的 - WxRentContractYearsSumVo vo = new WxRentContractYearsSumVo(); vo.setTotalSales(sum.toPlainString()); vo.setTotalRevenue(jumpRevenuePay.toPlainString()); @@ -3184,32 +1260,8 @@ return null; } private WxRentContractRevenueSetSalesVo handelHuiSuanBills(MallUserInfo user,WxRentContract rentcontract,String owe) { -// //计算每一年的基数 -// List priceArrs = WxRentContractHelper.calcuteRentAndRevenuePrice(rentcontract); -// String[] rentPriceArrs = priceArrs.get(0); -// //String[] revenuePriceArrs = priceArrs.get(1); -// //计算商业管理费 -// String[] bussinessManagerPriceArrs = WxRentContractHelper.calcuteBussinessManagementFee(rentcontract); -// //计算运营管理费 -// String[] operationManagerPriceArrs = WxRentContractHelper.calcuteOperatingManagementFee(rentcontract); -// -// //物业费单价 -// String[] propertyContractArrs = null; -// List yearList = this.getYearList(rentPriceArrs.length, 12, rentcontract.getRentalStartDate(),null); -// int yearIndex = 0; -// for( int i = 0 ; i < yearList.size() ; i ++) { -// Date yearEndDate = yearList.get(i); -// if (rentcontract.getYearsBegin().before(yearEndDate) || rentcontract.getYearsEnd().equals(yearEndDate)) { -// yearIndex = i-1; -// break; -// } -// } -// if (yearIndex <= 0 ) { -// yearIndex = 0; -// } -// StringBuffer sb = new StringBuffer(""); -// return handleBills(user,sb,rentcontract,null,owe,null,rentcontract.getYearsBegin(),rentcontract.getYearsEnd(),EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN,null,rentPriceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs,propertyContractArrs,yearIndex); - return null; + StringBuffer sb = new StringBuffer(""); + return handleBills(user,sb,rentcontract,owe,rentcontract.getYearsBegin(),rentcontract.getYearsEnd(),EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN); } @@ -3218,10 +1270,4 @@ return null; return wxRentContractRevenueJumpMapper.findList(jump); } - @Override - public BigDecimal calcuteContractUsedShopArea(WxRentContract wxRentContract,Long shopId) { - //根据合同区间查询已使用合同的总面积 - return null; - } - } diff --git a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml index a98a58814..8db8896f2 100644 --- a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml @@ -36,7 +36,6 @@ - @@ -53,7 +52,7 @@ `id`,`tenant_id`,`parent_tenant_id`,`shop_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`, `price_detail`,`need_pay`,`receive_pay`,`history_receive_pay`,`pay`,`pay_way`,`pay_date`,`set_off`,`use_money`,`starttime`,`endtime`,`status`,`energy_fees_id`, `return_pay`,`bill_remark`,`last_owe_call_time`,`last_owe_call_user`,`receive_date`,`period`, - `is_preview`,`shop_info`,`rent_contract_id`,`rent_contract_agile_fees_type`,`property_contract_id`,`parent_bill_id`,`virtual_compose_id`,`parent_virtual_compose_id`, + `is_preview`,`shop_info`,`rent_contract_id`,`rent_contract_agile_fees_type`,`parent_bill_id`,`virtual_compose_id`,`parent_virtual_compose_id`, `energy_reading_calcuteId`,`energy_reading_id`,`extra_create_from`,`rent_area`,`can_edit`,`cus_name`,`fees_type` @@ -70,7 +69,6 @@ and `energy_fees_id` = #{energyFeesId} and `rent_contract_id` = #{rentContractId} and `rent_contract_agile_fees_type` = #{rentContractAgileFeesType} - and `property_contract_id` = #{propertyContractId} and `parent_bill_id` = #{parentBillId} and `virtual_compose_id` = #{virtualComposeId} and `parent_virtual_compose_id` = #{parentVirtualComposeId} @@ -143,12 +141,6 @@ #{ridItem} - - and property_contract_id in - - #{pidItem} - - and `status` in @@ -323,9 +315,6 @@ and rent_contract_id = #{rentContractId} - - and property_contract_id = #{propertyContractId} - and rent_contract_agile_fees_type = #{rentContractAgileFeesType} @@ -340,8 +329,14 @@ and rent_contract_id = #{rentContractId} - - and property_contract_id = #{propertyContractId} + + and energy_fees_id = #{energyFeesId} + + + and `energy_fees_id` in + + #{eidItem} + @@ -364,9 +359,6 @@ and rent_contract_id = #{rentContractId} - - and property_contract_id = #{propertyContractId} - @@ -374,9 +366,6 @@ where rent_contract_id = #{rentContractId} - - where property_contract_id = #{propertyContractId} - @@ -391,7 +380,7 @@ #{item.needPay},#{item.receivePay},#{item.historyReceivePay},#{item.pay},#{item.payWay},#{item.payDate},#{item.setOff},#{item.useMoney}, #{item.starttime},#{item.endtime},#{item.status},#{item.energyFeesId},#{item.returnPay},#{item.billRemark}, #{item.lastOweCallTime},#{item.lastOweCallUser}, - #{item.receiveDate},#{item.period},#{item.isPreview},#{item.shopInfo},#{item.rentContractId},#{item.rentContractAgileFeesType},#{item.propertyContractId}, + #{item.receiveDate},#{item.period},#{item.isPreview},#{item.shopInfo},#{item.rentContractId},#{item.rentContractAgileFeesType}, #{item.parentBillId},#{item.virtualComposeId},#{item.parentVirtualComposeId},#{item.energyReadingCalcuteId}, #{item.energyReadingId},#{item.extraCreateFrom},#{item.rentArea},#{item.canEdit},#{item.cusName},#{item.feesType} ) @@ -417,18 +406,12 @@ and rent_contract_id = #{rentContractId} - - and property_contract_id = #{propertyContractId} - update wx_all_bill set cus_name = #{cusName} where tenant_id = #{tenantId} and rent_contract_id = #{rentContractId} - - - and property_contract_id = #{propertyContractId} and( @@ -449,5 +432,13 @@ + + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml index 97538d4e0..2f7d4fff5 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml @@ -128,14 +128,14 @@ - + c.id,c.tenant_id,c.parent_tenant_id,c.type,c.cover_img,c.cover_picture,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_rule,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, - car.vendor_type, car.vendor_params,c.credit_price, c.`auto_refund`, c.content_type + car.vendor_type, car.vendor_params,c.credit_price, c.`auto_refund`, c.content_type,c.use_limit_frequency + select + + from wx_rent_contract_agile_renevue_fees + + + + + + + + + delete from wx_rent_contract_agile_renevue_fees where agile_renevue_id = #{agileRenevueId} + + + + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractAgileRenevueItemMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractAgileRenevueItemMapper.xml new file mode 100644 index 000000000..780fcfe99 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxRentContractAgileRenevueItemMapper.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`renevue_id`,`begin_time`,`end_time`,`rate`, + `createtime`,`updatetime`,`is_free`,`is_father` + + + + where 1=1 + and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + and `rent_contract_id` = #{rentContractId} + and `renevue_id` = #{renevueId} + and `is_father` = #{isFather} + and `begin_time` <= #{validBeginTime} + and `end_time` >= #{validEndTime} + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + + delete from wx_rent_contract_agile_renevue_item where `renevue_id` = #{renevueId} + + + + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractAgileRenevueMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractAgileRenevueMapper.xml new file mode 100644 index 000000000..b89e6b466 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxRentContractAgileRenevueMapper.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`, + `time_period`,`time_unit`,`calcute_time`,`fees_create_rule`,`createtime`,`updatetime`,`limit_revenue` + + + + where 1=1 + and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + and `rent_contract_id` = #{rentContractId} + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml index d3a8ea0af..aa2b873dd 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractAgileUnDepositMapper.xml @@ -14,11 +14,12 @@ + - `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`setting_method`,`fees_id`,`price`,`price_unit`, - `time_period`,`time_unit`,`calcute_time`,`fees_create_rule`,`createtime`,`updatetime` + `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`setting_method`,`fees_id`, + `time_period`,`time_unit`,`calcute_time`,`fees_create_rule`,`createtime`,`updatetime`,`join_renevue_up` @@ -32,6 +33,7 @@ and `rent_contract_id` = #{rentContractId} and `fees_id` = #{feesId} + and `join_renevue_up` = #{joinRenevueUp} and id in @@ -54,11 +56,25 @@ + + + + update wx_rent_contract_agile_un_deposit set join_renevue_up = #{joinRenevueUp} where id = #{id} + + + + delete from wx_rent_contract_agile_un_deposit where id = #{id} and `tenant_id` = #{tenantId} + + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 242b6afa8..52c297733 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -23,16 +23,10 @@ - - - - - - @@ -40,8 +34,6 @@ - - @@ -50,12 +42,12 @@ `id`,`customers_id`,`tenant_id`,`parent_tenant_id`, `decimal_size`,`rental_start_date`,`rental_end_date`,`sign_date`, `filepath`,`status`,`contract_number`,`create_by`,`update_by`, - `day_price_calcute`,`month_average_days`,`free_period_remark`, - cashtype_content_lsit,`is_del`,`revenue_jumps_remark`, + `day_price_calcute`,`month_average_days`, + cashtype_content_lsit,`is_del`, `updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`, - `pay_account`,`lease`,`type`, - `start_date`,`end_date`,`from_id`,`end_contract_time`, - `apply_status`,`bank_name`,`fix_start_date`,`fix_end_date`,`create_by_name`,`update_by_name`, + `lease`,`type`, + `from_id`,`end_contract_time`, + `apply_status`,`create_by_name`,`update_by_name`, `rent_info`, `file_names`, shop_id_str, design_file,remark @@ -92,11 +84,8 @@ and `createtime` = #{createtime} and `link_person` = #{linkPerson} and `link_phone` = #{linkPhone} - and `pay_account` = #{payAccount} and `lease` = #{lease} and `type` = #{type} - and `start_date` = #{startDate} - and `end_date` = #{endDate} and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"')) and `day_price_calcute` = #{dayPriceCalcute} and `month_average_days` = #{monthAverageDays} diff --git a/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml index d76af906f..a588d0706 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml @@ -8,7 +8,6 @@ - @@ -21,7 +20,7 @@ - `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`rent_contract_id`,`property_contract_id`,`starttime`,`endtime`, + `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`rent_contract_id`,`starttime`,`endtime`, `sale_money`,`sale_money_valid`,`calcute_money`,`remark`,`is_confirm`,`is_calcute` @@ -35,7 +34,6 @@ and `parent_tenant_id` = #{parentTenantId} and `rent_contract_id` = #{rentContractId} - and `property_contract_id` = #{propertyContractId} and `starttime` >= #{starttime} and `starttime` = #{starttimeEqual} and `endtime` <= #{endtime}