DengTao 8 anni fa
parent
commit
134684568d
55 ha cambiato i file con 6590 aggiunte e 7 eliminazioni
  1. 37 7
      www/protected/components/CommonWeixin.php
  2. 2 0
      www/protected/config/main.php
  3. 4 0
      www/protected/config/yiguanjia_const.php
  4. 12 0
      www/protected/modules/moonclub/MoonclubModule.php
  5. 9 0
      www/protected/modules/moonclub/components/MoonClubBaseController.php
  6. 144 0
      www/protected/modules/moonclub/controllers/AdvisoryController.php
  7. 15 0
      www/protected/modules/moonclub/controllers/IndexController.php
  8. 112 0
      www/protected/modules/moonclub/controllers/WebController.php
  9. 77 0
      www/protected/modules/moonclub/models/Advisory.php
  10. 100 0
      www/protected/modules/moonclub/models/AppendOrder.php
  11. 89 0
      www/protected/modules/moonclub/models/BalanceLog.php
  12. 135 0
      www/protected/modules/moonclub/models/Comment.php
  13. 241 0
      www/protected/modules/moonclub/models/Commision.php
  14. 120 0
      www/protected/modules/moonclub/models/Coupon.php
  15. 119 0
      www/protected/modules/moonclub/models/CouponCode.php
  16. 195 0
      www/protected/modules/moonclub/models/FreeTimeRecord.php
  17. 96 0
      www/protected/modules/moonclub/models/Material.php
  18. 93 0
      www/protected/modules/moonclub/models/Product.php
  19. 88 0
      www/protected/modules/moonclub/models/Question.php
  20. 505 0
      www/protected/modules/moonclub/models/ROrder.php
  21. 90 0
      www/protected/modules/moonclub/models/Recharge.php
  22. 44 0
      www/protected/modules/moonclub/models/RechargeLog.php
  23. 55 0
      www/protected/modules/moonclub/models/RechargeOrder.php
  24. 44 0
      www/protected/modules/moonclub/models/SendCouponLog.php
  25. 112 0
      www/protected/modules/moonclub/models/Station.php
  26. 84 0
      www/protected/modules/moonclub/models/Stock.php
  27. 119 0
      www/protected/modules/moonclub/models/TechInfo.php
  28. 89 0
      www/protected/modules/moonclub/models/UserCoupon.php
  29. 229 0
      www/protected/modules/moonclub/views/advisory/SinglesDay.php
  30. 219 0
      www/protected/modules/moonclub/views/advisory/enterprise.php
  31. 67 0
      www/protected/modules/moonclub/views/advisory/im.php
  32. 418 0
      www/protected/modules/moonclub/views/advisory/index.php
  33. 169 0
      www/protected/modules/moonclub/views/advisory/month.php
  34. 39 0
      www/protected/modules/moonclub/views/advisory/xyhIm.php
  35. 343 0
      www/protected/modules/moonclub/views/commision/index.php
  36. 15 0
      www/protected/modules/moonclub/views/index/index.php
  37. 31 0
      www/protected/modules/moonclub/views/layouts/qyindex.php
  38. 30 0
      www/protected/modules/moonclub/views/layouts/qyinfo.php
  39. 14 0
      www/protected/modules/moonclub/views/layouts/techHomeLayout.php
  40. 5 0
      www/protected/modules/moonclub/views/myComment/error.php
  41. 88 0
      www/protected/modules/moonclub/views/myComment/index.php
  42. 106 0
      www/protected/modules/moonclub/views/myComment/info.php
  43. 5 0
      www/protected/modules/moonclub/views/myCommision/error.php
  44. 95 0
      www/protected/modules/moonclub/views/myCommision/index.php
  45. 83 0
      www/protected/modules/moonclub/views/myCommision/info_append.php
  46. 101 0
      www/protected/modules/moonclub/views/myCommision/info_order.php
  47. 5 0
      www/protected/modules/moonclub/views/myOrder/error.php
  48. 88 0
      www/protected/modules/moonclub/views/myOrder/index.php
  49. 557 0
      www/protected/modules/moonclub/views/myOrder/info.php
  50. 817 0
      www/protected/modules/moonclub/views/tech/index.php
  51. 1 0
      www/protected/modules/moonclub/views/techHome/error.php
  52. 161 0
      www/protected/modules/moonclub/views/techHome/index.php
  53. 24 0
      www/protected/modules/moonclub/views/web/authFailed.php
  54. 19 0
      www/protected/modules/moonclub/views/web/index.php
  55. 31 0
      www/protected/modules/moonclub/views/web/wxIndex.php

+ 37 - 7
www/protected/components/CommonWeixin.php

@@ -25,13 +25,6 @@ class CommonWeixin
 		
 		return $res;
 	}
-	
-	public static function getUserInfo($accessToken, $openId) {
-		$userInfoURI = 'https://api.weixin.qq.com/sns/userinfo?access_token=' . $accessToken . '&openid=' . $openId;
-		$res = json_decode(self::httpGet($userInfoURI), true);
-		
-		return $res;
-	}
 
 	public static function getFollowList() {
 		$wxConfig = Yii::app()->params['wxConfig'];
@@ -42,6 +35,43 @@ class CommonWeixin
 		$res = json_decode(self::httpGet($follow_list), true);
 		return $res['data']['openid'];
 	}
