HappinessVoucherExpressGoods.php 2.3 KB

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