Browse Source

fix

release_toaliyun_real
winter 1 year ago
parent
commit
5077d60999
4 changed files with 160 additions and 80 deletions
  1. +2
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumBillExtraCreateFrom.java
  2. +1
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java
  3. +145
    -79
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  4. +12
    -0
      mallinkService/src/main/resources/mapper/WxAllBillMapper.xml

+ 2
- 1
mallinkService/src/main/java/com/iformall/enums/EnumBillExtraCreateFrom.java View File

@@ -6,7 +6,8 @@ package com.iformall.enums;
*/

public enum EnumBillExtraCreateFrom {
RNET_TIAODIAN_HUISUAN(1,"跳点租金合同汇算差额自动生成")
RNET_TIAODIAN_HUISUAN(1,"跳点租金合同汇算差额自动生成"),
RNET_REVENUE_SALES(2,"录入销售额自动生成")
;

public static EnumBillExtraCreateFrom getEnum(Integer code) {


+ 1
- 0
mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java View File

@@ -24,6 +24,7 @@ public interface WxAllBillMapper extends CommonMapper<WxAllBill, Long> {
void deletePreviewBill(WxAllBill wxBillRent);
void deleteNoNeedPayBill(WxAllBill wxBillRent);
void deleteByRentHuiSuan(WxAllBill wxBillRent);
void deleteByRentReveneuSales(WxAllBill wxBillRent);
void updatePreviewStatus(WxAllBill record);



+ 145
- 79
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java View File

@@ -2559,6 +2559,19 @@ public class WxRentContractServiceImpl implements WxRentContractService {
WxAllBill rentBill = wxAllBillMapper.selectById(billId, rentcontract.getTenantId());
BigDecimal salesDeciaml = new BigDecimal(sales);
//删除自动创建的账单
WxAllBill billDel = new WxAllBill();
billDel.updateTenantInfo(rentcontract);
billDel.setRentContractId(rentcontract.getId());
billDel.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_REVENUE_SALES.getCode());
billDel.setStarttimeEqual(rentBill.getStarttime());
wxAllBillMapper.deleteByRentReveneuSales(billDel);
if (null != propertyContractId) {
billDel.setRentContractId(null);
billDel.setPropertyContractId(propertyContractId);
wxAllBillMapper.deleteByRentReveneuSales(billDel);
}
//加上物业
WxAllBill propertyBill = null;
BigDecimal propertyPrice = new BigDecimal(0);
@@ -2642,32 +2655,6 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
}
//计算资金分摊的比例 租金,商业管理费,营业管理费,物业费。每个科目税点不一样,这样分摊能降低成本
String[] moneyShareRates = new String[4];
BigDecimal rentPriceDecimal = new BigDecimal(rentPriceArrs[yearIndex]);
BigDecimal bussinessPriceDecimal = new BigDecimal(bussinessManagerPriceArrs[yearIndex]);
BigDecimal operaterPriceDecimal = new BigDecimal(operationManagerPriceArrs[yearIndex]);
if (null != rentPriceArrs && null != bussinessManagerPriceArrs && null != operationManagerPriceArrs
&& rentPriceDecimal.compareTo(new BigDecimal(0)) > 0 && bussinessPriceDecimal.compareTo(new BigDecimal(0)) > 0 && operaterPriceDecimal.compareTo(new BigDecimal(0)) > 0) {
BigDecimal total = rentPriceDecimal.add(bussinessPriceDecimal).add(operaterPriceDecimal);
BigDecimal property = new BigDecimal(0);
if (null != propertyContractArrs) {
property = new BigDecimal(propertyContractArrs[yearIndex]);
}
total = total.add(property);
moneyShareRates[0] = rentPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
moneyShareRates[1] = bussinessPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
moneyShareRates[2] = operaterPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
moneyShareRates[3] = property.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
}else {
SysConfig shareConfig = sysConfigService.getByKey(SysConfigConstant.rent_share_bill_rate, rentcontract);
if (null == shareConfig || StringUtils.isBlank(shareConfig.getConfigItemValue())) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"系统配置"+SysConfigConstant.rent_share_bill_rate+"未配置。");
}
moneyShareRates = shareConfig.getConfigItemValue().split(",");
}
//免租期
List<Date> freePeriods = getFreeDays(rentcontract);
@@ -2718,6 +2705,36 @@ public class WxRentContractServiceImpl implements WxRentContractService {
sale.setUpdateTime(new Date());
wxRentContractRevenueSalesMapper.insert(sale);
}
return handleBills(sb,rentcontract,propertyContractId,needpay,rentBill,propertyBill,rentPriceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs,propertyContractArrs,yearIndex);
}
private WxRentContractRevenueSetSalesVo handleBills(StringBuffer sb,WxRentContract rentcontract,Long propertyContractId, String needpay,WxAllBill rentBill,WxAllBill propertyBill,
String[] rentPriceArrs,String[] bussinessManagerPriceArrs,String[] operationManagerPriceArrs,String[] propertyContractArrs,int yearIndex) {
//计算资金分摊的比例 租金,商业管理费,营业管理费,物业费。每个科目税点不一样,这样分摊能降低成本
String[] moneyShareRates = new String[4];
BigDecimal rentPriceDecimal = new BigDecimal(rentPriceArrs[yearIndex]);
BigDecimal bussinessPriceDecimal = new BigDecimal(bussinessManagerPriceArrs[yearIndex]);
BigDecimal operaterPriceDecimal = new BigDecimal(operationManagerPriceArrs[yearIndex]);
if (null != rentPriceArrs && null != bussinessManagerPriceArrs && null != operationManagerPriceArrs
&& rentPriceDecimal.compareTo(new BigDecimal(0)) > 0 && bussinessPriceDecimal.compareTo(new BigDecimal(0)) > 0 && operaterPriceDecimal.compareTo(new BigDecimal(0)) > 0) {
BigDecimal total = rentPriceDecimal.add(bussinessPriceDecimal).add(operaterPriceDecimal);
BigDecimal property = new BigDecimal(0);
if (null != propertyContractArrs) {
property = new BigDecimal(propertyContractArrs[yearIndex]);
}
total = total.add(property);
moneyShareRates[0] = rentPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
moneyShareRates[1] = bussinessPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
moneyShareRates[2] = operaterPriceDecimal.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
moneyShareRates[3] = property.divide(total,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP).toPlainString();
}else {
SysConfig shareConfig = sysConfigService.getByKey(SysConfigConstant.rent_share_bill_rate, rentcontract);
if (null == shareConfig || StringUtils.isBlank(shareConfig.getConfigItemValue())) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"系统配置"+SysConfigConstant.rent_share_bill_rate+"未配置。");
}
moneyShareRates = shareConfig.getConfigItemValue().split(",");
}
String rentRate = moneyShareRates[0];
String bussinessRate = moneyShareRates[1];
@@ -2737,34 +2754,44 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
wxAllBillMapper.updateById(rentBill);
//物业账单应收就改为0,因为金额已经合并了
propertyBill = generatePropertyBill(rentcontract, propertyContractId, rentBill, needpay, propertyRate);
WxAllBill bmbill = generateManageBill(rentcontract, rentBill, needpay, bussinessRate, EnumBillAllType.RENT_BUSSINESS_MANAGE);
WxAllBill ombill = generateManageBill(rentcontract, rentBill, needpay, operaterRate, EnumBillAllType.RENT_OPERATION_MANAGE);
WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo();
vo.setTotal(needpay);
List<WxAllBill> blist = new ArrayList<WxAllBill>();
blist.add(rentBill);
if (null != propertyBill) {
String propertymoney = new BigDecimal(needpay).multiply(new BigDecimal(propertyRate)).divide(new BigDecimal(100)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString();
propertyBill.setMoneyChangeDetail("原合同物业金额:"+propertyBill.getNeedPay()+"元,计算调整为:"+propertymoney+"元。");
propertyBill.setReceivePay(propertymoney);
propertyBill.setBillRemark("设置销售额,自动计算");
if (new BigDecimal(propertyBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) {
propertyBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode());
}else {
//propertyBill.setStatus(EnumBillStatus.PAID.getCode());
}
propertyBill.setUpdatetime(new Date());
wxAllBillMapper.updateById(propertyBill);
blist.add(propertyBill);
}
if (null != bmbill) {
blist.add(bmbill);
}
if (null != ombill) {
blist.add(ombill);
}
vo.setBillList(blist);;
return vo;
}
private WxAllBill generateManageBill(WxRentContract rentcontract,WxAllBill rentBill,String total,String rate,EnumBillAllType type) {
//商业管理费,营运管理费应收改为0,因为金额已经合并了
WxAllBill bussinessmanageBill = new WxAllBill();
bussinessmanageBill.updateTenantInfo(rentcontract);
bussinessmanageBill.setBillType(EnumBillAllType.RENT_BUSSINESS_MANAGE.getCode());
bussinessmanageBill.setEnergyFeesId(EnumBillAllType.RENT_BUSSINESS_MANAGE.getEnergyFeesId());
bussinessmanageBill.setBillType(type.getCode());
bussinessmanageBill.setEnergyFeesId(type.getEnergyFeesId());
bussinessmanageBill.setRentContractId(rentcontract.getId());
bussinessmanageBill.setIsPreview(EnumYesOrNo.NO.getCode());
bussinessmanageBill.setStarttimeEqual(rentBill.getStarttime());
bussinessmanageBill.setEndtimeEqual(rentBill.getEndtime());
List<WxAllBill> bmbillList = wxAllBillMapper.findList(bussinessmanageBill);
WxAllBill bmbill = null;
String bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).divide(new BigDecimal(100)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString();
if (null != bmbillList && bmbillList.size() > 0 ) {
bmbill = bmbillList.get(0);
String bussinessmoney = new BigDecimal(needpay).multiply(new BigDecimal(bussinessRate)).divide(new BigDecimal(100)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString();
bmbill.setMoneyChangeDetail("原合同商业管理费金额:"+bmbill.getNeedPay()+"元,计算调整为:"+bussinessmoney+"元。");
bmbill.setReceivePay(bussinessmoney);
bmbill.setBillRemark("设置销售额,自动计算");
@@ -2775,48 +2802,87 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
bmbill.setUpdatetime(new Date());
wxAllBillMapper.updateById(bmbill);
}else {
bmbill = new WxAllBill();
final IdWorker idWorker = IdWorker.get();
bmbill.setId(idWorker.nextId());
bmbill.updateTenantInfo(rentcontract);
bmbill.setBillType(type.getCode());
bmbill.setEnergyFeesId(type.getEnergyFeesId());
bmbill.setRentContractId(rentcontract.getId());
bmbill.setIsPreview(EnumYesOrNo.NO.getCode());
bmbill.setMerchantId(rentcontract.getMerchantId());
bmbill.setRentShopType(rentcontract.getRentShopType());
bmbill.setCreatetime(new Date());
bmbill.setUpdatetime(new Date());
bmbill.setPriceDetail("");
bmbill.setNeedPay(bussinessmoney);
bmbill.setReceivePay(bussinessmoney);
bmbill.setPay("0");
bmbill.setStarttime(rentBill.getStarttime());
bmbill.setEndtime(rentBill.getEndtime());
bmbill.setStatus(EnumBillStatus.WAIT_PAY.getCode());
bmbill.setBillRemark("录入销售额,自动计算创建");
bmbill.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_REVENUE_SALES.getCode());
bmbill.setMoneyChangeDetail("自动计算创建,应收金额为:"+bussinessmoney+"元,");
wxAllBillMapper.insert(bmbill);
}
WxAllBill operatermanageBill = new WxAllBill();
operatermanageBill.updateTenantInfo(rentcontract);
operatermanageBill.setBillType(EnumBillAllType.RENT_OPERATION_MANAGE.getCode());
operatermanageBill.setEnergyFeesId(EnumBillAllType.RENT_OPERATION_MANAGE.getEnergyFeesId());
operatermanageBill.setRentContractId(rentcontract.getId());
operatermanageBill.setIsPreview(EnumYesOrNo.NO.getCode());
operatermanageBill.setStarttimeEqual(rentBill.getStarttime());
operatermanageBill.setEndtimeEqual(rentBill.getEndtime());
List<WxAllBill> ombillList = wxAllBillMapper.findList(operatermanageBill);
WxAllBill ombill = null;
if (null != ombillList && ombillList.size() > 0 ) {
ombill = ombillList.get(0);
String operatermoney = new BigDecimal(needpay).multiply(new BigDecimal(operaterRate)).divide(new BigDecimal(100)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString();
ombill.setMoneyChangeDetail("原合同营业管理费金额:"+bmbill.getNeedPay()+"元,计算调整为:"+operatermoney+"元。");
ombill.setReceivePay(operatermoney);
ombill.setBillRemark("设置销售额,自动计算");
if (new BigDecimal(ombill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) {
ombill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode());
return bmbill;
}
private WxAllBill generatePropertyBill(WxRentContract rentcontract,Long propertyContractId,WxAllBill rentBill,String total,String rate) {
//商业管理费,营运管理费应收改为0,因为金额已经合并了
WxAllBill propertyBillq = new WxAllBill();
propertyBillq.updateTenantInfo(rentcontract);
propertyBillq.setPropertyContractId(propertyContractId);
propertyBillq.setBillType(EnumBillAllType.PROPERTY.getCode());
propertyBillq.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId());
propertyBillq.setIsPreview(EnumYesOrNo.NO.getCode());
propertyBillq.setStarttimeEqual(rentBill.getStarttime());
propertyBillq.setEndtimeEqual(rentBill.getEndtime());
List<WxAllBill> bmbillList = wxAllBillMapper.findList(propertyBillq);
WxAllBill bmbill = null;
String bussinessmoney = new BigDecimal(total).multiply(new BigDecimal(rate)).divide(new BigDecimal(100)).setScale(rentcontract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).toPlainString();
if (null != bmbillList && bmbillList.size() > 0 ) {
bmbill = bmbillList.get(0);
bmbill.setMoneyChangeDetail("原合同商业管理费金额:"+bmbill.getNeedPay()+"元,计算调整为:"+bussinessmoney+"元。");
bmbill.setReceivePay(bussinessmoney);
bmbill.setBillRemark("设置销售额,自动计算");
if (new BigDecimal(bmbill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) {
bmbill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode());
}else {
//ombill.setStatus(EnumBillStatus.PAID.getCode());
//bmbill.setStatus(EnumBillStatus.PAID.getCode());
}
ombill.setUpdatetime(new Date());
wxAllBillMapper.updateById(ombill);
}
WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo();
vo.setTotal(needpay);
List<WxAllBill> blist = new ArrayList<WxAllBill>();
blist.add(rentBill);
if (null != propertyBill) {
blist.add(propertyBill);
}
if (null != bmbill) {
blist.add(bmbill);
}
if (null != ombill) {
blist.add(ombill);
bmbill.setUpdatetime(new Date());
wxAllBillMapper.updateById(bmbill);
}else {
bmbill = new WxAllBill();
final IdWorker idWorker = IdWorker.get();
bmbill.setId(idWorker.nextId());
bmbill.updateTenantInfo(rentcontract);
bmbill.setBillType(EnumBillAllType.PROPERTY.getCode());
bmbill.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId());
bmbill.setPropertyContractId(propertyContractId);
bmbill.setIsPreview(EnumYesOrNo.NO.getCode());
bmbill.setMerchantId(rentcontract.getMerchantId());
bmbill.setRentShopType(rentcontract.getRentShopType());
bmbill.setCreatetime(new Date());
bmbill.setUpdatetime(new Date());
bmbill.setPriceDetail("");
bmbill.setNeedPay(bussinessmoney);
bmbill.setReceivePay(bussinessmoney);
bmbill.setPay("0");
bmbill.setStarttime(rentBill.getStarttime());
bmbill.setEndtime(rentBill.getEndtime());
bmbill.setStatus(EnumBillStatus.WAIT_PAY.getCode());
bmbill.setBillRemark("录入销售额,自动计算创建");
bmbill.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_REVENUE_SALES.getCode());
bmbill.setMoneyChangeDetail("自动计算创建,应收金额为:"+bussinessmoney+"元,");
wxAllBillMapper.insert(bmbill);
}
vo.setBillList(blist);;
return vo;
return bmbill;
}


+ 12
- 0
mallinkService/src/main/resources/mapper/WxAllBillMapper.xml View File

@@ -294,6 +294,18 @@
and IFNULL(`pay`,'0') &lt;= 0 AND IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0
and extra_create_from = #{extraCreateFrom} and `starttime` = #{starttimeEqual}
</delete>
<delete id="deleteByRentReveneuSales" parameterType="com.iformall.domain.po.WxAllBill">
delete from wx_all_bill where and extra_create_from = #{extraCreateFrom}
and IFNULL(`pay`,'0') &lt;= 0 AND IFNULL(`set_off`,'0') &lt;= 0 and IFNULL(`return_pay`,'0') &lt;= 0
and `starttime` = #{starttimeEqual}
<if test=" null != rentContractId">
and rent_contract_id = #{rentContractId}
</if>
<if test=" null != propertyContractId">
and property_contract_id = #{propertyContractId}
</if>
</delete>

<update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxAllBill">
update wx_all_bill set is_preview = #{isPreview}


Loading…
Cancel
Save