龙珠限制礼包重复购买
parent
7263427cda
commit
09ba7b4492
|
|
@ -2,6 +2,7 @@ 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;
|
||||
|
|
@ -44,19 +45,18 @@ public class VouchersBuyGiftHandler extends BaseHandler<PlayerInfoProto.GmBuyGoo
|
|||
if (!cost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
if(!checkGoodStatus(user,goodsId,config)){
|
||||
throw new ErrorTableException(104,"礼包已购买");
|
||||
}
|
||||
// 走礼包逻辑发送奖励
|
||||
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());
|
||||
private static boolean checkGoodStatus(User user, int goodId,SRechargeCommodityNewConfig config){
|
||||
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(config.getOtype());
|
||||
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(goodId);
|
||||
if (bag == null){
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -184,19 +184,6 @@ public class BuyGoodsNewLogic {
|
|||
long now = TimeUtils.now();
|
||||
Result resultRes = new Result();
|
||||
resultRes.setResultCode(0);
|
||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
||||
if (session == null) {
|
||||
// Order order = new Order(uid, sdkGoodsId, openId, orderId, orderTime, amount);
|
||||
// String key = RedisKey.ANEW_RECHARGE_ORDER + ":" + uid;
|
||||
// RedisUtil.getInstence().putmap(key, order.getId(), order);
|
||||
// RedisUtil.getInstence().expireMills(key, TimeUtils.DAY * 30);
|
||||
// LOGGER.error("sendGoods 玩家不在缓存中,补单信息已放入redis缓存, uid={},order:{}",uid, order);
|
||||
//
|
||||
// resultRes.setResultCode(1);
|
||||
// resultRes.setResultMsg("Session is null");
|
||||
// return resultRes;
|
||||
LOGGER.error("玩家不在缓存中,uid={}", uid);
|
||||
}
|
||||
if (!StringUtil.isNumeric(sdkGoodsId)){
|
||||
LOGGER.error("sendGoods 参数错误, uid={}, sdkGoodsId={}",uid,sdkGoodsId);
|
||||
resultRes.setResultMsg("sdkGoodsId is error");
|
||||
|
|
@ -207,7 +194,6 @@ public class BuyGoodsNewLogic {
|
|||
resultRes.setResultMsg("SRechargeCommodityNewConfig is null");
|
||||
return resultRes;
|
||||
}
|
||||
|
||||
int goodsId = config.getId();
|
||||
// 支付金额用分
|
||||
double price = config.getPrice();
|
||||
|
|
@ -231,6 +217,23 @@ public class BuyGoodsNewLogic {
|
|||
resultRes.setResultMsg("Welfare bag not found");
|
||||
return resultRes;
|
||||
}
|
||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
||||
if (session == null) {
|
||||
Order order = new Order(uid, sdkGoodsId, openId, orderId, orderTime, amount);
|
||||
String key = RedisKey.ANEW_RECHARGE_ORDER + ":" + uid;
|
||||
RedisUtil.getInstence().putmap(key, order.getId(), order);
|
||||
RedisUtil.getInstence().expireMills(key, TimeUtils.DAY * 30);
|
||||
LOGGER.error("sendGoods 玩家不在缓存中,补单信息已放入redis缓存, uid={},order:{}",uid, order);
|
||||
|
||||
resultRes.setResultCode(1);
|
||||
resultRes.setResultMsg("Session is null");
|
||||
return resultRes;
|
||||
}
|
||||
if(!bag.isBuy()){
|
||||
resultRes.setResultMsg("bag limit");
|
||||
LOGGER.error("sendGoods 礼包已购买, uid={}, goodId={}",uid, goodsId);
|
||||
return resultRes;
|
||||
}
|
||||
|
||||
// 礼包购买
|
||||
bag.buy();
|
||||
|
|
|
|||
Loading…
Reference in New Issue