$roomid,'user_id' => $userid,'goods_id' => $goods_id,'type' => $type,'total_num' => $total_num, 'goods_price' => $goods_price,'lowest_price' => $lowest_price, 'add_time' => time(),'over_time' => time() + 86400 * $days,'closed' => 0]; return $this->insert($params); } public function getBargainById($bargain_id,$lock=false) { return $this->where(['bargain_id' => $bargain_id])->lock($lock)->find(); } public function getBargainByRoom($room_id,$lock=false) { return $this->where(['room_id' => $room_id])->lock($lock)->find(); } public function getBargainByUserGoods($user_id,$goods_id,$lock=false) { return $this->where(['user_id' => $user_id,'goods_id' => $goods_id])->lock($lock)->find(); } public function getBargainByUserGoodIDs($user_id,$goods_ids,$lock=false) { return $this->where(['user_id' => $user_id,'goods_id' => ['in',$goods_ids]])->lock($lock)->select(); } public function getBargainList($condition, $field = '*', $page = 0 , $order = 'bargain_id desc', $limit = 0) { return $this->where($condition)->field($field)->order($order)->page($page)->limit($limit)->select(); } public function editBargain($bargain_id,$datas) { return $this->where(['bargain_id' => $bargain_id])->update($datas); } public function getBargainNumByUser($user_id) { return $this->where(['user_id' => $user_id,'closed' => 0])->count(); } }