Beispiel #1
0
 // 使用RewardFactory静态方法创建,如newCashierRechargeReward(int, int, int)
 public static RuleReward newInstance(
     RewardType rewardType, int maxRewards, int rewardsPerPerson) {
   RuleReward ruleReward = new RuleReward();
   ruleReward.setMaxRewards(Long.valueOf(maxRewards));
   ruleReward.setCurrentRewards(Long.valueOf(0));
   ruleReward.setRewardsPerPerson((short) rewardsPerPerson);
   ruleReward.setStatus(Constants.ON);
   ruleReward.setRewardType(rewardType);
   ruleReward.setRewardable(RewardFactory.newInstance(rewardType));
   ruleReward.setSituation(getRewardSituation(rewardType));
   return ruleReward;
 }
Beispiel #2
0
  public static RuleReward fromDTO(MRuleRewardDTO dto) {
    if (dto == null) {
      return null;
    }

    RuleReward data = new RuleReward();
    data.setId(dto.getId());
    data.setRuleId(dto.getRuleId());
    data.setRewardValue(dto.getRewardValue());
    data.setRewardProduct(dto.getRewardProduct());
    data.setRewardType(dto.getRewardType());
    data.setMaxRewards(dto.getMaxRewards());
    data.setCurrentRewards(dto.getCurrentRewards());
    data.setRewardsPerPerson(dto.getRewardsPerPerson());
    data.setStatus(dto.getStatus());
    data.setCreateUser(dto.getCreateUser());
    data.setCreateTimestamp(dto.getCreateTimestamp());
    data.setUpdateUser(dto.getUpdateUser());
    data.setUpdateTimestamp(dto.getUpdateTimestamp());

    RewardType theType = RewardType.valueOf(data.getRewardType());
    data.setRewardable(RewardFactory.newInstance(theType));
    data.setSituation(getRewardSituation(theType));
    return data;
  }