Order.php
921 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace app\api\model;
use think\Model;
class Order extends Model
{
protected $name = 'order';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
// 添加一个订单
public function addOne($data)
{
return $this->insert($data);
}
// 根据条件查询订单
public function listByWhere($where)
{
return $this->where($where)->useSoftDelete($this->deleteTime)->select();
}
// 获取并锁定一个订单
public function infoAndLockById($id)
{
return $this->where(['order_id' => ['=', $id]])->useSoftDelete($this->deleteTime)->find();
}
// 修改一个订单
public function updateOne($id, $data)
{
return $this->where(['id' => ['=', $id]])->update($data);
}
}