コード例 #1
0
  public String updateSendStatus() {
    if (IDUtils.isNotCorrect(id)) {
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.promotion.award.id.required");
      return SUCCESS;
    }

    DcPromotionAwardSendStatusEnums statusEnums =
        DcPromotionAwardSendStatusEnums.getInstance(status);

    if (statusEnums == DcPromotionAwardSendStatusEnums.UNKNOWN) {
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.promotion.award.status.required");
      return SUCCESS;
    }

    try {
      int effectCount = dcPromotionAwardService.updateSendStatusById(id, statusEnums);
      if (effectCount > 0) {}

      json.setCode(JsonModel.CODE_SUCCESS);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      json.setCode(JsonModel.CODE_FAIL);
      json.setDetail(e.getMessage());
    }

    return SUCCESS;
  }
コード例 #2
0
  /**
   * 更新审核状态
   *
   * @return
   */
  public String updateReviewStatus() {

    if (IDUtils.isNotCorrect(id)) {
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.promotion.award.id.required");
      return SUCCESS;
    }

    DcPromotionAwardReviewStatusEnums statusEnums =
        DcPromotionAwardReviewStatusEnums.getInstance(status);

    if (statusEnums == DcPromotionAwardReviewStatusEnums.UNKNOWN) {
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.promotion.award.status.required");
      return SUCCESS;
    }
    try {
      int effectCount = dcPromotionAwardService.updateReviewStatusById(id, statusEnums);
      if (effectCount > 0) {
        // 更新该会员的未读消息
        DcPromotionAwardDTO awardDO = dcPromotionAwardService.getAwardById(id);
        if (awardDO != null) {
          Long userId = awardDO.getUserId();
          if (IDUtils.isCorrect(userId)) {
            dcUserService.incrUnreadMsgCountByUser(userId, 1); // 添加一条未读消息
          }
        }
      }
      json.setCode(JsonModel.CODE_SUCCESS);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      json.setCode(JsonModel.CODE_FAIL);
      json.setDetail(e.getMessage());
    }

    return SUCCESS;
  }
コード例 #3
0
  @Override
  public String execute() throws Exception {

    DcUserDTO user = dcAuthz.getUser();

    if (user == null) {
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.user.notLogin");
      return SUCCESS;
    }

    Long userId = user.getUserId();

    List<DcWinnerGameConfigDTO> configList = dcWinnerGameConfigService.getConfigs();

    // 没有配置
    if (CollectionUtils.isEmpty(configList)) {
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.winner.config.error");
      return SUCCESS;
    }

    // 今天是不是已经玩了太多次 ,每天最多玩10次// TODO 需要优化。目前是直接COUNT
    if (!dcUserFilterService.isWhiteListUser(userId)) {
      int todayPlayCount = dcWinnerGamePlayDetailService.countTodayPlayDetaiByUser(userId);

      if (todayPlayCount > 10) {
        json.setCode(JsonModel.CODE_ILL_ARGS);
        json.setDetail("dcome.winner.play.limit");
        return SUCCESS;
      }
    }

    List<KeyValuePair> betParamList = DcWinnerGameUtils.parseBetParam(betParam);
    if (CollectionUtils.isEmpty(betParamList)) {
      // 没有下注
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.winner.config.betParam.error");
      return SUCCESS;
    }

    // 计算要消耗多少积分
    int needIntegralCount = DcWinnerGameUtils.calcIntegral(betParamList);

    try {

      // 生成随机数
      int randomNum = RandomUtils.nextInt(new Random(System.currentTimeMillis()), 10000);

      DcWinnerGameConfigParser configParser = new DcWinnerGameConfigParser(configList);

      DcWinnerGameConfigDTO winConfig = configParser.win(randomNum);

      if (winConfig == null) {
        json.setCode(JsonModel.CODE_ILL_ARGS);
        json.setDetail("dcome.winner.config.error");
        return SUCCESS;
      }

      // 把分数加到积分
      dcUserService.updateWinnerScoreToIntegralByUser(userId);

      // kou扣除积分
      int comsumeIntegral = dcUserIntegralBO.doWinnerGame(userId, -needIntegralCount);

      DcWinnerGameResultModel resultModel = new DcWinnerGameResultModel();
      resultModel.setBetParamList(betParamList);
      resultModel.setWinCardName(winConfig.getCardName());
      resultModel.setWinCardScore(winConfig.getScore());

      int totalScore = DcWinnerGameUtils.calcTotalWinScore(betParamList, winConfig);

      dcUserService.incrWinnerScoreByUser(userId, totalScore);

      resultModel.setWinScore(totalScore);

      DcUserDTO userdto = dcUserService.getUser(userId);
      int integral = userdto.getIntegralCount();
      resultModel.setUserIntegralCount(integral);

      // 插入detail
      DcWinnerGamePlayDetailDO detail = new DcWinnerGamePlayDetailDO();
      detail.setBetParam(JacksonHelper.toJSON(betParamList));
      detail.setUserId(userId);
      detail.setUserNick(user.getNick());
      detail.setWinScore(totalScore);
      detail.setResult(JacksonHelper.toJSON(resultModel));
      detail.setBetIntegral(Math.abs(comsumeIntegral));
      dcWinnerGamePlayDetailService.insertPlayDetail(detail);

      json.setCode(JsonModel.CODE_SUCCESS);
      json.setData(resultModel);

    } catch (IntegralNotEnoughException e) {
      // 积分不足
      json.setCode(JsonModel.CODE_ILL_ARGS);
      json.setDetail("dcome.winner.user.integral.notEnough");
      return SUCCESS;
    } catch (Exception e) {
      json.setCode(JsonModel.CODE_FAIL);
      return SUCCESS;
    }

    return SUCCESS;
  }