OrderDetail.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. /*
  8. * @Author: your name
  9. * @Date: 2021-03-02 09:50:20
  10. * @LastEditTime: 2021-04-29 15:29:26
  11. * @LastEditors: Please set LastEditors
  12. * @Description: In User Settings Edit
  13. * @FilePath: \admin_php\models\OrderDetail.php
  14. */
  15. namespace app\models;
  16. use Yii;
  17. /**
  18. * This is the model class for table "{{%order_detail}}".
  19. *
  20. * @property integer $id
  21. * @property integer $order_id
  22. * @property integer $goods_id
  23. * @property integer $num
  24. * @property string $total_price
  25. * @property integer $created_at
  26. * @property integer $is_delete
  27. * @property string $attr
  28. * @property string $food_ext_goods
  29. * @property string $pic
  30. * @property string $integral
  31. * @property string $coin
  32. * @property string $share_base
  33. * @property string $pv_0
  34. * @property string $pv_1
  35. * @property integer $is_level
  36. * @property string $goods_name
  37. * @property string $goods_info
  38. * @property string $delivery_type
  39. * @property string $shop_id
  40. * @property integer $profit
  41. * @property string $cost_price
  42. * @property string $integral_price
  43. * @property string $product_unique_id
  44. */
  45. class OrderDetail extends \yii\db\ActiveRecord
  46. {
  47. /**
  48. * 类型枚举
  49. * 快递
  50. */
  51. const GOODS_DELIVERY_EXPRESS = 0;
  52. /**
  53. * 类型枚举
  54. * 自提
  55. */
  56. const GOODS_DELIVERY_SHOP = 1;
  57. /**
  58. * 类型枚举
  59. * 同城
  60. */
  61. const GOODS_DELIVERY_IM = 2;
  62. /**
  63. * @inheritdoc
  64. */
  65. public static function tableName()
  66. {
  67. return '{{%order_detail}}';
  68. }
  69. /**
  70. * @inheritdoc
  71. */
  72. public function rules()
  73. {
  74. return [
  75. [['order_id', 'goods_id', 'attr', 'pic'], 'required'],
  76. [['order_id', 'goods_id', 'num', 'created_at', 'is_delete', 'integral', 'is_level', 'delivery_type', 'shop_id','order_transit_id','integral_price'], 'integer'],
  77. [['total_price', 'supplier_price', 'profit','integral_difference_price', 'cost_price', 'coin', 'share_base'], 'number'],
  78. [['attr', 'food_ext_goods', 'goods_info', 'product_unique_id'], 'string'],
  79. [['pic','batch_price_tips', 'goods_name'], 'string', 'max' => 255],
  80. ];
  81. }
  82. /**
  83. * @inheritdoc
  84. */
  85. public function attributeLabels()
  86. {
  87. return [
  88. 'id' => 'ID',
  89. 'order_id' => 'Order ID',
  90. 'goods_id' => 'Goods ID',
  91. 'num' => '商品数量',
  92. 'total_price' => '此商品的总价',
  93. 'integral_price' => '销售积分',
  94. 'integral_difference_price' => '积分差额',
  95. 'created_at' => 'Addtime',
  96. 'is_delete' => 'Is Delete',
  97. 'attr' => '商品规格',
  98. 'pic' => '商品规格图片',
  99. 'integral' => '获取积分',
  100. 'coin' => '贡献积分',
  101. 'share_base' => '固定基数',
  102. 'is_level' => '会员折扣',
  103. 'batch_price_tips' => '满减价格提示',
  104. 'supplier_price' => '供货商进价',
  105. 'goods_name' => '商品名称',
  106. 'goods_info' => '商品快照',
  107. 'delivery_type' => '配送方式,0:快递,1:自提',
  108. 'shop_id' => '自提点id,默认:0',
  109. 'order_transit_id' => '云仓转单id',
  110. "cost_price" => '成本价'
  111. ];
  112. }
  113. public function afterSave($insert, $changedAttributes)
  114. {
  115. parent::afterSave($insert, $changedAttributes);
  116. BookingOrderExt::afterOrderDetailSave($insert, $changedAttributes, $this);
  117. \app\modules\admin\models\erp\InventoryForm::afterOrderDetailSave($this);
  118. \app\modules\admin\models\ActivityOrderRebateSelfForm::afterOrderDetailSave($this);
  119. }
  120. public function getGoods()
  121. {
  122. return $this->hasOne(Goods::className(), ['id'=>'goods_id']);
  123. }
  124. public function getOrder() {
  125. return $this->hasOne(Order::className(), ['id' => 'order_id']);
  126. }
  127. }