test_lgq/niucloud/app/model/order/RechargeOrderItem.php
2024-01-24 17:36:08 +08:00

67 lines
1.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\order;
use core\base\BaseModel;
use think\model\relation\HasOne;
/**
* 订单项目模型
* Class OrderItem
* @package app\model\order
*/
class RechargeOrderItem extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'order_item_id';
/**
* 模型名称
* @var string
*/
protected $name = 'recharge_order_item';
/**
* @return HasOne
*/
public function orderNo()
{
return $this->hasOne(RechargeOrder::class, 'order_id', 'order_id')->joinType('left')->withField('order_id, order_no')->bind(['order_no' => 'order_no']);
}
/**
* 数量字段处理
* @param $value
* @param $data
* @return string|void
*/
public function getNumAttr($value, $data)
{
if (isset($data['num'])) {
return number_format($data['num']);
}
}
/**
* 关联订单主表
* @return HasOne
*/
public function ordermain()
{
return $this->hasOne(RechargeOrder::class, 'order_id')->joinType('inner');
}
}