CommunityHeadOrder.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace addons\Community\common\models;
  3. use common\models\order\Order;
  4. use common\models\user\User;
  5. use Yii;
  6. use yii\db\ActiveQuery;
  7. /**
  8. * This is the model class for table "qimall_addons_community_head_order".
  9. *
  10. * @property int $id 主键
  11. * @property int $status 状态[-1:删除;0:禁用;1启用]
  12. * @property int $created_at 创建时间
  13. * @property int $updated_at 修改时间
  14. * @property int $mall_id 所属商城
  15. * @property int $user_id 团长ID
  16. * @property int $head_id 自提点ID
  17. * @property int $order_id 订单ID
  18. * @property int $buyer_user_id 买家ID
  19. * @property int $order_status 买家ID
  20. * @property string $order_no 买家ID
  21. */
  22. class CommunityHeadOrder extends \common\models\base\BaseActiveRecord
  23. {
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public static function tableName()
  28. {
  29. return 'qimall_addons_community_head_order';
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function rules()
  35. {
  36. return [
  37. [['status', 'created_at', 'updated_at', 'mall_id', 'user_id', 'head_id', 'order_id', 'buyer_user_id', 'order_status'], 'integer'],
  38. [['order_no'], 'string', 'max' => 30]
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'ID',
  48. 'status' => 'Status',
  49. 'created_at' => 'Created At',
  50. 'updated_at' => 'Updated At',
  51. 'mall_id' => 'Mall ID',
  52. 'user_id' => 'User ID',
  53. 'head_id' => 'Head ID',
  54. 'order_id' => 'Order ID',
  55. 'buyer_user_id' => 'Buyer User ID',
  56. ];
  57. }
  58. /**
  59. * @return ActiveQuery
  60. */
  61. public function getOrder(): ActiveQuery
  62. {
  63. return $this->hasOne(Order::class, ['id' => 'order_id']);
  64. }
  65. /**
  66. * @return ActiveQuery
  67. */
  68. public function getHead(): ActiveQuery
  69. {
  70. return $this->hasOne(CommunityHead::class, ['id' => 'head_id']);
  71. }
  72. /**
  73. * @return ActiveQuery
  74. */
  75. public function getHeadUser(): ActiveQuery
  76. {
  77. return $this->hasOne(User::class, ['id' => 'user_id'])->select('id, avatar_url, mobile, nickname');
  78. }
  79. /**
  80. * @return ActiveQuery
  81. */
  82. public function getBuyer(): ActiveQuery
  83. {
  84. return $this->hasOne(User::class, ['id' => 'buyer_user_id'])->select('id, avatar_url, mobile, nickname');
  85. }
  86. }