quanwei
2026-01-17 e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
 
namespace app\common\model\supplier\member;
 
use app\common\model\BaseModel;
 
/**
 * 供应商年卡订单模型
 * 记录供应商购买年卡的订单信息
 */
class Order extends BaseModel
{
    // 表名
    protected $name = 'supplier_member_order';
 
    protected $pk = 'order_id';
 
    /**
     * 关联供应商表
     */
    public function supplier()
    {
        return $this->belongsTo('app\common\model\supplier\Supplier', 'shop_supplier_id', 'shop_supplier_id');
    }
 
    /**
     * 关联年卡计划表
     */
    public function plan()
    {
        return $this->belongsTo('app\common\model\supplier\member\Plan', 'plan_id', 'plan_id');
    }
    
    /**
     * 获取列表
     */
    public function getList($data)
    {
        $model = $this;
        if (!empty($data['order_no'])) {
            $model = $model->where('order_no', '=', $data['order_no']);
        }
        if (isset($data['pay_status']) && $data['pay_status'] >= 0) {
            $model = $model->where('pay_status', '=', $data['pay_status']);
        }
        return $model->where('app_id', '=', $data['app_id'])
            ->with(['supplier'])
            ->order(['create_time' => 'desc'])
            ->paginate($data);
    }
    
    /**
     * 获取订单详情
     */
    public static function detail($orderId)
    {
        return (new static())->where('order_id', '=', $orderId)->find();
    }
    
    /**
     * 获取订单支付详情
     */
    public static function getPayDetail($orderNo)
    {
        return (new static())->where(['order_no' => $orderNo])->find();
    }
}