MassRecord.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace addons\Wechat\common\models;
  3. use yii\db\ActiveQuery;
  4. use common\helpers\StringHelper;
  5. use common\behaviors\MerchantStoreBehavior;
  6. use common\models\base\BaseModel;
  7. /**
  8. * This is the model class for table "{{%addon_wechat_mass_record}}".
  9. *
  10. * @property int $id
  11. * @property int|null $merchant_id 商户id
  12. * @property int|null $store_id 店铺ID
  13. * @property int|null $msg_id 微信消息id
  14. * @property string|null $msg_data_id 图文消息数据id
  15. * @property int|null $tag_id 标签id
  16. * @property string|null $tag_name 标签名称
  17. * @property int|null $fans_num 粉丝数量
  18. * @property string|null $module 模块类型
  19. * @property string|null $data
  20. * @property int|null $send_type 发送类别 1立即发送2定时发送
  21. * @property int|null $send_time 发送时间
  22. * @property int|null $send_status 0未发送 1已发送
  23. * @property int|null $final_send_time 最终发送时间
  24. * @property string|null $error_content 报错原因
  25. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  26. * @property int|null $created_at
  27. * @property int $updated_at 修改时间
  28. */
  29. class MassRecord extends BaseModel
  30. {
  31. use MerchantStoreBehavior;
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public static function tableName()
  36. {
  37. return '{{%addon_wechat_mass_record}}';
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function rules()
  43. {
  44. return [
  45. [['tag_id'], 'required'],
  46. [
  47. [
  48. 'merchant_id',
  49. 'store_id',
  50. 'msg_id',
  51. 'tag_id',
  52. 'fans_num',
  53. 'send_type',
  54. 'send_status',
  55. 'final_send_time',
  56. 'status',
  57. 'created_at',
  58. 'updated_at',
  59. ],
  60. 'integer',
  61. ],
  62. [['data', 'error_content'], 'string'],
  63. [['msg_data_id'], 'string', 'max' => 10],
  64. [['tag_name', 'module'], 'string', 'max' => 50],
  65. [['send_time'], 'safe'],
  66. ];
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function attributeLabels()
  72. {
  73. return [
  74. 'id' => 'ID',
  75. 'merchant_id' => '商户id',
  76. 'store_id' => '店铺ID',
  77. 'msg_id' => '微信消息id',
  78. 'msg_data_id' => '图文消息数据id',
  79. 'tag_id' => '标签',
  80. 'tag_name' => '标签名称',
  81. 'fans_num' => '粉丝数量',
  82. 'module' => '模块类型',
  83. 'data' => 'Data',
  84. 'send_type' => '发送类别 1立即发送2定时发送',
  85. 'send_time' => '发送时间',
  86. 'send_status' => '0未发送 1已发送',
  87. 'final_send_time' => '最终发送时间',
  88. 'error_content' => '报错原因',
  89. 'status' => '状态[-1:删除;0:禁用;1启用]',
  90. 'created_at' => 'Created At',
  91. 'updated_at' => '修改时间',
  92. ];
  93. }
  94. /**
  95. * @return ActiveQuery
  96. */
  97. public function getAttachment()
  98. {
  99. return $this->hasOne(Attachment::class, ['id' => 'data']);
  100. }
  101. public function beforeSave($insert)
  102. {
  103. $this->send_time = StringHelper::dateToInt($this->send_time);
  104. return parent::beforeSave($insert);
  105. }
  106. }
粤ICP备19079148号