+    public static function get_sign1($url = ''){
+        $path = Yii::getPathOfAlias('application');
+        require_once($path."/vendors/weixin/WeiXinSdk.php");
+        $wxConfig = Yii::app()->params['xyhWxConfig'];
+        $jssdk = new WeiXinSdk($wxConfig['appId'], $wxConfig['appSecret']);
+        $signPackage = $jssdk->GetSignPackage($url);
+        return $signPackage;
+    }
+
+    public static function getAccessInfo1($code) {
+        $wxConfig = Yii::app()->params['xyhWxConfig'];
+        $accessTokenURI = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $wxConfig['appId'] . '&secret=' . $wxConfig['appSecret'] . '&code=' . $code . '&grant_type=authorization_code';
+        $res = json_decode(self::httpGet($accessTokenURI), true);
+        return $res;
+    }
+
+    public static function getFollowList1() {
+        $wxConfig = Yii::app()->params['xyhWxConfig'];
+        $accessTokenURI = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$wxConfig['appId'].'&secret='.$wxConfig['appSecret'];
+        $res = json_decode(self::httpGet($accessTokenURI), true);
+        $token = $res['access_token'];
+        $follow_list = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token='.$token;
+        $res = json_decode(self::httpGet($follow_list), true);
+        return $res['data']['openid'];
+    }
+
+
+
+
+
+
+    public static function getUserInfo($accessToken, $openId) {
+        $userInfoURI = 'https://api.weixin.qq.com/sns/userinfo?access_token=' . $accessToken . '&openid=' . $openId;
+        $res = json_decode(self::httpGet($userInfoURI), true);
+
+        return $res;
+    }
 
 	private static function httpGet($url) {
         $curl = curl_init();

+ 2 - 0
www/protected/config/main.php

@@ -26,6 +26,7 @@ return array(
            'application.message.*',
            'application.widget.*',
            'application.modules.o2o.models.*',
+            'application.modules.moonclub.models.*',
            'application.extensions.phpexcel.*',
 
 
@@ -41,6 +42,7 @@ return array(
         'common',
         'api',
         'o2o',
+        'moonclub',
     ),
 
     'components'=>array(

+ 4 - 0
www/protected/config/yiguanjia_const.php

@@ -36,6 +36,10 @@ $wz['wxConfig'] = array(
     'appId' => 'wx9a632fd8918d1a48',
     'appSecret' => '1d21b873c19a36b200cf1d0bb1e9aa26'
 );
+$wz['xyhWxConfig'] = array(
+  'appId' =>'wx637ee1a426503bdb',
+  'appSecret' => '35938d1813453e91d732b085a939ad87'
+);
 $wz['shKey']    = '5f8f7be0-b3ce-4062-be51-d36c660e90e7';
 $wz['shMd5Key'] = 'uJM0y2O5W7ck1f8ddprsWLaqICg3Eej9';
 

+ 12 - 0
www/protected/modules/moonclub/MoonclubModule.php

@@ -0,0 +1,12 @@
+<?php
+class MoonclubModule extends CWebModule
+{
+    public function init()
+    {
+        $this->setImport(array(
+            'moonclub.controllers.*',
+            'moonclub.components.*',
+
+        ));
+    }
+}

+ 9 - 0
www/protected/modules/moonclub/components/MoonClubBaseController.php

@@ -0,0 +1,9 @@
+<?php
+/**
+ * o2o模块公共基类
+ */
+class MoonClubBaseController extends Controller{
+    protected function beforeAction($action) {
+        return true;
+    }
+}

+ 144 - 0
www/protected/modules/moonclub/controllers/AdvisoryController.php

@@ -0,0 +1,144 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/11/9
+ * Time: 17:55
+ */
+class AdvisoryController extends MoonClubBaseController
+{
+
+	public function actionIndex()
+	{
+		$status_option = CommonFn::getComboboxData(Advisory::$status_option, 1, true, 100);
+		$this->render('index', [
+			'status_option' => $status_option
+		]);
+	}
+
+	public function actionList()
+	{
+		$pageParams = CommonFn::getPageParams();
+
+		$id = intval(Yii::app()->request->getParam('id'));
+		$search = Yii::app()->request->getParam('search', '');
+		$status = intval(Yii::app()->request->getParam('status', 100));
+
+		$criteria = new EMongoCriteria($pageParams);
+		// id筛选
+		if ($id) {
+			$criteria->_id('==', new MongoId($id));
+		}
+		// 状态筛选
+		if ($status != 100) {
+			$criteria->status('==', $status);
+		}
+
+		$cursor = Advisory::model()->findAll($criteria);
+		$rows = CommonFn::getRowsFromCursor($cursor);
+		$parsedRows = Advisory::model()->parse($rows);
+		$total = $cursor->count();
+
+		echo CommonFn::composeDatagridData($parsedRows, $total);
+
+	}
+
+	public function actionEdit()
+	{
+		$status = intval(Yii::app()->request->getParam('status', 100));
+		$id = Yii::app()->request->getParam('id');
+		if (!$id) {
+			CommonFn::requestAjax(false, '');
+		}
+		if ($status == 100) {
+			CommonFn::requestAjax(false, '请选择状态');
+		}
+		$advisory = Advisory::model()->get(new MongoId($id));
+		$advisory->status = $status;
+		$success = $advisory->save();
+		if ($success) {
+			CommonFn::requestAjax(true, '修改成功');
+		}
+
+	}
+
+
+	//名宿保洁
+	public function actionSinglesDay()
+	{
+
+		$name = Yii::app()->request->getParam('user_name', '');
+		$area = str_replace('string:', "", Yii::app()->request->getParam('area', ''));
+		$homeType = str_replace('string:', "", Yii::app()->request->getParam('homeType', ''));
+		$num = str_replace('string:', "", Yii::app()->request->getParam('num', ''));
+		$mobile = Yii::app()->request->getParam('mobile');
+		$tech_content = Yii::app()->request->getParam('tech_content', '');
+		if ($name) {
+			$advisory = new Advisory();
+			$advisory->user_name = $name;
+			$advisory->area = $area;
+			$advisory->homeType = $homeType;
+			$advisory->mobile = $mobile;
+			$advisory->num = $num;
+			$advisory->area = $area;
+			$advisory->type = '名宿保洁';
+			$advisory->time = time();
+			$advisory->status = 1;
+			$advisory->tech_content = $tech_content;
+			if ($advisory->save()) {
+				echo '您的咨询已发送成功,请等待我们的管家与您联系,温馨提示,一般是一个工作日内,日间致电给您,请留意。';
+				exit;
+			}
+		}
+
+		$this->render('SinglesDay');
+	}
+
+	//企业服务
+	public function actionEnterprise()
+	{
+		$name = Yii::app()->request->getParam('user_name', '');
+		$area = str_replace('string:', "", Yii::app()->request->getParam('area', ''));
+		$homeType = str_replace('string:', "", Yii::app()->request->getParam('homeType', ''));
+		$num = str_replace('string:', "", Yii::app()->request->getParam('num', ''));
+		$mobile = Yii::app()->request->getParam('mobile');
+		$tech_content = str_replace('string:', "", Yii::app()->request->getParam('tech_content', ''));
+		if ($name) {
+			$advisory = new Advisory();
+			$advisory->user_name = $name;
+			$advisory->area = $area;
+			$advisory->homeType = $homeType;
+			$advisory->mobile = $mobile;
+			$advisory->num = $num;
+			$advisory->area = $area;
+			$advisory->time = time();
+			$advisory->type = '企业服务';
+			$advisory->status = 1;
+			$advisory->tech_content = $tech_content;
+			if ($advisory->save()) {
+				echo '您的咨询已发送成功,请等待我们的管家与您联系,温馨提示,一般是一个工作日内,日间致电给您,请留意。';
+				exit;
+			}
+		}
+		$this->render('enterprise');
+	}
+
+	//享月会联系
+	public function actionXyhIm()
+	{
+		$this->render('xyhIm');
+	}
+//享月会联系
+	public function actionMonth()
+	{
+		$this->render('month');
+	}
+
+	//联系壹管家
+	public function actionIm()
+	{
+		$this->render('im');
+	}
+
+}

+ 15 - 0
www/protected/modules/moonclub/controllers/IndexController.php

@@ -0,0 +1,15 @@
+<?php
+class IndexController extends MoonClubBaseController {
+
+    public function actionIndex() {
+
+        $signPackage = CommonWeixin::get_sign();
+        $current_uri = Yii::app()->request->baseUrl . '/o2o/index/index';
+        $appToken = 'wz';
+        $this->renderpartial('index', array(
+                'signPackage' => $signPackage,
+                'appToken' => $appToken,
+                'current_uri' => $current_uri,
+            ));
+    }
+}

+ 112 - 0
www/protected/modules/moonclub/controllers/WebController.php

@@ -0,0 +1,112 @@
+<?php
+class WebController extends MoonClubBaseController {
+
+    public function actionIndex() {
+
+        $signPackage = CommonWeixin::get_sign1();
+        $home_page = Yii::app()->getRequest()->getParam("home_page",'');
+        $code = Yii::app()->getRequest()->getParam("code");
+        $state = Yii::app()->getRequest()->getParam("state");
+
+        $userId = '';
+        $appToken = '';
+        if($code && $state){
+            $accessInfo = CommonWeixin::getAccessInfo1($code);
+            $userId = '';
+            if (!isset($accessInfo['errcode']) && $state == 'yiguanjia') {
+                $appToken = md5(substr($accessInfo['openid'],2));
+                //微信校验通过,登录(注册),分发token
+                $userInfo = CommonWeixin::getUserInfo($accessInfo['access_token'], $accessInfo['openid']);
+                if (!isset($accessInfo['errcode'])) {
+                    //检查是否有注册,没有就注册
+                    $criteria = new EMongoCriteria();
+                    $criteria->unionid('==', $accessInfo['unionid']);
+                    $user = RUser::model()->find($criteria);
+                    if ($user) {
+                        $userId = $user->_id;
+                        if(!isset($user->wx_pub_openid) || empty($user->wx_pub_openid)){
+                            $user->wx_pub_openid = $accessInfo['openid'];
+                            $user->wx_have_follow = 1;
+                            $user->update(array('wx_pub_openid','wx_have_follow'),true);
+                        }
+                    }else{
+                        $userAr  = new RUser();
+                        $userAr->user_name = $userInfo['nickname'];
+                        $userAr->avatar = $userInfo['headimgurl'];
+                        $userAr->wx_pub_openid = $userInfo['openid'];
+                        $userAr->unionid = $userInfo['unionid'];
+                        $userAr->sex = $userInfo['sex'];
+                        $userAr->register_time = time();
+                        $userAr->channel = 'wxpub';
+                        $userAr->wx_have_follow = 1;
+                        $u_criteria = new EMongoCriteria();
+                        $u_criteria->user_name('==',$userInfo['nickname']);
+                        $olduser = RUser::model()->find($u_criteria);
+                        if($olduser){
+                            $user_new_neme = $userAr->user_name.'_'.substr(time(),-7);
+                            $userAr->user_name = $user_new_neme;
+                        }
+
+                        $result = $userAr->save();
+                        if($result){
+                            //异步同步微信头像到七牛
+                            if (!empty($userAr->unionid) && (strpos($userAr->avatar, 'qiniu') === false)) {
+                                $list = new ARedisList('after_user_reg');
+                                $user_id = (string)$userAr->_id;
+                                $list->push($user_id);
+                            }
+                            $userId = (string)$userAr->_id;
+
+                        }else{
+                            var_dump($userAr);exit;
+                        }
+                    }
+                }else{
+                    echo $accessInfo['errcode'];
+                    die();
+                }
+            }
+
+        }
+
+        if($home_page){
+            $this->renderpartial($home_page.'Index', array(
+                'version' => '2015082505',
+                'debug' => 'false',
+                'signPackage' => $signPackage,
+                'userId' => $userId,
+                'appToken' => $appToken,
+            ));
+        }else{
+
+            $this->renderpartial('index', array(
+                'version' => '2015111601',
+                'debug' => 'false',
+                'signPackage' => $signPackage,
+                'userId' => $userId,
+                'appToken' => $appToken,
+            ));
+        }
+    }
+
+    //检查微信登录页
+    public function actionWxIndex() {
+        $wxConfig = Yii::app()->params['wxConfig'];
+        $home_page = Yii::app()->getRequest()->getParam("home_page",'');
+        $redirectURI = 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . '/o2o/web/index';
+        if($home_page){
+            $appURI = Yii::app()->request->baseUrl . '/o2o/web/index'.'&home_page='.$home_page;
+            $redirectURI = $redirectURI.'/'.$home_page;
+        }else{
+            $appURI = Yii::app()->request->baseUrl . '/o2o/web/index';
+        }
+        $scope = 'snsapi_userinfo';
+        $state = 'yiguanjia';
+        $codeURI = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $wxConfig['appId'] . '&redirect_uri=' . urlencode($redirectURI) . '&response_type=code&scope=' . $scope . '&state=' . $state . '#wechat_redirect';
+        $this->renderpartial('wxIndex', array(
+              'codeURI' => $codeURI,
+              'appURI' => $appURI
+        ));
+    }
+
+}

+ 77 - 0
www/protected/modules/moonclub/models/Advisory.php

@@ -0,0 +1,77 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/11/9
+ * Time: 17:05
+ * 咨询模型
+ */
+class Advisory extends MongoAr{
+    public $_id;
+    public $user_name;
+    public $mobile;
+    public $area;
+    public $homeType;
+    public $num;
+    public $sex;
+    public $type;//咨询类型
+    public $tech_content;//服务内容
+    public $status;//0 待处理 1 已处理
+    public $time;//创建时间
+
+    public static $status_option = array(
+        1 => '待处理',
+        2 => '已处理'
+    );
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'advisory';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        $newRow['user_name'] = CommonFn::get_val_if_isset($row,'user_name','');
+        $newRow['mobile'] = CommonFn::get_val_if_isset($row,'mobile','');
+        $newRow['area'] = CommonFn::get_val_if_isset($row,'area','');
+        $newRow['homeType'] = CommonFn::get_val_if_isset($row,'homeType','');
+        $newRow['num'] = CommonFn::get_val_if_isset($row,'num','');
+        $newRow['sex'] = CommonFn::get_val_if_isset($row,'sex','');
+        $newRow['tech_content'] = CommonFn::get_val_if_isset($row,'tech_content','');
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status');
+        $newRow['time'] = CommonFn::get_val_if_isset($row,'time','');
+        $newRow['type'] = CommonFn::get_val_if_isset($row,'type','');
+        if(APPLICATION=='admin'){
+            $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+            $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+            $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        }
+        return $this->output($newRow,$output);
+    }
+
+
+}

+ 100 - 0
www/protected/modules/moonclub/models/AppendOrder.php

@@ -0,0 +1,100 @@
+<?php
+/**
+ * 订单追加服务表
+ */
+class AppendOrder extends MongoAr
+{
+    public $_id;
+    public $order;
+    public $charge_id;//ping++的chargeId,charge_id即为支付单号
+    public $pay_channel;//支付渠道
+    public $append_time;//追加时间
+
+    public $products=array(); //订单包含的商品数组   数据库设计  支持多个产品在一个订单
+
+    public $price;  //订单金额
+
+    public $status=0;//状态 0=>待支付  1=>已支付 -1=>已退款
+    
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static $status_option = array(
+        0  => array('name' => '待支付'),
+        1  => array('name' => '已支付'),
+        -1 => array('name' => '已退款'),
+    );
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function getCollectionName()
+    {
+        return 'append_order';
+    }
+
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['order'] = (string)CommonFn::get_val_if_isset($row,'order','');
+        $newRow['pay_channel'] = CommonFn::get_val_if_isset($row,'pay_channel','');
+        $newRow['charge_id'] = CommonFn::get_val_if_isset($row,'charge_id','');
+        $newRow['price'] = CommonFn::get_val_if_isset($row,'price','');
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',0);
+        $newRow['status_str'] = self::$status_option[$newRow['status']]['name'];
+        if($newRow['status'] == 1){
+            $newRow['book_status_str'] = '已支付';
+        }elseif ($newRow['status'] == 0) {
+            $newRow['book_status_str'] = '未支付';
+        }
+        $products = array();
+        $newRow['products_str'] = '';
+        if(isset($row['products'])&&is_array($row['products'])){
+            foreach ($row['products'] as $key => $product) {
+                $product_obj = Product::get($product['product']);
+                $temp_info = $product_obj->parseRow($product_obj);
+                $temp_info['count'] = $product['count'];
+                $products[] = $temp_info;
+                if($key == 0){
+                    $newRow['products_str'] .= $temp_info['name'];
+                }else{
+                    $newRow['products_str'] .= '+'.$temp_info['name'];
+                }
+            }
+        }
+        $newRow['products'] = $products;
+        if(!isset($newRow['products'])||empty($newRow['products'])){
+            $newRow['products']=CommonFn::$empty;
+        }
+        $newRow['append_time'] = CommonFn::get_val_if_isset($row,'append_time',0);
+        $newRow['append_time_str'] = date('n月d日 H:i',$newRow['append_time']);
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+        if(APPLICATION=='api'){
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+
+        return $this->output($newRow,$output);
+    }
+
+
+}

+ 89 - 0
www/protected/modules/moonclub/models/BalanceLog.php

@@ -0,0 +1,89 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/9/26
+ * Time: 11:57
+ * 用户余额
+ */
+class BalanceLog extends MongoAr
+{
+    public $_id;
+
+    public $user;//用户 mongoid
+
+    public $time;//时间
+
+    public $memo;//说明
+
+
+    public $type;//操作类型   'recharge  充值;admin_recharge  后台充值;order  下订单;send  赠送;other  其他'
+
+    public $amount;//金额  可以为负数
+
+    public static $type_option = array(
+        'recharge' => '充值',
+        'admin_recharge' => '后台充值',
+        'order' => '下订单',
+        'send' => '赠送',
+        'other' => '其他',
+    );
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'balance_log';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        $newRow['memo'] = CommonFn::get_val_if_isset($row,'memo','');
+
+        $newRow['type'] = CommonFn::get_val_if_isset($row,'type','other');
+        $newRow['type_str'] = self::$type_option[$newRow['type']];
+
+        $newRow['time'] = CommonFn::get_val_if_isset($row,'time',time());
+
+        $newRow['time_str'] = CommonFn::sgmdate("Y年n月d日", $newRow['time'],1);
+
+        $newRow['amount'] = CommonFn::get_val_if_isset($row,'amount',0);
+
+        $user = array();
+        $t_user = new ZUser();
+        if(isset($row['user'])){
+            $_user = $t_user->get($row['user']);
+            $user = RUser::model()->parseRow($_user->attributes,array('id','user_name'));
+        }
+        $newRow['user'] = $user;
+
+
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+
+        return $this->output($newRow,$output);
+    }
+}

+ 135 - 0
www/protected/modules/moonclub/models/Comment.php

@@ -0,0 +1,135 @@
+<?php
+class Comment extends MongoAr
+{
+    public $_id;    //评价的object id
+
+    public $content;//内容
+
+    public $score;//评分
+
+    public $order;//订单object id
+
+    public $time;//评价发表时间
+
+    public $user;//作者object id
+
+    public $pics;
+
+    public $status =1;//状态   1正常   0删除   -1垃圾
+
+    public $type;// 
+
+    public $weight = 0;//评价权重
+
+    public $technician = 0;
+    public $technicians = array();//多个保洁师
+    public $technician_name = '';
+
+    public $reply = ''; // 客服回复
+
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static $status_option = array( 
+        1 => array('name' => '正常'),
+        0 => array('name' => '删除')
+        /*-1 => array('name' => '垃圾')*/
+    );
+
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'comment';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    /**
+     * 根据OrderId获取评价
+     */
+    public static function getByOrder($order) {
+        if (CommonFn::isMongoId($order)) {
+            $criteria = new EMongoCriteria();
+            $criteria->order('==', $order);
+            $model = self::model()->find($criteria);
+            return $model;
+        } else {
+            return false;
+        }
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        $newRow['content'] = CommonFn::get_val_if_isset($row,'content','');
+
+        $newRow['score'] = CommonFn::get_val_if_isset($row,'score',5);
+
+        $newRow['order'] = (string)CommonFn::get_val_if_isset($row,'order','');
+
+        $newRow['time'] = CommonFn::get_val_if_isset($row,'time',0);
+        $newRow['time_str'] = date('Y-m-d H:i:s',$newRow['time']);
+        $newRow['time_str_short'] = date('m-d H:i', $newRow['time']);
+        $newRow['type'] = CommonFn::get_val_if_isset($row,'type',1);
+        $newRow['weight'] = CommonFn::get_val_if_isset($row,'weight',0);
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',0);
+        $newRow['pics'] = CommonFn::get_val_if_isset($row,'pics',array());
+        if(empty($newRow['pics'])){
+            $newRow['pics'] = CommonFn::$empty;
+        }
+        $user = array();
+        $t_user = new ZUser();
+        if(isset($row['user'])){
+            $_user = $t_user->get($row['user']);
+            $user = RUser::model()->parseRow($_user->attributes,array('user_name','user_type','can_be_message','can_access','level','id','avatar','is_fake_user'));
+        }
+        $newRow['user'] = $user;
+
+        $newRow['technicians'] = CommonFn::get_val_if_isset($row, 'technicians');
+        //$newRow['technician_name'] = '';
+        $newRow['tech_info'] = [];
+        if ($newRow['technicians']) {
+            foreach($newRow['technicians'] as $technicians) {
+                $tech_info = TechInfo::get($technicians);
+                if ($tech_info) {
+                    $newRow['tech_info'][] = TechInfo::model()->parseRow($tech_info, array('id', 'name', 'mobile', 'weixin_userid'));
+                    $newRow['technician_name'][] = $tech_info->name;
+                }
+            }
+        }
+
+        $newRow['reply'] = CommonFn::get_val_if_isset($row, 'reply', '');
+
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        if(APPLICATION=='api'){
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+
+        return $this->output($newRow,$output);
+    }
+
+}

+ 241 - 0
www/protected/modules/moonclub/models/Commision.php

@@ -0,0 +1,241 @@
+<?php 
+/**
+ * 保洁师提成模型
+ * @author     2015-12-01
+ */
+class Commision extends MongoAr {
+
+    public $_id;
+    public $time;           // 订单完成时间
+    public $booking_time;   // 预定时间
+    public $user;           // 保洁师ID
+    public $order;          // 订单ID
+    public $commision;      // 提成价格
+    public $type;           // 订单类型
+    /*
+
+    */
+
+    const MAIN   = 0;
+    const APPEND = 1;
+
+    public static $type_option = array(
+        0  => array('name' => '普通'),
+        1  => array('name' => '追加'),
+        -1 => array('name' => '手动添加'),
+    );
+
+    public function __construct($scenario='insert') {
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static function model($className = __CLASS__) {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    /**
+     * 根据订单ID获得commision对象
+     * @param  MongoId           $id        : 订单ID
+     * @return Commision|Boolean $commision : Commision对象或false
+     */
+    public static function getByOrder($id) {
+        if (CommonFn::isMongoId($id)) {
+            $criteria = new EMongoCriteria();
+            $criteria->order('==', $id);
+            $commision = Commision::model()->find($criteria);
+
+            if (empty($commision)) {
+                return false;
+            } else {
+                return $commision;
+            }
+        } else {
+            return true;
+        }
+    }
+
+    public function getCollectionName () {
+        return 'commision';
+    }
+
+    /**
+     * 计算单个订单内保洁师提成
+     * @param  Object  $order       : 订单Object(AppendOrder或ROrder)
+     * @param  Boolean $type        : 订单类型
+     * @param  String  $scheme_name : 提成方案
+     * @return Float   $commision   : 计算所得提成
+     */
+    public static function getCommision($order, $type = self::MAIN, $scheme_name = 'scheme_30') {
+        $commision = 0.0;
+
+        // 订单内服务数量统计
+        $products = array();
+        $count = array();
+        foreach ($order->products as $key => $row) {
+            $products[] = $row['product'];
+            $product_id = (string)$row['product'];
+            $count[$product_id] = $row['count'];
+        }
+
+        // 订单内所有服务详细信息
+        $criteria = new EMongoCriteria();
+        $criteria->_id('in', $products);
+        $cursor = Product::model()->findAll($criteria);
+
+        // 提成方案
+        $scheme_name = $scheme_name == 'no_scheme' ? 'scheme_30' : $scheme_name;
+        $scheme = self::$scheme_list[$scheme_name];
+        // 默认百分比
+        $default = floatval(substr($scheme_name, strlen($scheme_name) - 2))/100;
+        foreach ($cursor as $key => $row) {
+            foreach ($scheme as $k => $value) {
+                $pattern = '/'.$value['name'].'/';
+                $subject = $row->name;
+                // 正则匹配字典中的name字段与服务名
+                if (preg_match($pattern, $subject) > 0) {
+                    if ($value['fixed'] != false) {
+                        $commision += $value['fixed'] * $count[(string)$row->_id];
+                        break;
+                    } else {
+                        $commision += floatval($row->price) * $count[(string)$row->_id] * $value['percentage'];
+                        break;
+                    }
+                } else {
+                    if ($k == count($scheme)) {
+                        $commision += floatval($row->price) * $count[(string)$row->_id] * $default;
+                        break;
+                    } else {
+                        continue;
+                    }
+                }
+            }
+        }
+
+        return $commision;
+    }
+
+    /**
+     * 整理函数,用于后台管理显示
+     */
+    public function parseRow($row, $output=array()) {
+        $newRow = array();
+
+        $newRow['id']       = (string)$row['_id'];
+        $newRow['time']     = CommonFn::get_val_if_isset($row, 'time', 0);
+        $newRow['time_str'] = $newRow['time'] == 0? '': date('Y-m-d H:i', $newRow['time']);
+
+        $newRow['user'] = CommonFn::get_val_if_isset($row, 'user', '');
+        if ($newRow['user'] != '') {
+            //$user = User::get($newRow['user']);
+            $newRow['user_str'] = $newRow['user'];
+        } else {
+            $newRow['user_str'] = '';
+        }
+
+        $newRow['order']     = (string)CommonFn::get_val_if_isset($row, 'order', '');
+        $newRow['commision'] = CommonFn::get_val_if_isset($row, 'commision', 0);
+
+        $newRow['type']      = CommonFn::get_val_if_isset($row, 'type', -1);
+        $type_option         = self::$type_option;
+        $newRow['type_str']  = $type_option[$newRow['type']]['name'];
+
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log']  = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        $newRow['booking_time'] = CommonFn::get_val_if_isset($row, 'booking_time', 0);
+        if ($newRow['booking_time']) {
+            if (date('Y', time()) == date('Y', $newRow['booking_time'])) {
+                $newRow['booking_time_str'] = date('m月d日 H:i', $newRow['booking_time']);
+            } else {
+                $newRow['booking_time_str'] = date('Y年m月d日 H:i', $newRow['booking_time']);
+            }
+        } else {
+            $newRow['booking_time_str'] = '';
+        }
+
+        return $this->output($newRow, $output);
+    }
+
+    /**
+     * 提成方案设置
+     */
+    public static $scheme_option = array(
+        -1 => array('name' => '未选择方案',  'alias' => 'no_scheme'),
+        0  => array('name' => '提成方案60%', 'alias' => 'scheme_60'),
+        1  => array('name' => '提成方案30%', 'alias' => 'scheme_30'),
+        2  => array('name' => '提成方案50%', 'alias' => 'scheme_50'),
+        3  => array('name' => '提成方案80%', 'alias' => 'scheme_80'),
+    );
+
+    /**
+     * 提成方案字典
+     * key : 方案名称scheme_百分比
+     * @param String         $name       : 类别的名称
+     * @param Float          $percentage : 提成百分比
+     * @param Boolean|Number $fixed      : 是否采用固定提成价格,否则填false,是则填相应数字
+     */
+    public static $scheme_list = array(
+        /* 提成方案60% */
+        'scheme_60' => array(
+            1  => array('name' => '日常清洁',     'percentage' => 0.6, 'fixed' => false),
+            2  => array('name' => '深度清洁',     'percentage' => 0.6, 'fixed' => false),
+            3  => array('name' => '除螨杀菌',     'percentage' => 0.6, 'fixed' => false),
+            4  => array('name' => '家电清洗',     'percentage' => 0.6, 'fixed' => false),
+            5  => array('name' => '民宿保洁',      'percentage' => 0.6, 'fixed' => false),
+            6  => array('name' => '新居开荒',     'percentage' => 0.6, 'fixed' => false),
+            7  => array('name' => '母婴房清洁',     'percentage' => 0.6, 'fixed' => false),
+            15 => array('name' => '租房清洁',   'percentage' => 0.6, 'fixed' => false),
+            8  => array('name' => '擦玻璃',   'percentage' => 0.6, 'fixed' => false),
+        ),
+        /* 提成方案30% */
+        'scheme_30' => array(
+            1  => array('name' => '日常清洁',     'percentage' => 0.3, 'fixed' => false),
+            2  => array('name' => '深度清洁',     'percentage' => 0.3, 'fixed' => false),
+            3  => array('name' => '除螨杀菌',     'percentage' => 0.3, 'fixed' => false),
+            4  => array('name' => '家电清洗',     'percentage' => 0.3, 'fixed' => false),
+            5  => array('name' => '民宿保洁',      'percentage' => 0.3, 'fixed' => false),
+            3  => array('name' => '新居开荒',     'percentage' => 0.5, 'fixed' => false),
+            7  => array('name' => '母婴房清洁',     'percentage' => 0.3, 'fixed' => false),
+            15 => array('name' => '租房清洁',   'percentage' => 0.3, 'fixed' => false),
+            8  => array('name' => '擦玻璃',   'percentage' => 0.3, 'fixed' => false),
+        ),
+        /* 提成方案50% */
+        'scheme_50' => array(
+            1  => array('name' => '日常清洁',     'percentage' => 0.5, 'fixed' => false),
+            2  => array('name' => '深度清洁',     'percentage' => 0.5, 'fixed' => false),
+            3  => array('name' => '除螨杀菌',     'percentage' => 0.5, 'fixed' => false),
+            4  => array('name' => '家电清洗',     'percentage' => 0.5, 'fixed' => false),
+            5  => array('name' => '民宿保洁',      'percentage' => 0.5, 'fixed' => false),
+            6  => array('name' => '新居开荒',     'percentage' => 0.5, 'fixed' => false),
+            7  => array('name' => '母婴房清洁',     'percentage' => 0.5, 'fixed' => false),
+            15 => array('name' => '租房清洁',   'percentage' => 0.5, 'fixed' => false),
+            8  => array('name' => '擦玻璃',   'percentage' => 0.5, 'fixed' => false),
+        ),
+        /* 提成方案80% */
+        'scheme_80' => array(
+            1  => array('name' => '日常清洁',     'percentage' => 0.8, 'fixed' => false),
+            2  => array('name' => '深度清洁',     'percentage' => 0.8, 'fixed' => false),
+            3  => array('name' => '除螨杀菌',     'percentage' => 0.8, 'fixed' => false),
+            4  => array('name' => '家电清洗',     'percentage' => 0.6, 'fixed' => false),
+            5  => array('name' => '民宿保洁',      'percentage' => 0.8, 'fixed' => false),
+            6  => array('name' => '新居开荒',     'percentage' => 0.8, 'fixed' => false),
+            7  => array('name' => '母婴房清洁',     'percentage' => 0.8, 'fixed' => false),
+            15 => array('name' => '租房清洁',   'percentage' => 0.8, 'fixed' => false),
+            8  => array('name' => '擦玻璃',   'percentage' => 0.8, 'fixed' => false),
+        ),
+    );
+
+}

+ 120 - 0
www/protected/modules/moonclub/models/Coupon.php

@@ -0,0 +1,120 @@
+<?php
+/**
+ * User: charlie
+ * 代金券
+ */
+class Coupon extends MongoAr
+{
+    public $_id;
+
+    public $value;//代金券面额
+
+    public $name;//代金券别名
+
+    public $pic=array();//代金券的图片
+
+    public $min_price;//满XX元才可以使用
+
+    public $status=0;//代金券状态 0=>暂停使用  1=>正常使用   -1=>已删除
+
+    public $memo;//备注
+
+    public $alias_name;//别名
+
+    public $type;//代金券的适用类型     array(1=>array("name"=>"宠物洗澡"),2=>array("name"=>"宠物剪毛"),3=>array("name"=>"宠物美容"))
+
+    public $workday_limit=0;  // 工作日非工作日限制 0: 无限制; 1: 仅限工作日使用; 2: 仅限周末使用
+
+    public $time_limit_start;   // 时间限制 0-24的数字
+    public $time_limit_end;     // 时间限制 0-24的数字
+
+    public $time;   // 代金券创建的时间
+
+    public static $status_option = array(
+        0 => array('name' => '暂停使用'),
+        1 => array('name' => '正常使用'),
+        -1 => array('name' => '已删除')
+    );
+
+    public static $workday_limit_option = array(
+        0 => array('name' => '无限制'),
+        1 => array('name' => '仅限工作日'),
+        2 => array('name' => '仅限周末'),
+    );
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'coupons';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        $newRow['value'] = CommonFn::get_val_if_isset($row,'value',10);
+        $newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
+        $newRow['alias_name'] = CommonFn::get_val_if_isset($row,'alias_name','');
+        $newRow['memo'] = CommonFn::get_val_if_isset($row,'memo','');
+        $newRow['min_price'] = CommonFn::get_val_if_isset($row,'min_price',100);
+
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
+
+        $newRow['type'] = CommonFn::get_val_if_isset($row,'type',0);
+        if($newRow['type'] == 0){
+            $newRow['type_str'] = '全部';
+        }else{
+            $newRow['type_str'] = Yii::app()->params['o2o_service'][$newRow['type']]['name'];
+        }
+
+        $newRow['workday_limit'] = CommonFn::get_val_if_isset($row, 'workday_limit', 0);
+        $newRow['workday_limit_str'] = self::$workday_limit_option[$newRow['workday_limit']]['name'];
+
+        $newRow['time_limit_start'] = CommonFn::get_val_if_isset($row, 'time_limit_start', '');
+        $newRow['time_limit_end'] = CommonFn::get_val_if_isset($row, 'time_limit_end', '');
+        $newRow['time_limit_str'] = '';
+        if($newRow['workday_limit']==1){
+            $newRow['time_limit_str'] = '工作日';
+        }elseif($newRow['workday_limit'] == 2){
+            $newRow['time_limit_str'] = '周末';
+        }
+        if($newRow['time_limit_start'] && $newRow['time_limit_end']){
+            $newRow['time_limit_str'] = $newRow['time_limit_str'].' '.$newRow['time_limit_start'].'点-'.$newRow['time_limit_end'].'点';
+        }
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        if(APPLICATION=='api'){
+            //unset($newRow['status']);
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+            unset($newRow['memo']);
+        }
+
+        return $this->output($newRow,$output);
+    }
+
+}

+ 119 - 0
www/protected/modules/moonclub/models/CouponCode.php

@@ -0,0 +1,119 @@
+<?php
+class CouponCode extends MongoAr
+{
+    public $_id;    //object id
+
+    public $code;   //兑换码 string
+
+    public $channel; //使用渠道  唯一批次标记
+
+    public $desc; //批次说明
+
+    public $coupons = array();
+
+    public $stop_time;//过期时间
+
+    public $use_time;//使用时间
+
+    public $user;//使用者
+
+    public $user_device_id;//领用用户的device_id or unionid
+
+    public $alway = 0; //是否可以重复使用
+
+    public $status = 0; //状态 0为未使用,1为已使用
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+        $time = time();
+        $this->code = substr($time,2);
+    }
+
+    public static $status_option = array(
+        0 => array('name' => '未使用'),
+        1 => array('name' => '已使用'),
+    );
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'coupon_code';
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        $newRow['code'] = CommonFn::get_val_if_isset($row,'code','');
+        $newRow['channel'] = CommonFn::get_val_if_isset($row,'channel','');
+        $newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
+
+        $newRow['user_device_id'] = CommonFn::get_val_if_isset($row,'user_device_id','');
+
+        $user = array();
+        if(isset($row['user'])){
+            $_user = RUser::get($row['user']);
+            if($_user){
+                $user = $_user->parseRow($_user->attributes,array('user_name','id','avatar'));
+            }
+
+        }
+        $newRow['user'] = $user;
+
+        $newRow['stop_time'] = CommonFn::get_val_if_isset($row,'stop_time');
+        if($newRow['stop_time']){
+            $newRow['stop_time_str'] = CommonFn::bgmdate("Y年n月d日", $newRow['stop_time'],1);
+        }
+
+
+        $newRow['use_time'] = CommonFn::get_val_if_isset($row,'use_time');
+        if($newRow['use_time']) {
+            $newRow['use_time_str'] = CommonFn::bgmdate("Y年n月d日", $newRow['use_time'], 1);
+        }
+
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',0);
+        $newRow['always'] = CommonFn::get_val_if_isset($row,'always',0);
+
+        $coupons = array();
+        if(isset($row['coupons']) && !empty($row['coupons'])){
+            foreach($row['coupons'] as $coupon_id){
+                $_coupon = Coupon::get($coupon_id);
+                if($_coupon){
+                    $coupons[] = Coupon::model()->parse($_coupon->attributes,false,array('id','name'));
+                }else{
+                    continue;
+                }
+            }
+        }
+        $newRow['coupons'] = $coupons;
+
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        if(APPLICATION=='api'){
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+
+        return $this->output($newRow,$output);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+}

+ 195 - 0
www/protected/modules/moonclub/models/FreeTimeRecord.php

@@ -0,0 +1,195 @@
+<?php
+class FreeTimeRecord extends MongoAr
+{
+    public $_id;//时间戳,整点时间戳格式
+
+    public $free_technician = array();//此时间段空闲保洁师列表
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        $criteria = new EMongoCriteria();
+        $criteria->_id('==', $_id);
+        $model = self::model()->find($criteria);
+        return $model;
+    }
+
+    /**
+     * 获取所有可用时间戳
+     */
+    public function getAvailableTimeList() {
+        $timeList = [];
+        for ($index = 0; $index < 15; $index++) {
+            $date = date('Ymd', strtotime('+'.$index.' days', time()));
+            $timeList[$date] = [
+                'name' => date('m月d日', strtotime($date)),
+                'timestampList' => [
+                    strtotime($date.'0900'), strtotime($date.'1000'), strtotime($date.'1100'),
+                    strtotime($date.'1200'), strtotime($date.'1300'), strtotime($date.'1400'),
+                    strtotime($date.'1500'), strtotime($date.'1600'), strtotime($date.'1700'),
+                    strtotime($date.'1800'), strtotime($date.'1900'),
+                ],
+            ];
+        }
+        return $timeList;
+    }
+
+    /**
+     * 获取某个保洁师的时间线
+     * 0: 此时段未设置
+     * 1: 此时段已设置且空闲
+     * 2: 此时段已预约
+     */
+    public function getTechTimeline($tech_id){
+        // 检索Order表
+        $criteria = new EMongoCriteria();
+        $timestamp_start_book = strtotime('today');
+        $timestamp_end_book = strtotime('+15 day', strtotime('today'));
+        $criteria->technician('==', $tech_id);
+        $criteria->status('notin',array(-3,-2,-1,7));
+        $criteria->booking_time('>=', $timestamp_start_book);
+        $criteria->booking_time('<=', $timestamp_end_book);
+        $criteria->sort('booking_time',EMongoCriteria::SORT_ASC);
+        $cursor = ROrder::model()->findAll($criteria);
+        $time_line = [];
+        foreach ($cursor as $key => $order) {
+            $booking_time = strtotime(date('YmdH00',$order->booking_time));
+            $time_line[$booking_time] = 2;//此时段已预约
+        }
+
+        // 检索free_time_record表
+        $free_list = array();
+        $criteria = new EMongoCriteria();
+        $criteria->free_technician('==', $tech_id);
+        $criteria->sort('_id', EMongoCriteria::SORT_ASC);
+        $cursor = FreeTimeRecord::model()->findAll($criteria);
+        foreach ($cursor as $key => $value) {
+            if(array_key_exists($value->_id, $time_line)){
+                $value->TechUnsetFreetime($tech_id,$value->_id);
+            }else{
+                $time_line[$value->_id] = 1;//此时段空闲
+            }
+        }
+
+        // 遍历availableTimeList生成TimeLine
+        $availabelTimeList = $this->getAvailableTimeList();
+        $data = [];
+        foreach ($availabelTimeList as $key => $item) {
+            $data[$key]['name'] = $item['name'];
+            $data[$key]['selected'] = 0;
+            $all_day = true;
+            foreach ($item['timestampList'] as $k => $time) {
+                if (array_key_exists($time, $time_line)) {
+                    $data[$key]['selectedHours'][] = $time_line[$time];
+                    $data[$key]['selected'] = 1;
+                } else {
+                    $data[$key]['selectedHours'][] = 0;
+                    $all_day = false;
+                }
+            }
+            $data[$key]['selected'] = $all_day ? 2 : $data[$key]['selected'];
+            $data[$key]['selectedHours'] = array_merge(
+                [0, 0, 0, 0, 0, 0, 0, 0, 0],
+                $data[$key]['selectedHours'],
+                [0, 0, 0, 0]
+            );
+        }
+        return $data;
+    }
+
+    //设置某时段保洁师忙碌
+    public static function TechUnsetFreetime($tech_id,$time_stamp){
+        if($time_stamp > time()+86400*15 || $time_stamp < strtotime('today') ){
+            return false;
+        }
+        $time_record = self::get($time_stamp);
+        if($time_record){
+            $old_free_list = $time_record->free_technician;
+            if(in_array($tech_id,$old_free_list) !== false){
+                unset($old_free_list[array_search($tech_id,$old_free_list)]);
+                $time_record->free_technician = array_values($old_free_list);
+                return $time_record->update(array('free_technician'),true);
+            }else{
+                return true;
+            }
+        }else{
+            return true;
+        }
+    }
+
+    //设置保洁师某时段空闲
+    public static function TechsetFreetime($tech_id,$time_stamp){
+        if($time_stamp > time()+86400*15 || $time_stamp < strtotime('today') ){
+            return false;
+        }
+        $time_record = self::get($time_stamp);
+        if($time_record){
+            $old_free_list = $time_record->free_technician;
+            if(in_array($tech_id,$old_free_list)){
+                return true;
+            }else{
+                $old_free_list[] = $tech_id;
+                $time_record->free_technician = array_values($old_free_list);
+                return $time_record->update(array('free_technician'),true);
+            }
+        }else{
+            $time_record = new FreeTimeRecord();
+            $time_record->_id = $time_stamp;
+            $time_record->free_technician = array($tech_id);
+            return $time_record->save();
+        }
+    }
+    
+
+    public function getCollectionName()
+    {
+        return 'free_time_record';
+    }
+
+    /**
+     * 空闲时间段格式转换
+     * 具体时间 -> 明天9:00
+     */
+    public static function parseFreeTime($time) {
+        $today = date('Ymd');
+
+        // 时间整理
+        $hour = date('H', $time);
+        if (intval($hour) != 10 && intval($hour) != 0) {
+            $hour = str_replace('0', '', $hour);
+        }
+        $min = date('i', $time);
+        $parsedTime = $hour.':'.$min;
+
+        // 是否今天
+        if ($today == date('Ymd', $time)) {
+            return '今天 '.$parsedTime;
+        // 是否明天
+        } else if ($today == date('Ymd', strtotime('-1 day', $time))) {
+            return '明天 '.$parsedTime;
+        // 是否后天
+        } else if ($today == date('Ymd', strtotime('-2 day', $time))) {
+            return '后天 '.$parsedTime;
+        } else {
+            $month = date('m', $time);
+            $day = date('d', $time);
+            if (intval($month) != 10) {
+                $month = str_replace('0', '', $month);
+            }
+            if (!in_array(intval($day), [10, 20, 30])) {
+                $day = str_replace('0', '', $day);
+            }
+            return $month.'-'.$day.' '.$parsedTime;
+        }
+    }
+ 
+}

+ 96 - 0
www/protected/modules/moonclub/models/Material.php

@@ -0,0 +1,96 @@
+<?php 
+/**
+ * 物资
+ * @author zhouxuchen 2015-09-16
+ */
+class Material extends MongoAr {
+
+    public $_id;
+    public $name;           // 物资的名称
+    public $unit_str;       // 物资的单位(文字)
+    public $unit;           // 物资的单位
+    public $price;          // 物资的单价
+    public $stock;          // 物资的库存
+    public $stockWarnLine;  // 库存警戒线
+    public $addTime;        // 物资加入的时间
+    public $status;         // 物资的库存状态
+    public $status_str;     // 物资的库存状态(文字)
+    public $enable;         // 是否启用此物资
+    public $enable_str;     // 是否启用此物资
+    public $remarks;        // 该物资的备注
+
+    public static $status_option = array(
+        0 => array('name' => '无库存'),
+        1 => array('name' => '紧张'),
+        2 => array('name' => '充足'),
+        3 => array('name' => '未知')
+    );
+
+    public static $enable_option = array(
+        0 => array('name' => '停用'),
+        1 => array('name' => '启用')
+    );
+
+    public static $unit_option = array(
+        1 => array('name' => '瓶'),
+        2 => array('name' => '袋'),
+        3 => array('name' => '盒'),
+        4 => array('name' => '台'),
+        5 => array('name' => '件'),
+        6 => array('name' => '双'),
+        7 => array('name' => '只'),
+        8 => array('name' => '个'),
+        9 => array('name' => '套'),
+        10 => array('name' => '副'),
+        11 => array('name' => '毫升')
+    );
+
+    public function __construct($scenario='insert') {
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static function model($className = __CLASS__) {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function getCollectionName () {
+        return 'material';
+    }
+
+    public function parseRow($row, $output = array()) {
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['name'] = CommonFn::get_val_if_isset($row, 'name', '');
+        $newRow['unit_str'] = CommonFn::get_val_if_isset($row, 'unit_str', '');
+        $newRow['unit'] = CommonFn::get_val_if_isset($row, 'unit', 0);
+        $newRow['price'] = CommonFn::get_val_if_isset($row, 'price', 0.00);
+        $newRow['stock'] = CommonFn::get_val_if_isset($row, 'stock', 0);
+        $newRow['stockWarnLine'] = CommonFn::get_val_if_isset($row, 'stockWarnLine', 0);
+        $newRow['addTime'] = date('Y-m-d H:i', CommonFn::get_val_if_isset($row, 'addTime', 0));
+        $newRow['status_str'] = CommonFn::get_val_if_isset($row, 'status_str', '');
+        $newRow['status'] = CommonFn::get_val_if_isset($row, 'status', 0);
+
+        $newRow['enable'] = CommonFn::get_val_if_isset($row, 'enable', 0);
+        $newRow['enable_str'] = CommonFn::get_val_if_isset($row, 'enable_str', 0);
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row, 'action_user', '');
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row, 'action_time', '');
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row, 'action_log', '');
+
+        $newRow['material_remarks'] = CommonFn::get_val_if_isset($row, 'remarks', '');
+
+        return $this->output($newRow, $output);
+    }
+}
+?>

+ 93 - 0
www/protected/modules/moonclub/models/Product.php

@@ -0,0 +1,93 @@
+<?php
+/**
+ * User: charlie
+ * 商品/服务
+ */
+class Product extends MongoAr
+{
+    public $_id;
+    public $name;//服务的名字
+    public $status=0;//产品状态 0=>暂停使用  1=>正常使用   -1=>已删除
+    public $order=0;//产品权重
+    public $type;//服务的适用类型
+    public $is_extra=0;
+    public $desc;//图文介绍   json格式  [{  // 图文详情"type": 1,  //  1: 图片url, 2: 纯文本 "content": "http://a.big.jpg"}, {"type": 1,"content": "http://b.big.jpg"}, {"type": 2,"content": "描述文案..."},  // ... ]
+    public $pics=array();//七牛的地址  array('url'=>'http://xxx.qiniudn.com/1414476356856.jpg','height'=>1180,'width'=>2340)
+
+    public $price=0;//商品的单价  单位:元
+
+    public $extra=array();//array('types'=>array(array('type'=>'一室一卫','price'=>180),array('type'=>'二室一卫','price'=>280)))
+
+    public static $status_option = array(
+        0 => array('name' => '暂停使用'),
+        1 => array('name' => '正常使用'),
+        -1 => array('name' => '已删除')
+    ); 
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function getCollectionName()
+    {
+        return 'products';
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['price'] = CommonFn::get_val_if_isset($row,'price',0);
+
+        $newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
+        $newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
+
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
+        $newRow['is_extra'] = CommonFn::get_val_if_isset($row,'is_extra',0);
+
+
+        $newRow['order'] = CommonFn::get_val_if_isset($row,'order',1);
+
+        $newRow['type'] = CommonFn::get_val_if_isset($row,'type',1);
+        $newRow['type_str'] = Yii::app()->params['o2o_service'][$newRow['type']]['name'];
+
+        $newRow['extra'] = CommonFn::get_val_if_isset($row,'extra',array());
+
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        $newRow['pics'] = CommonFn::get_val_if_isset($row,'pics',array());
+        if(empty($newRow['pics'])){
+            $newRow['pics'] = CommonFn::$empty;
+        }
+
+
+        if(APPLICATION=='api'){
+            //unset($newRow['status']);
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+
+        return $this->output($newRow,$output);
+    }
+
+}

+ 88 - 0
www/protected/modules/moonclub/models/Question.php

@@ -0,0 +1,88 @@
+<?php
+class Question extends MongoAr
+{
+    public $_id;    //问题的object id
+    public $content;//内容
+    public $time;//问题发表时间
+
+    public $user;//作者object id
+    public $quote;//引用的问题object id
+    public $type;//
+    public $status=1;//状态   1正常   0删除   -1垃圾
+    public $weight=0;//问题的权重
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_data'));
+        parent::__construct($scenario);
+    }
+
+    public static $status_option = array(
+        1 => array('name' => '正常'),
+        0 => array('name' => '删除'),
+        -1 => array('name' => '垃圾')
+    );
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'question';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['content'] = CommonFn::get_val_if_isset($row,'content','');
+
+        $newRow['time'] = CommonFn::get_val_if_isset($row,'time',time());
+        $newRow['time_str'] = CommonFn::sgmdate("Y年n月d日", $newRow['time'],1);
+
+        $user = array();
+        if(isset($row['user'])){
+            $_user = RUser::get($row['user']);
+            $user = RUser::model()->parseRow($_user->attributes,array('user_name','certify_status','certify_info','user_type','can_be_message','can_access','level','id','avatar','is_fake_user'));
+        }
+        $newRow['user'] = $user;
+
+        $quote = array();
+        if(!empty($row['quote'])){
+            $_question = self::get($row['quote']);
+            $quote['id'] = (string)$row['quote'];
+            $quote['content'] = $_question->content;
+            $quote['status'] = $_question->status;
+            $quote['time'] = $_question->time;
+            $_user = RUser::get($_question->user);
+            $puser = RUser::model()->parse($_user->attributes,false,array('id','certify_status','certify_info','user_type','can_be_message','can_access','user_name'));
+            $quote['user'] = $puser;
+        }else{
+            $quote = (object)$quote;
+        }
+        $newRow['quote'] = $quote;
+        $newRow['weight'] = CommonFn::get_val_if_isset($row,'weight',0);
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+        if(APPLICATION=='api'||APPLICATION=='common'){
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+        return $this->output($newRow,$output);
+    }
+
+}

+ 505 - 0
www/protected/modules/moonclub/models/ROrder.php

@@ -0,0 +1,505 @@
+<?php
+/**
+ * User: charlie
+ * O2O 订单表
+ */
+class ROrder extends MongoAr
+{
+    public $_id;
+
+    // public $pay_id;//由ping++生成的支付单号
+    //public $pay_type;//用户的支付方式
+
+    public $charge_id;//ping++的chargeId,charge_id即为支付单号
+    public $pay_channel;//支付渠道
+    public $channel;//订单来源渠道
+    public $precedence = 0;//加急 默认0
+    public $booking_time; //用户预约的时间
+    public $order_time;  //订单生成时间
+    public $deal_time;  //订单处理时间
+    public $take_time;  //接单时间
+    public $set_out_time;  //出发时间
+    public $arrive_time;  //到达时间
+    public $finish_time;  //完成时间
+    public $cancel_time;  //订单取消时间
+    public $apply_refund_time;  //订单申请退款时间
+    public $refund_time;  //订单退款时间
+    public $append_orders = array();
+    public $products=array(); //订单包含的商品数组   数据库设计  支持多个产品在一个订单
+    public $station = '';//服务网点,station的mongoid
+    public $price;  //订单金额
+    public $OrderNo;//JingBai订单id
+    public $final_price;  //订单使用代金券之后的金额  如果没有使用代金券   $final_price=$price
+    public $pay_price;//订单最终支付的金额  price-coupons-用户要支付的余额
+
+    public $signUrl;//签字图片链接 上传到七牛
+    public $coupons=array();//订单使用的代金券  数据库设计可以支持多张
+    
+    public $coupon_type;
+
+
+    public $user;  //对应的RUser 的mongoid
+    public $status=0;//订单状态 0=>待支付  1=>已支付  2=>已处理  3=>已接单  4=>已出发  5=>已上门 6=>已完成 -1=>已取消 -2=>已退款
+
+    public $memo = '';//用户备注
+    public $remark = '';//后台备注
+
+    public $type = 0;//订单类型
+
+    public $counts=1;//预订的数量
+
+    public $have_comment = 0; //是否已评价
+
+    public $technicians = array(); // 接单保洁师
+    //public $technician = ''; // 接单保洁师,user的id
+    //public $technician_name = ''; // 接单保洁师姓名
+
+    public $address = array(); //地址信息   包含   province  city  area position detail   name  mobile position
+
+
+    public static $order_filter = array(
+        0 => array('name' => '未选择'),
+        1 => array('name' => '来源'),
+        2 => array('name' => '服务'),
+        3 => array('name' => '状态')
+    );
+
+    public static $status_option = array(
+        0 => array('name' => '待支付'),
+        1 => array('name' => '已支付'),
+        2 => array('name' => '已处理'),
+        3 => array('name' => '已接单'),
+        4 => array('name' => '已出发'),
+        5 => array('name' => '已上门'),
+        6 => array('name' => '已完成'),
+        7 => array('name' => '退款中'),
+        -1 => array('name' => '已取消'),
+        -2 => array('name' => '已退款'),
+        -3 => array('name' => '申请退款'),
+    );
+
+
+    public static $channel_option = array(
+        "wx_pub" => array('name' => '微信公众号'),
+        "dongfang" => array('name' => '东方CJ'),
+        "youzan" => array('name' => '有赞'),
+        "shihui" => array('name' => '实惠'),
+        "shangmenshoukuan" => array('name' => '保洁师上门收款'),
+        "balance"=>array('name' => '余额支付'),
+        "mix"=>array('name' => '混合支付'),  //部分余额支付   部分付款
+        "jingbai" => array('name' => '精佰'),
+        "other" => array('name' => '其他'),
+
+    );
+
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+
+    public function getCollectionName()
+    {
+        return 'orders';
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        // $newRow['pay_id'] = CommonFn::get_val_if_isset($row,'pay_id','');
+        $newRow['pay_channel'] = CommonFn::get_val_if_isset($row,'pay_channel','');
+        $newRow['charge_id'] = CommonFn::get_val_if_isset($row,'charge_id','');
+        $newRow['channel'] = CommonFn::get_val_if_isset($row,'channel','wx_pub');
+        $newRow['type'] = CommonFn::get_val_if_isset($row,'type','');
+
+        $newRow['counts'] = CommonFn::get_val_if_isset($row,'counts',1);
+        $newRow['booking_time'] = CommonFn::get_val_if_isset($row,'booking_time',0);
+        $newRow['order_time'] = CommonFn::get_val_if_isset($row,'order_time',0);
+        $newRow['have_comment'] = CommonFn::get_val_if_isset($row,'have_comment',0);
+        $newRow['order_num'] = $newRow['order_time'].hexdec(substr((string)$row['user'],-3));
+        $newRow['deal_time'] = CommonFn::get_val_if_isset($row,'deal_time',0);
+        $newRow['take_time'] = CommonFn::get_val_if_isset($row,'take_time',0);
+        $newRow['set_out_time'] = CommonFn::get_val_if_isset($row,'set_out_time',0);
+        $newRow['arrive_time'] = CommonFn::get_val_if_isset($row,'arrive_time',0);
+        $newRow['finish_time'] = CommonFn::get_val_if_isset($row,'finish_time',0);
+        $newRow['cancel_time'] = CommonFn::get_val_if_isset($row,'cancel_time',0);
+        $newRow['apply_refund_time'] = CommonFn::get_val_if_isset($row,'apply_refund_time',0);
+        $newRow['apply_refund_time_str'] = $newRow['apply_refund_time']?date('Y年n月d日 H:i',$newRow['apply_refund_time']):'';
+        $newRow['refund_time'] = CommonFn::get_val_if_isset($row,'refund_time',0);
+        $newRow['booking_time_str'] = date('Y年n月d日 H:i',$newRow['booking_time']);
+        $newRow['order_time_str'] =   date("n月d日 H:i", $newRow['order_time']);
+        $newRow['deal_time_str'] = $newRow['deal_time']?CommonFn::sgmdate("Y年n月d日:H:i:s", $newRow['deal_time'],1):'';
+        $newRow['take_time_str'] = $newRow['take_time']?CommonFn::sgmdate("Y年n月d日:H:i:s", $newRow['take_time'],1):'';
+        $newRow['set_out_time_str'] = $newRow['set_out_time']?CommonFn::sgmdate("Y年n月d日:H:i:s", $newRow['set_out_time'],1):'';
+        $newRow['arrive_time_str'] = $newRow['arrive_time']?CommonFn::sgmdate("Y年n月d日:H:i:s", $newRow['arrive_time'],1):'';
+        $newRow['finish_time_str'] = $newRow['finish_time']?CommonFn::sgmdate("Y年n月d日:H:i:s", $newRow['finish_time'],1):'';
+        $newRow['cancel_time_str'] = $newRow['cancel_time']?CommonFn::sgmdate("Y年n月d日:H:i:s", $newRow['cancel_time'],1):'';
+        $newRow['refund_time_str'] = $newRow['refund_time']?CommonFn::sgmdate("Y年n月d日:H:i:s", $newRow['refund_time'],1):'';
+
+        $newRow['signUrl'] = CommonFn::get_val_if_isset($row,'signUrl','');
+        $newRow['sum_price'] = 0;
+        $newRow['price'] = floatval(CommonFn::get_val_if_isset($row,'price',0));
+
+        $newRow['af_sum_price'] = $newRow['price'];
+        $newRow['final_price'] = floatval(CommonFn::get_val_if_isset($row,'final_price',0));
+        $newRow['pay_price'] = floatval(CommonFn::get_val_if_isset($row,'pay_price',$newRow['final_price']));
+        $newRow['sum_price'] = $newRow['final_price'];
+        $newRow['memo'] = CommonFn::get_val_if_isset($row,'memo','');
+        $newRow['remark'] = CommonFn::get_val_if_isset($row,'remark','');
+        $newRow['technicians'] = CommonFn::get_val_if_isset($row,'technicians','');
+        $user = array();
+        $t_user = new ZUser();
+        if(isset($row['user']) && $row['user']){
+            $_user = $t_user->get($row['user']);
+            $user = RUser::model()->parseRow($_user->attributes,array('user_name','id','avatar'));
+            $user['otherPlatform'] = 0;
+        }else{
+            $user_name = self::$channel_option[$newRow['channel']]['name'].'用户';
+            $user = array('user_name'=>$user_name,'id'=>'','avatar'=>Yii::app()->params['defaultUserAvatar'], 'otherPlatform' => 1);
+        }
+        $newRow['user'] = $user;
+
+
+        $products = array();
+        // $t_component = new ZComponent();
+        $newRow['products_str'] = '';
+        if(isset($row['products'])&&is_array($row['products'])){
+            // $_products = $t_component->getList(Product::model(),$row['products']);
+            foreach ($row['products'] as $key => $product) {
+                $product_obj = Product::get($product['product']);
+                $temp_info = $product_obj->parseRow($product_obj);
+                //echo(json_encode($temp_info));exit;
+                $temp_info['count'] = $product['count'];
+                //$temp_info['extra'] = $product['extra'];
+                $products[] = array('product'=>$temp_info,'extra'=>$product['extra']);
+                //$temp_info['extra'] = $product['extra'];
+                if($key == 0){
+                    $newRow['products_str'] .= $temp_info['name'];
+                }else{
+                    $newRow['products_str'] .= '+'.$temp_info['name'];
+                }
+            }
+        }
+        $newRow['products'] = $products;
+        if(!isset($newRow['products'])||empty($newRow['products'])){
+            $newRow['products']=CommonFn::$empty;
+        }
+        $newRow['station'] = (object)array();
+        if(isset($row['station'])){
+            $staion = Station::get($row['station']);
+            $staion = Station::model()->parseRow($staion,array('id','name'));
+
+            $newRow['station'] = $staion;
+            $newRow['station_id'] = $staion['id'];
+            $newRow['station_name'] = $staion['name'];
+        }
+
+
+        foreach( $newRow['technicians'] as $technicians) {
+            $newRow['technician'] = $technicians;
+            if ($newRow['technician']) {
+                $tech_info = TechInfo::get($newRow['technician']);
+                if ($tech_info) {
+                    $newRow['tech_info'][] = TechInfo::model()->parseRow($tech_info, array('id', 'name', 'mobile', 'weixin_userid'));
+                } else {
+                    $newRow['tech_info'][] = [];
+                }
+            } else {
+                $newRow['tech_info'][] = [];
+            }
+        }
+        //$newRow['technician_name'] = isset($newRow['tech_info']['name']) ? $newRow['tech_info']['name'] : '';
+
+       // $newRow['hasSendTec'] = $newRow['technicians'] == 0 ? 0:1;
+        foreach($newRow['technicians'] as $technician) {
+            if ($technician == 0) {
+                $newRow['hasSendTec'] = 0;
+            } else {
+                $newRow['hasSendTec'] = 1;
+            }
+        }
+        $coupons = array();
+        if(isset($row['coupons'])&&is_array($row['coupons'])){
+            foreach ($row['coupons'] as $coupon) {
+                $user_coupon_obj = UserCoupon::get($coupon);
+                if(!$user_coupon_obj){
+                    continue;
+                }
+                $coupons[] = $user_coupon_obj->parseRow($user_coupon_obj);
+            }
+        }
+        $newRow['coupons'] = $coupons;
+        if(!isset($newRow['coupons'])||empty($newRow['coupons'])){
+            $newRow['coupons']=CommonFn::$empty;
+        }
+
+
+        if(!isset($newRow['coupons'])||empty($newRow['coupons'])){
+            $newRow['coupons']=CommonFn::$empty;
+        }
+
+
+        $newRow['address'] = CommonFn::get_val_if_isset($row,'address',array("province"=>"","city"=>"","area"=>"","address_info"=>"","name"=>"","mobile"=>"","position"=>array(121,31)));
+        if(!isset($newRow['address']['province'])){
+            $newRow['address']['province'] = '';
+        }
+        if(!isset($newRow['address']['city'])){
+            $newRow['address']['city'] = '';
+        }
+        if(!isset($newRow['address']['area'])){
+            $newRow['address']['area'] = '';
+        }
+        if(!isset($newRow['address']['detail'])){
+            $newRow['address']['detail'] = '';
+        }
+        if(!isset($newRow['address']['name'])){
+            $newRow['address']['name'] = '';
+        }
+        if(!isset($newRow['address']['mobile'])){
+            $newRow['address']['mobile'] = '';
+        }
+        if(!isset($newRow['address']['position'])){
+            $newRow['address']['position'] = array(121,31);
+        }
+        if(!isset($newRow['address']['poi']) || !isset($newRow['address']['poi']['name'])){
+            $newRow['address']['poi'] = array('name'=>'','uid'=>'');
+        }
+//echo(ROrder::$status_option[$newRow['status']]);exit;
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
+        $newRow['status_str'] = ROrder::$status_option[$newRow['status']]['name'];
+        $newRow['book_status'] = '';
+        if($newRow['status'] == 6){
+            $newRow['book_status'] = 3;
+            $newRow['book_status_str'] = '已完成';
+        }elseif ($newRow['status'] == -1) {
+            $newRow['book_status'] = 2;
+            $newRow['book_status_str'] = '已取消';
+        }else{
+            $newRow['book_status'] = 1;
+            $newRow['book_status_str'] = '预约中';
+        }
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        // 订单评分处理
+        if (intval($row['have_comment']) == 1) {
+            $criteria = new EMongoCriteria();
+            $criteria->order = $row['_id'];
+            $comment = Comment::model()->find($criteria);
+            $newRow['score'] = $comment->score;
+            $newRow['commentId'] = (string)$comment->_id;
+        } else {
+            $newRow['score'] = 100;
+            $newRow['commentId'] = '';
+        }
+
+        if(APPLICATION=='admin'){
+            if($newRow['address']['mobile']){
+                $mongo = new MongoClient(DB_CONNETC);
+
+                $where = array();
+
+                $where['address.mobile'] = $newRow['address']['mobile'];
+                $where['status'] = array('$gt'=>0);
+
+                $newRow['order_count'] = $mongo->fuwu->orders->count($where);
+            }else{
+                $newRow['order_count'] = 0;
+            }
+
+        }
+
+        if(APPLICATION=='api'){
+            unset($newRow['charge_id']);
+
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+        return $this->output($newRow,$output);
+    }
+
+    /**
+     * ROrder保存后的回调函数
+     */
+    protected function afterSave() {
+        parent::afterSave();
+
+
+        // 生成保洁师提成并保存
+        if ($this->status == 6 && !empty($this->technicians)) {
+            // 订单时间检查
+            // 预定时间是否在12月之后
+            $time = time();
+            if ($this->booking_time >= strtotime('2015-11-01')) {
+                // 若完成时间与预定时间相差大于7天,则完成时间为预定时间+3天
+                if ($this->booking_time + 604800 < $time) {
+                    $time = $this->booking_time + 259200;
+                }
+            } else {
+                return true;
+            }
+
+            $order = $this->_id;
+            $commisionObj = Commision::getByOrder($order);
+
+            // 检查Cmmmision信息是否已录入
+           foreach ($this->technicians as $key => $value) {
+               $technician_id = $value['technician_id'];
+               $technician = $value['technician_name'];
+               $tech = TechInfo::get($technician_id);
+               if ($commisionObj == false) {
+                   // 普通订单生成提成并保存
+                   $commisionObj = new Commision();
+                   $commisionObj->time = empty($this->finish_time) ? $time : $this->finish_time;
+                   $commisionObj->booking_time = $this->booking_time;
+                   $commisionObj->user = $technician;
+                   $commisionObj->order = $this->_id;
+                   $commisionObj->commision = Commision::getCommision($this, Commision::MAIN, $tech->scheme);
+                   $commisionObj->type = Commision::MAIN;
+                   $commisionObj->insert();
+
+                   // 订单内附加订单生成提成并保存
+                   $appends = $this->append_orders;
+                   if (!empty($appends)) {
+                       $criteria = new EMongoCriteria();
+                       $criteria->_id('in', $appends);
+                       $appendOrders = AppendOrder::model()->findAll($criteria);
+                       foreach ($appendOrders as $key => $row) {
+                           if ($row->status != 1) {
+                               continue;
+                           }
+                           $commisionObj = new Commision();
+                           $commisionObj->time = empty($this->finish_time) ? $time : $this->finish_time;
+                           $commisionObj->booking_time = $this->booking_time;
+                           $commisionObj->user = $technician;
+                           $commisionObj->order = $row->_id;
+                           $commisionObj->commision = Commision::getCommision($row, Commision::APPEND, $tech->scheme);
+                           $commisionObj->type = Commision::APPEND;
+                           $commisionObj->insert();
+                       }
+                   }
+               }
+
+
+               // 提示保洁师订单已完成
+               if ($tech && $tech->weixin_userid) {
+                   // 检查订单评价是否存在,若存在则不发送
+                   $comment = Comment::getByOrder($this->_id);
+                   if (!$comment) {
+                       $wechat = O2oApp::getWechatActive();
+                       $url_prefix = ENVIRONMENT == 'product' ? 'http:// api.yiguanjia.me' : 'http:// apitest.yiguanjia.me';
+                       $wechat_data = [
+                           'touser' => $tech->weixin_userid,
+                           'msgtype' => 'news',
+                           'agentid' => '24',
+                           'news' => [
+                               'articles' => [
+                                   [
+                                       'title' => '壹管家提示-订单已完成',
+                                       'description' => $tech->name . '你好!预定时间在' . date('m月d日H:i', $this->booking_time) . '的订单已完成,请点击查看订单情况。',
+                                       'url' => $url_prefix . '/index.php?r=o2o/myCommision/info&order=' . (string)$order . '&user=' . $technician . '&type=0',
+                                   ],
+                               ],
+                           ],
+                       ];
+                       $wechat->sendMessage($wechat_data);
+                   }
+               }
+           }
+       }
+
+    }
+    //取消订单
+    public function delOrder($orderId){
+        $data['key']         = Yii::app()->params['shKey'];
+        $data['version']     = '1.0';
+        $data['serviceType'] = (int)26;
+        $data['orderId']     = $orderId;
+        echo self::curl_post($data);
+    }
+
+    //更新订单状态
+    public function actionUpdateStatus($orderId,$status){
+        $data['key']         = Yii::app()->params['shKey'];
+        $data['version']     = '1.0';
+        $data['serviceType'] = (int)26;
+        $data['orderId']     = $orderId;
+        $data['status']      = $status;
+        echo self::curl_post($data);
+
+    }
+    //查询订单状态
+    /*public function actionQueryOrder(){
+        $data['key']         = Yii::app()->params['shKey'];
+        $data['version']     = '1.0';
+        $data['serviceType'] = (int)26;
+        $data['orderId']     = '57fde8059f5160c4048b4aeb';
+        $data['status']      = '-1';
+        ksort($data);
+        $str = '';
+        $dat = '';
+        foreach ($data as $key => $value) {
+            $str .= $key.'='.$value.'&';
+            $dat .= $key.'='.urlencode($value).'&';
+        }
+        $str = rtrim(trim($str),'&');
+        $str .= $str.Yii::app()->params['shMd5Key'];
+
+        $data['sign'] = strtoupper(md5($str));
+        $dat .= 'sign='.urlencode($data['sign']);//构建post 参数
+        $url = 'http://test2.app.hiwemeet.com/v2/openpf/home/order/thirdOrder/detail';  //调用接口的平台服务地址
+
+        $url .= '?'.$dat;
+        $result = CommonFn::simple_http($url);
+        echo $result;
+
+    }*/
+
+    public function curl_post($data){
+        ksort($data);
+        $str = '';
+        $dat = '';
+        foreach ($data as $key => $value) {
+            $str .= $key.'='.$value.'&';
+            $dat .= $key.'='.urlencode($value).'&';
+        }
+        $str = rtrim(trim($str),'&');
+        $str .= $str.Yii::app()->params['shMd5Key'];
+
+        $data['sign'] = strtoupper(md5($str));
+        $dat .= 'sign='.urlencode($data['sign']);//构建post 参数
+        $url = 'http://test2.app.hiwemeet.com/v2/openpf/home/order/thirdOrder/cancel';  //调用接口的平台服务地址
+
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $dat);
+        $result = curl_exec($ch);
+        curl_close($ch);
+        return  $result;
+    }
+
+}

+ 90 - 0
www/protected/modules/moonclub/models/Recharge.php

@@ -0,0 +1,90 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/9/26
+ * Time: 11:57
+ * 会员充值卡模型
+ */
+class Recharge extends MongoAr
+{
+    public $_id;
+
+    public $denomination;//充值面额
+
+    public $coupons = array();//赠送的优惠券
+
+    public $cash_back;//返现的金额
+
+    public $desc;//介绍
+
+    public $status=1;//充值卡状态  1 正常使用   0 暂停使用   -1 已删除
+    public $order;//排序权重
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static $status_option = array(
+        1 => array('name' => '正常'),
+        0 => array('name' => '暂停'),
+        -1 => array('name' => '删除')
+    );
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'recharge';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['denomination'] = CommonFn::get_val_if_isset($row,'denomination',0);
+        $newRow['cash_back'] = CommonFn::get_val_if_isset($row,'cash_back',0);
+        $newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
+        $newRow['order'] = CommonFn::get_val_if_isset($row,'order',1);
+
+        $coupons = array();
+        if(isset($row['coupons'])&&is_array($row['coupons'])&&!empty($row['coupons'])){
+            $where = array('_id' => array('$in' => array_values($row['coupons'])));
+            $cursor = Coupon::model()->getCollection()->find($where, array('_id','name'));
+            foreach ($cursor as $v){
+                $_id = (array)$v['_id'];
+                unset($v['_id']);
+                $v['id'] = $_id['$id'];
+                $coupons[] = $v;
+            }
+        }
+
+        $newRow['coupons'] = $coupons;
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+        if  (APPLICATION=='api'||APPLICATION=='common'){
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+        return $this->output($newRow,$output);
+    }
+
+
+}

+ 44 - 0
www/protected/modules/moonclub/models/RechargeLog.php

@@ -0,0 +1,44 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/9/26
+ * Time: 11:57
+ * 会员充值日志
+ */
+class RechargeLog extends MongoAr
+{
+    public $_id;
+
+    public $user;//充值用户 mongoid
+
+    public $time;//充值时间
+
+    public $recharge;//充值卡  mongoid
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'recharge_log';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+}

+ 55 - 0
www/protected/modules/moonclub/models/RechargeOrder.php

@@ -0,0 +1,55 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/9/26
+ * Time: 11:57
+ * 充值卡 订单模型
+ */
+class RechargeOrder extends MongoAr
+{
+    public $_id;
+
+    public $user;//充值用户 mongoid
+
+    public $time;//充值时间
+
+    public $recharge;//充值卡  mongoid
+
+    public $charge_id;//ping++的chargeId,charge_id即为支付单号
+    public $pay_channel;//支付渠道
+
+    public $price;  //订单金额
+    public $status=0;//订单状态 0=>待支付  1=>已支付
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static $status_option = array(
+        0 => array('name' => '待支付'),
+        1 => array('name' => '已支付'),
+    );
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'recharge_order';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+}

+ 44 - 0
www/protected/modules/moonclub/models/SendCouponLog.php

@@ -0,0 +1,44 @@
+<?php
+/**
+ * User: charlie
+ * 用户的代金券
+ */
+class SendCouponLog extends MongoAr
+{
+    public $_id;
+
+    public $user_id;//发放用户的id
+    public $device_id;//发放用户的device_id
+    public $batch;//最后一次发放优惠券的批次
+    public $last_batch_time;//上次发放优惠券的时间
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+    
+
+    public function getCollectionName()
+    {
+        return 'send_coupon_log';
+    }
+
+ 
+}

+ 112 - 0
www/protected/modules/moonclub/models/Station.php

@@ -0,0 +1,112 @@
+<?php
+/**
+ * User: charlie
+ * 服务点
+ */
+class Station extends MongoAr
+{
+    public $_id;
+    public $status=0;//服务点状态 0=>待营业  1=>正常营业 -1=>暂停营业  -2=>已删除
+
+    public $name;//服务点名字
+
+    public $start_time=9;//开始服务时间  如9   每天9点开始
+    public $end_time=20;//结束服务时间    如20    每天20点停止接受订单
+
+    //public $city_info = array();          //所属的城市信息    "province"=>"上海","city"=>"上海","area"=>"浦东"  "business"=>"世纪公园"  或者   "province"=>"江苏","city"=>"苏州","area"="昆山"
+    //public $address;//服务点详细地址
+    //public $position=array();   //坐标
+    public $address = array(); //地址信息   包含   province  city  area business position detail
+
+    public $beauticians_count=1;  //保洁师数量
+    public $coverage = array();//服务范围
+
+    public $types = array();//该服务点  支持的服务项目  
+
+    public static $status_option = array(
+        0 => array('name' => '待营业'),
+        1 => array('name' => '正常营业'),
+        -1 => array('name' => '暂停营业'),
+        -2 => array('name' => '已删除'),
+    );
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'stations';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+    
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        $newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
+
+        $newRow['start_time'] = CommonFn::get_val_if_isset($row,'start_time',9);
+        $newRow['end_time'] = CommonFn::get_val_if_isset($row,'end_time',21);
+
+        $newRow['address'] = CommonFn::get_val_if_isset($row,'address',array("province"=>"","city"=>"","area"=>"","detail"=>"","business"=>"","position"=>""));
+        if(!isset($newRow['address']['province'])){
+            $newRow['address']['province'] = '';
+        }
+        if(!isset($newRow['address']['city'])){
+            $newRow['address']['city'] = '';
+        }
+        if(!isset($newRow['address']['area'])){
+            $newRow['address']['area'] = '';
+        }
+        if(!isset($newRow['address']['business'])){
+            $newRow['address']['business'] = '';
+        }
+        if(!isset($newRow['address']['detail'])){
+            $newRow['address']['detail'] = '';
+        }
+        if(!isset($newRow['address']['position'])){
+            $newRow['address']['position'] = array(121,31);
+        }
+
+
+        $newRow['coverage'] = CommonFn::get_val_if_isset($row,'coverage',array());
+
+        $newRow['types'] = CommonFn::get_val_if_isset($row,'types',array());
+
+        $newRow['beauticians_count'] = CommonFn::get_val_if_isset($row,'beauticians_count',1);
+
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
+
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        if(APPLICATION=='api'){
+            //unset($newRow['status']);
+            unset($newRow['action_user']);
+            unset($newRow['action_time']);
+            unset($newRow['action_log']);
+        }
+
+        return $this->output($newRow,$output);
+    }
+
+}

