WalletLogCoin.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\models;
  3. use yii\behaviors\TimestampBehavior;
  4. use yii\db\ActiveRecord;
  5. /**
  6. * This is the model class for table "{{%wallet_log_coin}}".
  7. *
  8. * @property int $id ID
  9. * @property int $store_id 商城ID
  10. * @property int $user_id 用户ID
  11. * @property int $saas_id 联盟ID
  12. * @property float $money 资金变动(支持负数)
  13. * @property float $before_money 变动前金额
  14. * @property string $desc 关联表
  15. * @property string $type
  16. * @property string $created_at 创建时间
  17. * @property string $update_at 更新时间
  18. */
  19. class WalletLogCoin extends \yii\db\ActiveRecord
  20. {
  21. public static function tableName()
  22. {
  23. return '{{%wallet_log_coin}}';
  24. }
  25. public function behaviors()
  26. {
  27. return [
  28. [
  29. 'class' => TimestampBehavior::class,
  30. 'attributes' => [
  31. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  32. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
  33. ]
  34. ]
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['store_id', 'user_id', 'money', 'before_money'], 'required'],
  44. [['id','store_id', 'user_id', 'saas_id', 'source_id', 'created_at', 'updated_at'], 'integer'],
  45. [['money', 'before_money'], 'number'],
  46. [['type'], 'string', 'max' => 32],
  47. [['currency_code','source_table'], 'string', 'max' => 64],
  48. [['desc'], 'string', 'max' => 255],
  49. [['extra'],'string']
  50. ];
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function attributeLabels()
  56. {
  57. return [
  58. 'id' => 'ID',
  59. 'store_id' => '商城ID',
  60. 'user_id' => '用户ID',
  61. 'saas_id' => '联盟ID',
  62. 'currency_code' => '货币代码',
  63. 'money' => '资金变动(支持负数)',
  64. 'before_money' => '变动前金额',
  65. 'type' => '类型',
  66. 'source_table' => '关联表',
  67. 'source_id' => '关联表id',
  68. 'desc' => '描述',
  69. 'extra' => '额外信息',
  70. 'created_at' => '创建时间',
  71. 'updated_at' => '更新时间',
  72. ];
  73. }
  74. public function getUser()
  75. {
  76. return $this->hasOne(User::class, ['id' => 'user_id']);
  77. }
  78. }