| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- /*
- * @Descripttion:
- * @copyright: Copyright (c) 2021 广东七件事集团
- * @Author: lun
- * @Date: 2022-01-01 01:10:32
- */
- namespace addons\Rebate\common\models;
- use common\models\user\User;
- use yii\db\Exception;
- /**
- *
- * @property-read mixed $user
- */
- class RebateVirtualOrderLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_rebate_virtual_order_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'rebate_id', 'rebate_buy_id'], 'required'],
- [['mall_id', 'user_id', 'rebate_id', 'rebate_buy_id', 'user_parent_id'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'user_id' => 'User Id',
- 'mall_id' => 'Mall Id',
- 'user_parent_id' => 'User Parent Id',
- 'rebate_id' => 'Rebate Id',
- 'rebate_buy_id' => 'Rebate Buy Id',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /***
- * 关联用户
- */
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- /***
- * 关联上级用户
- */
- public function getParentUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_parent_id']);
- }
- /***
- * 关联推三返一活动
- */
- public function getRebate()
- {
- return $this->hasOne(Rebate::class, ['id' => 'rebate_id']);
- }
- /***
- * 关联推三返一活动购买信息
- */
- public function getRebateBuy()
- {
- return $this->hasOne(RebateBuy::class, ['id' => 'rebate_buy_id']);
- }
- /**
- * 保存数据
- *
- * @Author : lun
- * @DateTime : 2022/1/15 0015 9:36
- * @Copyright: copyright (c) 2021 广东七件事集团
- *
- * @param $mall_id
- * @param array $params
- *
- * @return array|bool
- */
- public static function setData($mall_id, array $params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $mall_id;
- if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model->toArray();
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|