diff --git a/mallinkAdmin/src/main/resources/db/migration/V201905211601__L_ALTER_RENT.sql b/mallinkAdmin/src/main/resources/db/migration/V201905211601__L_ALTER_RENT.sql new file mode 100644 index 000000000..f3bc7a460 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201905211601__L_ALTER_RENT.sql @@ -0,0 +1,5 @@ +ALTER TABLE wx_property_contract + ADD COLUMN rent_price int(11) DEFAULT 0 COMMENT '多径租金单价(其他放rentInfo)'; + +ALTER TABLE wx_rent_contract + ADD COLUMN rent_price int(11) DEFAULT 0 COMMENT '多径租金单价(其他放rentInfo)'; \ No newline at end of file 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 3b1cc2205..cff82f473 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java @@ -168,6 +168,9 @@ public class WxPropertyContract extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value = "租金单位1日2月3年", name = "priceUnit") private Integer priceUnit; + @io.swagger.annotations.ApiModelProperty(value = "多径租赁单价(其他放rentInfo)", name = "priceUnit") + private String rentPrice; + public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") 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 845545851..5f2142c0a 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -213,6 +213,9 @@ public class WxRentContract extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value = "租金单位1日2月3年", name = "priceUnit") private Integer priceUnit; + @io.swagger.annotations.ApiModelProperty(value = "多径租赁单价(其他放rentInfo)", name = "priceUnit") + private String rentPrice; + public static enum Field { Id_ASC("`id` ASC"), Id_DESC("`id` DESC") , MerchantId_ASC("`merchant_id` ASC"), MerchantId_DESC("`merchant_id` DESC") diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index df47e55fb..e18419642 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -18,6 +18,7 @@ import com.iformall.service.WxPropertyContractService; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; import org.apache.commons.collections.map.HashedMap; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -91,7 +92,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); } - //init dateDiff + //m:init dateDiff if(wxPropertyContract.getRentalStartDate() != null && wxPropertyContract.getRentalEndDate() != null){ Calendar instance = Calendar.getInstance(); instance.setTime(wxPropertyContract.getRentalEndDate()); @@ -101,6 +102,32 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService result.put("totalPeriodDay",array[1]); } + //m:init 租赁单价 + String rentInfo = wxPropertyContract.getRentInfo(); + if(StringUtils.isNotBlank(rentInfo)){ + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + int size = rentInfoArray.size(); + //查询rent_info 包括shopId + for (int i = 0; i < size; i++) { + JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); + Double rentPrice = rentInfoObject.getDouble("rentPrice"); + Long price = wxPropertyContract.getPrice()/100; + if(rentPrice == null){ + Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()); + rentPrice = new BigDecimal((float)price/rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + rentInfoObject.put("rentPrice",rentPrice); + } + } + wxPropertyContract.setRentInfo(rentInfoArray.toJSONString()); + }else{ + if(wxPropertyContract.getRentPrice() == null){ + Long price = wxPropertyContract.getPrice()/100; + Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()); + Double rentPrice = new BigDecimal((float)price/rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + wxPropertyContract.setRentPrice(rentPrice.toString()); + } + } + wxPropertyContract.setPrice(wxPropertyContract.getPrice() != null ? wxPropertyContract.getPrice() : 0); wxPropertyContract.setDeposit(wxPropertyContract.getDeposit() != null ? wxPropertyContract.getDeposit() : 0); 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 01fcbe2a5..5785b46ed 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -123,7 +123,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); } - //init dateDiff + //m: init dateDiff if(wxRentContract.getRentalStartDate() != null && wxRentContract.getRentalEndDate() != null){ Calendar instance = Calendar.getInstance(); instance.setTime(wxRentContract.getRentalEndDate()); @@ -133,32 +133,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { result.put("totalPeriodDay",array[1]); } - //商场信息 - WxMall wxMall = new WxMall(); - wxMall.setTenantId(wxRentContract.getTenantId()); - List mallList = wxMallMapper.findList(wxMall); - if (!mallList.isEmpty()) { - result.put("mall", mallList.get(0)); - } - wxRentContract.setPrice(wxRentContract.getPrice() != null ? wxRentContract.getPrice() : 0); - wxRentContract.setDeposit(wxRentContract.getDeposit() != null ? wxRentContract.getDeposit() : 0); - - //目前只有多经点位租赁合同 - WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); - if(wxShop !=null && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ - //handle adjustPeriod 1日 2月 monthHandleType 2按账单周期 3按自然月 - if(wxRentContract.getAdjustPeriod().intValue() == 1){ - wxRentContract.setAdjustPeriod(1); - wxRentContract.setMonthHandleType(null); - }else if(wxRentContract.getAdjustPeriod().intValue() == 2){ - wxRentContract.setAdjustPeriod(2); - wxRentContract.setMonthHandleType(2); - }else if(wxRentContract.getAdjustPeriod().intValue() == 3){ - wxRentContract.setAdjustPeriod(2); - wxRentContract.setMonthHandleType(3); - } - } - //m: init 租赁单价 String rentInfo = wxRentContract.getRentInfo(); if(StringUtils.isNotBlank(rentInfo)){ @@ -176,7 +150,41 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } wxRentContract.setRentInfo(rentInfoArray.toJSONString()); + }else{ + if(wxRentContract.getRentPrice() == null){ + Long price = wxRentContract.getPrice()/100; + Double rentArea = Double.parseDouble(wxRentContract.getRentArea()); + Double rentPrice = new BigDecimal((float)price/rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + wxRentContract.setRentPrice(rentPrice.toString()); + } + } + + //商场信息 + WxMall wxMall = new WxMall(); + wxMall.setTenantId(wxRentContract.getTenantId()); + List mallList = wxMallMapper.findList(wxMall); + if (!mallList.isEmpty()) { + result.put("mall", mallList.get(0)); } + wxRentContract.setPrice(wxRentContract.getPrice() != null ? wxRentContract.getPrice() : 0); + wxRentContract.setDeposit(wxRentContract.getDeposit() != null ? wxRentContract.getDeposit() : 0); + + //目前只有多经点位租赁合同 +// WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); +// if(wxShop !=null && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ +// //handle adjustPeriod 1日 2月 monthHandleType 2按账单周期 3按自然月 +// if(wxRentContract.getAdjustPeriod().intValue() == 1){ +// wxRentContract.setAdjustPeriod(1); +// wxRentContract.setMonthHandleType(null); +// }else if(wxRentContract.getAdjustPeriod().intValue() == 2){ +// wxRentContract.setAdjustPeriod(2); +// wxRentContract.setMonthHandleType(2); +// }else if(wxRentContract.getAdjustPeriod().intValue() == 3){ +// wxRentContract.setAdjustPeriod(2); +// wxRentContract.setMonthHandleType(3); +// } +// } + result.put("wxRentContract", wxRentContract); //关联的商户 diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 742093286..dcaebc3c0 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -39,7 +39,7 @@ - + @@ -48,7 +48,7 @@ `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`,price_unit + `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`, `file_names`,price_unit,rent_price diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 130b4209b..1a6792bd5 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -45,6 +45,7 @@ + @@ -55,7 +56,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`,price_unit + `business_type`,`rent_info`, `file_names`,price_unit,rent_price