Evaluate.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace addons\TinyShop\common\models\product;
  3. use common\models\member\Member;
  4. use addons\TinyShop\common\models\order\Order;
  5. use addons\TinyShop\common\models\order\OrderProduct;
  6. /**
  7. * This is the model class for table "{{%addon_tiny_shop_product_evaluate}}".
  8. *
  9. * @property int $id 评价ID
  10. * @property int $merchant_id 商户id
  11. * @property int|null $order_id 订单ID
  12. * @property string|null $order_sn 订单编号
  13. * @property int|null $order_product_id 订单项ID
  14. * @property int|null $product_id 商品ID
  15. * @property string|null $product_name 商品名称
  16. * @property float|null $product_price 商品价格
  17. * @property string|null $product_picture 商品图片
  18. * @property string|null $sku_name sku名称
  19. * @property string $content 评价内容
  20. * @property string|null $covers 评价图片
  21. * @property string|null $video 视频地址
  22. * @property string|null $explain_first 解释内容
  23. * @property int|null $member_id 评价人编号
  24. * @property string|null $member_nickname 评价人名称
  25. * @property string|null $member_head_portrait 头像
  26. * @property int|null $is_anonymous 0表示不是 1表示是匿名评价
  27. * @property int $scores 1-5分
  28. * @property string|null $again_content 追加评价内容
  29. * @property string|null $again_covers 追评评价图片
  30. * @property string|null $again_explain 追加解释内容
  31. * @property int|null $again_addtime 追加评价时间
  32. * @property int|null $explain_type 1好评2中评3差评
  33. * @property int|null $has_again 是否追加 0 否 1 是
  34. * @property int|null $has_content 是否有内容 0 否 1 是
  35. * @property int|null $has_cover 是否有图 0 否 1 是
  36. * @property int|null $has_video 是否视频 0 否 1 是
  37. * @property int|null $is_auto 是否自动评价 0 否 1 是
  38. * @property int|null $status 状态
  39. * @property int $created_at 创建时间
  40. * @property int $updated_at 更新时间
  41. */
  42. class Evaluate extends \common\models\base\BaseModel
  43. {
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public static function tableName()
  48. {
  49. return '{{%addon_tiny_shop_product_evaluate}}';
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function rules()
  55. {
  56. return [
  57. [['merchant_id', 'order_id', 'order_product_id', 'product_id', 'member_id', 'is_anonymous', 'scores', 'again_addtime', 'explain_type', 'has_again', 'has_content', 'has_cover', 'has_video', 'is_auto', 'status', 'created_at', 'updated_at'], 'integer'],
  58. [['product_price'], 'number'],
  59. [['covers', 'again_covers'], 'safe'],
  60. [['scores'], 'required'],
  61. [['order_sn'], 'string', 'max' => 30],
  62. [['product_name', 'member_nickname'], 'string', 'max' => 100],
  63. [['product_picture', 'content', 'video', 'explain_first', 'again_content', 'again_explain'], 'string', 'max' => 255],
  64. [['sku_name'], 'string', 'max' => 50],
  65. [['member_head_portrait'], 'string', 'max' => 150],
  66. ];
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function attributeLabels()
  72. {
  73. return [
  74. 'id' => 'ID',
  75. 'merchant_id' => '商户id',
  76. 'order_id' => '订单ID',
  77. 'order_sn' => '订单编号',
  78. 'order_product_id' => '订单项ID',
  79. 'product_id' => '商品ID',
  80. 'product_name' => '商品名称',
  81. 'product_price' => '商品价格',
  82. 'product_picture' => '商品图片',
  83. 'sku_name' => 'sku名称',
  84. 'content' => '评价内容',
  85. 'covers' => '评价图片',
  86. 'video' => '视频地址',
  87. 'explain_first' => '解释内容',
  88. 'member_id' => '评价人编号',
  89. 'member_nickname' => '评价人名称',
  90. 'member_head_portrait' => '头像',
  91. 'is_anonymous' => '0表示不是 1表示是匿名评价',
  92. 'scores' => '1-5分',
  93. 'again_content' => '追加评价内容',
  94. 'again_covers' => '追评评价图片',
  95. 'again_explain' => '追加解释内容',
  96. 'again_addtime' => '追加评价时间',
  97. 'explain_type' => '1好评2中评3差评',
  98. 'has_again' => '是否追加 0 否 1 是',
  99. 'has_content' => '是否有内容 0 否 1 是',
  100. 'has_cover' => '是否有图 0 否 1 是',
  101. 'has_video' => '是否视频 0 否 1 是',
  102. 'is_auto' => '是否自动评价 0 否 1 是',
  103. 'status' => '状态',
  104. 'created_at' => '创建时间',
  105. 'updated_at' => '更新时间',
  106. ];
  107. }
  108. /**
  109. * 关联订单
  110. *
  111. * @return \yii\db\ActiveQuery
  112. */
  113. public function getOrder()
  114. {
  115. return $this->hasOne(Order::class, ['id' => 'order_id']);
  116. }
  117. /**
  118. * 用户
  119. *
  120. * @return \yii\db\ActiveQuery
  121. */
  122. public function getMember()
  123. {
  124. return $this->hasOne(Member::class, ['id' => 'member_id'])->select([
  125. 'id',
  126. 'nickname',
  127. 'head_portrait',
  128. 'type',
  129. ]);
  130. }
  131. /**
  132. * 关联商品
  133. *
  134. * @return \yii\db\ActiveQuery
  135. */
  136. public function getProduct()
  137. {
  138. return $this->hasOne(Product::class, ['id' => 'product_id']);
  139. }
  140. /**
  141. * 关联订单商品
  142. *
  143. * @return \yii\db\ActiveQuery
  144. */
  145. public function getOrderProduct()
  146. {
  147. return $this->hasOne(OrderProduct::class, ['id' => 'order_product_id']);
  148. }
  149. }
粤ICP备19079148号