/// <summary> /// OrderInfoCache /// </summary> public static void DoOrderInfoCache() { var orderInfoSet = new ShareCacheStruct <OrderInfoCache>(); TraceLog.WriteInfo("Do OrderInfoCache table start..."); int count = 0; try { var dbProvider = DbConnectionProvider.CreateDbProvider(DbConfig.MERGE); string sql = "SELECT OrderId,UserId,NickName,MerchandiseName,PayId,Amount,PassportID,PassportID," + "GameCoins,CreateDate,RetailID,RcId FROM OrderInfoCache"; using (IDataReader reader = dbProvider.ExecuteReader(CommandType.Text, sql)) { while (reader.Read()) { OrderInfoCache newOrderInfo = new OrderInfoCache() { OrderId = reader["OrderId"].ToString(), UserId = reader["UserId"].ToInt(), NickName = reader["NickName"].ToString(), MerchandiseName = reader["MerchandiseName"].ToString(), PayId = reader["PayId"].ToInt(), Amount = reader["Amount"].ToInt(), PassportID = reader["PassportID"].ToString(), ServerID = reader["ServerID"].ToInt(), GameCoins = reader["GameCoins"].ToInt(), CreateDate = reader["CreateDate"].ToDateTime(), RetailID = reader["RetailID"].ToString(), RcId = reader["RcId"].ToInt(), }; if (orderInfoSet.FindKey(newOrderInfo.OrderId) == null) { //orderInfoSet.Add(newOrderInfo); count++; } } //orderInfoSet.Update(); } } catch (Exception ex) { TraceLog.WriteError("Do OrderInfoCache table error Exception: {0} .", ex); return; } TraceLog.WriteInfo("Do OrderInfoCache table successful : {0} .", count); }
private JsonResult verifyDeliver(Dictionary <string, string> parms) { receipt = new JsonResult(); receipt.ResultCode = 0; JsonOrderInfo jsonorder = null; JsonCustomData jsoncustom = null; try { parms.TryGetValue("DATA", out _data); jsonorder = MathUtils.ParseJson <JsonOrderInfo>(_data); if (jsonorder == null) { receipt.ResultString = "DATA 数据解析错误"; return(receipt); } jsonorder.CustomData = CryptoHelper.HttpBase64Decode(jsonorder.CustomData); jsonorder.CustomData = HttpUtility.UrlDecode(jsonorder.CustomData); jsoncustom = MathUtils.ParseJson <JsonCustomData>(jsonorder.CustomData); if (jsoncustom == null) { receipt.ResultString = "CustomData 自定义数据解析错误"; return(receipt); } } catch (Exception e) { receipt.ResultString = "解析失败!JSON格式错误"; TraceLog.WriteError(string.Format("{0}\n {1}\n {2}", receipt.ResultString, _data, e)); return(receipt); } try { // MD5 string signParameter = md5key + jsonorder.OrderId + jsonorder.CpOrderId + jsonorder.Amount + jsoncustom.PayId; string sign = CryptoHelper.MD5_Encrypt(signParameter, Encoding.UTF8).ToLower(); if (sign.CompareTo(jsonorder.Sign) != 0) { receipt.ResultString = "MD5验证失败"; return(receipt); } var orderInfoCache = new ShareCacheStruct <OrderInfoCache>(); var orderinfo = orderInfoCache.FindKey(jsonorder.OrderId); if (orderinfo != null) {// 如果是已经发货了,返回成功 receipt.ResultCode = 1; receipt.ResultString = "该订单已经发货"; return(receipt); } UserBasisCache user = UserHelper.FindUserBasisOfRetail(jsoncustom.RetailID, jsonorder.OpenId, jsoncustom.ServerID); if (user == null) {// 优先使用OpenId + RetailID + ServerID来获取充值角色 user = UserHelper.FindUserBasis(jsonorder.UserId); if (user == null) { receipt.ResultString = "没有找到该玩家"; return(receipt); } } UserPayCache userpay = UserHelper.FindUserPay(user.UserID); if (userpay == null) { receipt.ResultString = "没有找到该玩家充值信息表"; return(receipt); } var paycfg = new ShareCacheStruct <Config_Pay>().FindKey(jsoncustom.PayId); if (paycfg == null) { receipt.ResultString = "PayId 错误"; return(receipt); } int deliverNum = paycfg.AcquisitionDiamond + paycfg.PresentedDiamond; if (jsonorder.Amount != paycfg.PaySum) { receipt.ResultString = "金额错误"; TraceLog.WriteError("Pay error Uid:{0}, Name:{1}, OrderAmount:{2}, ConfigAmount:{3} .", user.UserID, user.NickName, jsonorder.Amount, paycfg.PaySum); return(receipt); } if (!UserHelper.OnWebPay(user.UserID, jsoncustom.PayId)) { receipt.ResultString = "发货失败"; return(receipt); } OrderInfoCache newOrderInfo = new OrderInfoCache() { OrderId = jsonorder.OrderId, UserId = user.UserID, NickName = user.NickName, MerchandiseName = paycfg.Identifying, PayId = jsoncustom.PayId, Amount = jsonorder.Amount, PassportID = user.Pid, ServerID = user.ServerID, GameCoins = deliverNum, CreateDate = DateTime.Now, RetailID = jsoncustom.RetailID, RcId = jsonorder.RcId }; orderInfoCache.Add(newOrderInfo); orderInfoCache.Update(); receipt.ResultCode = 1; receipt.ResultString = "SUCCEED"; } catch (Exception e) { receipt.ResultString = "发货过程出现异常"; TraceLog.WriteError(string.Format("{0}\n {1}\n {2}", receipt.ResultString, _data, e)); return(receipt); } return(receipt); }