From 2b82fad89ba5c735dd80eb5193010454ae8d05b6 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Mon, 21 Oct 2019 16:27:03 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=B4=A6=E5=8D=95][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E6=89=8B=E7=BB=AD=E8=B4=B9]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rent/WxBillDepositController.java | 4 +- .../rent/WxBillPropertyDepositController.java | 4 +- .../com/iformall/domain/po/WxBillDeposit.java | 3 + .../domain/po/WxBillPropertyDeposit.java | 3 + .../iformall/mapper/WxBillDepositMapper.java | 2 +- .../mapper/WxBillPropertyDepositMapper.java | 2 +- .../service/WxBillDepositService.java | 10 +- .../service/WxBillPropertyDepositService.java | 6 +- .../service/impl/WxBillAllServiceImpl.java | 143 ++++++++++-------- .../service/impl/WxBillDailyServiceImpl.java | 46 +++--- .../impl/WxBillDepositServiceImpl.java | 38 ++--- .../impl/WxBillOtherDepositServiceImpl.java | 45 +++--- .../service/impl/WxBillOtherServiceImpl.java | 46 +++--- .../WxBillPropertyDepositServiceImpl.java | 38 ++--- .../impl/WxBillPropertyServiceImpl.java | 137 +++++++---------- .../service/impl/WxBillRentServiceImpl.java | 95 +++++------- .../resources/mapper/WxBillDepositMapper.xml | 19 +-- .../mapper/WxBillPropertyDepositMapper.xml | 15 +- 18 files changed, 310 insertions(+), 346 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDepositController.java b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDepositController.java index 2e514711d..2bc4ce597 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDepositController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDepositController.java @@ -14,8 +14,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.Map; - /** * @author gongbiao */ @@ -38,7 +36,7 @@ public class WxBillDepositController extends BaseController { wxBillDeposit = new WxBillDeposit(); } wxBillDeposit.setTenantId(getTenantId()); - final PageInfo> page = wxBillDepositService.listAsPage(wxBillDeposit, pageNum, pageSize); + final PageInfo page = wxBillDepositService.listAsPage(wxBillDeposit, pageNum, pageSize); return new ResultData(page); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillPropertyDepositController.java b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillPropertyDepositController.java index e61a8defe..cfdc94f30 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillPropertyDepositController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillPropertyDepositController.java @@ -14,8 +14,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.Map; - /** * @author gongbiao */ @@ -38,7 +36,7 @@ public class WxBillPropertyDepositController extends BaseController { wxBillPropertyDeposit = new WxBillPropertyDeposit(); } wxBillPropertyDeposit.setTenantId(getTenantId()); - PageInfo> result = wxBillPropertyDepositService.listAsPage(wxBillPropertyDeposit, pageNum, pageSize); + PageInfo result = wxBillPropertyDepositService.listAsPage(wxBillPropertyDeposit, pageNum, pageSize); return new ResultData(result); } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxBillDeposit.java b/mallinkService/src/main/java/com/iformall/domain/po/WxBillDeposit.java index f019263a2..925ff8cf5 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxBillDeposit.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxBillDeposit.java @@ -23,6 +23,9 @@ public class WxBillDeposit extends BaseEntity { @TableField(exist = false) private String merchantName; + @TableField(exist = false) + private String shopNumber; + @io.swagger.annotations.ApiModelProperty(value="租金合同ID",name="rentContractId") private Long rentContractId; @io.swagger.annotations.ApiModelProperty(value="实际应收金额",name="receivePay") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxBillPropertyDeposit.java b/mallinkService/src/main/java/com/iformall/domain/po/WxBillPropertyDeposit.java index 74d850971..1b1434b1c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxBillPropertyDeposit.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxBillPropertyDeposit.java @@ -21,6 +21,9 @@ public class WxBillPropertyDeposit extends BaseEntity { @TableField(exist = false) private String merchantName; + @TableField(exist = false) + private String shopNumber; + @io.swagger.annotations.ApiModelProperty(value="物业合同ID",name="propertyContractId") private Long propertyContractId; @io.swagger.annotations.ApiModelProperty(value="实际应收金额",name="receivePay") diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillDepositMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillDepositMapper.java index ff0060e53..c13448e58 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillDepositMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillDepositMapper.java @@ -14,7 +14,7 @@ public interface WxBillDepositMapper extends CommonMapper { List findList(WxBillDeposit wxBillDeposit); - List> queryBillDepositList(WxBillDeposit record); + List queryBillDepositList(WxBillDeposit record); Map queryPayInfo(Map params); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyDepositMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyDepositMapper.java index 37442397e..077f02681 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyDepositMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyDepositMapper.java @@ -14,7 +14,7 @@ public interface WxBillPropertyDepositMapper extends CommonMapper findList(WxBillPropertyDeposit wxBillPropertyDeposit); - List> queryBillDepositList(WxBillPropertyDeposit record); + List queryBillDepositList(WxBillPropertyDeposit record); Map queryPayInfo(Map params); diff --git a/mallinkService/src/main/java/com/iformall/service/WxBillDepositService.java b/mallinkService/src/main/java/com/iformall/service/WxBillDepositService.java index 5bd145511..2d4145550 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxBillDepositService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxBillDepositService.java @@ -4,8 +4,7 @@ import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxBillDeposit; - -import java.util.Map; +import com.iformall.domain.po.WxPayAccountBill; public interface WxBillDepositService { @@ -17,7 +16,7 @@ public interface WxBillDepositService { * @param record * @return */ - PageInfo> listAsPage(WxBillDeposit record, Integer pageIndex, Integer pageSize); + PageInfo listAsPage(WxBillDeposit record, Integer pageIndex, Integer pageSize); void updateBillStatus(WxBillDeposit record); @@ -27,7 +26,7 @@ public interface WxBillDepositService { * @param id * @return */ - Map getById(Long id); + WxBillDeposit getById(Long id); /** * 保存或更新实体 @@ -50,4 +49,7 @@ public interface WxBillDepositService { ResultData returnDeposit(WxBillDeposit wxBillDeposit, MallUserInfo user); ResultData adjustDeposit(WxBillDeposit wxBillDeposit); + + void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillDeposit deposit); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java b/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java index 832446725..9f318ed2a 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxBillPropertyDepositService.java @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxBillPropertyDeposit; +import com.iformall.domain.po.WxPayAccountBill; import java.util.Map; @@ -20,7 +21,7 @@ public interface WxBillPropertyDepositService { * @param record * @return */ - PageInfo> listAsPage(WxBillPropertyDeposit record, Integer pageIndex, Integer pageSize); + PageInfo listAsPage(WxBillPropertyDeposit record, Integer pageIndex, Integer pageSize); void updateBillStatus(WxBillPropertyDeposit record); @@ -30,7 +31,7 @@ public interface WxBillPropertyDepositService { * @param id * @return */ - Map getById(Long id); + WxBillPropertyDeposit getById(Long id); /** * 保存或更新实体 @@ -54,4 +55,5 @@ public interface WxBillPropertyDepositService { ResultData adjustDeposit(WxBillPropertyDeposit wxBillPropertyDeposit); + void computeTotalMoney(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 5ce01abc3..567a5009e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java @@ -147,26 +147,31 @@ public class WxBillAllServiceImpl implements WxBillAllService { PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillAllMapper.list(record)); //手续费 = 合同应收+手续费+滞纳金 - pageInfo.getList().stream().forEach(e->{ + pageInfo.getList().stream().forEach(e -> { //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + cmputeTotalMoney(wxPayAccountBill, e); }); Map result = new HashMap<>(); result.put("pageInfo", pageInfo); return result; } + + public void cmputeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillAllVo e) { + if (e.getReceivePay() != null) { + if (e.getLatePayPrice() == null) e.setLatePayPrice(0L); + BigDecimal servicePay; + if (e.getServiceChargePay() != null) { + servicePay = new BigDecimal(e.getServiceChargePay()); + } 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()); + } + } + @Override public List> listBillOweAndWaitPay(WxBillAll wxBillAll) { //更新各账单状态 @@ -203,7 +208,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { wxBillAll.setBillTypeValue(EnumBillTypeParam.ROUTINE.getCode()); } else if (wxBillAll.getBillTypeValue().equals(EnumBillType.AIR_CONDITIONING.getCode())) { wxBillAll.setBillTypeValue(EnumBillTypeParam.AIR_CONDITIONING.getCode()); - }else if (wxBillAll.getBillTypeValue().equals(EnumBillType.SETTLE.getCode())) { + } else if (wxBillAll.getBillTypeValue().equals(EnumBillType.SETTLE.getCode())) { wxBillAll.setBillTypeValue(EnumBillTypeParam.SETTLE.getCode()); } else { logger.info("账单不存在"); @@ -213,28 +218,28 @@ public class WxBillAllServiceImpl implements WxBillAllService { if (wxBillAll.getPageIndex() != null && wxBillAll.getPageIndex() != null) { PageHelper.startPage(wxBillAll.getPageIndex(), wxBillAll.getPageSize()); List> maps = wxBillAllMapper.listData(wxBillAll); - for (Map map:maps) { - Integer billType = ((Long)map.get("billTypeValue")).intValue(); - if(EnumBillType.SETTLE.getCode().equals(billType)){ - Long id = (Long)map.get("id"); - WxBillSettle settle = wxBillSettleService.getById(id,EnumFilterSettle.YES.getCode()); - map.put("owe",settle.getBalance()); - settle = wxBillSettleService.getById(id,EnumFilterSettle.NO.getCode()); - map.put("receivePay",settle.getBalance()); + for (Map map : maps) { + Integer billType = ((Long) map.get("billTypeValue")).intValue(); + if (EnumBillType.SETTLE.getCode().equals(billType)) { + Long id = (Long) map.get("id"); + WxBillSettle settle = wxBillSettleService.getById(id, EnumFilterSettle.YES.getCode()); + map.put("owe", settle.getBalance()); + settle = wxBillSettleService.getById(id, EnumFilterSettle.NO.getCode()); + map.put("receivePay", settle.getBalance()); } } PageInfo> pageInfo = new PageInfo<>(maps); return new ResultData(pageInfo); } List> maps = wxBillAllMapper.listData(wxBillAll); - for (Map map:maps) { - Integer billType = ((Long)map.get("billTypeValue")).intValue(); - if(EnumBillType.SETTLE.getCode().equals(billType)){ - Long id = (Long)map.get("id"); - WxBillSettle settle = wxBillSettleService.getById(id,EnumFilterSettle.YES.getCode()); - map.put("owe",settle.getBalance()); - settle = wxBillSettleService.getById(id,EnumFilterSettle.NO.getCode()); - map.put("receivePay",settle.getBalance()); + for (Map map : maps) { + Integer billType = ((Long) map.get("billTypeValue")).intValue(); + if (EnumBillType.SETTLE.getCode().equals(billType)) { + Long id = (Long) map.get("id"); + WxBillSettle settle = wxBillSettleService.getById(id, EnumFilterSettle.YES.getCode()); + map.put("owe", settle.getBalance()); + settle = wxBillSettleService.getById(id, EnumFilterSettle.NO.getCode()); + map.put("receivePay", settle.getBalance()); } } return new ResultData(maps); @@ -302,30 +307,30 @@ public class WxBillAllServiceImpl implements WxBillAllService { try { logger.info("更新结算单id:{}", JsonUtil.obj2Json(bill)); - WxBillSettle wxBillSettle = wxBillSettleService.getById((Long)bill.get("id"), EnumFilterSettle.YES.getCode()); + WxBillSettle wxBillSettle = wxBillSettleService.getById((Long) bill.get("id"), EnumFilterSettle.YES.getCode()); WxBillSettleRecord settleRecord = new WxBillSettleRecord(); - settleRecord.setSettleId((Long)bill.get("id")); + settleRecord.setSettleId((Long) bill.get("id")); settleRecord.setSettleMoney(wxBillSettle.getBalance()); settleRecord.setSettleTime(new Date()); settleRecord.setSettleWay(EnumSettleRecordWay.WEBCAT.getCode()); settleRecord.setTenantId(wxBillSettle.getTenantId()); BigDecimal money = new BigDecimal(settleRecord.getSettleMoney()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP); - settleRecord.setDetail(EnumSettleRecordWay.getEnum(settleRecord.getSettleWay()).getMessage()+"收款"+money.toString()+"元"); - wxBillSettleRecordService.saveOrUpdate(settleRecord,null,(Long)bill.get("userId")); + settleRecord.setDetail(EnumSettleRecordWay.getEnum(settleRecord.getSettleWay()).getMessage() + "收款" + money.toString() + "元"); + wxBillSettleRecordService.saveOrUpdate(settleRecord, null, (Long) bill.get("userId")); wxBillSettle.setUpdatetime(new Date()); wxBillSettle.setStatus(EnumSettleStatus.FINISH.getCode()); wxBillSettleMapper.updateById(wxBillSettle); logger.info("更新结算单success"); - }catch (Exception e){ - logger.error("结算单error",e); + } catch (Exception e) { + logger.error("结算单error", e); e.printStackTrace(); } - }else{ + } else { logger.info("账单类型不存在"); } } @@ -357,7 +362,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { wxBillAllVo.setRentEndTime(DateUtils.format(wxBillAllVo.getEndtime())); //status不是欠缴,都展示0,与前端保持一致 - if(!EnumBillRentStatus.NOT_PAID.getCode().equals(wxBillAllVo.getStatus())){ + if (!EnumBillRentStatus.NOT_PAID.getCode().equals(wxBillAllVo.getStatus())) { wxBillAllVo.setOwe(0l); wxBillAllVo.setOweStr("0"); } @@ -863,14 +868,18 @@ public class WxBillAllServiceImpl implements WxBillAllService { String filepath = fmUploadDir; String filename = UUID.randomUUID() + ".docx"; String exportFileName = "催缴单.docx"; - WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); + WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response, null); } @Override public void exportSettleBill(WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) { wxBillSettle = wxBillSettleService.getById(wxBillSettle.getId(), EnumFilterSettle.NO.getCode()); - if(wxBillSettle.getReceiveBillIds() == null) wxBillSettle.setReceiveBillIds(new ArrayList<>()); - if(wxBillSettle.getPayBillIds() == null) wxBillSettle.setPayBillIds(new ArrayList<>()); + if (wxBillSettle.getReceiveBillIds() == null) { + wxBillSettle.setReceiveBillIds(new ArrayList<>()); + } + if (wxBillSettle.getPayBillIds() == null) { + wxBillSettle.setPayBillIds(new ArrayList<>()); + } //映射结果 Map result = new HashMap<>(); @@ -884,35 +893,35 @@ public class WxBillAllServiceImpl implements WxBillAllService { BigDecimal receiveM = (new BigDecimal(wxBillSettle.getReceiveMoney()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)); BigDecimal payM = (new BigDecimal(wxBillSettle.getPayMoney()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)); BigDecimal bM = (new BigDecimal(wxBillSettle.getBalance()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)); - result.put("receiveM", receiveM.toString()+"元"); - result.put("payM", payM.toString()+"元"); - result.put("bM", bM.toString()+"元"); + result.put("receiveM", receiveM.toString() + "元"); + result.put("payM", payM.toString() + "元"); + result.put("bM", bM.toString() + "元"); result.put("receiveMU", PriceUtil.digitUppercase(receiveM.doubleValue())); result.put("payMU", PriceUtil.digitUppercase(payM.doubleValue())); result.put("bMU", PriceUtil.digitUppercase(bM.doubleValue())); WordDocTableVo wordDocTableVo = new WordDocTableVo(); List> rowsParams = new ArrayList<>(); - int size = wxBillSettle.getReceiveBillIds().size() > wxBillSettle.getPayBillIds().size()?wxBillSettle.getReceiveBillIds().size():wxBillSettle.getPayBillIds().size(); + int size = wxBillSettle.getReceiveBillIds().size() > wxBillSettle.getPayBillIds().size() ? wxBillSettle.getReceiveBillIds().size() : wxBillSettle.getPayBillIds().size(); int count = 1; - for (int i = 0; i < size ; i++) { - WxBillSettleBill bill = i>wxBillSettle.getReceiveBillIds().size()-1?null:wxBillSettle.getReceiveBillIds().get(i); + for (int i = 0; i < size; i++) { + WxBillSettleBill bill = i > wxBillSettle.getReceiveBillIds().size() - 1 ? null : wxBillSettle.getReceiveBillIds().get(i); List cellList = new ArrayList<>(); - cellList.add(count+""); + cellList.add(count + ""); - if(bill != null){ + if (bill != null) { cellList.add(bill.getBillName()); cellList.add(new BigDecimal(bill.getReceivePay()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).toString()); - }else{ + } else { cellList.add(""); cellList.add(""); } - cellList.add(count+""); - WxBillSettleBill payBill = i>wxBillSettle.getPayBillIds().size()-1?null:wxBillSettle.getPayBillIds().get(i); - if(payBill != null){ + cellList.add(count + ""); + WxBillSettleBill payBill = i > wxBillSettle.getPayBillIds().size() - 1 ? null : wxBillSettle.getPayBillIds().get(i); + if (payBill != null) { cellList.add(payBill.getBillName()); cellList.add(new BigDecimal(payBill.getReceivePay()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).toString()); - }else{ + } else { cellList.add(""); cellList.add(""); } @@ -927,7 +936,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { String filepath = fmUploadDir; String filename = UUID.randomUUID() + ".docx"; String exportFileName = "结算单.docx"; - WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,wordDocTableVo); + WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response, wordDocTableVo); } @@ -962,7 +971,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { } } else if (billType.equals(EnumBillTypeParam.RENT_DEPOSIT.getCode())) { WxBillDeposit dbBill = wxBillDepositMapper.selectById(id); - if(dbBill!=null) { + if (dbBill != null) { //租赁押金账单更新 WxBillDeposit wxBillDeposit = new WxBillDeposit(); wxBillDeposit.setId(id); @@ -978,7 +987,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { } WxBillPropertyDeposit propertyDeposit = wxBillPropertyDepositMapper.selectById(id); - if(propertyDeposit!=null){ + if (propertyDeposit != null) { //物业押金账单更新 WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit(); wxBillPropertyDeposit.setId(id); @@ -1723,7 +1732,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { record.setLimitStart(0); record.setLimitEnd(Integer.MAX_VALUE); List totalList = wxBillAllMapper.getReceiveAndPayBillAsPage(record); - if(CollectionUtils.isEmpty(totalList)){ + if (CollectionUtils.isEmpty(totalList)) { PageHelper.startPage(pageNum, pageSize); PageInfo> pageInfo = new PageInfo(new ArrayList()); pageInfo.setPages(0); @@ -1735,12 +1744,12 @@ public class WxBillAllServiceImpl implements WxBillAllService { int total = totalList.size(); int pages; - if(total % pageSize == 0){ + if (total % pageSize == 0) { pages = total / pageSize; - }else{ - pages = total / pageSize +1; + } else { + pages = total / pageSize + 1; } - record.setLimitStart((pageNum -1) * pageSize); + record.setLimitStart((pageNum - 1) * pageSize); record.setLimitEnd(pageSize); List> list = wxBillAllMapper.getReceiveAndPayBillAsPage(record); @@ -1798,14 +1807,14 @@ public class WxBillAllServiceImpl implements WxBillAllService { oweMerchantVo.setName((String) map.get("name")); oweMerchantVo.setLinkPhone((String) map.get("linkPhone")); oweMerchantVo.setShopNumber((String) map.get("shopNumber")); - if(EnumRentShopType.POINT.getCode().equals(map.get("type"))){ + if (EnumRentShopType.POINT.getCode().equals(map.get("type"))) { oweMerchantVo.setShopType("多经点位"); - }else if(EnumRentShopType.SHOP.getCode().equals(map.get("type"))){ + } else if (EnumRentShopType.SHOP.getCode().equals(map.get("type"))) { oweMerchantVo.setShopType("商铺"); } - oweMerchantVo.setReceivePay(map.get("receivePay")==null?"0":map.get("receivePay").toString()); - oweMerchantVo.setPayOut(map.get("payOut")==null?"0":map.get("payOut").toString()); - oweMerchantVo.setBalance(map.get("balance")==null?"0":map.get("balance").toString()); + oweMerchantVo.setReceivePay(map.get("receivePay") == null ? "0" : map.get("receivePay").toString()); + oweMerchantVo.setPayOut(map.get("payOut") == null ? "0" : map.get("payOut").toString()); + oweMerchantVo.setBalance(map.get("balance") == null ? "0" : map.get("balance").toString()); list.add(oweMerchantVo); } String name = "商户账单列表"; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java index 44955e841..914ab1304 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java @@ -65,24 +65,27 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { List billDepositList = wxBillDailyMapper.queryBillDailyList(record); billDepositList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); //结果放入分页对象 PageInfo pageInfo = new PageInfo<>(billDepositList); return pageInfo; } + public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillDaily e) { + if (e.getReceivePay() != null) { + BigDecimal servicePay; + if (e.getServiceChargePay() != null) { + servicePay = new BigDecimal(e.getServiceChargePay()); + } 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.getReceivePay(); + e.setRealReceivePay(realReceivePay); + e.setServiceChargePay(servicePay.intValue()); + } + } + @Override public void updateBillStatus(WxBillDaily record) { logger.info("更新日常账单状态开始..."); @@ -127,6 +130,9 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { WxBillDaily record = new WxBillDaily(); record.setId(id); WxBillDaily wxBillDaily = wxBillDailyMapper.queryBillDailyList(record).get(0); + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(record.getTenantId()); + computeTotalMoney(wxPayAccountBill, record); + record.setOwe(record.getRealReceivePay() - record.getPay()); if (wxBillDaily.getShopId() != null) { WxShop shop = new WxShop(); shop.setId(wxBillDaily.getShopId()); @@ -135,7 +141,6 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { }else{ wxBillDaily.setShops(Collections.EMPTY_LIST); } - return wxBillDaily; } @@ -191,7 +196,7 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { wxBillDaily.setPayDate(record.getPayDate()); wxBillDaily.setPay(record.getPay()); wxBillDaily.setReceivePay(record.getReceivePay()); - wxBillDaily.setOwe(record.getReceivePay()-record.getPay()); + wxBillDaily.setOwe(record.getRealReceivePay() - record.getPay()); if (record.getPay().equals(record.getReceivePay())) { wxBillDaily.setStatus(EnumBillRentStatus.PAID.getCode()); Date payDate = record.getPayDate(); @@ -351,18 +356,7 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { List billDailyList = wxBillDailyMapper.queryBillDailyList(record); billDailyList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); List datalist = new ArrayList<>(); WxBillDailyExportVo wxBillDailyExportVo; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java index 22da6ca52..da83a50a4 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java @@ -49,29 +49,34 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { WxPayAccountBillService wxPayAccountBillService; @Override - public PageInfo> listAsPage(WxBillDeposit record, Integer pageIndex, Integer pageSize) { + public PageInfo listAsPage(WxBillDeposit record, Integer pageIndex, Integer pageSize) { WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(record.getTenantId()); PageHelper.startPage(pageIndex, pageSize); - List> billDepositList = wxBillDepositMapper.queryBillDepositList(record); + List billDepositList = wxBillDepositMapper.queryBillDepositList(record); billDepositList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.get("receivePay") != null){ - Long receivePayB = (Long)e.get("receivePay"); - BigDecimal servicePay; - if(e.get("serviceChargePay") != null){ - servicePay = new BigDecimal((Long)e.get("serviceChargePay")); - }else{ - servicePay = new BigDecimal(receivePayB).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - } - Long realReceivePay = servicePay.longValue() + receivePayB; - e.put("realReceivePay",realReceivePay); - e.put("serviceChargePay",servicePay.intValue()); - } + computeTotalMoney(wxPayAccountBill, e); }); - PageInfo> pageInfo = new PageInfo<>(billDepositList); + PageInfo pageInfo = new PageInfo<>(billDepositList); return pageInfo; } + @Override + public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillDeposit deposit) { + if (deposit.getReceivePay() != null) { + Long receivePayB = deposit.getReceivePay(); + BigDecimal servicePay; + if (deposit.getServiceChargePay() != null) { + servicePay = new BigDecimal(deposit.getServiceChargePay()); + } else { + servicePay = new BigDecimal(receivePayB).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); + } + Long realReceivePay = servicePay.longValue() + receivePayB; + deposit.setRealReceivePay(realReceivePay); + deposit.setServiceChargePay(servicePay.intValue()); + } + } + @Override public void updateBillStatus(WxBillDeposit record) { logger.info("更新租赁押金账单状态开始..."); @@ -113,7 +118,7 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { } @Override - public Map getById(Long id) { + public WxBillDeposit getById(Long id) { WxBillDeposit record = new WxBillDeposit(); record.setId(id); return wxBillDepositMapper.queryBillDepositList(record).get(0); @@ -164,7 +169,6 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { wxBillDeposit.setPayDate(date); wxBillDeposit.setUpdatetime(date); wxBillDeposit.setPayWay(record.getPayWay()); - //wxBillDeposit.setServiceChargePay(record.getServiceChargePay()); try { wxBillDepositMapper.updateById(wxBillDeposit); } catch (Exception e) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java index 542786514..b905e321a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java @@ -59,18 +59,7 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService List billList = wxBillOtherDepositMapper.queryBillList(record); billList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); //结果放入分页对象 PageInfo pageInfo = new PageInfo<>(billList); @@ -78,6 +67,20 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService } + public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillOtherDeposit e) { + if (e.getReceivePay() != null) { + BigDecimal servicePay; + if (e.getServiceChargePay() != null) { + servicePay = new BigDecimal(e.getServiceChargePay()); + } 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.getReceivePay(); + e.setRealReceivePay(realReceivePay); + e.setServiceChargePay(servicePay.intValue()); + } + } + @Override public void updateBillStatus(WxBillOtherDeposit record) { logger.info("更新其他押金账单状态开始..."); @@ -122,6 +125,9 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService WxBillOtherDeposit record = new WxBillOtherDeposit(); record.setId(id); WxBillOtherDeposit wxBillOther = wxBillOtherDepositMapper.queryBillList(record).get(0); + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(record.getTenantId()); + computeTotalMoney(wxPayAccountBill, record); + record.setOwe(record.getRealReceivePay() - record.getPay()); if (wxBillOther.getShopId() != null) { WxShop shop = new WxShop(); shop.setId(wxBillOther.getShopId()); @@ -186,7 +192,7 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService wxBillOtherDeposit.setPayDate(record.getPayDate()); wxBillOtherDeposit.setPay(record.getPay()); wxBillOtherDeposit.setReceivePay(record.getReceivePay()); - wxBillOtherDeposit.setOwe(record.getReceivePay() - record.getPay()); + wxBillOtherDeposit.setOwe(record.getRealReceivePay() - record.getPay()); if (record.getPay().equals(record.getReceivePay())) { wxBillOtherDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); Date payDate = record.getPayDate(); @@ -324,18 +330,7 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService List datalist = wxBillOtherDepositMapper.queryBillList(wxBillDeposit); datalist.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); excelService.exportExcel(datalist, null, "其他押金账单", WxBillOtherDeposit.class, "其他押金账单.xlsx", response, false); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java index 8e6c1dc21..b20ca3300 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java @@ -59,18 +59,7 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { List billList = wxBillOtherMapper.queryBillList(record); billList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); //结果放入分页对象 PageInfo pageInfo = new PageInfo<>(billList); @@ -78,6 +67,20 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { } + public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillOther e) { + if (e.getReceivePay() != null) { + BigDecimal servicePay; + if (e.getServiceChargePay() != null) { + servicePay = new BigDecimal(e.getServiceChargePay()); + } 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.getReceivePay(); + e.setRealReceivePay(realReceivePay); + e.setServiceChargePay(servicePay.intValue()); + } + } + @Override public void updateBillStatus(WxBillOther record) { logger.info("更新其他账单状态开始..."); @@ -122,7 +125,9 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { WxBillOther record = new WxBillOther(); record.setId(id); WxBillOther wxBillOther = wxBillOtherMapper.queryBillList(record).get(0); - + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(record.getTenantId()); + computeTotalMoney(wxPayAccountBill, record); + record.setOwe(record.getRealReceivePay() - record.getPay()); if (wxBillOther.getShopId() != null) { WxShop shop = new WxShop(); shop.setId(wxBillOther.getShopId()); @@ -187,7 +192,7 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { wxBillOther.setPayDate(record.getPayDate()); wxBillOther.setPay(record.getPay()); wxBillOther.setReceivePay(record.getReceivePay()); - wxBillOther.setOwe(record.getReceivePay()-record.getPay()); + wxBillOther.setOwe(record.getRealReceivePay() - record.getPay()); if (record.getPay().equals(record.getReceivePay())) { wxBillOther.setStatus(EnumBillRentStatus.PAID.getCode()); Date payDate = record.getPayDate(); @@ -269,18 +274,7 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { List datalist = wxBillOtherMapper.queryBillList(wxBillOther); datalist.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); excelService.exportExcel(datalist, null, "其他费用账单", WxBillOther.class, "其他费用账单.xlsx", response, false); } 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 4d625b0d5..b52ae5a75 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java @@ -47,29 +47,33 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe WxPayAccountBillService wxPayAccountBillService; @Override - public PageInfo> listAsPage(WxBillPropertyDeposit record, Integer pageIndex, Integer pageSize) { + public PageInfo listAsPage(WxBillPropertyDeposit record, Integer pageIndex, Integer pageSize) { WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(record.getTenantId()); PageHelper.startPage(pageIndex, pageSize); - List> billDepositList = wxBillPropertyDepositMapper.queryBillDepositList(record); + List billDepositList = wxBillPropertyDepositMapper.queryBillDepositList(record); billDepositList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.get("receivePay") != null){ - Long receivePayB = (Long)e.get("receivePay"); - BigDecimal servicePay; - if(e.get("serviceChargePay") != null){ - servicePay = new BigDecimal((Long)e.get("serviceChargePay")); - }else{ - servicePay = new BigDecimal(receivePayB).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - } - Long realReceivePay = servicePay.longValue() + receivePayB; - e.put("realReceivePay",realReceivePay); - e.put("serviceChargePay",servicePay.intValue()); - } + computeTotalMoney(wxPayAccountBill, e); }); - PageInfo> pageInfo = new PageInfo<>(billDepositList); + PageInfo pageInfo = new PageInfo<>(billDepositList); return pageInfo; } + @Override + public void computeTotalMoney(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); + } + Long realReceivePay = servicePay.longValue() + deposit.getReceivePay(); + deposit.setRealReceivePay(realReceivePay); + deposit.setServiceChargePay(servicePay.intValue()); + } + } + @Override public void updateBillStatus(WxBillPropertyDeposit record) { logger.info("更新物业押金账单状态开始..."); @@ -112,7 +116,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe } @Override - public Map getById(Long id) { + public WxBillPropertyDeposit getById(Long id) { WxBillPropertyDeposit record = new WxBillPropertyDeposit(); record.setId(id); return wxBillPropertyDepositMapper.queryBillDepositList(record).get(0); @@ -150,7 +154,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe Long addpay = wxBillDeposit.getPay(); wxBillDeposit.setPay(record.getPay()); wxBillDeposit.setReceivePay(record.getReceivePay()); - wxBillDeposit.setOwe(record.getReceivePay()-record.getPay()); + wxBillDeposit.setOwe(record.getRealReceivePay() - record.getPay()); if (record.getPay().equals(record.getReceivePay())) { wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); Date receiveDate = wxBillDeposit.getReceiveDate(); 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 d3787b9e9..06699edb8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java @@ -14,10 +14,7 @@ import com.iformall.exception.MallinkException; import com.iformall.mapper.WxBillActionMapper; import com.iformall.mapper.WxBillPropertyDepositMapper; import com.iformall.mapper.WxBillPropertyMapper; -import com.iformall.service.ExcelService; -import com.iformall.service.WxBillActionService; -import com.iformall.service.WxBillPropertyService; -import com.iformall.service.WxPayAccountBillService; +import com.iformall.service.*; import com.iformall.utils.DateUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -55,6 +52,8 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { WxBillActionMapper wxBillActionMapper; @Autowired WxPayAccountBillService wxPayAccountBillService; + @Autowired + WxBillPropertyDepositService wxBillPropertyDepositService; @Override @@ -62,25 +61,33 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(record.getTenantId()); PageHelper.startPage(pageIndex, pageSize); List billRentList = wxBillPropertyMapper.queryBillPropertyList(record); - billRentList.stream().forEach(e->{ - //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + billRentList.stream().forEach(e -> { + computeTotalMoney(wxPayAccountBill, e); + }); PageInfo pageInfo = new PageInfo<>(billRentList); return pageInfo; } + public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillProperty e) { + //手续费 = 合同应收+手续费+滞纳金 + if (e.getReceivePay() != null) { + if (e.getLatePayPrice() == null) { + long latePayPrice = 0L; + e.setLatePayPrice(latePayPrice); + } + BigDecimal servicePay; + if (e.getServiceChargePay() != null) { + servicePay = new BigDecimal(e.getServiceChargePay()); + } 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()); + } + } + @Override public void updateBillStatus(WxBillProperty record) { logger.info("更新物业账单状态开始..."); @@ -125,15 +132,20 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { public WxBillProperty getById(Long id) { WxBillProperty record = new WxBillProperty(); record.setId(id); - return wxBillPropertyMapper.queryBillPropertyList(record).get(0); + WxBillProperty property = wxBillPropertyMapper.queryBillPropertyList(record).get(0); + //手续费 = 合同应收+手续费+滞纳金 + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(property.getTenantId()); + computeTotalMoney(wxPayAccountBill, property); + property.setOwe(property.getRealReceivePay() - property.getPay()); + return property; } @Override public ResultData saveOrUpdate(WxBillProperty record, MallUserInfo user) { - int receivepay = record.getReceivePay()==null?0:record.getReceivePay().intValue(); - int pay = record.getPay()==null?0:record.getPay().intValue(); - if(pay>receivepay){ - return new ResultData(ErrorCode.BILL_PAY_ERROR,"实收金额不能大于实际应收金额"); + int receivepay = record.getReceivePay() == null ? 0 : record.getReceivePay().intValue(); + int pay = record.getPay() == null ? 0 : record.getPay().intValue(); + if (pay > receivepay) { + return new ResultData(ErrorCode.BILL_PAY_ERROR, "实收金额不能大于实际应收金额"); } Date date = new Date(); if (record.getId() == null) { @@ -142,7 +154,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { record.setId(idWorker.nextId()); record.setCreatetime(date); record.setUpdatetime(date); - record.setOwe(record.getReceivePay()-record.getPay()); + record.setOwe(record.getReceivePay() - record.getPay()); record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); try { wxBillPropertyMapper.insert(record); @@ -154,16 +166,16 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { } else { logger.info("更新物业账单"); WxBillProperty property = wxBillPropertyMapper.selectById(record.getId()); - if(property==null){ + if (property == null) { return new ResultData(ErrorCode.BILL_PROPERTY_IS_NOT_FOUND); } String message = ""; String price = ""; - if(record.getServiceChargePayUpdate() != null){ - Double l = Double.valueOf(record.getServiceChargePayUpdate())*100; + if (record.getServiceChargePayUpdate() != null) { + Double l = Double.valueOf(record.getServiceChargePayUpdate()) * 100; property.setServiceChargePay(l.intValue()); - }else{ + } else { Long addpay = property.getPay(); property.setRevenue(record.getRevenue()); property.setLatePayRatio(record.getLatePayRatio()); @@ -172,7 +184,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { property.setPayDate(record.getPayDate()); property.setPay(record.getPay()); property.setReceivePay(record.getReceivePay()); - property.setOwe(record.getReceivePay()-record.getPay()); + property.setOwe(record.getRealReceivePay() - record.getPay()); if (record.getPay().equals(record.getReceivePay())) { property.setStatus(EnumBillRentStatus.PAID.getCode()); Date payDate = record.getPayDate(); @@ -201,10 +213,10 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { wxBillAction.setBillId(property.getId()); wxBillAction.setDetails(message + price + "元"); - if(record.getServiceChargePayUpdate() != null){ - wxBillAction.setDetails(record.getServiceChargePayBefore()+"元变更为" +record.getServiceChargePayUpdate()+"元"); + if (record.getServiceChargePayUpdate() != null) { + wxBillAction.setDetails(record.getServiceChargePayBefore() + "元变更为" + record.getServiceChargePayUpdate() + "元"); wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); - }else{ + } else { wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); } wxBillAction.setUserId(user.getId()); @@ -237,20 +249,9 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { updateBillStatus(record); PageHelper.startPage(pageIndex, pageSize); List billRentList = wxBillPropertyMapper.queryBillPropertyList(record); - billRentList.stream().forEach(e->{ + billRentList.stream().forEach(e -> { //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); PageInfo pageInfo = new PageInfo<>(billRentList); @@ -262,11 +263,11 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { @Override public ResultData updatePaid(Long id) { WxBillProperty record = wxBillPropertyMapper.selectById(id); - if(record==null){ + if (record == null) { return new ResultData(ErrorCode.BILL_PROPERTY_IS_NOT_FOUND); } record.setStatus(EnumBillRentStatus.PAID.getCode()); - Date d =new Date(); + Date d = new Date(); record.setPayDate(d); record.setUpdatetime(d); try { @@ -285,26 +286,15 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { //押金 WxBillPropertyDeposit depositParam = new WxBillPropertyDeposit(); depositParam.setPropertyContractId(property.getPropertyContractId()); - Map deposit = null; - List> billDepositList = wxBillPropertyDepositMapper.queryBillDepositList(depositParam); + WxBillPropertyDeposit deposit = null; + List billDepositList = wxBillPropertyDepositMapper.queryBillDepositList(depositParam); if (!billDepositList.isEmpty()) { + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(property.getTenantId()); deposit = billDepositList.get(0); - } - //手续费 = 合同应收+手续费+滞纳金 - WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(property.getTenantId()); - if(property.getReceivePay() != null){ - if(property.getLatePayPrice() == null) property.setLatePayPrice(0l); - BigDecimal servicePay; - if(property.getServiceChargePay() != null){ - servicePay = new BigDecimal(property.getServiceChargePay()); - }else{ - servicePay = new BigDecimal(property.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - } - Long realReceivePay = servicePay.longValue() + property.getLatePayPrice() + property.getReceivePay(); - property.setRealReceivePay(realReceivePay); - property.setServiceChargePay(servicePay.intValue()); - } + wxBillPropertyDepositService.computeTotalMoney(wxPayAccountBill, deposit); + deposit.setOwe(deposit.getRealReceivePay() - deposit.getPay()); + } Map result = new HashMap<>(2); result.put("property", property); result.put("deposit", deposit); @@ -330,20 +320,9 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { String billName = wxBillProperty.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) ? "商铺物业账单" : "多经点位物业账单"; List billPropertyList = wxBillPropertyMapper.queryBillPropertyList(wxBillProperty); - billPropertyList.stream().forEach(e->{ + billPropertyList.stream().forEach(e -> { //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); Map> collect = billPropertyList.parallelStream() .collect(Collectors.groupingBy(WxBillProperty::getMerchantId)); @@ -377,7 +356,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { final IdWorker idWorker = IdWorker.get(); WxBillAction billAction = new WxBillAction(); - if(record.getLatePayMoneyUpdate() != null) { + if (record.getLatePayMoneyUpdate() != null) { record.setLatePayPrice(Long.parseLong(record.getLatePayMoneyUpdate()) * 100); billAction.setId(idWorker.nextId()); @@ -385,7 +364,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { billAction.setUserName("系统端"); billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); billAction.setBillId(record.getId()); - billAction.setDetails(record.getLatePayMoneyBefore()+"元变更为" +record.getLatePayMoneyUpdate()+"元"); + billAction.setDetails(record.getLatePayMoneyBefore() + "元变更为" + record.getLatePayMoneyUpdate() + "元"); billAction.setUpdatetime(new Date()); wxBillActionMapper.insert(billAction); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index 79b3e3cbc..73145e75a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -13,10 +13,7 @@ import com.iformall.domain.vo.RatioVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; -import com.iformall.service.ExcelService; -import com.iformall.service.WxBillActionService; -import com.iformall.service.WxBillRentService; -import com.iformall.service.WxPayAccountBillService; +import com.iformall.service.*; import com.iformall.utils.DateUtils; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; @@ -59,6 +56,8 @@ public class WxBillRentServiceImpl implements WxBillRentService { WxMerchantTradeDailyMapper wxMerchantTradeDailyMapper; @Autowired WxPayAccountBillService wxPayAccountBillService; + @Autowired + WxBillDepositService wxBillDepositService; @Override public PageInfo listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) { @@ -68,23 +67,29 @@ public class WxBillRentServiceImpl implements WxBillRentService { List billRentList = wxBillRentMapper.queryBillRentList(record); billRentList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); PageInfo pageInfo = new PageInfo<>(billRentList); return pageInfo; } + public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillRent rent) { + if (rent.getReceivePay() != null) { + if (rent.getLatePayPrice() == null) { + rent.setLatePayPrice(0L); + } + BigDecimal servicePay; + if (rent.getServiceChargePay() != null) { + servicePay = new BigDecimal(rent.getServiceChargePay()); + } else { + servicePay = new BigDecimal(rent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); + } + Long realReceivePay = servicePay.longValue() + rent.getLatePayPrice() + rent.getReceivePay(); + rent.setRealReceivePay(realReceivePay); + rent.setServiceChargePay(servicePay.intValue()); + } + } + @Override public void updateBillStatus(WxBillRent record) { logger.info("更新租赁账单状态开始..."); @@ -129,7 +134,12 @@ public class WxBillRentServiceImpl implements WxBillRentService { public WxBillRent getById(Long id) { WxBillRent record = new WxBillRent(); record.setId(id); - return wxBillRentMapper.queryBillRentList(record).get(0); + WxBillRent rent = wxBillRentMapper.queryBillRentList(record).get(0); + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(record.getTenantId()); + //手续费 = 合同应收+手续费+滞纳金 + computeTotalMoney(wxPayAccountBill, rent); + rent.setOwe(rent.getRealReceivePay() - rent.getPay()); + return rent; } @Override @@ -175,7 +185,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { wxBillRent.setLatePayStatus(record.getLatePayStatus()); wxBillRent.setPay(record.getPay()); wxBillRent.setReceivePay(record.getReceivePay()); - wxBillRent.setOwe(record.getReceivePay()-record.getPay()); + wxBillRent.setOwe(record.getRealReceivePay() - record.getPay()); if (record.getPay().equals(record.getReceivePay())) { wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); Date payDate = record.getPayDate(); @@ -243,18 +253,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { e.setPayRatio(0l); } //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); PageInfo pageInfo = new PageInfo<>(billRentList); return pageInfo; @@ -287,27 +286,14 @@ public class WxBillRentServiceImpl implements WxBillRentService { //押金 WxBillDeposit depositParam = new WxBillDeposit(); depositParam.setRentContractId(rent.getRentContractId()); - Map deposit = null; - List> billDepositList = wxBillDepositMapper.queryBillDepositList(depositParam); + WxBillDeposit deposit = null; + List billDepositList = wxBillDepositMapper.queryBillDepositList(depositParam); if (!billDepositList.isEmpty()) { + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(rent.getTenantId()); deposit = billDepositList.get(0); + wxBillDepositService.computeTotalMoney(wxPayAccountBill, deposit); + deposit.setOwe(deposit.getRealReceivePay() - deposit.getPay()); } - - //手续费 = 合同应收+手续费+滞纳金 - WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantId(rent.getTenantId()); - if(rent.getReceivePay() != null){ - if(rent.getLatePayPrice() == null) rent.setLatePayPrice(0l); - BigDecimal servicePay; - if(rent.getServiceChargePay() != null){ - servicePay = new BigDecimal(rent.getServiceChargePay()); - }else{ - servicePay = new BigDecimal(rent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - } - Long realReceivePay = servicePay.longValue() + rent.getLatePayPrice() + rent.getReceivePay(); - rent.setRealReceivePay(realReceivePay); - rent.setServiceChargePay(servicePay.intValue()); - } - //周期 Map result = new HashMap<>(3); result.put("rent", rent); @@ -445,18 +431,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { List billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); billRentList.stream().forEach(e->{ //手续费 = 合同应收+手续费+滞纳金 - if(e.getReceivePay() != null){ - if(e.getLatePayPrice() == null) e.setLatePayPrice(0l); - BigDecimal servicePay; - if(e.getServiceChargePay() != null){ - servicePay = new BigDecimal(e.getServiceChargePay()); - }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()); - } + computeTotalMoney(wxPayAccountBill, e); }); Map> collect = billRentList.parallelStream() .collect(Collectors.groupingBy(WxBillRent::getMerchantId)); diff --git a/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml index ebede0fee..f43d0a2e4 100644 --- a/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml @@ -23,6 +23,10 @@ + + + + @@ -66,13 +70,11 @@ select from wx_bill_rent_deposit - - + select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`, + br.`owe`,br.`status`,br.`need_pay`,m.`name` merchant_name,s.shop_number,br.`updatetime`,br.`merchant_id`, + br.`rent_shop_type`,br.`return_price`, br.pay_way,br.shop_info ,br.freeze,br.service_charge_pay from wx_bill_rent_deposit br left join wx_merchant m on br.merchant_id=m.id left join wx_shop s on br.shop_id=s.id @@ -85,9 +87,8 @@ and br.`rent_shop_type` = #{rentShopType} and br.`rent_contract_id` = #{rentContractId} and br.`pay_way` = #{payWay} - - order by id desc + order by br.id desc - + select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`, + br.`pay_date`,br.`createtime`,br.`expired_day`,br.`owe`,br.`status`, + br.`need_pay`,m.`name` merchant_name,s.shop_number,br.`updatetime`, + br.`merchant_id`,br.`rent_shop_type`,br.`return_price`,br.`shop_info`,br.pay_way, + br.freeze,br.service_charge_pay from wx_bill_property_deposit br left join wx_merchant m on br.merchant_id=m.id left join wx_shop s on br.shop_id=s.id