From 14bf488b7cc3334687e62b277264ef87ff0dd71a Mon Sep 17 00:00:00 2001 From: winter <664946893@qq.com> Date: Sat, 7 Jun 2025 23:49:22 +0800 Subject: [PATCH] fix contract --- .../contract/WxAgileContractController.java | 216 +++++++------ .../contract/WxContractBaseController.java | 46 +-- .../contract/WxRentContractController.java | 5 +- .../controller/market/WxEnergyController.java | 31 -- .../market/WxFinanceController.java | 46 --- .../com/iformall/domain/po/WxAllBill.java | 2 + .../iformall/domain/po/WxRentContract.java | 23 +- .../iformall/enums/EnumAgileContractType.java | 4 +- .../iformall/enums/EnumEnergyMeterType.java | 13 +- .../com/iformall/mapper/WxAllBillMapper.java | 2 + .../iformall/mapper/WxRentContractMapper.java | 3 + .../service/WxAgileContractService.java | 17 +- .../service/WxRentContractService.java | 2 +- .../service/helper/WxEnergyHelper.java | 133 +++++--- .../impl/WxAgileContractServiceImpl.java | 188 ++++++----- .../service/impl/WxEnergyServiceImpl.java | 306 +++++++++--------- .../service/impl/WxFlowServiceImpl.java | 139 ++------ .../impl/WxRentContractServiceImpl.java | 36 ++- .../main/resources/mapper/WxAllBillMapper.xml | 4 + .../resources/mapper/WxRentContractMapper.xml | 13 +- 20 files changed, 606 insertions(+), 623 deletions(-) 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 6a262bd98..ea6cf5fe2 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java @@ -84,7 +84,6 @@ 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) { @@ -95,15 +94,6 @@ 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,8 +128,58 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(map); } + @GetMapping("customerTypes") + public ResultData customerTypes() { + Map tmap = new HashMap(); + for (EnumShopUsersPrincipalType t : EnumShopUsersPrincipalType.values()) { + tmap.put(t.getCode(), t.getMessage()); + } + return new ResultData(tmap); + } + + @ApiOperation("分页列表接口") + @GetMapping("contractCustomerList") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData contractCustomerList(@ModelAttribute WxContractCustomers record, Integer pageNum, Integer pageSize) { + if (record == null) record = new WxContractCustomers(); + record.updateTenantInfo(getTenantInfo()); + record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); + return new ResultData(wxAgileContractService.getContractCustomersList(record, pageNum, pageSize)); + } + + /** + * 修改新增客户 + */ + @PostMapping("saveCustomer") + public ResultData saveCustomer(@RequestBody WxRentContract record) { + record.updateTenantInfo(this.getTenantInfo()); + try { + wxAgileContractService.setCustomers(record,EnumContractCustomersStatus.FORMUL); + }catch(Exception e) { + logger.error("saveCustomer error.",e); + return new ResultData(Result.ERROR,e.getMessage()); + } + + return new ResultData(record); + } + + @GetMapping("contractTypes") + public ResultData contractTypes() { + Map tmap = new HashMap(); + for (EnumAgileContractType t : EnumAgileContractType.values()) { + tmap.put(t.getCode(), t.getMessage()); + } + return new ResultData(tmap); + } + /** * 新增/修改第一步 + * + * 生效中合同修改. + * 思路:创建影子数据,等审核成功或者修改生效时,把影子数据更新到正式数据。正式数据删除,影子数据ID变更为正式数据的ID + * * @param wxRentContract * @return */ @@ -148,11 +188,21 @@ public class WxAgileContractController extends WxContractBaseController { MallUserInfo user = getUser(); wxRentContract.updateTenantInfo(user); - //如果是修改,并且合同是生效的,则不允许 + //如果是修改 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 if(isValidContract(r)){ + //如果当前合同存在影子合同,则不让修改,直接修改影子合同即可 + WxRentContract rc = wxAgileContractService.findYingZiContract(r.getId(), r); + if (null != rc) { + return new ResultData(Result.ERROR,"已存在影子合同,请直接修改影子合同"); + } + //把源合同的款项设置复制过来 + //wxAgileContractService.copyContractFees(r, user); + wxRentContract.setOrginId(r.getId()); + wxRentContract.setId(null); }else { return new ResultData(Result.ERROR,"该状态不允许修改"); } @@ -163,7 +213,6 @@ public class WxAgileContractController extends WxContractBaseController { }catch(Exception e) { return new ResultData(Result.ERROR,e.getMessage()); } - return wxAgileContractService.saveOrUpdate(wxRentContract, user); } @@ -222,46 +271,6 @@ public class WxAgileContractController extends WxContractBaseController { } } - /** - * 生效中合同修改 - * @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,"该状态不允许修改"); - } - - 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()) { @@ -292,6 +301,28 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(wxAgileContractService.selectById(wxRentContract.getId())); } + @PostMapping("delete") + public ResultData delete(@RequestBody WxRentContract wxRentContract) { + WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); + if (null == rentContract) { + return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同"); + } + + if(rentContract.getStatus().intValue() == EnumRentContractStatus.DRAFT.getCode().intValue() + || rentContract.getStatus().intValue() == EnumRentContractStatus.UNWRITE.getCode().intValue()) { + }else { + return new ResultData(Result.ERROR,"该状态不允许删除"); + } + + //Long orginId = rentContract.getOrginId(); + //if (null != orginId && (!orginId.equals(rentContract.getId()))) { + //}else { + // return new ResultData(Result.ERROR, "影子合同才能删除"); + //} + wxAgileContractService.deleteContract(rentContract.getId(),rentContract); + return new ResultData(); + } + /** * 押金科目 @@ -335,15 +366,6 @@ 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()); @@ -447,16 +469,13 @@ public class WxAgileContractController extends WxContractBaseController { @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()); + if (null == unDeposit.getId()) { + return new ResultData(Result.ERROR,"参数无效"); } + WxRentContractAgileUnDeposit aunDeposit = wxAgileContractService.getUnDepositById(unDeposit.getId(),unDeposit); + try { - wxAgileContractService.deleteUnDeposit(unDeposit); + wxAgileContractService.deleteUnDeposit(aunDeposit); }catch(Exception e) { return new ResultData(Result.ERROR,"保存账单失败:"+e.getMessage()); } @@ -481,12 +500,6 @@ public class WxAgileContractController extends WxContractBaseController { renevue.setId(_ore.getId()); } - //如果是生效的合同变更 - WxRentContract r = wxAgileContractService.selectById(renevue.getRentContractId()); - if (isValidContract(r)) { - wxAgileContractService.endContractRenevueBill(renevue); - } - try { wxAgileContractService.saveRenuvue(renevue); }catch(Exception e) { @@ -495,6 +508,18 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(); } + /** + * 查询非押金 + */ + @GetMapping("getRenevue") + public ResultData getRenevue(@ModelAttribute WxRentContractAgileRenevue renevue) { + renevue.updateTenantInfo(getTenantInfo()); + if (null == renevue.getRentContractId()) { + return new ResultData(Result.ERROR,"参数无效"); + } + return new ResultData(wxAgileContractService.findRenevueByContract(renevue.getRentContractId(),renevue)); + } + /** * 设置联营扣点跳点 */ @@ -505,13 +530,6 @@ public class WxAgileContractController extends WxContractBaseController { 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) { @@ -520,6 +538,18 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(); } + /** + * 查询非押金 + */ + @GetMapping("getRenevueJump") + public ResultData getRenevueJump(@ModelAttribute WxRentContractRevenueJump renevueJump) { + renevueJump.updateTenantInfo(getTenantInfo()); + if (null == renevueJump.getRentContractId()) { + return new ResultData(Result.ERROR,"参数无效"); + } + return new ResultData(wxAgileContractService.findRevenueJumpList(renevueJump)); + } + /** * 设置款项是否参与取高 */ @@ -529,7 +559,7 @@ public class WxAgileContractController extends WxContractBaseController { WxRentContractAgileUnDeposit und = wxAgileContractService.getUnDepositById(unDeposit.getId(),unDeposit); //计算周期等需要和扣点设置一致 - WxRentContractAgileRenevue _ore = wxAgileContractService.findRenevueByContract(unDeposit.getRentContractId(),unDeposit); + WxRentContractAgileRenevue _ore = wxAgileContractService.findRenevueByContract(und.getRentContractId(),und); if (null == _ore) { return new ResultData(Result.ERROR,"请先设置扣点信息"); } @@ -543,14 +573,8 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(Result.ERROR,"当前款项费用生成规则和扣点设置不一致。"); } - //如果是生效的合同变更 - WxRentContract r = wxAgileContractService.selectById(_ore.getRentContractId()); - if (isValidContract(r)) { - wxAgileContractService.endContractRenevueBill(_ore); - } - try { - wxAgileContractService.setJoinRenevueUp(unDeposit); + wxAgileContractService.setJoinRenevueUp(und); }catch(Exception e) { return new ResultData(Result.ERROR,"保存信息失败:"+e.getMessage()); } @@ -570,18 +594,6 @@ public class WxAgileContractController extends WxContractBaseController { return new ResultData(wxAllBillService.listAsPage(record, pageNum, pageSize)); } - @ApiOperation("分页列表接口") - @GetMapping("contractCustomerList") - @ApiImplicitParams({ - @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), - @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) - public ResultData contractCustomerList(@ModelAttribute WxContractCustomers record, Integer pageNum, Integer pageSize) { - if (record == null) record = new WxContractCustomers(); - record.updateTenantInfo(getTenantInfo()); - record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); - return new ResultData(wxAgileContractService.getContractCustomersList(record, pageNum, pageSize)); - } - /** * 续签 */ 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 45c32719f..ed0a81ef3 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java @@ -52,31 +52,15 @@ public class WxContractBaseController extends BaseController{ private WxRentContractService wxRentContractService; - protected Map generateFlowParams(WxContractCustomers contractCustomers,EnumFlowKey flowType,EnumFlowContractType contractType,String remark,Long contractId,Long wholeProperyId) { + protected Map generateFlowParams(WxContractCustomers contractCustomers,EnumFlowKey flowType,String remark,Long contractId) { Map map = new HashMap(); map.put("businessType", flowType.getCode()); map.put("remark", remark); - //租金+物业合同时用到 - if (null != wholeProperyId) { - map.put("businessId", String.valueOf(contractId)+"_RP_"+String.valueOf(wholeProperyId)); - map.put("wholeProperyId", String.valueOf(wholeProperyId)); - }else { - map.put("businessId", String.valueOf(contractId)); - } List variablesList = new ArrayList(); - Map contractTypeMap = new HashMap(); - contractTypeMap.put("key","contractType"); - contractTypeMap.put("value",String.valueOf(contractType.getCode())); - variablesList.add(contractTypeMap); Map contractNumberMap = new HashMap(); contractNumberMap.put("key","contractNumber"); - //租金+物业合同时用到 - if (null != wholeProperyId) { - contractNumberMap.put("value", String.valueOf(contractId)+"_RP_"+String.valueOf(wholeProperyId)); - }else { - contractNumberMap.put("value", String.valueOf(contractId)); - } + contractNumberMap.put("value", String.valueOf(contractId)); variablesList.add(contractNumberMap); Map rentNameMap = new HashMap(); @@ -91,7 +75,11 @@ public class WxContractBaseController extends BaseController{ protected boolean rentContractHasWorkFlow(WxRentContract wxRentContract) { WxFlowModel wxFlowModel = new WxFlowModel(); - wxFlowModel.setFlowType(EnumFlowKey.NEW_RENT_CONTRACT.getCode()); + if (wxRentContract.isYingZiContract()) { + wxFlowModel.setFlowType(EnumFlowKey.NEW_EDIT_VALID_CONTRACT.getCode()); + }else { + wxFlowModel.setFlowType(EnumFlowKey.NEW_RENT_CONTRACT.getCode()); + } wxFlowModel.updateTenantInfo(wxRentContract); List flows = wxFlowService.getModelBybusiness(wxFlowModel); if (null != flows && flows.size() > 0) { @@ -100,17 +88,6 @@ 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) { @@ -214,8 +191,15 @@ public class WxContractBaseController extends BaseController{ throw new MallinkException(Result.ERROR, "房间面积不能为0。"); } } - contractValidShop(rentContract,rentContract.getId(),rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), + + //如果是影子数据修改,则要排除源合同 + if (rentContract.isYingZiContract()) { + contractValidShop(rentContract,rentContract.getOrginId(),rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), + rentContract.getRentShopArea(),true); + }else { + contractValidShop(rentContract,rentContract.getId(),rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), rentContract.getRentShopArea(),true); + } } } 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 8674bf896..e3b1a0870 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -171,7 +171,7 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(Result.ERROR,e.getMessage()); } - wxRentContractService.updateRentContractStatus(wxRentContract.getId(),false); + wxRentContractService.updateRentContractStatus(wxRentContract.getId()); return new ResultData(Result.SUCCESS,"合同生效成功!"); } @@ -194,12 +194,11 @@ public class WxRentContractController extends WxContractBaseController { } WxContractCustomers customers = wxAgileContractService.findCustomers(rentContract, rentContract.getCustomersId()); - rentContract.setFlowParams(generateFlowParams(customers,EnumFlowKey.NEW_RENT_CONTRACT, EnumFlowContractType.RENT, wxRentContract.getRemark(), wxRentContract.getId(),null)); + rentContract.setFlowParams(generateFlowParams(customers,EnumFlowKey.NEW_RENT_CONTRACT, wxRentContract.getRemark(), wxRentContract.getId())); return wxRentContractService.apply(rentContract,user); } @GetMapping("getPayAccountInfo") - @SystemControllerLog(description = "租赁合同-获取甲方账户") public ResultData getPayAccountInfo() { logger.debug("[" + getIpAddr() + "] WxRentContractController::updateRentContractStatus"); WxPayAccountBill payAccountBill = payAccountBillService.getByTenantInfo(getTenantInfo()); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java index 2bbcef4b1..21445780e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxEnergyController.java @@ -625,37 +625,6 @@ public class WxEnergyController extends BaseController { return new ResultData(); } -// @ApiOperation("查询科目计量单位列表") -// @GetMapping("feesCalcuteUnitList") -// public ResultData typeCalcuteUnitList(Integer billType) { -// List enumList = EnumBillAllType.getCalucuteUnites(billType); -// if (null != enumList) { -// Map retMap = new HashMap(); -// for (int i = 0 ; i < enumList.size(); i++) { -// EnumFeesStandardsCalcuteUnit cu = enumList.get(i); -// retMap.put(cu.getCode(), cu.getMessage()); -// } -// return new ResultData(retMap); -// } -// return new ResultData(); -// } -// -// @ApiOperation("查询科目计算时间单位列表") -// @GetMapping("feesTimeUnitList") -// public ResultData typeTimeUnitList(Integer billType) { -// List enumList = EnumBillAllType.getTimeUnites(billType); -// if (null != enumList) { -// Map retMap = new HashMap(); -// for (int i = 0 ; i < enumList.size(); i++) { -// EnumFeesStandardsTimeUnit cu = enumList.get(i); -// retMap.put(cu.getCode(), cu.getMessage()); -// } -// return new ResultData(retMap); -// } -// return new ResultData(); -// } - - @ApiOperation("抄表数据分页列表接口") @GetMapping("readingList") @ApiImplicitParams({ diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java index 8b8ae4498..a37d8ec09 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java @@ -116,51 +116,6 @@ public class WxFinanceController extends BaseController { return new ResultData(page); } -// @ApiOperation("其他费用科目列表") -// @GetMapping("otherFeesList") -// @ApiImplicitParams({ -// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), -// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), -// }) -// public ResultData otherFeesList(@ModelAttribute WxFinanceFees record, Integer pageNum, Integer pageSize) { -// record.updateTenantInfo(getTenantInfo()); -// record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); -// record.setCashierType(EnumFinanceCashierType.RECEIVE.getCode()); -// PageInfo page = wxEnergyService.feesListAsPage(record, pageNum, pageSize,false); -// return new ResultData(page); -// } -// -// @ApiOperation("预收科目列表") -// @GetMapping("advanceFeesList") -// @ApiImplicitParams({ -// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), -// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), -// }) -// public ResultData advanceTypeList(@ModelAttribute WxFinanceFees record, Integer pageNum, Integer pageSize) { -// record.updateTenantInfo(getTenantInfo()); -// record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); -// record.setBillType(EnumBillAllType.ADVANCE.getCode()); -// record.setCashierType(EnumFinanceCashierType.RECEIVE.getCode()); -// PageInfo page = wxEnergyService.feesListAsPage(record, pageNum, pageSize,true); -// return new ResultData(page); -// } -// -// @ApiOperation("临时付款科目列表") -// @GetMapping("toPayMerchantFeesList") -// @ApiImplicitParams({ -// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), -// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), -// }) -// public ResultData toPayMerchantFeesList(@ModelAttribute WxFinanceFees record, Integer pageNum, Integer pageSize) { -// record.updateTenantInfo(getTenantInfo()); -// record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); -// record.setBillType(EnumBillAllType.TEMP_TO_PAYMERCHANT.getCode()); -// record.setCashierType(EnumFinanceCashierType.PAY.getCode()); -// PageInfo page = wxEnergyService.feesListAsPage(record, pageNum, pageSize,true); -// return new ResultData(page); -// } - - @ApiOperation("费用区间列表") @PostMapping("saveFees") public ResultData saveFees(@RequestBody WxFinanceFees record) { @@ -186,7 +141,6 @@ public class WxFinanceController extends BaseController { return new ResultData(); } - @ApiOperation("支付方式列表") @GetMapping("payWayList") @ApiImplicitParams({ 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 058408051..60252275c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java @@ -397,4 +397,6 @@ public class WxAllBill extends TenantEntity { private List cusNameShopIdList; @TableField(exist = false) private String queryShopIdStr; + @TableField(exist = false) + private Long orginContractId; } 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 ee84996b7..ba8744e1e 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.iformall.common.SortColumn; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.RentContractFreePeriodVo; +import com.iformall.enums.EnumAgileContractType; import com.iformall.enums.EnumPriceUnit; import com.iformall.enums.EnumRentAgileType; import com.iformall.enums.EnumRentContractAdjustPeriod; @@ -116,6 +117,14 @@ public class WxRentContract extends TenantEntity { private String shopIdStr; @io.swagger.annotations.ApiModelProperty(value = "类型EnumAgileContractType", name = "type") private Integer type; + @TableField(exist = false) + private String typeName; + public String getTypeName() { + if (null != type) { + return EnumAgileContractType.getEnum(type).getMessage(); + } + return null; + } @io.swagger.annotations.ApiModelProperty(value = "审核状态, 0未审核 1审核中 2审核通过 3驳回EnumRentContractAppStatus", name = "applyStatus") private Integer applyStatus; @io.swagger.annotations.ApiModelProperty(value = "终止时间", name = "endContractTime") @@ -128,6 +137,8 @@ public class WxRentContract extends TenantEntity { private Integer dayPriceCalcute; @io.swagger.annotations.ApiModelProperty(value = "每月平均天数", name = "monthAverageDays") private Integer monthAverageDays; + @io.swagger.annotations.ApiModelProperty(value = "来源ID,用于履约中合同修改影子数据", name = "orginId") + private Long orginId; public List shopIdsByRentInfo() { List shopList = Lists.newArrayList(); @@ -225,12 +236,16 @@ public class WxRentContract extends TenantEntity { } } + public boolean isYingZiContract() { + if (null != orginId && (!orginId.equals(id))) { + return true; + } + return false; + } + //是否有工作流 1:有 0:无" @TableField(exist = false) private Integer flowHas; - //是否有修改履约中工作流 1:有 0:无" - @TableField(exist = false) - private Integer flowHasValidEdit; //联营扣点跳点设置 @TableField(exist = false) private List revenueJumps; @@ -241,8 +256,6 @@ public class WxRentContract extends TenantEntity { @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) diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumAgileContractType.java b/mallinkService/src/main/java/com/iformall/enums/EnumAgileContractType.java index 65d26c270..84a2f50fa 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumAgileContractType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumAgileContractType.java @@ -6,9 +6,9 @@ package com.iformall.enums; public enum EnumAgileContractType { - AREA(1, "面积"), + AREA(1, "面积计费"), RENEVUE(2, "联营扣点"), - RENEVUE_UP(3, "面积与联营扣点取高") + RENEVUE_UP(3, "面积计费与联营扣点取高") ; public static EnumAgileContractType getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumEnergyMeterType.java b/mallinkService/src/main/java/com/iformall/enums/EnumEnergyMeterType.java index e7546d026..8a01be322 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumEnergyMeterType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumEnergyMeterType.java @@ -6,9 +6,9 @@ package com.iformall.enums; public enum EnumEnergyMeterType { - WATER(1,"水表",EnumBillDailyType.WATER.getCode()), - POWER(2,"电表",EnumBillDailyType.POWER.getCode()), - AIR_CONDITIONING(3, "燃气表",EnumBillDailyType.AIR_CONDITIONING.getCode()), + WATER(1,"水表"), + POWER(2,"电表"), + AIR_CONDITIONING(3, "燃气表") ; public static EnumEnergyMeterType getEnum(Integer code) { @@ -22,12 +22,10 @@ public enum EnumEnergyMeterType { private Integer code; private String message; - private Integer billDailyType; - EnumEnergyMeterType(Integer code, String message,Integer billDailyType) { + EnumEnergyMeterType(Integer code, String message) { this.code = code; this.message = message; - this.billDailyType = billDailyType; } public Integer getCode() { @@ -38,7 +36,4 @@ public enum EnumEnergyMeterType { return message; } - public Integer getBillDailyType() { - return billDailyType; - } } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java index cd594a975..5abb40a9d 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java @@ -57,5 +57,7 @@ public interface WxAllBillMapper extends CommonMapper { void transferCusName(WxAllBill wxBillRent); BigDecimal getReceivePaySum(WxAllBill wxBillRent); + + void updateContractId(@Param("oldContractId")Long oldContractId,@Param("newContractId")Long newContractId,@Param("tenantId")String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java index 8855c922a..f18fc2012 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java @@ -40,4 +40,7 @@ public interface WxRentContractMapper extends CommonMapper void setEndContractTime(WxRentContract rentContract); List findToEndContractList(WxRentContract rentContract); + + void deleteContract(@Param("tenantId") String tenantId,@Param("id") Long id); + void updateContractId(@Param("tenantId") String tenantId,@Param("oldId") Long oldId,@Param("newId") Long newId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java index 7ae04b87c..d871b7304 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java @@ -10,9 +10,11 @@ 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.WxRentContractRevenueJump; import com.iformall.domain.po.WxRentContractRevenueSales; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxRentContractYearsVo; +import com.iformall.enums.EnumContractCustomersStatus; import java.math.BigDecimal; import java.util.Date; @@ -25,8 +27,12 @@ public interface WxAgileContractService { PageInfo getRentContractList(WxRentContract record, Integer pageIndex, Integer pageSize); WxRentContract selectById(Long id); + + void setCustomers(WxRentContract record,EnumContractCustomersStatus status); ResultData saveOrUpdate(WxRentContract record,MallUserInfo user); + + WxRentContract findYingZiContract(Long orginId,TenantEntity tenantEntity); void saveDeposit(WxRentContract wxRentContract,MallUserInfo user); @@ -54,6 +60,8 @@ public interface WxAgileContractService { void saveRenuvueJumps(WxRentContract contract); + List findRevenueJumpList(WxRentContractRevenueJump jump); + void setJoinRenevueUp(WxRentContractAgileUnDeposit unDeposit); List findRenevueItemListByContract(Long rentContractId,TenantEntity tenantEntity); @@ -78,8 +86,9 @@ public interface WxAgileContractService { 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); + //void copyContractFees(Long oriContractId,WxRentContract destcontract,MallUserInfo user); + //void endContractDespoitBill(WxRentContract wxRentContract,MallUserInfo user); + //void endContractUnDespositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user); + //void endContractRenevueBill(WxRentContractAgileRenevue renevue); + void deleteContract(Long id,TenantEntity tenantEntity); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index a0d9282f3..b82c08bac 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -65,7 +65,7 @@ public interface WxRentContractService { PageInfo getRenevueContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); - ResultData updateRentContractStatus(Long id,boolean buildPropertyBill); + ResultData updateRentContractStatus(Long id); List getShopIds(WxRentContract record) ; diff --git a/mallinkService/src/main/java/com/iformall/service/helper/WxEnergyHelper.java b/mallinkService/src/main/java/com/iformall/service/helper/WxEnergyHelper.java index 830f99475..3ab3f0039 100644 --- a/mallinkService/src/main/java/com/iformall/service/helper/WxEnergyHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/helper/WxEnergyHelper.java @@ -76,6 +76,9 @@ public class WxEnergyHelper { addComponent(retList, "铺位面积", "{#shopArea#}"); } + addComponent(retList, "用户水表", "{#userWaterMeters#}"); + addComponent(retList, "用户电表", "{#userPowerMeters#}"); + addComponent(retList, "用户燃气表", "{#userGasMeters#}"); return retList; } @@ -94,7 +97,7 @@ public class WxEnergyHelper { } private String replaceFormulaData(String formula,BigDecimal totalArea,WxShop shop,Map buildingAreaMap, - Map floorAreaMap,Map meterNumberMap) { + Map floorAreaMap,Map meterNumberMap,BigDecimal userWaterNumbers,BigDecimal userPowerNumbers,BigDecimal userGasNumbers) { if (StringUtils.isBlank(formula)) { return null; } @@ -158,6 +161,10 @@ public class WxEnergyHelper { formula = formula.replaceAll("#shopPublicRax#", shop.getPulicRate()); } formula = formula.replaceAll("#shopArea#", shop.getOperationArea()); + + formula = formula.replaceAll("#userWaterMeters#", userWaterNumbers.toPlainString()); + formula = formula.replaceAll("#userPowerMeters#", userPowerNumbers.toPlainString()); + formula = formula.replaceAll("#userGasMeters#", userGasNumbers.toPlainString()); return formula; } @@ -176,6 +183,9 @@ public class WxEnergyHelper { } formula = formula.replaceAll("#shopPublicRax#", shopPulicRax); formula = formula.replaceAll("#shopArea#", shopArea); + formula = formula.replaceAll("#userWaterMeters#", "1"); + formula = formula.replaceAll("#userPowerMeters#", "1"); + formula = formula.replaceAll("#userGasMeters#", "1"); FormulaParser.evaluate(formula); } @@ -194,60 +204,79 @@ public class WxEnergyHelper { * @return */ public String calcuteMoney(StringBuffer sb,BigDecimal totalArea,WxShop shop,WxEnergyFeesTime time,WxFinanceFees fees, WxFeesCalcuteShop shopfee, - List userMeterList,Map> summaryMeterMap,Map buildingAreaMap,Map floorAreaMap) { + List waterMeterList,List powerMeterList,List gasMeterList,Map> summaryMeterMap,Map buildingAreaMap, + Map floorAreaMap) { if (StringUtils.isBlank(shopfee.getPrice())) { return "0"; } -// //如果是公摊,或者非能源费用,则用公式计算 -// if (shopfee.getIsPublic() == EnumYesOrNo.YES.getCode() || fees.getBillType() != EnumBillAllType.DAILY.getCode()) { -// //替代占位符为真实数据 -// //公摊总表数据,根据公摊总表下的公共表来查询所有的读数 -// Map meterNumberMap = null; -// if (null != summaryMeterMap) { -// meterNumberMap = new HashMap(); -// for (Iterator it = summaryMeterMap.keySet().iterator(); it.hasNext();) { -// Long sumaryMeterId = it.next(); -// List childmids = summaryMeterMap.get(sumaryMeterId); -// //查询子表的总读数 -// WxEnergyMeterReading mrq = new WxEnergyMeterReading(); -// mrq.updateTenantInfo(shopfee); -// mrq.setMeterIds(childmids); -// mrq.setStartTime(time.getStartTime()); -// mrq.setEndTime(time.getEndTime()); -// mrq.setIsConfirm(EnumYesOrNo.YES.getCode()); -// BigDecimal totalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); -// if (null == totalNumber || totalNumber.compareTo(new BigDecimal(0)) <= 0 ) { -// totalNumber = new BigDecimal(0); -// } -// meterNumberMap.put(sumaryMeterId, totalNumber); -// } -// } -// String formula = replaceFormulaData(shopfee.getFormula(),totalArea,shop,buildingAreaMap,floorAreaMap,meterNumberMap); -// if (null != formula) { -// return new BigDecimal(FormulaParser.evaluate(formula)).multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); -// } -// return "0"; -// }else { -// //如果是用户能耗 -// if (null == userMeterList || userMeterList.size() <= 0 ) { -// return "0"; -// } -// //根据表,区间的开始日期,结束日期来查询抄表数据。 -// WxEnergyMeterReading mrq = new WxEnergyMeterReading(); -// mrq.updateTenantInfo(shopfee); -// mrq.setMeterIds(userMeterList); -// mrq.setStartTime(time.getStartTime()); -// mrq.setEndTime(time.getEndTime()); -// mrq.setIsConfirm(EnumYesOrNo.YES.getCode()); -// BigDecimal totalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); -// if (null == totalNumber || totalNumber.compareTo(new BigDecimal(0)) <= 0 ) { -// return "0"; -// } -// sb.append("表总度数"+totalNumber.toPlainString()+",单价:"+shopfee.getPrice()); -// return totalNumber.multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); -// -// } -return "0"; + + //公摊总表数据,根据公摊总表下的公共表来查询所有的读数 + Map meterNumberMap = null; + if (null != summaryMeterMap) { + meterNumberMap = new HashMap(); + for (Iterator it = summaryMeterMap.keySet().iterator(); it.hasNext();) { + Long sumaryMeterId = it.next(); + List childmids = summaryMeterMap.get(sumaryMeterId); + //查询子表的总读数 + WxEnergyMeterReading mrq = new WxEnergyMeterReading(); + mrq.updateTenantInfo(shopfee); + mrq.setMeterIds(childmids); + mrq.setStartTime(time.getStartTime()); + mrq.setEndTime(time.getEndTime()); + mrq.setIsConfirm(EnumYesOrNo.YES.getCode()); + BigDecimal totalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); + if (null == totalNumber || totalNumber.compareTo(new BigDecimal(0)) <= 0 ) { + totalNumber = new BigDecimal(0); + } + meterNumberMap.put(sumaryMeterId, totalNumber); + } + } + + //用户表数据 + //根据表,区间的开始日期,结束日期来查询抄表数据。 + WxEnergyMeterReading mrq = new WxEnergyMeterReading(); + mrq.updateTenantInfo(shopfee); + mrq.setStartTime(time.getStartTime()); + mrq.setEndTime(time.getEndTime()); + mrq.setIsConfirm(EnumYesOrNo.YES.getCode()); + BigDecimal waterTotalNumber = null; + if (null != waterMeterList && waterMeterList.size() > 0 ) { + mrq.setMeterIds(waterMeterList); + waterTotalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); + } + if (null == waterTotalNumber || waterTotalNumber.compareTo(new BigDecimal(0)) <= 0 ) { + waterTotalNumber = new BigDecimal(0); + } + waterTotalNumber = waterTotalNumber.multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP); + //sb.append("用户水表总度数"+waterTotalNumber.toPlainString()+",单价:"+shopfee.getPrice()); + + BigDecimal powerTotalNumber = null; + if (null != powerMeterList && powerMeterList.size() > 0 ) { + mrq.setMeterIds(powerMeterList); + powerTotalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); + } + if (null == powerTotalNumber || powerTotalNumber.compareTo(new BigDecimal(0)) <= 0 ) { + powerTotalNumber = new BigDecimal(0); + } + powerTotalNumber = powerTotalNumber.multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP); + //sb.append("用户电表总度数"+powerTotalNumber.toPlainString()+",单价:"+shopfee.getPrice()); + + BigDecimal gasTotalNumber = null; + if (null != gasMeterList && gasMeterList.size() > 0 ) { + mrq.setMeterIds(gasMeterList); + gasTotalNumber = wxEnergyMeterReadingMapper.findNumberSum(mrq); + } + if (null == gasTotalNumber || gasTotalNumber.compareTo(new BigDecimal(0)) <= 0 ) { + gasTotalNumber = new BigDecimal(0); + } + gasTotalNumber = gasTotalNumber.multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP); + + + String formula = replaceFormulaData(shopfee.getFormula(),totalArea,shop,buildingAreaMap,floorAreaMap,meterNumberMap,waterTotalNumber,powerTotalNumber,gasTotalNumber); + if (null != formula) { + return new BigDecimal(FormulaParser.evaluate(formula)).multiply(new BigDecimal(shopfee.getPrice())).setScale(2,BigDecimal.ROUND_HALF_UP).toPlainString(); + } + return "0"; } 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 e4e8d854d..7910967b5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java @@ -263,7 +263,7 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { List shopList = record.shopIdsByRentInfo(); setShops(record,shopList); //关联客户 - setCustomers(record); + setCustomers(record,EnumContractCustomersStatus.TEMP); try { record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); record.setStatus(EnumRentContractStatus.DRAFT.getCode()); @@ -280,8 +280,26 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { return new ResultData(Result.SUCCESS, "保存合同信息成功", record); } + @Override + public WxRentContract findYingZiContract(Long orginId,TenantEntity tenantEntity) { + try { + WxRentContract contract = new WxRentContract(); + contract.updateTenantInfo(tenantEntity); + contract.setOrginId(orginId); + List clist = wxRentContractMapper.findList(contract); + if (null != clist && clist.size() > 0 ) { + return clist.get(0); + } + return null; + } catch (Exception e) { + logger.error("保存合同信息失败,e:" + e.getMessage(),e); + throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); + } + + } - public void setCustomers(WxRentContract record) { + @Override + public void setCustomers(WxRentContract record,EnumContractCustomersStatus status) { WxContractCustomers cq = new WxContractCustomers(); cq.updateTenantInfo(record); cq.setPrincipalType(record.getCustomerType()); @@ -304,7 +322,7 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { cus.setLinkPerson(record.getCustomerLinkPerson()); cus.setCreateDate(new Date()); cus.setUpdateDate(new Date()); - cus.setStatus(EnumContractCustomersStatus.TEMP.getCode()); + cus.setStatus(status.getCode()); wxContractCustomersMapper.insert(cus); } record.setCustomersId(cus.getId()); @@ -930,6 +948,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { } } + @Override + public List findRevenueJumpList(WxRentContractRevenueJump jump) { + jump.setSortColumn("min_money asc"); + return wxRentContractRevenueJumpMapper.findList(jump); + } + @Override public void setJoinRenevueUp(WxRentContractAgileUnDeposit unDeposit) { wxRentContractAgileUnDepositMapper.updateJoinRenevueUp(unDeposit); @@ -1212,7 +1236,7 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { @Transactional(rollbackFor = {Exception.class}) @Override public void transfer(WxRentContract rentContract,MallUserInfo user) { - this.setCustomers(rentContract); + this.setCustomers(rentContract,EnumContractCustomersStatus.TEMP); rentContract.setUpdatetime(new Date()); rentContract.setUpdateBy(user.getId()); rentContract.setUpdateByName(user.getName()); @@ -1304,89 +1328,85 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { 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); + public void deleteContract(Long id, TenantEntity tenantEntity) { + wxRentContractMapper.deleteById(id); } - @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 copyContractFees(Long oriContractId,WxRentContract destcontract,MallUserInfo user) { +// +// //原来所有的非押金,扣点都默认设置为按合同,然后时间设置为合同开始时间和结束时间,单价为0 +// WxRentContractAgileUnDeposit udq = new WxRentContractAgileUnDeposit(); +// udq.updateTenantInfo(destcontract); +// udq.setRentContractId(oriContractId); +// 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 udi = generateUnDepositItem(idWorker, destcontract, 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()); +// } +// } +// } - @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); - } +// @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/WxEnergyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxEnergyServiceImpl.java index 9d483bede..2784c8bb5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxEnergyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxEnergyServiceImpl.java @@ -16,6 +16,7 @@ import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxShopBillVo; import com.iformall.enums.EnumEnergyMeterPhysicsType; import com.iformall.enums.EnumEnergyMeterShopFloorType; +import com.iformall.enums.EnumEnergyMeterType; import com.iformall.enums.EnumFeesType; import com.iformall.enums.EnumFinanceCashierType; import com.iformall.enums.EnumYesOrNo; @@ -1219,149 +1220,166 @@ public class WxEnergyServiceImpl implements WxEnergyService { * */ public void generateCalcuteResult(WxFinanceFees fees,WxEnergyReadingCalcute record,List shopIds) { -// final IdWorker idWorker = IdWorker.get(); -// WxShop shq = new WxShop(); -// shq.updateTenantInfo(record); -// shq.setIds(shopIds); -// Map shopMap = wxShopService.findShopMap(shq); -// // 总共面积 -// BigDecimal totalArea = new BigDecimal(0); -// // 楼栋的面积 -// Map buildingAreaMap = null; -// //楼层 -// Map floorAreaMap = null; -// WxMallFloor fq = new WxMallFloor(); -// fq.updateTenantInfo(record); -// List floorList = wxMallFloorService.getBudingFloorList(fq, null); -// if (null != floorList && floorList.size() > 0 ) { -// floorAreaMap = new HashMap(); -// buildingAreaMap = new HashMap(); -// for (int i = 0 ; i < floorList.size() ; i ++) { -// WxMallFloor floor = floorList.get(i); -// if (null != floor.getOperatingArea()) { -// floorAreaMap.put(floor.getId(), floor.getOperatingArea()); -// BigDecimal bud = buildingAreaMap.get(floor.getBuildingId()); -// if (null == bud) { -// bud = new BigDecimal(0); -// } -// bud = bud.add(floor.getOperatingArea()); -// buildingAreaMap.put(floor.getBuildingId(), bud); -// totalArea = totalArea.add(floor.getOperatingArea()); -// } -// } -// } -// //查询公摊表 -// Map> summaryMeterMap = null; -// if (fees.getIsPublic() == EnumYesOrNo.YES.getCode()) { -// WxEnergyMeter sumq = new WxEnergyMeter(); -// sumq.updateTenantInfo(record); -// sumq.setType(fees.getType()); -// sumq.setPhysicsType(EnumEnergyMeterPhysicsType.SUMMARY.getCode()); -// List sumeterList = wxEnergyMeterMapper.findList(sumq); -// if (null != sumeterList && sumeterList.size() > 0 ) { -// summaryMeterMap = new HashMap>(); -// for (int i = 0 ; i < sumeterList.size(); i ++) { -// WxEnergyMeter summaryMeter = sumeterList.get(i); -// //查询总表下的子表 -// WxEnergyMeterChild mcq = new WxEnergyMeterChild(); -// mcq.updateTenantInfo(record); -// mcq.setParentMeterId(summaryMeter.getId()); -// List childMeterIds = wxEnergyMeterChildMapper.findChildMeterIdList(mcq); -// if (null != childMeterIds && childMeterIds.size() > 0 ) { -// summaryMeterMap.put(summaryMeter.getId(), childMeterIds); -// } -// } -// } -// } -// -// List resultList = new ArrayList(); -// for (int i = 0 ; i < shopIds.size(); i ++) { -// Long shopId= shopIds.get(i); -// WxShop shop = shopMap.get(shopId); -// -// //查询用户表 -// WxEnergyMeterShopFloor sfq = new WxEnergyMeterShopFloor(); -// sfq.updateTenantInfo(record); -// sfq.setType(EnumEnergyMeterShopFloorType.SHOP.getCode()); -// sfq.setAliseId(shopId); -// List meterList = wxEnergyMeterShopFloorMapper.findMeterIdList(sfq); -// -// //如果店铺已经存在了计算,则不允许重复 -// WxEnergyReadingCalcuteResult crq = new WxEnergyReadingCalcuteResult(); -// crq.updateTenantInfo(record); -// crq.setShopId(shopId); -// crq.setPeriod(record.getPeriod()); -// crq.setFeesId(record.getFeesId()); -// List list = wxEnergyReadingCalcuteResultMapper.findList(crq); -// if (null != list && list.size() > 0 ) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"科目["+fees.getName()+"]该年月已存在计算记录,不能重复计算"); -// } -// -// //一个年月,一个店铺应该只有一个抄表周期 -// WxEnergyFeesTime time = null; + final IdWorker idWorker = IdWorker.get(); + WxShop shq = new WxShop(); + shq.updateTenantInfo(record); + shq.setIds(shopIds); + Map shopMap = wxShopService.findShopMap(shq); + // 总共面积 + BigDecimal totalArea = new BigDecimal(0); + // 楼栋的面积 + Map buildingAreaMap = null; + //楼层 + Map floorAreaMap = null; + WxMallFloor fq = new WxMallFloor(); + fq.updateTenantInfo(record); + List floorList = wxMallFloorService.getBudingFloorList(fq, null); + if (null != floorList && floorList.size() > 0 ) { + floorAreaMap = new HashMap(); + buildingAreaMap = new HashMap(); + for (int i = 0 ; i < floorList.size() ; i ++) { + WxMallFloor floor = floorList.get(i); + if (null != floor.getOperatingArea()) { + floorAreaMap.put(floor.getId(), floor.getOperatingArea()); + BigDecimal bud = buildingAreaMap.get(floor.getBuildingId()); + if (null == bud) { + bud = new BigDecimal(0); + } + bud = bud.add(floor.getOperatingArea()); + buildingAreaMap.put(floor.getBuildingId(), bud); + totalArea = totalArea.add(floor.getOperatingArea()); + } + } + } + //查询公摊表 + Map> summaryMeterMap = null; + WxEnergyMeter sumq = new WxEnergyMeter(); + sumq.updateTenantInfo(record); + sumq.setPhysicsType(EnumEnergyMeterPhysicsType.SUMMARY.getCode()); + List sumeterList = wxEnergyMeterMapper.findList(sumq); + if (null != sumeterList && sumeterList.size() > 0 ) { + summaryMeterMap = new HashMap>(); + for (int i = 0 ; i < sumeterList.size(); i ++) { + WxEnergyMeter summaryMeter = sumeterList.get(i); + //查询总表下的子表 + WxEnergyMeterChild mcq = new WxEnergyMeterChild(); + mcq.updateTenantInfo(record); + mcq.setParentMeterId(summaryMeter.getId()); + List childMeterIds = wxEnergyMeterChildMapper.findChildMeterIdList(mcq); + if (null != childMeterIds && childMeterIds.size() > 0 ) { + summaryMeterMap.put(summaryMeter.getId(), childMeterIds); + } + } + } + + List resultList = new ArrayList(); + for (int i = 0 ; i < shopIds.size(); i ++) { + Long shopId= shopIds.get(i); + WxShop shop = shopMap.get(shopId); + + //查询用户表 + WxEnergyMeterShopFloor sfq = new WxEnergyMeterShopFloor(); + sfq.updateTenantInfo(record); + sfq.setType(EnumEnergyMeterShopFloorType.SHOP.getCode()); + sfq.setAliseId(shopId); + List meterList = wxEnergyMeterShopFloorMapper.findMeterIdList(sfq); + //分别查询水,电,燃气表 + List waterMeterList = null; + List powerMeterList = null; + List gasMeterList = null; + if (null != meterList && meterList.size() > 0 ) { + WxEnergyMeter mq = new WxEnergyMeter(); + mq.updateTenantInfo(record); + mq.setType(EnumEnergyMeterType.WATER.getCode()); + mq.setIsDel(EnumYesOrNo.NO.getCode()); + mq.setHasFee(EnumYesOrNo.YES.getCode()); + mq.setPhysicsType(EnumEnergyMeterPhysicsType.USER.getCode()); + waterMeterList = wxEnergyMeterMapper.findIdList(mq); + + mq.setType(EnumEnergyMeterType.POWER.getCode()); + powerMeterList = wxEnergyMeterMapper.findIdList(mq); + + mq.setType(EnumEnergyMeterType.AIR_CONDITIONING.getCode()); + gasMeterList = wxEnergyMeterMapper.findIdList(mq); + } + + + //如果店铺已经存在了计算,则不允许重复 + WxEnergyReadingCalcuteResult crq = new WxEnergyReadingCalcuteResult(); + crq.updateTenantInfo(record); + crq.setShopId(shopId); + crq.setPeriod(record.getPeriod()); + crq.setFeesId(record.getFeesId()); + List list = wxEnergyReadingCalcuteResultMapper.findList(crq); + if (null != list && list.size() > 0 ) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"科目["+fees.getName()+"]该年月已存在计算记录,不能重复计算"); + } + + //一个年月,一个店铺应该只有一个抄表周期 + WxEnergyFeesTime time = null; // if (fees.getBillType() == EnumBillAllType.DAILY.getCode()) { -// -// //根据店铺,所属年月去查询时间区间.根据店铺,时间区间去查对应的抄表数据,根据表来计算总和 -// WxEnergyFeesTimeShop sq = new WxEnergyFeesTimeShop(); -// sq.updateTenantInfo(record); -// sq.setShopId(shopId); -// List timeIds = wxEnergyFeesTimeShopMapper.findTimeIdList(sq); -// if (null == timeIds || timeIds.size() <= 0 ) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"未设置抄表区间"); -// } -// -// WxEnergyFeesTime tq = new WxEnergyFeesTime(); -// tq.updateTenantInfo(record); -// tq.setIds(timeIds); -// tq.setPeriod(record.getPeriod()); -// List timelist = wxEnergyFeesTimeMapper.findList(tq); -// if (null == timelist || timelist.size() <= 0 ) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"未设置抄表区间"); -// } -// time = timelist.get(0); -// } -// -// //根据店铺查询绑定的科目 -// WxFeesCalcuteShop csq = new WxFeesCalcuteShop(); -// csq.updateTenantInfo(record); -// csq.setFeesId(fees.getId()); -// csq.setShopId(shopId); -// List shopFeesList = wxEnergyFeesShopMapper.findList(csq); -// if (null == shopFeesList || shopFeesList.size() <= 0 ) { -// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"未设置该科目费用标准"); -// } -// -// //循环店铺科目, -// for (int j = 0 ; j < shopFeesList.size() ; j ++) { -// WxFeesCalcuteShop shopfee = shopFeesList.get(j); -// WxEnergyReadingCalcuteResult cs = new WxEnergyReadingCalcuteResult(); -// cs.updateTenantInfo(record); -// cs.setId(idWorker.nextId()); -// cs.setCalcuteId(record.getId()); -// cs.setShopId(shopId); -// cs.setCreateTime(new Date()); -// cs.setUpdateTime(new Date()); -// cs.setFeesId(shopfee.getFeesId()); -// cs.setFeesPrice(shopfee.getPrice()); -// cs.setFeesShopId(shopfee.getId()); -// StringBuffer sb = new StringBuffer(); -// cs.setMoney(wxEnergyHelper.calcuteMoney(sb,totalArea,shop,time, fees, shopfee,meterList,summaryMeterMap,buildingAreaMap,floorAreaMap)); -// cs.setPeriod(record.getPeriod()); -// cs.setMoneyDeail(sb.toString()); -// //如果是能源的,从抄表周期里面取 -// if (null != time) { -// cs.setBeginTime(time.getStartTime()); -// cs.setEndTime(time.getEndTime()); -// }else { -// cs.setBeginTime(shopfee.getBeginTime()); -// cs.setEndTime(shopfee.getEndTime()); -// } -// resultList.add(cs); + + //根据店铺,所属年月去查询时间区间.根据店铺,时间区间去查对应的抄表数据,根据表来计算总和 + WxEnergyFeesTimeShop sq = new WxEnergyFeesTimeShop(); + sq.updateTenantInfo(record); + sq.setShopId(shopId); + List timeIds = wxEnergyFeesTimeShopMapper.findTimeIdList(sq); + if (null == timeIds || timeIds.size() <= 0 ) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"未设置抄表区间"); + } + + WxEnergyFeesTime tq = new WxEnergyFeesTime(); + tq.updateTenantInfo(record); + tq.setIds(timeIds); + tq.setPeriod(record.getPeriod()); + List timelist = wxEnergyFeesTimeMapper.findList(tq); + if (null == timelist || timelist.size() <= 0 ) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"未设置抄表区间"); + } + time = timelist.get(0); // } -// } -// if (resultList.size() > 0 ) { -// wxEnergyReadingCalcuteResultMapper.insertResults(record.getTenantId(),resultList); -// } + + //根据店铺查询绑定的科目 + WxFeesCalcuteShop csq = new WxFeesCalcuteShop(); + csq.updateTenantInfo(record); + csq.setFeesId(fees.getId()); + csq.setShopId(shopId); + List shopFeesList = wxEnergyFeesShopMapper.findList(csq); + if (null == shopFeesList || shopFeesList.size() <= 0 ) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"未设置该科目费用标准"); + } + + //循环店铺科目, + for (int j = 0 ; j < shopFeesList.size() ; j ++) { + WxFeesCalcuteShop shopfee = shopFeesList.get(j); + WxEnergyReadingCalcuteResult cs = new WxEnergyReadingCalcuteResult(); + cs.updateTenantInfo(record); + cs.setId(idWorker.nextId()); + cs.setCalcuteId(record.getId()); + cs.setShopId(shopId); + cs.setCreateTime(new Date()); + cs.setUpdateTime(new Date()); + cs.setFeesId(shopfee.getFeesId()); + cs.setFeesPrice(shopfee.getPrice()); + cs.setFeesShopId(shopfee.getId()); + StringBuffer sb = new StringBuffer(); + cs.setMoney(wxEnergyHelper.calcuteMoney(sb,totalArea,shop,time, fees, shopfee,waterMeterList,powerMeterList,gasMeterList,summaryMeterMap,buildingAreaMap,floorAreaMap)); + cs.setPeriod(record.getPeriod()); + cs.setMoneyDeail(sb.toString()); + //如果是能源的,从抄表周期里面取 + if (null != time) { + cs.setBeginTime(time.getStartTime()); + cs.setEndTime(time.getEndTime()); + }else { + cs.setBeginTime(shopfee.getBeginTime()); + cs.setEndTime(shopfee.getEndTime()); + } + resultList.add(cs); + } + } + if (resultList.size() > 0 ) { + wxEnergyReadingCalcuteResultMapper.insertResults(record.getTenantId(),resultList); + } } private void initReadingCalcuteResultQueryParam(WxEnergyReadingCalcuteResult record) { @@ -1559,7 +1577,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { } WxFeesCalcuteShop feesShop = wxEnergyFeesShopMapper.selectById(result.getFeesShopId(), result.getTenantId()); if (null == feesShop) { - throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"该科目费用标准未查询到"); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"店铺"+shop.getShopNumber()+"该款项费用标准未查询到"); } //非能耗费的费用标准更新开始日期和结束日期,能耗的是使用的抄表区间的时间。 @@ -1569,7 +1587,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { // feesShopList.add(feesShop); // } - WxAllBill bill = result.generateBill(calcute, shop, user,result.getBeginTime(),result.getEndTime(), result.getMoney(), result.getMoneyDeail(), "能源计算自动生成"); + WxAllBill bill = result.generateBill(calcute, shop, user,result.getBeginTime(),result.getEndTime(), result.getMoney(), result.getMoneyDeail(), "款项计算自动生成"); billList.add(bill); } @@ -1582,7 +1600,7 @@ public class WxEnergyServiceImpl implements WxEnergyService { wxAllBillService.insertBills(record.getTenantId(), billList); //更新费用标准的开始日期和结束日期 - wxEnergyFeesShopMapper.updateTimes(record.getTenantId(), feesShopList); +// wxEnergyFeesShopMapper.updateTimes(record.getTenantId(), feesShopList); }catch(Exception e) { logger.error("insert bills error.",e); 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 117afcbff..a9333ced5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -169,101 +169,48 @@ public class WxFlowServiceImpl implements WxFlowService { String businessId = mapInfo.get("businessId").toString(); Integer flowType = getIngeter(mapInfo.get("flowType")); List> variables = (List)mapInfo.get("variables"); - Integer contractType = 0; - String str = (String)getVariableByKey(variables,"contractType"); Integer operateType = getIngeter(getVariableByKey(variables,"approvalType")); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - if(StringUtils.isNotBlank(str)){ - contractType = Integer.parseInt(str); - } 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)) { - - WxRentContract rent = new WxRentContract(); - //租金+合同的bussinessId 特殊 - Long bsId = 0L; - Long propetyId = 0L; - if (businessId.contains("_RP_")) { - bsId = Long.parseLong(businessId.split("_RP_")[0]); - propetyId = Long.parseLong(businessId.split("_RP_")[1]); - }else { - bsId = Long.parseLong(businessId); - } - rent.setId(bsId); - rent.setApplyStatus(applyStatus); - //rent.setBusinessType(flowType); - - WxRentContract record = wxRentContractMapper.selectById(bsId); - - boolean isrentproperty = false; - Integer propertyStatus = null; - //合并的合同-审批时 物业合同的状态肯定不在 签约中 避免更新物业合同时提示店铺存在 - //if(record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())){ - // isrentproperty = true; - //} - //String wholeProperyId = (String)mapInfo.get("wholeProperyId"); - //如果是提交审批 , 审批驳回状态不变 - if (EnumRentContractAppStatus.APPLYING.getCode().intValue() == applyStatus.intValue()) { - //如果合同的状态非正常,则不处理 - if (EnumRentContractStatus.DRAFT.getCode().intValue() == record.getStatus().intValue()) { - rent.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); - //如果是租金+物业,则还要更新物业合同的状态 - if (isrentproperty) { - propertyStatus = EnumRentContractStatus.PERFORMANCE.getCode(); - } - } - //如果审批完成 - }else if (EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { - wxRentContractService.updateRentContractStatus(bsId,false); - if (isrentproperty) { - //wxPropertyContractService.updatePropertyContractStatus(propetyId); - } - //如果是审批撤回,或者驳回,改回草稿状态 - }else if (EnumRentContractAppStatus.SETBACK.getCode().intValue() == applyStatus.intValue() - || EnumRentContractAppStatus.REJECT.getCode().intValue() == applyStatus.intValue()) { - rent.setStatus(EnumRentContractStatus.DRAFT.getCode()); - //如果是租金+物业,则还要更新物业合同的状态 - if (isrentproperty) { - propertyStatus = EnumRentContractStatus.DRAFT.getCode(); - } - } - wxRentContractService.updateApplyStatus(rent); - - }else if(EnumFlowContractType.PROPERTY.getCode().equals(contractType)){ - - } + WxRentContract rent = new WxRentContract(); + //租金+合同的bussinessId 特殊 + Long bsId = Long.parseLong(businessId); + rent.setId(bsId); + rent.setApplyStatus(applyStatus); + //rent.setBusinessType(flowType); + + WxRentContract record = wxRentContractMapper.selectById(bsId); + + //如果是提交审批 , 审批驳回状态不变 + if (EnumRentContractAppStatus.APPLYING.getCode().intValue() == applyStatus.intValue()) { + //如果合同的状态非正常,则不处理 + if (EnumRentContractStatus.DRAFT.getCode().intValue() == record.getStatus().intValue()) { + rent.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); + } + //如果审批完成 + }else if (EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { + wxRentContractService.updateRentContractStatus(bsId); + //如果是审批撤回,或者驳回,改回草稿状态 + }else if (EnumRentContractAppStatus.SETBACK.getCode().intValue() == applyStatus.intValue() + || EnumRentContractAppStatus.REJECT.getCode().intValue() == applyStatus.intValue()) { + rent.setStatus(EnumRentContractStatus.DRAFT.getCode()); + } + wxRentContractService.updateApplyStatus(rent); }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(); - //租金+合同的bussinessId 特殊 - Long bsId ; - Long propetyId; - if (businessId.contains("_RP_")) { - bsId = Long.parseLong(businessId.split("_RP_")[0]); - propetyId = Long.parseLong(businessId.split("_RP_")[1]); - }else { - bsId = Long.parseLong(businessId); - } - - rent.setId(bsId); - rent.setApplyStatus(applyStatus); - //rent.setBusinessType(flowType); + WxRentContract rent = new WxRentContract(); + //租金+合同的bussinessId 特殊 + Long bsId = Long.parseLong(businessId); + rent.setId(bsId); + rent.setApplyStatus(applyStatus); + //rent.setBusinessType(flowType); - if(EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { - rent.setStatus(EnumRentContractStatus.TERMINATE.getCode()); - - //终止租赁合同,同时终止物业合同 - Integer endProperty = getIngeter(getVariableByKey(variables,"endProperty")); - //rent.setEndProperty(endProperty); - wxRentContractService.endContract(rent,null); - } - wxRentContractService.updateApplyStatus(rent); - }else if(EnumFlowContractType.PROPERTY.getCode().equals(contractType)){ + if(EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { + rent.setStatus(EnumRentContractStatus.TERMINATE.getCode()); + wxRentContractService.endContract(rent,null); } + wxRentContractService.updateApplyStatus(rent); } else if (EnumFlowKey.BILL.getCode().equals(flowType) || EnumFlowKey.NEW_BILL_CHANGE.getCode().equals(flowType) || EnumFlowKey.BILL_FINISH.getCode().equals(flowType)) { Integer billType = getIngeter(getVariableByKey(variables, "billType")); @@ -390,24 +337,6 @@ public class WxFlowServiceImpl implements WxFlowService { WxBillSettle wxBillSettle = new WxBillSettle(); wxBillSettle.setId(Long.parseLong(businessId)); wxBillSettle.setApplyStatus(applyStatus); - - //审批完成,账单解冻 -// WxBillSettle settle = wxBillSettleService.getById(Long.parseLong(businessId), EnumFilterSettle.NO.getCode()); -// if(EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { -// wxBillSettle.setStatus(EnumSettleStatus.NOT_FINISH.getCode()); -// wxBillSettleService.updateFreezeOrStatus(settle.getReceiveBillIds(), EnumFreezeType.DEF.getCode(),EnumBillStatus.PAID.getCode(),null); -// wxBillSettleService.updateFreezeOrStatus(settle.getPayBillIds(),EnumFreezeType.DEF.getCode(),EnumBillStatus.PAID.getCode(),null); -// -// //刚好结清 -// if(settle.getReceiveMoney().equals(settle.getPayMoney())){ -// wxBillSettle.setStatus(EnumSettleStatus.FINISH.getCode()); -// } -// }else if(EnumRentContractAppStatus.SETBACK.getCode().intValue() == applyStatus.intValue() || EnumRentContractAppStatus.REJECT.getCode().intValue() == applyStatus.intValue()) { -// //解冻 -// wxBillSettleService.updateFreezeOrStatus(settle.getReceiveBillIds(), EnumFreezeType.DEF.getCode(),null,null); -// wxBillSettleService.updateFreezeOrStatus(settle.getPayBillIds(),EnumFreezeType.DEF.getCode(),null,null); -// } -// wxBillSettleMapper.updateById(wxBillSettle); }else if (EnumFlowKey.CASH_OUT.getCode().equals(flowType)) { String tenantId = (String)getVariableByKey(variables,"cashTenantId"); WxCashOut cashout = wxCashOutService.getById(Long.parseLong(businessId), tenantId); 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 c27c68977..1baac2b51 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -499,7 +499,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Override @Transactional(rollbackFor = {Exception.class}) - public ResultData updateRentContractStatus(Long id,boolean buildProperyBill) { + public ResultData updateRentContractStatus(Long id) { logger.info(" updateRentContractStatus_:"+id); @@ -510,16 +510,30 @@ public class WxRentContractServiceImpl implements WxRentContractService { if (record == null) { return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); } + //如果合同状态为非正常状态,则不更新合同状态,并删除账单 if(record.getStatus().intValue() == EnumRentContractStatus.INVALID.getCode().intValue() || record.getStatus().intValue() == EnumRentContractStatus.TERMINATE.getCode().intValue()) { return new ResultData(ErrorCode.RENT_CONTRACT_IS_TERMINATED.getCode(),"合同状态已作废或者已终止."); } + //如果合同是影子合同,则删除之前的源合同,本合同的ID变更为源合同的ID + boolean isYingzi = false; + Long orginId = record.getOrginId(); + if (record.isYingZiContract()){ + isYingzi = true; + wxRentContractMapper.deleteContract(record.getTenantId(),id); + wxRentContractMapper.updateContractId(record.getTenantId(), id, record.getOrginId()); + record.setId(orginId); + } //更新合同状态为签约 WxRentContract wxRentContract = new WxRentContract(); - wxRentContract.setId(id); + if (isYingzi) { + wxRentContract.setId(orginId);//影子合同的ID已经变为源合同ID了 + }else { + wxRentContract.setId(id); + } if (record.getRentalStartDate().before(new Date())) { wxRentContract.setStatus(EnumRentContractStatus.PAING.getCode()); } else { @@ -539,9 +553,25 @@ public class WxRentContractServiceImpl implements WxRentContractService { //如果合同的账单cusName为空的话,则设置为customers name handleContractBillCusName(record,cusName); + //影子合同处理,源合同账单则需要清空当前时间之后未处理的账单 + if (isYingzi) { + //当前时间之后的未处理过的账单,全部删除,之前的账单,还有以后已经处理过的账单,不处理。需财务手工处理这些账单 + WxAllBill bq = new WxAllBill(); + bq.updateTenantInfo(wxRentContract); + bq.setRentContractId(orginId); + bq.setShopEndtime(new Date()); + wxAllBillMapper.deleteNoNeedPayBill(bq); + //把原账单的合同编号更改为源合同ID + wxAllBillMapper.updateContractId(id, orginId, wxRentContract.getTenantId()); + } + //预览账单改为正式,并写入商户id WxAllBill billRent = new WxAllBill(); - billRent.setRentContractId(id); + if (isYingzi) { + billRent.setRentContractId(orginId); + }else { + billRent.setRentContractId(id); + } billRent.setIsPreview(EnumIsPreview.NO.getCode()); billRent.updateTenantInfo(record); wxAllBillMapper.updatePreviewStatus(billRent); diff --git a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml index 8db8896f2..9c50793db 100644 --- a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml @@ -439,6 +439,10 @@ + + update wx_all_bill set rent_contract_id = #{newContractId} where tenant_id = #{tenantId} and rent_contract_id = #{oldContractId} + + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 52c297733..e9201b660 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -36,6 +36,7 @@ + @@ -50,7 +51,7 @@ `apply_status`,`create_by_name`,`update_by_name`, `rent_info`, `file_names`, shop_id_str, - design_file,remark + design_file,remark,orgin_id @@ -58,6 +59,7 @@ where 1 = 1 and `id` = #{id} and `from_id` = #{fromId} + and `orgin_id` = #{orginId} and `customers_id` = #{customersId} and `rental_start_date` = #{rentalStartDate} and `rental_end_date` = #{rentalEndDate} @@ -240,5 +242,14 @@ where `tenant_id` = #{tenantId} and status = 3 and end_contract_time <= now(); + + insert into wx_rent_contract_valid_delete select * from wx_rent_contract where id = #{id} and `tenant_id` = #{tenantId}; + delete from wx_rent_contract where `tenant_id` = #{tenantId} and id = #{id}; + + + + update wx_rent_contract set id = #{newId} where id = #{oldId} and `tenant_id` = #{tenantId}; + +