Reserve.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: PHP
  5. * Date: 2016/11/9
  6. * Time: 17:05
  7. * 咨询模型
  8. */
  9. class Reserve extends MongoAr{
  10. public $_id;
  11. public $user_name;
  12. public $mobile;
  13. public $homeType;
  14. public $num;
  15. public $sex;
  16. public $booking_time;//预约时间
  17. public $type;//咨询类型
  18. public $tech_content;//服务内容
  19. public $status;//0 待处理 1 已处理
  20. public $time;//创建时间
  21. public $user;
  22. public $source_type;//格式{'id': 1, 'name': '青浦店'}
  23. public static $status_option = array(
  24. 1 => '待处理',
  25. 2 => '已处理'
  26. );
  27. public function __construct($scenario='insert'){
  28. $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
  29. parent::__construct($scenario);
  30. }
  31. public static function model($className=__CLASS__)
  32. {
  33. return parent::model($className);
  34. }
  35. public function getCollectionName()
  36. {
  37. return 'reserve';
  38. }
  39. public static function get($_id) {
  40. if(CommonFn::isMongoId($_id)){
  41. $criteria = new EMongoCriteria();
  42. $criteria->_id('==', $_id);
  43. $model = self::model()->find($criteria);
  44. return $model;
  45. }else{
  46. return false;
  47. }
  48. }
  49. public function parseRow($row,$output=array()){
  50. $newRow = array();
  51. $newRow['id'] = (string)$row['_id'];
  52. $newRow['user'] = CommonFn::get_val_if_isset($row,'user','');
  53. $newRow['user_name'] = CommonFn::get_val_if_isset($row,'user_name','');
  54. $newRow['mobile'] = CommonFn::get_val_if_isset($row,'mobile','');
  55. $newRow['area'] = CommonFn::get_val_if_isset($row,'area','');
  56. $newRow['homeType'] = CommonFn::get_val_if_isset($row,'homeType','');
  57. $newRow['num'] = CommonFn::get_val_if_isset($row,'num','');
  58. $newRow['sex'] = CommonFn::get_val_if_isset($row,'sex','');
  59. $newRow['tech_content'] = CommonFn::get_val_if_isset($row,'tech_content','');
  60. $newRow['status'] = CommonFn::get_val_if_isset($row,'status');
  61. $newRow['time'] = CommonFn::get_val_if_isset($row,'time','');
  62. $newRow['type'] = CommonFn::get_val_if_isset($row,'type','');
  63. $newRow['booking_time'] = CommonFn::get_val_if_isset($row,'booking_time',0);
  64. $newRow['booking_time_str'] = date('Y年n月d日 H:i',$newRow['booking_time']);;
  65. $newRow['source_type'] =CommonFn::get_val_if_isset($row,'$source_type','');
  66. if(APPLICATION=='admin'){
  67. $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
  68. $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
  69. $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
  70. }
  71. return $this->output($newRow,$output);
  72. }
  73. }