| @@ -912,6 +912,24 @@ public class WxRentContractController extends WxContractBaseController { | |||
| return new ResultData(wxRentContractService.getRentContractYears(rentContract)); | |||
| } | |||
| //查询合同年限已输入销售额情况 | |||
| @GetMapping("getContractYearsSales") | |||
| public ResultData getContractYearsSales(@ModelAttribute WxRentContract wxRentContract) { | |||
| if (null == wxRentContract) wxRentContract = new WxRentContract(); | |||
| WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| return new ResultData(wxRentContractService.getContractSales(rentContract)); | |||
| } | |||
| @PostMapping("setContractYearsSalesConfirm") | |||
| public ResultData setContractYearsSalesConfirm(@RequestBody WxRentContract wxRentContract) { | |||
| WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| if (null == rentContract) { | |||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同"); | |||
| } | |||
| wxRentContractService.setContractSalesConfirm(rentContract); | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 取高年度汇算计算 | |||
| * @param wxRentContract | |||
| @@ -934,6 +952,23 @@ public class WxRentContractController extends WxContractBaseController { | |||
| } | |||
| return new ResultData(wxRentContractService.calcuteYearsRevenueRentUp(rentContract)); | |||
| } | |||
| //查询合同年度汇算账单列表 | |||
| @GetMapping("getYearsRevenueRentUpBills") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData getYearsRevenueRentUpBills(@ModelAttribute WxRentContract wxRentContract, Integer pageNum, Integer pageSize) { | |||
| if (null == wxRentContract) wxRentContract = new WxRentContract(); | |||
| WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| WxAllBill billd = new WxAllBill(); | |||
| billd.updateTenantInfo(rentContract); | |||
| billd.setRentContractId(rentContract.getId()); | |||
| //删除这个时间的,不设置结束时间,因为可能之前有了账单。,然后撤铺,结束时间虽然不一样,开始时间是一致的。 | |||
| billd.setStarttimeEqual(rentContract.getYearsBegin()); | |||
| billd.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN.getCode()); | |||
| return new ResultData(wxAllBillService.listAsPage(billd,pageNum,pageSize)); | |||
| } | |||
| } | |||
| @@ -35,6 +35,12 @@ public class WxRentContractRevenueSales extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "账单编号", name = "billId") | |||
| private Long billId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "账单开始日期", name = "starttime") | |||
| private Date starttime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "账单结束日期", name = "endtime") | |||
| private Date endtime; | |||
| @io.swagger.annotations.ApiModelProperty(value="账单应付金额",name="minMoney") | |||
| private String billMoney; | |||
| @@ -50,4 +56,10 @@ public class WxRentContractRevenueSales extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="备注",name="remark") | |||
| private String remark; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否已确认",name="isConfirm") | |||
| private Integer isConfirm; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否已计算",name="isCalcute") | |||
| private Integer isCalcute; | |||
| } | |||
| @@ -26,6 +26,7 @@ public interface WxAllBillMapper extends CommonMapper<WxAllBill, Long> { | |||
| void deletePreviewBill(WxAllBill wxBillRent); | |||
| void deleteNoNeedPayBill(WxAllBill wxBillRent); | |||
| void deleteByRentHuiSuan(WxAllBill wxBillRent); | |||
| Integer countValidBillCountByRentHuiSuan(WxAllBill wxBillRent); | |||
| void deleteByRentReveneuSales(WxAllBill wxBillRent); | |||
| void updatePreviewStatus(WxAllBill record); | |||
| @@ -19,5 +19,9 @@ public interface WxRentContractRevenueSalesMapper extends CommonMapper<WxRentCon | |||
| BigDecimal findSumSalesMoneyValid(WxRentContractRevenueSales wxBillRent); | |||
| List<Long> findBillId(WxRentContractRevenueSales wxBillRent); | |||
| void updateConfirm(WxRentContractRevenueSales wxBillRent); | |||
| void updateCalcute(WxRentContractRevenueSales wxBillRent); | |||
| } | |||
| @@ -164,6 +164,8 @@ public interface WxRentContractService { | |||
| WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract,String sales,Long billId,Long propertyContractId); | |||
| void setContractSalesConfirm(WxRentContract wxRentContract); | |||
| WxRentContractYearsSumVo calcuteYearsRevenueRentUp(WxRentContract rentcontract); | |||
| List<WxRentContractRevenueJump> findJumpList(WxRentContractRevenueJump jump); | |||
| @@ -2170,6 +2170,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| WxRentContractRevenueSales sales = new WxRentContractRevenueSales(); | |||
| sales.updateTenantInfo(wxRentContract); | |||
| sales.setRentContractId(wxRentContract.getId()); | |||
| if (null != wxRentContract.getYearsBegin() && null != wxRentContract.getYearsEnd()) { | |||
| sales.setStarttime(wxRentContract.getYearsBegin()); | |||
| sales.setEndtime(wxRentContract.getYearsEnd()); | |||
| } | |||
| return wxRentContractRevenueSalesMapper.findList(sales); | |||
| } | |||
| @@ -2450,7 +2454,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| public WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract, String sales, Long billId, Long propertyContractId) { | |||
| //如果账单存在缴费,付款,减免,冲抵,等情况,则不允许。 | |||
| WxAllBill rentBill = wxAllBillMapper.selectById(billId, rentcontract.getTenantId()); | |||
| if ((StringUtils.isNotBlank(rentBill.getPay()) && new BigDecimal(rentBill.getPay()).compareTo(new BigDecimal(0)) > 0 ) | |||
| || (StringUtils.isNotBlank(rentBill.getSetOff()) && new BigDecimal(rentBill.getSetOff()).compareTo(new BigDecimal(0)) > 0 ) | |||
| || (StringUtils.isNotBlank(rentBill.getReturnPay()) && new BigDecimal(rentBill.getReturnPay()).compareTo(new BigDecimal(0)) > 0 ) | |||
| || (StringUtils.isNotBlank(rentBill.getUseMoney()) && new BigDecimal(rentBill.getUseMoney()).compareTo(new BigDecimal(0)) > 0 ) ) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"账单存在已经已经缴费或付款,扣减,减免,冲抵的情况,不允许操作"); | |||
| } | |||
| BigDecimal salesDeciaml = new BigDecimal(sales); | |||
| //删除自动创建的账单 | |||
| @@ -2592,6 +2604,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| sale.setId(idWorker.nextId()); | |||
| sale.updateTenantInfo(rentcontract); | |||
| sale.setBillId(billId); | |||
| sale.setStarttime(rentBill.getStarttime()); | |||
| sale.setEndtime(rentBill.getEndtime()); | |||
| sale.setRentContractId(rentcontract.getId()); | |||
| sale.setBillMoney(rentBill.getReceivePay()); | |||
| sale.setSaleMoney(sales); | |||
| @@ -2653,7 +2667,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| sb.append(" 租金原合同租金金额:"+rentBill.getNeedPay()+"元,分摊比率为:"+rentRate+",计算之后为:"+rentneedpay+"元。"); | |||
| rentBill.setMoneyChangeDetail(sb.toString()); | |||
| rentBill.setReceivePay(rentneedpay); | |||
| rentBill.setBillRemark("设置销售额,自动计算"); | |||
| rentBill.setBillRemark(createFrom.getMessage()+",自动计算:"+sb.toString()); | |||
| rentBill.setUpdatetime(new Date()); | |||
| if (new BigDecimal(rentBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) { | |||
| //rentBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); | |||
| @@ -2705,7 +2719,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| bmbill = bmbillList.get(0); | |||
| bmbill.setMoneyChangeDetail("原合同商业管理费金额:"+bmbill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); | |||
| bmbill.setReceivePay(bussinessmoney); | |||
| bmbill.setBillRemark("设置销售额,自动计算"); | |||
| bmbill.setBillRemark(createFrom.getMessage()+",自动计算。"+"原合同商业管理费金额:"+bmbill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); | |||
| if (new BigDecimal(bmbill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) { | |||
| //bmbill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); | |||
| }else { | |||
| @@ -2733,7 +2747,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| bmbill.setPay("0"); | |||
| bmbill.setStarttime(rentBill.getStarttime()); | |||
| bmbill.setEndtime(rentBill.getEndtime()); | |||
| bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建"); | |||
| bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,总计分摊比率为:"+rate); | |||
| bmbill.setExtraCreateFrom(createFrom.getCode()); | |||
| bmbill.setMoneyChangeDetail("自动计算创建,总计分摊比率为:"+rate+",应收金额为:"+bussinessmoney+"元,"); | |||
| wxAllBillMapper.insert(bmbill); | |||
| @@ -2749,7 +2763,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if (null != propertyBill ) { | |||
| propertyBill.setMoneyChangeDetail("原合同商业管理费金额:"+propertyBill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); | |||
| propertyBill.setReceivePay(bussinessmoney); | |||
| propertyBill.setBillRemark("设置销售额,自动计算"); | |||
| propertyBill.setBillRemark(createFrom.getMessage()+",自动计算"+"原合同商业管理费金额:"+propertyBill.getNeedPay()+"元,总计分摊比率为:"+rate+",计算调整为:"+bussinessmoney+"元。"); | |||
| if (new BigDecimal(propertyBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) { | |||
| //propertyBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); | |||
| }else { | |||
| @@ -2779,7 +2793,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| bmbill.setPay("0"); | |||
| bmbill.setStarttime(rentBill.getStarttime()); | |||
| bmbill.setEndtime(rentBill.getEndtime()); | |||
| bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建"); | |||
| bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,总计分摊比率为:"+rate); | |||
| bmbill.setExtraCreateFrom(createFrom.getCode()); | |||
| bmbill.setMoneyChangeDetail("自动计算创建,总计分摊比率为:"+rate+",应收金额为:"+bussinessmoney+"元,"); | |||
| wxAllBillMapper.insert(bmbill); | |||
| @@ -2809,14 +2823,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| bmbill.setPay("0"); | |||
| bmbill.setStarttime(starttime); | |||
| bmbill.setEndtime(endtime); | |||
| bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建"); | |||
| bmbill.setBillRemark(createFrom.getMessage()+",自动计算创建,分摊比例为"+rate); | |||
| bmbill.setExtraCreateFrom(createFrom.getCode()); | |||
| bmbill.setMoneyChangeDetail("自动计算创建,分摊比例为"+rate+",计算应收金额为:"+money+"元,"); | |||
| wxAllBillMapper.insert(bmbill); | |||
| return bmbill; | |||
| } | |||
| @Override | |||
| public void setContractSalesConfirm(WxRentContract rentcontract) { | |||
| WxRentContractRevenueSales sales = new WxRentContractRevenueSales(); | |||
| sales.updateTenantInfo(rentcontract); | |||
| sales.setRentContractId(rentcontract.getId()); | |||
| sales.setStarttime(rentcontract.getYearsBegin()); | |||
| sales.setEndtime(rentcontract.getYearsEnd()); | |||
| wxRentContractRevenueSalesMapper.updateConfirm(sales); | |||
| } | |||
| @Override | |||
| public WxRentContractYearsSumVo calcuteYearsRevenueRentUp(WxRentContract rentcontract) { | |||
| @@ -2833,13 +2855,21 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return vo; | |||
| } | |||
| //删除未支付,未冲抵,未退款的之前的账单 | |||
| //如果有账单已经缴费或者付款,扣减,减免,冲抵等,则不允许操作。 | |||
| WxAllBill billd = new WxAllBill(); | |||
| billd.updateTenantInfo(rentcontract); | |||
| billd.setRentContractId(rentcontract.getId()); | |||
| //删除这个时间的,不设置结束时间,因为可能之前有了账单。,然后撤铺,结束时间虽然不一样,开始时间是一致的。 | |||
| billd.setStarttimeEqual(rentcontract.getYearsBegin()); | |||
| billd.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN.getCode()); | |||
| Integer validCount = wxAllBillMapper.countValidBillCountByRentHuiSuan(billd); | |||
| if (null != validCount && validCount > 0 ) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"存在已经已经缴费或付款,扣减,减免,冲抵的账单,则不允许操作"); | |||
| } | |||
| //删除未支付,未冲抵,未退款的之前的账单 | |||
| wxAllBillMapper.deleteByRentHuiSuan(billd); | |||
| //计算跳点。 | |||
| @@ -309,6 +309,12 @@ | |||
| and extra_create_from = #{extraCreateFrom} and `starttime` = #{starttimeEqual} | |||
| </delete> | |||
| <select id="countValidBillCountByRentHuiSuan" parameterType="com.iformall.domain.po.WxAllBill" resultType="Integer"> | |||
| select count(1) from wx_all_bill where rent_contract_id = #{rentContractId} | |||
| and (IFNULL(`pay`,'0') > 0 or IFNULL(`set_off`,'0') > 0 or IFNULL(`return_pay`,'0') > 0 or IFNULL(`use_money`,'0') > 0) | |||
| and extra_create_from = #{extraCreateFrom} and `starttime` = #{starttimeEqual} | |||
| </select> | |||
| <delete id="deleteByRentReveneuSales" parameterType="com.iformall.domain.po.WxAllBill"> | |||
| delete from wx_all_bill where extra_create_from = #{extraCreateFrom} | |||
| and IFNULL(`pay`,'0') <= 0 AND IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0 and IFNULL(`use_money`,'0') <= 0 | |||
| @@ -10,16 +10,21 @@ | |||
| <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/> | |||
| <result column="property_contract_id" jdbcType="BIGINT" property="propertyContractId"/> | |||
| <result column="bill_id" jdbcType="BIGINT" property="billId"/> | |||
| <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/> | |||
| <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/> | |||
| <result column="bill_money" jdbcType="VARCHAR" property="billMoney"/> | |||
| <result column="sale_money" jdbcType="VARCHAR" property="saleMoney"/> | |||
| <result column="sale_money_valid" jdbcType="VARCHAR" property="saleMoneyValid"/> | |||
| <result column="calcute_money" jdbcType="VARCHAR" property="calcuteMoney"/> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||
| <result column="is_confirm" jdbcType="INTEGER" property="isConfirm"/> | |||
| <result column="is_calcute" jdbcType="INTEGER" property="isCalcute"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`rent_contract_id`,`property_contract_id`,`bill_id`,`bill_money`, | |||
| `sale_money`,`sale_money_valid`,`calcute_money`,`remark` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`rent_contract_id`,`property_contract_id`,`bill_id`,`starttime`,`endtime`,`bill_money`, | |||
| `sale_money`,`sale_money_valid`,`calcute_money`,`remark`,`is_confirm`,`is_calcute` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -34,6 +39,10 @@ | |||
| <if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if> | |||
| <if test=" null != propertyContractId ">and `property_contract_id` = #{propertyContractId}</if> | |||
| <if test=" null != billId ">and `bill_id` = #{billId}</if> | |||
| <if test=" null != starttime ">and `starttime` >= #{starttime}</if> | |||
| <if test=" null != endtime ">and `endtime` <= #{endtime}</if> | |||
| <if test=" null != isConfirm ">and `is_confirm` = #{isConfirm}</if> | |||
| <if test=" null != isCalcute ">and `is_calcute` = #{isCalcute}</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -68,5 +77,15 @@ | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <update id= "updateConfirm" parameterType="com.iformall.domain.po.WxRentContractRevenueSales"> | |||
| update wx_rent_contract_revenue_sales set is_confirm = 1 | |||
| where `tenant_id` = #{tenantId} and `rent_contract_id` = #{rentContractId} and `starttime` >= #{starttime} and `endtime` <= #{endtime} | |||
| </update> | |||
| <update id= "updateCalcute" parameterType="com.iformall.domain.po.WxRentContractRevenueSales"> | |||
| update wx_rent_contract_revenue_sales set is_calcute = 1 | |||
| where `tenant_id` = #{tenantId} and `rent_contract_id` = #{rentContractId} and `starttime` >= #{starttime} and `endtime` <= #{endtime} | |||
| </update> | |||
| </mapper> | |||