| @@ -123,9 +123,6 @@ public class WxShop implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value = "备注", name = "comments") | |||
| private String comments; | |||
| @io.swagger.annotations.ApiModelProperty(value = "邮箱", name = "email") | |||
| private String email; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = " ") | |||
| private Integer isDel; | |||
| @@ -137,14 +134,6 @@ public class WxShop implements Serializable { | |||
| this.isDel = isDel; | |||
| } | |||
| public String getEmail() { | |||
| return email; | |||
| } | |||
| public void setEmail(String email) { | |||
| this.email = email; | |||
| } | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| @@ -16,6 +16,7 @@ import com.iformall.service.WxFlowRecordService; | |||
| import com.iformall.service.WxFlowService; | |||
| import com.iformall.service.WxPropertyContractService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.collections.map.HashedMap; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -30,6 +31,8 @@ import java.math.BigDecimal; | |||
| import java.math.RoundingMode; | |||
| import java.net.HttpURLConnection; | |||
| import java.net.URL; | |||
| import java.text.DecimalFormat; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.*; | |||
| /** | |||
| @@ -508,6 +511,63 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| wxBillProperty.setEndtime(instance.getTime()); | |||
| needpay = price * extralease; | |||
| } | |||
| //自然月,开始日期、缴款日,结束日期 | |||
| if(wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | |||
| if(i == 0){//第一周期 | |||
| wxBillProperty.setReceiveDate(wxPropertyContract.getStartDate()); | |||
| wxBillProperty.setStarttime(wxPropertyContract.getStartDate()); | |||
| double oneDayProce = (double) price / DateUtils.getMonthDayCount(wxPropertyContract.getStartDate()); | |||
| int startDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxPropertyContract.getStartDate())); | |||
| double needPayDouble; | |||
| if(receivePeriod <= 1) {//周期为一个月 | |||
| wxBillProperty.setEndtime(DateUtils.getLastDayForMonth(wxPropertyContract.getStartDate())); | |||
| needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxPropertyContract.getStartDate())-startDateInt+1); | |||
| }else{ //周期大于一个月 | |||
| wxBillProperty.setEndtime(DateUtils.getLastDayForMonth(wxPropertyContract.getStartDate(),receivePeriod - 1)); | |||
| // [A/31 *(31-12+1)]+A+A | |||
| needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxPropertyContract.getStartDate())-startDateInt+1); | |||
| needPayDouble += price * (receivePeriod - 1); | |||
| } | |||
| DecimalFormat format = new DecimalFormat("0"); | |||
| needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入 | |||
| }else if(i < paycount - 1){//中间周期 | |||
| Date receiveDate = DateUtils.getFirstDayOfNextMonth(wxPropertyContract.getStartDate(),receivePeriod * i); | |||
| wxBillProperty.setReceiveDate(receiveDate); | |||
| wxBillProperty.setStarttime(receiveDate); | |||
| wxBillProperty.setEndtime(DateUtils.getLastDayForMonth(receiveDate,receivePeriod * i)); | |||
| instance.clear(); | |||
| instance.setTime(receiveDate); | |||
| instance.add(dayType, receivePeriod); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| wxBillProperty.setEndtime(instance.getTime()); | |||
| }else if(i == paycount - 1) {//最后周期 | |||
| Date receiveDate = DateUtils.getFirstDayOfNextMonth(wxPropertyContract.getStartDate(),receivePeriod * i); | |||
| wxBillProperty.setReceiveDate(receiveDate); | |||
| wxBillProperty.setStarttime(receiveDate); | |||
| instance.clear(); | |||
| instance.setTime(receiveDate); | |||
| instance.add(dayType, extracount>0?extralease:receivePeriod);//最后一期不足,一个完整周期 | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| int endDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxPropertyContract.getEndDate())); | |||
| String endDateStr = DateUtils.date2String(instance.getTime(),"yyyy-MM")+ "-" +endDateInt; | |||
| wxBillProperty.setEndtime(DateUtils.stringToDate(endDateStr,"yyyy-MM-dd")); | |||
| double needPayDouble; | |||
| double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxBillProperty.getEndtime()); | |||
| if(receivePeriod <= 1) {//周期为一个月 | |||
| needPayDouble = oneDayProce * endDateInt; | |||
| }else{ | |||
| needPayDouble = price * (extralease-1); | |||
| needPayDouble += oneDayProce * endDateInt; | |||
| } | |||
| DecimalFormat format = new DecimalFormat("0"); | |||
| needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入 | |||
| } | |||
| } | |||
| wxBillProperty.setNeedPay(needpay); | |||
| wxBillProperty.setOwe(needpay); | |||
| wxBillProperty.setReceivePay(needpay); | |||
| @@ -587,7 +647,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| Integer price = propertyContract.getPrice(); | |||
| //按月计租 | |||
| if (propertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())) { | |||
| if (propertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) | |||
| ||propertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | |||
| result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview); | |||
| } else { | |||
| //按日计租 | |||
| @@ -562,7 +562,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| Date rentalStartDate = wxRentContract.getRentalStartDate(); | |||
| Integer price = wxRentContract.getPrice(); | |||
| //按月计租 | |||
| if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())) { | |||
| if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) | |||
| ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | |||
| rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); | |||
| } else { | |||
| //按日计租 | |||
| @@ -678,22 +679,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return resultList; | |||
| } | |||
| /** | |||
| * 是否是残月 | |||
| * @param date | |||
| * @return | |||
| */ | |||
| public boolean incompleteMonth(Date date){ | |||
| if("01".equals(new SimpleDateFormat("dd").format(date))){ | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| public Map<String, Object> buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map<String, Object> shopInfo) { | |||
| //todo:test | |||
| wxRentContract.setAdjustPeriod(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode()); | |||
| String shopInfoStr = null; | |||
| if (shopInfo != null) { | |||
| shopInfoStr = JSONObject.toJSONString(shopInfo); | |||
| @@ -754,40 +740,56 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| //自然月,开始日期、缴款日,结束日期 | |||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | |||
| if(i == 0){//第一周期 | |||
| wxBillRent.setReceiveDate(wxRentContract.getStartDate()); | |||
| wxBillRent.setStarttime(wxRentContract.getStartDate()); | |||
| double oneDayProce = (double) price / DateUtils.getMonthDayCount(wxRentContract.getStartDate()); | |||
| int startDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxRentContract.getStartDate())); | |||
| double needPayDouble; | |||
| if(receivePeriod <= 1) {//周期为一个月 | |||
| wxBillRent.setReceiveDate(wxRentContract.getStartDate()); | |||
| wxBillRent.setStarttime(wxRentContract.getStartDate()); | |||
| wxBillRent.setEndtime(DateUtils.getLastDayForCurrMonth()); | |||
| double needPayDouble = (double) price / DateUtils.getCurrMonthDayCount(); | |||
| int startDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxRentContract.getStartDate())); | |||
| // 5月12日 周期:3 [A/31 *(31-12+1)]+A+A | |||
| needPayDouble = (needPayDouble * (DateUtils.getCurrMonthDayCount()-startDateInt+1)) + (price * (receivePeriod-1)); | |||
| DecimalFormat format = new DecimalFormat("0"); | |||
| needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入 | |||
| }else{ | |||
| wxBillRent.setReceiveDate(wxRentContract.getStartDate()); | |||
| wxBillRent.setStarttime(wxRentContract.getStartDate()); | |||
| wxBillRent.setEndtime(DateUtils.getFirstDayOfNextMonth(wxRentContract.getStartDate(),receivePeriod - 1)); | |||
| double needPayDouble = (double) price / DateUtils.getCurrMonthDayCount(); | |||
| needPayDouble = needPayDouble * DateUtils.daysBetween(DateUtils.getFirstDayForCurrMonth(), wxRentContract.getStartDate()); | |||
| DecimalFormat format = new DecimalFormat("0"); | |||
| needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入 | |||
| wxBillRent.setEndtime(DateUtils.getLastDayForMonth(wxRentContract.getStartDate())); | |||
| needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxRentContract.getStartDate())-startDateInt+1); | |||
| }else{ //周期大于一个月 | |||
| wxBillRent.setEndtime(DateUtils.getLastDayForMonth(wxRentContract.getStartDate(),receivePeriod - 1)); | |||
| // [A/31 *(31-12+1)]+A+A | |||
| needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxRentContract.getStartDate())-startDateInt+1); | |||
| needPayDouble += price * (receivePeriod - 1); | |||
| } | |||
| DecimalFormat format = new DecimalFormat("0"); | |||
| needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入 | |||
| }else if(i < paycount - 1){//中间周期 | |||
| Date receiveDate = DateUtils.getFirstDayOfNextMonth(wxRentContract.getStartDate(),receivePeriod * i); | |||
| wxBillRent.setReceiveDate(receiveDate); | |||
| wxBillRent.setStarttime(receiveDate); | |||
| wxBillRent.setEndtime(DateUtils.getLastDayForMonth(receiveDate,receivePeriod * i)); | |||
| instance.clear(); | |||
| instance.setTime(receiveDate); | |||
| instance.add(dayType, receivePeriod); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| }else if(i == paycount - 1) {//最后周期 | |||
| wxBillRent.setReceiveDate(DateUtils.getFirstDayForCurrMonth()); | |||
| wxBillRent.setStarttime(DateUtils.getFirstDayForCurrMonth()); | |||
| wxBillRent.setEndtime(wxRentContract.getStartDate()); | |||
| double needPayDouble = (double) price/DateUtils.getCurrMonthDayCount(); | |||
| needPayDouble = needPayDouble * DateUtils.daysBetween(DateUtils.getFirstDayForCurrMonth(),wxRentContract.getStartDate()); | |||
| Date receiveDate = DateUtils.getFirstDayOfNextMonth(wxRentContract.getStartDate(),receivePeriod * i); | |||
| wxBillRent.setReceiveDate(receiveDate); | |||
| wxBillRent.setStarttime(receiveDate); | |||
| instance.clear(); | |||
| instance.setTime(receiveDate); | |||
| instance.add(dayType, extracount>0?extralease:receivePeriod);//最后一期不足,一个完整周期 | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| int endDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxRentContract.getEndDate())); | |||
| String endDateStr = DateUtils.date2String(instance.getTime(),"yyyy-MM")+ "-" +endDateInt; | |||
| wxBillRent.setEndtime(DateUtils.stringToDate(endDateStr,"yyyy-MM-dd")); | |||
| double needPayDouble; | |||
| double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxBillRent.getEndtime()); | |||
| if(receivePeriod <= 1) {//周期为一个月 | |||
| needPayDouble = oneDayProce * endDateInt; | |||
| }else{ | |||
| needPayDouble = price * (extralease-1); | |||
| needPayDouble += oneDayProce * endDateInt; | |||
| } | |||
| DecimalFormat format = new DecimalFormat("0"); | |||
| needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入 | |||
| }else{//中间周期 | |||
| wxBillRent.setReceiveDate(DateUtils.getFirstDayForCurrMonth()); | |||
| wxBillRent.setStarttime(DateUtils.getFirstDayForCurrMonth()); | |||
| wxBillRent.setEndtime(DateUtils.getLastDayForCurrMonth()); | |||
| } | |||
| } | |||
| @@ -839,7 +841,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| public static void main(String[] args) { | |||
| System.out.println(new SimpleDateFormat("d").format(DateUtils.getLastDayForCurrMonth())); | |||
| System.out.println(new SimpleDateFormat("d").format(DateUtils.getLastDayForMonth(new Date()))); | |||
| } | |||
| @@ -948,22 +948,45 @@ public class DateUtils { | |||
| cale.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 | |||
| return cale.getTime(); | |||
| } | |||
| /** | |||
| * 获取当前月的第一天 | |||
| * @return | |||
| */ | |||
| public static Date getFirstDayForCurrMonth(Date date){ | |||
| Calendar cale = Calendar.getInstance(); | |||
| cale.setTime(date); | |||
| cale.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 | |||
| return cale.getTime(); | |||
| } | |||
| /** | |||
| * 获取当前月的最后一天 | |||
| * 获取指定月的最后一天 | |||
| * @return | |||
| */ | |||
| public static Date getLastDayForMonth(Date date){ | |||
| Calendar ca = Calendar.getInstance(); | |||
| ca.setTime(date); | |||
| ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH)); | |||
| return ca.getTime(); | |||
| } | |||
| /** | |||
| * 获取指定日期n个月后的最后一天 | |||
| * @return | |||
| */ | |||
| public static Date getLastDayForCurrMonth(){ | |||
| public static Date getLastDayForMonth(Date date, int amount){ | |||
| Calendar ca = Calendar.getInstance(); | |||
| ca.setTime(date); | |||
| ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH)); | |||
| ca.add(Calendar.MONTH, amount); | |||
| return ca.getTime(); | |||
| } | |||
| /** | |||
| * 取得当月天数 | |||
| * 取得指定月的天数 | |||
| * */ | |||
| public static int getCurrMonthDayCount() { | |||
| public static int getMonthDayCount(Date date) { | |||
| Calendar a = Calendar.getInstance(); | |||
| a.setTime(date); | |||
| a.set(Calendar.DATE, 1);//把日期设置为当月第一天 | |||
| a.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天 | |||
| int maxDate = a.get(Calendar.DATE); | |||
| @@ -1007,4 +1030,17 @@ public class DateUtils { | |||
| return calendar.getTime(); | |||
| } | |||
| /** | |||
| * 获取指定日期n个月后的最后一天 | |||
| * @return | |||
| */ | |||
| public static Date getLastDayOfNextMonth(Date date,int amount){ | |||
| Calendar calendar = Calendar.getInstance(); | |||
| calendar.setTime(date); | |||
| calendar.set(Calendar.DAY_OF_MONTH,1); | |||
| calendar.add(Calendar.MONTH, amount); | |||
| Date d = calendar.getTime(); | |||
| return getFirstDayForCurrMonth(d); | |||
| } | |||
| } | |||
| @@ -24,7 +24,6 @@ | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="point_type" jdbcType="INTEGER" property="pointType"/> | |||
| <result column="comments" jdbcType="VARCHAR" property="comments"/> | |||
| <result column="email" property="email"/> | |||
| <result column="is_del" jdbcType="INTEGER" property="isDel"/> | |||
| </resultMap> | |||
| @@ -32,7 +31,7 @@ | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`, | |||
| `floor`,`status`,`x`,`y`,`addr`,`baidu_poi`,`longitude`,`latitude`,`create_date`, | |||
| `update_date`,`img_url`,`manager`,`manager_phone`,`type`,`point_type`,`comments`,email,`is_del` | |||
| `update_date`,`img_url`,`manager`,`manager_phone`,`type`,`point_type`,`comments`,`is_del` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -131,10 +130,7 @@ | |||
| <if test=" null != pointType "> | |||
| and `point_type` = #{pointType} | |||
| </if> | |||
| <if test=" null != email "> | |||
| and `email` = #{email} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -158,7 +154,7 @@ | |||
| s.img_url imgUrl,s.operation_area operationArea, | |||
| s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId, | |||
| m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone, | |||
| s.type,s.point_type pointType,s.addr,s.email | |||
| s.type,s.point_type pointType,s.addr | |||
| from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0 | |||
| left join wx_merchant m on ms.merchant_id=m.id | |||
| left join wx_mall_building b on s.building=b.id | |||
| @@ -253,13 +249,9 @@ | |||
| <if test=" null != type "> | |||
| and s.`type` = #{type} | |||
| </if> | |||
| <if test=" null != pointType "> | |||
| and s.`point_type` = #{pointType} | |||
| </if> | |||
| <if test=" null != email "> | |||
| and s.`email`= #{email} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and s.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -294,8 +286,6 @@ | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="point_type" jdbcType="INTEGER" property="pointType"/> | |||
| <result column="comments" jdbcType="VARCHAR" property="comments"/> | |||
| <result column="email" property="email"/> | |||
| <result column="building_name" jdbcType="VARCHAR" property="buildingName"/> | |||
| <result column="floor_name" jdbcType="VARCHAR" property="floorName"/> | |||
| @@ -314,7 +304,7 @@ | |||
| <select id="findListWithMerchantMap" parameterType="com.iformall.domain.vo.WxShopVo" resultMap="VoResultMap"> | |||
| select | |||
| s.id,s.shop_number,s.build_area,s.img_url,s.operation_area,s.status,s.manager,s.manager_phone,s.addr,s.email,s.type,s.point_type, | |||
| s.id,s.shop_number,s.build_area,s.img_url,s.operation_area,s.status,s.manager,s.manager_phone,s.addr,s.type,s.point_type, | |||
| b.building_name,f.floor_name, | |||
| m.id merchantId,m.name merchantName,m.link_person,m.link_phone, | |||
| brand.name brandName, | |||
| @@ -415,9 +405,6 @@ | |||
| <if test=" null != type "> | |||
| and s.`type` = #{type} | |||
| </if> | |||
| <if test=" null != email "> | |||
| and s.`email` = #{email} | |||
| </if> | |||
| <if test=" null != pointType "> | |||
| and s.`point_type` = #{pointType} | |||
| </if> | |||
| @@ -441,7 +428,7 @@ | |||
| <select id="getMerchantShopByShopId" resultType="hashmap" parameterType="hashmap"> | |||
| select m.`name` merchantName,s.build_area buildArea,s.operation_area operationArea, | |||
| c.price,c.receive_period receivePeriod,s.shop_number shopNumber,m.link_person linkPerson, | |||
| m.link_phone linkPhone,s.email | |||
| m.link_phone linkPhone | |||
| from wx_merchant_shop ms inner join wx_merchant m on ms.merchant_id=m.id | |||
| inner join wx_shop s on ms.shop_id=s.id | |||
| inner join wx_rent_contract c on ms.merchant_id=c.merchant_id | |||
| @@ -458,7 +445,7 @@ | |||
| s.img_url imgUrl,s.operation_area operationArea, | |||
| s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId, | |||
| m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone, | |||
| m.brand,m.business_id businessId,m.shop_type shopType,s.email | |||
| m.brand,m.business_id businessId,m.shop_type shopType | |||
| from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id | |||
| left join wx_merchant m on ms.merchant_id=m.id | |||
| left join wx_mall_building b on s.building=b.id | |||