HappinessVoucherExpress.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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".
  6. *
  7. * @property int $id
  8. * @property int $order_id 提货订单ID
  9. * @property string $order_no 提货订单号
  10. * @property string $express_no 物流单号
  11. * @property string $express_company 物流公司
  12. * @property int $status
  13. * @property int $get_status 提货状态:0 未确认 1已确认
  14. * @property int $mall_id
  15. * @property int $created_at
  16. * @property int $updated_at
  17. */
  18. class HappinessVoucherExpress extends \common\models\base\BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return 'qimall_addons_happiness_voucher_express';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['order_id', 'status', 'get_status', 'mall_id', 'created_at', 'updated_at'], 'integer'],
  34. [['order_no', 'express_no', 'express_company'], 'string', 'max' => 255],
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'ID',
  44. 'order_id' => 'Order ID',
  45. 'order_no' => 'Order No',
  46. 'express_no' => 'Express No',
  47. 'express_company' => 'Express Company',
  48. 'status' => 'Status',
  49. 'get_status' => 'Get Status',
  50. 'mall_id' => 'Mall ID',
  51. 'created_at' => 'Created At',
  52. 'updated_at' => 'Updated At',
  53. ];
  54. }
  55. public function getGoods()
  56. {
  57. return $this->hasMany(HappinessVoucherExpressGoods::className(), ['express_id' => 'id']);
  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. }