Переглянути джерело

[租赁账单][修改][押金]

release_toaliyun_real
gongbiao 7 роки тому
джерело
коміт
9d791daf18
3 змінених файлів з 111 додано та 7 видалено
  1. +11
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxBillRent.java
  2. +96
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  3. +4
    -3
      mallinkService/src/main/resources/mapper/WxBillRentMapper.xml

+ 11
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxBillRent.java Переглянути файл

@@ -121,6 +121,17 @@ public class WxBillRent implements Serializable {
@io.swagger.annotations.ApiModelProperty(value = "预览账单0否1是", name = "isPreview")
private Integer isPreview;

@io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo")
private String shopInfo;

public String getShopInfo() {
return shopInfo;
}

public void setShopInfo(String shopInfo) {
this.shopInfo = shopInfo;
}

public Integer getIsPreview() {
return isPreview;
}


+ 96
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java Переглянути файл

@@ -442,6 +442,16 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillDeposit.setUpdatetime(date);
wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode());
wxBillDeposit.setRentShopType(wxRentContract.getRentShopType());
String rentInfo = wxRentContract.getRentInfo();
if (rentInfo != null) {
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
Map<String, Object> shopInfo = new HashMap<>();
for (int i = 0, size = rentInfoArray.size(); i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("deposit"));
}

}
try {
wxBillDepositMapper.insertSelective(wxBillDeposit);
} catch (Exception e) {
@@ -483,7 +493,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview);
} else {
//按日计租
Map<String,Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0,isPreview);
Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null);
rentList = ( List<WxBillRent>)resultMap.get("billList");
}
}
@@ -525,7 +535,10 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}

public List<WxBillRent> buildRentMonth(WxMerchant wxMerchant, Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Integer price,Integer isPreview) {
List<int[]> priceList = computePrice(wxRentContract.getRentInfo());
String rentInfo = wxRentContract.getRentInfo();
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);

