AcPoolAwardRecord.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use yii\base\ErrorException;
  9. use yii\db\ActiveRecord;
  10. use yii\behaviors\TimestampBehavior;
  11. use Yii;
  12. /**
  13. * This is the model class for table "{{%ac_pool_award_record}}".
  14. *
  15. * @property integer $id
  16. * @property integer $currency_id
  17. * @property integer $money
  18. * @property integer $pool_id
  19. * @property integer $saas_id
  20. * @property string $weight
  21. * @property string $fee
  22. * @property string $miss_money
  23. * @property string $desc
  24. * @property integer $created_at
  25. */
  26. class AcPoolAwardRecord extends \yii\db\ActiveRecord
  27. {
  28. /**
  29. * @inheritdoc
  30. */
  31. public static function tableName()
  32. {
  33. return '{{%ac_pool_award_record}}';
  34. }
  35. public function behaviors()
  36. {
  37. return [
  38. [
  39. 'class' => TimestampBehavior::class,
  40. 'attributes' => [
  41. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  42. ]
  43. ]
  44. ];
  45. }
  46. /**
  47. * @inheritdoc
  48. */
  49. public function rules()
  50. {
  51. return [
  52. [[ 'pool_id', 'saas_id','currency_id'], 'integer'],
  53. [['desc'], 'string'],
  54. [['money','weight','miss_money','fee'], 'number'],
  55. [['created_at'], 'safe']
  56. ];
  57. }
  58. public static function createRecord($currency_id,$saas_id,$pool_id,$weight,$desc,$money,$fee,$miss){
  59. try {
  60. $record = new self();
  61. $record->money=$money;
  62. $record->currency_id=$currency_id;
  63. $record->pool_id=$pool_id;
  64. $record->saas_id=$saas_id;
  65. $record->weight=$weight?:0;
  66. $record->fee=$fee?:0;
  67. $record->miss_money=$miss?:0;
  68. $record->desc=$desc;
  69. if (!$record->save())throw new ErrorException('保存失败'.json_encode($record->getErrors()));
  70. return true;
  71. }catch (ErrorException $e){
  72. //debug_log([__METHOD__, __LINE__, "发放是失败 {$e->getMessage() }"], "app_debug_partner.log");
  73. return false;
  74. }
  75. }
  76. }