WithdrawsLimitChangeLog.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace common\models\user;
  3. use common\enums\StatusEnum;
  4. use common\models\base\BaseActiveRecord;
  5. use Exception;
  6. use Yii;
  7. /**
  8. * This is the model class for table "{{%withdraws_limit_change_log}}".
  9. *
  10. * @property int $id
  11. * @property int $mall_id 商城ID
  12. * @property int $user_id 消费者ID
  13. * @property float $amount 变动额度,单位:元
  14. * @property int $withdraw_log_id 提现id
  15. * @property int $from 提现来源1佣金2余额
  16. * @property int $status 状态[-1:删除;0:禁用;1启用]
  17. * @property int $created_at 创建时间
  18. * @property int $updated_at 修改时间
  19. * @property int $type 0:公共额度(如果开启提现余额限额则不包含余额的额度),1:提现余额额度
  20. */
  21. class WithdrawsLimitChangeLog extends BaseActiveRecord
  22. {
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return '{{%withdraws_limit_change_log}}';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['mall_id', 'user_id', 'withdraw_log_id', 'from', 'status', 'created_at', 'updated_at', 'type'], 'integer'],
  37. [['amount'], 'number'],
  38. ];
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'mall_id' => 'Mall ID',
  48. 'user_id' => 'User ID',
  49. 'amount' => 'Amount',
  50. 'withdraw_log_id' => 'Withdraw Log ID',
  51. 'from' => 'From',
  52. 'status' => 'Status',
  53. 'created_at' => 'Created At',
  54. 'updated_at' => 'Updated At',
  55. 'type' => 'Type',
  56. ];
  57. }
  58. /**
  59. * 保存数据
  60. * @param array $params
  61. * @return bool|UserWallet
  62. */
  63. public static function setData(array $params)
  64. {
  65. try {
  66. if (!empty($params['id'])) {
  67. $model = self::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
  68. if (empty($model)) throw new Exception('数据异常');
  69. }
  70. if (empty($model)) {
  71. $model = new self();
  72. $model->loadDefaultValues();
  73. }
  74. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  75. return $model;
  76. } catch (Exception $e) {
  77. self::$static_error = $e->getMessage();
  78. return false;
  79. }
  80. }
  81. }