现金点券购买礼包

master_zzxx
grimm 2024-05-13 17:27:56 +08:00
parent 4da48e9d63
commit 1ccd8f470f
6 changed files with 90 additions and 17 deletions

View File

@ -184,6 +184,7 @@ public enum ErrorCode implements IErrorCode {
GUILD_NOT_AUTHORITY(300,"账号因错误发言导致相关功能封禁中,操作失败"),
RECHARGE_NUM_NOT(157,"充值金额不足"),
BEFORE_CONDITION_NOT(158,"前置条件不足"),
GOOD_INFO_NOT(180,"礼包不存在"),
ACCOUNT_ERROR(-104,"帐号异常,被封号"),
;
// private static final Set<Integer> CodeSet = new HashSet<>();

View File

@ -463,4 +463,5 @@ public interface BIReason {
int SOLDIER_DISMISS_REWARD = 1349;//小兵遣散获得
int SOLDIER_MIAN_LEVEL_REWARD = 1350;//小兵主线奖励
int COMPARE_NUM_GAME_REWARD = 1351;//比数小游戏挂机奖励
int MONEY_BUY_GOOD_COST = 1352;//现金点卷购买礼包消耗
}

View File

@ -0,0 +1,50 @@
package com.ljsd.jieling.handler.goods;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.exception.ErrorTableException;
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.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 MoneyBuyGiftHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MoneyBuyGiftRequest;
}
@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 || config.getOtherBuy1() == null || config.getOtherBuy1().length == 0){
throw new ErrorTableException(180);//礼包不存在
}
// 道具是否足够
boolean cost = ItemUtil.itemCost(user, config.getOtherBuy1(), BIReason.MONEY_BUY_GOOD_COST, 0);
if (!cost){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
// 走礼包逻辑发送奖励
BuyGoodsNewLogic.moneyBuyGoods(iSession, goodsId);
}
}

View File

@ -7,8 +7,6 @@ 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;
@ -50,18 +48,15 @@ public class VouchersBuyGiftHandler extends BaseHandler<PlayerInfoProto.GmBuyGoo
/**
*
* @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();
}
// 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();
// }
}

View File

@ -68,6 +68,7 @@ public class BuyGoodsNewLogic {
private static final String gm_modifier = "gm_modifier";
private static final String vouchers_order = "vouchers_order";
private static final String support_order = "support_order";
private static final String money_order = "money_order";
//获取充值总金额,结合前面的
public static double getAllAmount(User user){
@ -129,6 +130,19 @@ public class BuyGoodsNewLogic {
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.TEST_BUY_GIGT_GOODS_RESPONSE_VALUE,null,true);
}
/**
*
*/
public static void moneyBuyGoods(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()*100;
sendGoods(iSession.getUid(), String.valueOf(goodsId), "", money_order, TimeUtils.now(), price);
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.TEST_BUY_GIGT_GOODS_RESPONSE_VALUE,null,true);
}
/**
* gm
*/
@ -169,6 +183,13 @@ public class BuyGoodsNewLogic {
return !gm_modifier.equals(orderId) && !test_buy_order.equals(orderId) && !support_order.equals(orderId) && !vouchers_order.equals(orderId);
}
/**
*
*/
private static boolean isRechargeBuy(String orderId){
return !gm_modifier.equals(orderId) && !money_order.equals(orderId);
}
/**
*
*/
@ -234,7 +255,7 @@ public class BuyGoodsNewLogic {
}
// gm购买礼包不参与补助
int[][] gainCrystal = config.getGainCrystal();
if (!orderId.equals(gm_modifier) && gainCrystal != null && gainCrystal.length > 0){
if (isRechargeBuy(orderId) && gainCrystal != null && gainCrystal.length > 0){
list.add(gainCrystal);
}
//处理特权
@ -257,7 +278,7 @@ public class BuyGoodsNewLogic {
// 惊喜礼盒,事件推送
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),config.getId(),1,1));
// gm充值不进行单笔充值活动
if (!gm_modifier.equals(orderId)){
if (isRechargeBuy(orderId)){
// 单笔充值
Poster.getPoster().dispatchEvent(new SingleRechargeEvent(user.getId(),(int)price));
// 线下自动返利

View File

@ -17,6 +17,7 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
private int type;
private double price;
private int[][] otherBuy;
private int[][] OtherBuy1;
private int[][] firstMultiple;
private int[] continuedMultiple;
private int[][] baseReward;
@ -126,6 +127,10 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
return otherBuy;
}
public int[][] getOtherBuy1() {
return OtherBuy1;
}
public int getAccumulativeRecharge() { return accumulativeRecharge; }
public int getTime() { return time; }