合併相同商品

//合併相同商品
private void toMergeSameItem(List<pos_detail> details) {
    Map<String, pos_detail> detailMap = new HashMap<String, pos_detail>();
    for (pos_detail posDetail : details) {
        if (detailMap.containsKey(posDetail.getItem_no())) {
            posDetail.setSale_qnty(posDetail.getSale_qnty() + detailMap.get(posDetail.getItem_no()).getSale_qnty());
            posDetail.setSale_money(posDetail.getSale_money() + detailMap.get(posDetail.getItem_no()).getSale_money());
        }
        detailMap.put(posDetail.getItem_no(), posDetail);
    }
    details.clear();// 清空棧內存
    for (Map.Entry<String, pos_detail> entry : detailMap.entrySet()) {
        details.add(entry.getValue());
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章