ReservationServiceNotice.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace addons\ReservationService\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "qimall_addons_reservation_service_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 string|null $content 发送内容
  15. * @property string|null $res 响应内容
  16. * @property string $mobile 接收号码
  17. * @property string $area_code 区号
  18. * @property string $gateway 网关
  19. */
  20. class ReservationServiceNotice extends \common\models\base\BaseActiveRecord
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function tableName()
  26. {
  27. return 'qimall_addons_reservation_service_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. 'area_code' => 'Area Code',
  58. 'gateway' => 'Gateway',
  59. ];
  60. }
  61. /**
  62. * @param int $mall_id
  63. * @param int $user_id
  64. * @param string $gateway
  65. * @param string $area_code
  66. * @param string $mobile
  67. * @param int $send_at
  68. * @param array $content
  69. * @return true
  70. * @throws \Exception
  71. */
  72. public static function setData(int $mall_id, int $user_id, string $gateway, string $area_code, string $mobile, int $send_at, array $content)
  73. {
  74. $model = new self();
  75. $model->mall_id = $mall_id;
  76. $model->user_id = $user_id;
  77. $model->mobile = $mobile;
  78. $model->send_at = $send_at;
  79. $model->content = $content;
  80. $model->gateway = $gateway;
  81. $model->area_code = $area_code;
  82. if (!$model->save()) throw new \Exception($model->getErrorMessage());
  83. return true;
  84. }
  85. }