AreaCumulativeRewardLog.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace addons\Area\common\models;
  3. use Exception;
  4. use RuntimeException;
  5. use Yii;
  6. /**
  7. * This is the model class for table "qimall_addons_area_cumulative_reward_log".
  8. *
  9. * @property int $id
  10. * @property int $mall_id
  11. * @property string $source_table 来源表
  12. * @property int $source_table_id 来源表id
  13. * @property int $status 状态[-1:删除;0:禁用;1启用]
  14. * @property string $wallet_type 奖励类型 commission:佣金 score:积分 digital:数字币
  15. * @property float $change_num 变动数量
  16. * @property int $is_return 是否已退回
  17. * @property int $agent_id qimall_addons_area_agent 表 id
  18. * @property int $user_id 用户id
  19. * @property int $level 代理等级
  20. * @property int $agent_area 代理区域
  21. * @property int $reward_type 奖励类型
  22. * @property int $created_at
  23. * @property int $updated_at
  24. */
  25. class AreaCumulativeRewardLog extends \common\models\base\BaseActiveRecord
  26. {
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public static function tableName()
  31. {
  32. return 'qimall_addons_area_cumulative_reward_log';
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function rules()
  38. {
  39. return [
  40. [['mall_id', 'source_table_id', 'status', 'is_return', 'agent_id', 'user_id', 'level', 'agent_area', 'created_at', 'updated_at'], 'integer'],
  41. [['change_num'], 'number'],
  42. [['source_table'], 'string', 'max' => 255],
  43. [['wallet_type', 'reward_type'], 'string', 'max' => 50],
  44. ];
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function attributeLabels()
  50. {
  51. return [
  52. 'id' => 'ID',
  53. 'mall_id' => 'Mall ID',
  54. 'source_table' => 'Source Table',
  55. 'source_table_id' => 'Source Table ID',
  56. 'status' => 'Status',
  57. 'wallet_type' => 'Wallet Type',
  58. 'change_num' => 'Change Num',
  59. 'is_return' => 'Is Refund',
  60. 'agent_id' => 'Agent ID',
  61. 'user_id' => 'User ID',
  62. 'level' => 'Level',
  63. 'agent_area' => 'Agent Area',
  64. 'reward_type' => 'Reward Type',
  65. 'created_at' => 'Created At',
  66. 'updated_at' => 'Updated At',
  67. ];
  68. }
  69. /**
  70. * @param array $params
  71. *
  72. * @return bool|self
  73. */
  74. public static function setData(array $params)
  75. {
  76. try {
  77. $model = new self();
  78. $model->loadDefaultValues();
  79. if (!$model->load($params, '')) {
  80. throw new RuntimeException($model->getErrorMessage());
  81. }
  82. if (!$model->save()) {
  83. throw new RuntimeException($model->getErrorMessage());
  84. }
  85. return $model;
  86. } catch (Exception $e) {
  87. self::$static_error = $e->getMessage();
  88. return false;
  89. }
  90. }
  91. }