zainali5120
2020-09-25 286ea89f5f6cade73276f865effa5dcd2b19406d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.xcong.excoin.trade;
 
import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
 
public class MergeOrder {
    private List<OrderCoinsEntity> orders = new ArrayList<>();
 
    //最后位置添加一个
    public void add(OrderCoinsEntity order){
        orders.add(order);
    }
 
 
    public OrderCoinsEntity get(){
        return orders.get(0);
    }
 
    public int size(){
        return orders.size();
    }
 
    public BigDecimal getPrice(){
        return orders.get(0).getEntrustPrice();
    }
 
    public Iterator<OrderCoinsEntity> iterator(){
        return orders.iterator();
    }
    
    public BigDecimal getTotalAmount() {
        BigDecimal total = new BigDecimal(0);
        for(OrderCoinsEntity item : orders) {
            total = total.add(item.getEntrustCnt());
        }
        return total;
    }
}