Station.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * User: charlie
  4. * 服务点
  5. */
  6. class Station extends MongoAr
  7. {
  8. public $_id;
  9. public $status=0;//服务点状态 0=>待营业 1=>正常营业 -1=>暂停营业 -2=>已删除
  10. public $name;//服务点名字
  11. public $start_time=9;//开始服务时间 如9 每天9点开始
  12. public $end_time=20;//结束服务时间 如20 每天20点停止接受订单
  13. //public $city_info = array(); //所属的城市信息 "province"=>"上海","city"=>"上海","area"=>"浦东" "business"=>"世纪公园" 或者 "province"=>"江苏","city"=>"苏州","area"="昆山"
  14. //public $address;//服务点详细地址
  15. //public $position=array(); //坐标
  16. public $address = array(); //地址信息 包含 province city area business position detail
  17. public $beauticians_count=1; //保洁师数量
  18. public $coverage = array();//服务范围
  19. public $types = array();//该服务点 支持的服务项目
  20. public static $status_option = array(
  21. 0 => array('name' => '待营业'),
  22. 1 => array('name' => '正常营业'),
  23. -1 => array('name' => '暂停营业'),
  24. -2 => array('name' => '已删除'),
  25. );
  26. public function __construct($scenario='insert'){
  27. $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
  28. parent::__construct($scenario);
  29. }
  30. public static function model($className=__CLASS__)
  31. {
  32. return parent::model($className);
  33. }
  34. public function getCollectionName()
  35. {
  36. return 'stations';
  37. }
  38. public static function get($_id) {
  39. if(CommonFn::isMongoId($_id)){
  40. $criteria = new EMongoCriteria();
  41. $criteria->_id('==', $_id);
  42. $model = self::model()->find($criteria);
  43. return $model;
  44. }else{
  45. return false;
  46. }
  47. }
  48. public function parseRow($row,$output=array()){
  49. $newRow = array();
  50. $newRow['id'] = (string)$row['_id'];
  51. $newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
  52. $newRow['start_time'] = CommonFn::get_val_if_isset($row,'start_time',9);
  53. $newRow['end_time'] = CommonFn::get_val_if_isset($row,'end_time',21);
  54. $newRow['address'] = CommonFn::get_val_if_isset($row,'address',array("province"=>"","city"=>"","area"=>"","detail"=>"","business"=>"","position"=>""));
  55. if(!isset($newRow['address']['province'])){
  56. $newRow['address']['province'] = '';
  57. }
  58. if(!isset($newRow['address']['city'])){
  59. $newRow['address']['city'] = '';
  60. }
  61. if(!isset($newRow['address']['area'])){
  62. $newRow['address']['area'] = '';
  63. }
  64. if(!isset($newRow['address']['business'])){
  65. $newRow['address']['business'] = '';
  66. }
  67. if(!isset($newRow['address']['detail'])){
  68. $newRow['address']['detail'] = '';
  69. }
  70. if(!isset($newRow['address']['position'])){
  71. $newRow['address']['position'] = array(121,31);
  72. }
  73. $newRow['coverage'] = CommonFn::get_val_if_isset($row,'coverage',array());
  74. $newRow['types'] = CommonFn::get_val_if_isset($row,'types',array());
  75. $newRow['beauticians_count'] = CommonFn::get_val_if_isset($row,'beauticians_count',1);
  76. $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
  77. $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
  78. $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
  79. $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
  80. if(APPLICATION=='api'){
  81. //unset($newRow['status']);
  82. unset($newRow['action_user']);
  83. unset($newRow['action_time']);
  84. unset($newRow['action_log']);
  85. }
  86. return $this->output($newRow,$output);
  87. }
  88. }