| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace common\models\user;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Exception;
- use Yii;
- /**
- * This is the model class for table "{{%withdraws_limit_change_log}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $user_id 消费者ID
- * @property float $amount 变动额度,单位:元
- * @property int $withdraw_log_id 提现id
- * @property int $from 提现来源1佣金2余额
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- * @property int $type 0:公共额度(如果开启提现余额限额则不包含余额的额度),1:提现余额额度
- */
- class WithdrawsLimitChangeLog extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%withdraws_limit_change_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'withdraw_log_id', 'from', 'status', 'created_at', 'updated_at', 'type'], 'integer'],
- [['amount'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'amount' => 'Amount',
- 'withdraw_log_id' => 'Withdraw Log ID',
- 'from' => 'From',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'type' => 'Type',
- ];
- }
- /**
- * 保存数据
- * @param array $params
- * @return bool|UserWallet
- */
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) throw new Exception('数据异常');
-
- }
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- } catch (Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|