+ 84 - 0
www/protected/modules/moonclub/models/Stock.php

@@ -0,0 +1,84 @@
+<?php 
+/**
+ * 物资领取情况模型
+ * @author     2015-09-18
+ */
+class Stock extends MongoAr {
+    public $_id;
+    public $mid;            // 对应物资的id
+    public $mname;          // 对应物资的name
+    public $user;           // 对应的User 的id
+    public $username;       // 对应的Username
+    public $time;           // 操作的时间
+    public $operate;        // 操作的类型 0=>减少 1=>增加
+    public $operate_str;    // 操作的类型
+    public $num;            // 数量
+    public $tot_price;      // 总价
+    public $lastStock;      // 操作前库存数
+    public $newStock;       // 操作后库存数
+    public $remarks;        // 本次操作的备注信息
+    public $object;         // 本次操作的对象ID
+    public $objectName;     // 本次操作对象的name
+    public $station;        // 领取人员所在区域
+    public $stationName;    // 领取人员所在区域的名称
+
+    public static $operate_option = array(
+        1 => array('name' => '入库'),
+        0 => array('name' => '出库')
+    );
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static function model($className=__CLASS__) {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+    public function getCollectionName () {
+        return 'stock';
+    }
+
+    public function parseRow($row, $output = array()) {
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['mid'] = (string)$row['mid'];
+        $newRow['mname'] = CommonFn::get_val_if_isset($row, 'mname', '');
+        $newRow['user'] = CommonFn::get_val_if_isset($row, 'user', '');
+        $newRow['username'] = CommonFn::get_val_if_isset($row, 'username', '');
+        $newRow['time'] = date('Y-m-d H:i:s', intval(CommonFn::get_val_if_isset($row, 'time', 0)));
+        $newRow['operate'] = intval(CommonFn::get_val_if_isset($row,'operate',1));
+        $newRow['operate_str'] = CommonFn::get_val_if_isset($row,'operate_str', '');
+        $newRow['num'] = intval(CommonFn::get_val_if_isset($row, 'num', 0));
+        $newRow['tot_price'] = CommonFn::get_val_if_isset($row,'tot_price', 0);
+        $newRow['lastStock'] = intval(CommonFn::get_val_if_isset($row, 'lastStock', 0));
+        $newRow['newStock'] = intval(CommonFn::get_val_if_isset($row, 'newStock', 0));
+        $newRow['remarks'] = CommonFn::get_val_if_isset($row,'remarks', '');
+        
+        $newRow['object'] = CommonFn::get_val_if_isset($row, 'object', '');
+        $newRow['objectName'] = CommonFn::get_val_if_isset($row, 'objectName', '');
+
+        $newRow['station'] = isset($row['station']) ? (string)$row['station'] : 'noStation';
+        $newRow['stationName'] = CommonFn::get_val_if_isset($row, 'stationName', '');
+
+        $newRow['action_user'] = CommonFn::get_val_if_isset($row, 'action_user', '');
+        $newRow['action_time'] = CommonFn::get_val_if_isset($row, 'action_time', '');
+        $newRow['action_log'] = CommonFn::get_val_if_isset($row, 'action_log', '');
+
+        return $this->output($newRow, $output);
+    }
+}
+
+?>

+ 119 - 0
www/protected/modules/moonclub/models/TechInfo.php

@@ -0,0 +1,119 @@
+<?php
+class TechInfo extends MongoAr {
+
+    public $_id;//使用后台用户id作为保洁师信息表主键
+    public $name;//姓名
+    public $desc = '';//描述
+    public $avatar;//头像
+    public $favourable_count=0;//好评数
+    public $order_count=0;//服务次数
+    public $coverage = [];//服务商圈镜像字段
+    public $business = [];//服务商圈
+    public $status;//状态,同User表
+    public $weixin_userid = '';//微信企业号内ID
+    public $mobile = '';//手机号
+    public $weixin_info = [];//微信企业号成员信息
+    public $scheme = 'no_scheme';//提成方案
+    public $service_type = [];//服务类型
+
+    public static $status_option = [
+        1  => ['name' => '正常',   'wx' => 1],
+        0  => ['name' => '待审核', 'wx' => 0],
+        -1 => ['name' => '已删除', 'wx' => 0],
+    ];
+
+    public function __construct($scenario='insert') {
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    public static function model($className=__CLASS__) {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        $criteria = new EMongoCriteria();
+        $criteria->_id('==', intval($_id));
+        $tech = self::model()->find($criteria);
+        return $tech;
+    }
+
+    public static function getByUserid($userid) {
+        $criteria = new EMongoCriteria();
+        $criteria->weixin_userid = $userid;
+        $tech = self::model()->find($criteria);
+        return $tech;
+    }
+
+    public static function getByMobile($mobile) {
+        $criteria = new EMongoCriteria();
+        $criteria->mobile = $mobile;
+        $tech = self::model()->find($criteria);
+        return $tech;
+    }
+
+    public static function updateWeixinStatus($_id, $status) {
+        $tech = self::get($_id);
+        if ($tech) {
+            $weixin_userid = $tech->weixin_userid;
+            if ($weixin_userid) {
+                $weixin_enable = self::$status_option[$status]['wx'];
+                $user_data = [
+                    'userid' => $weixin_userid,
+                    'enable' => $weixin_enable,
+                ];
+                $option = WechatConfig::getIns()->getLinkOption();
+                $secret = WechatConfig::getIns()->getSecret('admin_dev');
+                $wechat = new QyWechat($option);
+                $wechat->checkAuth($option['appid'], $secret);
+                return $wechat->updateUser($user_data);
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+
+    public function getCollectionName() {
+        return 'technician_info';
+    }
+
+    public function parseRow($row, $output=[]) {
+        $newRow = [];
+
+        $newRow['_id']              = intval($row['_id']);
+        $newRow['name']             = CommonFn::get_val_if_isset($row, 'name', '');
+        $newRow['desc']             = CommonFn::get_val_if_isset($row, 'desc', '');
+        $newRow['avatar']           = CommonFn::get_val_if_isset($row, 'avatar', '');
+        $newRow['favourable_count'] = CommonFn::get_val_if_isset($row, 'favourable_count', 0);
+        $newRow['order_count']      = CommonFn::get_val_if_isset($row, 'order_count', 0);
+        $newRow['business']         = CommonFn::get_val_if_isset($row, 'business', []);
+        $newRow['coverage']         = CommonFn::get_val_if_isset($row, 'coverage', []);
+        $newRow['coverage_json']    = json_encode($newRow['coverage']);
+        $newRow['status']           = CommonFn::get_val_if_isset($row, 'status', 0);
+        $newRow['status_str']       = self::$status_option[$newRow['status']]['name'];
+        $newRow['weixin_userid']    = CommonFn::get_val_if_isset($row, 'weixin_userid', '');
+        $newRow['weixin_info']      = CommonFn::get_val_if_isset($row, 'wechat_info', (object)[]);
+        $newRow['mobile']           = CommonFn::get_val_if_isset($row, 'mobile', '');
+        $newRow['service_type']     = CommonFn::get_val_if_isset($row, 'service_type', []);
+
+        $scheme                     = CommonFn::get_val_if_isset($row, 'scheme', 'no_scheme');
+        $scheme_option              = Commision::$scheme_option;
+        if ($scheme == 'no_scheme') {
+            $newRow['scheme'] = -1;
+            $newRow['scheme_str'] = '未选择方案';
+        } else {
+            foreach ($scheme_option as $key => $item) {
+                if ($item['alias'] == $scheme) {
+                    $newRow['scheme'] = $key;
+                    $newRow['scheme_str'] = $item['name'];
+                    break;
+                }
+            }
+        }
+
+        return $this->output($newRow, $output);
+    }
+
+}

+ 89 - 0
www/protected/modules/moonclub/models/UserCoupon.php

@@ -0,0 +1,89 @@
+<?php
+/**
+ * User: charlie
+ * 用户的代金券
+ */
+class UserCoupon extends MongoAr
+{
+    public $_id;
+
+    public $start_time;//代金券的有效开始时间
+    public $end_time;//代金券的有效结束时间
+
+    public $coupon;//Coupon 的  mongoid
+    public $user;  //对应的RUser 的mongoid
+    public $user_device_id;  //对应的RUser 的user_device_id
+    public $use_time;
+
+    public $status=0;// 0=>暂停使用  1=>待使用 -1=>已使用 -2=>已过期
+
+    public static $status_option = array(
+        0 => array('name' => '暂停使用'),
+        1 => array('name' => '待使用'),
+        -1 => array('name' => '已使用'),
+        -2 => array('name' => '已过期'),
+    );
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+    
+
+    public function getCollectionName()
+    {
+        return 'user_coupons';
+    }
+
+    public function parseRow($row,$output=array()){
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+
+        $newRow['start_time'] = CommonFn::get_val_if_isset($row,'start_time',0);
+        $newRow['end_time'] = CommonFn::get_val_if_isset($row,'end_time',0);
+
+        $newRow['start_time_str'] =  date('Y.n.d',$newRow['start_time']);
+        $newRow['end_time_str'] = date('Y.n.d',$newRow['end_time']);
+
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
+
+        $user = array();
+        $t_user = new ZUser();
+        if(isset($row['user'])){
+            $_user = $t_user->get($row['user']);
+            if($_user){
+                $user = RUser::model()->parseRow($_user->attributes,array('user_name','id','avatar'));
+            }
+        }
+        $newRow['user'] = $user;
+
+        $coupon = array();
+        if(isset($row['coupon'])){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $row['coupon']);
+            $_coupon = Coupon::model()->find($criteria);
+            $coupon = Coupon::model()->parseRow($_coupon->attributes,array('name','id','value','type','alias_name','time_limit_str','type_str','workday_limit','time_limit_start','time_limit_end','workday_limit_str','min_price','status'));
+        }
+        $newRow['coupon'] = $coupon;
+
+        return $this->output($newRow,$output);
+    }
+
+}

+ 229 - 0
www/protected/modules/moonclub/views/advisory/SinglesDay.php

@@ -0,0 +1,229 @@
+<!DOCTYPE html>
+<!--HTML5 doctype-->
+<html ng-app="myapp">
+<head>
+  <title>壹管家</title>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+  <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+  <meta name="apple-mobile-web-app-capable" content="yes">
+  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
+  <meta http-equiv="Pragma" content="no-cache">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <!--引入css文件-->
+  <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/webapp/common/css/common.css">
+  <link rel="stylesheet" href=" <?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-3.3.7.min.css">
+  <!--引入js文件-->
+  <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery-3.1.1.min.js"></script>
+  <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/AngularJS v1.4.3.min.js"></script>
+  <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-3.3.7.min.js"></script>
+  <!--修改title-->
+  <script>
+    $(function () {
+      document.title = "壹管家";
+    })
+  </script>
+</head>
+<body ng-controller="myctrl">
+<div class="">
+  <form action="" method='post'
+        class="container  form-horizontal  ng-valid ng-dirty ng-valid-parse" id='singlesDay'
+        style="margin-bottom: 15%; ">
+    <div class="container">
+      <!--姓名-->
+      <div class="form-group">
+        <label>姓名:</label>
+        <input type="text" name='user_name' class="form-control username" placeholder="请输入您的姓名" ng-model="username">
+      </div>
+      <!--选择区域-->
+      <div class="form-group">
+        <label>选择区域:</label>
+        <select name="area" onchange="theforever(this.value)" class="form-control" ng-model="Area"
+                ng-init="Area=AreaList[0].id"
+                ng-options="info.name as info.name for info in AreaList" id="">
+          <option value="">--请选择--</option>
+        </select>
+      </div>
+      <!--房型-->
+      <div class="form-group">
+        <label>选择房型:</label>
+        <select name="homeType" onchange="theforever(this.value)" class="form-control" ng-model="Type"
+                ng-init="Type=TypeList[0].id"
+                ng-options="type.name as type.name for type in TypeList" id="">
+          <option value="">--请选择--</option>
+        </select>
+      </div>
+      <!--房源套数-->
+      <div class="form-group">
+        <label>选择房源套数:</label>
+        <select name="num" onchange="theforever(this.value)" class="form-control" ng-model="Num"
+                ng-init="Num=NumList[0].id"
+                ng-options="num.name as num.name for num in NumList" id="">
+          <option value="">--请选择--</option>
+        </select>
+      </div>
+      <!--手机号码-->
+      <div class="form-group">
+        <label>手机号码:</label>
+        <input type="text" name="mobile" class="form-control"
+               placeholder="请输入您的手机号码" ng-model="phone"/>
+      </div>
+      <!--性别-->
+      <div class="form-group">
+        <div style="display: inline-block;max-width: 100%;margin-bottom: 5px;font-weight: 700;">性别:</div>
+        <div>
+          <label class="radio-inline">
+            <input type="radio" name="sex" value="先生" ng-model="sex">先生
+          </label>
+          <label class="radio-inline">
+            <input type="radio" name="sex" value="女士" ng-model="sex">女士
+          </label>
+        </div>
+      </div>
+      <!--按钮-->
+      <div class="form-group">
+        <a id="SinglesDayBtn"
+          style="background: rgb(42,36,0);color:rgb(178,143,0);border: 0"
+          class="btn btn-success col-xs-12"
+          data-container="body"
+          data-toggle="popover"
+          data-placement="top"
+          data-content="{{btnContent}}">
+          提交
+        </a>
+      </div>
+    </div>
+  </form>
+</div>
+<div class="prevent-scroll">
+  <div class="box my-action">
+    <!--首页-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-my-order" href="/index.php?r=o2o/web/index#">
+          <div class="logo logo-my-order" style="margin-bottom: 5px;"></div>
+          <div class="name">首页</div>
+        </a>
+      </div>
+    </div>
+    <!--LOGO-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-logo" href="/index.php?r=o2o/advisory/im">
+          <div class="logo logo-my-logo"></div>
+        </a>
+      </div>
+    </div>
+    <!--我的-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-coupon">
+          <div class="logo logo-coupon" style="margin-bottom: 5px;"></div>
+          <div class="name">我的</div>
+        </a>
+      </div>
+    </div>
+  </div>
+</div>
+<!--模态框-->
+<div class="model" style="width: 100%;position: fixed;top: 0;background: rgba(0,0,0,0.4)">
+  <!--错误提示容器-->
+  <div class="model-box"
+       style="border-radius: 10px;height:130px;display:none;width: 70%;background: #fff;margin: 0 auto;top:25%;left:15%;position: fixed;">
+    <div class="model-title"
+         style="font-family: '微软雅黑', 'Microsoft YaHei', 'STHeiti Light';width: 100%;text-align: center;font-size: 1.1rem;margin-top: 5%;"></div>
+    <div class="model-content"
+         style="font-family: '微软雅黑', 'Microsoft YaHei', 'STHeiti Light';margin: 0 auto;width: 80%;background: rgb(42,36,0);color:rgb(178,143,0);font-size: 1.3rem;margin-top: 30px;text-align: center;padding: 5px 0 5px 0"></div>
+  </div>
+</div>
+</body>
+</html>
+<script>
+  var myapp = angular.module('myapp', []);
+  myapp.controller('myctrl', ['$scope', function ($scope) {
+    $('.model-content').on('click', function () {
+      if ($('.model-content').html() == '返回首页') {
+        window.location.href = '/index.php?r=o2o/web/index';
+      } else {
+        $('.model').css('height', '0');
+        $('.model-box').css('display', 'none');
+      }
+    });
+    /*表单提交进行判断*/
+    $('#SinglesDayBtn').on('click', function () {
+        /*姓名是否为空*/
+        if ($scope.username == undefined) {
+          model('请重填', '确认您的姓名');
+          return false;
+        }
+
+
+
+        /*验证手机号码*/
+        if (!(/^1[34578]\d{9}$/.test($scope.phone)) || $scope.phone == 0) {
+          model('请重填', '手机号码有误');
+          return false;
+        }
+        /*性别*/
+        if ($scope.sex == undefined) {
+          model('请重新选择', '确认');
+          return false;
+        }
+        /*model*/
+        $.ajax({
+          url: 'index.php?r=o2o/Advisory/SinglesDay',
+          type: 'POST',
+          dataType: 'html',
+          data: $('#singlesDay').serialize(),
+          success: function (message) {
+            model(message,'返回首页');
+
+          },
+          error: function (message) {
+            model('标题', '咨询失败');
+          }
+
+
+        });
+
+        function model(title, content) {
+          $('.model-box').css('display', 'inline');
+          $('.model').height(window.screen.height);
+          $('.model-title').html(title);
+          $('.model-content').html(content);
+        }
+      }
+    );
+
+    $scope.AreaList = [
+      {'id': 1, 'name': '跨多个区', 'parent': 1, type: '2'},
+      {'id': 2, 'name': '黄浦区', 'parent': 1, type: '2'},
+      {'id': 3, 'name': '徐汇区', 'parent': 1, type: '2'},
+      {'id': 4, 'name': '长宁区', 'parent': 1, type: '2'},
+      {'id': 5, 'name': '静安区', 'parent': 1, type: '2'},
+      {'id': 6, 'name': '普陀区', 'parent': 1, type: '2'},
+      {'id': 7, 'name': '虹口区', 'parent': 1, type: '2'},
+      {'id': 8, 'name': '杨浦区', 'parent': 1, type: '2'},
+      {'id': 9, 'name': '闵行区', 'parent': 1, type: '2'},
+      {'id': 10, 'name': '宝山区', 'parent': 1, type: '2'},
+      {'id': 11, 'name': '嘉定区', 'parent': 1, type: '2'},
+      {'id': 12, 'name': '浦东新区', 'parent': 1, type: '2'},
+      {'id': 13, 'name': '金山区', 'parent': 1, type: '2'},
+      {'id': 14, 'name': '松江区', 'parent': 1, type: '2'},
+      {'id': 15, 'name': '青浦区', 'parent': 1, type: '2'},
+      {'id': 16, 'name': '奉贤区', 'parent': 1, type: '2'}
+    ];
+    $scope.TypeList = [
+      {'id': 1, 'name': '一户室', 'parent': 1, type: '3'},
+      {'id': 2, 'name': '两户室', 'parent': 1, type: '3'},
+      {'id': 3, 'name': '三户及以上', 'parent': 1, type: '3'},
+      {'id': 4, 'name': '单间', 'parent': 1, type: '3'},
+      {'id': 5, 'name': '多套多房型', 'parent': 1, type: '3'},
+    ];
+    $scope.NumList = [
+      {'id': 1, 'name': '整房三套以下', 'parent': 1, type: '4'},
+      {'id': 2, 'name': '整房三套以上', 'parent': 1, type: '4'},
+      {'id': 3, 'name': '多套单间', 'parent': 1, type: '4'}
+    ]
+  }])
+</script>

+ 219 - 0
www/protected/modules/moonclub/views/advisory/enterprise.php

@@ -0,0 +1,219 @@
+<!DOCTYPE html>
+<!--HTML5 doctype-->
+<html ng-app="myapp">
+<head>
+  <title>壹管家</title>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+  <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+  <meta name="apple-mobile-web-app-capable" content="yes">
+  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
+  <meta http-equiv="Pragma" content="no-cache">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <!--引入css文件-->
+  <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/webapp/common/css/common.css">
+  <link rel="stylesheet" href=" <?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-3.3.7.min.css">
+  <!--引入js文件-->
+  <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery-3.1.1.min.js"></script>
+  <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-3.3.7.min.js"></script>
+  <!--修改title-->
+  <script>
+    $(function () {
+      document.title = "壹管家";
+    })
+  </script>
+</head>
+<body ng-controller="myctrl">
+<div class="container" style="margin-top: 2rem">
+  <form action="" method='post'
+        class="container  form-horizontal  ng-valid ng-dirty ng-valid-parse" id='enterprise'
+        style="margin-bottom: 15%; ">
+      <!--姓名-->
+      <div class="form-group">
+        <label>姓名:</label>
+        <input type="text" name='user_name' class="form-control username" placeholder="请输入您的姓名" ng-model="username">
+      </div>
+      <!--选择区域-->
+      <div class="form-group">
+        <label>选择区域:</label>
+        <select name="area" class="form-control" ng-model="Area" ng-init="Area=AreaList[0].id"
+                ng-options="info.name as info.name for info in AreaList" id="">
+          <option value="">--请选择--</option>
+        </select>
+      </div>
+      <!--房型-->
+      <div class="form-group">
+        <label>选择服务:</label>
+        <select name="tech_content" class="form-control" ng-model="AechContent" ng-init="AechContent=AechContentList[0].id"
+                ng-options="type.name as type.name for type in AechContentList" id="">
+          <option value="">--请选择--</option>
+        </select>
+      </div>
+
+      <!--手机号码-->
+      <div class="form-group">
+        <label>手机号码:</label>
+        <input type="text" name="mobile" class="form-control"
+               placeholder="请输入您的手机号码" ng-model="phone"/>
+      </div>
+      <!--性别-->
+      <div class="form-group">
+        <div style="display: inline-block;max-width: 100%;margin-bottom: 5px;font-weight: 700;">性别:</div>
+        <div>
+          <label class="radio-inline">
+            <input type="radio" name="sex" value="先生" ng-model="sex">先生
+          </label>
+          <label class="radio-inline">
+            <input type="radio" name="sex" value="女士" ng-model="sex">女士
+          </label>
+        </div>
+      </div>
+      <!--按钮-->
+      <div class="form-group">
+        <a id="enterpriseBtn"
+            style="background: rgb(42,36,0);color:rgb(178,143,0);border: 0"
+            class="btn btn-success col-xs-12"
+            data-container="body"
+            data-toggle="popover"
+            data-placement="top"
+            data-content="{{btnContent}}">
+          提交
+        </a>
+      </div>
+    </div>
+  </form>
+</div>
+<div class="prevent-scroll">
+  <div class="box my-action">
+    <!--首页-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-my-order" href="/index.php?r=o2o/web/index">
+          <div class="logo logo-my-order" style="margin-bottom: 0.5rem;"></div>
+          <div class="name">首页</div>
+        </a>
+      </div>
+    </div>
+    <!--LOGO-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-logo" href="/index.php?r=o2o/advisory/im">
+          <div class="logo logo-my-logo"></div>
+        </a>
+      </div>
+    </div>
+    <!--我的-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-coupon">
+          <div class="logo logo-coupon"style="margin-bottom: 0.5rem;"></div>
+          <div class="name">我的</div>
+        </a>
+      </div>
+    </div>
+  </div>
+</div>
+<!--模态框-->
+<div class="model" style="width: 100%;position: fixed;top: 0;background: rgba(0,0,0,0.4)">
+  <!--错误提示容器-->
+  <div class="model-box"
+       style="border-radius: 10px;height:130px;display:none;width: 70%;background: #fff;margin: 0 auto;top:25%;left:15%;position: fixed;">
+    <div class="model-title"
+         style="font-family: '微软雅黑', 'Microsoft YaHei', 'STHeiti Light';width: 100%;text-align: center;font-size: 1.1rem;margin-top: 5%;"></div>
+    <div class="model-content"
+         style="font-family: '微软雅黑', 'Microsoft YaHei', 'STHeiti Light';margin: 0 auto;width: 80%;background: rgb(42,36,0);color:rgb(178,143,0);font-size: 1.3rem;margin-top: 30px;text-align: center;padding: 5px 0 5px 0"></div>
+  </div>
+</div>
+</body>
+</html>
+<script src="//cdn.bootcss.com/angular.js/1.4.3/angular.min.js"></script>
+<script>
+  var myapp = angular.module('myapp', []);
+  myapp.controller('myctrl', ['$scope', function ($scope) {
+    $('.model-content').on('click', function () {
+      if ($('.model-content').html() == '返回首页') {
+        window.location.href = '/index.php?r=o2o/web/index';
+      } else {
+        $('.model').css('height', '0');
+        $('.model-box').css('display', 'none');
+      }
+    });
+    /*表单提交进行判断*/
+    $('#enterpriseBtn').on('click', function () {
+
+          /*姓名是否为空*/
+          if ($scope.username == undefined) {
+            model('请重填', '确认您的姓名');
+            return false;
+          }
+          /*验证手机号码*/
+          if (!(/^1[34578]\d{9}$/.test($scope.phone)) || $scope.phone == 0) {
+            model('请重填', '手机号码有误');
+            return false;
+          }
+          /*性别*/
+          if ($scope.sex == undefined) {
+            model('请重新选择', '确认');
+            return false;
+          }
+          /*model*/
+
+          $.ajax({
+            url: 'index.php?r=o2o/Advisory/enterprise',
+            type: 'POST',
+            dataType: 'html',
+            data: $('#enterprise').serialize(),
+            success: function (message) {
+              model(message,'返回首页');
+
+            },
+            error: function (message) {
+              model('标题', '咨询失败');
+            }
+          });
+
+          function model(title, content) {
+            $('.model-box').css('display', 'inline');
+            $('.model').height(window.screen.height);
+            $('.model-title').html(title);
+            $('.model-content').html(content);
+          }
+        }
+    );
+
+    $scope.AreaList = [
+      {'id': 1, 'name': '跨多个区', 'parent': 1, type: '2'},
+      {'id': 2, 'name': '黄浦区', 'parent': 1, type: '2'},
+      {'id': 3, 'name': '徐汇区', 'parent': 1, type: '2'},
+      {'id': 4, 'name': '长宁区', 'parent': 1, type: '2'},
+      {'id': 5, 'name': '静安区', 'parent': 1, type: '2'},
+      {'id': 6, 'name': '普陀区', 'parent': 1, type: '2'},
+      {'id': 7, 'name': '虹口区', 'parent': 1, type: '2'},
+      {'id': 8, 'name': '杨浦区', 'parent': 1, type: '2'},
+      {'id': 9, 'name': '闵行区', 'parent': 1, type: '2'},
+      {'id': 10, 'name': '宝山区', 'parent': 1, type: '2'},
+      {'id': 11, 'name': '嘉定区', 'parent': 1, type: '2'},
+      {'id': 12, 'name': '浦东新区', 'parent': 1, type: '2'},
+      {'id': 13, 'name': '金山区', 'parent': 1, type: '2'},
+      {'id': 14, 'name': '松江区', 'parent': 1, type: '2'},
+      {'id': 15, 'name': '青浦区', 'parent': 1, type: '2'},
+      {'id': 16, 'name': '奉贤区', 'parent': 1, type: '2'}
+    ];
+    $scope.AechContentList=[
+      {'id': 1, 'name': '写字楼日常保洁', 'parent': 1, type: '3'},
+      {'id': 2, 'name': '展会日常保洁', 'parent': 1, type: '3'},
+      {'id': 3, 'name': '开荒保洁', 'parent': 1, type: '3'},
+      {'id': 4, 'name': '地毯清洁', 'parent': 1, type: '3'},
+      {'id': 5, 'name': '地板打蜡', 'parent': 1, type: '3'},
+      {'id': 6, 'name': '沙发清洗', 'parent': 1, type: '3'},
+      {'id': 7, 'name': '电器清洗', 'parent': 1, type: '3'},
+      {'id': 8, 'name': '玻璃清洗', 'parent': 1, type: '3'},
+      {'id': 9, 'name': '整体消毒', 'parent': 1, type: '3'},
+      {'id': 10, 'name': '电器消毒', 'parent': 1, type: '3'},
+      {'id': 11, 'name': '除尘除螨', 'parent': 1, type: '3'}
+    ];
+
+  }])
+
+
+</script>

+ 67 - 0
www/protected/modules/moonclub/views/advisory/im.php

@@ -0,0 +1,67 @@
+<!--/**
+ * Created by PhpStorm.
+ * User: Jinguo
+ * Date: 2016/11/11
+ * Time: 13:14
+ */-->
+<!DOCTYPE html>
+<!--HTML5 doctype-->
+<html ng-app="myapp">
+<head>
+  <title>壹管家</title>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+  <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+  <meta name="apple-mobile-web-app-capable" content="yes">
+  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
+  <meta http-equiv="Pragma" content="no-cache">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <!--引入css文件-->
+  <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/webapp/common/css/common.css">
+  <link rel="stylesheet" href=" <?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-3.3.7.min.css">
+  <!--引入js文件-->
+  <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery-3.1.1.min.js"></script>
+  <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-3.3.7.min.js"></script>
+  <!--修改title-->
+  <script>
+    $(function () {
+      document.title = "壹管家";
+	    $('img').height($(window).height());
+	    $('img').width($(window).width());
+    })
+  </script>
+</head>
+<body>
+  <img src="http://odulvej8l.bkt.clouddn.com/1110%E4%BA%8C%E7%BB%B4%E7%A0%81.jpg" alt="联系我们" style="width: 100%;margin-top: -0.2rem">
+<div class="prevent-scroll">
+  <div class="box my-action">
+    <!--首页-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-my-order" href="/index.php?r=o2o/web/index">
+          <div class="logo logo-my-order" style="margin-bottom: 0.5rem;"></div>
+          <div class="name">首页</div>
+        </a>
+      </div>
+    </div>
+    <!--LOGO-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-logo" href="/index.php?r=o2o/advisory/im">
+          <div class="logo logo-my-logo"></div>
+        </a>
+      </div>
+    </div>
+    <!--我的-->
+    <div class="width-percent-33">
+      <div class="title-container-square">
+        <a class="btn-home-action btn-action-coupon">
+          <div class="logo logo-coupon"style="margin-bottom: 0.5rem;"></div>
+          <div class="name">我的</div>
+        </a>
+      </div>
+    </div>
+  </div>
+</div>
+</body>
+</html>

+ 418 - 0
www/protected/modules/moonclub/views/advisory/index.php

@@ -0,0 +1,418 @@
+<style>
+    .f_label {width: 90px;}
+    .accordion-body {padding: 0;}
+    #view_select_position {
+        display:inline-block;
+        padding:1px 4px 1px 4px;
+        border:1px solid #999999;
+        text-decoration:none;
+        color:#333333;
+    }
+</style>
+
+<div id="main">
+    <div region="west" border="false" id="west_panel">
+        <table id="dg_content"></table>
+        <div id="tb_content">
+
+            <div class="tb_line">
+                <span class="tb_label">状态: </span>
+                <input id="filter_status" />
+
+            </div>
+
+
+        </div>
+    </div>
+    <div id="acc_container" class="accordion" region="center">
+        <div region="center" title="充值卡" data-options="iconCls:'icon-save',selected:true">
+            <div class="easyui-layout detail_layout">
+                <div data-options="region:'center'" class="detail_center">
+                    <div class="detail_main">
+                        <form id="content_form" method="post">
+                            <ul>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>ID: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input type="hidden" name="id" id="id"/>
+                                            <span id="id_str"></span>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>咨询类型: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <!--                                            <input type="text" name="mobile" id="edit_denomination" value='' />-->
+                                            <span id="type"></span>
+                                        </div>
+                                    </div>
+                                </li>
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>联系方式: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+<!--                                            <input type="text" name="mobile" id="edit_denomination" value='' />-->
+                                            <span id="mobile"></span>
+                                        </div>
+                                    </div>
+                                </li>
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>区域: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="area"></span>
+<!--                                            <textarea name="area" id="area" style="width: 250px;min-height: 100px"></textarea>-->
+                                        </div>
+                                    </div>
+                                </li>
+
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>房型: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="homeType"></span>
+<!--                                            <input id="edit_order" name="homeType" />-->
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>房源数: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="num"> </span>
+                                            <!--<input id="edit_order" name="num" />-->
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>服务: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="tech_content"> </span><!--<id="edit_order" name="tech_content" />-->
+                                        </div>
+                                    </div>
+                                </li>
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>状态:</span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input id="setStatus" name="status" />
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="action_info" style="color:green;"></span>
+                                        </div>
+                                    </div>
+                                </li>
+
+                            </ul>
+                        </form>
+                    </div>
+                    <div data-options="region:'south'" class="detail_south">
+                        <div class="detail_toolbar">
+                            <a href="#" class="easyui-linkbutton set_button" iconCls="icon-save" onclick="save_content();return false;">保存</a>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<div style="display:none;">
+    <div id="refund_tip_dialog" style="padding: 30px 0;">
+        <div style="text-align:center;"><span id="refund_tip"></span></div>
+    </div>
+</div>
+<script language="javascript" type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/coolautosuggest/jquery.coolautosuggest.js"></script>
+<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/coolautosuggest/jquery.coolautosuggest.css" />
+<script type="text/javascript">
+    var jq_dg_content = $('#dg_content');
+    var jq_content_form = $('#content_form');
+    var jq_filter_status = $('#filter_status');
+    var jq_setStatus_add = $('#setStatus_add');
+    var module_router = site_root + '/index.php?r=o2o/Advisory';
+    var status_data = <?php echo json_encode($status_option); ?>;
+    var jq_setStatus = $('#setStatus');
+    var w_width = $(window).width();
+    var w_height = $(window).height();
+    var jq_ss = $('#ss');
+    var jq_action_info = $('#action_info');
+
+    var jq_add_dialog = $('#add_dialog');
+    var jq_add_form = $('#add_form');
+
+
+    var jq_set_precedence = $('#set_precedence');
+
+
+    var jq_acc = $('#acc_container');
+
+    $(function(){
+
+        jq_acc.accordion({
+            height: w_height - 18,
+            onSelect: function(title) {
+
+            }
+        });
+
+
+
+        var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+        buttons[0].text = '确定';
+
+        jq_setStatus.combobox({
+            editable: false,
+            data: status_data
+        });
+
+
+        jq_setStatus_add.combobox({
+            editable: false,
+            data: (function () {
+                var status_data_temp = new Array();
+                $.extend(status_data_temp, status_data);
+                status_data_temp.shift();
+
+                return status_data_temp;
+            })()
+        });
+
+
+
+
+
+
+
+        var p_width = parseInt(w_width / 2);
+        if (p_width < 520){
+            p_width = 520;
+        }
+        var d_width = p_width - 10;
+        $('#west_panel').css({width : p_width});
+        $('#main').css({width: w_width - 25, height: w_height - 18}).layout();
+
+        jq_ss.searchbox({
+            width: 130,
+            searcher:function(value){
+                search_content();
+            },
+            prompt: '请输入关键字'
+        });
+
+        jq_setStatus.combobox({
+            editable: false,
+            data: status_data
+        });
+
+
+        jq_dg_content.datagrid({
+            url: module_router + '/list',
+            title: '咨询列表',
+            width: d_width,
+            height: w_height - 18,
+            fitColumns: true,
+            autoRowHeight: true,
+            striped: true,
+            toolbar: '#tb_content',
+            singleSelect: true,
+            selectOnCheck: false,
+            checkOnSelect: false,
+            rowStyler: function(index,row){
+                if (row.status==1){
+                    //return 'color:red;';
+                }else if(row.status==-3){
+                    return 'color:green;';
+                }
+            },
+            pagination: true,
+            pageList: [20, 30, 50],
+            pageSize: 20,
+            nowrap: false,
+            idField: 'id',
+            sortName: 'order_time',
+            sortOrder: 'desc',
+            queryParams: get_param_obj(),
+            frozenColumns:[[
+                {field:'ck',checkbox:true}
+            ]],
+            columns:[[
+                {field:'user_name', title:'姓名', width:25,sortable:false},
+                {field:'mobile', title:'联系方式', width:50, sortable: true},
+                {field:'status', title:'状态', width:50, sortable: true,
+                    formatter: function(value, row){
+                        return get_filed_text(value, status_data);
+                    }
+                },
+                {field:'time', title:'咨询时间', width:70,sortable:true,formatter: function(value, row){
+                    var now=new Date(value*1000);
+
+                    var   month=now.getMonth()+1;
+                    var   date=now.getDate();
+                    var   hour = now.getHours();
+                    return   month+"月"+date+"日"+hour+":00";
+                }
+                },
+            ]],
+
+            onSelect: function(index, row){
+                var data = $.extend({}, row);
+                $('#id_str').html(data.id);
+                $('#id').html(data.id);
+                $('#user_name').html(data.user_name);
+                $('#mobile').html(data.mobile);
+                $('#area').html(data.area);
+                $('#homeType').html(data.homeType);
+                $('#num').html(data.num);
+                $('#type').html(data.type);
+                $('#user_name').html(data.user_name);
+                $('#tech_content').html(data.tech_content);
+                jq_content_form.form('load', data);
+                $('#admins_edit_info').html('');
+                if (data['action_user'] != ''){
+                    jq_action_info.html('信息已被编辑: ' + data['action_user'] + ' ' + data['action_time']);
+                } else {
+                    jq_action_info.html('');
+                }
+
+            }
+
+        });
+
+        jq_filter_status.combobox({
+            width: 100,
+            data: status_data,
+            editable: false,
+            onSelect: function(){
+                search_content();
+            }
+        });
+
+
+
+
+        jq_content_form.form({
+            url: module_router + '/edit',
+            onSubmit: function(param){
+                if ($('#order_id').val() == ""){
+                    return false;
+                }
+                var isValid = $(this).form('validate');
+                if (!isValid){
+                    $.messager.progress('close');
+                }
+                return isValid;
+            },
+            success: function(res){
+                $.messager.progress('close');
+                var res = JSON.parse(res);
+
+                if (res.success){
+                    jq_dg_content.datagrid('reload');
+                }
+                if(res.success){
+                    $.messager.show({
+                        title: '提示',
+                        msg: '保存成功',
+                        timeout: 3500,
+                        showType: 'slide'
+                    });
+
+                    $('#technician_id').val(0);
+                }else{
+                    $.messager.show({
+                        title: '提示',
+                        msg: res.message,
+                        timeout: 3500,
+                        showType: 'slide'
+                    });
+                }
+            }
+        });
+
+        jq_add_form.form({
+            url : module_router + '/add',
+            onSubmit : function (param) {
+                var isValid = $(this).form('validate');
+                if (!isValid){
+                    $.messager.progress('close');
+                }
+                return isValid;
+            },
+            success : function (res) {
+                $.messager.progress('close');
+                var res = JSON.parse(res);
+
+                if (res.success) {
+                    $.messager.show({
+                        title : '提示',
+                        msg : '保存成功',
+                        timeout : 3500,
+                        showType : 'slide'
+                    });
+                    jq_add_dialog.dialog('close');
+                    jq_dg_content.datagrid('reload');
+                } else {
+                    $.messager.show({
+                        title : '提示',
+                        msg : res.message,
+                        timeout : 3500,
+                        showType : 'slide'
+                    });
+                }
+            }
+        });
+
+
+    });
+
+    function save_content(){
+        if ($('#recharge_id').val() == ""){
+            return false;
+        }
+        $.messager.progress();
+        jq_content_form.submit();
+    }
+    function search_content(){
+
+        var filter_status = jq_filter_status.combobox('getValue');
+
+        jq_dg_content.datagrid({
+            pageNum: 1,
+            queryParams: {
+                status : filter_status
+            }
+        });
+
+    };
+
+
+
+</script>

+ 169 - 0
www/protected/modules/moonclub/views/advisory/month.php

@@ -0,0 +1,169 @@
+<!DOCTYPE html>
+<!--HTML5 doctype-->
+<html ng-app="myapp">
+<head>
+	<title>壹管家</title>
+	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+	<meta name="viewport"
+	      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+	<meta name="apple-mobile-web-app-capable" content="yes">
+	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
+	<meta http-equiv="Pragma" content="no-cache">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge">
+	<!--css-->
+	<style>
+		.gradient {
+			color: #ffffff;
+			font-size: 2rem;
+			width: 100%;
+			line-height: 40px;
+			background: -webkit-linear-gradient(#4e1a42, #4e1a42, #4e1a42, #4e1a42); /* Safari 5.1 - 6.0 */
+			background: -o-linear-gradient(#4e1a42, #4e1a42, #4e1a42, #4e1a42); /* Opera 11.1 - 12.0 */
+			background: -moz-linear-gradient(#4e1a42, #4e1a42, #4e1a42, #4e1a42); /* Firefox 3.6 - 15 */
+			background: linear-gradient(#4e1a42, #4e1a42, #4e1a42, #4e1a42); /* 标准的语法 */
+		}
+	</style>
+	<!--引入css文件-->
+	<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/webapp/common/css/common.css">
+	<link rel="stylesheet" href=" <?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-3.3.7.min.css">
+	<link rel="stylesheet" href=" <?php echo Yii::app()->request->baseUrl; ?>/css/common_o2o/LCalendar.css">
+	<!--引入js文件-->
+	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery-3.1.1.min.js"></script>
+	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/AngularJS v1.4.3.min.js"></script>
+	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-3.3.7.min.js"></script>
+	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/o2o/LCalendar.js"></script>
+	<!--修改title-->
+	<script>
+		$(function () {
+			document.title = "壹管家";
+		})
+	</script>
+</head>
+<body ng-controller="myctrl">
+<div class="gradient" style="font-size: 12px;padding-left: 10px;">返回</div>
+<h1 style="text-align: center">咨询</h1>
+<div class="">
+	<form action="" method='post'
+	      class="container  form-horizontal  ng-valid ng-dirty ng-valid-parse" id='singlesDay'
+	      style="margin-bottom: 15%; ">
+		<div class="container">
+			<!--姓名-->
+			<div class="form-group">
+				<label>姓名:</label>
+				<input type="text" name='user_name' class="form-control username" placeholder="请输入您的姓名" ng-model="username">
+			</div>
+			<!--手机号码-->
+			<div class="form-group">
+				<label>手机号码:</label>
+				<input type="text" name="mobile" class="form-control"
+				       placeholder="请输入您的手机号码" ng-model="phone"/>
+			</div>
+			<!--房型-->
+			<div class="form-group">
+				<label>咨询套餐:</label>
+				<select name="homeType" onchange="theforever(this.value)" class="form-control" ng-model="Type"
+				        ng-init="Type=TypeList[0].id"
+				        ng-options="type.name as type.name for type in TypeList" id="">
+					<option value="">--请选择--</option>
+				</select>
+			</div>
+			<!--数据-->
+			<input type="text" name="area" value="享月会" style="position: absolute;top:-1000px;">
+			<!--预产期-->
+			<div class="form-group">
+				<input name="num" class="form-control" style="background-color: #fff;" id="demo1" type="text" readonly=""
+				       placeholder="请选择日期"/>
+			</div>
+			<!--按钮-->
+			<div class="form-group">
+				<a id="SinglesDayBtn"
+				   style="background: #2f004e;color:rgb(255,255,255);border: 0"
+				   class="btn btn-success col-xs-12"
+				   data-container="body"
+				   data-toggle="popover"
+				   data-placement="top"
+				   data-content="{{btnContent}}">
+					提交
+				</a>
+			</div>
+		</div>
+	</form>
+</div>
+
+<!--模态框-->
+<div class="model" style="width: 100%;position: fixed;top: 0;background: rgba(0,0,0,0.4)">
+	<!--错误提示容器-->
+	<div class="model-box"
+	     style="border-radius: 10px;height:130px;display:none;width: 70%;background: #fff;margin: 0 auto;top:25%;left:15%;position: fixed;">
+		<div class="model-title"
+		     style="font-family: '微软雅黑', 'Microsoft YaHei', 'STHeiti Light';width: 100%;text-align: center;font-size: 1.1rem;margin-top: 5%;"></div>
+		<div class="model-content"
+		     style="font-family: '微软雅黑', 'Microsoft YaHei', 'STHeiti Light';margin: 0 auto;width: 80%;background: #2f004e;color:rgb(255, 255, 255);font-size: 1.3rem;margin-top: 30px;text-align: center;padding: 5px 0 5px 0"></div>
+	</div>
+</div>
+</body>
+</html>
+<script>
+	var myapp = angular.module('myapp', []);
+	myapp.controller('myctrl', ['$scope', function ($scope) {
+		$('.model-content').on('click', function () {
+			if ($('.model-content').html() == '返回首页') {
+				window.location.href = '/index.php?r=o2o/web/index';
+			} else {
+				$('.model').css('height', '0');
+				$('.model-box').css('display', 'none');
+			}
+		});
+		$('.gradient').on('click',function () {
+			window.location.href = '/index.php?r=o2o/web/index';
+		})
+		/*表单提交进行判断*/
+		$('#SinglesDayBtn').on('click', function () {
+				/*姓名是否为空*/
+				if ($scope.username == undefined) {
+					model('请重填', '确认您的姓名');
+					return false;
+				}
+				/*验证手机号码*/
+				if (!(/^1[34578]\d{9}$/.test($scope.phone)) || $scope.phone == 0) {
+					model('请重填', '手机号码有误');
+					return false;
+				}
+				/*model*/
+				$.ajax({
+					url: 'index.php?r=o2o/Advisory/SinglesDay',
+					type: 'POST',
+					dataType: 'html',
+					data: $('#singlesDay').serialize(),
+					success: function (message) {
+						model(message, '返回首页');
+					},
+					error: function (message) {
+						model('标题', '咨询失败');
+					}
+				});
+				function model(title, content) {
+					$('.model-box').css('display', 'inline');
+					$('.model').height(window.screen.height);
+					$('.model-title').html(title);
+					$('.model-content').html(content);
+				}
+			}
+		);
+		$scope.TypeList = [
+			{'id': 1, 'name': '至惠套餐', 'parent': 1, type: '3'},
+			{'id': 2, 'name': '至悦套餐', 'parent': 1, type: '3'},
+			{'id': 3, 'name': '至享套餐', 'parent': 1, type: '3'},
+			{'id': 4, 'name': '至尊套餐', 'parent': 1, type: '3'}
+		];
+	}])
+</script>
+<script>
+	var calendar = new LCalendar();
+	calendar.init({
+		'trigger': '#demo1', //标签id
+		'type': 'date', //date 调出日期选择 datetime 调出日期时间选择 time 调出时间选择 ym 调出年月选择,
+		'minDate': '1900-1-1', //最小日期
+		'maxDate': (new Date().getFullYear() + 10) + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate() //最大日期
+	});
+</script>

+ 39 - 0
www/protected/modules/moonclub/views/advisory/xyhIm.php

@@ -0,0 +1,39 @@
+<!--/**
+ * Created by PhpStorm.
+ * User: Jinguo
+ * Date: 2016/11/11
+ * Time: 13:14
+ */-->
+<!DOCTYPE html>
+<!--HTML5 doctype-->
+<html ng-app="myapp">
+<head>
+	<title>壹管家</title>
+	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+	<meta name="viewport"
+	      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+	<meta name="apple-mobile-web-app-capable" content="yes">
+	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
+	<meta http-equiv="Pragma" content="no-cache">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge">
+	<!--引入css文件-->
+	<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/webapp/common/css/common.css">
+	<link rel="stylesheet" href=" <?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-3.3.7.min.css">
+	<!--引入js文件-->
+	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery-3.1.1.min.js"></script>
+	<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-3.3.7.min.js"></script>
+	<!--修改title-->
+	<script>
+		$(function () {
+			document.title = "壹管家";
+			$('img').height($(window).height());
+			$('img').width($(window).width());
+		})
+	</script>
+</head>
+<body>
+<img src="http://odulvej8l.bkt.clouddn.com/%E4%BA%8C%E7%BB%B4%E7%A0%81%E8%81%8A%E5%A4%A9-01.jpg" alt="联系我们"
+     style="width: 100%;margin-top: -0.2rem">
+</body>
+
+</html>

+ 343 - 0
www/protected/modules/moonclub/views/commision/index.php

@@ -0,0 +1,343 @@
+<style>
+    .f_label {width: 90px;}
+    .accordion-body {padding: 0;}
+</style>
+<div id="main">
+<div region="west" border="false" id="west_panel">
+    <table id="dg_content"></table>
+    <div id="tb_content">
+        <div class="tb_line">
+            <input id="search" style="120px" />
+            <span class="tb_label">类型: </span>
+            <input id="filter_type" />
+            <span class="tb_label">预约时间: </span>
+            <input id="filter_start" style="100px"/>
+            <span class="tb_label">至</span>
+            <input id="filter_end" style="100px"/>
+            <div class="right">
+                <a href="#" class='easyui-linkbutton' iconCls="icon-add" plain="true" onclick="add();return false;">新增</a>
+                <a href="#" class='easyui-linkbutton' iconCls="icon-search" plain="true" onclick="searchContent();return false;">查询</a>
+            </div>
+        </div>
+    </div>
+</div>
+<div region="center" border="false">
+<div class="easyui-layout detail_layout">
+<div data-options="region:'center'" class="detail_center">
+<div class="detail_main">
+    <form id="content_form">
+        <ul id="content_ul"></ul>
+    </form>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div style="display:none;">
+<div id="add_dialog" style="padding: 15px 0;">
+    <form id="add_form" method="post">
+        <ul>
+            <li class="f_item">
+                <div class="box">
+                    <div class="f_label">
+                        <span>时间:</span>
+                    </div>
+                    <div class="box_flex f_content">
+                        <input id="add_datetime" name="datetime" />
+                    </div>
+                </div>
+            </li>
+            <li class="f_item">
+                <div class="box">
+                    <div class="f_label">
+                        <span>选择保洁师:</span>
+                    </div>
+                    <div class="box_flex f_content">
+                        <input id="add_username" name="user_name" />
+                        <input id="add_userid" name="user" type="hidden" />
+                    </div>
+                </div>
+            </li>
+            <li class="f_item">
+                <div class="box">
+                    <div class="f_label">
+                        <span>订单ID:</span>
+                    </div>
+                    <div class="box_flex f_content">
+                        <input id="add_order" name="order" />
+                    </div>
+                </div>
+            </li>
+            <li class="f_item">
+                <div class="box">
+                    <div class="f_label">
+                        <span>提成数(元):</span>
+                    </div>
+                    <div class="box_flex f_content">
+                        <input id="add_commision" name="commision" />
+                    </div>
+                </div>
+            </li>
+        </ul>
+    </form>
+</div>
+</div>
+<script language="javascript" type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/coolautosuggest/jquery.coolautosuggest.js"></script>
+<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/coolautosuggest/jquery.coolautosuggest.css" />
+<script type="text/javascript">
+var jq_dg_content   = $('#dg_content');
+var w_width         = $(window).width();
+var w_height        = $(window).height();
+var jq_content_form = $('#content_form');
+var jq_filter_type  = $('#filter_type');
+var jq_search       = $('#search');
+var jq_filter_start = $('#filter_start');
+var jq_filter_end   = $('#filter_end');
+var jq_add_dialog   = $('#add_dialog');
+var jq_add_form     = $('#add_form');
+var jq_add_datetime = $('#add_datetime');
+var jq_add_username = $('#add_username');
+var type_option = <?php echo json_encode($type_option); ?>
+
+var module_router = site_root + '/index.php?r=o2o/commision';
+
+$(function() {
+    var p_width = parseInt(w_width / 2);
+    if (p_width < 520){
+        p_width = 520;
+    }
+    var d_width = p_width - 10;
+    $('#west_panel').css({width: p_width});
+    $('#main').css({width: w_width-25, height: w_height-18}).layout();
+
+    jq_filter_type.combobox({
+        editable: false,
+        width: 100,
+        data: type_option,
+        onSelect: function() {
+            searchContent();
+        }
+    });
+
+    jq_search.searchbox({
+        width: 150,
+        prompt: '订单ID、姓名、拼音',
+        searcher: function() {
+            searchContent();
+        }
+    });
+
+    jq_filter_start.datebox({
+        width: 100,
+        editable: false
+    });
+
+    jq_filter_end.datebox({
+        width: 100,
+        editable: false
+    });
+
+    jq_add_datetime.datetimebox({
+        showSeconds: false,
+        width: 150,
+        editable: true
+    });
+
+    // 内容表格
+    jq_dg_content.datagrid({
+        url: module_router + '/list',
+        title: '保洁师提成',
+        width: d_width,
+        height: w_height - 18,
+        fitColumns: true,
+        autoRowHeight: true,
+        striped: true,
+        toolbar: '#tb_content',
+        singleSelect: true,
+        selectOnCheck: false,
+        checkOnSelect: false,
+        pagination: true,
+        pageList: [20, 30, 50],
+        pageSize: 20,
+        nowrap: false,
+        idField: 'id',
+        sortName: 'booking_time',
+        sortOrder: 'desc',
+        queryParams: $.extend(get_param_obj(), {}),
+        frozenColumns:[],
+        columns: [
+            [
+                {field: 'id', titie:'id', hidden: true},
+                {field: 'time_str', title: '完成时间', width: 30},
+                {field: 'booking_time', title: '预约时间', width: 30, sortable: true,
+                    formatter: function(value, row, index) {
+                        return row['booking_time_str'];
+                    }
+                },
+                {field: 'user_str', title: '保洁师姓名', width: 25},
+                {field: 'commision', title: '提成数量(元)', width: 25},
+                {field: 'type_str', title: '类型', width: 25},
+                {field: 'order', title: '操作', width: 25,
+                    formatter: function(value, row, index) {
+                        if (row.type == 0) {
+                            var url = '\'<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=rOrder&id='+value+'\'';
+                            return '<a href="javascript:;" onclick="parent.load_url('+url+')">'+'查看订单'+'</a>';
+                        } else if (row.type == 1) {
+                            var url = '\'<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=appendOrders&id='+value+'\'';
+                            return '<a href="javascript:;" onclick="parent.load_url('+url+')">'+'查看订单'+'</a>';
+                        } else {
+                            return '';
+                        }
+                    }
+                }
+            ]
+        ],
+        onSelect: function(index, row) {
+
+        },
+        onLoadSuccess: function() {
+            $('#content_ul').empty();
+            if (jq_search.searchbox('getValue') && jq_filter_start.datebox('getValue') && jq_filter_end.datebox('getValue')) {
+                $.post(
+                    module_router + '/commisionCountOne',
+                    {
+                        search: jq_search.searchbox('getValue'),
+                        start: jq_filter_start.datebox('getValue'),
+                        end: jq_filter_end.datebox('getValue'),
+                        type: jq_filter_type.combobox('getValue')
+                    },
+                    function (res) {
+                        var data = $.parseJSON(res);
+                        for (key in data) {
+                            var _html  = '<li class="f_item"><div class="box"><div class="f_label">';
+                                _html += '<span>' + data[key]['type'] + '</span>';
+                                _html += '</div><div class="box_flex f_content">' + data[key]['sum'] + '</div>';
+                                _html += '</div></li>';
+                            $('#content_ul').append(_html);
+                        }
+                    }
+                );
+            }
+        }
+    });
+
+    // 新增提成表单
+    jq_add_form.form({
+        url: module_router + '/addCommision',
+        onSubmit: function(param) {
+            check = checkAddForm();
+            if (!check) {
+                return false;
+            } else {
+                $.messager.progress();
+            }
+        },
+        success: function(res) {
+            $.messager.progress('close');
+            var res = JSON.parse(res);
+
+            if (res.success){
+                jq_dg_content.datagrid('reload');
+            }
+            if(res.success){
+                $.messager.show({
+                    title: '提示',
+                    msg: '保存成功',
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+                jq_add_dialog.dialog('close');
+            }else{
+                $.messager.show({
+                    title: '提示',
+                    msg: res.message,
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            }
+        }
+    });
+
+    // 新增提成弹窗
+    jq_add_dialog.dialog({
+        title: '新增提成',
+        width: 400,
+        height: 280,
+        closed: true,
+        modal: true,
+        buttons:[{
+            text: '确认',
+            iconCls: 'icon-ok',
+            handler: function() {
+                jq_add_form.submit();
+            }
+        }, {
+            text: '取消',
+            iconCls: 'icon-cancel',
+            handler: function() {
+                jq_add_dialog.dialog('close');
+            }
+        }],
+        onOpen: function() {
+            jq_add_form.form('clear');
+            $('#suggestions_holder').remove();
+            jq_add_username.coolautosuggest({
+                url: 'index.php?r=material/selectUser&user=',
+                showDescription: true,
+                onSelected: function(result) {
+                    $('#add_userid').val(result.uid);
+                }
+            });
+        }
+    });
+});
+
+function add() {
+    jq_add_dialog.dialog('open');
+}
+
+function searchContent() {
+    var type_search    = jq_filter_type.combobox('getValue');
+    var search_content = jq_search.searchbox('getValue');
+    var filter_start   = jq_filter_start.datebox('getValue');
+    var filter_end     = jq_filter_end.datebox('getValue');
+
+    jq_dg_content.datagrid({
+        pageNum: 1,
+        queryParams: {
+            type: type_search,
+            search: search_content,
+            start: filter_start,
+            end: filter_end
+        }
+    });
+}
+
+function checkAddForm() {
+    var username = $('#add_username').val();
+    if (username.length == 0) {
+        $.messager.alert('提示', '请选择保洁师');
+        return false;
+    }
+
+    // var order = $('#add_order').val();
+    // if (order.length == 0) {
+    //     $.messager.alert('提示', '请输入普通订单/追加订单号');
+    //     return false;
+    // }
+
+    var commision = $('#add_commision').val();
+    if (commision.length == 0) {
+        $.messager.alert('提示', '请输入提成数');
+        return false;
+    }
+
+    var num_reg = new RegExp(/^[-\d]*\d*[\.]*\d*$/);
+    if (!num_reg.test(commision)) {
+        $.messager.alert('提示', '提成只能输入整数或带小数点的数字');
+        return false;
+    }
+
+    return true;
+}
+</script>

File diff suppressed because it is too large
+ 15 - 0
www/protected/modules/moonclub/views/index/index.php


+ 31 - 0
www/protected/modules/moonclub/views/layouts/qyindex.php

@@ -0,0 +1,31 @@
+<!DOCTYPE>
+<html>
+<head>
+    <title></title>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
+    <!-- vue 框架 -->
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/vue.js"></script>
+    <!-- jquery 框架 -->
+    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
+    <!-- amaze 框架 -->
+    <link rel="stylesheet" type="text/css" href="http://cdn.amazeui.org/amazeui/2.5.0/css/amazeui.css">
+    <link rel="stylesheet" type="text/css" href="http://cdn.amazeui.org/amazeui/2.5.0/css/amazeui.min.css">
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.min.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.ie8polyfill.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.ie8polyfill.min.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.widgets.helper.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.widgets.helper.min.js"></script>
+    <!-- 自定义样式 -->
+    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/qywechat/style.css?v=20151215">
+    <!-- 插件 -->
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/jquery.vtable.js?v=20151215"></script>
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/jquery.valert.js?v=20160106"></script>
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/jquery.vloading.js?v=20151215"></script>
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/jquery.vselect.js?v=20151215"></script>
+</head>
+<body>
+<?php echo $content; ?>
+</body>
+</html>

+ 30 - 0
www/protected/modules/moonclub/views/layouts/qyinfo.php

@@ -0,0 +1,30 @@
+<!-- 企业号应用详情布局 -->
+<!DOCTYPE>
+<html>
+<head>
+    <title></title>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
+    <!-- vue 框架 -->
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/vue.js"></script>
+    <!-- jquery 框架 -->
+    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
+    <!-- amaze 框架 -->
+    <link rel="stylesheet" type="text/css" href="http://cdn.amazeui.org/amazeui/2.5.0/css/amazeui.css">
+    <link rel="stylesheet" type="text/css" href="http://cdn.amazeui.org/amazeui/2.5.0/css/amazeui.min.css">
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.min.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.ie8polyfill.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.ie8polyfill.min.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.widgets.helper.js"></script>
+    <script type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.widgets.helper.min.js"></script>
+    <!-- 自定义样式 -->
+    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/qywechat/info.css?v=20160101">
+    <!-- 插件 -->
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/jquery.valert.js?v=20160106"></script>
+    <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qywechat/jquery.vloading.js?v=20160106"></script>
+</head>
+<body>
+<?php echo $content; ?>
+</body>
+</html>

+ 14 - 0
www/protected/modules/moonclub/views/layouts/techHomeLayout.php

@@ -0,0 +1,14 @@
+<!DOCTYPE>
+<html>
+<head>
+    <title></title>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
+    <link rel="stylesheet" href="http://cdn.amazeui.org/amazeui/2.5.0/css/amazeui.min.css">
+    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
+    <!-- <script src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.min.js"></script> -->
+</head>
+<body>
+<?php echo $content; ?>
+</body>
+</html>

+ 5 - 0
www/protected/modules/moonclub/views/myComment/error.php

@@ -0,0 +1,5 @@
+<script type="text/javascript">
+document.title = '错误';
+var message = <?php echo json_encode($msg); ?>;
+$.valert(message);
+</script>

+ 88 - 0
www/protected/modules/moonclub/views/myComment/index.php

@@ -0,0 +1,88 @@
+<div id="main">
+    <div id="head" class="layoutbox">
+        <div id="vselect"></div>
+    </div>
+    <div id="content" class="layoutbox" style="display: none;">
+        <div id="info" class="am-g">
+            <div class="am-u-sm-12 am-text-center am-text-default">
+                <span>该月共有&nbsp;{{count}}条评价</span>
+            </div>
+        </div>
+        <div id="vtable" style="margin-top: 2%;"></div>
+    </div>
+    <div id="footer"></div>
+</div>
+<script type="text/javascript">
+/* sessionStorage设置 */
+if (!sessionStorage.getItem('timelist_index_comment')) {
+    sessionStorage.setItem('timelist_index_comment', '0');
+    var timelist_index_comment = 0;
+} else {
+    timelist_index_str = sessionStorage.getItem('timelist_index_comment');
+    var timelist_index_comment = parseInt(timelist_index_str);
+}
+
+var username = <?php echo json_encode($username); ?>;
+document.title = '我的评价-'+username;
+/* 获取变量 */
+var userid = <?php echo json_encode($userid); ?>;
+var user = <?php echo json_encode($user); ?>;
+var timelist = <?php echo json_encode($timelist); ?>;
+var jq_vtable = $('#vtable');
+var jq_vselect = $('#vselect');
+
+jq_vselect.vselect({
+    options: timelist,
+    selected: timelist_index_comment,
+    onSelect: function(value, index) {
+        // 筛选列表
+        jq_vtable.vtable({
+            page: 1,
+            query: {
+                userid: userid,
+                start: value
+            }
+        });
+        // sessionStorage设置
+        sessionStorage.setItem('timelist_index_comment', index);
+    }
+});
+
+/* vtable插件 */
+jq_vtable.vtable({
+    url: '/index.php?r=o2o/myComment/list',
+    pagination: true,
+    rows: 30,
+    sort: 'time',
+    query: {
+        userid: userid,
+        start: timelist[jq_vselect.getVIndex()]['value']
+    },
+    columns: [
+        {key: 'time_str_short', name: '时间'},
+        {key: 'score', name: '评分'}
+    ],
+    beforeLoad: function() {
+        $.vloading('open');
+    },
+    onSelect: function(index, row) {
+        if (row.order == '') {
+            $.valert('订单信息未录入');
+        }
+        window.location.href = '/index.php?r=o2o/myComment/info&order='+row.order+'&user='+user;
+    },
+    afterLoad: function(data) {
+        $.vloading('close');
+        v_info.count = data.count;
+        $('#content').show();
+    }
+});
+
+/* 基本信息 */
+var v_info = new Vue({
+    el: '#info',
+    data: {
+        count: 0
+    }
+});
+</script>

+ 106 - 0
www/protected/modules/moonclub/views/myComment/info.php

@@ -0,0 +1,106 @@
+<div>
+    <div id="header">
+        <div class="am-g">
+            <div class="am-u-sm-12">
+                <div class="layoutbox">
+                    评价详情
+                </div>
+            </div>
+        </div>
+    </div>
+    <!-- 订单详情 -->
+    <div id="info">
+        <div class="am-popup-bd" id="info_content" style="display: none;">
+            <div class="am-g">
+                <div class="am-u-sm-4">预约时间</div>
+                <div class="am-u-sm-8">{{info.booking_time_str}}</div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">客户姓名</div>
+                <div class="am-u-sm-8">{{info.address.name}}</div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">地址</div>
+                <div class="am-u-sm-8">{{info.address.city}}&nbsp;{{info.address.area}}&nbsp;{{info.address.poi.name}}&nbsp;{{info.address.detail}}</div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">客户电话</div>
+                <div class="am-u-sm-8"><a href="tel:{{info.address.mobile}}">{{info.address.mobile}}</a></div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">评价信息</div>
+                <div class="am-u-sm-8">{{info.comment}}</a></div>
+            </div>
+            <br>
+            <div class="am-g">
+                <div class="am-u-sm-4">产品</div>
+                <div class="am-u-sm-12">
+                    <ul class="am-list am-list-static am-list-border">
+                        <li v-for="product in info.products">
+                            名称:&nbsp;{{info.products[0].product.name}}<br>
+                            价格:&nbsp;{{info.products[0].product.price}}
+                        </li>
+                    </ul>
+                </div>
+            </div>
+            <div class="am-g" v-if="info.append_orders.length > 0">
+                <div class="am-u-sm-4">追加订单</div>
+                <div class="am-u-sm-12">
+                    <ul class="am-list am-list-static am-list-border">
+                        <li v-for="append in info.append_orders">
+                            <ul class="am-list am-list-static am-list-border">
+                                <li v-for="product in append.products">
+                                    服务:&nbsp;{{product.name}}<br>
+                                    价格:&nbsp;{{product.price}}
+                                </li>
+                            </ul>
+                        </li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script type="text/javascript">
+document.title = '评价详情';
+var order = <?php echo json_encode($order); ?>;
+var user = <?php echo json_encode($user); ?>;
+
+var v_order = new Vue({
+    el: '#info',
+    data: {
+        info: []
+    }
+});
+
+$(function() {
+    getCommentInfo(order, user);
+});
+
+function getCommentInfo(order, user) {
+    // ID为空则弹窗提示
+    if (order.length == 0 || user.length == 0) {
+        $.valert('订单信息未录入');
+        return false;
+    }
+
+    $.vloading('open');
+    $.post(
+        '/index.php?r=o2o/o2oApp/getCommentInfo',
+        {
+            id : order,
+            user : user
+        },
+        function(res) {
+            $.vloading('close');
+            var data = $.parseJSON(res);
+            if (data.success == false) {
+                $.valert(data.msg);
+            } else {
+                v_order.info = data.content;
+                $('#info_content').show();
+            }
+        }
+    );
+}
+</script>

+ 5 - 0
www/protected/modules/moonclub/views/myCommision/error.php

@@ -0,0 +1,5 @@
+<script type="text/javascript">
+document.title = '错误';
+var message = <?php echo json_encode($msg); ?>;
+$.valert(message);
+</script>

+ 95 - 0
www/protected/modules/moonclub/views/myCommision/index.php

@@ -0,0 +1,95 @@
+<div id="main">
+    <div id="head" class="layoutbox">
+        <div id="vselect"></div>
+    </div>
+    <div id="content" class="layoutbox">
+        <div id="info" class="am-g">
+            <div class="am-u-sm-6 am-text-center am-text-default">
+                <span>完成单数&nbsp;{{count}}&nbsp;单</span>
+            </div>
+            <div class="am-u-sm-6 am-text-center am-text-default">
+                <span>总提成&nbsp;{{sum}}&nbsp;元</span>
+            </div>
+        </div>
+        <div id="vtable" style="margin-top: 2%;"></div>
+    </div>
+    <div id="footer" class="layoutbox"></div>
+</div>
+<script type="text/javascript">
+/* sessionStorage设置 */
+if (!sessionStorage.getItem('timelist_index_commision')) {
+    sessionStorage.setItem('timelist_index_commision', '0');
+    var timelist_index_commision = 0;
+} else {
+    timelist_index_str = sessionStorage.getItem('timelist_index_commision');
+    var timelist_index_commision = parseInt(timelist_index_str);
+}
+
+var username = <?php echo json_encode($username); ?>;
+document.title = '我的提成-'+username;
+/* 获取变量 */
+var userid = <?php echo json_encode($userid); ?>;
+var user = <?php echo json_encode($user); ?>;
+var timelist = <?php echo json_encode($timelist); ?>;
+var jq_vtable = $('#vtable');
+var jq_vselect = $('#vselect');
+
+jq_vselect.vselect({
+    options: timelist,
+    selected: timelist_index_commision,
+    onSelect: function(value, index) {
+        // 筛选列表
+        jq_vtable.vtable({
+            page: 1,
+            query: {
+                userid: userid,
+                start: value
+            }
+        });
+        // sessionStorage设置
+        sessionStorage.setItem('timelist_index_commision', index);
+    }
+});
+
+/* 基本信息 */
+var v_info = new Vue({
+    el: '#info',
+    data: {
+        count: 0,
+        sum: 0
+    }
+});
+
+/* vtable插件 */
+jq_vtable.vtable({
+    url: '/index.php?r=o2o/myCommision/list',
+    pagination: true,
+    rows: 30,
+    sort: 'time',
+    query: {
+        userid: userid,
+        start: timelist[jq_vselect.getVIndex()]['value']
+    },
+    columns: [
+        {key: 'booking_time_str', name: '预约时间'},
+        {key: 'commision', name: '提成'},
+        {key: 'type_str', name: '类型'}
+    ],
+    beforeLoad: function() {
+        $.vloading('open');
+    },
+    onSelect: function(index, row) {
+        var order = row.order;
+        if (order.length == 0 || (row.type != 0 && row.type != 1)) {
+            $.valert('订单信息未录入');
+        } else {
+            window.location.href = '/index.php?r=o2o/myCommision/info&order='+order+'&user='+user+'&type='+row.type;
+        }
+    },
+    afterLoad: function(data) {
+        $.vloading('close');
+        v_info.sum = data.sum;
+        v_info.count = data.count;
+    }
+});
+</script>

+ 83 - 0
www/protected/modules/moonclub/views/myCommision/info_append.php

@@ -0,0 +1,83 @@
+<div>
+    <div id="header">
+        <div class="am-g">
+            <div class="am-u-sm-12">
+                <div class="layoutbox">
+                    订单详情
+                </div>
+            </div>
+        </div>
+    </div>
+    <!-- 订单详情 -->
+    <div id="info">
+        <div class="am-popup-bd" id="info_content" style="display: none;">
+            <div class="am-g">
+                <div class="am-u-sm-4">追加时间</div>
+                <div class="am-u-sm-8">{{info.append_time_str}}</div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">产品</div>
+                <div class="am-u-sm-12">
+                    <ul class="am-list am-list-static am-list-border">
+                        <li v-for="product in info.products">
+                            名称:&nbsp;{{product.name}}<br>
+                            价格:&nbsp;{{product.price}}
+                        </li>
+                    </ul>
+                </div>
+            </div>
+            <div class="am-g">
+                <button type="button" class="am-btn am-btn-warning am-radius" style="width:100%;"
+                onclick="getOrderInfo();">查看被追加的订单</button>
+                <input type="hidden" id="order" :value="info.order" />
+            </div>
+        </div>
+    </div>
+</div>
+<script type="text/javascript">
+document.title = '我的提成-详情';
+var order = <?php echo json_encode($order); ?>;
+var user = <?php echo json_encode($user); ?>;
+
+var v_order = new Vue({
+    el: '#info',
+    data: {
+        info: []
+    }
+});
+
+$(function() {
+    getCommisionInfo(order, user);
+});
+
+function getOrderInfo(order) {
+    var orderID = $('#order').val();
+    window.location.href = '/index.php?r=o2o/myCommision/info&order='+orderID+'&user='+user+'&type='+0;
+}
+
+function getCommisionInfo(order, user) {
+    if (order.length == 0 || user.length == 0) {
+        $.valert('订单信息未录入');
+        return false;
+    }
+
+    $.vloading('open');
+    $.post(
+        '/index.php?r=o2o/o2oApp/getAppendInfo',
+        {
+            id: order,
+            user: user
+        },
+        function(res) {
+            $.vloading('close');
+            var data = $.parseJSON(res);
+            if (data.success == false) {
+                $.valert(data.msg);
+            } else {
+                v_order.info = data.content;
+                $('#info_content').show();
+            }
+        }
+    );
+}
+</script>

+ 101 - 0
www/protected/modules/moonclub/views/myCommision/info_order.php

@@ -0,0 +1,101 @@
+<div>
+    <div id="header">
+        <div class="am-g">
+            <div class="am-u-sm-12">
+                <div class="layoutbox">
+                    订单详情
+                </div>
+            </div>
+        </div>
+    </div>
+    <!-- 订单详情 -->
+    <div id="info">
+        <div class="am-popup-bd" id="info_content" style="display: none;">
+            <div class="am-g">
+                <div class="am-u-sm-4">预约时间</div>
+                <div class="am-u-sm-8">{{info.booking_time_str}}</div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">客户姓名</div>
+                <div class="am-u-sm-8">{{info.address.name}}</div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">地址</div>
+                <div class="am-u-sm-8">{{info.address.city}}&nbsp;{{info.address.area}}&nbsp;{{info.address.poi.name}}&nbsp;{{info.address.detail}}</div>
+            </div>
+            <div class="am-g">
+                <div class="am-u-sm-4">客户电话</div>
+                <div class="am-u-sm-8"><a href="tel:{{info.address.mobile}}">{{info.address.mobile}}</a></div>
+            </div>
+            <br>
+            <div class="am-g">
+                <div class="am-u-sm-4">产品</div>
+                <div class="am-u-sm-12">
+                    <ul class="am-list am-list-static am-list-border">
+                        <li v-for="product in info.products">
+                            名称:&nbsp;{{info.products[0].product.name}}<br>
+                            价格:&nbsp;{{info.products[0].product.price}}
+                        </li>
+                    </ul>
+                </div>
+            </div>
+            <div class="am-g" v-if="info.append_orders.length > 0">
+                <div class="am-u-sm-4">追加订单</div>
+                <div class="am-u-sm-12">
+                    <ul class="am-list am-list-static am-list-border">
+                        <li v-for="append in info.append_orders">
+                            <ul class="am-list am-list-static am-list-border">
+                                <li v-for="product in append.products">
+                                    服务:&nbsp;{{product.name}}<br>
+                                    价格:&nbsp;{{product.price}}
+                                </li>
+                            </ul>
+                        </li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script type="text/javascript">
+document.title = '我的提成-详情';
+var order = <?php echo json_encode($order); ?>;
+var user = <?php echo json_encode($user); ?>;
+
+var v_order = new Vue({
+    el: '#info',
+    data: {
+        info: []
+    }
+});
+
+$(function() {
+    getCommisionInfo(order, user);
+});
+
+function getCommisionInfo(order, user) {
+    if (order.length == 0 || user.length == 0) {
+        $.valert('订单信息未录入');
+        return false;
+    }
+
+    $.vloading('open');
+    $.post(
+        '/index.php?r=o2o/o2oApp/getOrderInfo',
+        {
+            id: order,
+            user: user
+        },
+        function(res) {
+            $.vloading('close');
+            var data = $.parseJSON(res);
+            if (data.success == false) {
+                $.valert(data.msg);
+            } else {
+                v_order.info = data.content;
+                $('#info_content').show();
+            }
+        }
+    );
+}
+</script>

+ 5 - 0
www/protected/modules/moonclub/views/myOrder/error.php

@@ -0,0 +1,5 @@
+<script type="text/javascript">
+document.title = '错误';
+var message = <?php echo json_encode($msg); ?>;
+$.valert(message);
+</script>

+ 88 - 0
www/protected/modules/moonclub/views/myOrder/index.php

@@ -0,0 +1,88 @@
+<div id="main">
+    <div id="head" class="layoutbox">
+        <div id="vselect"></div>
+    </div>
+    <div id="content" class="layoutbox">
+        <div id="info" class="am-g">
+            <div class="am-u-sm-12 am-text-center am-text-default">
+                <span>该月共有&nbsp;{{count}}个订单</span>
+            </div>
+        </div>
+        <div id="vtable" style="margin-top: 2%;"></div>
+    </div>
+    <div id="footer"></div>
+</div>
+<script type="text/javascript">
+/* sessionStorage设置 */
+if (!sessionStorage.getItem('timelist_index_order')) {
+    sessionStorage.setItem('timelist_index_order', '0');
+    var timelist_index_order = 0;
+} else {
+    timelist_index_str = sessionStorage.getItem('timelist_index_order');
+    var timelist_index_order = parseInt(timelist_index_str);
+}
+
+var username = <?php echo json_encode($username); ?>;
+document.title = '我的订单-'+username;
+/* 获取变量 */
+var userid = <?php echo json_encode($userid); ?>;
+var user = <?php echo json_encode($user); ?>;
+var timelist = <?php echo json_encode($timelist); ?>;
+var jq_vtable = $('#vtable');
+var jq_vselect = $('#vselect');
+
+jq_vselect.vselect({
+    options: timelist,
+    selected: timelist_index_order,
+    onSelect: function(value, index) {
+        // 筛选列表
+        jq_vtable.vtable({
+            page: 1,
+            query: {
+                userid: userid,
+                start: value
+            }
+        });
+        // sessionStorage设置
+        sessionStorage.setItem('timelist_index_order', index);
+    }
+});
+
+var v_info = new Vue({
+    el: '#info',
+    data: {
+        count: 0
+    }
+});
+
+/* vtable插件 */
+jq_vtable.vtable({
+    url: '/index.php?r=o2o/myOrder/list',
+    pagination: true,
+    rows: 30,
+    sort: 'booking_time',
+    query: {
+        userid: userid,
+        start: timelist[jq_vselect.getVIndex()]['value']
+    },
+    columns: [
+        {key: 'booking_time_str', name: '预约时间'},
+        {key: 'status_str', name: '状态'}
+    ],
+    beforeLoad: function() {
+        $.vloading('open');
+    },
+    onSelect: function(index, row) {
+        var order = row.id;
+        if (order.length == 0) {
+            $.valert('订单信息未录入');
+        } else {
+            window.location.href = '/index.php?r=o2o/myOrder/info&order='+order+'&user='+user;
+        }
+    },
+    afterLoad: function(data) {
+        $.vloading('close');
+        v_info.count = data.count;
+    }
+});
+</script>

+ 557 - 0
www/protected/modules/moonclub/views/myOrder/info.php

@@ -0,0 +1,557 @@
+<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=B349f0b32ef6e78b2e678f45cb9fddaf"></script>
+<link href="//cdn.bootcss.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet">
+<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/o2o/jq-signature.min.js"></script>
+
+<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css">
+<div>
+  <div id="header">
+    <div class="am-g">
+      <div class="am-u-sm-12">
+        <div class="layoutbox">
+          订单详情
+        </div>
+      </div>
+    </div>
+  </div>
+  <!-- 订单详情 -->
+  <div id="info">
+    <div class="am-popup-bd" id="info_content" style="display: none;">
+      <div class="am-g">
+        <div class="am-u-sm-4">预约时间</div>
+        <div class="am-u-sm-8">{{info.booking_time_str}}</div>
+      </div>
+      <div class="am-g">
+        <div class="am-u-sm-4">客户姓名</div>
+        <div class="am-u-sm-8">{{info.address.name}}</div>
+      </div>
+      <div class="am-g">
+        <div class="am-u-sm-4">地址</div>
+        <div class="am-u-sm-8">{{info.address.city}}&nbsp;{{info.address.area}}&nbsp;{{info.address.poi.name}}&nbsp;{{info.address.detail}}</div>
+      </div>
+      <div class="am-g">
+        <div class="am-u-sm-4">客户电话</div>
+        <div class="am-u-sm-8"><a href="tel:{{info.address.mobile}}">{{info.address.mobile}}</a></div>
+      </div>
+      <div class="am-g">
+        <div class="am-u-sm-4">订单状态</div>
+        <div class="am-u-sm-8">{{info.status_str}}</div>
+      </div>
+      <br>
+      <div class="am-g">
+        <div class="am-u-sm-6">
+          <button class="am-btn am-btn-primary" style="width: 100%;" id="showMap">显示地图</button>
+        </div>
+        <div class="am-u-sm-6">
+          <button class="am-btn am-btn-default" style="width: 100%;" id="hideMap">隐藏地图</button>
+        </div>
+      </div>
+      <div class="am-g">
+        <div class="am-u-sm-12">
+          <div id="map_box" style="display: none;">
+            <div id="map_container" style="margin-top: 10px; width: 100%;"></div>
+          </div>
+        </div>
+      </div>
+      <br>
+      <div class="am-g">
+        <div class="am-u-sm-4">产品</div>
+        <div class="am-u-sm-12">
+          <ul class="am-list am-list-static am-list-border">
+            <li v-for="product in info.products">
+              名称:&nbsp;<span id="formProductName">{{info.products[0].product.name}}</span><br>
+              价格:&nbsp;{{info.products[0].product.price}}
+            </li>
+          </ul>
+        </div>
+      </div>
+      <div class="am-g" v-if="info.append_orders.length > 0">
+        <div class="am-u-sm-4">追加订单</div>
+        <div class="am-u-sm-12">
+          <ul class="am-list am-list-static am-list-border">
+            <li v-for="append in info.append_orders">
+              <ul class="am-list am-list-static am-list-border">
+                <li v-for="product in append.products">
+                  服务:&nbsp;{{product.name}}<br>
+                  价格:&nbsp;{{product.price}}
+                </li>
+              </ul>
+            </li>
+          </ul>
+        </div>
+      </div>
+      <div class="am-g am-hide" id="confirm_container">
+        <div class="am-u-sm-12">
+          <button class="am-btn am-btn-block am-btn-primary" id="confirm_set_out">确认订单</button>
+        </div>
+      </div>
+      <div class="am-g am-hide" id="setout_container">
+        <div class="am-u-sm-12">
+          <button class="am-btn am-btn-block am-btn-primary" id="confirm_set_out">确认出发</button>
+        </div>
+      </div>
+      <div class="am-g am-hide" id="come_container">
+        <div class="am-u-sm-12">
+          <button class="am-btn am-btn-block am-btn-primary" id="confirm_come">确认上门</button>
+        </div>
+      </div>
+      <div class="am-g am-hide" id="has_come_container">
+        <div class="am-u-sm-12">
+          <button class="am-btn am-btn-block am-btn-primary">已上门</button>
+        </div>
+      </div>
+      <div class="am-g am-hide" id="has_come_success">
+        <div class="am-u-sm-12">
+          <button class="am-btn am-btn-block am-btn-primary am-disabled">已完成</button>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
+<!--手写板-->
+<div id="pics"
+     style="position: fixed;width: 100%;background: #fff;top:0;display: none;text-align: center;padding-bottom: 10px;">
+  <div class="">
+    <div class="">
+      <div class="js-signature"></div>
+    </div>
+    <p style="margin:0;border-top: 1px solid rgba(0,0,0,0.3);padding-top: 4px;">
+      <button id="returnBtn" class="btn btn-default">返回</button>
+      <button id="clearBtn" class="btn btn-default" onclick="clearCanvas();">清除</button>
+      &nbsp;
+      <button id="saveBtn" class="btn btn-default" onclick="saveSignature();" disabled>确认财产无误</button>
+    </p>
+  </div>
+</div>
+<div style="clear: both"></div>
+<!--表单-->
+<div id="orderForm"
+     class="am-hide"
+     style="position: fixed;top: 0;width: 100%;background: rgba(255,255,255,1);color:rgb(0,0,0);">
+  <h1 style="text-align: center;margin-top: 1rem" id="formH1">民宿保洁检查表</h1>
+  <form action="" id="orderFormTitle" class="form-ul">
+    <div class="form-ul" style="position: fixed;5rem;">
+      <!--设备检查-->
+      <div id="orderForm1" class="am-hide">
+        <h3 style="text-align: left">设备检查</h3>
+        <input type="checkbox" value="电视机">电视机有遥控器、可开启。<br/>
+        <input type="checkbox" value="空调">空调有遥控器、可开启。<br/>
+        <input type="checkbox" value="冰箱">冰箱运行中。<br/>
+        <input type="checkbox" value="Wifi">Wifi可连接。<br/>
+      </div>
+      <!--卧室客厅-->
+      <div id="orderForm2" class="am-hide">
+        <h3 style="text-align: left">卧室客厅</h3>
+        <input type="checkbox" value="四件套">四件套,已换新,无污无毛发。<br/>
+        <input type="checkbox" value="床底">床底,床沿触手可及处,无异物。<br/>
+        <input type="checkbox" value="床头柜"><span>床头柜,抽屉内无前客残留物,台面干净、无灰尘污迹。</span><br/>
+        <input type="checkbox" value="地面">地面,扫过一遍,无明显毛发、灰尘、污迹。<br/>
+        <input type="checkbox" value="茶几、写字台">茶几、写字台,台面干净、无灰尘污迹。<br/>
+      </div>
+      <!--洗手间-->
+      <div id="orderForm3" class="am-hide">
+        <h3 style="text-align: left">洗手间</h3>
+        <input type="checkbox" value="马桶">马桶洗刷一遍,清洁无渍,无毛发,马桶盖翻开。<br/>
+        <input type="checkbox" value="台盆">台盆,台面台盆整洁,已擦干,无渍无毛发。<br/>
+        <input type="checkbox" value="浴缸、淋浴房">浴缸、淋浴房,已擦干,无渍无毛发。<br/>
+        <input type="checkbox" value="地面">地面拖过一遍、无明显毛发、灰尘、污迹。<br/>
+      </div>
+      <!--厨房-->
+      <div id="orderForm4" class="am-hide">
+        <h3 style="text-align: left">厨房</h3>
+        <input type="checkbox" value="冰箱">厨房无前客残留物,内无食物残留污迹。<br/>
+        <input type="checkbox" value="微波炉">微波炉内壁托盘无明显食物残留污迹。<br/>
+        <input type="checkbox" value="灶台、厨具">灶台、厨具灶台清洁无油渍,使用过的厨具清洗擦拭收纳。<br/>
+        <input type="checkbox" value="餐桌">餐桌擦拭一遍,无污迹油渍。。<br/>
+        <input type="checkbox" value="水斗">水斗无厨余残存痕迹。<br/>
+        <input type="checkbox" value="地面">地面扫过一遍,无明显灰尘、污迹。<br/>
+      </div>
+      <!--最后检查-->
+      <div id="orderForm5" class="am-hide form-group">
+        <h3 style="text-align: left">最后检查</h3>
+        <div class="col-xs-12 col-sm-12 col-md-12">
+          <input type="checkbox" value="窗户">窗户闭合关实。<br/>
+          <input type="checkbox" value="电器">电器除冰箱、wifi外,其它家电关闭状态。<br/>
+        </div>
+        <h4>物料</h4>
+        <div class="" style="display: block">
+          <span class="col-xs-8 col-md-8">卧室、客厅,有纸巾摆放包数。</span>
+          <select name="" class="" id="">
+            <option value="0">0</option>
+            <option value="0-5">0-5</option>
+            <option value="5-10">5-10</option>
+            <option value="10-20">10-20</option>
+          </select>
+        </div>
+        <div class="col-lg-12">
+          <span class="col-xs-8 col-md-8">厕所,有卷纸摆放包数。</span>
+          <br>
+          <select name="" class="" id="">
+            <option value="0">0</option>
+            <option value="0-5">0-5</option>
+            <option value="5-10">5-10</option>
+            <option value="10-20">10-20</option>
+          </select>
+        </div>
+        <div class="col-xs-12 col-sm-12 col-md-12">
+          <input type="checkbox"> 洗发水、沐浴露预估存于30%以上。
+        </div>
+      </div>
+    </div>
+    <div style="text-align: center;position:fixed;bottom:1rem;margin-top: 1rem;" class="col-xs-12 col-sm-12 col-md-12">
+      <a class="btn btn-danger" id="formNO">取消</a>
+      &nbsp;&nbsp;
+      <a class="btn btn-success" id="formYes">确认</a>
+    </div>
+  </form>
+</div>
+<script type="text/javascript">
+  /*设置全局变量*/
+  var url;
+  var index = 0;
+  /*表单js*/
+  $(function () {
+    /*取消*/
+    $('#formNO').on('click', function () {
+      if (index == 0) {
+        $('#orderForm').addClass('am-hide');
+        $('#orderForm1').addClass('am-hide');
+        return false;
+      }
+      if (index == 1) {
+        $('#orderForm1').removeClass('am-hide');
+        $('#orderForm2').addClass('am-hide');
+        index = 0;
+        return false;
+      }
+      if (index == 2) {
+        $('#orderForm2').removeClass('am-hide');
+        $('#orderForm3').addClass('am-hide');
+        index = 1;
+        return false;
+      }
+      if (index == 3) {
+        $('#orderForm3').removeClass('am-hide');
+        $('#orderForm4').addClass('am-hide');
+        index = 2;
+        return false;
+      }
+      if (index == 4) {
+        $('#orderForm4').removeClass('am-hide');
+        $('#orderForm5').addClass('am-hide');
+        index = 3;
+        return false;
+      }
+    });
+    /*确认*/
+    $('#formYes').on('click', function () {
+      if (index == 0) {
+        $('#orderForm1').addClass('am-hide');
+        $('#orderForm2').removeClass('am-hide');
+        index = 1;
+        return false;
+      }
+      if (index == 1) {
+        $('#orderForm2').addClass('am-hide');
+        $('#orderForm3').removeClass('am-hide');
+        index = 2;
+        return false;
+      }
+      if (index == 2) {
+
+        $('#orderForm3').addClass('am-hide');
+        $('#orderForm4').removeClass('am-hide');
+        index = 3;
+        return false;
+      }
+      if (index == 3) {
+
+        $('#orderForm4').addClass('am-hide');
+        $('#orderForm5').removeClass('am-hide');
+        index = 4;
+        return false;
+      }
+      if (index == 4) {
+        $('#orderForm5').addClass('am-hide');
+
+        //隐藏表单
+        $('#orderForm').addClass('am-hide');
+        /*调用手写板*/
+        $('#has_come_container').addClass('am-hide');
+        $('#has_come_success').removeClass('am-hide');
+        $('#pics').css('display', 'block');
+        $('.js-signature').eq(0).on('jq.signature.changed', function () {
+          $('#saveBtn').attr('disabled', false);
+        });
+      }
+
+    });
+    /*返回*/
+    $('#returnBtn').on('click', function () {
+      index = 0;
+      $('#pics').css('display', 'none');
+      $('#has_come_container').removeClass('am-hide');
+      $('#has_come_success').addClass('am-hide');
+    })
+  });
+  /*form样式调整*/
+  $(function () {
+    /*设置ul与li样式*/
+    $('ul.form-ul').css("margin", '0').css('padding', '0');
+    $('ul.form-ul').children('li').css("list-style", 'none');
+    /*设置ul的宽度*/
+    $('ul.form-ul').children('li').width(($(window).width()));
+    /*设置ul的高度  orderFormOne*/
+    $('ul.form-ul').height($('#orderForm1').height());
+    /*设置li的宽度*/
+//    $('ul.form-ul').children('li').width($(window).width());
+    /*设置表单的margin-top*/
+    var formMargin = ((($(window).height()) - ($('#orderFormTitle').height())) / 6) - (($('#formH1').height()) * 3);
+    $('#orderFormTitle').css('margin-top', formMargin);
+    $('#orderForm').height($(window).height());
+    /*设置body的外边距为0*/
+    $('body').css('margin', '0');
+  });
+  /*手写板js*/
+  $(document).on('ready', function () {
+    if ($('.js-signature').length) {
+      $('.js-signature').jqSignature();
+    }
+  });
+  $('.js-signature').eq(0).on('jq.signature.changed', function () {
+    $('#saveBtn').attr('disabled', false);
+  });
+  $('#pics').height($(window).height());//设置底层div高度
+  $("canvas").width($(window).width());//设置手写板宽度
+  $("canvas").height($(window).height() - ($('#saveBtn').height()));//设置手写板高度
+  document.title = '我的订单-详情';
+  var order = <?php echo json_encode($order); ?>;
+  var user = <?php echo json_encode($user); ?>;
+  var showMap = false;
+  var w_height = $(window).height();
+  var map_height = w_height * 0.6;
+  $('#map_container').css({height: map_height + 'px'});
+  var v_order = new Vue({
+    el: '#info',
+    data: {
+      info: []
+    }
+  });
+  $(function () {
+    getOrderInfo(order, user);
+    // 显示地图
+    $('#showMap').click(function () {
+      address = v_order.info.address;
+      position = address.position;
+      if (!position) {
+        $.valert('定位信息未记录');
+        return false;
+      }
+
+      $('#map_box').show();
+
+      map = new BMap.Map('map_container');
+      point = new BMap.Point(position[0], position[1]);
+      marker = new BMap.Marker(point);
+      map.addOverlay(marker);
+      map.centerAndZoom(point, 15);
+
+      windowOpts = {
+        width: 200,
+        height: 100,
+        title: address.area
+      }
+      infoWindow = new BMap.InfoWindow(address.detail, windowOpts);
+      marker.addEventListener("click", function () {
+        map.openInfoWindow(infoWindow, point);
+      });
+    });
+    // 隐藏地图
+    $('#hideMap').click(function () {
+      $('#map_box').hide();
+    });
+    //确认订单
+    $('#confirm_container').click(function () {
+      $.vloading('open');
+      $.post(
+        '/index.php?r=o2o/myOrder/techConfirmOrder',
+        {
+          order: order,
+          user: user
+        },
+        function (res) {
+          $.vloading('close');
+          var data = $.parseJSON(res);
+          if (data.success) {
+            $('#confirm_container').addClass('am-hide');
+            $('#setout_container').removeClass('am-hide');
+            $('#come_container').addClass('am-hide');
+            $('#has_come_container').addClass('am-hide');
+          } else {
+            $.valert(data.msg);
+          }
+        }
+      );
+    });
+    // 确认出发
+    $('#setout_container').click(function () {
+      $.vloading('open');
+      $.post(
+        '/index.php?r=o2o/myOrder/techSetout',
+        {
+          order: order,
+          user: user
+        },
+        function (res) {
+          $.vloading('close');
+          var data = $.parseJSON(res);
+          if (data.success) {
+            $('#setout_container').addClass('am-hide');
+            $('#come_container').removeClass('am-hide');
+            $('#has_come_container').addClass('am-hide');
+          } else {
+            $.valert(data.msg);
+          }
+        }
+      );
+    });
+    // 确认上门
+    $('#confirm_come').click(function () {
+      $.vloading('open');
+      $.post(
+        '/index.php?r=o2o/myOrder/techCome',
+        {
+          order: order,
+          user: user
+        },
+        function (res) {
+          $.vloading('close');
+          var data = $.parseJSON(res);
+          if (data.success) {
+            $('#setout_container').addClass('am-hide');
+            $('#come_container').addClass('am-hide');
+            $('#has_come_container').removeClass('am-hide');
+            $('#has_come_success').addClass('am-hide');
+          } else {
+            $.valert(data.msg);
+          }
+        }
+      );
+    });
+    //已上门
+
+    $('#has_come_container').click(function () {
+      console.log();
+      if($('#formProductName').html()=='民宿保洁'){
+        /*调出表单*/
+        $('#orderForm').removeClass('am-hide');
+        $('#orderForm1').removeClass('am-hide');
+      }else {
+        /*调用手写板*/
+        $('#has_come_container').addClass('am-hide');
+        $('#has_come_success').removeClass('am-hide');
+        $('#pics').css('display', 'block');
+        $('.js-signature').eq(0).on('jq.signature.changed', function () {
+          $('#saveBtn').attr('disabled', false);
+        });
+      }
+//      return false;
+
+    });
+  });
+  function putb64() {
+    var pic = url.replace("data:image/png;base64,", "");//需要提交的base64
+    var uri = "http://up.qiniu.com/putb64/-1";//提交地址
+    var xhr = new XMLHttpRequest();
+    xhr.onreadystatechange = function () {
+      if (xhr.readyState == 4) {
+        $.post(
+          '/index.php?r=o2o/myOrder/techComplete',
+          {
+            order: order,
+            user: user,
+            o2oImage: xhr.responseText
+          },
+          function (res) {
+            $.vloading('close');
+            var data = $.parseJSON(res);
+            if (data.success) {
+              $('#setout_container').addClass('am-hide');
+              $('#come_container').addClass('am-hide');
+              $('#has_come_container').addClass('am-hide');
+              $('#has_come_success').removeClass('am-hide');
+            } else {
+              $.valert(data.msg);
+            }
+          }
+        );
+      }
+    }
+    xhr.open("POST", uri, true);
+    xhr.setRequestHeader("Content-Type", "application/octet-stream");
+    xhr.setRequestHeader("Authorization", "UpToken Kn8GNMFOLKTNMUaKZ6r1wnjsgTk4ideQifK3umUr:a-HCK5r5iPL8Bisb-mQLI21oZJM=:eyJzY29wZSI6ImF2YXRhcnMiLCJkZWFkbGluZSI6MTQ3NDQ1MTg0OTAwMDAwMDAwMH0=");
+    xhr.send(pic);
+  }
+  function saveSignature() {
+    $('#signature').empty();
+    url = $('.js-signature').eq(0).jqSignature('getDataURL');
+    if (url != undefined) {
+      $('#pics').css('display', 'none');
+      //七牛上传照片
+      putb64();
+    }
+  }
+  function clearCanvas() {
+    $('.js-signature').eq(0).jqSignature('clearCanvas');
+    $('#saveBtn').attr('disabled', true);
+  }
+  function getOrderInfo(order, user) {
+    if (order.length == 0 || user.length == 0) {
+      $.valert('订单信息未录入');
+      return false;
+    }
+
+    $.vloading('open');
+    $.post(
+      '/index.php?r=o2o/o2oApp/getOrderInfo',
+      {
+        id: order,
+        user: user
+      },
+      function (res) {
+        $.vloading('close');
+        var data = $.parseJSON(res);
+        if (data.success == false) {
+          $.valert(data.msg);
+        } else {
+          var content = data.content;
+          v_order.info = content;
+          for (var j in content.technicians) {
+            if (content.technicians[j]['technician_id'] == user) {
+              if (content.status != 4 && content.status != 5 && content.status != 6 && $.inArray(content.status, [1, 2, 3]) != -1) {
+                $('#confirm_container').removeClass('am-hide');
+                $('#setout_container').addClass('am-hide');
+                $('#come_container').addClass('am-hide');
+                $('#has_come_container').addClass('am-hide');
+              } else if (content.status == 4) {
+                $('#setout_container').addClass('am-hide');
+                $('#come_container').removeClass('am-hide');
+                $('#has_come_container').addClass('am-hide');
+              } else if (content.status == 5) {
+                $('#setout_container').addClass('am-hide');
+                $('#come_container').addClass('am-hide');
+                $('#has_come_container').removeClass('am-hide');
+              } else if (content.status == 6) {
+                $('#setout_container').addClass('am-hide');
+                $('#come_container').addClass('am-hide');
+                $('#has_come_container').addClass('am-hide');
+                $('#has_come_success').removeClass('am-hide');
+              }
+              break;
+            }
+          }
+          $('#info_content').show();
+        }
+      }
+    );
+  }
+</script>

+ 817 - 0
www/protected/modules/moonclub/views/tech/index.php

@@ -0,0 +1,817 @@
+<link rel="stylesheet" href="http://cdn.amazeui.org//amazeui/2.5.0/css/amazeui.min.css">
+<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/datetimepicker.css">
+<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/datetimepicker.js?v=2"></script>
+<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/amazeui.datetimepicker.zh-CN.js?v=2"></script>
+<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/baidu_map/CityList.js?v=201405243209"></script>
+<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qiniu_upload_single.js?v=20200307"></script>
+<div id="main">
+    <div region="west" id="west_panel" border="false">
+        <table id="dg_content"></table>
+        <div id="tb_content">
+            <div class="tb_line">
+                <div>
+                    <input id="search">
+                    <span>状态</span>
+                    <input id="filter_status">
+                    <span>提成方案</span>
+                    <input id="filter_scheme">
+                    <div class="right">
+                        <a href="#" class='easyui-linkbutton' iconCls="icon-search" plain="true" onclick="search_content();return false;">查询</a>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div region="center" class="easyui-accordion">
+        <div region="center" title="基本信息">
+            <div class="easyui-layout detail_layout">
+                <div data-options="region:'center'" class="detail_center">
+                    <div class="detail_main">
+                        <form id="content_form" method="post">
+                            <ul>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>ID: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input type="hidden" name="_id" id="content_id_hide" value="" />
+                                            <span id="content_id"></span>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>名字: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input name="name" />
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>头像: </span>
+                                        </div>
+                                        <div class="box_flex f_content" id="content_avatar">
+                                            <div id="content_avatar_show"></div>
+                                            <div>
+                                                <a href="#" iconCls="icon-add" id="content_avatar_uploader" class="easyui-linkbutton" plain="true">
+                                                    上传图片
+                                                </a>
+                                            </div>
+                                            <input type="hidden" name="avatar" id="content_avatar_info" />
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>手机号: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input name="mobile" id="content_mobile" readonly/>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>状态: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input name="status" id="content_status" />
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>提成方案: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input name="scheme" id="content_scheme"/>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>服务类型: </span>
+                                        </div>
+                                        <div class="box_flex f_content" id="service_type_container">
+                                            <?php foreach ($service_type as $key => $value): ?>
+                                                <?php if (($key-1) % 4 == 0 && $key != 1): ?>
+                                                    <br>
+                                                <?php endif ?>
+                                                <span class="service_type_list">
+                                                    <input type="checkbox" value="<?=$key?>" name="service_type[]" /><?=$value['name']?>
+                                                </span>
+                                            <?php endforeach ?>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>描述: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <textarea name="desc" style="width:200px;height:120px;"></textarea>
+                                        </div>
+                                    </div>
+                                </li>
+                            </ul>
+                        </form>
+                    </div>
+                </div>
+                <div data-options="region:'south'" class="detail_south">
+                    <div class="detail_toolbar">
+                        <a href="#" class="easyui-linkbutton set_button" iconCls="icon-save" onclick="save_content();return false;">保存</a>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div region="center" title="微信信息">
+            <div class="easyui-layout detail_layout">
+                <div data-options="region:'center'" class="detail_center">
+                    <form id="weixin_info_form" method="post">
+                        <ul>
+                            <li class="f_item">
+                                <div class="box">
+                                    <div class="f_label">
+                                        <span>姓名</span>
+                                    </div>
+                                    <div class="box_flex f_content">
+                                        <input type="hidden" name="_id" />
+                                        <input type="hidden" name="name" />
+                                        <span id="weixin_info_name"></span>
+                                    </div>
+                                </div>
+                            </li>
+                            <li class="f_item">
+                                <div class="box">
+                                    <div class="f_label">
+                                        <span>微信ID</span>
+                                    </div>
+                                    <div class="box_flex f_content">
+                                        <input name="weixin_userid" id="weixin_info_userid" />
+                                    </div>
+                                </div>
+                            </li>
+                            <li class="f_item">
+                                <div class="box">
+                                    <div class="f_label">
+                                        <span>手机号</span>
+                                    </div>
+                                    <div class="box_flex f_content">
+                                        <input name="mobile" id="weixin_info_mobile" />
+                                    </div>
+                                </div>
+                            </li>
+                        </ul>
+                    </form>
+                </div>
+                <div data-options="region:'south'" class="detail_south">
+                    <div class="detail_toolbar">
+                        <a href="#" class="easyui-linkbutton set-button" id="save_weixin_info" iconCls="icon-save" onclick="save_weixin_info()">保存</a>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div region="center" title="服务时间">
+            <div class="easyui-layout detail_layout">
+                <div data-options="region:'center'" class="detail_center">
+                    <div id="datetimepicker_container"></div>
+                    <div>
+                        <form id="free_time_form" method="post">
+                            <input type="hidden" name="_id" />
+                            <input type="hidden" name="old_time_list" id="old_time_list" value="{}"/>
+                            <input type="hidden" name="new_time_list" id="new_time_list" value="{}"/>
+                        </form>
+                    </div>
+                </div>
+                <div data-options="region:'south'" class="detail_south">
+                    <div class="detail_toolbar">
+                        <a href="#" class="easyui-linkbutton set_button" id="save_selected_time" iconCls="icon-save" onclick="save_timeline();return false;">保存</a>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div region="center" title="服务范围">
+            <div class="easyui-layout detail_layout">
+                <div data-options="region:'center'" class="detail_center">
+                    <div style="width: 540px;height: 460px;">
+                        <div id="add_coverage_container" style="padding-bottom: 10px;display:inline-block;width:400px;"></div>
+                        <div id="add_coverage_button" style="display:inline-block;">
+                            <a href="#" class="easyui-linkbutton set_button" iconCls="icon-add" plain="true" onclick="add_coverage();">添加服务范围</a>
+                        </div>
+                        <div id="add_coverage_map_container" style="width:520px;height:340px;"></div>
+                        <div>
+                            <div id="coverage_info">
+                            </div>
+                            <form id="coverage_form" method="post">
+                                <input type="hidden" name="_id" />
+                                <input type="hidden" name="coverage_json" id="coverage_json" />
+                            </form>
+                        </div>
+                    </div>
+                </div>
+                <div data-options="region:'south'" class="detail_south">
+                    <div class="detail_toolbar">
+                        <a href="#" class="easyui-linkbutton set_button" iconCls="icon-save" onclick="save_coverage();return false;">保存</a>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<style type="text/css">
+body {margin: 8px;}
+.f_label {width: 90px;}
+.service_type_list {display:inline-block;width:110px;}
+</style>
+<script type="text/javascript">
+// option
+var status_option = <?php echo json_encode($status_option); ?>;
+var scheme_option = <?php echo json_encode($scheme_option); ?>;
+
+// base
+var module_root = site_root + '/index.php?r=o2o/tech';
+var w_width = $(window).width();
+var w_height = $(window).height();
+
+// datagrid
+var jq_dg_content = $('#dg_content');
+var jq_search = $('#search');
+var jq_filter_status = $('#filter_status');
+var jq_filter_scheme = $('#filter_scheme');
+
+// content_form
+var jq_content_form = $('#content_form');
+var jq_content_status = $('#content_status');
+var jq_content_scheme = $('#content_scheme');
+
+// add_form
+var jq_add_dialog = $('#add_dialog');
+var jq_add_form = $('#add_form');
+
+// free_time
+var datePickerStart = <?=json_encode($datePickerStart)?>;
+var datePickerEnd = <?=json_encode($datePickerEnd)?>;
+var jq_free_time_form = $('#free_time_form');
+
+// coverage
+var jq_coverage_form = $('#coverage_form');
+
+// weixin
+var jq_weixin_info_form = $('#weixin_info_form');
+
+$(function() {
+    var p_width = parseInt(w_width / 2);
+    if (p_width < 550) {p_width = 550}
+    var d_width = p_width - 18;
+
+    $('#west_panel').css({width: p_width});
+    $('#main').css({width: w_width - 25, height: w_height - 18}).layout();
+
+    // content_form
+    jq_content_status.combobox({
+        data: status_option,
+        editable: false
+    });
+
+    jq_content_scheme.combobox({
+        data: scheme_option,
+        editable: false
+    });
+
+    jq_content_form.form({
+        url: module_root + '/edit',
+        onSubmit: function(params) {
+            $.messager.progress();
+            var isValid = $(this).form('validate');
+            if (!isValid) {
+                $.messager.progress('close');
+            }
+            return isValid;
+        },
+        success: function(res) {
+            $.messager.progress('close');
+            var res = JSON.parse(res);
+            if(res.success) {
+                jq_dg_content.datagrid('reload');
+                $.messager.show({
+                    title: '提示',
+                    msg: '保存成功',
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            } else {
+                $.messager.show({
+                    title: '提示',
+                    msg: res.message,
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            }
+        }
+    });
+
+    // datagrid
+    jq_search.searchbox({
+        width: 150,
+        searcher: function() {
+            search_content();
+        },
+        prompt: 'ID、名字、微信ID'
+    });
+
+    jq_filter_status.combobox({
+        data: status_option,
+        width: 80,
+        editable: false,
+        onSelect: function() {
+            search_content();
+        }
+    });
+
+    jq_filter_scheme.combobox({
+        data: scheme_option,
+        width: 80,
+        editable: false,
+        onSelect: function() {
+            search_content();
+        }
+    });
+
+    jq_dg_content.datagrid({
+        height: w_height - 18,
+        width: d_width,
+        title: '保洁师列表',
+        idField: '_id',
+        url: module_root + '/list',
+        toolbar: '#tb_content',
+        nowrap: false,
+        singleSelect: true,
+        fitColumns: true,
+        queryParams: $.extend({
+            status: 1
+        }, get_param_obj()),
+        sortName: '_id',
+        sortOrder: 'asc',
+        pagination: true,
+        pageSize: 30,
+        pageList: [10, 20, 30, 50],
+        columns: [[
+            {field: 'name', title: '名字', width: 100},
+            {field: 'weixin_userid', title: '微信ID', width: 100},
+            {field: 'favourable_count', title: '好评数', width: 50},
+            {field: 'order_count', title: '服务次数', width: 50},
+            {field: 'scheme', title: '提成方案', width: 60,
+                formatter: function(value, row) {
+                    if (value == -1) {
+                        return '<span style="color: orange;">'+row['scheme_str']+'</span>';
+                    } else {
+                        return '<span>'+row['scheme_str']+'</span>';
+                    }
+                }
+            },
+            {field: 'status', title: '状态', width: 40,
+                formatter: function(value, row) {
+                    if (value == 1) {
+                        var color = 'green';
+                    } else if (value == 0) {
+                        var color = 'orange';
+                    } else {
+                        var color = 'red';
+                    }
+                    return '<span style="color:'+color+'">'+row.status_str+'</span>';
+                }
+            }
+        ]],
+        onSelect: function(index, row) {
+            // 载入数据
+            var data = $.extend(row, {});
+            jq_content_form.form('load', data);
+            $('#content_id').html(row._id);
+
+            // 头像显示
+            $('input[name="file"]').remove();
+            $('#content_avatar_show').empty();
+            if (data.avatar) {
+                var avatar_url = data.avatar;
+                $('#content_avatar_info').val(avatar_url);
+                $('#content_avatar_show').html('<img src="'+avatar_url+'" style="max-width: 60px" />');
+            } else {
+                $('#content_avatar_info').val('');
+            }
+
+            // 头像上传
+            $.fn.qiniu_upload_single('init', {
+                bucket: 'avatars',
+                button: '#content_avatar_uploader',
+                success_callback: function(result) {
+                    console.log(result);
+                    var img_url = result.url;
+
+                    var img = new Image();
+                    img.onload = function() {
+                        var imgWidth = img.width;
+                        var imgHeight = img.height;
+                        $('#content_avatar_info').val(img_url);
+                        $('#content_avatar_show').html('<img src="'+img_url+'" style="max-width: 60px;"/>');
+                    }
+                    img.src = img_url;
+                },
+                fail_callback: function() {
+                    $.messager.alert('提示', '上传失败,请重试');
+                    return false;
+                }
+            });
+
+            // 服务类型选择
+            $('#service_type_container').children().each(function (index, element) {
+                var val = parseInt($(this).find('input').val());
+                if ($.inArray(val, data.service_type) != -1) {
+                    $(this).find('input').prop('checked', true);
+                } else {
+                    $(this).find('input').prop('checked', false);
+                }
+            });
+
+            // 时间选择
+            $('#datetimepicker_container').empty();
+            $('#old_time_list').val('{}');
+            $('#new_time_list').val('{}');
+            showDatetimePicker(data._id);
+            jq_free_time_form.form('load', data);
+
+            // 服务范围选择
+            initBaiduCityList();
+            jq_coverage_form.form('load', data);
+            $('#add_coverage_button').show();
+            var coverage_info = '';
+            for (key in data.coverage) {
+                coverage_info += parse_coverage_item(data['coverage'][key], key);
+            }
+            $('#coverage_info').html(coverage_info);
+
+            // 微信信息
+            jq_weixin_info_form.form('load', data);
+            $('#weixin_info_name').html(data.name);
+            if (data.weixin_userid) {
+                $('#weixin_info_userid').attr('readonly', true);
+            } else {
+                $('#weixin_info_userid').removeAttr('readonly');
+            }
+        },
+        onLoadSuccess: function() {
+            // 基本信息
+            jq_content_form.form('clear');
+            $('#content_id').html('');
+            $('#content_avatar_show').empty();
+
+            // 时间选择
+            jq_free_time_form.form('clear');
+            $('#datetimepicker_container').empty();
+
+            // 服务范围
+            jq_coverage_form.form('clear');
+            $('#add_coverage_container').empty();
+            $('#add_coverage_map_container').empty();
+            $('#add_coverage_button').hide();
+            $('#coverage_info').empty();
+            
+            // 微信信息
+            jq_weixin_info_form.form('clear');
+            $('#weixin_info_name').empty();
+            $('#weixin_info_userid').removeAttr('disabled');
+        }
+    });
+
+    // free_time
+    jq_free_time_form.form({
+        url: module_root + '/modifyFreetime',
+        onSubmit: function(param) {
+            $.messager.progress();
+            var isValid = $(this).form('validate');
+            if (!isValid) {
+                $.messager.progress('close');
+            }
+            return isValid;
+        },
+        success: function(res) {
+            $.messager.progress('close');
+            var res = JSON.parse(res);
+
+            if (res.success) {
+                jq_dg_content.datagrid('reload');
+                $.messager.show({
+                    title: '提示',
+                    msg: '保存成功',
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            } else {
+                $.messager.show({
+                    title: '提示',
+                    msg: res.message,
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            }
+        }
+    });
+
+    // coverage
+    jq_coverage_form.form({
+        url: module_root + '/modifyCoverage',
+        onSubmit: function(param) {
+            $.messager.progress();
+            var isValid = $(this).form('validate');
+            if (!isValid) {
+                $.messager.progress('close');
+            }
+            return isValid;
+        },
+        success: function(res) {
+            $.messager.progress('close');
+            var res = JSON.parse(res);
+
+            if (res.success) {
+                jq_dg_content.datagrid('reload');
+                $.messager.show({
+                    title: '提示',
+                    msg: '保存成功',
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            } else {
+                $.messager.show({
+                    title: '提示',
+                    msg: res.message,
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            }
+        }
+    });
+
+    // 删除item绑定事件
+    $('body').on('click', '.del_coverage_item', function() {
+        var coverages = new Array();
+        if ($('#coverage_json').val()) {
+            var coverages = JSON.parse($('#coverage_json').val());
+        }
+
+        coverages.splice($(this).parent('div').attr('data'), 1);
+        $(this).parent('div').remove();
+        $('#coverage_info').children('div').each(function(index, e) {
+            $(this).attr('data', index);
+        });
+
+        $('#coverage_json').val(JSON.stringify(coverages));
+    });
+
+    // weixin_info
+    jq_weixin_info_form.form({
+        url: module_root + '/modifyWeixinInfo',
+        onSubmit: function(param) {
+            $.messager.progress();
+            var isValid = $(this).form('validate');
+            if (!isValid) {
+                $.messager.progress('close');
+            }
+            return isValid;
+        },
+        success: function(res) {
+            $.messager.progress('close');
+            var res = JSON.parse(res);
+
+            if (res.success) {
+                jq_dg_content.datagrid('reload');
+                $.messager.show({
+                    title: '提示',
+                    msg: '保存成功',
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            } else {
+                $.messager.show({
+                    title: '提示',
+                    msg: res.message,
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            }
+        }
+    });
+});
+
+function search_content() {
+    var status = jq_filter_status.combobox('getValue');
+    var scheme = jq_filter_scheme.combobox('getValue');
+    var search = jq_search.searchbox('getValue');
+
+    var query = {
+        status: status,
+        scheme: scheme,
+        search: search
+    };
+
+    jq_dg_content.datagrid({
+        queryParams: query
+    });
+}
+
+function save_content() {
+    if (!$('#content_id_hide').val()) {
+        $.messager.alert('提示', '请选择一个保洁师');
+        return false;
+    }
+
+    if (jq_content_scheme.combobox('getValue') == 100) {
+        $.messager.alert('提示', '请选择一个提成方案');
+        return false;
+    }
+
+    var status = jq_content_status.combobox('getValue');
+    if (parseInt(status) == -1) {
+        $.messager.confirm('提示', '确认删除吗?<br>该操作将删除后台用户,同时禁用微信端成员', function (r) {
+            if (!r) {
+                return false;
+            } else {
+                jq_content_form.form('submit');
+            }
+        });
+    } else {
+        jq_content_form.form('submit');
+    }
+}
+
+// 显示时间选择插件
+function showDatetimePicker(_id) {
+    $.post(
+        module_root + '/getTechTimeline',
+        {
+            _id: _id
+        },
+        function (res) {
+            var data = $.parseJSON(res);
+            var old_time_list = {};
+            var selected = {
+                day: {},
+                hours: {}
+            }
+            for (key in data) {
+                if (data[key]['selected']) {
+                    selected.day[key] = parseInt(data[key]['selected']);
+                    selected.hours[key] = data[key]['selectedHours'].slice();
+                    old_time_list[key] = data[key]['selectedHours'].slice();
+                }
+            }
+            $('#old_time_list').val(JSON.stringify(old_time_list));
+            $('#datetimepicker_container').append('<input id="datetimepicker" size="16" type="text" value="'+datePickerStart+'" readonly class="form-datetime am-form-field">');
+            initDatetimepicker(datePickerStart, datePickerEnd, selected);
+        }
+    );
+}
+
+function initDatetimepicker(startDate, endDate, selected) {
+    $('#datetimepicker').datetimepicker({
+        language:  'zh-CN',
+        format: 'yyyy-mm-dd hh:ii:ss',
+        startDate: startDate,
+        endDate: endDate,
+        startView: 2,
+        minView: 1,
+        todayBtn: true,
+        todayHighlight: true,
+        startHours: 9,
+        endHours: 19,
+        minuteStep: 10,
+        selected: selected
+    }).on('changeHour', function(event){
+        newSelectedTime(event);
+    }).on('today', function(event) {
+        newSelectedTime(event);
+    }).on('allDay', function(event) {
+        newSelectedTime(event);
+    });
+}
+
+function newSelectedTime(event) {
+    var new_time_list = JSON.parse($('#new_time_list').val());
+    if (event.type == 'today') {
+        var dateObj = new Date();
+        var today_year = dateObj.getFullYear() + '';
+        var today_month = dateObj.getMonth() + 1 + '';
+        var today_date = dateObj.getDate() + '';
+        if (today_month.length < 2) {
+            today_month = '0' + today_month;
+        }
+        if (today_date.length < 2) {
+            today_date = '0' + today_date;
+        }
+
+        var today_key = today_year + today_month + today_date;
+
+        new_time_list[today_key] = [
+            0, 0, 0, 0, 0, 0, 0, 0,
+            0, 1, 1, 1, 1, 1, 1, 1,
+            1, 1, 1, 1, 0, 0, 0, 0
+        ];
+    } else {
+        new_time_list = event.selectedHours;
+    }
+
+    $('#new_time_list').val(JSON.stringify(new_time_list));
+}
+
+function save_timeline() {
+    jq_free_time_form.submit();
+}
+
+function initBaiduCityList() {
+    map = new BMap.Map('add_coverage_map_container');
+    map.centerAndZoom(new BMap.Point(31.229402,121.455129), 12);
+    var cityList = new BMapLib.CityList({
+        container: 'add_coverage_container',
+        map: map
+    });
+}
+
+function add_coverage() {
+    var coverages = new Array();
+    if ($('#coverage_json').val()) {
+        coverages = JSON.parse($('#coverage_json').val());
+    }
+
+    var coverage_item = {};
+    coverage_item.province = storage.getItem('province');
+    coverage_item.city     = storage.getItem('city');
+    coverage_item.area     = storage.getItem('area');
+
+    if (storage.getItem('business') && storage.getItem('business') != '请选择') {
+        coverage_item.business = storage.getItem('business');
+    }
+
+    if (coverage_item.city != '上海市') {
+        $.messager.alert('提示', '必须选择上海市');
+        return false;
+    } else if (!coverage_item.province || !coverage_item.city || !coverage_item.area) {
+        $.messager.alert('提示', '必须选择区');
+        return false;
+    } else if (!coverage_item.business) {
+        var businessArray = [];
+        $('#add_coverage_container>select').last().children().each(function (index, element) {
+            if (this.title != '请选择') {
+                var coverage_json = $('#coverage_json').val();
+                var coverages = coverage_json ? JSON.parse(coverage_json) : [];
+                coverage_item.business = this.title;
+                coverages.push(coverage_item);
+                $('#coverage_json').val(JSON.stringify(coverages));
+                $('#coverage_info').html($('#coverage_info').html() + parse_coverage_item(coverage_item, coverages.length - 1));
+            }
+        });
+    } else {
+        coverages.push(coverage_item);
+        $('#coverage_json').val(JSON.stringify(coverages));
+        $('#coverage_info').html($('#coverage_info').html() + parse_coverage_item(coverage_item, coverages.length - 1));
+    }
+
+    storage.removeItem('province');
+    storage.removeItem('city');
+    storage.removeItem('area');
+    storage.removeItem('business');
+    storage.removeItem('points');
+    initBaiduCityList();
+}
+
+function parse_coverage_item(item, index) {
+    if (item.business) {
+        return '<div data='+index+'>['+item.province+'-'+item.city+'-'+item.area+'-'+item.business+']&nbsp;&nbsp;<a href="#" class="del_coverage_item">删除</a></div>';
+    } else {
+        return '<div data='+index+'>['+item.province+'-'+item.city+'-'+item.area+']&nbsp;&nbsp;<a href="#" class="del_coverage_item">删除</a></div>';
+    }
+}
+
+function save_coverage() {
+    jq_coverage_form.submit();
+}
+
+function save_weixin_info() {
+    if (!$('#weixin_info_userid').val()) {
+        $.messager.alert('提示', '请输入微信ID');
+        return false;
+    }
+    if (!$('#weixin_info_mobile').val()) {
+        $.messager.alert('提示', '请输入手机号');
+        return false;
+    }
+    jq_weixin_info_form.submit();
+}
+</script>

+ 1 - 0
www/protected/modules/moonclub/views/techHome/error.php

@@ -0,0 +1 @@
+<h1><?=$msg?></h1>

+ 161 - 0
www/protected/modules/moonclub/views/techHome/index.php

@@ -0,0 +1,161 @@
+<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/js/cropbox/jquery.cropbox.css">
+<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/cropbox/hammer.js"></script>
+<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/cropbox/jquery.mousewheel.js"></script>
+<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/cropbox/jquery.cropbox.js?v=2016032201"></script>
+
+<form class="am-form tech-form">
+  <fieldset>
+    <legend><?=$name?><small>个人信息</small></legend>
+    <div class="am-form-group">
+      <label for="doc-ta-1">介绍</label>
+      <textarea class="intro" rows="5" id="doc-ta-1"><?=$desc?></textarea>
+    </div>
+
+    <div class="am-form-group am-form-file">
+      <label for="doc-ipt-file-2">头像</label>
+      <div>
+        <button type="button" class="am-btn am-btn-default am-btn-sm tech-avatar-btn">
+          <i class="am-icon-cloud-upload"></i> 选择图片</button>
+        <input type="file" id="tech-avatar" style="top: initial;bottom: 0;font-size: 1.4rem;padding: .25em 1em;">
+      </div>
+    </div>
+    <p class="img-preview">
+      <img src="<?=$avatar?>" alt="" class="" width="200" height="200">
+    </p>
+    <p>
+      <!-- <button type="submit" class="am-btn am-btn-default btn-edit">编辑</button> -->
+      <button type="submit" class="am-btn am-btn-success btn-submit">提交</button>
+    </p>
+  </fieldset>
+</form>
+<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
+  <div class="am-modal-dialog">
+    <div class="am-modal-hd">提示信息</div>
+    <div class="am-modal-bd">
+      介绍或者头像不能为空
+    </div>
+    <div class="am-modal-footer">
+      <span class="am-modal-btn">确定</span>
+    </div>
+  </div>
+</div>
+<script>
+$(function(){
+  /* 初始化参数 */
+  var tech_name   = <?=json_encode($name)?>;          // 保洁师姓名
+  var tech_id     = <?=json_encode($_id)?>;           // 保洁师后台ID
+  var token       = <?=json_encode($qiniu_token)?>;   // 七牛上传token
+  var url         = <?=json_encode($qiniu_url)?>;     // 七牛上传url_prefix
+  var avatar = <?=json_encode($avatar)?>;
+  var intro = <?=json_encode($desc)?>;
+  var cropImg = '';
+  var apiUrl = 'http:// api.yiguanjia.me';
+  if (location.host == ' apitest.yiguanjia.me') {
+    apiUrl = 'http:// apitest.yiguanjia.me';
+  } else if (location.host == 'api.yiguanjiadev.me') {
+    apiUrl = 'http://api.yiguanjiadev.me';
+  }
+
+  function edit() {
+    $('.tech-form').find('.intro').removeAttr('readonly');
+    $('#tech-avatar').removeAttr('disabled');
+    $('.tech-avatar-btn').removeClass('am-disabled');
+  }
+  function submit() {
+    $('.tech-form').find('.intro').attr('readonly', 'true');
+    $('#tech-avatar').attr('disabled', 'disabled');
+    $('.tech-avatar-btn').addClass('am-disabled');
+  }
+
+  $('.intro').on('blur', function(event) {
+    event.preventDefault();
+    intro = $(this).val();
+  });
+
+  $('.tech-form').on('click', '.btn-edit', function(event) {
+    event.preventDefault();
+    edit();
+  });
+
+  $('.tech-form').on('click', '.btn-submit', function(event) {
+    event.preventDefault();
+    if (intro == '') {
+      alert('介绍不能为空');
+    } else if (avatar == '') {
+      alert('请上传头像');
+    } else {
+      submit();
+      $.ajax({
+        url: apiUrl + '/index.php?r=o2o/techHome/updateInfo',
+        jsonp: "callback",
+        dataType: "jsonp",
+        data: {
+          tech_id: tech_id,
+          desc: intro,
+          avatar: avatar + cropImg
+        }
+      })
+      .done(function(res) {
+        alert(res.message);
+      })
+      .fail(function(res) {
+        alert(res.message);
+      })
+      .always(function() {
+        edit();
+      });
+    }
+  });
+
+  $('.tech-form').on('change', '#tech-avatar', function(event) {
+    event.preventDefault();
+
+    var files = event.target.files;
+    var formData = new FormData();
+    formData.append('token', token);
+    formData.append('file', files[0]);
+    var name = files[0].name;
+    var point = name.lastIndexOf('.'),
+        type = name.substr(point),
+        key = Math.random().toString(16).substring(2) + (+new Date()) + type;
+    formData.append('key', key);
+
+    $.ajax({
+      url: 'http://upload.qiniu.com',
+      type: 'POST',
+      data: formData,
+      processData: false,
+      contentType: false
+    })
+    .done(function(res) {
+      avatar = url + res.key
+      $('.img-preview').html('<img src="'+ url + res.key +'" alt="" class="cropimage">');
+      crop();
+    })
+    .fail(function() {
+      console.log("error");
+    })
+    .always(function() {
+      console.log("complete");
+    });
+
+  });
+
+  function crop() {
+    $('.cropimage').cropbox({
+      width: 200,
+      height: 200,
+      controls: ''
+    }, function() {
+      //on load
+
+    }).on('cropbox', function(event, results) {
+      var X = results.cropX;
+      var Y = results.cropY;
+      var W = results.cropW;
+      var H = results.cropH;
+      cropImg = '?imageMogr/v2/crop/!' + W + 'x' + H + 'a' + X + 'a' + Y;
+    });
+  }
+})
+</script>

+ 24 - 0
www/protected/modules/moonclub/views/web/authFailed.php

@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<!--HTML5 doctype-->
+<html>
+ 
+<head>
+    <title>壹管家宠物服务</title>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+    <meta name="apple-mobile-web-app-capable" content="yes">
+	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
+    <meta http-equiv="Pragma" content="no-cache">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/webapp/framework/ratchet-2.0.2/dist/css/ratchet.min.css">
+	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/webapp/framework/ratchet-2.0.2/dist/css/ratchet-theme-ios.min.css">
+</head>
+	
+<body>
+	<div class="content-padded">
+		<h2>微信登录失败</h2>
+		<a class="btn btn-primary btn-block" href="<?php echo $wxLoginURI; ?>">重新登录</a>
+	</div>
+</body>
+	
+</html>

File diff suppressed because it is too large
+ 19 - 0
www/protected/modules/moonclub/views/web/index.php


+ 31 - 0
www/protected/modules/moonclub/views/web/wxIndex.php

@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<!--HTML5 doctype-->
+<html>
+
+<head>
+    <title>壹管家</title>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
+    <meta name="apple-mobile-web-app-capable" content="yes">
+    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
+    <meta http-equiv="Pragma" content="no-cache">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+</head>
+
+<body>
+    <script type="text/javascript">
+    (function(){
+        var codeURI = '<?php echo $codeURI; ?>';
+        var appURI = '<?php echo $appURI; ?>';
+
+        var wxUserID = localStorage.getItem('wxUserID');
+        if (wxUserID) {
+            location.href = appURI+'&userId='+wxUserID;
+        } else {
+            location.href = codeURI;
+        }
+    })();
+    </script>
+</body>
+
+</html>

Some files were not shown because too many files changed in this diff