admin
2019-02-27 309a22d0624e8fec46f4b6722ed6135fe0a2ea3d
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -31,7 +31,6 @@
import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
@@ -56,6 +55,8 @@
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserNotificationService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
@@ -124,6 +125,12 @@
   @Resource
   private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
   @Resource
   private UserSystemCouponService userSystemCouponService;
   @Resource
   private UserSystemCouponRecordService userSystemCouponRecordService;
   @Override
   public int insert(HongBaoV2 record) {
@@ -505,6 +512,23 @@
      if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
         BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
         // 免单处理
         boolean mianDan = false;
         if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
            List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
                  commonOrder.getOrderNo());
            if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
               BigDecimal payMent = commonOrder.getPayment();
               if (commonOrder.getState() == CommonOrder.STATE_JS)
                  payMent = commonOrder.getSettlement();
               if (payMent.compareTo(new BigDecimal(10)) < 0) {
                  mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getOrderNo());
                  fanliRate = new BigDecimal(100);
               }
            }
         }
         HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
         hongBao.setUpdateTime(new Date());
         // 更改状态与资金
@@ -685,6 +709,34 @@
         throws HongBaoException {
      if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
         BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
         // 查询是否有免单计划
         boolean mianDan = false;
         if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
            List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
                  commonOrder.getOrderNo());
            if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
               BigDecimal payMent = commonOrder.getPayment();
               if (commonOrder.getState() == CommonOrder.STATE_JS)
                  payMent = commonOrder.getSettlement();
               CommonOrderGoods goods = commonOrderGoodsMapper
                     .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId());
               if (goods != null) {
                  try {
                     mianDan = userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(),
                           commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId()));
                     if (mianDan)
                        fanliRate = new BigDecimal(100);
                  } catch (NumberFormatException e) {
                     throw new HongBaoException(10, "免单商品处理出错");
                  } catch (Exception e) {
                     throw new HongBaoException(11, "免单商品处理出错");
                  }
               }
            }
         }
         HongBaoV2 hongBao = new HongBaoV2();
         hongBao.setUserInfo(commonOrder.getUserInfo());
         hongBao.setCreateTime(new Date());
@@ -733,7 +785,7 @@
         }
         UserInfo boss = threeSaleSerivce.getBoss(user.getId());
         if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO) {// 1级BOSS存在且红包未失效
         if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO && !mianDan) {// 1级BOSS存在且红包未失效,免单不支持多级分销
            // 插入一级子红包
            BigDecimal firstRate = hongBaoManageService