OrderInvoice.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. use yii\db\ActiveRecord;
  11. /**
  12. * This is the model class for table "{{%order_invoice}}".
  13. *
  14. * @property integer $id
  15. */
  16. class OrderInvoice extends \yii\db\ActiveRecord
  17. {
  18. const STATUS_DEFAULT = 0;//待开票
  19. const STATUS_FINISH = 1;//已开票
  20. const STATUS_REJECT = 2;//已拒绝
  21. /**
  22. * @inheritdoc
  23. */
  24. public static function tableName()
  25. {
  26. return '{{%order_invoice}}';
  27. }
  28. public function behaviors()
  29. {
  30. return [
  31. [
  32. 'class' => TimestampBehavior::class,
  33. ]
  34. ];
  35. }
  36. public function afterSave($insert, $changedAttributes)
  37. {
  38. if($insert){
  39. SaasUserInvoiceConf::saveOrderInvoiceConf($this);
  40. }
  41. }
  42. public function getOrder()
  43. {
  44. return $this->hasOne(Order::className(), ['id' => 'order_id']);
  45. }
  46. public function getUser()
  47. {
  48. return $this->hasOne(User::className(), ['id'=>'user_id']);
  49. }
  50. }