public TradeOperResult BuyMine(string token, string userName, int minesCount, int payType) { #if Delay Thread.Sleep(5000); #endif if (RSAProvider.LoadRSA(token)) { try { TradeOperResult result = new TradeOperResult(); result.PayType = payType; if (minesCount <= 0) { return(result); } return(OrderController.Instance.MineOrderController.BuyMine(userName, minesCount, payType)); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("玩家[" + userName + "] 购买矿山异常,购买矿山数为:" + minesCount + ",支付类型为:" + ((PayType)payType).ToString(), exc); return(null); } } else { throw new Exception(); } }
private void BuyMineByRMB(MinesBuyRecord record, TradeOperResult result) { CustomerMySqlTransaction myTrans = null; try { myTrans = MyDBHelper.Instance.CreateTrans(); int value = PlayerController.Instance.BuyMineByRMB(record, myTrans); result.ResultCode = value; if (value == OperResult.RESULTCODE_TRUE) { record.PayTime = DateTime.Now; DBProvider.MineRecordDBProvider.SaveFinalMineTradeRecord(record, myTrans); PlayerActionController.Instance.AddLog(record.UserName, MetaData.ActionLog.ActionType.BuyMine, (int)record.GainMinesCount, "增加了 " + record.GainStonesReserves.ToString() + " 的矿石储量"); } myTrans.Commit(); } catch (Exception exc) { myTrans.Rollback(); LogHelper.Instance.AddErrorLog("玩家[" + record.UserName + "], 用灵币购买矿山异常", exc); } finally { if (myTrans != null) { myTrans.Dispose(); } } }
public TradeOperResult GoldCoinRecharge(string token, string userName, int goldCoinCount, int payType) { #if Delay Thread.Sleep(5000); #endif if (RSAProvider.LoadRSA(token)) { try { TradeOperResult result = new TradeOperResult(); result.PayType = payType; result.TradeType = (int)AlipayTradeInType.BuyGoldCoin; if (ClientManager.GetClientUserName(token) != userName) { result.ResultCode = OperResult.RESULTCODE_USER_NOT_EXIST; } int valueRMB = (int)Math.Ceiling(goldCoinCount / GlobalConfig.GameConfig.RMB_GoldCoin); return(OrderController.Instance.GoldCoinOrderController.RechargeGoldCoin(userName, valueRMB, goldCoinCount, payType)); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("玩家[" + userName + "] 金币充值异常,充值金币数为:" + goldCoinCount + ",支付类型为:" + ((PayType)payType).ToString(), exc); return(null); } } else { throw new Exception(); } }
void Client_GoldCoinRechargeCompleted(object sender, Wcf.Clients.WebInvokeEventArgs <MetaData.Trade.TradeOperResult> e) { try { if (e.Cancelled) { return; } if (e.Error != null) { MyMessageBox.ShowInfo("访问服务器失败。"); return; } TradeOperResult result = e.Result; if (result.ResultCode != OperResult.RESULTCODE_TRUE) { MyMessageBox.ShowInfo("金币充值失败。原因:" + OperResult.GetMsg(result.ResultCode)); return; } if (result.PayType == (int)PayType.Alipay) { MyWebPage.ShowMyWebPage(result.AlipayLink); MyMessageBox.ShowInfo("请在弹出的网页中,登录支付宝进行付款。"); if (!AlipayPaySucceed) { var payResult = MyMessageBox.ShowAlipayPayQuestion(); if (payResult == MessageBoxAlipayPayQuestionResult.Succeed) { if (!AlipayPaySucceed) { MyMessageBox.ShowInfo("没有接收到支付宝付款信息。如确实付款,请稍后查看购买记录,或联系客服。"); } } else if (payResult == MessageBoxAlipayPayQuestionResult.Failed) { MyWebPage.ShowMyWebPage(result.AlipayLink); MyMessageBox.ShowInfo("请在弹出的网页中,登录支付宝进行付款。"); return; } } } App.UserVMObject.AsyncGetPlayerInfo(); _syn.Post(p => { //this.DialogResult = true; this.Close(); }, null); } catch (Exception exc) { MyMessageBox.ShowInfo("充值金币,服务器回调处理异常。" + exc.Message); } }
public TradeOperResult RechargeGoldCoin(string userName, int goldCoinCount, PayType payType) { try { TradeOperResult result = new TradeOperResult(); result.PayType = (int)payType; result.TradeType = (int)AlipayTradeInType.BuyGoldCoin; int valueRMB = (int)Math.Ceiling(goldCoinCount / GlobalConfig.GameConfig.RMB_GoldCoin); return(OrderController.Instance.GoldCoinOrderController.RechargeGoldCoin(userName, valueRMB, goldCoinCount, (int)payType)); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("微信端。玩家[" + userName + "] 金币充值异常,充值金币数为:" + goldCoinCount + ",支付类型为:" + (payType).ToString(), exc); return(null); } }
public TradeOperResult RechargeGoldCoin(string userName, int rmbValue, int gainGoldCoin, int payType) { TradeOperResult result = new TradeOperResult(); result.PayType = payType; DateTime timenow = DateTime.Now; var player = PlayerController.Instance.GetPlayerInfoByUserName(userName); string orderNumber = OrderController.Instance.CreateOrderNumber(userName, timenow, AlipayTradeInType.BuyGoldCoin); GoldCoinRechargeRecord record = new GoldCoinRechargeRecord() { OrderNumber = orderNumber, CreateTime = timenow, UserID = player.SimpleInfo.UserID, UserName = userName, SpendRMB = rmbValue, GainGoldCoin = gainGoldCoin }; if (payType == (int)PayType.RMB) { result = RechargeGoldCoinByRMB(record); } else if (payType == (int)PayType.Diamand) { result = RechargeGoldCoinByDiamond(record); } else if (payType == (int)PayType.Alipay) { lock (this._lock) { this._listTempRecord.Add(record.OrderNumber, record); } DBProvider.GoldCoinRecordDBProvider.SaveTempGoldCoinRechargeTradeRecord(record); result.ResultCode = OperResult.RESULTCODE_TRUE; result.AlipayLink = OrderController.Instance.CreateAlipayLink(userName, record.OrderNumber, "迅灵金币", record.SpendRMB, "金币可用于购买矿工"); } else if (payType == (int)PayType.Credits) { result = RechargeGoldCoinByShoppingCredits(record); } return(result); }
public TradeOperResult BuyMine(string userName, int minesCount, PayType payType) { TradeOperResult result = new TradeOperResult(); try { result.PayType = (int)payType; if (minesCount <= 0) { result.ResultCode = OperResult.RESULTCODE_PARAM_INVALID; return(result); } return(OrderController.Instance.MineOrderController.BuyMine(userName, minesCount, (int)payType)); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("微信端。玩家[" + userName + "] 购买矿山异常,购买矿山数为:" + minesCount + ",支付类型为:" + ((PayType)payType).ToString(), exc); result.ResultCode = OperResult.RESULTCODE_EXCEPTION; return(result); } }
private TradeOperResult RechargeGoldCoinByRMB(GoldCoinRechargeRecord record) { TradeOperResult result = new TradeOperResult(); CustomerMySqlTransaction myTrans = null; try { myTrans = MyDBHelper.Instance.CreateTrans(); int value = PlayerController.Instance.RechargeGoldCoinByRMB(record.UserName, (int)record.SpendRMB, (int)record.GainGoldCoin, myTrans); result.ResultCode = value; if (value == OperResult.RESULTCODE_TRUE) { record.PayTime = DateTime.Now; DBProvider.GoldCoinRecordDBProvider.SaveFinalGoldCoinRechargeRecord(record, myTrans); } myTrans.Commit(); PlayerActionController.Instance.AddLog(record.UserName, MetaData.ActionLog.ActionType.GoldCoinRecharge, record.GainGoldCoin, "充值了 " + record.GainGoldCoin.ToString() + " 的金币"); return(result); } catch (Exception exc) { myTrans.Rollback(); LogHelper.Instance.AddErrorLog("玩家[" + record.UserName + "] 用灵币购买金币异常", exc); result.ResultCode = OperResult.RESULTCODE_EXCEPTION; return(result); } finally { if (myTrans != null) { myTrans.Dispose(); } } }
public TradeOperResult BuyMine(string userName, int minesCount, int payType) { TradeOperResult result = new TradeOperResult(); var systemState = DBProvider.UserDBProvider.GetAllXunLingMineFortuneState(); int surplus = GlobalConfig.GameConfig.LimitStoneCount - (int)systemState.AllStonesCount; if (surplus <= 0) { result.ResultCode = OperResult.RESULTCODE_BUYMINE_MINEISFULL; return(result); } result.PayType = payType; DateTime timenow = DateTime.Now; var playerInfo = PlayerController.Instance.GetPlayerInfoByUserName(userName); bool isVIP = playerInfo.FortuneInfo.Exp > GlobalConfig.GameConfig.PlayerVIPInterval; string orderNumber = OrderController.Instance.CreateOrderNumber(userName, timenow, AlipayTradeInType.BuyMine); result.OperNumber = GetStoneCount_BuyMine(minesCount, isVIP, surplus); MinesBuyRecord record = new MinesBuyRecord() { OrderNumber = orderNumber, CreateTime = timenow, UserID = playerInfo.SimpleInfo.UserID, UserName = userName, GainMinesCount = minesCount, GainStonesReserves = (int)result.OperNumber, SpendRMB = (int)Math.Ceiling(minesCount * GlobalConfig.GameConfig.RMB_Mine) }; switch ((PayType)payType) { case PayType.Alipay: lock (this._lock) { this._listTempRecord.Add(record.OrderNumber, record); } DBProvider.MineRecordDBProvider.SaveTempMineTradeRecord(record); result.ResultCode = OperResult.RESULTCODE_TRUE; result.AlipayLink = OrderController.Instance.CreateAlipayLink(userName, record.OrderNumber, "迅灵矿山", record.SpendRMB, "勘探一座矿山,可增加" + result.OperNumber + "矿石储量"); break; case PayType.RMB: BuyMineByRMB(record, result); break; case PayType.GoldCoin: break; case PayType.Diamand: BuyMineByDiamond(record, result); break; case PayType.Credits: BuyMineByShoppingCredits(record, result); break; default: break; } return(result); }