admin
2019-02-15 c12b6ec43f6c79426d6f2337f903d3c0a225e9a5
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -31,26 +31,34 @@
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;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.order.ShareGoodsActivityOrder;
import com.yeshi.fanli.entity.taobao.PidOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.exception.HongBaoException;
import com.yeshi.fanli.exception.order.ShareGoodsActivityOrderException;
import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.msg.UserOrderMsgNotificationService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
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.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
@@ -107,6 +115,15 @@
   @Resource
   private UserOrderMsgNotificationService userOrderMsgNotificationService;
   @Resource
   private ConfigService configService;
   @Resource
   private ShareGoodsActivityOrderService shareGoodsActivityOrderService;
   @Resource
   private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
   @Override
   public int insert(HongBaoV2 record) {
@@ -557,27 +574,33 @@
               hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
               // 加入通知
               if (notificationMap.get(type) == null) {
               if (notificationMap.get(child.getType()) == null) {
                  HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
                  tempHongBao.setUserInfo(child.getUserInfo());
                  tempHongBao.setMoney(child.getMoney());
                  CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
                  tempCommonOrder.setPayment(commonOrder.getPayment());
                  notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
                  notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
               } else {
                  // 增加付款金额与资金
                  HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
                  HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType());
                  tempHongBaoOrder.getCommonOrder().setPayment(
                        tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
                  tempHongBaoOrder.getHongBaoV2()
                        .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney()));
                  notificationMap.put(type, tempHongBaoOrder);
                  notificationMap.put(child.getType(), tempHongBaoOrder);
               }
            }
      } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
         BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
         BigDecimal fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
         List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
               .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
         if (list != null && list.size() > 0) {
            fanliRate = list.get(0).getShareRate();
         }
         HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
         hongBao.setUpdateTime(new Date());
         // 更改状态与资金
@@ -815,6 +838,37 @@
            return;
         // 分享赚
         BigDecimal shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
         // 判断订单分享活动是否开启
         if ("1".equalsIgnoreCase(configService.get("share_goods_activity_open"))) {
            // 没有订单,并且是渠道ID来的,并且
            UserExtraTaoBaoInfo taoBaoExtraInfo = userExtraTaoBaoInfoService
                  .getByUid(commonOrder.getUserInfo().getId());
            if (taoBaoExtraInfo != null && ((!StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num())
                  && !commonOrder.getOrderNo().endsWith(taoBaoExtraInfo.getTaoBaoOrderEnd6Num().trim()))
                  || StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num()))) {
               List<TaoBaoOrder> taoBaoOrderList = taoBaoOrderMapper
                     .selectTaoBaoOrderByOrderId(commonOrder.getOrderNo());
               if (taoBaoOrderList != null && taoBaoOrderList.size() > 0
                     && !StringUtil.isNullOrEmpty(taoBaoOrderList.get(0).getRelationId())) {
                  if (shareGoodsActivityOrderService.listByUid(commonOrder.getUserInfo().getId()).size() < 1) {
                     shareRate = new BigDecimal(hongBaoManageService.get("share_activity_proportion"));
                     try {
                        shareGoodsActivityOrderService.addShareGoodsActivityOrder(
                              commonOrder.getUserInfo().getId(), shareRate, commonOrder.getOrderNo());
                     } catch (ShareGoodsActivityOrderException e) {
                        try {
                           LogHelper.errorDetailInfo(e);
                        } catch (Exception e1) {
                           e1.printStackTrace();
                        }
                     }
                  }
               }
            }
         }
         HongBaoV2 hongBao = new HongBaoV2();
         hongBao.setCreateTime(new Date());
         hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);