Order.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model\recharge;
  13. use app\common\model\BaseModel;
  14. /**
  15. * 用户充值订单模型
  16. * Class Order
  17. * @package app\common\model\recharge
  18. */
  19. class Order extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'recharge_order';
  23. // 定义主键
  24. protected $pk = 'order_id';
  25. /**
  26. * 关联会员记录表
  27. * @return \think\model\relation\BelongsTo
  28. */
  29. public function user()
  30. {
  31. $module = self::getCalledModule();
  32. return $this->belongsTo("app\\{$module}\\model\\User");
  33. }
  34. /**
  35. * 关联订单套餐快照表
  36. * @return \think\model\relation\HasOne
  37. */
  38. public function orderPlan()
  39. {
  40. return $this->hasOne('OrderPlan', 'order_id');
  41. }
  42. /**
  43. * 付款时间
  44. * @param $value
  45. * @return array
  46. */
  47. public function getPayTimeAttr($value)
  48. {
  49. return format_time($value);
  50. }
  51. /**
  52. * 获取订单详情
  53. * @param $where
  54. * @return array|null|\think\Model
  55. */
  56. public static function detail($where)
  57. {
  58. return static::get($where);
  59. }
  60. }