/*
   * 修改浏览次数
   */
  @Override
  public DealerInfo modifyViewContact(String brandId, String dealerId) throws BusinessException {
    DealerInfoModel dealerInfo = dealerInfoService.findById(dealerId);
    if (null == dealerInfo) {
      throw new BusinessException(CommonConst.DATA_NOT_EXISTS);
    }

    UserInfo userInfo = userInfoService.selectByPrimaryKey(dealerId);
    Integer contactIsExistInt = brandViewContactMapper.isExist(brandId, dealerId, null);
    Short viewType = BrandConstant.BrandViewContact.VIEW_TYPE_INITIATIVE;
    if (contactIsExistInt > 0) {
      Integer groomIsExistInt = dealerGroomMapper.isExist(brandId, dealerId);
      if (groomIsExistInt > 0) {
        viewType = BrandConstant.BrandViewContact.VIEW_TYPE__RECOMMEND;
      } else {
        Integer inviteIsExistInt = brandInviteMapper.isExist(brandId, dealerId);
        if (inviteIsExistInt > 0) {
          viewType = BrandConstant.BrandViewContact.VIEW_TYPE_APPLICATION;
        }
      }
    }
    BrandViewContact brandViewContact = new BrandViewContact();
    brandViewContact.setBrandId(brandId);
    brandViewContact.setDealerId(dealerId);
    brandViewContact.setViewType(viewType);
    if (contactIsExistInt == 0) {
      brandViewContact.setRefrenceId(com.zttx.sdk.utils.SerialnoUtils.buildPrimaryKey());
      brandViewContact.setViewTime(CalendarUtils.getCurrentLong());
      brandViewContactMapper.insert(brandViewContact);
    }

    BrandCount brandCount = brandCountService.selectByPrimaryKey(brandId);
    Integer viewCount = brandCountService.getViewDealerTotal(brandId);
    boolean brandCountisExist = true;
    if (null != brandCount) {
      if (viewCount.intValue() <= brandCount.getViewDealerCount().intValue()) {
        throw new BusinessException(BrandConst.VIEW_CONTACT_LACK_POINTS);
      }
    } else {
      brandCountisExist = false;
      brandCount = new BrandCount();
      brandCount.setRefrenceId(com.zttx.sdk.utils.SerialnoUtils.buildPrimaryKey());
    }
    // 查看经销商联系信息数量
    Long count = brandViewContactMapper.getBrandViewContactCount(brandViewContact);
    brandCount.setViewDealerCount(count.intValue());
    if (brandCountisExist) {
      brandCountService.updateByPrimaryKey(brandCount);
    } else {
      brandCountService.insert(brandCount);
    }
    Boolean isExits = false;
    if (contactIsExistInt > 0) {
      isExits = true;
    }
    dealerInfo.setIsViewAdd(isExits);
    dealerInfo.setUserMobile(userInfo.getUserMobile());

    return dealerInfo;
  }
 /*
  * 校验是否存在
  * */
 @Override
 public Integer isExist(String brandId, String dealerId) {
   Short viewType = BrandConstant.BrandViewContact.VIEW_TYPE_INITIATIVE;
   Integer isExist = brandViewContactMapper.isExist(brandId, dealerId, null);
   return isExist;
 }
 @Override
 public Boolean isExist(String brandId, String dealerId, Short viewType) {
   return brandViewContactMapper.isExist(brandId, dealerId, viewType) > 0;
 }