礼包购买逻辑优化,添加非空验证
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.BIReason;
|
||||||
import com.ljsd.jieling.globals.Global;
|
import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.jbean.ActivityMission;
|
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.GlobleSystemLogic;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.activity.AbstractActivity;
|
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 {
|
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();
|
long now = TimeUtils.now();
|
||||||
Result resultRes = new Result();
|
Result resultRes = new Result();
|
||||||
resultRes.setResultCode(0);
|
resultRes.setResultCode(0);
|
||||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
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) {
|
||||||
LOGGER.info("购买礼包耗时1:{}", TimeUtils.now() - now);
|
resultRes.setResultMsg("Session is null");
|
||||||
now = TimeUtils.now();
|
return resultRes;
|
||||||
|
}
|
||||||
if (!StringUtil.isNumeric(sdkGoodsId)){
|
if (!StringUtil.isNumeric(sdkGoodsId)){
|
||||||
|
resultRes.setResultMsg("sdkGoodsId is error");
|
||||||
return resultRes;
|
return resultRes;
|
||||||
}
|
}
|
||||||
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.configMap.get(Integer.parseInt(sdkGoodsId));
|
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.configMap.get(Integer.parseInt(sdkGoodsId));
|
||||||
if(null == config){
|
if(null == config){
|
||||||
resultRes.setResultMsg("good config null");
|
resultRes.setResultMsg("SRechargeCommodityNewConfig is null");
|
||||||
LOGGER.error("sendGoods the uid={},the goodId={},购买的礼包为空",uid,sdkGoodsId);
|
|
||||||
return resultRes;
|
return resultRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,19 +207,26 @@ public class BuyGoodsNewLogic {
|
||||||
// int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
|
// int cfgType = SSpecialConfig.getIntegerValue(SSpecialConfig.EXCHANGE_FORCE_TYPE);
|
||||||
// double price = priceTemp==0?0: SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
|
// double price = priceTemp==0?0: SExchangeRate.doubleIntegerHashMap.get(cfgType).get((int)priceTemp);
|
||||||
if(amount != price*100){
|
if(amount != price*100){
|
||||||
resultRes.setResultMsg("charge price error");
|
resultRes.setResultMsg("compared amount fail");
|
||||||
LOGGER.error("sendGoods 金额校验失败, uid={},the goodId={}, currentPrice={},realPrice={}",uid,goodsId, amount,price);
|
LOGGER.error("sendGoods 金额校验失败, uid={}, goodId={}, amount={}, price={}",uid,goodsId, amount, price*100);
|
||||||
return resultRes;
|
return resultRes;
|
||||||
}
|
}
|
||||||
LOGGER.info("购买礼包耗时2:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
|
if (user == null) {
|
||||||
|
resultRes.setResultMsg("User not found");
|
||||||
|
return resultRes;
|
||||||
|
}
|
||||||
|
|
||||||
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
|
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
|
||||||
AbstractWelfareBag bag = rechargeHandler.getBag(user, goodsId);
|
AbstractWelfareBag bag = rechargeHandler.getBag(user, goodsId);
|
||||||
|
if (bag == null) {
|
||||||
|
resultRes.setResultMsg("Welfare bag not found");
|
||||||
|
return resultRes;
|
||||||
|
}
|
||||||
|
|
||||||
// 礼包购买
|
// 礼包购买
|
||||||
bag.buy();
|
bag.buy();
|
||||||
LOGGER.info("购买礼包耗时3:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
int[] forbid = config.getForbid();
|
int[] forbid = config.getForbid();
|
||||||
if(forbid != null){
|
if(forbid != null){
|
||||||
//每日礼包一键购买之后,把所有单个的每日礼包的购买次数加一
|
//每日礼包一键购买之后,把所有单个的每日礼包的购买次数加一
|
||||||
|
@ -229,24 +236,18 @@ public class BuyGoodsNewLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int[][]> list = bag.getDropByBag();
|
List<int[][]> list = bag.getDropByBag();
|
||||||
int[][] gainFame = config.getGainFame();
|
|
||||||
// 购买礼包额外补助
|
// 购买礼包额外补助
|
||||||
|
int[][] gainFame = config.getGainFame();
|
||||||
if (gainFame != null && gainFame.length > 0){
|
if (gainFame != null && gainFame.length > 0){
|
||||||
list.add(gainFame);
|
list.add(gainFame);
|
||||||
}
|
}
|
||||||
// gm购买礼包不参与补助
|
// gm购买礼包不参与补助
|
||||||
if (!orderId.equals(gm_modifier)){
|
int[][] gainCrystal = config.getGainCrystal();
|
||||||
int[][] gainCrystal = config.getGainCrystal();
|
if (!orderId.equals(gm_modifier) && gainCrystal != null && gainCrystal.length > 0){
|
||||||
if (gainCrystal != null && gainCrystal.length > 0){
|
list.add(gainCrystal);
|
||||||
list.add(gainCrystal);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LOGGER.info("购买礼包耗时4:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
//处理特权
|
//处理特权
|
||||||
activePrivilege(user,config);
|
activePrivilege(user,config);
|
||||||
LOGGER.info("购买礼包耗时5:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
// 校验
|
// 校验
|
||||||
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
|
NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo();
|
||||||
if(config.getAccumulativeRecharge() == 1){
|
if(config.getAccumulativeRecharge() == 1){
|
||||||
|
@ -255,25 +256,15 @@ public class BuyGoodsNewLogic {
|
||||||
//活动
|
//活动
|
||||||
changeActivity(user,price,info);
|
changeActivity(user,price,info);
|
||||||
}
|
}
|
||||||
LOGGER.info("购买礼包耗时6:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
if(getFirstRechargeTime(uid) == 0){
|
if(getFirstRechargeTime(uid) == 0){
|
||||||
setFirstRecharge(uid);
|
setFirstRecharge(uid);
|
||||||
}
|
}
|
||||||
LOGGER.info("购买礼包耗时7:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
// 全部礼包状态推送
|
// 全部礼包状态推送
|
||||||
sendGiftGoodsWithoutJudge(uid);
|
sendGiftGoodsWithoutJudge(uid);
|
||||||
LOGGER.info("购买礼包耗时8:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
// 推送礼包
|
// 推送礼包
|
||||||
openPush(session,user, PushRechargeType.point_recharge.getType(),goodsId);
|
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));
|
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),config.getId(),1,1));
|
||||||
LOGGER.info("购买礼包耗时10:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
// gm充值不进行单笔充值活动
|
// gm充值不进行单笔充值活动
|
||||||
if (!gm_modifier.equals(orderId)){
|
if (!gm_modifier.equals(orderId)){
|
||||||
// 单笔充值
|
// 单笔充值
|
||||||
|
@ -281,39 +272,28 @@ public class BuyGoodsNewLogic {
|
||||||
// 线下自动返利
|
// 线下自动返利
|
||||||
Poster.getPoster().dispatchEvent(new AutoRechargeBackEvent(user.getId(),goodsId,orderId));
|
Poster.getPoster().dispatchEvent(new AutoRechargeBackEvent(user.getId(),goodsId,orderId));
|
||||||
}
|
}
|
||||||
LOGGER.info("购买礼包耗时11:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
// 发货
|
// 发货
|
||||||
sendGoodsByType(user,config,list);
|
sendGoodsByType(user,config,list);
|
||||||
LOGGER.info("购买礼包耗时12:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
// 通知前端
|
// 通知前端
|
||||||
notifyPaySuccessFul(uid,goodsId,amount != -999);
|
notifyPaySuccessFul(uid,goodsId,amount != -999);
|
||||||
LOGGER.info("购买礼包耗时13:{}", TimeUtils.now() - now);
|
|
||||||
now = TimeUtils.now();
|
|
||||||
//发送邮件
|
//发送邮件
|
||||||
int[] mail = config.getMail();
|
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 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}, "#");
|
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);
|
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)) {
|
if(price>0 && isRmbBuy(orderId)) {
|
||||||
// 记录真实充值
|
info.addRealityRmb(price);// 记录真实充值
|
||||||
info.addRealityRmb(price);
|
|
||||||
// 开天上报
|
|
||||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserPayEvent, goodsId, orderId, resultRes.getResultCode(), price);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新入库
|
// 更新入库
|
||||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
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);
|
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.RECHARGE_SUCCESS_INDICATION_VALUE, PlayerInfoProto.RechargeSuccessIndication.newBuilder().setOrderId(orderId).build(), true);
|
||||||
LOGGER.info("购买礼包耗时16:{}", TimeUtils.now() - now);
|
LOGGER.info("购买礼包耗时16:{}", TimeUtils.now() - now);
|
||||||
|
|
||||||
|
resultRes.setResultCode(1);
|
||||||
return resultRes;
|
return resultRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,6 +385,10 @@ public class BuyGoodsNewLogic {
|
||||||
getGoodsBagInfo(uid, goodsBagInfo);
|
getGoodsBagInfo(uid, goodsBagInfo);
|
||||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
ISession session = OnlineUserManager.getSessionByUid(uid);
|
||||||
if(session!=null){
|
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();
|
PlayerInfoProto.AllGiftGoodsIndication build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo).build();
|
||||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true);
|
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue