Master.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Created by JetBrains PhpStorm.
  4. * User: charlie
  5. * Date: 13-11-29
  6. * Time: 下午4:47
  7. * 保洁师、摄影师、训犬师等
  8. */
  9. class Master extends MongoAr
  10. {
  11. public $_id;
  12. public $status = 0; //状态
  13. public $user;//对应的后台帐号
  14. public $ruser;//对应的前端帐号
  15. public $type; //"beautician"=> 保洁师
  16. public $name;//名字
  17. public $city_info = array(); ////用户所属的城市信息 "province"=>"上海","city"=>"上海","area"=>"浦东" 或者 "province"=>"江苏","city"=>"苏州","area"="昆山"
  18. public $position=array(); //用户的坐标
  19. public $mobile = ''; //手机号
  20. public $address = ''; //地址
  21. public $sex = 3; //性别 1男 2女 3不告诉你
  22. public $avatar = ''; //头像七牛的地址
  23. public $desc='';//简介
  24. public $pics=array();//相册
  25. public $coverage = array();//服务范围
  26. public static $status_option = array(
  27. 1 => array('name' => '正常', 'color' => 'green'),
  28. 0 => array('name' => '暂停服务', 'color' => 'blue'),
  29. -1 => array('name' => '删除', 'color' => 'red')
  30. );
  31. public static function model($className=__CLASS__)
  32. {
  33. return parent::model($className);
  34. }
  35. public function getCollectionName()
  36. {
  37. return 'master';
  38. }
  39. public function parseRow($row,$output=array()){
  40. $newRow = array();
  41. $newRow['id'] = (string)$row['_id'];
  42. $newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
  43. $newRow['status'] = CommonFn::get_val_if_isset($row,'status',0);
  44. $newRow['type'] = CommonFn::get_val_if_isset($row,'type','');
  45. $newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
  46. $newRow['mobile'] = CommonFn::get_val_if_isset($row,'mobile','');
  47. $newRow['address'] = CommonFn::get_val_if_isset($row,'address','');
  48. $newRow['sex'] = CommonFn::get_val_if_isset($row,'sex',3);
  49. $newRow['city_info'] = CommonFn::get_val_if_isset($row,'city_info',array("province"=>"","city"=>"","area"=>""));
  50. if(!isset($newRow['city_info']['province'])){
  51. $newRow['city_info']['province'] = '';
  52. }
  53. if(!isset($newRow['city_info']['city'])){
  54. $newRow['city_info']['city'] = '';
  55. }
  56. if(!isset($newRow['city_info']['area'])){
  57. $newRow['city_info']['area'] = '';
  58. }
  59. $newRow['longitude'] = isset($row['position'][0]) ? floatval($row['position'][0]) : 121;
  60. $newRow['latitude'] = isset($row['position'][1]) ? floatval($row['position'][1]) : 31;
  61. $newRow['avatar'] = CommonFn::get_val_if_isset($row,'avatar',Yii::app()->params['defaultUserAvatar']);
  62. if($newRow['avatar']==''){
  63. $newRow['avatar'] = Yii::app()->params['defaultUserAvatar'];
  64. }
  65. $newRow['pics'] = CommonFn::get_val_if_isset($row,'pics',array());
  66. if(empty($newRow['pics'])){
  67. $newRow['pics'] = CommonFn::$empty;
  68. }
  69. $user = array();
  70. $t_user = new ZUser();
  71. if(isset($row['user'])){
  72. $_user = $t_user->get($row['user']);
  73. $user = RUser::model()->parseRow($_user->attributes,array('user_name','level','id','avatar','is_fake_user'));
  74. }
  75. $newRow['user'] = $user;
  76. return $this->output($newRow,$output);
  77. }
  78. }