| | |
| | | package com.yeshi.fanli.util.factory.order.dividents;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | public class TeamDividentsSourceOrderFactory {
|
| | |
|
| | | public static TeamDividentsSourceOrder create(List<CommonOrder> commonOrderList,
|
| | | BigDecimal rate) {
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | int invalidCount = 0;
|
| | | for (CommonOrder commonOrder : commonOrderList) {
|
| | | if (commonOrder.geteIncome() != null)
|
| | | money = money.add(commonOrder.geteIncome());
|
| | | if (commonOrder.getState() == CommonOrder.STATE_SX)
|
| | | invalidCount++;
|
| | | }
|
| | | |
| | | if (invalidCount >= commonOrderList.size())
|
| | | return null;
|
| | |
|
| | | if (money.compareTo(new BigDecimal(0)) <= 0)
|
| | | return null;
|
| | |
|
| | | BigDecimal dividents = MoneyBigDecimalUtil.div(money.multiply(rate), new BigDecimal(100));
|
| | | TeamDividentsSourceOrder sourceOrder = new TeamDividentsSourceOrder();
|
| | | sourceOrder.setMoney(dividents);
|
| | | sourceOrder.setOrderNo(commonOrderList.get(0).getOrderNo());
|
| | | sourceOrder.setSourceType(commonOrderList.get(0).getSourceType());
|
| | | sourceOrder.setState(TeamDividentsSourceOrder.STATE_CAN_SEND);
|
| | | sourceOrder.setUid(commonOrderList.get(0).getUserInfo().getId());
|
| | |
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrderList.get(0).getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | sourceOrder.setPreSendTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
|
| | |
|
| | | return sourceOrder;
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.util.factory.order.dividents; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.util.order.CommonOrderUtil; |
| | | |
| | | public class TeamDividentsSourceOrderFactory { |
| | | |
| | | public static TeamDividentsSourceOrder create(List<CommonOrder> commonOrderList) { |
| | | BigDecimal money = null; |
| | | int orderState = CommonOrderUtil.getState(commonOrderList); |
| | | if (orderState == CommonOrder.STATE_SX) |
| | | return null; |
| | | |
| | | if (orderState == CommonOrder.STATE_FK) { |
| | | money = CommonOrderUtil.computeEstimate(commonOrderList); |
| | | } else { |
| | | money = CommonOrderUtil.computeIncome(commonOrderList); |
| | | } |
| | | |
| | | if (money.compareTo(new BigDecimal(0)) <= 0) |
| | | return null; |
| | | |
| | | TeamDividentsSourceOrder sourceOrder = new TeamDividentsSourceOrder(); |
| | | sourceOrder.setMoney(money); |
| | | sourceOrder.setOrderNo(commonOrderList.get(0).getOrderNo()); |
| | | sourceOrder.setSourceType(commonOrderList.get(0).getSourceType()); |
| | | |
| | | if (orderState == CommonOrder.STATE_JS || orderState == CommonOrder.STATE_WQ) { |
| | | sourceOrder.setState(TeamDividentsSourceOrder.STATE_CAN_SEND); |
| | | Date settlementTime = CommonOrderUtil.getSettlementTime(commonOrderList); |
| | | if (settlementTime == null) |
| | | return null; |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(settlementTime); |
| | | calendar.add(Calendar.MONTH, 1); |
| | | sourceOrder.setPreSendTime(new Date(TimeUtil.convertToTimeTemp( |
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd"))); |
| | | } else { |
| | | sourceOrder.setState(TeamDividentsSourceOrder.STATE_UNKOWN); |
| | | } |
| | | sourceOrder.setUid(commonOrderList.get(0).getUserInfo().getId()); |
| | | sourceOrder.setCreateTime(commonOrderList.get(0).getThirdCreateTime());//下单时间 |
| | | |
| | | return sourceOrder; |
| | | } |
| | | |
| | | } |