package com.yeshi.fanli.util.order;
|
|
import java.math.BigDecimal;
|
import java.util.Date;
|
import java.util.List;
|
|
import com.yeshi.fanli.entity.order.CommonOrder;
|
|
public class CommonOrderUtil {
|
|
/**
|
* 就算收益
|
* @Title: computeIncome
|
* @Description:
|
* @param orderList
|
* @return
|
* BigDecimal 返回类型
|
* @throws
|
*/
|
public static BigDecimal computeIncome(List<CommonOrder> orderList) {
|
if (orderList == null || orderList.size() == 0)
|
return null;
|
BigDecimal money = new BigDecimal(0);
|
for (CommonOrder commonOrder : orderList)
|
if (commonOrder.getState() != CommonOrder.STATE_SX && commonOrder.geteIncome() != null)
|
money = money.add(commonOrder.geteIncome());
|
return money;
|
}
|
|
/**
|
* 计算预估收益
|
* @Title: computeEstimate
|
* @Description:
|
* @param orderList
|
* @return
|
* BigDecimal 返回类型
|
* @throws
|
*/
|
public static BigDecimal computeEstimate(List<CommonOrder> orderList) {
|
if (orderList == null || orderList.size() == 0)
|
return null;
|
BigDecimal money = new BigDecimal(0);
|
for (CommonOrder commonOrder : orderList)
|
if (commonOrder.getState() != CommonOrder.STATE_SX && commonOrder.getEstimate() != null)
|
money = money.add(commonOrder.getEstimate());
|
return money;
|
}
|
|
public static Integer getState(List<CommonOrder> orderList) {
|
if (orderList == null || orderList.size() == 0)
|
return null;
|
int sxCount = 0;
|
int wqCount = 0;
|
int fkCount = 0;
|
int jsCount = 0;
|
for (CommonOrder order : orderList) {
|
switch (order.getState()) {
|
case CommonOrder.STATE_FK:
|
fkCount++;
|
break;
|
case CommonOrder.STATE_JS:
|
jsCount++;
|
break;
|
case CommonOrder.STATE_SX:
|
sxCount++;
|
break;
|
case CommonOrder.STATE_WQ:
|
wqCount++;
|
break;
|
}
|
}
|
|
if (sxCount == orderList.size())
|
return CommonOrder.STATE_SX;
|
|
if (wqCount + sxCount == orderList.size())
|
return CommonOrder.STATE_WQ;
|
|
if (wqCount + sxCount + jsCount == orderList.size())
|
return CommonOrder.STATE_JS;
|
|
return CommonOrder.STATE_FK;
|
}
|
|
public static Date getSettlementTime(List<CommonOrder> orderList) {
|
if (orderList == null)
|
return null;
|
for (CommonOrder order : orderList) {
|
switch (order.getState()) {
|
|
case CommonOrder.STATE_JS:
|
case CommonOrder.STATE_WQ:
|
return order.getSettleTime();
|
}
|
}
|
return null;
|
}
|
|
}
|