private void checkForm(PartnerActivityProductAudit form, String domain) {
    if (StringUtils.isBlank(form.getActId())) {
      throw new BizException(GlobalErrorCode.UNKNOWN, "活动Id不存在");
    }

    if (StringUtils.isBlank(form.getProductId())) {
      throw new BizException(GlobalErrorCode.UNKNOWN, "商品Id不存在");
    }

    if (form.getAuditState() == null) {
      throw new BizException(GlobalErrorCode.UNKNOWN, "审核状态不存在");
    }

    if (form.getAuditor() == null) {
      throw new BizException(GlobalErrorCode.UNKNOWN, "审核人不存在");
    }

    if (ActivityTicketAuditStatus.APPROVED.equals(form.getAuditState())) {
      if (form.getStartTime() == null || form.getEndTime() == null)
        throw new BizException(GlobalErrorCode.UNKNOWN, "审核通过必须分配活动开始结束时间");
      if (form.getProductId() == null) throw new BizException(GlobalErrorCode.UNKNOWN, "审核信息不完整");
    }

    User user =
        userService.loadExtUser(StringUtils.defaultString(domain, "xiangqu"), form.getAuditor());
    if (user == null) {
      throw new BizException(GlobalErrorCode.UNAUTHORIZED, "您没有权限审核该活动");
    }
  }
  /**
   * 审核活动商品<br>
   * /openapi/s/partner/act/audit?auditor=123&actId=2585&productId=6e5rm0&auditState=APPROVED&shortName=xbwceshi
   * 问题:审核的时候又复制了一条ticket,没有在原基础上添加审核状态,造成数据冗余,商品的ticketId也级联修改,造成不必要的操作,解决:不添加新的ticket记录<br>
   * 事物回滚应该全部调用放在service层) 新建一条ticket并且将活动商品关联到该ticket@RequestHeader("Domain")
   */
  @ResponseBody
  @RequestMapping("/partner/act/audit")
  public ResponseObject<Boolean> auditActivityProduct(
      @ModelAttribute PartnerActivityProductAudit form, String domain) {
    checkForm(form, domain);

    // 获取店铺,商品所属的活动信息
    ActivityTicket ticket =
        activityService.loadSubmittedTicket4Audit(form.getActId(), form.getProductId());
    if (ticket == null) {
      log.warn("活动 " + form.getActId() + " 商品 " + form.getProductId() + " 申请不存在,审核失败");
      return new ResponseObject<Boolean>(false);
    }

    auditAP(form, ticket, false);
    return new ResponseObject<Boolean>(true);
  }
  /** 再次审核 */
  @ResponseBody
  @RequestMapping("/partner/act/reAudit")
  public ResponseObject<Boolean> reAuditActivityProduct(
      @ModelAttribute PartnerActivityProductAudit form, String domain) {
    checkForm(form, domain);

    if (StringUtils.isEmpty(form.getTicketId()))
      throw new BizException(GlobalErrorCode.UNKNOWN, "活动不存在, 审核失败");

    ActivityTicket ticket = activityTicketMapper.selectByPrimaryKey(form.getTicketId());
    if (ticket == null) {
      log.warn("活动 " + form.getActId() + " 商品 " + form.getProductId() + " 申请不存在,审核失败");
      return new ResponseObject<Boolean>(false);
    }

    auditAP(form, ticket, true);
    return new ResponseObject<Boolean>(true);
  }
  private void auditAP(PartnerActivityProductAudit form, ActivityTicket ticket, boolean isReAudit) {
    // 已经结束了的活动不能再次审核
    if (ActivityStatus.CLOSED.equals(ticket.getStatus())) {
      log.warn("您要审核的活动" + form.getActId() + "商品 " + form.getProductId() + " 已经结束,不能审核");
      throw new BizException(GlobalErrorCode.UNKNOWN, "已经结束了的活动不能审核");
    }

    ActivityTicket newTicket = new ActivityTicket();
    BeanUtils.copyProperties(ticket, newTicket);
    newTicket.setAuditStatus(form.getAuditState());
    newTicket.setStartTime(form.getStartTime() != null ? new Date(form.getStartTime()) : null);
    newTicket.setEndTime(form.getEndTime() != null ? new Date(form.getEndTime()) : null);
    newTicket.setAuditReason(form.getAuditReason());
    newTicket.setAuditor(form.getAuditor());

    if (isReAudit) { // 再次审核
      // 获取报名信息
      if (StringUtils.isEmpty(form.getTicketId()))
        throw new BizException(GlobalErrorCode.UNKNOWN, "再次审核,活动商品id不能为空");
      ActivityTicket at = activityTicketMapper.selectByPrimaryKey(form.getTicketId());
      if (at == null) throw new BizException(GlobalErrorCode.UNKNOWN, "活动不存在, 再次审核失败");
      if (!at.getStatus().equals(ActivityStatus.NOT_STARTED))
        throw new BizException(GlobalErrorCode.UNKNOWN, "进行中或已关闭的活动不能再次审核");
      if (!ActivityTicketAuditStatus.APPROVED.equals(at.getAuditStatus())
          && !ActivityTicketAuditStatus.REJECTED.equals(at.getAuditStatus())) {
        throw new BizException(GlobalErrorCode.UNKNOWN, "只能重审未通过或已通过状态的活动商品");
      }
      newTicket.setAuditReason(
          StringUtils.isEmpty(form.getAuditReason()) ? at.getAuditReason() : form.getAuditReason());
      newTicket.setReason(at.getReason());
      activityTicketMapper.deleteByIds(at.getId()); // 重审直接删除后新增,保留才记录方便追踪
      newTicket.setId(null);
    }

    // 查询该商品是否已在同一时点的其他活动中有出现过
    if (ActivityTicketAuditStatus.APPROVED.equals(form.getAuditState())) {
      if (activityService.existProductInRange(
          newTicket.getStartTime(), newTicket.getEndTime(), null, form.getProductId())) {
        throw new BizException(
            GlobalErrorCode.INTERNAL_ERROR, "商品重复参与活动,ID:" + form.getProductId());
      }
    }

    activityService.insertTicket(newTicket);

    activityService.auditTicketProduct(
        newTicket.getId(),
        form.getActId(),
        ticket.getId(),
        form.getProductId(),
        form.getProductBrand(),
        form.getShortName(),
        form.getSort(),
        form.getImagePc(),
        form.getImageApp());
    // 拒绝活动申请--商品可以修改
    if (!isReAudit && form.getAuditState().equals(ActivityTicketAuditStatus.REJECTED)) {
      productService.lockProduct(form.getProductId(), false);
      campaignProductMapper.deleteActivityProducts(
          form.getActId(), newTicket.getId(), form.getProductId());
      List<CampaignProduct> list = campaignProductMapper.selectByTicket(ticket.getId());
      // 如果该活动再没有商品待审核直接删除该活动申请以便重新报名
      if (list == null
          || list.size() == 0
          || (list.size() == 1 && list.get(0).getProductId().equals(form.getProductId()))) {
        activityTicketMapper.deleteByIds(ticket.getId());
      }
    }
  }