UnlockOrder.php 1.9 KB

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