發(fā)布時間:2019-03-10
欄目:其他
//現(xiàn)在初始化里面定義后邊要使用的redis參數(shù)
public function_initialize(){
PHPweb批量更新文章parent::_initialize();
$goods_id = I("goods_id",'0','intval');
if($goods_id){
$this->goods_id = $goods_id;
$this->user_queue_key = "goods_".$goods_id."_user";//當(dāng)前商品隊列的用戶情況
$this->goods_number_key = "goods".$goods_id;//當(dāng)前商品的庫存隊列
}
$this->user_id = $this->user_id ? $this->user_id : $_SESSION['uid'];
}
2.4. 第二步就是關(guān)鍵所在機製性梗阻,用戶在進入商品詳情頁前先將當(dāng)前商品的庫存進行隊列存入redis如下:
* 訪問產(chǎn)品前先將當(dāng)前產(chǎn)品庫存隊列
* @access public
* @author bieanju
*/
publicfunction_before_detail(){
$where['goods_id'] = $this->goods_id;
$where['start_time'] = array("lt"PHPweb批量添加產(chǎn)品,time());
$where['end_time'] = array("gt",time());
$goods= M("goods")->where($where)->field('goods_num,start_timePHPweb批量刪除關(guān)鍵詞 ,end_time')->find();
!$goods&& $this->error("當(dāng)前秒殺已結(jié)束PHPweb批量上傳內(nèi)容 機製!");
if($goods['goods_num'] > $goods['order_num']){
$redis= $this->connectRedis();
$getUserRedis= $redis->hGetAll("{$this->user_queue_key}");
$gnRedis= $redis->llen("{$this->goods_number_key}");
/* 如果沒有會員進來隊列庫存 */
if(!count($getUserRedis) && !$gnRedis){
for($i= 0; $i< $goods['goods_num']; $i++) {
$redis->lpush("{$this->goods_number_key}"PHPweb批量助手 , 1);
}
}
$resetRedis= $redis->llen("{$this->goods_number_key}");
if(!$resetRedis){
$this->error("系統(tǒng)繁忙,請稍后搶購PHPweb批量添加欄目集成應用!");
}
}else{
$this->error("當(dāng)前產(chǎn)品已經(jīng)秒殺完探討!");
}
}
接下來要做的就是用ajax來異步的處理用戶點擊購買按鈕進行符合條件的數(shù)據(jù)進入購買的排隊隊列(如果當(dāng)前用戶沒在當(dāng)前產(chǎn)品用戶的隊列就進入排隊并且pop一個庫存隊列,如果在就拋出高效流通,):
下一篇:留住用戶合規意識,比拉新更重要
文章地址:http://61py.com/article/other/xzcshlmdyhbysydrediscs.html