DigitalLog.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace common\models\user;
  3. use Yii;
  4. use yii\db\Exception;
  5. /**
  6. * This is the model class for table "{{%digital_log}}".
  7. *
  8. * @property int $id
  9. * @property int $mall_id
  10. * @property int $user_id
  11. * @property string $change_type 操作类型:add-增加,sub-减少
  12. * @property float $change_num 操作数量
  13. * @property float $current_num 当前数量
  14. * @property string $desc 变动说明
  15. * @property string $source_table
  16. * @property int $source_table_id 操作来源业务id
  17. * @property string $from_type 来源类型
  18. * @property string $capital_type 资金类型
  19. * @property string $order_no 订单编号
  20. * @property string $contributor_name 名称
  21. * @property float $contributor_money 分佣金额
  22. * @property int $contributor_id 贡献者id
  23. * @property int $status 状态,-1:失效,1:正常
  24. * @property int $send_status 状态,-1:失效,1:正常,9:冻结
  25. * @property int $created_at 添加时间戳
  26. * @property int $updated_at 更新时间戳
  27. */
  28. class DigitalLog extends \common\models\base\BaseActiveRecord
  29. {
  30. const SEND_STATUS_INVALID = -1;
  31. const SEND_STATUS_NORMAL = 1;
  32. const SEND_STATUS_FROZEN = 9;
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public static function tableName()
  37. {
  38. return '{{%digital_log}}';
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function rules()
  44. {
  45. return [
  46. [['mall_id', 'user_id', 'source_table_id', 'contributor_id', 'status', 'created_at', 'updated_at','send_status'], 'integer'],
  47. [['change_num', 'current_num', 'contributor_money'], 'number'],
  48. [['change_type'], 'string', 'max' => 12],
  49. [['desc', 'source_table', 'from_type', 'capital_type', 'contributor_name'], 'string', 'max' => 255],
  50. [['order_no'], 'string', 'max' => 100],
  51. ];
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function attributeLabels()
  57. {
  58. return [
  59. 'id' => 'ID',
  60. 'mall_id' => 'Mall ID',
  61. 'user_id' => 'User ID',
  62. 'change_type' => 'Change Type',
  63. 'change_num' => 'Change Num',
  64. 'current_num' => 'Current Num',
  65. 'desc' => 'Desc',
  66. 'source_table' => 'Source Table',
  67. 'source_table_id' => 'Source Table ID',
  68. 'from_type' => 'From Type',
  69. 'capital_type' => 'Capital Type',
  70. 'order_no' => 'Order No',
  71. 'contributor_name' => 'Contributor Name',
  72. 'contributor_money' => 'Contributor Money',
  73. 'contributor_id' => 'Contributor ID',
  74. 'status' => 'Status',
  75. 'created_at' => 'Created At',
  76. 'updated_at' => 'Updated At',
  77. ];
  78. }
  79. public function getUser()
  80. {
  81. return $this->hasOne(User::class, ['id' => 'user_id']);
  82. }
  83. /**
  84. * 保存数据
  85. * @param array $params
  86. * @return bool|UserInfo
  87. */
  88. public static function setData(array $params)
  89. {
  90. try {
  91. $model = new self();
  92. $model->loadDefaultValues();
  93. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  94. return $model;
  95. } catch (Exception $e) {
  96. self::$static_error = $e->getMessage();
  97. return false;
  98. }
  99. }
  100. }