| @@ -138,62 +138,140 @@ public class WxAgileContractController extends WxContractBaseController { | |||||
| public ResultData saveOrUpdate(@RequestBody WxRentContract wxRentContract) { | public ResultData saveOrUpdate(@RequestBody WxRentContract wxRentContract) { | ||||
| MallUserInfo user = getUser(); | MallUserInfo user = getUser(); | ||||
| wxRentContract.updateTenantInfo(user); | 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()) { | if (null == wxRentContract.getRentalStartDate()) { | ||||
| return new ResultData(Result.ERROR,"请选择合同开始日期"); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择合同开始日期"); | |||||
| } | } | ||||
| if (null == wxRentContract.getRentalEndDate()) { | 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()); | int[] array = DateUtils.getDiff(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate()); | ||||
| wxRentContract.setLease(array[0]); | wxRentContract.setLease(array[0]); | ||||
| if (null == wxRentContract.getSignDate()) { | if (null == wxRentContract.getSignDate()) { | ||||
| return new ResultData(Result.ERROR,"请选择合同签约日期"); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择合同签约日期"); | |||||
| } | } | ||||
| String rentInfo = wxRentContract.getRentInfo(); | String rentInfo = wxRentContract.getRentInfo(); | ||||
| if (StringUtils.isBlank(rentInfo)) { | if (StringUtils.isBlank(rentInfo)) { | ||||
| return new ResultData(Result.ERROR,"请选择铺位"); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择铺位"); | |||||
| } | } | ||||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | ||||
| int size = rentInfoArray.size(); | int size = rentInfoArray.size(); | ||||
| if (size == 0) { | if (size == 0) { | ||||
| return new ResultData(ErrorCode.SHOP_NOT_SELECTED); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择店铺"); | |||||
| } | } | ||||
| List<Long> shopList = Lists.newArrayList(); | List<Long> shopList = Lists.newArrayList(); | ||||
| //查询rent_info 包括 shopId | //查询rent_info 包括 shopId | ||||
| String shopIdStr = ""; | |||||
| //String shopIdStr = ""; | |||||
| BigDecimal rentAreaDecimal = new BigDecimal(0); | BigDecimal rentAreaDecimal = new BigDecimal(0); | ||||
| for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | ||||
| Long shopId = rentInfoObject.getLong("id"); | Long shopId = rentInfoObject.getLong("id"); | ||||
| //wxRentContract.setShopId(shopId); | |||||
| String shopNumber = rentInfoObject.getString("shopNumber"); | |||||
| //String shopNumber = rentInfoObject.getString("shopNumber"); | |||||
| if (!shopList.contains(shopId)) { | if (!shopList.contains(shopId)) { | ||||
| shopList.add(shopId); | shopList.add(shopId); | ||||
| shopIdStr = shopIdStr +","+ shopId; | |||||
| //shopIdStr = shopIdStr +","+ shopId; | |||||
| } | } | ||||
| String rentArea = rentInfoObject.getString("operationArea"); | String rentArea = rentInfoObject.getString("operationArea"); | ||||
| if (StringUtils.isNotBlank(rentArea)) { | if (StringUtils.isNotBlank(rentArea)) { | ||||
| rentAreaDecimal = rentAreaDecimal.add(new BigDecimal(rentArea)); | rentAreaDecimal = rentAreaDecimal.add(new BigDecimal(rentArea)); | ||||
| } | } | ||||
| } | } | ||||
| Collections.sort(shopList); | |||||
| wxRentContract.setRentArea(rentAreaDecimal.toPlainString()); | wxRentContract.setRentArea(rentAreaDecimal.toPlainString()); | ||||
| wxRentContract.setShopIdStr(shopIdStr); | |||||
| wxRentContract.setShopIdStr(StringUtils.join(shopList,",")); | |||||
| try { | try { | ||||
| rentContractValidShop(wxRentContract); | rentContractValidShop(wxRentContract); | ||||
| } catch (Exception e) { | } 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; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -248,6 +326,16 @@ public class WxAgileContractController extends WxContractBaseController { | |||||
| return new ResultData(Result.ERROR,"请至少增加一个"); | return new ResultData(Result.ERROR,"请至少增加一个"); | ||||
| } | } | ||||
| wxRentContract.updateTenantInfo(getTenantInfo()); | 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 { | try { | ||||
| wxAgileContractService.saveDeposit(wxRentContract,this.getUser()); | wxAgileContractService.saveDeposit(wxRentContract,this.getUser()); | ||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| @@ -342,6 +430,30 @@ public class WxAgileContractController extends WxContractBaseController { | |||||
| return new ResultData(wxAgileContractService.findUnDepositList(unDeposit)); | 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(); | |||||
| } | |||||
| /** | /** | ||||
| * 设置联营扣点 | * 设置联营扣点 | ||||
| */ | */ | ||||
| @@ -359,6 +471,13 @@ public class WxAgileContractController extends WxContractBaseController { | |||||
| if (null != _ore) { | if (null != _ore) { | ||||
| renevue.setId(_ore.getId()); | renevue.setId(_ore.getId()); | ||||
| } | } | ||||
| //如果是生效的合同变更 | |||||
| WxRentContract r = wxAgileContractService.selectById(renevue.getRentContractId()); | |||||
| if (isValidContract(r)) { | |||||
| wxAgileContractService.endContractRenevueBill(renevue); | |||||
| } | |||||
| try { | try { | ||||
| wxAgileContractService.saveRenuvue(renevue); | wxAgileContractService.saveRenuvue(renevue); | ||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| @@ -376,6 +495,14 @@ public class WxAgileContractController extends WxContractBaseController { | |||||
| if (null == contract.getRevenueJumps() || contract.getRevenueJumps().size() <= 0 ) { | if (null == contract.getRevenueJumps() || contract.getRevenueJumps().size() <= 0 ) { | ||||
| return new ResultData(Result.ERROR,"无配置项"); | 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 { | try { | ||||
| wxAgileContractService.saveRenuvueJumps(contract); | wxAgileContractService.saveRenuvueJumps(contract); | ||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| @@ -407,6 +534,12 @@ public class WxAgileContractController extends WxContractBaseController { | |||||
| return new ResultData(Result.ERROR,"当前款项费用生成规则和扣点设置不一致。"); | return new ResultData(Result.ERROR,"当前款项费用生成规则和扣点设置不一致。"); | ||||
| } | } | ||||
| //如果是生效的合同变更 | |||||
| WxRentContract r = wxAgileContractService.selectById(_ore.getRentContractId()); | |||||
| if (isValidContract(r)) { | |||||
| wxAgileContractService.endContractRenevueBill(_ore); | |||||
| } | |||||
| try { | try { | ||||
| wxAgileContractService.setJoinRenevueUp(unDeposit); | wxAgileContractService.setJoinRenevueUp(unDeposit); | ||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| @@ -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") | @Excel(name = "状态", replace = {"欠缴_1", "待缴_2", "已结清_3", "未到期_4", "已退还_5", "失效_6", "坏账_7", "退租待结算_8","预收待抵扣_9"}, width = 20, orderNum = "10") | ||||
| @io.swagger.annotations.ApiModelProperty(value = "账单状态EnumBillStatus", name = "status") | @io.swagger.annotations.ApiModelProperty(value = "账单状态EnumBillStatus", name = "status") | ||||
| public Integer 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) | @TableField(exist = false) | ||||
| public List<Integer> statusList; | public List<Integer> statusList; | ||||
| @@ -273,9 +265,6 @@ public class WxAllBill extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="自定义合同费用类型EnumRentContractAgileFeesType",name="rentContractAgileFeesType") | @io.swagger.annotations.ApiModelProperty(value="自定义合同费用类型EnumRentContractAgileFeesType",name="rentContractAgileFeesType") | ||||
| public Integer rentContractAgileFeesType; | public Integer rentContractAgileFeesType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="物业合同ID",name="propertyContractId") | |||||
| public Long propertyContractId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="主物账单ID(针对合同里面的自定义科目账单)",name="parentBillId") | @io.swagger.annotations.ApiModelProperty(value="主物账单ID(针对合同里面的自定义科目账单)",name="parentBillId") | ||||
| public Long parentBillId; | public Long parentBillId; | ||||
| @@ -19,5 +19,7 @@ public interface WxRentContractAgileUnDepositMapper extends CommonMapper<WxRentC | |||||
| List<Long> findFeesIdList(WxRentContractAgileUnDeposit wxBillRent); | List<Long> findFeesIdList(WxRentContractAgileUnDeposit wxBillRent); | ||||
| void updateJoinRenevueUp(WxRentContractAgileUnDeposit wxBillRent); | void updateJoinRenevueUp(WxRentContractAgileUnDeposit wxBillRent); | ||||
| void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| } | } | ||||
| @@ -42,6 +42,8 @@ public interface WxAgileContractService { | |||||
| List<WxRentContractAgileUnDeposit> findUnDepositList(WxRentContractAgileUnDeposit unDeposit); | List<WxRentContractAgileUnDeposit> findUnDepositList(WxRentContractAgileUnDeposit unDeposit); | ||||
| void deleteUnDeposit(WxRentContractAgileUnDeposit unDeposit); | |||||
| List<Long> findUnDepositFeesIdList(WxRentContractAgileUnDeposit unDeposit); | List<Long> findUnDepositFeesIdList(WxRentContractAgileUnDeposit unDeposit); | ||||
| void createUnDepositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user); | void createUnDepositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user); | ||||
| @@ -75,4 +77,9 @@ public interface WxAgileContractService { | |||||
| void transfer(WxRentContract wxRentContract,MallUserInfo user); | void transfer(WxRentContract wxRentContract,MallUserInfo user); | ||||
| List<WxRentContractYearsVo> getRentContractYears(WxRentContract rentContract); | List<WxRentContractYearsVo> 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); | |||||
| } | } | ||||
| @@ -558,6 +558,24 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| return list; | 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 | @Override | ||||
| public List<Long> findUnDepositFeesIdList(WxRentContractAgileUnDeposit unDeposit) { | public List<Long> findUnDepositFeesIdList(WxRentContractAgileUnDeposit unDeposit) { | ||||
| return wxRentContractAgileUnDepositMapper.findFeesIdList(unDeposit); | return wxRentContractAgileUnDepositMapper.findFeesIdList(unDeposit); | ||||
| @@ -1107,16 +1125,7 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| } | } | ||||
| } | } | ||||
| if (null != renevueId) { | if (null != 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.setId(idWorker.nextId()); | |||||
| ari.setCreatetime(new Date()); | |||||
| ari.setUpdatetime(new Date()); | |||||
| WxRentContractAgileRenevueItem ari = generateRenevueItem(idWorker, rentContract, newContractId, renevueId); | |||||
| wxRentContractAgileRenevueItemMapper.insert(ari); | wxRentContractAgileRenevueItemMapper.insert(ari); | ||||
| } | } | ||||
| WxRentContractAgileRenevueFees fq = new WxRentContractAgileRenevueFees(); | WxRentContractAgileRenevueFees fq = new WxRentContractAgileRenevueFees(); | ||||
| @@ -1165,6 +1174,20 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| wxRentContractMapper.insert(rentContract); | 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) { | private WxRentContractAgileUnDepositItem generateUnDepositItem(IdWorker idWorker,WxRentContract rentContract,Long undepositId,Long feesId,Long shopId) { | ||||
| WxRentContractAgileUnDepositItem raudi = new WxRentContractAgileUnDepositItem(); | WxRentContractAgileUnDepositItem raudi = new WxRentContractAgileUnDepositItem(); | ||||
| @@ -1280,5 +1303,90 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||||
| } | } | ||||
| return yearList; | 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<WxRentContractAgileUnDeposit> 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<WxRentContractAgileRenevue> 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<Long> feesIds = new ArrayList<Long>(); | |||||
| 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); | |||||
| } | |||||
| } | } | ||||
| @@ -36,7 +36,6 @@ | |||||
| <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/> | <result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/> | ||||
| <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/> | <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/> | ||||
| <result column="rent_contract_agile_fees_type" jdbcType="INTEGER" property="rentContractAgileFeesType"/> | <result column="rent_contract_agile_fees_type" jdbcType="INTEGER" property="rentContractAgileFeesType"/> | ||||
| <result column="property_contract_id" jdbcType="BIGINT" property="propertyContractId"/> | |||||
| <result column="parent_bill_id" jdbcType="BIGINT" property="parentBillId"/> | <result column="parent_bill_id" jdbcType="BIGINT" property="parentBillId"/> | ||||
| <result column="virtual_compose_id" jdbcType="BIGINT" property="virtualComposeId"/> | <result column="virtual_compose_id" jdbcType="BIGINT" property="virtualComposeId"/> | ||||
| <result column="parent_virtual_compose_id" jdbcType="BIGINT" property="parentVirtualComposeId"/> | <result column="parent_virtual_compose_id" jdbcType="BIGINT" property="parentVirtualComposeId"/> | ||||
| @@ -53,7 +52,7 @@ | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`shop_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`, | `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`, | `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`, | `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` | `energy_reading_calcuteId`,`energy_reading_id`,`extra_create_from`,`rent_area`,`can_edit`,`cus_name`,`fees_type` | ||||
| </sql> | </sql> | ||||
| @@ -70,7 +69,6 @@ | |||||
| <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if> | <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if> | ||||
| <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if> | <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if> | ||||
| <if test=" null != rentContractAgileFeesType ">and `rent_contract_agile_fees_type` = #{rentContractAgileFeesType}</if> | <if test=" null != rentContractAgileFeesType ">and `rent_contract_agile_fees_type` = #{rentContractAgileFeesType}</if> | ||||
| <if test=" null != propertyContractId ">and `property_contract_id` = #{propertyContractId}</if> | |||||
| <if test=" null != parentBillId ">and `parent_bill_id` = #{parentBillId}</if> | <if test=" null != parentBillId ">and `parent_bill_id` = #{parentBillId}</if> | ||||
| <if test=" null != virtualComposeId ">and `virtual_compose_id` = #{virtualComposeId}</if> | <if test=" null != virtualComposeId ">and `virtual_compose_id` = #{virtualComposeId}</if> | ||||
| <if test=" null != parentVirtualComposeId ">and `parent_virtual_compose_id` = #{parentVirtualComposeId}</if> | <if test=" null != parentVirtualComposeId ">and `parent_virtual_compose_id` = #{parentVirtualComposeId}</if> | ||||
| @@ -143,12 +141,6 @@ | |||||
| #{ridItem} | #{ridItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test=" null != propertyContractIds "> | |||||
| and property_contract_id in | |||||
| <foreach collection="propertyContractIds" index="index" item="pidItem" open="(" separator="," close=")"> | |||||
| #{pidItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != statusList "> | <if test=" null != statusList "> | ||||
| and `status` in | and `status` in | ||||
| <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")"> | <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")"> | ||||
| @@ -323,9 +315,6 @@ | |||||
| <if test=" null != rentContractId"> | <if test=" null != rentContractId"> | ||||
| and rent_contract_id = #{rentContractId} | and rent_contract_id = #{rentContractId} | ||||
| </if> | </if> | ||||
| <if test=" null != propertyContractId"> | |||||
| and property_contract_id = #{propertyContractId} | |||||
| </if> | |||||
| <if test=" null != rentContractAgileFeesType"> | <if test=" null != rentContractAgileFeesType"> | ||||
| and rent_contract_agile_fees_type = #{rentContractAgileFeesType} | and rent_contract_agile_fees_type = #{rentContractAgileFeesType} | ||||
| </if> | </if> | ||||
| @@ -340,8 +329,14 @@ | |||||
| <if test=" null != rentContractId"> | <if test=" null != rentContractId"> | ||||
| and rent_contract_id = #{rentContractId} | and rent_contract_id = #{rentContractId} | ||||
| </if> | </if> | ||||
| <if test=" null != propertyContractId"> | |||||
| and property_contract_id = #{propertyContractId} | |||||
| <if test=" null != energyFeesId"> | |||||
| and energy_fees_id = #{energyFeesId} | |||||
| </if> | |||||
| <if test=" null != energyFeesIds "> | |||||
| and `energy_fees_id` in | |||||
| <foreach collection="energyFeesIds" index="index" item="eidItem" open="(" separator="," close=")"> | |||||
| #{eidItem} | |||||
| </foreach> | |||||
| </if> | </if> | ||||
| </delete> | </delete> | ||||
| @@ -364,9 +359,6 @@ | |||||
| <if test=" null != rentContractId"> | <if test=" null != rentContractId"> | ||||
| and rent_contract_id = #{rentContractId} | and rent_contract_id = #{rentContractId} | ||||
| </if> | </if> | ||||
| <if test=" null != propertyContractId"> | |||||
| and property_contract_id = #{propertyContractId} | |||||
| </if> | |||||
| </delete> | </delete> | ||||
| <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxAllBill"> | <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxAllBill"> | ||||
| @@ -374,9 +366,6 @@ | |||||
| <if test=" null != rentContractId"> | <if test=" null != rentContractId"> | ||||
| where rent_contract_id = #{rentContractId} | where rent_contract_id = #{rentContractId} | ||||
| </if> | </if> | ||||
| <if test=" null != propertyContractId"> | |||||
| where property_contract_id = #{propertyContractId} | |||||
| </if> | |||||
| </update> | </update> | ||||
| <insert id="insertBills" parameterType="HashMap"> | <insert id="insertBills" parameterType="HashMap"> | ||||
| @@ -391,7 +380,7 @@ | |||||
| #{item.needPay},#{item.receivePay},#{item.historyReceivePay},#{item.pay},#{item.payWay},#{item.payDate},#{item.setOff},#{item.useMoney}, | #{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.starttime},#{item.endtime},#{item.status},#{item.energyFeesId},#{item.returnPay},#{item.billRemark}, | ||||
| #{item.lastOweCallTime},#{item.lastOweCallUser}, | #{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.parentBillId},#{item.virtualComposeId},#{item.parentVirtualComposeId},#{item.energyReadingCalcuteId}, | ||||
| #{item.energyReadingId},#{item.extraCreateFrom},#{item.rentArea},#{item.canEdit},#{item.cusName},#{item.feesType} | #{item.energyReadingId},#{item.extraCreateFrom},#{item.rentArea},#{item.canEdit},#{item.cusName},#{item.feesType} | ||||
| ) | ) | ||||
| @@ -417,18 +406,12 @@ | |||||
| <if test=" null != rentContractId"> | <if test=" null != rentContractId"> | ||||
| and rent_contract_id = #{rentContractId} | and rent_contract_id = #{rentContractId} | ||||
| </if> | </if> | ||||
| <if test=" null != propertyContractId"> | |||||
| and property_contract_id = #{propertyContractId} | |||||
| </if> | |||||
| </update> | </update> | ||||
| <update id="transferCusName" parameterType="com.iformall.domain.po.WxAllBill"> | <update id="transferCusName" parameterType="com.iformall.domain.po.WxAllBill"> | ||||
| update wx_all_bill set cus_name = #{cusName} where tenant_id = #{tenantId} | update wx_all_bill set cus_name = #{cusName} where tenant_id = #{tenantId} | ||||
| <if test=" null != rentContractId"> | <if test=" null != rentContractId"> | ||||
| and rent_contract_id = #{rentContractId} | and rent_contract_id = #{rentContractId} | ||||
| </if> | |||||
| <if test=" null != propertyContractId"> | |||||
| and property_contract_id = #{propertyContractId} | |||||
| </if> | </if> | ||||
| and( | and( | ||||
| <!-- 应收 --> | <!-- 应收 --> | ||||
| @@ -64,7 +64,7 @@ | |||||
| </select> | </select> | ||||
| <delete id="deleteByRenevue" parameterType="com.iformall.domain.po.WxRentContractAgileRenevueItem"> | <delete id="deleteByRenevue" parameterType="com.iformall.domain.po.WxRentContractAgileRenevueItem"> | ||||
| delete from wx_rent_contract_agile_renevue_item where `renevue_id` = #{unDepositId} | |||||
| delete from wx_rent_contract_agile_renevue_item where `renevue_id` = #{renevueId} | |||||
| </delete> | </delete> | ||||
| </mapper> | </mapper> | ||||
| @@ -72,5 +72,9 @@ | |||||
| update wx_rent_contract_agile_un_deposit set join_renevue_up = #{joinRenevueUp} where id = #{id} | update wx_rent_contract_agile_un_deposit set join_renevue_up = #{joinRenevueUp} where id = #{id} | ||||
| </update> | </update> | ||||
| <delete id="deleteById" parameterType="HashMap"> | |||||
| delete from wx_rent_contract_agile_un_deposit where id = #{id} and `tenant_id` = #{tenantId} | |||||
| </delete> | |||||
| </mapper> | </mapper> | ||||