From 8eff85d7dd64976512098ae6c4dc53a518c6446a Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 16 May 2019 19:17:30 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96=E5=90=88=E5=90=8C][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E5=BC=80=E5=8F=91=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=90=88=E5=90=8C=E9=9C=80=E6=B1=82]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WxMerchantTradeDailyController.java | 3 + .../domain/po/WxMerchantTradeDaily.java | 6 +- .../domain/po/WxPropertyContract.java | 35 ++++++++- .../iformall/domain/po/WxRentContract.java | 33 +++++++++ .../domain/vo/WxMerchantTradeDailyVo.java | 8 +-- .../impl/WxRentContractServiceImpl.java | 71 ++++++------------- .../java/com/iformall/utils/DateUtils.java | 21 ++++++ .../mapper/WxPropertyContractMapper.xml | 9 ++- .../resources/mapper/WxRentContractMapper.xml | 9 ++- 9 files changed, 132 insertions(+), 63 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java index bf95ef510..7e5ffea4f 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java @@ -92,6 +92,9 @@ public class WxMerchantTradeDailyController extends BaseController { wxMerchantTradeDaily.getTradeAmt() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); wxMerchantTradeDaily.setTenantId(getTenantId()); + if(wxMerchantTradeDaily.getTradeCount() == null){ + wxMerchantTradeDaily.setTradeCount(0); + } if (wxMerchantTradeDaily.getReportDate() == null) { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantTradeDaily.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantTradeDaily.java index 747005a83..7d296e286 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantTradeDaily.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantTradeDaily.java @@ -63,7 +63,7 @@ public class WxMerchantTradeDaily implements Serializable { private String reportDate; /*交易笔数**/ @io.swagger.annotations.ApiModelProperty(value = "交易笔数", name = "tradeCount") - private String tradeCount; + private Integer tradeCount; /*凭证**/ @io.swagger.annotations.ApiModelProperty(value = "凭证", name = "proof") private String proof; @@ -93,11 +93,11 @@ public class WxMerchantTradeDaily implements Serializable { this.month = month; } - public String getTradeCount() { + public Integer getTradeCount() { return tradeCount; } - public void setTradeCount(String tradeCount) { + public void setTradeCount(Integer tradeCount) { this.tradeCount = tradeCount; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java index 9f60ba4c8..9e1011c29 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java @@ -3,7 +3,6 @@ package com.iformall.domain.po; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; -import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -181,6 +180,40 @@ public class WxPropertyContract extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames") private String fileNames; + @io.swagger.annotations.ApiModelProperty(value = "总租期(月)", name = "totalPeriodMonth") + private Integer totalPeriodMonth; + + @io.swagger.annotations.ApiModelProperty(value = "总租期(天)", name = "totalPeriodDay") + private Integer totalPeriodDay; + + @io.swagger.annotations.ApiModelProperty(value = "租赁单价", name = "rentPrice") + private Integer rentPrice; + + + public Integer getTotalPeriodMonth() { + return totalPeriodMonth; + } + + public void setTotalPeriodMonth(Integer totalPeriodMonth) { + this.totalPeriodMonth = totalPeriodMonth; + } + + public Integer getTotalPeriodDay() { + return totalPeriodDay; + } + + public void setTotalPeriodDay(Integer totalPeriodDay) { + this.totalPeriodDay = totalPeriodDay; + } + + public Integer getRentPrice() { + return rentPrice; + } + + public void setRentPrice(Integer rentPrice) { + this.rentPrice = rentPrice; + } + public String getFileNames() { return fileNames; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index 9ff040fa1..9617f6ce4 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -333,6 +333,39 @@ public class WxRentContract extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames") private String fileNames; + @io.swagger.annotations.ApiModelProperty(value = "总租期(月)", name = "totalPeriodMonth") + private Integer totalPeriodMonth; + + @io.swagger.annotations.ApiModelProperty(value = "总租期(天)", name = "totalPeriodDay") + private Integer totalPeriodDay; + + @io.swagger.annotations.ApiModelProperty(value = "租赁单价", name = "rentPrice") + private Integer rentPrice; + + public Integer getTotalPeriodMonth() { + return totalPeriodMonth; + } + + public void setTotalPeriodMonth(Integer totalPeriodMonth) { + this.totalPeriodMonth = totalPeriodMonth; + } + + public Integer getTotalPeriodDay() { + return totalPeriodDay; + } + + public void setTotalPeriodDay(Integer totalPeriodDay) { + this.totalPeriodDay = totalPeriodDay; + } + + public Integer getRentPrice() { + return rentPrice; + } + + public void setRentPrice(Integer rentPrice) { + this.rentPrice = rentPrice; + } + public String getRentInfo() { return rentInfo; } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantTradeDailyVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantTradeDailyVo.java index abe77cd12..4ae3769d6 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantTradeDailyVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantTradeDailyVo.java @@ -73,11 +73,9 @@ public class WxMerchantTradeDailyVo extends BaseEntity { /*交易笔数**/ @io.swagger.annotations.ApiModelProperty(value = "交易笔数", name = "tradeCount") - @Transient - private String tradeCount; + private Integer tradeCount; /*凭证**/ @io.swagger.annotations.ApiModelProperty(value = "凭证", name = "proof") - @Transient private String proof; @Transient @@ -91,11 +89,11 @@ public class WxMerchantTradeDailyVo extends BaseEntity { this.isToday = isToday; } - public String getTradeCount() { + public Integer getTradeCount() { return tradeCount; } - public void setTradeCount(String tradeCount) { + public void setTradeCount(Integer tradeCount) { this.tradeCount = tradeCount; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 4ddcfde6b..d7aed7f2a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -41,6 +41,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.text.DecimalFormat; import java.text.SimpleDateFormat; +import java.time.*; import java.util.*; /** @@ -332,9 +333,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Transactional(rollbackFor = {Exception.class}) @Override public ResultData update(WxRentContract record, Long userId,String userName) { - //对比上一次,是否有更改,有,重新生成预账单 - WxRentContract dbRent = wxRentContractMapper.selectByPrimaryKey(record.getId()); - //查询预账单用于展示 WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setRentContractId(record.getId()); @@ -356,52 +354,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode()); } } - /* //有改变,删除预账单,重新生成 - if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null - && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0)) { - boolean change = false; - if (CollectionUtils.isEmpty(resultList)) { - change = true; - } else if (record.getAdjustPeriod().intValue() != dbRent.getAdjustPeriod().intValue()) { - change = true; - } else { - if (record.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode())) { - if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) - || !record.getLease().equals(dbRent.getLease()) - || !record.getType().equals(dbRent.getType()) - || !record.getPrice().equals(dbRent.getPrice()) - || !record.getAdjustRatio().replaceAll("\\s*", "").equals(dbRent.getAdjustRatio().replaceAll("\\s*", "")) - || !DateUtils.date2String(record.getRentalStartDate(),"yyyy-MM-dd").equals(DateUtils.date2String(dbRent.getRentalStartDate(),"yyyy-MM-dd")) - ) { - change = true; - } - } else if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) - || !record.getLease().equals(dbRent.getLease()) - || !record.getType().equals(dbRent.getType()) - || !record.getRevenue().equals(dbRent.getRevenue()) - || !record.getPayRatio().equals(dbRent.getPayRatio()) - || !DateUtils.date2String(record.getRentalStartDate(),"yyyy-MM-dd").equals(DateUtils.date2String(dbRent.getRentalStartDate(),"yyyy-MM-dd")) - ) { - change = true; - } - } else if (record.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { - if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) - || !record.getLease().equals(dbRent.getLease()) - || !record.getType().equals(dbRent.getType()) - || !record.getPrice().equals(dbRent.getPrice()) - || !record.getPayRatio().equals(dbRent.getPayRatio()) - || !DateUtils.date2String(record.getRentalStartDate(),"yyyy-MM-dd").equals(DateUtils.date2String(dbRent.getRentalStartDate(),"yyyy-MM-dd")) - ) { - change = true; - } - } - } - if (change) { - wxBillRentMapper.deletePreviewBill(record); - resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode()); - } - }*/ //启动审批流 if(record.getFlowParams() != null){ @@ -1081,6 +1033,26 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } + //最后一期截止到结束日期 + if(i == paycount - 1){ + if(wxRentContract.getRentalEndDate().after(wxBillRent.getEndtime())) { + wxBillRent.setEndtime(wxRentContract.getRentalEndDate()); + } + ZoneId zone = ZoneId.systemDefault(); + + LocalDateTime localDateTime = LocalDateTime.ofInstant(wxBillRent.getStarttime().toInstant(), zone); + LocalDate startLocalDate = localDateTime.toLocalDate(); + + localDateTime = LocalDateTime.ofInstant(wxBillRent.getEndtime().toInstant(), zone); + LocalDate endLocalDate = localDateTime.toLocalDate(); + + int[] diff = DateUtils.getDiff(startLocalDate,endLocalDate); + needpay = diff[0]*price; + + double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxRentContract.getRentalEndDate()); + needpay += diff[1] * oneDayProce; + } + wxBillRent.setNeedPay(needpay); wxBillRent.setOwe(needpay); wxBillRent.setReceivePay(needpay); @@ -1128,7 +1100,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { return resultMap; } - @Transactional(rollbackFor = {Exception.class}) @Override public ResultData deleteById(String id) { diff --git a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java index 0a3a04a0a..54992f50b 100755 --- a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java +++ b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java @@ -5,6 +5,8 @@ import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.Period; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -1083,4 +1085,23 @@ public class DateUtils { } } + /** + * 计算两个时间 相差n个月 零n天 + * @param start + * @param end + * @return + */ + public static int[] getDiff(LocalDate start,LocalDate end) { + if (!start.isBefore(end)) { + throw new IllegalArgumentException("Start must not be before end."); + } + + Period period = Period.between(start, end); + int years = period.getYears(); + int months = period.getMonths(); + int days = period.getDays(); + + return new int[] {years * 12 + months, days}; + } + } diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 3d6a6fc4f..412f5b4eb 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -38,6 +38,9 @@ + + + @@ -47,7 +50,8 @@ `deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`, `shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`, `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`, - `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`, `file_names` + `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`, `file_names`, + total_period_month,total_period_day,rent_price @@ -107,7 +111,8 @@ rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate, start_date startDate,end_date endDate,rc.rent_contract_id rentContractId,br.`name` brandName, s.addr,rc.apply_status applyStatus,rc.adjust_period adjustPeriod,rc.business_type businessType, - rc.adjust_ratio adjustRatio,rc.rent_info rentInfo, rc.file_names fileNames + rc.adjust_ratio adjustRatio,rc.rent_info rentInfo, rc.file_names fileNames, + rc.total_period_month,rc.total_period_day,rc.rent_price from wx_property_contract rc left join wx_shop s on rc.shop_id=s.id left join wx_mall_floor f on s.floor=f.id diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 3e27e1c9a..288821afd 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -44,6 +44,10 @@ + + + + @@ -53,7 +57,7 @@ `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`, `start_date`,`end_date`, `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`, - `business_type`,`rent_info`, `file_names` + `business_type`,`rent_info`, `file_names`,total_period_month,total_period_day,rent_price @@ -113,7 +117,8 @@ rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate,rc.merchant_id merchantId,rc.type, rc.start_date startDate,rc.end_date endDate,br.`name` brandName,rc.apply_status applyStatus,rc.bank_name bankName,rc.rent_shop_type rentShopType,rc.fix_start_date fixStartDate,rc.fix_end_date fixEndDate - ,rc.business_type businessType,rc.adjust_period adjustPeriod,rc.rent_info rentInfo, rc.file_names fileNames + ,rc.business_type businessType,rc.adjust_period adjustPeriod,rc.rent_info rentInfo, rc.file_names fileNames, + rc.total_period_month,rc.total_period_day,rc.rent_price from wx_rent_contract rc left join wx_shop s on rc.shop_id=s.id left join wx_mall_floor f on s.floor=f.id