quanwei
2025-12-10 898043fc97d2ab8b793fd317a049b874ed207c6d
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
<?php
namespace app\common\model\plus\business;
 
use app\common\model\BaseModel;
use app\common\service\order\OrderService;
use app\common\enum\order\OrderPayStatusEnum;
use app\common\enum\order\OrderPayTypeEnum;
use app\api\service\order\PaymentService;
use app\common\enum\order\OrderTypeEnum;
 
/**
 * 名片订单模型
 */
class Order extends BaseModel
{
    protected $name = 'business_card_order';
    
    /**
     * 关联用户表
     */
    public function user()
    {
        return $this->belongsTo('app\\common\\model\\user\\User', 'user_id', 'user_id');
    }
    
    /**
     * 关联名片表
     */
    public function businessCard()
    {
        return $this->belongsTo('app\\common\\model\\plus\\business\\Business', 'business_card_id', 'business_card_id');
    }
    
    /**
     * 关联名片等级表
     */
    public function grade()
    {
        return $this->belongsTo('app\\common\\model\\plus\\business\\Grade', 'grade_id', 'grade_id');
    }
    
    /**
     * 生成订单号
     */
    public function orderNo()
    {
        return OrderService::createOrderNo();
    }
    
    /**
     * 获取订单支付详情
     */
    public static function getPayDetail($orderNo)
    {
        return (new static())->with(['user', 'businessCard', 'grade'])->where(['order_no' => $orderNo])->find();
    }
}