using System; using LitJson; using ProtoCSStruct; using SimpleHttpServer; using Sog; namespace Operation { [MenuMapping(refc = typeof(PlayerInfoOp))] public class GMPayment { //paydiamond 表中的所有数据 [RequestMapping("paydiamond配置查询",PermissionCode.GAME_CONFIG_SEARCH)] public static int OnGetPayDiamondListHttpReq(string httpApiCmd, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId) { JsonData data1 = new JsonData(); foreach (var item in PayDiamondDescMgr.Instance.ItemTable) { string nameKey = item.Value.itemName; var lang = LanguageDescMgr.Instance.GetConfig(nameKey); if (lang != null) { string cn = lang.ZH; if (cn != "" && cn != null) { nameKey = cn; } } data1[string.Concat(item.Value.itemID)] = nameKey; } jsondata["data"] = data1; return 0; } [RequestMapping("内部福利",PermissionCode.GAME_CONFIG_SEARCH,true)] public static int OnGetPaymentListHttpReq(string httpApiCmd, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId) { RepeatedFixedStructString128_10 data = new RepeatedFixedStructString128_10(); string targetUid = query.GetValue("target_uid"); if (String.IsNullOrEmpty(targetUid)) { targetUid = ""; } string name = query.GetValue("name"); data.Add(targetUid); data.Add(name); HttpApiRootHandler.FillHttpApiDbReq2MessageTaskDistributor(httpApiCmd, httpContextId, ref data); rsp.IsWaitFor = true; return 0; } public static int OnGetPaymentListHttpRes(string httpApiCmd, SSHttpApiDbReq req, DBOperator dbOperator) { TraceLog.Trace("GMPayment.OnGetPaymentListHttpRes HttpContextId {0}", req.HttpContextId); HttpRequestInfo m_request = null; LitJson.JsonData builder = new LitJson.JsonData(); try { var httpContextId = req.HttpContextId; var data=req.Data; m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == httpContextId); dbOperator.DbSelectPaymentAll(builder,data); } catch (Exception ex) { TraceLog.Error("GMPayment.OnGetPaymentListHttpRes Error Msg {0}", ex.Message); } finally { if (m_request != null) { m_request.Http.httpResponse.ContentAsUTF8 = builder.ToJson(); m_request.ProcessEnd = true; } } TraceLog.Trace("GMPayment.OnGetPaymentListHttpRes success httpContextId {0}", req.HttpContextId); return 0; } [RequestMapping("发放内部福利",PermissionCode.GAME_CONFIG_SEARCH)] public static int OnInsertPaymentHttpReq(string httpApiCmd, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId) { RepeatedFixedStructString128_10 data = new RepeatedFixedStructString128_10(); string itemIds = query.GetValue("itemId").ToString() == "" ? "" : query.GetValue("itemId").ToString(); int uid = query.GetValue("uid").Toint32(0) == 0 ? 1 : query.GetValue("uid").Toint32(0); string owner = query.GetValue("owner").ToString() == null ? "" : query.GetValue("owner").ToString(); string realm = query.GetValue("realm").ToString() == null ? "" : query.GetValue("realm").ToString(); string dep = query.GetValue("dep").ToString() == null ? "" : query.GetValue("dep").ToString(); string account = OperationServerUtils.GetAccount(query.GetValue("token")); if (account == null) { jsondata["ret"] = 6; jsondata["msg"] = "账号不存在或未登录"; return 6; } data.Add(account); data.Add(owner); data.Add(realm); data.Add(dep); data.Add(uid.ToString()); data.Add(itemIds); HttpApiRootHandler.FillHttpApiDbReq2MessageTaskDistributor(httpApiCmd, httpContextId, ref data); rsp.IsWaitFor = true; return 0; } public static int OnInsertPaymentHttpRes(string httpApiCmd, SSHttpApiDbReq req, DBOperator dbOperator) { TraceLog.Trace("GMPayment.OnInsertPaymentHttpRes HttpContextId {0}", req.HttpContextId); HttpRequestInfo m_request = null; LitJson.JsonData builder = new LitJson.JsonData(); try { var httpContextId = req.HttpContextId; m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == httpContextId); if (req.Data.Count < 4) { TraceLog.Error("GMPayment.OnInsertPaymentHttpRes param error"); builder["ret"] = 2; builder["msg"] = "参数错误"; return 6; } else { int UID = int.Parse(req.Data[4].ToString()); string itemIds = req.Data[5].ToString(); string[] itemIdList = itemIds.Split(","); SSOperationFakePay notify = new SSOperationFakePay(); notify.Id = req.HttpContextId; notify.Uid = UID; foreach (string itemId in itemIdList) { notify.ItemId.Add(int.Parse(itemId)); } notify.Data.CopyFrom(ref req.Data); OperationServerUtils.SendToWorld((int)SSGameMsgID.OperationFakepay, ref notify, UID, 0, ""); } } catch (Exception ex) { TraceLog.Error("GMPayment.OnInsertPaymentHttpRes Error Msg {0}", ex.Message); } finally { if (m_request != null) { m_request.Http.httpResponse.IsWaitFor = true; } } TraceLog.Trace("GMPayment.OnInsertPaymentHttpRes success httpContextId {0}", req.HttpContextId); return 0; } public static int OnSendPaymentRes(uint remoteAppId, StructPacket packet, DBOperator dbOperator) { SSOperationFakePayRes res = packet.GetMessage(); TraceLog.Trace("GMPayment.OnSendPaymentRes HttpContextId {0}", res.Id); HttpRequestInfo m_request = null; LitJson.JsonData builder = new LitJson.JsonData(); try { var httpContextId = res.Id; m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == httpContextId); var UID = res.Uid; string itemIds = res.Data[5].ToString(); if (res.Ret == 0) { builder["code"] = 0; builder["msg"] = "发送成功"; int result = dbOperator.DbInsertPayment(builder, res.Data[0].ToString(), res.Data[1].ToString(), res.Data[2].ToString(), res.Data[3].ToString(), (int)UID, itemIds, 1); } else { builder["code"] = -1; builder["msg"] = "玩家不在线,发送失败"; } } catch (Exception ex) { TraceLog.Error("GMPayment.OnSendPaymentRes Error Msg {0}", ex.Message); } finally { if (m_request != null) { m_request.Http.httpResponse.ContentAsUTF8 = builder.ToJson(); m_request.ProcessEnd = true; } } TraceLog.Trace("GMPayment.OnSendPaymentRes success httpContextId {0}", res.Id); return 0; } } }