TaxRefund.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace addons\AvoidTax\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use Yii;
  5. /**
  6. * This is the model class for table "{{%addons_tax_refund}}".
  7. *
  8. * @property int $id
  9. * @property int $mall_id
  10. * @property int $book_id 记账本ID
  11. * @property float $amount 退回金额
  12. * @property string $account_name 账户名称
  13. * @property string $account_number 账户账号
  14. * @property string|null $response 响应参数
  15. * @property int|null $created_at
  16. * @property int|null $updated_at
  17. */
  18. class TaxRefund extends BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%addons_tax_refund}}';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['mall_id', 'book_id', 'amount', 'account_name', 'account_number'], 'required'],
  34. [['mall_id', 'book_id', 'created_at', 'updated_at'], 'integer'],
  35. [['amount'], 'number'],
  36. [['response'], 'string'],
  37. [['account_name'], 'string', 'max' => 32],
  38. [['account_number'], 'string', 'max' => 64],
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'ID',
  48. 'mall_id' => 'Mall ID',
  49. 'book_id' => 'Book ID',
  50. 'amount' => 'Amount',
  51. 'account_name' => 'Account Name',
  52. 'account_number' => 'Account Number',
  53. 'response' => 'Response',
  54. 'created_at' => 'Created At',
  55. 'updated_at' => 'Updated At',
  56. ];
  57. }
  58. /**
  59. * 添加提现数据
  60. *
  61. * @param array $data
  62. * @return static|false
  63. */
  64. public static function addLog(array $data)
  65. {
  66. $model = new static();
  67. $model->load($data, '');
  68. return $model->save() ? $model : false;
  69. }
  70. /**
  71. * @param array|string $response
  72. * @return void
  73. */
  74. public function setResponse($response)
  75. {
  76. $this->response = is_array($response) ? json_encode($response) : $response;
  77. $this->save();
  78. }
  79. }