CommunityNotice.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace addons\Community\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "qimall_addons_community_notice".
  6. *
  7. * @property int $id
  8. * @property int $mall_id Mall ID
  9. * @property int $status 状态 [1启用 0禁用 -1删除]
  10. * @property int $created_at 创建时间
  11. * @property int $updated_at 更新时间
  12. * @property int $user_id 用户ID
  13. * @property int $send_at 发送时间
  14. * @property array|null $content 发送内容
  15. * @property array|null $res 响应内容
  16. * @property string $mobile 接收号码
  17. * @property string $area_code 接收号码
  18. * @property string $gateway 接收号码
  19. */
  20. class CommunityNotice extends \common\models\base\BaseActiveRecord
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function tableName()
  26. {
  27. return 'qimall_addons_community_notice';
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function rules()
  33. {
  34. return [
  35. [['mall_id', 'status', 'created_at', 'updated_at', 'user_id', 'send_at'], 'integer'],
  36. [['content', 'res'], 'safe'],
  37. [['mobile', 'gateway'], 'string', 'max' => 20],
  38. [['area_code'], 'string', 'max' => 10],
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'ID',
  48. 'mall_id' => 'Mall ID',
  49. 'status' => 'Status',
  50. 'created_at' => 'Created At',
  51. 'updated_at' => 'Updated At',
  52. 'user_id' => 'User ID',
  53. 'send_at' => 'Send At',
  54. 'content' => 'Content',
  55. 'res' => 'Res',
  56. 'mobile' => 'Mobile',
  57. ];
  58. }
  59. /**
  60. * @param int $mall_id
  61. * @param int $user_id
  62. * @param string $gateway
  63. * @param string $area_code
  64. * @param string $mobile
  65. * @param int $send_at
  66. * @param array $content
  67. * @return true
  68. * @throws \Exception
  69. */
  70. public static function setData(int $mall_id, int $user_id, string $gateway, string $area_code, string $mobile, int $send_at, array $content)
  71. {
  72. $model = new self();
  73. $model->mall_id = $mall_id;
  74. $model->user_id = $user_id;
  75. $model->mobile = $mobile;
  76. $model->send_at = $send_at;
  77. $model->content = $content;
  78. $model->gateway = $gateway;
  79. $model->area_code = $area_code;
  80. if (!$model->save()) throw new \Exception($model->getErrorMessage());
  81. return true;
  82. }
  83. }