ModifyLever.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace backend\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "crm_modify_lever".
  6. *
  7. * @property string $id
  8. * @property integer $type
  9. * @property string $member_id
  10. * @property integer $login
  11. * @property integer $lever
  12. * @property string $in_time
  13. * @property string $memo
  14. */
  15. class ModifyLever extends \yii\db\ActiveRecord
  16. {
  17. /**
  18. * @var array
  19. */
  20. public static $typeTextMap = [
  21. 0 => '待审核',
  22. 1 => '审核不通过',
  23. 2 => '已修改',
  24. ];
  25. /**
  26. * @inheritdoc
  27. */
  28. public static function tableName()
  29. {
  30. return 'crm_modify_lever';
  31. }
  32. /**
  33. * @return \yii\db\Connection the database connection used by this AR class.
  34. */
  35. public static function getDb()
  36. {
  37. return Yii::$app->get('dbXcrm');
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function rules()
  43. {
  44. return [
  45. [['type', 'member_id', 'login', 'lever', 'in_time'], 'required'],
  46. [['type', 'member_id', 'login', 'lever', 'in_time'], 'integer'],
  47. [['memo'], 'string', 'max' => 255],
  48. ];
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'id' => 'ID',
  57. 'type' => 'Type',
  58. 'member_id' => 'Member ID',
  59. 'login' => 'Login',
  60. 'lever' => 'Lever',
  61. 'in_time' => 'In Time',
  62. 'memo' => 'Memo',
  63. ];
  64. }
  65. /**
  66. * 修改杠杆数量
  67. * @param int $type 0等待审核,1审核不通过,2已修改
  68. * @return int
  69. */
  70. public static function countByType($type)
  71. {
  72. if (!is_numeric($type)) {
  73. return 0;
  74. }
  75. return static::find()->where(['type' => $type])->count();
  76. }
  77. }