礼包逻辑修改

master_haizei
grimm 2024-05-06 16:14:46 +08:00
parent 0ed2ab4036
commit b760741462
1 changed files with 34 additions and 29 deletions

View File

@ -12,8 +12,6 @@ import com.ljsd.jieling.exception.ErrorTableException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.AbstractActivity;
@ -184,18 +182,22 @@ public class BuyGoodsNewLogic {
*
*/
public static Result sendGoods(int uid, String sdkGoodsId, String openId, String orderId, long orderTime, int amount) throws Exception {
LOGGER.info("sendGoods to uid={},the goods={},openID={},orderId={},orderTime={},amount={}",uid,sdkGoodsId,openId,orderId,orderTime,amount);
long now = TimeUtils.now();
Result resultRes = new Result();
resultRes.setResultCode(0);
ISession session = OnlineUserManager.getSessionByUid(uid);
LOGGER.info("sendGoods to uid={},the goods={},openID={},orderId={},orderTime={},amount={}",uid,sdkGoodsId,openId,orderId,orderTime,amount);
if (session == null) {
resultRes.setResultMsg("Session is null");
return resultRes;
}
if (!StringUtil.isNumeric(sdkGoodsId)){
resultRes.setResultMsg("sdkGoodsId is error");
return resultRes;
}
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.configMap.get(Integer.parseInt(sdkGoodsId));
if(null == config){
resultRes.setResultMsg("good config null");
LOGGER.error("sendGoods the uid={},the goodId={},购买的礼包为空",uid,sdkGoodsId);
resultRes.setResultMsg("SRechargeCommodityNewConfig is null");
return resultRes;
}
@ -205,17 +207,26 @@ public class BuyGoodsNewLogic {
// int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
// double price = priceTemp==0?0: SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
if(amount != price*100){
resultRes.setResultMsg("charge price error");
LOGGER.error("sendGoods 金额校验失败, uid={},the goodId={}, currentPrice={},realPrice={}",uid,goodsId, amount,price);
resultRes.setResultMsg("compared amount fail");
LOGGER.error("sendGoods 金额校验失败, uid={}, goodId={}, amount={}, price={}",uid,goodsId, amount, price*100);
return resultRes;
}
User user = UserManager.getUser(uid);
if (user == null) {
resultRes.setResultMsg("User not found");
return resultRes;
}
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
AbstractWelfareBag bag = rechargeHandler.getBag(user, goodsId);
if (bag == null) {
resultRes.setResultMsg("Welfare bag not found");
return resultRes;
}
// 礼包购买
bag.buy();
int[] forbid = config.getForbid();
if(forbid != null){
//每日礼包一键购买之后,把所有单个的每日礼包的购买次数加一
@ -225,19 +236,16 @@ public class BuyGoodsNewLogic {
}
List<int[][]> list = bag.getDropByBag();
int[][] gainFame = config.getGainFame();
// 购买礼包额外补助
int[][] gainFame = config.getGainFame();
if (gainFame != null && gainFame.length > 0){
list.add(gainFame);
}
// gm购买礼包不参与补助
if (!orderId.equals(gm_modifier)){
int[][] gainCrystal = config.getGainCrystal();
if (gainCrystal != null && gainCrystal.length > 0){
list.add(gainCrystal);
}
int[][] gainCrystal = config.getGainCrystal();
if (!orderId.equals(gm_modifier) && gainCrystal != null && gainCrystal.length > 0){
list.add(gainCrystal);
}
//处理特权
activePrivilege(user,config);
// 校验
@ -248,16 +256,13 @@ public class BuyGoodsNewLogic {
//活动
changeActivity(user,price,info);
}
if(getFirstRechargeTime(uid) == 0){
setFirstRecharge(uid);
}
// 全部礼包状态推送
sendGiftGoodsWithoutJudge(uid);
// 推送礼包
openPush(session,user, PushRechargeType.point_recharge.getType(),goodsId);
// 惊喜礼盒,事件推送
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),config.getId(),1,1));
// gm充值不进行单笔充值活动
@ -267,32 +272,28 @@ public class BuyGoodsNewLogic {
// 线下自动返利
Poster.getPoster().dispatchEvent(new AutoRechargeBackEvent(user.getId(),goodsId,orderId));
}
// 发货
sendGoodsByType(user,config,list);
// 通知前端
notifyPaySuccessFul(uid,goodsId,amount != -999);
//发送邮件
int[] mail = config.getMail();
if(config.getPrice()!=0&&mail!=null&&mail.length>1){
if(config.getPrice() != 0 && mail != null && mail.length >= 2){
String title = SErrorCodeEerverConfig.getI18NMessage(SErrorCodeEerverConfig.errorMap.get(mail[0]).getkey());
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert(SErrorCodeEerverConfig.errorMap.get(mail[1]).getkey(), new Object[]{config.getName()}, new int[]{1}, "#");
MailLogic.getInstance().sendMail(uid,title,content,"",TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
}
resultRes.setResultCode(1);
// 只记录真实充值
if(price>0 && isRmbBuy(orderId)) {
// 记录真实充值
info.addRealityRmb(price);
// 开天上报
KtEventUtils.onKtEvent(user, ParamEventBean.UserPayEvent, goodsId, orderId, resultRes.getResultCode(), price);
info.addRealityRmb(price);// 记录真实充值
}
// 更新入库
MongoUtil.getLjsdMongoTemplate().lastUpdate();
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.RECHARGE_SUCCESS_INDICATION_VALUE, PlayerInfoProto.RechargeSuccessIndication.newBuilder().setOrderId(orderId).build(), true);
LOGGER.info("购买礼包耗时16{}", TimeUtils.now() - now);
resultRes.setResultCode(1);
return resultRes;
}
@ -384,6 +385,10 @@ public class BuyGoodsNewLogic {
getGoodsBagInfo(uid, goodsBagInfo);
ISession session = OnlineUserManager.getSessionByUid(uid);
if(session!=null){
// for (CommonProto.GiftGoodsInfo info : goodsBagInfo) {
// Gson gson = new Gson();
// LOGGER.info("礼包信息推送uid{},礼包信息:{}",session.getUid(), gson.toJson(info));
// }
PlayerInfoProto.AllGiftGoodsIndication build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build();
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true);
}