12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\common\model;
- use think\Db;
- use think\Exception;
- use think\Model;
- use Yansongda\Pay\Exceptions\GatewayException;
- use addons\epay\library\Service;
- use app\common\model\OrderAction;
- use app\common\model\TemplateMsg;
- use traits\model\SoftDelete;
- use app\common\Enum\OrderEnum;
- use app\common\Traits\OrderStatusTrait;
- /**
- * 订单模型
- * @property mixed $address 订单地址信息(动态属性)
- */
- class Order extends Model
- {
- use SoftDelete;
- use OrderStatusTrait;
- // 表名
- protected $name = 'shop_order';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = 'deletetime';
- // 追加属性
- // protected $append = [
- // 'order_status_text',
- // ];
- protected static $tagCount = 0;
- // public function getOrderStatusTextAttr($value, $data)
- // {
- // return OrderEnum::getOrderStatusText($data['order_status']);
- // }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function address()
- {
- return $this->belongsTo('Address', 'address_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function orderGoods()
- {
- return $this->hasMany('OrderGoods', 'order_sn', 'order_sn');
- }
- public function orderElectronics()
- {
- return $this->hasMany('OrderElectronics', 'order_sn', 'order_sn');
- }
- public function orderAction()
- {
- return $this->hasMany('OrderAction', 'order_sn', 'order_sn');
- }
- public function orderAddress()
- {
- return $this->hasOne('OrderAddress', 'order_id', 'id');
- }
- public function orderProfile()
- {
- return $this->hasOne('OrderProfile', 'order_id', 'id');
- }
- }
|