礼包购买逻辑优化,添加非空验证
parent
dac102e271
commit
b1406255ed
|
@ -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,20 +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);
|
||||
LOGGER.info("购买礼包耗时1:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -207,19 +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;
|
||||
}
|
||||
LOGGER.info("购买礼包耗时2:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
|
||||
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();
|
||||
LOGGER.info("购买礼包耗时3:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
int[] forbid = config.getForbid();
|
||||
if(forbid != null){
|
||||
//每日礼包一键购买之后,把所有单个的每日礼包的购买次数加一
|
||||
|
@ -229,24 +236,18 @@ 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);
|
||||
}
|
||||
LOGGER.info("购买礼包耗时4:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
//处理特权
|
||||
activePrivilege(user,config);
|
||||
LOGGER.info("购买礼包耗时5:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
// 校验
|
||||
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||
if(config.getAccumulativeRecharge() == 1){
|
||||
|
@ -255,25 +256,15 @@ public class BuyGoodsNewLogic {
|
|||
//活动
|
||||
changeActivity(user,price,info);
|
||||
}
|
||||
LOGGER.info("购买礼包耗时6:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
if(getFirstRechargeTime(uid) == 0){
|
||||
setFirstRecharge(uid);
|
||||
}
|
||||
LOGGER.info("购买礼包耗时7:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
// 全部礼包状态推送
|
||||
sendGiftGoodsWithoutJudge(uid);
|
||||
LOGGER.info("购买礼包耗时8:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
// 推送礼包
|
||||
openPush(session,user, PushRechargeType.point_recharge.getType(),goodsId);
|
||||
LOGGER.info("购买礼包耗时9:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
// 惊喜礼盒,事件推送
|
||||
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),config.getId(),1,1));
|
||||
LOGGER.info("购买礼包耗时10:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
// gm充值不进行单笔充值活动
|
||||
if (!gm_modifier.equals(orderId)){
|
||||
// 单笔充值
|
||||
|
@ -281,39 +272,28 @@ public class BuyGoodsNewLogic {
|
|||
// 线下自动返利
|
||||
Poster.getPoster().dispatchEvent(new AutoRechargeBackEvent(user.getId(),goodsId,orderId));
|
||||
}
|
||||
LOGGER.info("购买礼包耗时11:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
// 发货
|
||||
sendGoodsByType(user,config,list);
|
||||
LOGGER.info("购买礼包耗时12:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
// 通知前端
|
||||
notifyPaySuccessFul(uid,goodsId,amount != -999);
|
||||
LOGGER.info("购买礼包耗时13:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
//发送邮件
|
||||
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);
|
||||
}
|
||||
LOGGER.info("购买礼包耗时14:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
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();
|
||||
LOGGER.info("购买礼包耗时15:{}", TimeUtils.now() - now);
|
||||
now = TimeUtils.now();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -405,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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue