Transfer.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace backend\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "crm_transfer".
  6. *
  7. * @property integer $id
  8. * @property integer $type
  9. * @property integer $member_id
  10. * @property integer $from_login
  11. * @property integer $to_login
  12. * @property string $amount
  13. * @property integer $in_time
  14. * @property string $memo
  15. * @property string $admin_name
  16. */
  17. class Transfer extends \yii\db\ActiveRecord
  18. {
  19. /**
  20. * @var array
  21. */
  22. public static $typeTextMap = [
  23. 0 => '待审核',
  24. 1 => '审核不通过',
  25. 2 => '已修改',
  26. ];
  27. /**
  28. * @inheritdoc
  29. */
  30. public static function tableName()
  31. {
  32. return 'crm_transfer';
  33. }
  34. /**
  35. * @return \yii\db\Connection the database connection used by this AR class.
  36. */
  37. public static function getDb()
  38. {
  39. return Yii::$app->get('dbXcrm');
  40. }
  41. /**
  42. * @inheritdoc
  43. */
  44. public function rules()
  45. {
  46. return [
  47. [['type', 'member_id', 'from_login', 'to_login', 'amount', 'in_time'], 'required'],
  48. [['type', 'member_id', 'from_login', 'to_login', 'in_time'], 'integer'],
  49. [['amount'], 'number'],
  50. [['memo', 'admin_name'], 'string', 'max' => 255],
  51. ];
  52. }
  53. /**
  54. * @inheritdoc
  55. */
  56. public function attributeLabels()
  57. {
  58. return [
  59. 'id' => '主键ID',
  60. 'type' => '状态(0:等待审核;1:不通过;2:已转账)',
  61. 'member_id' => '代理商ID',
  62. 'from_login' => '转出账户',
  63. 'to_login' => '转入账户',
  64. 'amount' => '金额',
  65. 'in_time' => '创建时间',
  66. 'memo' => '备注',
  67. 'admin_name' => '操作人',
  68. ];
  69. }
  70. /**
  71. * 同名转账数量
  72. * @param int $type 0等待审核,1审核不通过,2已修改
  73. * @return int
  74. */
  75. public static function countByType($type)
  76. {
  77. if (!is_numeric($type)) {
  78. return 0;
  79. }
  80. return static::find()->where(['type' => $type])->count();
  81. }
  82. }