admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -272,7 +272,7 @@
      HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoOrder.getHongBaoV2().getId());
      if (oldHongBao == null)
         throw new HongBaoException(10, "红包对象不存在");
      // 已经失效或者已经领取的红包不做处理
      // 已经失效,已经领取,新老状态一致的红包不做处理
      if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
         return;
@@ -312,6 +312,14 @@
         } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
            hongBao.setState(HongBaoV2.STATE_SHIXIAO);
            hongBao.setMoney(new BigDecimal(0));
         }
         // 新老红包状态一致不处理
         if (oldHongBao.getState().intValue() == hongBao.getState())
            return;
         if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
            if (mianDan) {
               try {
                  userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo());
@@ -321,6 +329,7 @@
               }
            }
         }
         hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
         // 加入通知
@@ -587,21 +596,23 @@
               if (notificationMap.get(child.getType()) == null) {
                  HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                  tempHongBao.setUserInfo(child.getUserInfo());
                  tempHongBao.setMoney(childUpdate.getMoney());
                  tempHongBao
                        .setMoney(childUpdate.getMoney() == null ? new BigDecimal(0) : childUpdate.getMoney());
                  CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                  tempCommonOrder.setPayment(commonOrder.getPayment());
                  notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
               } else {
                  // 增加付款金额与资金
                  HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType());
                  tempHongBaoOrder.getCommonOrder().setPayment(
                        tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                  tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(childUpdate.getMoney()));
                  if (commonOrder.getPayment() != null)
                     tempHongBaoOrder.getCommonOrder().setPayment(
                           tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                  if (childUpdate.getMoney() != null)
                     tempHongBaoOrder.getHongBaoV2()
                           .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(childUpdate.getMoney()));
                  notificationMap.put(child.getType(), tempHongBaoOrder);
               }
            }
      } else
         throw new HongBaoException(2, "type错误");
@@ -727,6 +738,10 @@
               firstHongbao.setMoney(
                     MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
            }
            // 返利为0的不通知
            if (firstHongbao.getMoney() == null || firstHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
               return;
            hongBaoV2Mapper.insertSelective(firstHongbao);
            // 用户通知
            if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
@@ -774,6 +789,11 @@
                  secondHongbao.setMoney(
                        MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
               }
               // 返利为0的不统计
               if (secondHongbao.getMoney() == null || secondHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
                  return;
               hongBaoV2Mapper.insertSelective(secondHongbao);
               // 用户通知
@@ -1021,9 +1041,14 @@
      else
         return money;
   }
   @Override
   public List<HongBaoV2> listChildrenById(Long id){
   public List<HongBaoV2> listChildrenById(Long id) {
      return hongBaoV2Mapper.listChildrenById(id);
   }
   @Override
   public List<Long> getUidByNear30DayShareSucceed() {
      return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
   }
}