您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

制作我们自己的Ebay(拍卖系统)(7)

来源:未知 责任编辑:智问网络 发表时间:2013-09-03 12:18 点击:
Chris Payne

September 11, 2000

Well, now your auction can run for an indefinite time. People can keep placing bids until you decide to
stop them (good for the seller, but makes bidders kind of unhappy, to say the least). Lets discuss the
mechanisms for stopping an auction.

There are two easy ways to do it. The first, and easiest to perform, though requiring more manual
intervention in the long run, is to simply build in an "Active" bit field into your tblAuctions table.
When you decide to stop the auction, flip the bit, and the auction is over. (Youll also have to add some
code to make sure that the DoBids and ResolveBids functions dont operate on closed auctions.) Then simply
query the database, find out the winner(s), and let them and the seller know. Easy as pie.

The second method is to go by the end date the seller specifies (better business, believe me). To do this,
you can manually stop the auction (via the process above) when the appropriate date comes, or you can
schedule a task to turn an auction off at the appropriate times. There are a few ways to do this, via your
database program and the Windows NT Task Scheduler, so I wont go through each one. You could simply set
the script to run every midnight or so to stop the auction and determine the winners.

If you let the seller specify an exact time for the auction to end, then youre introducing a whole new
set of complications. One way to handle this is to programmatically set a scheduled task as soon as the
seller submits the auction, for the end date of the auction. This requires minimum intervention, but
requires you to know how to do that (for documentation on the Task Scheduler, read this MSDN article).
Another method is to create your own specific version of task scheduler; create a small program that will
run in the background and watch the times on auctions. When an auction end date passes, flip the bit.

Okay, so the auction is over. Now what?

Assuming that you would like minimal manual intervention, and you dont really care who wins (like the
head guys at Ebay care who wins every single auction), then you could create a function to send alerts to
the winner(s) and seller that will kick off when the auction is over. This function could also in turn
kick off some type of payment system, but that is beyond the scope of this article. Lets look at the
function:



Function SelectWinners(AuctionID, itemID)


Set variables and create objects
dim totItems, intAvailable
totItems = 0
strConnectionString = "DSN=MyAuction;UID=username;PWD=password;Database=MyAuctionDB"
set rst = Server.CreateObject("ADODB.Recordset")


Find the number of items available
strSQL = "SELECT Available FROM tblAuctionItems WHERE " & _
"IID = " & ItemID
rst.open strSQL, strConnectionString
intAvailable = rst(1)
rst.close


find the winners
If two customers bid the same amount, the customer requesting
more items will win. If still tied, the customer placing the
earliest bid will win
strSQL = "SELECT UID, WinPrice, WinItems FROM tblAuctionBids " & _
"WHERE IID = " & itemID & " ORDER BY WinItems DESC, Time"


rst.open strSQL, strConnectionString
if not rst.eof then
do until rst.eof OR totItems >= intAvailable
Keep a running tally of items distributed
totItems = totItems + rst(2)
If totItems <= intAvailable then This buyer won
Send an email alerting this buyer
call SendWinningEmail(rst(0))
End if
rst.movenext
loop
end if


End Function


This is a pretty simple function. Simply loop through the bids in the correct order (by number of items
won first, and then by date), and alert the buyers that theyve won. Once the number of items bid for gets
higher than the number of items available, every one else loses, and you can stop the loop. I wont go
into the SendWinningEmail() function, but all it does is send the user specified by rst(0) an email that
says theyve won and for how much and how many. (For an example using email, check out this WDVL article.)



    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • WAP常见问题问答大全(四)
    • ASP开发必备:WEB打印代码大全
    • ASP调用系统ping命令
    • asp缓存技术
    • ASP教程:第三篇 ASP基础
    • 用ASP+XML打造留言本(4)
    • 关于ASP Recordset 分页出现负数解决方法及建议
    • 用asp怎样编写文档搜索页面(5)
    • ASP处理多关键词查询实例代码
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1