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, "您没有权限审核该活动"); } }
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()); } } }