|
|
@@ -3,6 +3,8 @@ package com.ljsd.jieling.logic.family;
|
|
|
import com.google.protobuf.GeneratedMessage;
|
|
|
import com.ljsd.GameApplication;
|
|
|
import com.ljsd.jieling.core.GlobalsDef;
|
|
|
+import com.ljsd.jieling.core.Lockeys;
|
|
|
+import com.ljsd.jieling.core.SimpleTransaction;
|
|
|
import com.ljsd.jieling.core.VipPrivilegeType;
|
|
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
|
|
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
|
|
@@ -53,7 +55,8 @@ public class GuildLogic {
|
|
|
}
|
|
|
|
|
|
public void flushEveryDay(User user, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder) throws Exception {
|
|
|
- takeAllReward(user);
|
|
|
+// takeAllReward(user);
|
|
|
+ refreshAndTakeAllReward(user);
|
|
|
// 发送公会援助奖励
|
|
|
// sendGuildHelpRewardEmail(user);
|
|
|
|
|
|
@@ -73,6 +76,98 @@ public class GuildLogic {
|
|
|
//
|
|
|
}
|
|
|
|
|
|
+ void refreshAndTakeAllReward(User user) throws Exception {
|
|
|
+ try {
|
|
|
+ int guildId = user.getPlayerInfoManager().getGuildId();
|
|
|
+ if (guildId == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
|
|
+
|
|
|
+ if (!TimeUtils.isOverTime(0, guildInfo.getLastRefreshTime())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ long now = TimeUtils.now();
|
|
|
+
|
|
|
+ List<int[][]> itemArrs = new LinkedList<>();
|
|
|
+ //补发前日未领取的祭祀奖
|
|
|
+ Map<Integer, SGuildSacrificeRewardConfig> config = STableManager.getConfig(SGuildSacrificeRewardConfig.class);
|
|
|
+ if (null == config) {
|
|
|
+ throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
|
|
+ }
|
|
|
+ RedisUtil.getInstence().del(RedisKey.getKey(RedisKey.GUILD_RED_PACKAGE_RANK, String.valueOf(guildId), false));
|
|
|
+
|
|
|
+ for (Set<Integer> items : guildInfo.getMembers().values()) {
|
|
|
+ for (Integer uid : items) {
|
|
|
+ User target = UserManager.getUser(uid);
|
|
|
+ int gId = target.getPlayerInfoManager().getGuildId();
|
|
|
+ if (gId == -1) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //check 最近一次公会id
|
|
|
+ if (target.getGuildMyInfo().getFeteguild() != guildId) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Integer> objects = new HashSet<>(config.keySet());
|
|
|
+ objects.removeAll(target.getGuildMyInfo().getHadTakeReward());
|
|
|
+
|
|
|
+ for (Integer missionId : objects) {
|
|
|
+ //checkAndUpdate cfg
|
|
|
+ SGuildSacrificeRewardConfig sGuildSacrificeRewardConfig = config.get(missionId);
|
|
|
+
|
|
|
+ //take rewards checkAndUpdate
|
|
|
+ int fete = guildInfo.getFete();
|
|
|
+ if (sGuildSacrificeRewardConfig.getScore() > fete) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //up miss
|
|
|
+ int[][] reward = sGuildSacrificeRewardConfig.getReward();
|
|
|
+ itemArrs.add(reward);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (itemArrs.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String title = SErrorCodeEerverConfig.getI18NMessage("guildsacrifice_reward_title");
|
|
|
+ String content = SErrorCodeEerverConfig.getI18NMessage("guildsacrifice_reward_txt");
|
|
|
+ String mailReward = ItemUtil.getMailReward(itemArrs);
|
|
|
+ int nowTime = (int) (now / 999);
|
|
|
+ MailLogic.getInstance().sendMail(target.getId(), title, content, mailReward, nowTime, Global.MAIL_EFFECTIVE_TIME);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ guildInfo.reSetFete();
|
|
|
+ guildInfo.setLastRefreshTime(now);
|
|
|
+
|
|
|
+ SimpleTransaction transaction = SimpleTransaction.current();
|
|
|
+ Set<Integer> sendUids = new HashSet<>();
|
|
|
+ for (Set<Integer> items : guildInfo.getMembers().values()) {
|
|
|
+ sendUids.addAll(items);
|
|
|
+ }
|
|
|
+ Lockeys.getLockeys().lock("guild", sendUids);
|
|
|
+ guildInfo.clearGuildHelpLog();
|
|
|
+
|
|
|
+ //统一清除
|
|
|
+ for (Integer sendUid : sendUids) {
|
|
|
+ User target = UserManager.getUser(sendUid);
|
|
|
+ GuildLogic.sendGuildHelpRewardEmail(target);
|
|
|
+ GuildMyInfo guildMyInfo = target.getGuildMyInfo();
|
|
|
+ guildMyInfo.setGuidHelpInfo(new HashMap<>());
|
|
|
+ guildMyInfo.setGuidHelpHadTakeInfo(new HashMap<>());
|
|
|
+ guildMyInfo.setGuildHelpSendTime(0);
|
|
|
+ guildMyInfo.setGuildHelpReward(false);
|
|
|
+ guildMyInfo.setGuildHelpTime(0);
|
|
|
+ }
|
|
|
+ SimpleTransaction.remove();
|
|
|
+ //处理公会援助信息
|
|
|
+
|
|
|
+ //入库
|
|
|
+ MongoUtil.getInstence().lastUpdate();
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.error("Exception refreshAndTakeAllReward");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
void takeAllReward(User user) throws Exception {
|
|
|
|