HappinessVoucherGoods.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace addons\Happiness\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "qimall_addons_happiness_voucher_goods".
  6. *
  7. * @property int $id
  8. * @property int $order_id 提货订单ID
  9. * @property int $goods_id 商品ID
  10. * @property int $attr_id 规格ID
  11. * @property int $num 提货数量
  12. * @property int $leave_num 剩余提货数量
  13. * @property int $mall_id 商城ID
  14. * @property float|null voucher 提货券
  15. * @property int|null label_id 提货类别
  16. * @property int $status
  17. * @property int $created_at
  18. * @property int $updated_at
  19. */
  20. class HappinessVoucherGoods extends \common\models\base\BaseActiveRecord
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function tableName()
  26. {
  27. return 'qimall_addons_happiness_voucher_goods';
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function rules()
  33. {
  34. return [
  35. [['order_id', 'goods_id', 'attr_id', 'num', 'leave_num', 'mall_id','label_id', 'status', 'created_at', 'updated_at'], 'integer'],
  36. [['voucher'], 'number'],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'order_id' => 'Order ID',
  47. 'goods_id' => 'Goods ID',
  48. 'attr_id' => 'Attr ID',
  49. 'num' => 'Num',
  50. 'leave_num' => 'Leave Num',
  51. 'mall_id' => 'Mall ID',
  52. 'status' => 'Status',
  53. 'voucher' => 'Voucher',
  54. 'label_id' => 'Label ID',
  55. 'created_at' => 'Created At',
  56. 'updated_at' => 'Updated At',
  57. ];
  58. }
  59. public static function setData(array $params)
  60. {
  61. try {
  62. if(isset($params['id']) && !empty($params['id']))
  63. $model = self::findOne($params['id']);
  64. else {
  65. $model = new self();
  66. $model->loadDefaultValues();
  67. }
  68. if(!$model)
  69. {
  70. $model = new self();
  71. $model->loadDefaultValues();
  72. }
  73. if (!$model->load($params, '') || !$model->save()) {
  74. throw new \Exception($model->getErrorMessage());
  75. }
  76. return $model;
  77. } catch (\Exception $e) {
  78. self::$static_error = $e->getMessage();
  79. return false;
  80. }
  81. }
  82. }