DoubleCopyFrozenFundClearLog.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace addons\DoubleCopy\common\models;
  3. use Yii;
  4. use yii\db\Exception;
  5. /**
  6. * This is the model class for table "{{%addons_double_copy_frozen_fund_clear_log}}".
  7. *
  8. * @property int $id
  9. * @property int $mall_id 商城id
  10. * @property int $user_id 用户id
  11. * @property float $clear_num 操作金额
  12. * @property string $reward_currency 奖励类型:佣金-commission,积分-score
  13. * @property int $status 状态[-1:删除;0:禁用;1启用]
  14. * @property int $created_at 添加时间戳
  15. * @property int $updated_at 更新时间戳
  16. * @property string $operation_type 操作类型(主要是为了标识扣减原因)
  17. */
  18. class DoubleCopyFrozenFundClearLog extends \common\models\base\BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%addons_double_copy_frozen_fund_clear_log}}';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['mall_id', 'user_id', 'status', 'created_at', 'updated_at'], 'integer'],
  34. [['clear_num'], 'number'],
  35. [['reward_currency'], 'string', 'max' => 32],
  36. [['operation_type'], 'string', 'max' => 50],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'mall_id' => 'Mall ID',
  47. 'user_id' => 'User ID',
  48. 'clear_num' => 'Clear Num',
  49. 'reward_currency' => 'Reward Currency',
  50. 'status' => 'Status',
  51. 'created_at' => 'Created At',
  52. 'updated_at' => 'Updated At',
  53. 'operation_type' => 'Operation Type',
  54. ];
  55. }
  56. public static function setData($params)
  57. {
  58. try {
  59. $model = new self();
  60. $model->loadDefaultValues();
  61. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  62. return $model->toArray();
  63. } catch (\Exception $e) {
  64. self::setStaticError($e->getMessage());
  65. return false;
  66. }
  67. }
  68. }