补单,未开放
parent
b3ff1d81b8
commit
a4ded00e30
|
@ -0,0 +1,24 @@
|
||||||
|
package com.ljsd.jieling.handler.store;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import rpc.protocols.MessageTypeProto;
|
||||||
|
import rpc.protocols.PlayerInfoProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补单
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class AnewRechargeOrderHandler extends BaseHandler<PlayerInfoProto.AnewRechargeOrderRequest> {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.AnewRechargeOrderRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processWithProto(ISession iSession, PlayerInfoProto.AnewRechargeOrderRequest proto) throws Exception {
|
||||||
|
BuyGoodsNewLogic.anewRecharge(iSession);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.util.KeyGenUtils;
|
||||||
|
import com.ljsd.jieling.util.UUIDEnum;
|
||||||
|
|
||||||
|
public class Order {
|
||||||
|
private String id;
|
||||||
|
private int uid;
|
||||||
|
private String sdkGoodsId;
|
||||||
|
private String openId;
|
||||||
|
private String orderId;
|
||||||
|
private long orderTime;
|
||||||
|
private long amount;
|
||||||
|
|
||||||
|
public Order() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order(int uid, String sdkGoodsId, String openId, String orderId, long orderTime, long amount) {
|
||||||
|
this.id = KeyGenUtils.produceIdByModuleNew(UUIDEnum.Recharge, uid);
|
||||||
|
this.uid = uid;
|
||||||
|
this.sdkGoodsId = sdkGoodsId;
|
||||||
|
this.openId = openId;
|
||||||
|
this.orderId = orderId;
|
||||||
|
this.orderTime = orderTime;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUid(int uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSdkGoodsId() {
|
||||||
|
return sdkGoodsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSdkGoodsId(String sdkGoodsId) {
|
||||||
|
this.sdkGoodsId = sdkGoodsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenId() {
|
||||||
|
return openId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpenId(String openId) {
|
||||||
|
this.openId = openId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrderId() {
|
||||||
|
return orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderId(String orderId) {
|
||||||
|
this.orderId = orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getOrderTime() {
|
||||||
|
return orderTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderTime(long orderTime) {
|
||||||
|
this.orderTime = orderTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(long amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Order{" +
|
||||||
|
"id='" + id + '\'' +
|
||||||
|
", uid=" + uid +
|
||||||
|
", sdkGoodsId='" + sdkGoodsId + '\'' +
|
||||||
|
", openId='" + openId + '\'' +
|
||||||
|
", orderId='" + orderId + '\'' +
|
||||||
|
", orderTime=" + orderTime +
|
||||||
|
", amount=" + amount +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ import com.ljsd.jieling.logic.activity.ActivityType;
|
||||||
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
||||||
import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic;
|
import com.ljsd.jieling.logic.activity.activityLogic.GmSingleActivityLogic;
|
||||||
import com.ljsd.jieling.logic.activity.event.*;
|
import com.ljsd.jieling.logic.activity.event.*;
|
||||||
|
import com.ljsd.jieling.logic.dao.Order;
|
||||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.VipInfo;
|
import com.ljsd.jieling.logic.dao.VipInfo;
|
||||||
|
@ -188,6 +189,13 @@ public class BuyGoodsNewLogic {
|
||||||
resultRes.setResultCode(0);
|
resultRes.setResultCode(0);
|
||||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
ISession session = OnlineUserManager.getSessionByUid(uid);
|
||||||
if (session == null) {
|
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");
|
resultRes.setResultMsg("Session is null");
|
||||||
return resultRes;
|
return resultRes;
|
||||||
}
|
}
|
||||||
|
@ -297,6 +305,33 @@ public class BuyGoodsNewLogic {
|
||||||
return resultRes;
|
return resultRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补单
|
||||||
|
*/
|
||||||
|
public static void anewRecharge(ISession session){
|
||||||
|
PlayerInfoProto.AnewRechargeOrderResponse.Builder builder = PlayerInfoProto.AnewRechargeOrderResponse.newBuilder();
|
||||||
|
String key = RedisKey.ANEW_RECHARGE_ORDER + ":" + session.getUid();
|
||||||
|
Map<String, Order> orderMap = RedisUtil.getInstence().getmapvaluekeyclass(key, String.class, Order.class);
|
||||||
|
if (orderMap == null || orderMap.isEmpty()){
|
||||||
|
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.AnewRechargeOrderResponse_VALUE, builder.build(), true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Order> entry : orderMap.entrySet()) {
|
||||||
|
Order order = entry.getValue();
|
||||||
|
if (order == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
LOGGER.info("补单信息:{}", order);
|
||||||
|
try {
|
||||||
|
sendGoods(order.getUid(), order.getSdkGoodsId(), order.getOpenId(), order.getOrderId(), order.getOrderTime(), (int) order.getAmount());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("补单失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RedisUtil.getInstence().del(key);
|
||||||
|
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.AnewRechargeOrderResponse_VALUE, builder.build(), true);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setFirstRecharge(int uid){
|
public static void setFirstRecharge(int uid){
|
||||||
RedisUtil.getInstence().putmap(RedisKey.First_Recharge, String.valueOf(uid), TimeUtils.now());
|
RedisUtil.getInstence().putmap(RedisKey.First_Recharge, String.valueOf(uid), TimeUtils.now());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue