|
|
@@ -572,7 +572,59 @@ public class TsfGoodsService {
|
|
|
* @date 2021. 3. 8
|
|
|
*/
|
|
|
public Collection<Goods> getTmtbGoodsList(Goods goods) {
|
|
|
- return goodsDao.getTmtbGoodsList(goods);
|
|
|
+
|
|
|
+ Collection<Goods> result = new ArrayList<Goods>();
|
|
|
+
|
|
|
+ Collection<Tmtb> tmtbSqList = goodsDao.getTmtbSqList(goods);
|
|
|
+ if (tmtbSqList == null || tmtbSqList.isEmpty()) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ int rCount = 0; //다다익선 조회수
|
|
|
+ int tCount = goods.getMaxRownum(); //리턴 잔여수
|
|
|
+ if (tCount == 0) tCount = 20;
|
|
|
+
|
|
|
+ for (Tmtb tmtb: tmtbSqList) {
|
|
|
+
|
|
|
+ tmtb.setTmtbSq(tmtb.getTmtbSq());
|
|
|
+ Collection<Goods> tmtbGoodsList = goodsDao.getTmtbGoodsList(goods);
|
|
|
+ if (tmtbGoodsList == null || tmtbGoodsList.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tCount == 0) { //잔여수가 없으면 종료
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //다다익선 조회 상품 수
|
|
|
+ rCount = tmtbGoodsList.size();
|
|
|
+
|
|
|
+ if (tCount > rCount) { //조회수보다 잔여수가 클경우
|
|
|
+ result.addAll(tmtbGoodsList);
|
|
|
+ tCount = tCount - rCount; //남은 잔여수 계산
|
|
|
+ }else {
|
|
|
+ if (tCount == rCount) { //잔여 수량과 조회수가 같은면 종료
|
|
|
+ result.addAll(tmtbGoodsList);
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+
|
|
|
+ for (int i=0; i<tCount; i++) { //잔여수량만큼 loop
|
|
|
+ int tmtbGoodsListCnt = 0;
|
|
|
+ for(Goods tmtbGoods: tmtbGoodsList) {
|
|
|
+ if (i == tmtbGoodsListCnt) {
|
|
|
+ result.add(tmtbGoods);
|
|
|
+ tCount --;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ tmtbGoodsListCnt ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|