From 794de36c6f3471daa512cd22e260df007373515f Mon Sep 17 00:00:00 2001 From: luozukai Date: Fri, 24 May 2019 15:16:55 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=90=88=E5=90=8C=E4=BC=98=E5=8C=96][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][fail]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/WxAppinfoController.java | 8 -- .../impl/WxRentContractServiceImpl.java | 118 +++++++++++++++--- 2 files changed, 99 insertions(+), 27 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java b/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java index 7dcc11398..738efc513 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java @@ -3,7 +3,6 @@ package com.iformall.controller.app; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; import com.amazonaws.services.s3.model.ObjectMetadata; -import com.github.pagehelper.PageInfo; import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; @@ -15,11 +14,8 @@ import com.iformall.exception.MallinkException; import com.iformall.mapper.WxMerchantMapper; import com.iformall.service.WxAppinfoService; import com.iformall.service.wechat.FmOpenService; -import com.iformall.utils.Constant; import com.iformall.utils.MaUtil; import com.iformall.utils.QRCodeUtils; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import me.chanjar.weixin.common.error.WxErrorException; import org.apache.commons.lang3.StringUtils; @@ -28,8 +24,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -37,8 +31,6 @@ import java.io.*; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; @RestController @RequestMapping("wxAppinfo") 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 85cdfeb25..0567a0c1a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -898,11 +898,89 @@ public class WxRentContractServiceImpl implements WxRentContractService { Map resultMap = new HashedMap(); List resultList = new ArrayList<>(); + final IdWorker idWorker = IdWorker.get(); + + Date start = startdate; + Date end = wxRentContract.getRentalEndDate(); + while (true){ + WxBillRent wxBillRent = new WxBillRent(); + wxBillRent.setIsPreview(isPreview); + wxBillRent.setId(idWorker.nextId()); + wxBillRent.setRentContractId(wxRentContract.getId()); + wxBillRent.setPay(0L); + long needpay = new BigDecimal(price).multiply(new BigDecimal(receivePeriod)).longValue(); + + Calendar instance = Calendar.getInstance(); + instance.setTime(start); + instance.add(dayType, receivePeriod); + if(!wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ + instance.add(Calendar.DAY_OF_MONTH, -1); + } + Date time = instance.getTime(); + wxBillRent.setReceiveDate(time); + //账单开始时间 + instance.clear(); + instance.setTime(wxBillRent.getReceiveDate()); + if(!wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ + instance.add(Calendar.DAY_OF_MONTH, 1); + } + wxBillRent.setStarttime(instance.getTime()); + //账单结束时间 + instance.clear(); + instance.setTime(wxBillRent.getStarttime()); + instance.add(dayType, receivePeriod); + instance.add(Calendar.DAY_OF_MONTH, -1); + wxBillRent.setEndtime(instance.getTime()); + + wxBillRent.setNeedPay(needpay); + wxBillRent.setOwe(needpay); + wxBillRent.setReceivePay(needpay); + + //截止收租日在当前时间之前 + Date date = new Date(); + if (wxBillRent.getReceiveDate().before(date)) { + long day = (time.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); + wxBillRent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); + wxBillRent.setExpiredDay(day); + } else {//截止收租日在当前时间之后 + Calendar now = Calendar.getInstance(); + now.add(dayType, receivePeriod); + Date currenttime = now.getTime(); + //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 + if (currenttime.before(wxBillRent.getReceiveDate())) { + wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); + wxBillRent.setExpiredDay(0L); + } else { + wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); + wxBillRent.setExpiredDay(0L); + } + } + wxBillRent.setRevenue(0L); + wxBillRent.setTenantId(wxMerchant.getTenantId()); + wxBillRent.setIsDel(0); + wxBillRent.setMerchantId(wxMerchant.getId()); + wxBillRent.setUserId(userId); + wxBillRent.setShopId(wxRentContract.getShopId()); + wxBillRent.setCreatetime(date); + wxBillRent.setUpdatetime(date); + wxBillRent.setIsDel(EnumDelStatus.NOT_DEL.getCode()); + wxBillRent.setRentShopType(wxRentContract.getRentShopType()); + wxBillRent.setPeriod(++billcount); + wxBillRent.setShopInfo(shopInfoStr); + wxBillRentMapper.insertSelective(wxBillRent); + resultList.add(wxBillRent); + + //next + start = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1); + + break; + } + + int extralease = lease % receivePeriod; //余 int extracount = extralease > 0 ? 1 : 0; int paycount = lease / receivePeriod + extracount; int index = paycount - 1; - final IdWorker idWorker = IdWorker.get(); //自然月计租,而且残月,周期整除,n+1,最后一个周期作为残月 if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode()) @@ -916,7 +994,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { for(int i = 0; i < paycount; i++){ WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setIsPreview(isPreview); - wxBillRent.setId(idWorker.nextId()); wxBillRent.setRentContractId(wxRentContract.getId()); wxBillRent.setPay(0L); @@ -1080,23 +1157,26 @@ public class WxRentContractServiceImpl implements WxRentContractService { } //最后一期截止到结束日期 - if(i == paycount - 1 && isLastYesr){ - wxBillRent.setEndtime(wxRentContract.getRentalEndDate()); - //当天也算,加1天 - Date newEndDate = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1); - //按日 - if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){ - int dayCount = DateUtils.daysBetween(wxBillRent.getStarttime(),newEndDate); - needpay = dayCount*price; - }else{ - //按月 - int[] diff = DateUtils.getDiff(wxBillRent.getStarttime(),newEndDate); - needpay = diff[0]*price; - - double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxRentContract.getRentalEndDate()); - needpay += diff[1] * oneDayProce; - } - } +// if(i == paycount - 1 && isLastYesr){ +// wxBillRent.setEndtime(wxRentContract.getRentalEndDate()); +// //当天也算,加1天 +// Date newEndDate = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1); +// //按日 +// if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){ +// int dayCount = DateUtils.daysBetween(wxBillRent.getStarttime(),newEndDate); +// needpay = dayCount*price; +// }else{ +// //按月 +// SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); +// System.out.println("----1"+sd.format(wxBillRent.getStarttime())); +// System.out.println("----2"+sd.format(newEndDate)); +// int[] diff = DateUtils.getDiff(wxBillRent.getStarttime(),newEndDate); +// needpay = diff[0]*price; +// +// double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxRentContract.getRentalEndDate()); +// needpay += diff[1] * oneDayProce; +// } +// } wxBillRent.setNeedPay(needpay); wxBillRent.setOwe(needpay);