全民福利活动修改
parent
05243c0cb9
commit
8d786bb5e1
|
@ -94,7 +94,7 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
// 参数初始化
|
||||
int missionId = entry.getKey();
|
||||
int value = getValue(entry.getValue().getRechargeCom());
|
||||
int state = getState(progressInfoMap.get(missionId));
|
||||
int state = getState(missionId, progressInfoMap.get(missionId));
|
||||
// 封装proto并返回
|
||||
CommonProto.ActivityInfo.MissionInfo build = CommonProto.ActivityInfo.MissionInfo.newBuilder()
|
||||
.setMissionId(missionId)
|
||||
|
@ -111,10 +111,14 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
* @param progressInfo
|
||||
* @return
|
||||
*/
|
||||
private int getState(ActivityProgressInfo progressInfo){
|
||||
private int getState(int missionId, ActivityProgressInfo progressInfo){
|
||||
int state = 0;
|
||||
if (progressInfo != null && progressInfo.getState() == ActivityType.HAD_TAKED){
|
||||
state = ActivityType.HAD_TAKED;
|
||||
SUniversalWelfareConfig welfareConfig = STableManager.getConfig(SUniversalWelfareConfig.class).get(missionId);
|
||||
if (progressInfo != null && progressInfo.getState() == 2){
|
||||
state = 2;
|
||||
}
|
||||
else if (getValue(welfareConfig.getRechargeCom()) >= welfareConfig.getPeolple()){
|
||||
state = 1;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -136,21 +140,17 @@ public class AllPeopleWelfareActivity extends AbstractActivity {
|
|||
}
|
||||
SUniversalWelfareConfig welfareConfig = STableManager.getConfig(SUniversalWelfareConfig.class).get(missionId);
|
||||
if (welfareConfig == null){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"领取挡位不存在,活动id ==> 挡位id:"+id+"==>"+missionId);
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"领取挡位不存在,活动id ==> "+id+",挡位id==>"+missionId);
|
||||
}
|
||||
ActivityProgressInfo progressInfo = mission.getActivityMissionMap().get(missionId);
|
||||
if (progressInfo != null && progressInfo.getState() == ActivityType.HAD_TAKED){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"档位已领取,活动id ==> 挡位id:"+id+"==>"+missionId);
|
||||
}
|
||||
int value = getValue(welfareConfig.getRechargeCom());
|
||||
if (value < welfareConfig.getPeolple()){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"条件不满足,活动id ==> 挡位id ==> 当前数量:"+id+"==>"+missionId+"==>"+value);
|
||||
int state = getState(missionId, mission.getActivityMissionMap().get(missionId));
|
||||
if (state != 1){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"档位已领取或条件不满足,活动id ==> "+id+",挡位id ==>"+missionId);
|
||||
}
|
||||
// reward
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, welfareConfig.getType(), BIReason.TAKE_ACTIVITY_REWARD);
|
||||
// 更新数据库
|
||||
ActivityProgressInfo info = new ActivityProgressInfo();
|
||||
info.setState(ActivityType.HAD_TAKED);
|
||||
info.setState(2);
|
||||
mission.getActivityMissionMap().put(missionId,info);
|
||||
|
||||
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
|
||||
|
|
Loading…
Reference in New Issue