WechatSendMessageLog.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace common\models\wechat;
  3. use Yii;
  4. /**
  5. * This is the model class for table "qimall_wechat_send_message_log".
  6. *
  7. * @property int $id
  8. * @property int $mall_id 商城ID
  9. * @property int $user_id 会员id
  10. * @property string $openid
  11. * @property string|null $send_data 发送参数
  12. * @property string|null $result_data 返回参数
  13. * @property int $updated_at
  14. * @property int $created_at
  15. */
  16. class WechatSendMessageLog extends \common\models\base\BaseActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return '{{%wechat_send_message_log}}';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['mall_id', 'user_id','updated_at', 'created_at'], 'integer'],
  32. [['openid','send_data', 'result_data'], 'string'],
  33. ];
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function attributeLabels()
  39. {
  40. return [
  41. 'id' => 'ID',
  42. 'mall_id' => '商城ID',
  43. 'user_id' => '会员id',
  44. 'openid' => 'openid',
  45. 'send_data' => '发送参数',
  46. 'result_data' => '返回参数',
  47. 'updated_at' => 'Updated At',
  48. 'created_at' => 'Created At',
  49. ];
  50. }
  51. public static function add(array $params)
  52. {
  53. try {
  54. $model = new self();
  55. $model->loadDefaultValues();
  56. if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
  57. return $model;
  58. } catch (\Exception $e) {
  59. self::$static_error = $e->getMessage();
  60. return false;
  61. }
  62. }
  63. }