Example #1
0
 public List<GoodsOperateBean> getGoodsList() {
   List<GoodsOperateBean> list = new ArrayList<GoodsOperateBean>();
   if (!Util.isEmpty(this.mustList)) {
     for (GoodsOperateBean bean : this.mustList) {
       list.add(bean.clone());
     }
   }
   Peshe peshe = this.getPeshe(this.randomPesheList);
   if (peshe != null) {
     list.add(new GoodsOperateBean(peshe.getGoodsId(), peshe.getNum(), peshe.getBind()));
   }
   return list;
 }
Example #2
0
 private Peshe getPeshe(List<Peshe> pesheList) {
   if (null == pesheList || 0 == pesheList.size()) {
     return null;
   }
   int sumGon = 0;
   for (Peshe item : pesheList) {
     sumGon += item.getGon();
   }
   if (0 == sumGon) {
     return null;
   }
   int random = ProbabilityMachine.randomIntWithoutZero(sumGon);
   int overlapCount = 0;
   for (Peshe it : pesheList) {
     if ((overlapCount < random) && (random <= (overlapCount + it.getGon()))) {
       if (it.getGoodsId() != 0) {
         return it;
       }
       break;
     }
     overlapCount += it.getGon();
   }
   return null;
 }