1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2018/1/5
- * Time: 下午8:00
- */
- class room_bargainModel extends Model
- {
- public function __construct() {
- parent::__construct('room_bargain');
- }
- public function create($roomid,$userid,$goods_id,$goods_price,$cost_price,$lowest_price,$days)
- {
- $params = ['room_id' => $roomid,'user_id' => $userid,'goods_id' => $goods_id,
- 'goods_price' => $goods_price,'cost_price' => $cost_price,'lowest_price' => $lowest_price,
- 'add_time' => time(),'over_time' => time() + 86400 * $days];
- 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();
- }
- }
|