HappinessVoucherOrder.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace addons\Happiness\common\models;
  3. use common\enums\StatusEnum;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_happiness_voucher_order".
  7. *
  8. * @property int $id
  9. * @property string|null $order_no 提货批次
  10. * @property int|null $total_num 总提货数量
  11. * @property int|null $leave_num 剩余提货数量
  12. * @property string|null $user_name 提货人
  13. * @property string|null $mobile 提货人手机号
  14. * @property string|null $address 提货地址
  15. * @property int|null $order_status 提货状态 0未审核,1已审核 2 部分发货 3已全部发货 4 已拒绝
  16. * @property int|null $status
  17. * @property string|null $remark 备注
  18. * @property int|null $mall_id
  19. * @property int|null $created_at
  20. * @property int|null $updated_at
  21. */
  22. class HappinessVoucherOrder extends \common\models\base\BaseActiveRecord
  23. {
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public static function tableName()
  28. {
  29. return 'qimall_addons_happiness_voucher_order';
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function rules()
  35. {
  36. return [
  37. [['total_num', 'leave_num', 'status', 'mall_id','store_id', 'created_at', 'updated_at', 'order_status'], 'integer'],
  38. [['user_name', 'mobile', 'address','order_no','remark'], 'string', 'max' => 255]
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'ID',
  48. 'store_id' => 'Store ID',
  49. 'order_no' => 'Order No',
  50. 'total_num' => 'Total Num',
  51. 'leave_num' => 'Leave Num',
  52. 'user_name' => 'User Name',
  53. 'mobile' => 'Mobile',
  54. 'address' => 'Address',
  55. 'order_status' => 'Order Status',
  56. 'status' => 'Status',
  57. 'mall_id' => 'Mall ID',
  58. 'remark' => 'Remark',
  59. 'created_at' => 'Created At',
  60. 'updated_at' => 'Updated At',
  61. ];
  62. }
  63. public function getStore()
  64. {
  65. return $this->hasOne(HappinessStore::className(), ['id' => 'store_id']);
  66. }
  67. public function getGoods()
  68. {
  69. return $this->hasMany(HappinessVoucherGoods::className(), ['order_id' => 'id']);
  70. }
  71. public static function setData(array $params)
  72. {
  73. try {
  74. if(isset($params['id']) && !empty($params['id']))
  75. $model = self::findOne($params['id']);
  76. else {
  77. $model = new self();
  78. $model->loadDefaultValues();
  79. }
  80. if(!$model)
  81. {
  82. $model = new self();
  83. $model->loadDefaultValues();
  84. }
  85. if (!$model->load($params, '') || !$model->save()) {
  86. throw new \Exception($model->getErrorMessage());
  87. }
  88. return $model;
  89. } catch (\Exception $e) {
  90. self::$static_error = $e->getMessage();
  91. return false;
  92. }
  93. }
  94. }