BlindBoxNotice.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace addons\BlindBox\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_blind_box_notice".
  7. *
  8. * @property int $id
  9. * @property int $mall_id 商城id
  10. * @property int $user_id 会员id
  11. * @property string $content 内容
  12. * @property int $status 状态[-1:删除;0:禁用;1启用]
  13. * @property int $created_at
  14. * @property int $updated_at
  15. */
  16. class BlindBoxNotice extends BaseActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return '{{%addons_blind_box_notice}}';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['id'], 'required'],
  32. [['id', 'mall_id', 'user_id', 'status', 'created_at', 'updated_at'], 'integer'],
  33. [['content'], 'string', 'max' => 1000],
  34. [['id'], 'unique'],
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'ID',
  44. 'mall_id' => '商城id',
  45. 'user_id' => '会员id',
  46. 'content' => '内容',
  47. 'status' => '状态[-1:删除;0:禁用;1启用]',
  48. 'created_at' => 'Created At',
  49. 'updated_at' => 'Updated At',
  50. ];
  51. }
  52. public static function setData($insert)
  53. {
  54. try {
  55. $field = ['mall_id', 'user_id', 'content', 'status', 'created_at', 'updated_at'];
  56. // 批量插入数据
  57. Yii::$app->db->createCommand()->batchInsert(self::tableName(), $field, $insert)->execute();
  58. return true;
  59. } catch (\Exception $e) {
  60. self::$static_error = $e->getMessage();
  61. return false;
  62. }
  63. }
  64. }