码迷,mamicode.com
首页 > Web开发 > 详细

带输出參数的存储过程的定义,以及在aso.net中调用

时间:2017-05-27 17:08:04      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:string   tracking   help   gen   charge   use   desc   ota   query   

ALTER proc [dbo].[mp_w_RechargePortalPayPal_All]
(
@PayPalOrderNo nvarchar(50), --订单号
@nAccountIDFrom int, --充值帐号
@nAccountIDTo int, --充入帐号
@cTotalMoney numeric(18,2), --总价        用户所在货币总价
@nMoneyType int, --货币类型    用户所在货币类型    -- 非system货币
@nToGameID int, --充入游戏
@nToGameAreaID int, --充入游戏区域
@nToGameServerID int, --冲入游戏server
@GameRoleName nvarchar(50) , --冲入游戏角色名


@nVMoney int, --平台币(总)
@nGamePoint int, --游戏币(总)
@AccountIP nvarchar(50), --充值IP
@AccountName nvarchar(150), --姓名
@AccountEmail nvarchar(150), --邮件
@AccountTel nvarchar(50), --电话
@PayType int, --支付方式
@BuyType int, --购买方式


@rv int out, -- >0成功 -1帐号不存在 -2帐号被封或冻结
@rOrderNo nvarchar(50) out,
@rBalanceMoney numeric(18,2) out
)
as


declare @rate decimal(18,6) --汇率
declare @LocalMoneyType int --系统的当地货币类型
declare @orderID int --订单ID
declare @LocalMoneyPrice numeric(18,2) --系统的当地货币
declare @sAccountFrom nvarchar(150) --充值帐户
declare @sAccountTo nvarchar(150) --充入帐户
declare @orderNO nvarchar(50) --订单号
declare @SKUID nvarchar(58) --SKUID
set @rOrderNo=‘‘;
set @rBalanceMoney=0;




--推断帐号是否存在
if not exists (select 1 from w_MainAccountInfo where nAccountID=@nAccountIDTo)
begin
set @rv=-1
return
end
--推断账号的状态是否正常
if not exists(select 1 from w_MainAccountInfo ma left join w_MainAccountDetailInfo da on ma.NAccountID=da.NAccountID where ma.naccountID =@nAccountIDTo and da.coldtime<getdate() and ma.status=1)
begin
set @rv=-2
end
--推断订单号是否存在,存在则又一次生成
if exists (select 1 from w_OnlinePayOrderInfo where OrderNo=@PayPalOrderNo)
begin
set @PayPalOrderNo=dbo.f_generateOrderNO(@BuyType,@nToGameID,newid())
end


--查询账户信息
select @sAccountFrom=sAccount from w_MainAccountInfo where nAccountID=@nAccountIDFrom
select @sAccountTo=sAccount from w_MainAccountInfo where nAccountID=@nAccountIDTo




--写入订单表
set @orderNO = @PayPalOrderNo -- 订单号为卡号  -- dbo.f_generateOrderNO(1,@cardCountry,newid())


--查询汇率。将金额兑换为美元
if @nMoneyType <> 99
begin
select top 1 @rate = moneyprice/balanceMoneyPrice,@LocalMoneyType=balanceMoneyType from w_OnlinePayExchangeRate where moneyType = @nMoneyType order by AddDate desc
set @LocalMoneyPrice = @cTotalMoney / @rate
end
else
begin
set @rate=1
set @LocalMoneyPrice = @cTotalMoney
set @LocalMoneyType= @nMoneyType

end


--查询赠送点数
declare @GiftPoints int
declare @RealnGamePoint int


if(@nToGameID>0)
begin
--exec mp_w_RechargeGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@NaccountIDTo,@GiftPoints output
--declare @INGameServerName nvarchar(10)
--if(@nToGameID=3 or @nToGameID=12 or @nToGameID=18 or @nToGameID=19)
--begin
-- set @INGameServerName = ‘S‘+CONVERT(nvarchar(10),@GiftServerID)
--end
--exec mp_w_RechargeServerGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@nAccountIDTo,@INGameServerName,@GiftPoints output
exec mp_w_RechargeServerGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@nAccountIDTo,@nToGameServerID,@GiftPoints output


end
else if(@nToGameID=0)
begin
set @GiftPoints=0
end


--手工兑换上线后。调用存储过程需删除
--exec mp_w_RechargeGiftPoints @orderNO,@nToGameID,@PayType,@nGamePoint,@NaccountIDTo,@GiftPoints output


set @RealnGamePoint=@nGamePoint+@GiftPoints


--插入订单表 OrderState为0
insert into w_OnlinePayOrderInfo(NaccountID,sAccount,OrderNo,MoneyPrice,MoneyType,OrderState
,BuyVMoneyNum,BuyGamePointNum,balanceMoneyPrice,balanceMoneyType,balanceRate,balancePoundage
,AddDate,PayDate,PayType,nAccountID_To,sAccount_To,UserHostIP
,SendVMoneyDate,GameID,MoneyOldPrice,RechargeArea,UserName,UserEmail
,UserTel,RechargeServerID)
values (@NaccountIDFrom,@sAccountFrom,@orderNO,@LocalMoneyPrice,@LocalMoneyType,0
,@nVMoney,@RealnGamePoint,@cTotalMoney,@nMoneyType,@rate,0
,getdate(),0,@PayType,@NaccountIDTo,@sAccountTo,@AccountIP
,0,@nToGameID,0,@nToGameAreaID,@AccountName,@AccountEmail
,@AccountTel,@nToGameServerID) 
select @orderID=@@identity

if(LEN( @AccountName)>58)
SET @SKUID=substring( @AccountName,1,56)
else
SET @SKUID=@AccountName

