代金卷购买
parent
ecafe44bfb
commit
9baf7f486e
|
@ -30,6 +30,9 @@ public class MongoRechargeConverter implements Converter<BasicDBObject, Abstract
|
|||
if(config.getOtype()==RechargeType.push.getType()){
|
||||
target = PushWelfareBag.class;
|
||||
}
|
||||
if(config.getOtype()==RechargeType.gmSingle.getType()){
|
||||
target = GmSingleWelfareBag.class;
|
||||
}
|
||||
}
|
||||
String s = gson.toJson(source);
|
||||
return JSON.parseObject(s, target);
|
||||
|
|
|
@ -436,4 +436,6 @@ public interface BIReason {
|
|||
int MAGIC_SOLDIER_RETURN_GET = 1327;//神兵涅槃获得
|
||||
int MAGIC_SOLDIER_UP_LEVEL_COST = 1328;//神兵升级消耗
|
||||
int MAGIC_SOLDIER_UP_STAR_COST = 1329;//神兵升星消耗
|
||||
|
||||
int VOUCHERS_BUY_GOOD_COST = 1330;//代金卷购买礼包消耗
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.ljsd.jieling.handler.bt;
|
||||
package com.ljsd.jieling.handler.goods;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
|
@ -0,0 +1,67 @@
|
|||
package com.ljsd.jieling.handler.goods;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.bean.AbstractWelfareBag;
|
||||
import com.ljsd.jieling.logic.store.newRechargeInfo.rechargeHandler.RechargeHandler;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import config.SRechargeCommodityNewConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
* @Date 2021/6/8 15:40
|
||||
* @Description: 代金卷购买物品
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class VouchersBuyGiftHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodRequest> {
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.VouchersBuyGiftRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.GmBuyGoodRequest proto) throws Exception {
|
||||
// 用户信息
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
int goodsId = proto.getGoodsId();
|
||||
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(goodsId);
|
||||
if (config == null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL,"礼包id不存在:"+goodsId);
|
||||
}
|
||||
// 道具是否足够
|
||||
boolean cost = ItemUtil.itemCost(user, config.getOtherBuy(), BIReason.VOUCHERS_BUY_GOOD_COST, 0);
|
||||
if (!cost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
// 走礼包逻辑发送奖励
|
||||
BuyGoodsNewLogic.vouchersBuyGoods(iSession, goodsId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证礼包是否购买
|
||||
* @param user
|
||||
* @param goodId
|
||||
* @return
|
||||
*/
|
||||
private static boolean checkGoodStatus(User user, int goodId){
|
||||
SRechargeCommodityNewConfig recharge = SRechargeCommodityNewConfig.getConfigById(goodId);
|
||||
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(recharge.getOtype());
|
||||
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(goodId);
|
||||
if (bag == null){
|
||||
return false;
|
||||
}
|
||||
// 是否可买
|
||||
return bag.isBuy();
|
||||
}
|
||||
}
|
|
@ -457,16 +457,13 @@ public class GlobalDataManaager implements IManager {
|
|||
Map<Integer, SDailyTasksConfig> config = SDailyTasksConfig.config;
|
||||
int dailymissionType = GameMisionType.DAILYMISSION.getType();
|
||||
int day = TimeUtils.getDayOfPeriod(GameApplication.serverConfig.getCacheOpenTime(),Calendar.DAY_OF_MONTH);//当月第几天
|
||||
boolean refreshStype = false;
|
||||
if(TimeUtils.isSameMonth2(GameApplication.serverConfig.getCacheOpenTime(),TimeUtils.now())){
|
||||
refreshStype = true;
|
||||
}
|
||||
boolean refreshStype = TimeUtils.isSameMonth2(GameApplication.serverConfig.getCacheOpenTime(), TimeUtils.now());
|
||||
for(SDailyTasksConfig sDailyTasksConfig:config.values()){
|
||||
if(refreshStype){
|
||||
if(day >= sDailyTasksConfig.getViewDateUp()&& day <=sDailyTasksConfig.getViewDataDown()){
|
||||
if(refreshStype && day >= sDailyTasksConfig.getViewDateUp() && day <=sDailyTasksConfig.getViewDataDown()){
|
||||
if(day >= sDailyTasksConfig.getViewDateUp() && day <=sDailyTasksConfig.getViewDataDown()){
|
||||
fBuilder.addUserMissionInfo(CommonProto.UserMissionInfo.newBuilder().setMissionId(sDailyTasksConfig.getId()).setState(0).setType(dailymissionType).setProgress(0));
|
||||
}
|
||||
}else{
|
||||
}else if(sDailyTasksConfig.getViewDateUp() == 1){
|
||||
if(sDailyTasksConfig.getViewDateUp() == 1){
|
||||
fBuilder.addUserMissionInfo(CommonProto.UserMissionInfo.newBuilder().setMissionId(sDailyTasksConfig.getId()).setState(0).setType(dailymissionType).setProgress(0));
|
||||
}
|
||||
|
@ -494,8 +491,6 @@ public class GlobalDataManaager implements IManager {
|
|||
user.getUserMissionManager().onGameEvent(user, GameEvent.LOGIN_GAME,0);
|
||||
// 惊喜礼盒,超值基金,零点逻辑(可以同用一个状态)
|
||||
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),SuperBoxEvent.zero_init));
|
||||
// 心愿格子信息刷新
|
||||
// HeroLogic.getInstance().resetWishDrawCardInfoMap(user);
|
||||
//玉虚论道每日刷新
|
||||
user.getArenaManager().setCrossYuxulundaoDailyRewad(new ArrayList<>(Arrays.asList(0,0,0)));
|
||||
//终身卡在线跨天
|
||||
|
|
|
@ -87,7 +87,7 @@ class NewRechargeSumDayActivity extends AbstractActivity {
|
|||
}
|
||||
ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id);
|
||||
// 表示已购买今天的礼包
|
||||
if (mission.getV() == 1){
|
||||
if (mission == null || mission.getV() == 1){
|
||||
return;
|
||||
}
|
||||
List<SActivityRewardConfig> rewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
|
||||
|
|
|
@ -237,7 +237,7 @@ public class GmActivityLogic implements IEventHandler {
|
|||
// 领取完全部奖励后重置活动
|
||||
long count = gmActivity.getMissionMap().values().stream().filter(v -> v.getState() == 1).count();
|
||||
LOGGER.info("单日累充,第二步,userid:{}, 活动id:{}, 完成度对比:{}-{}", user.getId(),gmActivity.getId(),gmMissionList.size(),count);
|
||||
if (gmMissionList.size() == count){
|
||||
if (count > 0 && gmMissionList.size() == count){
|
||||
// 重置活动对象
|
||||
gmActivity.setMissionMap(new HashMap<>());
|
||||
// 减去满级金额
|
||||
|
|
|
@ -65,6 +65,7 @@ public class BuyGoodsNewLogic {
|
|||
|
||||
private static final String test_buy_order = "test_buy_order";
|
||||
private static final String gm_modifier = "gm_modifier";
|
||||
private static final String vouchers_order = "vouchers_order";
|
||||
private static final String support_order = "support_order";
|
||||
|
||||
//获取充值总金额,结合前面的
|
||||
|
@ -77,12 +78,6 @@ public class BuyGoodsNewLogic {
|
|||
* 登录刷新礼包
|
||||
*/
|
||||
public static boolean refreshWelfareState(User user) throws Exception {
|
||||
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
if(info == null){
|
||||
info = new NewRechargeInfo();
|
||||
user.getPlayerInfoManager().setNewRechargeInfo(info);
|
||||
}
|
||||
dailyRefresh(user);
|
||||
boolean needChange = false;
|
||||
for(Map.Entry<Integer,SRechargeCommodityNewConfig> entry : SRechargeCommodityNewConfig.configMap.entrySet()){
|
||||
SRechargeCommodityNewConfig config = entry.getValue();
|
||||
|
@ -118,7 +113,23 @@ public class BuyGoodsNewLogic {
|
|||
}
|
||||
|
||||
/**
|
||||
* gm修改器购买物品
|
||||
* 代金卷修改器购买物品
|
||||
* @param iSession
|
||||
* @param goodsId
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void vouchersBuyGoods(ISession iSession, int goodsId) throws Exception {
|
||||
SRechargeCommodityNewConfig sRechargeCommodityConfig = SRechargeCommodityNewConfig.getConfigById(goodsId);
|
||||
if(sRechargeCommodityConfig == null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
int price = (int)sRechargeCommodityConfig.getPrice();
|
||||
sendGoods(iSession.getUid(), String.valueOf(goodsId), "", vouchers_order, TimeUtils.now(), price);
|
||||
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.TEST_BUY_GIGT_GOODS_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* gm代金卷购买物品
|
||||
* @param iSession
|
||||
* @param goodsId
|
||||
* @throws Exception
|
||||
|
@ -162,7 +173,7 @@ public class BuyGoodsNewLogic {
|
|||
* @return
|
||||
*/
|
||||
private static boolean isRmbBuy(String orderId){
|
||||
return !gm_modifier.equals(orderId) && !test_buy_order.equals(orderId) && !support_order.equals(orderId);
|
||||
return !gm_modifier.equals(orderId) && !test_buy_order.equals(orderId) && !support_order.equals(orderId) && !vouchers_order.equals(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,7 +252,6 @@ public class BuyGoodsNewLogic {
|
|||
changeActivity(user,price,info);
|
||||
}
|
||||
|
||||
// todo 可以放到redis 首充标记
|
||||
if(getFirstRechargeTime(uid) == 0){
|
||||
setFirstRecharge(uid);
|
||||
}
|
||||
|
@ -648,7 +658,7 @@ public class BuyGoodsNewLogic {
|
|||
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
|
||||
AbstractWelfareBag bag = rechargeHandler.getBag(user, config.getId());
|
||||
if (bag == null){
|
||||
result = true;
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
result = bag.getBuyTimes() >= 1;
|
||||
|
@ -678,6 +688,8 @@ public class BuyGoodsNewLogic {
|
|||
list.addAll(rechargeInfo.getReceiveMap().values());
|
||||
// 推送礼包
|
||||
list.addAll(rechargeInfo.getPushMap().values());
|
||||
// gm礼包
|
||||
list.addAll(rechargeInfo.getGmSingleMap().values());
|
||||
|
||||
for(AbstractWelfareBag bag : list){
|
||||
if(bag.isOpen()){
|
||||
|
@ -819,9 +831,16 @@ public class BuyGoodsNewLogic {
|
|||
builder.setBuyTimes(bag.getBuyTimes());
|
||||
builder.setStartTime((int)(bag.getStartTime()/1000));
|
||||
builder.setEndTime((int)(bag.getEndTime()/1000));
|
||||
builder.setDynamicBuyTimes(1);
|
||||
if(bag.getLimit() != 0){
|
||||
builder.setDynamicBuyTimes(bag.getLimit() - bag.getBuyTimes());
|
||||
|
||||
int limit = bag.getLimit();
|
||||
if(limit != 0){
|
||||
builder.setDynamicBuyTimes(limit-bag.getBuyTimes());
|
||||
}else {
|
||||
builder.setDynamicBuyTimes(1);
|
||||
}
|
||||
|
||||
if (bag.getType() == RechargeType.push.getType() && builder.getDynamicBuyTimes() <= 0){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(bag.getType() == RechargeType.perpetual.getType() && bag.getRefreshTime() > 0){
|
||||
|
@ -832,24 +851,15 @@ public class BuyGoodsNewLogic {
|
|||
}
|
||||
}
|
||||
|
||||
if(bag.getType() == RechargeType.receive.getType() && bag.getEndTime() == 0){
|
||||
builder.setEndTime((int)((bag.getStartTime() + bag.getContinueDays() * TimeUtils.DAY)/1000));
|
||||
}
|
||||
|
||||
// 礼包类型特殊处理,使用bought字段验证是否购买
|
||||
if(bag.getType() == RechargeType.receive.getType()){
|
||||
if (bag.getEndTime() == 0){
|
||||
builder.setEndTime((int)((bag.getStartTime() + bag.getContinueDays() * TimeUtils.DAY)/1000));
|
||||
}
|
||||
ReceiveWelfareBag receiveBag = (ReceiveWelfareBag) bag;
|
||||
int bought = receiveBag.isBought()?1:0;
|
||||
builder.setIsBought(bought);
|
||||
}
|
||||
|
||||
if (bag.getType() == RechargeType.push.getType() && builder.getDynamicBuyTimes() <= 0){
|
||||
return null;
|
||||
}
|
||||
|
||||
if (bag.getType() == RechargeType.gmSingle.getType()){
|
||||
builder.setStartTime(0);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -987,14 +997,6 @@ public class BuyGoodsNewLogic {
|
|||
return list;
|
||||
}
|
||||
|
||||
private static void dailyRefresh(User user){
|
||||
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
long now = TimeUtils.now();
|
||||
if(TimeUtils.differentDays(info.getLastRefreshTime(), now) >= 1){
|
||||
info.setLastRefreshTime(now);
|
||||
}
|
||||
}
|
||||
|
||||
//是否属于五星成长礼
|
||||
// public static boolean isFiveStarBag(int id){
|
||||
// return id == 21 || (id >= 400 && id <= 402) || (id >= 7300 && id <= 7304) || (id >= 1100 && id <= 1104);
|
||||
|
|
|
@ -22,13 +22,10 @@ public class NewRechargeInfo extends MongoBase {
|
|||
private Map<Integer, AbstractWelfareBag> receiveMap = new HashMap<>();//限时刷新礼包
|
||||
private Map<Integer, AbstractWelfareBag> pushMap = new HashMap<>();//推送礼包
|
||||
private Map<Integer, AbstractWelfareBag> gmSingleMap = new HashMap<>();//gm单笔礼包
|
||||
|
||||
private long nextPushTime; //上次推送时间
|
||||
private Map<Integer,Long>typePushTimeMap=new HashMap<>();//记录推送条件类型cd时间
|
||||
private Map<Integer,Integer> dayPushNumMap =new HashMap<>();//记录当天推送次数
|
||||
private Map<Integer,Integer> allPushNumMap =new HashMap<>();//记录历史推送次数
|
||||
|
||||
private long lastRefreshTime;
|
||||
public static int FIVESTARLIMIT = 2;//临时五星成长礼每天最多两次
|
||||
|
||||
public boolean checkOneGoodsIsOverTimeByPrivilege(int privilegeId){
|
||||
|
@ -248,15 +245,6 @@ public class NewRechargeInfo extends MongoBase {
|
|||
updateString("allPushNumMap."+pushId,pushNum);
|
||||
}
|
||||
|
||||
public long getLastRefreshTime() {
|
||||
return lastRefreshTime;
|
||||
}
|
||||
|
||||
public void setLastRefreshTime(long lastRefreshTime) {
|
||||
this.lastRefreshTime = lastRefreshTime;
|
||||
updateString("lastRefreshTime",lastRefreshTime);
|
||||
}
|
||||
|
||||
public void setRechargeList(long _rechargeTime,double _rechargePrice) {
|
||||
this.rechargeList.put(_rechargeTime,_rechargePrice);
|
||||
updateString("rechargeList",this.rechargeList);
|
||||
|
|
|
@ -20,6 +20,9 @@ public abstract class AbstractRechargeHandler implements RechargeHandler {
|
|||
//判断刷新时间
|
||||
long now = TimeUtils.now();
|
||||
AbstractWelfareBag bag = getBag(user, rechargeId);
|
||||
if (bag == null){
|
||||
return false;
|
||||
}
|
||||
if(bag.getRefreshTime() != 0 && bag.getRefreshTime() < now){
|
||||
bag.refresh();
|
||||
return true;
|
||||
|
|
|
@ -42,10 +42,6 @@ public class GmSingleHandler extends AbstractRechargeHandler {
|
|||
return user.getPlayerInfoManager().getNewRechargeInfo().getGmSingleMap();
|
||||
}
|
||||
|
||||
public boolean rechargeIsInBag(User user, int rechargeId) {
|
||||
return getRechargeMap(user).containsKey(rechargeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractWelfareBag initUnitWF(User user, SRechargeCommodityNewConfig config) {
|
||||
Map<Integer, List<Integer>> singleIdMap = user.getGmActivityManager().getGmSingleIdMap();
|
||||
|
|
|
@ -12,14 +12,11 @@ import java.util.Map;
|
|||
public class SRechargeCommodityNewConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private String rechargeId;
|
||||
|
||||
private String name;
|
||||
|
||||
private int type;
|
||||
|
||||
private double price;
|
||||
private int[][] otherBuy;
|
||||
private int[][] firstMultiple;
|
||||
private int[] continuedMultiple;
|
||||
private int[][] baseReward;
|
||||
|
@ -125,6 +122,10 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
|
|||
|
||||
public int getFirstInvest() { return firstInvest; }
|
||||
|
||||
public int[][] getOtherBuy() {
|
||||
return otherBuy;
|
||||
}
|
||||
|
||||
public int getAccumulativeRecharge() { return accumulativeRecharge; }
|
||||
|
||||
public int getTime() { return time; }
|
||||
|
|
Loading…
Reference in New Issue