diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxSettleMerchantController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxSettleMerchantController.java index 8f021e640..08ea074b9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxSettleMerchantController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxSettleMerchantController.java @@ -215,18 +215,18 @@ public class WxSettleMerchantController extends BaseController { if (null == blist || null == blist.getList() || blist.getList().size() <= 0 ) { return new ResultData(Result.ERROR,"物业合同无对应账单"); } - Long all = 0L; + BigDecimal all = new BigDecimal(0); for (int i = 0 ; i < blist.getList().size() ; i ++) { WxBillProperty r = blist.getList().get(i); - Long _np = 0L; + String _np = "0"; if (null != r.getNeedPay()) { _np = r.getNeedPay(); } - all = all + _np; + all = all.add(new BigDecimal(_np)); } Map retMap = new HashMap(); retMap.put("property", property); - retMap.put("money", new BigDecimal(all).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP)); + retMap.put("money", all.setScale(property.getDecimalSize(),BigDecimal.ROUND_HALF_UP)); return new ResultData(retMap); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java b/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java index 652ddde0b..ed2c20615 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java @@ -53,5 +53,5 @@ public interface WxBillPropertyDepositService { ResultData adjustDeposit(WxBillPropertyDeposit wxBillPropertyDeposit); - void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillPropertyDeposit deposit); + void computeTotalMoney(Integer decimalSize,WxPayAccountBill wxPayAccountBill, WxBillPropertyDeposit deposit); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java index 796da697b..d32202a9a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java @@ -688,9 +688,9 @@ public class WxBillAllServiceImpl implements WxBillAllService { } Date date = new Date(); wxBillPropertyDeposit.setPayDate(date); - Long owe = (Long) bill.get("owe"); - wxBillPropertyDeposit.setPay(wxBillPropertyDeposit.getPay() + owe); - wxBillPropertyDeposit.setOwe(0L); + String owe = (String) bill.get("owe"); + wxBillPropertyDeposit.setPay(new BigDecimal(wxBillPropertyDeposit.getPay()).add(new BigDecimal(owe)).toPlainString()); + wxBillPropertyDeposit.setOwe("0"); wxBillPropertyDeposit.setStatus(EnumBillDailyStatus.PAID.getCode()); wxBillPropertyDeposit.setPayDate(date); wxBillPropertyDeposit.setUpdatetime(date); @@ -733,9 +733,9 @@ public class WxBillAllServiceImpl implements WxBillAllService { } Date date = new Date(); property.setPayDate(date); - Long owe = (Long) bill.get("owe"); - property.setPay(property.getPay() + owe); - property.setOwe(0L); + String owe = (String) bill.get("owe"); + property.setPay(new BigDecimal(property.getPay()).add(new BigDecimal(owe)).toPlainString()); + property.setOwe("0"); property.setStatus(EnumBillDailyStatus.PAID.getCode()); property.setPayDate(date); property.setUpdatetime(date); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java index 54ed3d233..aeab4baaf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java @@ -140,17 +140,17 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe } @Override - public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillPropertyDeposit deposit) { + public void computeTotalMoney(Integer decimalSize,WxPayAccountBill wxPayAccountBill, WxBillPropertyDeposit deposit) { if (deposit.getReceivePay() != null) { BigDecimal servicePay; if (deposit.getServiceChargePay() != null) { servicePay = new BigDecimal(deposit.getServiceChargePay()); } else { - servicePay = new BigDecimal(deposit.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); + servicePay = new BigDecimal(deposit.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), decimalSize, BigDecimal.ROUND_HALF_UP); } - Long realReceivePay = servicePay.longValue() + deposit.getReceivePay(); - deposit.setRealReceivePay(realReceivePay); - deposit.setServiceChargePay(servicePay.intValue()); + BigDecimal realReceivePay = servicePay.add(new BigDecimal(deposit.getReceivePay())); + deposit.setRealReceivePay(realReceivePay.toPlainString()); + deposit.setServiceChargePay(servicePay.toPlainString()); } } @@ -204,9 +204,9 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe @Override public ResultData saveOrUpdate(WxBillPropertyDeposit record, MallUserInfo user) { - int receivepay = record.getReceivePay()==null?0:record.getReceivePay().intValue(); - int pay = record.getPay()==null?0:record.getPay().intValue(); - if(pay>receivepay){ + String receivepay = StringUtils.isBlank(record.getReceivePay()) ? "0" : record.getReceivePay(); + String pay = StringUtils.isBlank(record.getPay()) ? "0" : record.getPay(); + if(new BigDecimal(pay).compareTo(new BigDecimal(receivepay)) > 0 ){ return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(), "实收金额不能大于实际应收金额"); } Date date = new Date(); @@ -216,7 +216,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe record.setId(idWorker.nextId()); record.setCreatetime(date); record.setUpdatetime(date); - record.setOwe(record.getReceivePay()-record.getPay()); + record.setOwe(new BigDecimal(receivepay).subtract(new BigDecimal(pay)).toPlainString()); record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); try { wxBillPropertyDepositMapper.insert(record); @@ -231,10 +231,10 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe if(record==null){ return new ResultData(ErrorCode.BILL_PROPERTY_DEPOSIT_IS_NOT_FOUND); } - Long addpay = wxBillDeposit.getPay(); + String addpay = wxBillDeposit.getPay(); wxBillDeposit.setPay(record.getPay()); wxBillDeposit.setReceivePay(record.getReceivePay()); - wxBillDeposit.setOwe(record.getReceivePay() - record.getPay()); + wxBillDeposit.setOwe(new BigDecimal(receivepay).subtract(new BigDecimal(pay)).toPlainString()); if (record.getPay().equals(record.getReceivePay())) { wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); Date receiveDate = wxBillDeposit.getReceiveDate(); @@ -257,7 +257,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe WxBillAction wxBillAction = new WxBillAction(); wxBillAction.setBillId(wxBillDeposit.getId()); String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); - String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); + String price = new BigDecimal(record.getPay()).subtract(new BigDecimal(addpay)).toPlainString(); wxBillAction.setDetails(message + price + "元"); wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); wxBillAction.setUserId(user.getId()); @@ -346,7 +346,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe return new ResultData(ErrorCode.BILL_OTHER_DEPOSIT_IS_NOT_FOUND); } wxBillDeposit.setReceivePay(record.getReceivePay()); - wxBillDeposit.setOwe(record.getReceivePay() - record.getPay()); + wxBillDeposit.setOwe(new BigDecimal(record.getReceivePay()).subtract(new BigDecimal(record.getPay())).toPlainString()); wxBillDeposit.setUpdatetime(new Date()); try { wxBillPropertyDepositMapper.updateById(wxBillDeposit); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java index 19b243ed3..87a7f9bc6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java @@ -205,7 +205,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { //手续费 = 合同应收+手续费+滞纳金 if (e.getReceivePay() != null) { if (e.getLatePayPrice() == null) { - long latePayPrice = 0L; + String latePayPrice = "0"; e.setLatePayPrice(latePayPrice); } BigDecimal servicePay; @@ -214,13 +214,13 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { } else { servicePay = new BigDecimal(e.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); } - Long realReceivePay = servicePay.longValue() + e.getLatePayPrice() + e.getReceivePay(); - e.setRealReceivePay(realReceivePay); - e.setServiceChargePay(servicePay.intValue()); + BigDecimal realReceivePay = servicePay.add(new BigDecimal(e.getLatePayPrice())).add(new BigDecimal(e.getReceivePay())); + e.setRealReceivePay(realReceivePay.toPlainString()); + e.setServiceChargePay(servicePay.toPlainString()); if (!e.getStatus().equals(EnumBillRentStatus.NOT_PAID.getCode())) { - e.setOwe(0L); + e.setOwe("0"); } else { - e.setOwe(realReceivePay - e.getPay()); + e.setOwe(realReceivePay.subtract(new BigDecimal(e.getPay())).toPlainString()); } } } @@ -274,15 +274,15 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { record.updateTenantInfo(tenantEntity); PageInfo page = getBillPropertyList(1, 10000, wxPayAccountBill, record); WxBillProperty property = page.getList().get(0); - property.setOwe(property.getRealReceivePay() - property.getPay()); + property.setOwe(new BigDecimal(property.getRealReceivePay()).subtract(new BigDecimal(property.getPay())).toPlainString()); return property; } @Override public ResultData saveOrUpdate(WxBillProperty record, MallUserInfo user) { - int receivepay = record.getRealReceivePay() == null ? 0 : record.getRealReceivePay().intValue(); - int pay = record.getPay() == null ? 0 : record.getPay().intValue(); - if (pay > receivepay) { + String receivepay = StringUtils.isBlank(record.getRealReceivePay()) ? "0" : record.getRealReceivePay(); + String pay = StringUtils.isBlank(record.getPay()) ? "0" : record.getPay(); + if (new BigDecimal(pay).compareTo(new BigDecimal(receivepay)) > 0 ) { return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(), "实收金额不能大于实际应收总金额"); } Date date = new Date(); @@ -292,7 +292,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { record.setId(idWorker.nextId()); record.setCreatetime(date); record.setUpdatetime(date); - record.setOwe(record.getRealReceivePay() - record.getPay()); + record.setOwe(new BigDecimal(record.getRealReceivePay()).subtract(new BigDecimal(record.getPay())).toPlainString()); record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); try { wxBillPropertyMapper.insert(record); @@ -311,12 +311,12 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { String message = ""; String price = ""; if (record.getServiceChargePayUpdate() != null) { - Double l = Double.valueOf(record.getServiceChargePayUpdate()) * 100; - property.setServiceChargePay(l.intValue()); - long latePayPrice = property.getLatePayPrice() == null ? 0 : property.getLatePayPrice(); - property.setOwe(property.getReceivePay() + latePayPrice + property.getServiceChargePay() - property.getPay()); + property.setServiceChargePay(record.getServiceChargePayUpdate()); + String latePayPrice = StringUtils.isBlank(property.getLatePayPrice()) ? "0" : property.getLatePayPrice(); + property.setOwe(new BigDecimal(property.getReceivePay()).add(new BigDecimal(latePayPrice)) + .add(new BigDecimal(property.getServiceChargePay())).subtract(new BigDecimal(property.getPay())).toPlainString()); } else { - Long addpay = property.getPay(); + String addpay = property.getPay(); property.setRevenue(record.getRevenue()); property.setLatePayRatio(record.getLatePayRatio()); property.setLatePayTime(record.getLatePayTime()); @@ -324,7 +324,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { property.setPayDate(record.getPayDate()); property.setPay(record.getPay()); property.setReceivePay(record.getReceivePay()); - property.setOwe(record.getRealReceivePay() - record.getPay()); + property.setOwe(new BigDecimal(record.getRealReceivePay()).subtract(new BigDecimal(record.getPay())).toPlainString()); if (record.getPay().equals(record.getRealReceivePay())) { property.setStatus(EnumBillRentStatus.PAID.getCode()); Date payDate = record.getPayDate(); @@ -339,7 +339,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { property.setUpdatetime(date); property.setPayWay(record.getPayWay()); message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); - price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); + price = new BigDecimal(record.getPay()).subtract(new BigDecimal(addpay)).toPlainString(); } try { @@ -489,8 +489,9 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { WxBillProperty property = wxBillPropertyMapper.selectById(record.getId()); if (record.getLatePayMoneyUpdate() != null) { - property.setLatePayPrice(Long.parseLong(record.getLatePayMoneyUpdate()) * 100); - property.setOwe(property.getReceivePay() + property.getLatePayPrice() + property.getServiceChargePay() - property.getPay()); + property.setLatePayPrice(record.getLatePayMoneyUpdate()); + property.setOwe(new BigDecimal(property.getReceivePay()).add(new BigDecimal(property.getLatePayPrice())) + .add(new BigDecimal(property.getServiceChargePay())).subtract(new BigDecimal(property.getPay())).toPlainString()); final IdWorker idWorker = IdWorker.get(); WxBillAction billAction = new WxBillAction(); billAction.setId(idWorker.nextId()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java index b3facdca5..4003cbb6c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java @@ -273,9 +273,9 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { propertyDeposit.setPayDate(new Date()); WxBillPropertyDeposit dbBill = wxBillPropertyDepositMapper.selectById(wxBillRent.getId()); if(dbBill!=null) { - if(dbBill.getPay() == null) dbBill.setPay(0l); - if(dbBill.getReceivePay() == null) dbBill.setReceivePay(0l); - propertyDeposit.setPay(dbBill.getPay()+ dbBill.getReceivePay()); + if(StringUtils.isBlank(dbBill.getPay())) dbBill.setPay("0"); + if(StringUtils.isBlank(dbBill.getReceivePay())) dbBill.setReceivePay("0"); + propertyDeposit.setPay(new BigDecimal(dbBill.getPay()).add(new BigDecimal(dbBill.getReceivePay())).toPlainString()); propertyDeposit.setPayDate(new Date()); if(EnumSettleBillType.R.getCode().equals(bill.getType())){ propertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); @@ -305,9 +305,9 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { wxBillRent.setPayDate(new Date()); WxBillProperty dbBill = wxBillPropertyMapper.selectById(wxBillRent.getId()); if(dbBill!=null) { - if(dbBill.getPay() == null) dbBill.setPay(0l); - if(dbBill.getOwe() == null) dbBill.setOwe(0l); - wxBillRent.setPay(dbBill.getPay()+dbBill.getOwe()); + if(StringUtils.isBlank(dbBill.getPay())) dbBill.setPay("0"); + if(StringUtils.isBlank(dbBill.getOwe())) dbBill.setOwe("0"); + wxBillRent.setPay(new BigDecimal(dbBill.getPay()).add(new BigDecimal(dbBill.getOwe())).toPlainString()); wxBillRent.setPayDate(new Date()); addBillAction(bill.getBillId(), String.valueOf(dbBill.getOwe())); } @@ -331,9 +331,9 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { propertyDeposit.setPayDate(new Date()); WxBillPropertyDeposit dbBill = wxBillPropertyDepositMapper.selectById(wxBillRent.getId()); if(dbBill!=null) { - if(dbBill.getPay() == null) dbBill.setPay(0l); - if(dbBill.getReceivePay() == null) dbBill.setReceivePay(0l); - propertyDeposit.setPay(dbBill.getPay()+dbBill.getReceivePay()); + if(StringUtils.isBlank(dbBill.getPay())) dbBill.setPay("0"); + if(StringUtils.isBlank(dbBill.getReceivePay())) dbBill.setReceivePay("0"); + propertyDeposit.setPay(new BigDecimal(dbBill.getPay()).add(new BigDecimal(dbBill.getReceivePay())).toPlainString()); propertyDeposit.setPayDate(new Date()); if(EnumSettleBillType.R.getCode().equals(bill.getType())){ propertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java index d3a0441cf..b076ae172 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java @@ -162,9 +162,9 @@ public class WxBusinessServiceImpl implements WxBusinessService { continue; } logger.info("业态分析>>>>>>>>>>>>>>>>>>物业合同ID:" + dbRent.getId()); - Long price = dbRent.getPrice(); + String price = dbRent.getPrice(); Integer priceUnit = dbRent.getPriceUnit(); - BigDecimal priceDecimal = getPriceDecimal(dbRent.getDecimalSize(),day, String.valueOf(price), priceUnit, EnumRentContractType.RENT_BY_AREA.getCode(), null, null); + BigDecimal priceDecimal = getPriceDecimal(dbRent.getDecimalSize(),day, price, priceUnit, EnumRentContractType.RENT_BY_AREA.getCode(), null, null); businessSumMoney = businessSumMoney.add(priceDecimal); } logger.info("业态分析>>>>>>>>>>>>>>>>>>商铺面积:" + e.get("area").toString()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index 94d1f1195..6423a6e2f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -136,12 +136,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService //查询rent_info 包括shopId for (int i = 0; i < size; i++) { JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); - Double rentPrice = rentInfoObject.getDouble("rentPrice"); - Long price = wxPropertyContract.getPrice()/100; + String rentPrice = rentInfoObject.getString("rentPrice"); + String price = wxPropertyContract.getPrice(); if(rentPrice == null){ if(StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea())&& !"0.0".equals(wxPropertyContract.getRentArea()) ) { Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()); - rentPrice = new BigDecimal((double) price / rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea),wxPropertyContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP).toPlainString(); rentInfoObject.put("rentPrice", rentPrice); } } @@ -150,12 +150,11 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService }else{ if(StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea())&& !"0.0".equals(wxPropertyContract.getRentArea()) ) { if(StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea())) { - Long price = wxPropertyContract.getPrice(); + String price = wxPropertyContract.getPrice(); Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()) * 100; - Double rentPrice = new BigDecimal((double) price / rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - rentPrice = rentPrice * 100; - if (rentPrice > 0) { - wxPropertyContract.setRentPrice(rentPrice.toString()); + BigDecimal rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea),wxPropertyContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); + if (rentPrice.compareTo(new BigDecimal(0)) > 0) { + wxPropertyContract.setRentPrice(rentPrice.toPlainString()); } else { wxPropertyContract.setRentPrice("0"); } @@ -170,8 +169,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxPropertyContract.setPriceUnit(EnumPriceUnit.D.getCode()); } - wxPropertyContract.setPrice(wxPropertyContract.getPrice() != null ? wxPropertyContract.getPrice() : 0); - wxPropertyContract.setDeposit(wxPropertyContract.getDeposit() != null ? wxPropertyContract.getDeposit() : 0); + wxPropertyContract.setPrice(StringUtils.isNotBlank(wxPropertyContract.getPrice()) ? wxPropertyContract.getPrice() : "0"); + wxPropertyContract.setDeposit(StringUtils.isNotBlank(wxPropertyContract.getDeposit()) ? wxPropertyContract.getDeposit() : "0"); result.put("wxPropertyContract", wxPropertyContract); //关联的商户 @@ -263,9 +262,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService bill.setPeriod(count); bill.setIsPreview(EnumIsPreview.YES.getCode()); bill.setShopInfo(getShopInfoStr(record)); - bill.setRevenue(0L); + bill.setRevenue("0"); bill.setLatePayRatio(0); - bill.setPay(0L); + bill.setPay("0"); bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); //bill.setShopId(record.getShopId()); bill.setExpiredDay(0L); @@ -274,9 +273,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService bill.setStatus(EnumBillRentStatus.PAID.getCode()); bill.setPayDate(date); } - BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - bill.setServiceChargePay(servicePay.intValue()); - bill.setOwe(bill.getReceivePay() + bill.getServiceChargePay()); + BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(100), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); + bill.setServiceChargePay(servicePay.toPlainString()); + bill.setOwe(new BigDecimal(bill.getReceivePay()).add(new BigDecimal(bill.getServiceChargePay())).toPlainString()); count++; } wxBillPropertyMapper.insertBills(record.getPreviewBillRentList()); @@ -416,8 +415,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService record.setRentalEndDate(wxRentContract.getRentalEndDate()); record.setStartDate(wxRentContract.getStartDate()); record.setEndDate(wxRentContract.getEndDate()); - record.setPrice(record.getPrice() != null ? record.getPrice() : 0); - record.setDeposit(record.getDeposit() != null ? record.getDeposit() : 0); + record.setPrice(StringUtils.isNotBlank(record.getPrice()) ? record.getPrice() : "0"); + record.setDeposit(StringUtils.isNotBlank(record.getDeposit()) ? record.getDeposit() : "0"); record.setUpdatetime(new Date()); //如果是合并合同 物业合同的状态为 意向 @@ -464,9 +463,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } wxPropertyContractMapper.updateById(wxPropertyContract); //建立账单 - if (record.getMerchantId() != null - && record.getReceivePeriod() != null && - record.getPrice() > 0) { + if (record.getMerchantId() != null && record.getReceivePeriod() != null + && new BigDecimal(record.getPrice()).compareTo(new BigDecimal(0)) > 0) { //预览账单改为正式,并写入商户id updatePropertyPreviewBill(record); } @@ -480,7 +478,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService billProperty.setIsPreview(EnumIsPreview.NO.getCode()); billProperty.setMerchantId(record.getMerchantId()); wxBillPropertyMapper.updatePreviewStatus(billProperty); - if(record.getDeposit() > 0) { + if(new BigDecimal(record.getDeposit()).compareTo(new BigDecimal(0)) > 0) { buildDeposit(record); } } @@ -489,15 +487,15 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService public void buildDeposit(WxPropertyContract record) { Long propertyContractId = record.getId(); WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById(propertyContractId); - if (wxPropertyContract != null && wxPropertyContract.getDeposit() > 0) { + if (wxPropertyContract != null && new BigDecimal(wxPropertyContract.getDeposit()).compareTo(new BigDecimal(0)) > 0) { //找到计租方式 int dayType = wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; final IdWorker idWorker = IdWorker.get(); WxBillPropertyDeposit wxBillDeposit = new WxBillPropertyDeposit(); wxBillDeposit.setId(idWorker.nextId()); wxBillDeposit.setPropertyContractId(wxPropertyContract.getId()); - wxBillDeposit.setPay(0L); - Long needpay = wxPropertyContract.getDeposit(); + wxBillDeposit.setPay("0"); + String needpay = wxPropertyContract.getDeposit(); wxBillDeposit.setNeedPay(needpay); wxBillDeposit.setReceivePay(needpay); wxBillDeposit.setOwe(needpay); @@ -550,7 +548,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return JSONObject.toJSONString(shopInfo); } - public List buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview,boolean saveDb) { + public List buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview,boolean saveDb) { String adjustRatio = wxPropertyContract.getAdjustRatio(); String rentInfo = wxPropertyContract.getRentInfo(); Map shopInfo = new HashMap<>(); @@ -565,24 +563,24 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService List integers = JSONArray.parseArray(adjustRatio, Integer.class); integers.add(0, 0); int size = integers.size(); - long[] priceArr = new long[size]; + String[] priceArr = new String[size]; priceArr[0] = price; //判断年租金调整方式 if (wxPropertyContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { - double priceD = price; + BigDecimal priceD = new BigDecimal(price); for (int i = 1; i < size; i++) { - priceD = priceD + priceD * integers.get(i) / 10000.0; - priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue(); + priceD = priceD.add(priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100))); + priceArr[i] = priceD.setScale(wxPropertyContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); } } else if (wxPropertyContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { - long priceD = price; + BigDecimal priceD = new BigDecimal(price); for (int i = 1; i < size; i++) { - priceD = priceD + integers.get(i); - priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue(); + priceD = priceD.add(new BigDecimal(integers.get(i))); + priceArr[i] = priceD.setScale(wxPropertyContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); } } else { for (int i = 1; i < size; i++) { - priceArr[i] = new BigDecimal(integers.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); + priceArr[i] = new BigDecimal(integers.get(i)).setScale(wxPropertyContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); } } @@ -626,7 +624,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return resultList; } - public Map buildRent(int receivePeriod,long[] priceArrs, List yearList,int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview,Map shopInfo,boolean saveDb) { + public Map buildRent(int receivePeriod,String[] priceArrs, List yearList,int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview,Map shopInfo,boolean saveDb) { WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxPropertyContract); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); Map resultMap = new HashedMap(); @@ -656,7 +654,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService for (int i = 0; i < billTimeVoList.size(); i++) { BillTimeVo billTimeVo = billTimeVoList.get(i); //计算金额 - long needpay = 0; + String needpay = "0"; boolean flag = false; if(yearList.size() > 1) { @@ -669,8 +667,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService //如果是计算账单金额&cross 拆分日期进行计算 if(!saveDb && billTimeVo.getEndDate().after(endDate)) { - long needpayFront = 0; - long needpayAfter = 0; + String needpayFront = "0"; + String needpayAfter = "0"; //同一天,算一天 if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ needpayFront = getNeedPayMoney(wxPropertyContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod); @@ -705,7 +703,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxBillProperty.setIsPreview(isPreview); wxBillProperty.setId(idWorker.nextId()); wxBillProperty.setPropertyContractId(wxPropertyContract.getId()); - wxBillProperty.setPay(0L); + wxBillProperty.setPay("0"); wxBillProperty.setStarttime(billTimeVo.getStartDate()); wxBillProperty.setEndtime(billTimeVo.getEndDate()); wxBillProperty.setReceiveDate(billTimeVo.getReceiveDate()); @@ -733,9 +731,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxBillProperty.setLatePayRatio(0); //计算手续费 - BigDecimal servicePay = new BigDecimal(wxBillProperty.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - wxBillProperty.setServiceChargePay(servicePay.intValue()); - wxBillProperty.setOwe(wxBillProperty.getReceivePay() + wxBillProperty.getServiceChargePay()); + BigDecimal servicePay = new BigDecimal(wxBillProperty.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(100), wxPropertyContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); + wxBillProperty.setServiceChargePay(servicePay.toPlainString()); + wxBillProperty.setOwe(new BigDecimal(wxBillProperty.getReceivePay()).add(new BigDecimal(wxBillProperty.getServiceChargePay())).toPlainString()); resultList.add(wxBillProperty); } @@ -748,13 +746,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return resultMap; } - public long getNeedPayMoney(WxPropertyContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod){ - long needpay; + public String getNeedPayMoney(WxPropertyContract wxRentContract,String price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod){ + String needpay; //按日 if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ BigDecimal priceD = new BigDecimal(price); String needpayD = WxRentContractHelper.getNeedPay(wxRentContract.getDecimalSize(),new BigDecimal(0),priceD,startDate,endDate); - needpay = new Double(needpayD).longValue(); + needpay = needpayD; }else{ //年 需要除12 BigDecimal priceD = new BigDecimal(price); @@ -764,7 +762,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService //生成金额直接计算 if(!saveDb){ - needpay = new Double(WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); return needpay; } @@ -777,18 +775,18 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if(sdMR.format(startDate).equals(sdMR.format(wxRentContract.getStartDate())) && sdMR.format(endDate).equals(sdMR.format(wxRentContract.getEndDate())) ){ int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); months++; - needpay = new BigDecimal(months).multiply(priceD).longValue(); + needpay = new BigDecimal(months).multiply(priceD).toPlainString(); }else { - needpay = new Double(WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); } }else if(i == 0){//第一期 if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ if(isFirstDay(startDate)){ int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); months++; - needpay = new BigDecimal(months).multiply(priceD).longValue(); + needpay = new BigDecimal(months).multiply(priceD).toPlainString(); }else{ - needpay = new Double(WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); } }else{ if(isFirstDay(startDate)){ @@ -796,9 +794,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if(isFirstDay(startDate)){ months++; } - needpay = new BigDecimal(months).multiply(priceD).longValue(); + needpay = new BigDecimal(months).multiply(priceD).toPlainString(); }else{ - needpay = new Double(WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); } } }else{//中间 @@ -806,7 +804,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if(isFirstDay(startDate)){ months++; } - needpay = new BigDecimal(months).multiply(priceD).longValue(); + needpay = new BigDecimal(months).multiply(priceD).toPlainString(); } } return needpay; @@ -874,7 +872,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService rentalStartDate = wxPropertyContract.getStartDate(); } propertyContract.setRentalStartDate(rentalStartDate); - Long price = propertyContract.getPrice(); + String price = propertyContract.getPrice(); //按月计租 result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview,saveDb);