quanwei
2025-12-09 ca425b889f3c1b5847ffc26a0229307f7f8ef43e
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
41
42
43
44
45
<?php
 
namespace app\common\model\order;
 
 
use app\common\model\BaseModel;
 
/**
 * Class OrderTrade
 */
class OrderTrade extends BaseModel
{
    protected $name = 'order_trade';
    protected $pk = 'id';
 
    /**
     * 关联订单表
     */
    public function orderList()
    {
        return $this->hasMany('app\\common\\model\\order\\Order', 'order_id', 'order_id');
    }
 
    /**
     * 详情
     */
    public static function detail($where, $with = [])
    {
        is_array($where) ? $filter = $where : $filter['id'] = (int)$where;
        return (new static())->with($with)->where($filter)->find();
    }
 
    /**
     * 详情
     */
    public static function detailWithOrder($where)
    {
        $list = (new static())->where($where)->select();
        $orderList = [];
        foreach ($list as $trade){
            array_push($orderList, Order::detail($trade['order_id']));
        }
        return $orderList;
    }
}