Appointment.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace common\models;
  3. use common\models\User;
  4. use Yii;
  5. /**
  6. * This is the model class for table "{{%appointment}}".
  7. *
  8. * @property string $id
  9. * @property integer $uid
  10. * @property integer $type
  11. * @property integer $pid
  12. * @property integer $created_at
  13. * @property integer $booking_time
  14. * @property integer $updated_at
  15. * @property string $applicant_tel
  16. * @property string $applicant_name
  17. * @property integer $status
  18. * @property integer $state
  19. * @property string $remark
  20. * @property integer $handle
  21. */
  22. class Appointment extends \yii\db\ActiveRecord
  23. {
  24. const STATUS_DELETE = 0;//删除或取消
  25. const STATUS_DEAL = 10;//发布
  26. const STATE_YTAY = 0;//待处理
  27. const STATE_YES = 10;//已处理
  28. const TYPE_SITE = 1;//工地类型
  29. const TYPE_HOUSE = 2;//样板房类型
  30. const HANDLE_YES = 10;//后台已处理
  31. const HANDLE_NO = 0;//后台未处理
  32. const WARNING_TEXT ="您还不是豪省心的会员,无法查看业主联系方式,请联系平台客服<a href='tel:15985837914'>15985837914</a>开通会员";
  33. /**
  34. * @inheritdoc
  35. */
  36. public static function tableName()
  37. {
  38. return '{{%appointment}}';
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function rules()
  44. {
  45. return [
  46. [['uid', 'type', 'pid', 'created_at', 'booking_time', 'updated_at', 'status'], 'required'],
  47. [['uid', 'type', 'pid', 'created_at', 'booking_time', 'updated_at', 'status', 'state','handle'], 'integer'],
  48. [['applicant_tel', 'applicant_name'], 'string', 'max' => 32],
  49. [['remark'], 'string', 'max' => 255],
  50. ];
  51. }
  52. /**
  53. * @inheritdoc
  54. */
  55. public function attributeLabels()
  56. {
  57. return [
  58. 'id' => 'ID',
  59. 'uid' => '预约人',
  60. 'type' => '类型',
  61. 'pid' => '工地编号',
  62. 'created_at' => '创建时间',
  63. 'booking_time' => '预定时间',
  64. 'updated_at' => '最后修改时间',
  65. 'applicant_tel' => '联系电话',
  66. 'applicant_name' => '联系名称',
  67. 'status' => '状态',
  68. 'state' => '流程进度',
  69. 'remark' => '备注信息',
  70. 'handle' => '后台回访',
  71. ];
  72. }
  73. //样板房或工地
  74. public function getBuilding(){
  75. return $this->hasOne(Building::className(),['id'=>'pid']);
  76. }
  77. //预约的人
  78. public function getUser(){
  79. return $this->hasOne(User::className(),['id'=>'uid']);
  80. }
  81. //预约的人
  82. public function getUserinfo(){
  83. return $this->hasOne(UserInfo::className(),['uid'=>'uid']);
  84. }
  85. /**
  86. * 回访记录
  87. */
  88. public function getVisit()
  89. {
  90. return $this->hasMany(AppointmentVisit::className(),['aid'=>'id']);
  91. }
  92. static function telPreg($tel)
  93. {
  94. if(empty($tel))
  95. return $tel;
  96. return preg_replace("/(1\d{1,3})\d\d\d\d\d(\d{3,4})/", "\$1*****\$2", $tel);
  97. }
  98. }