pktsandy | 发表于:10-10-13 11:54 11楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
数据库的变化.就我测试
![]() |
pktsandy | 发表于:10-10-13 12:02 12楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
秒杀时刻
![]() 我的电脑时钟: ![]() |
pktsandy | 发表于:10-10-13 12:05 13楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
下午再修正一下就完成了前台
![]() |
pktsandy | 发表于:10-10-13 15:31 14楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
完美的秒杀测试:
临时表: ![]() 正表记录: ![]() 测试结果: ![]() |
pktsandy | 发表于:10-10-13 16:04 15楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
前台收工了!放出代码有高手过过眼!帮我瞧一瞧:
function king_secondbuy(){ global $king; $king->Load('user'); $user=$king->user->access(); //验证 //用户资料是否完整 $res=$king->db->getRows_one("select gid,realname,usertel,useraddress from %s_user where userid='".$user['userid']."' and isdelete=0"); if(!empty($res['realname']) && !empty($res['usertel']) && !empty($res['useraddress'])){ //是否为合理的秒产产品:现在的时间>开始时间<结束时间 $category=((int)kc_get('CID',2,0)!=1)?1:(int)kc_get('CID',2,0); $productID=(int)kc_get('PID',2,1); $serial=($res['gid']==2)?'':kc_random(16); $group=((int)$res['gid']===2)?"vip会员":"普通会员"; $res=$king->db->getRows_one("select unix_timestamp(k_nfinish)as finidate,ktitle,nprice from %s__shop where kid=".$productID." and localtimestamp() BETWEEN k_nstart AND k_nfinish"); if(empty($res)) kc_error($king->lang->get('portal/groupbuy/buyrang')); //活动结束了 $currdate=time(); //当前 $finidate=$res['finidate']; //结束时间 $title=$res['ktitle']; $price=$res['nprice']; $array=array( 'usergroup'=>$group, 'nprice'=>$price, 'userid'=>$user['userid'], 'username'=>$user['username'], 'ktitle'=>$title, 'productID'=>$productID, 'nip'=>kc_getip(), 'ndate'=>$currdate, 'serial'=>$serial, ); //临时表是否存在 $tmptab="temp".$productID; $sql="select ndate from %s__".$tmptab." order by sbid desc limit 1"; $res=$king->db->getRows_one($sql); if(!$res || empty($res)){ //创建临时表 $sql="usergroup char(10) NOT NULL, nprice real not null default 0, userid int(11) NOT NULL DEFAULT 0, username char(15) NOT NULL DEFAULT '', ktitle varchar(100) DEFAULT NULL, productID int(11) NOT NULL DEFAULT 0, nip int(10) NOT NULL DEFAULT 0, ndate int(10) NOT NULL DEFAULT 0, serial varchar(20) DEFAULT NULL"; $king->db->createTable("%s__{$tmptab}",$sql,'sbid'); //第一位参与者 } //写到临时表 $king->db->insert('%s__'.$tmptab,$array); //作临界点判断 if($finidate-$currdate<=1){ //取当前的.0,1 //提到表中 $array=array( 'usergroup'=>$group, 'nprice'=>$price, 'userid'=>$user['userid'], 'username'=>$user['username'], 'ktitle'=>$title, 'productID'=>$productID, 'nip'=>kc_getip(), 'ndate'=>time(), 'serial'=>$serial, 'category'=>$category, 'nstatus'=>0, ); //先入为主 $res=$king->db>getRows_one("select count(gb.userid)as number from %s_groupbuy gb join %s__shop s on gb.productID=s.kid where gb.category=".$category." and s.kid=".$productID." and unix_timestamp(s.k_nfinish)-gb.ndate<=1"); if($res['number']==0) $king->db->insert('%s_groupbuy',$array); //删除临时表 } $goto=$king->config('inst').'index.php'; //pktsandy code $stitle=$king->lang->get('portal/groupbuy/newbuy'); $s.=kc_htm_ol($king->lang->get('portal/groupbuy/sbaccess'),'',$goto); }else{ $stitle=$king->lang->get('portal/groupbuy/gbalert'); $s=$king->lang->get('portal/groupbuy/reqmore'); } $tmp=new KC_Template_class($king->config('templateuser','user'),$king->config('templatepath').'/inside/user/login.htm'); $tmp->assign('title',$stitle); $tmp->assign('main',$s); echo $tmp->output(); } |
z | 发表于:10-10-13 16:14 编辑于:10-13 16:14 16楼 [回复] #Top# |
---|---|
![]() ![]() ![]() |
虽然看不懂,但是也得支持下。估计应该能打包成模块形式,然后让安装好KingCMS PHP版的用户能导入?
|
aaaaab1 | 发表于:10-10-13 18:25 17楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() |
懂点皮毛 只能过眼 做个记号
谢谢pktsandy 向你学习 |
pktsandy | 发表于:10-10-14 10:29 18楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
pktsandy | 发表于:10-10-14 10:29 19楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
pktsandy | 发表于:10-10-14 10:30 20楼 [回复] #Top# |
---|---|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |