HappinessMoveItem.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace addons\Happiness\common\models;
  3. use addons\StarChain\common\models\GoodsAttr;
  4. use common\models\goods\Goods;
  5. use Yii;
  6. /**
  7. * This is the model class for table "qimall_addons_happiness_move_item".
  8. *
  9. * @property int $id
  10. * @property int $goods_id 商品ID
  11. * @property int $store_id 小店ID
  12. * @property int $order_status 状态:0待调货,1 已调货 2已拒绝
  13. * @property int $total_num 总数量
  14. * @property int $total_price 总金额
  15. * @property int $status
  16. * @property int $created_at
  17. * @property int $updated_at
  18. * @property int $agent_user 审核代理用户ID
  19. * @property int $give_store_id 赠送的店ID
  20. * @property int $mall_id
  21. * @property int $label_id 标签ID
  22. * @property string $remark
  23. */
  24. class HappinessMoveItem extends \common\models\base\BaseActiveRecord
  25. {
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public static function tableName()
  30. {
  31. return 'qimall_addons_happiness_move_item';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['goods_id', 'store_id', 'order_status', 'status', 'total_num', 'created_at', 'updated_at', 'agent_user',
  40. 'mall_id', 'label_id', 'give_store_id'], 'integer'],
  41. [['total_price'], 'number'],
  42. [['remark'], 'string'],
  43. ];
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function attributeLabels()
  49. {
  50. return [
  51. 'id' => 'ID',
  52. 'goods_id' => 'Goods ID',
  53. 'store_id' => 'Store ID',
  54. 'order_status' => 'Order Status',
  55. 'status' => 'Status',
  56. 'total_num' => 'Total Num',
  57. 'total_price' => 'Total Price',
  58. 'created_at' => 'Created At',
  59. 'updated_at' => 'Updated At',
  60. 'agent_user' => 'Agent User',
  61. 'give_store_id' => 'Give Store ID',
  62. 'mall_id' => 'Mall ID',
  63. 'label_id' => 'Label ID',
  64. 'remark' => 'Remark',
  65. ];
  66. }
  67. public function getGoods()
  68. {
  69. return $this->hasMany(HappinessMoveGoods::class, ['move_id' => 'id']);
  70. }
  71. public function getMallGood()
  72. {
  73. return $this->hasOne(Goods::class, ['id' => 'goods_id']);
  74. }
  75. public function getStore()
  76. {
  77. return $this->hasOne(HappinessStore::class, ['id' => 'store_id']);
  78. }
  79. public function getGiveStore()
  80. {
  81. return $this->hasOne(HappinessStore::class, ['id' => 'give_store_id']);
  82. }
  83. public static function setData($params)
  84. {
  85. try {
  86. if (isset($params['id']) && !empty($params['id']))
  87. $model = self::findOne($params['id']);
  88. else {
  89. $model = new self();
  90. $model->loadDefaultValues();
  91. }
  92. if (!$model->load($params, '') || !$model->save()) {
  93. throw new \Exception($model->getErrorMessage());
  94. }
  95. return $model;
  96. } catch (\Exception $e) {
  97. self::$static_error = $e->getMessage();
  98. return false;
  99. }
  100. }
  101. }