List<int[]> priceList = computePrice(rentInfo);
int size = priceList.size();
int[] priceArrs = new int[size];
for (int i = 0; i < size; i++) {
@@ -537,6 +550,17 @@ public class WxRentContractServiceImpl implements WxRentContractService {
priceArrs[i] = sum;
}

List<Map<String, Object>> shopInfos = new ArrayList<>();
for (int i = 0; i < size; i++) {
Map<String, Object> shopInfo = new HashMap<>();
int[] ints = priceList.get(i);
for (int j = 0; j < ints.length; j++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(j);
shopInfo.put(rentInfoObject.getString("shopNumber"), ints[j]);
}
shopInfos.add(shopInfo);
}

int month = 12;
int divide = lease / month;
int mod = lease % month;
@@ -555,7 +579,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
instance.setTime(rentalStartDate);
//开始时间
instance.add(Calendar.MONTH, month * i);
Map<String, Object> resultMap = buildRent(leaseArr[i], receivePeriod, priceArrs[i], instance.getTime(), Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount, isPreview);
Map<String, Object> resultMap = buildRent(leaseArr[i], receivePeriod, priceArrs[i], instance.getTime(), Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount, isPreview, shopInfos.get(i));
List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList");
billcount = (Integer)resultMap.get("billcount");
resultList.addAll(billRentList);
@@ -563,7 +587,11 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return resultList;
}

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) {
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) {
String shopInfoStr = null;
if (shopInfo != null) {
shopInfoStr = JSONObject.toJSONString(shopInfo);
}
Map<String,Object> resultMap = new HashedMap();
List<WxBillRent> resultList = new ArrayList<>();
int extralease = lease % receivePeriod;
@@ -650,6 +678,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillRent.setIsDel(EnumDelStatus.NOT_DEL.getCode());
wxBillRent.setRentShopType(wxRentContract.getRentShopType());
wxBillRent.setPeriod(++billcount);
wxBillRent.setShopInfo(shopInfoStr);
try {
wxBillRentMapper.insertSelective(wxBillRent);
resultList.add(wxBillRent);
@@ -1509,4 +1538,67 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxRentContractMapper.updateApplyStatus(wxRentContract);
}


public static void main(String[] args) {
JSONArray rentInfoArray = JSONArray.parseArray("[{shopId:0,shopNumber:0,price:1000,adjustRatio:[1100,1100]},{shopId:1,shopNumber:1,price:2000,adjustRatio:[1200,1200]},{shopId:2,shopNumber:2,price:3000,adjustRatio:[1300,1300]}]");
int arraySize = rentInfoArray.size();
List<int[]> priceList = new ArrayList<>();
//第一年
int[] priceArr = new int[arraySize];
for (int i = 0; i < arraySize; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
priceArr[i] = rentInfoObject.getIntValue("price");
}
priceList.add(priceArr);
//大于一年
JSONObject rentInfoObject = rentInfoArray.getJSONObject(0);
JSONArray adjustRatio = rentInfoObject.getJSONArray("adjustRatio");
int adjustRatioSize = adjustRatio.size();

for (int i = 0; i < adjustRatioSize; i++) {
int[] priceArrs = new int[arraySize];
for (int j = 0; j < arraySize; j++) {
rentInfoObject = rentInfoArray.getJSONObject(j);
adjustRatio = rentInfoObject.getJSONArray("adjustRatio");//
double price = priceList.get(i)[j] + priceList.get(i)[j] * adjustRatio.getIntValue(i) / 10000.0;
priceArrs[j] = new BigDecimal(price).setScale(0, RoundingMode.HALF_EVEN).intValue();
}
priceList.add(priceArrs);
}
int size = priceList.size();
int[] priceArrs = new int[size];
for (int i = 0; i < size; i++) {
int[] price = priceList.get(i);
int sum = 0;
for (int p : price) {
sum += p;
}
priceArrs[i] = sum;
}


List<Map<String, Object>> shopInfos = new ArrayList<>();
for (int i = 0; i < size; i++) {
Map<String, Object> shopInfo = new HashMap<>();
int[] ints = priceList.get(i);
for (int j = 0; j < ints.length; j++) {
rentInfoObject = rentInfoArray.getJSONObject(j);
shopInfo.put(rentInfoObject.getString("shopNumber"), ints[j]);
}
shopInfos.add(shopInfo);
}

System.out.println(shopInfos);
//System.out.println(Arrays.toString(priceArr));
// Calendar a = Calendar.getInstance();
// a.set(Calendar.DATE, 1);
// a.roll(Calendar.DATE, -1);
// int maxDate = a.get(Calendar.DATE);
// System.out.println(maxDate);
// a.clear();
// a.setTime(new Date());
// System.out.println(a.get(Calendar.DAY_OF_MONTH));

}

}

+ 4
- 3
mallinkService/src/main/resources/mapper/WxBillRentMapper.xml Переглянути файл

@@ -26,14 +26,15 @@
<result column="late_pay_price" jdbcType="INTEGER" property="latePayPrice"/>
<result column="period" jdbcType="INTEGER" property="period"/>
<result column="is_preview" property="isPreview"/>

<result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
</resultMap>
<sql id="allColumns">
`id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,
`createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,
`merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,
`revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`
`revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`,`shop_info`
</sql>
<sql id="dynamicWhereConditions">
@@ -85,7 +86,7 @@
br.`rent_contract_id` rentContractId,d.receive_pay deposit,case when br.late_pay_time is null then 0 else
FLOOR(DATEDIFF(now(),br.late_pay_time)*br.late_pay_ratio/10000*br.owe) end latePayPrice,
(select max(period) from wx_bill_rent where rent_contract_id=br.rent_contract_id) allPeriod,d.`status`
depositStatus
depositStatus,br.shop_info shopInfo
from wx_bill_rent br left join wx_merchant m on br.merchant_id=m.id
left join wx_shop s on br.shop_id=s.id
left join wx_rent_contract r on br.rent_contract_id=r.id


Завантаження…
Відмінити
Зберегти