SeckillActivityOrderLog.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use yii\behaviors\TimestampBehavior;
  9. use yii\db\ActiveRecord;
  10. /**
  11. * This is the model class for table "{{%seckill_activity_order_log}}".
  12. *
  13. * @property integer $id
  14. * @property integer $order_id
  15. * @property integer $order_detail_id
  16. * @property integer $user_id
  17. * @property float $sale_price
  18. * @property integer $activity_id
  19. * @property integer $activity_goods_id
  20. * @property integer $num
  21. * @property integer $created_at
  22. * @property integer $updated_at
  23. * @property integer $is_delete
  24. * @property integer $store_id
  25. * @property integer $goods_id
  26. */
  27. class SeckillActivityOrderLog extends \yii\db\ActiveRecord
  28. {
  29. /**
  30. * @inheritdoc
  31. */
  32. public static function tableName()
  33. {
  34. return '{{%seckill_activity_order_log}}';
  35. }
  36. public function behaviors()
  37. {
  38. return [
  39. [
  40. 'class' => TimestampBehavior::class,
  41. 'attributes' => [
  42. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  43. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
  44. ]
  45. ]
  46. ];
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. public function rules()
  52. {
  53. return [
  54. [['id', 'order_id', 'order_detail_id', 'store_id', 'is_delete', 'activity_id', 'activity_goods_id', 'user_id', 'num', 'goods_id'], 'integer'],
  55. [['sale_price'], 'number'],
  56. [['created_at', 'updated_at'], 'safe']
  57. ];
  58. }
  59. /**
  60. * @inheritdoc
  61. */
  62. public function attributeLabels()
  63. {
  64. return [
  65. 'id' => 'ID',
  66. 'order_id' => '订单ID',
  67. 'order_detail_id' => '订单详情ID',
  68. 'user_id' => '用户ID',
  69. 'sale_price' => '销售金额',
  70. 'activity_id' => '活动ID',
  71. 'activity_goods_id' => '活动商品ID',
  72. 'num' => '购买数量',
  73. 'created_at' => '创建时间',
  74. 'updated_at' => '修改时间',
  75. 'is_delete' => '是否删除',
  76. 'store_id' => '商城ID',
  77. 'goods_id' => '商品id'
  78. ];
  79. }
  80. public function afterSave($insert, $changedAttributes)
  81. {
  82. parent::afterSave($insert, $changedAttributes);
  83. if($insert){
  84. (new \app\utils\OrderUtil())->seckillActivityOrder($this);
  85. }
  86. }
  87. }