<?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();
|
}
|
}
|