insert into w_OnlinePayOrderDetailInfo(OrderID,ItemNum,cVmoneyNum,cMoneyPrice,cMoneyType,cGamePointNum) values (@orderID,1,@nVMoney,@cTotalMoney,@nMoneyType,@nGamePoint)
insert into w_OnlinePayBuyerInfo(OrderID,INGameRoleName,INGameServerName,SKUID) values (@orderID,@GameRoleName,@nToGameServerID,@SKUID)


set @rv=@orderID
set @rOrderNo=@orderNO
set @rBalanceMoney=@LocalMoneyPrice


--记录赠送日志
if(@GiftPoints > 0)
begin


update w_OnlinepayGiftPointsHistory set orderid=@orderID,naccountid=@nAccountIDTo,
naccountname=@sAccountTo,rechargedate=getdate() where orderno=@OrderNo


end


----订单日志

--insert into w_OnlinePayOrderLog(info) values (‘PayPal_All订单:‘ + @orderNO + ‘生成成功‘)



  /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程參数</param>
        /// <param name="rowsAffected">影响的行数</param>
        /// <returns></returns>
        public static int RunProcedure(string storedProcName, int DataBaseType, IDataParameter[] parameters, out int rowsAffected)
        {
            using (SqlConnection connection = new SqlConnection(GetDBGameConnstring(DataBaseType)))
            {
                int result;
                connection.Open();
                SqlCommand command = BuildIntCommand(connection, storedProcName, parameters);
                command.CommandTimeout = 60;
                rowsAffected = command.ExecuteNonQuery();
                result = (int)command.Parameters["ReturnValue"].Value;
                //Connection.Close();
                return result;
            }
        }



     public static void OnlineRechargePayPalAll(string OrderNo, int AccountIDFrom, int AccountIDTo, string TotalMoney, int PriceType, int GameID, int GameArea, int AreaServerID, string sGameRoleName, int vMoney, int GamePoint, string IP, string Name, string Email, string Tel, int PayType, int BuyType, out int ErrorCode, out string ReturnOrderNo, out string BalanceMoney)
        {
            int iRows = 0;


            SqlParameter[] parsRechargePayPal = {
new SqlParameter("@PayPalOrderNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@nAccountIDFrom", SqlDbType.Int),
                    new SqlParameter("@nAccountIDTo", SqlDbType.Int),
                    new SqlParameter("@cTotalMoney", SqlDbType.Decimal),
                    new SqlParameter("@nMoneyType",SqlDbType.Int),
                    new SqlParameter("@nToGameID",SqlDbType.Int),
                    new SqlParameter("@nToGameAreaID",SqlDbType.Int),
                    new SqlParameter("@nToGameServerID",SqlDbType.Int), 
                    new SqlParameter("@GameRoleName",SqlDbType.NVarChar,50),


                    new SqlParameter("@nVMoney",SqlDbType.Int),
                    new SqlParameter("@nGamePoint",SqlDbType.Int),
                    new SqlParameter("@AccountIP",SqlDbType.NVarChar,50),
                    new SqlParameter("@AccountName",SqlDbType.NVarChar,150),
                    new SqlParameter("@AccountEmail",SqlDbType.NVarChar,150),
                    new SqlParameter("@AccountTel",SqlDbType.NVarChar,50),
                    new SqlParameter("@PayType",SqlDbType.Int),
                    new SqlParameter("@BuyType",SqlDbType.Int),
                   
                    new SqlParameter("@rv",SqlDbType.Int),
                    new SqlParameter("@rOrderNo",SqlDbType.NVarChar,50),
                    new SqlParameter("@rBalanceMoney",SqlDbType.Decimal)};
            parsRechargePayPal[0].Value = OrderNo;
            parsRechargePayPal[1].Value = AccountIDFrom;
            parsRechargePayPal[2].Value = AccountIDTo;
            parsRechargePayPal[3].Value = TotalMoney;
            parsRechargePayPal[4].Value = PriceType;
            parsRechargePayPal[5].Value = GameID;
            parsRechargePayPal[6].Value = GameArea;
            parsRechargePayPal[7].Value = AreaServerID;
            parsRechargePayPal[8].Value = sGameRoleName;


            parsRechargePayPal[9].Value = vMoney;
            parsRechargePayPal[10].Value = GamePoint;
            parsRechargePayPal[11].Value = IP;
            parsRechargePayPal[12].Value = Name;
            parsRechargePayPal[13].Value = Email;
            parsRechargePayPal[14].Value = Tel;
            parsRechargePayPal[15].Value = PayType;
            parsRechargePayPal[16].Value = BuyType;


            parsRechargePayPal[17].Direction = ParameterDirection.Output;
            parsRechargePayPal[17].Value = 0;
            parsRechargePayPal[18].Direction = ParameterDirection.Output;
            parsRechargePayPal[18].Value = "";
            parsRechargePayPal[19].Direction = ParameterDirection.Output;
            parsRechargePayPal[19].Value = "0.0";
            parsRechargePayPal[19].Precision = 10;
            parsRechargePayPal[19].Scale = 2;


            DbHelperSQL.RunProcedure("mp_w_RechargePortalPayPal_All", parsRechargePayPal, out iRows);
            ErrorCode = CmnProc.getInt(parsRechargePayPal[17].Value);
            ReturnOrderNo = CmnProc.getString(parsRechargePayPal[18].Value);
            BalanceMoney = CmnProc.getString(parsRechargePayPal[19].Value);
        }

















带输出參数的存储过程的定义,以及在aso.net中调用

标签:string   tracking   help   gen   charge   use   desc   ota   query   

原文地址:http://www.cnblogs.com/claireyuancy/p/6913460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!