无聊的时候,写个sql,琢磨着解决自己工作中遇到的费时的问题.

平常工作最麻烦的就是游戏玩家的银子丢了之后,我要判断是他断线丢的还是输给别人他自己搞错了。

虽然还没有好的思路,还是一直打算写个方便点的程序,节约劳动,今天有空,就写了下,虽然效果还不太好,不过功能上大体满足了。

代码如下:

--用户银子分析
--Designed by whbo
--Designed at 2005-10-19
--Modified by
--Modified at
Declare @intWantedamount int
Declare @intUserID int,@intTax real
Declare @BgnDateTime DATETIME,@EndDateTime DATETIME
Declare @chvLoginName varchar(64)
set @chvLoginName='liuyun512'  --用户名             <1>
set @intUserID=10322057   --用户ID
if @chvLoginName<>''
 select @intUserid=[UserID] from UserCenter.dbo.AllUser where [LoginName]=@chvLoginName

set @intWantedamount=0  --丢失银子
set @BgnDateTime='2005-10-19'  --开始时间           <2>
set @EndDateTime='2005-10-19 20:00:00'  --终止时间
if @intWantedAmount=0
 set @intWantedamount=40000    --  <3>
/*
 目前的税收说明:
 0.03-----------苏州麻将:(觅渡桥 : 10062) ; (山塘街 :10071)
         南京麻将:(新街口(300倍):10080);
         关牌    :(万年桥(32倍) :10067) ; (血战到底(32倍):10073)
 0.05-----------包分    :(接驾桥(150倍):10034) ; (金鸡湖(150倍) :10063) ;网师园(150倍) : 10055  
 0.00-----------其他游戏无税收
*/
--从下面选择一种税收
set @intTax=0.97
--set @intTax=0.95
if @BgnDateTime=''
 set @BgnDateTime=convert(varchar(10),GetDate())
if @EndDateTime=''
 set @EndDateTime=GetDate()
select userid [用户ID],wantedamount [丢失银子],convert(int,wantedamount*@inttax) as [税后银子],sourcename [游戏服务器编号],remark [游戏服务器],writetime [时间] from moneylog where userid=@intUserID and writetime >@BgnDateTime and wantedamount<-@intWantedamount
and modename not in ('管理员','保险箱') order by writetime

set @BgnDateTime='2005-10-19 13:33:00'   --<S1>
set @EndDateTime='2005-10-19 19:15:00'   --<S2>

Declare @chvSourceName table(SourceName varchar(20))

insert into @chvSourceName select sourcename from moneylog where userid=@intUserID and writetime >@BgnDateTime and wantedamount<-@intWantedamount order by writetime

select a.userid [用户ID],a.wantedamount [获得银子],a.sourcename [游戏服务器编号],a.remark [游戏服务器],a.writetime [时间] from moneylog a
inner join @chvSourceName b on a.sourcename=b.sourcename and a.wantedamount>@intWantedamount and a.writetime between @BgnDateTime and @EndDateTime
order by a.writetime

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值