private static bool CreateOrder(PlayerBusiness player, string token) { Order log = new Order(); log.Created = DateTime.UtcNow; log.token = token; log.openid = player.UserID; log.pid = player.PID; log.zoneid = ServerLogger.zoneid; bool result = OrderAccess.Instance.Save(log); return result; }
/// <summary> /// /// </summary> /// <param name="order"></param> /// <param name="time">时间</param> /// <returns></returns> public static OrderResult CheckOrder(Order order, int time = 900) { if (order == null) { return OrderResult.OtherError; } //检查时间(误差time秒) if (Math.Abs(UtcTimeExtention.NowTotalSeconds() - order.ts) > time) { return OrderResult.InvalidTime; } if (order.money <= 0) { return OrderResult.AmtError; } if (order.Coin <= 0) { return OrderResult.CoinError; } if (order.providetype >= 0 && order.providetype < maxoType) { int a = moneys[order.providetype]; int b = coins[order.providetype]; if (a * b == 0) { return OrderResult.InvalidOtype; } if ((int)(Math.Round(b * order.money)) == (a * order.Coin)) { return OrderResult.Success; } else { return OrderResult.CoinError; } } else { return OrderResult.InvalidOtype; } }
public static Order CreateShipment(Dictionary<string, string> querise) { Order log = new Order(); log.Created = DateTime.UtcNow; log.amt = int.Parse(querise.GetStringOrDefault("amt")); log.billno = querise.GetStringOrDefault("billno"); log.openid = querise.GetStringOrDefault("openid"); log.payitem = querise.GetStringOrDefault("payitem"); log.version = querise.GetStringOrDefault("version") ?? "v3"; int providetype; if (int.TryParse(querise.GetStringOrDefault("providetype"), out providetype)) { log.providetype = providetype; } log.ppc = querise.GetStringOrDefault("pubacct_payamt_coins"); log.sig = querise.GetStringOrDefault("sig"); log.token = querise.GetStringOrDefault("token"); long ts; if (long.TryParse(querise.GetStringOrDefault("ts"), out ts)) { log.ts = ts; } string zone = querise.GetStringOrDefault("zoneid"); if (!string.IsNullOrEmpty(zone)) { if (zone[0] == 'S' || zone[0] == 's') { log.zoneid = int.Parse(zone.Substring(1)); } else { log.zoneid = int.Parse(zone); } } return log; }
/// <summary> /// 保存订单 /// </summary> /// <param name="log"></param> /// <returns></returns> public bool Save(Order log) { var query = Query.And(Query.EQ("_id", log.token), Query.EQ("state", log.state)); try { var update = Update.Set("amt", log.amt) .Set("billno", log.billno) .Set("Coin", log.Coin) .Set("Created", log.Created) .Set("openid", log.openid) .Set("payitem", log.payitem) .Set("pid", log.pid) .Set("ppc", log.ppc) .Set("providetype", log.providetype) .Set("sig", log.sig) .Set("ts", log.ts) .Set("zoneid", log.zoneid) .Set("Ver", log.Ver) .Set("money", log.money) .Set("Url", log.Url); var v = m_collection.Update(query, update, UpdateFlags.Upsert, SafeMode.True); return v == null ? false : v.DocumentsAffected > 0; } catch { return m_collection.Count(query) == 1; } }
/// <summary> /// 补全Order信息 /// (状态为0时才可以补全) /// </summary> /// <param name="log"></param> /// <param name="newState">补全后状态设置新值,默认为11</param> /// <returns>角色ID</returns> public int Replenish(Order log, int newState) { var query = Query.And(Query.EQ("_id", log.token), Query.EQ("state", 0)); var update = Update.Set("amt", log.amt).Set("billno", log.billno) .Set("openid", log.openid).Set("payitem", log.payitem).Set("ppc", log.ppc) .Set("providetype", log.providetype).Set("sig", log.sig).Set("ts", log.ts) .Set("zoneid", log.zoneid).Inc("state", newState); FieldsBuilder fb = new FieldsBuilder().Include("pid"); var pf = m_collection.FindAndModify(query, null, update, fb, true, false); if (pf != null && pf.Ok && pf.ModifiedDocument != null) { BsonValue vaule; if (pf.ModifiedDocument.TryGetValue("pid", out vaule)) { return (Int32)vaule; } } //记录已补全.直接获取 return GetPlayerID(log.token); }
public bool NewOrder(Order order) { try { var result = m_collection.Insert<Order>(order, DefaultInsertOptions); return result != null && result.Ok; } catch { return false; } }
/// <summary> /// 插入新订单 /// </summary> /// <param name="log"></param> /// <returns></returns> public bool Insert(Order log) { try { var v = m_collection.Insert(log, SafeMode.True); return v == null ? false : v.Ok; } catch { return false; } }
private Order CreateOrder(string authBase64, string sign) { Variant token = verification.DecryptGamewaveToken(authBase64, sign); if (token == null) { return null; } string oid = token.GetStringOrEmpty("oid"); if (string.IsNullOrEmpty(oid)) { return null; } Order order = new Order(); order.billno = oid; order.token = oid; order.openid = token.GetStringOrEmpty("uid").TrimStart('0'); order.money = token.GetDoubleOrDefault("money"); order.Coin = token.GetIntOrDefault("gold"); order.providetype = token.GetIntOrDefault("otype"); order.ts = token.GetInt64OrDefault("time"); order.zoneid = token.GetIntOrDefault("sid"); order.payitem = token.GetStringOrDefault("auth"); order.sig = sign; order.Created = DateTime.UtcNow; return order; }
private static bool ResponseCompleted(Socket client, Order order, PlayerBusiness player) { int coin = order.Coin; //检查tokenID(状态由11变到12,准备充值,用于锁定) if (OrderAccess.Instance.IncOrderState(order.token, 11, 1, coin)) { if (player.AddCoin(coin, FinanceType.BuyCoin)) { //(状态由12变到13,充值成功) if (OrderAccess.Instance.IncOrderState(order.token, 12, 1)) { //成功 Send(client, OrderResult.Success); try { //发送充值成功通知. player.Call(MallCommand.CoinSuccess, order.token, coin, player.Coin); UserNote note = new UserNote(player, PartCommand.Recharge, new object[] { coin }); Notifier.Instance.Publish(note); } catch { } return true; } } } return false; }
static void Main() { string sig = "1D7560DC02F9148B67CEBFFE5570C538"; string cmd = "noticeList"; string par = "[]"; string time = "1341203395";//((long)(UtcTimeExtention.NowTotalSeconds())).ToString(); string testsig = MD5Helper.MD5Encrypt(cmd + par + time + "192168100203"); if (testsig != sig) { Console.WriteLine("验证错误"); return; } TestHttpClient(); //{"Ver" : 0, "_id" : "3D0CA00BCC64CDA40C89341717181B7E16426", "amt" : 500, "billno" : "-APPDJ18203-20120410-1259072131", "openid" : "0000000000000000000000001F32BF75", "payitem" : "G_C000000*10*5", "pid" : 0, "ppc" : "", "providetype" : 0, "sig" : "FxcgbH25MZALt86Hl5rGG8BJgtY=", "state" : 3, "ts" : NumberLong(1334033947), "zoneid" : 7 } //{"Ver" : 0, "_id" : "0A0D832B7E45B153F904B129779F3BB228323", "amt" : 500, "billno" : "-APPDJ18203-20120410-1307352624", "openid" : "0000000000000000000000001F32BF75", "payitem" : "G_C000000*10*5", "pid" : 0, "ppc" : "", "providetype" : 0, "sig" : "Gy44bB7mPWqyI+o4nR84punWlV8=", "state" : 3, "ts" : NumberLong(1334034455), "zoneid" : 7 } Order o = new Order(); o.amt = 500; o.billno = "-APPDJ18203-20120410-1259072131"; o.openid = "0000000000000000000000001F32BF75"; o.payitem = "G_C000000*10*5"; o.pid = 775; o.ppc = ""; o.providetype = 0; o.state = 0; o.token = "3D0CA00BCC64CDA40C89341717181B7E16426"; o.ts = 1334033947; o.Ver = 3; o.zoneid = 7; string text = o.GetSig(@"/cgi-bin/pay"); if (text == "Gy44bB7mPWqyI+o4nR84punWlV8=") { Console.WriteLine("成功"); } TestSign(); return; string test = "a*b+recv中+文测试#$%^&*()fg sadfe"; string st = HttpUtility.UrlEncode(test); Console.WriteLine(st); string st2 = UrlUtility.UrlEncode(test); string st3 = UrlUtility.UrlEncode(test); if (st3 != st2) { Console.WriteLine(st2); } CodeTimer.Initialize(); CodeTimer.Time("testPad", 1000, testPad); CodeTimer.Time("testzero", 1000, testzero); CodeTimer.Time("testChar", 1000, testChar); string res = "Sinan.resources.dll"; int index = res.IndexOf('.'); if (index >= 0) { Console.WriteLine(res.Substring(0, index)); Console.WriteLine(res.Substring(index + 1)); } Assembly assembly = Assembly.LoadFrom(res); System.Resources.ResourceManager cn = new System.Resources.ResourceManager("Sinan.Text.zh-CN", assembly); string x = cn.GetString("Age"); System.Resources.ResourceManager tw = new System.Resources.ResourceManager("Sinan.Text.zh-TW", assembly); string x2 = tw.GetString("Age"); //CoverDBHelper.CoverDB(); Console.WriteLine("按任意键退出......"); Console.Read(); }