Преглед на файлове

Merge branch 'test' of git.oschina.net:yiguanjia/php into test

seam преди 7 години
родител
ревизия
4d0a59155b

+ 30 - 30
www/protected/config/main.php

@@ -12,33 +12,33 @@ return array(
     'language' => 'zh_cn',
     // autoloading model and component classes
     'import'=>array(
-           'application.models.*',
-           'application.models.data.*',
-           'application.models.redis.*',
-           'application.models.admin.*',
-           'application.components.*',
-           'ext.YiiMongoDbSuite.*',
-           'ext.redis.*',
-           'application.vendors.*',
-           'application.behaviors.*',
-           'application.services.*',
-           'application.controllers.*',
-           'application.message.*',
-           'application.widget.*',
-           'application.modules.o2o.models.*',
-           'application.modules.moonclub.models.*',
-           'ext.phpexcel.*',
-           'ext.aliyuncs.*',
+        'application.models.*',
+        'application.models.data.*',
+        'application.models.redis.*',
+        'application.models.admin.*',
+        'application.components.*',
+        'ext.YiiMongoDbSuite.*',
+        'ext.redis.*',
+        'application.vendors.*',
+        'application.behaviors.*',
+        'application.services.*',
+        'application.controllers.*',
+        'application.message.*',
+        'application.widget.*',
+        'application.modules.o2o.models.*',
+        'application.modules.moonclub.models.*',
+        'ext.phpexcel.*',
+        'ext.aliyuncs.*',
 
 
     ),
 
     'modules'=>array(
-         /*'gii'=>array(
-                       'class'=>'system.gii.GiiModule',
-                       'password'=>'admin',
-                       'ipFilters'=>array('127.0.0.1','::1','192.168.7.1'),
-                    ),*/
+        /*'gii'=>array(
+                      'class'=>'system.gii.GiiModule',
+                      'password'=>'admin',
+                      'ipFilters'=>array('127.0.0.1','::1','192.168.7.1'),
+                   ),*/
         'dataview',
         'common',
         'api',
@@ -59,8 +59,8 @@ return array(
 
         ),
         'cache' => array (
-             'class' => 'system.caching.CFileCache',
-             'directoryLevel' => 2,
+            'class' => 'system.caching.CFileCache',
+            'directoryLevel' => 2,
         ),
         'redis' => array(
             'class' => 'ext.redis.ARedisConnection',
@@ -101,15 +101,15 @@ return array(
         'log'=>array(
             'class'=>'CLogRouter',
             'routes'=>array(
-              array(
-                'class'=>'CFileLogRoute',
-                'levels'=>'error',
-                'filter'=>'CLogFilter',
-              ),
+                array(
+                    'class'=>'CFileLogRoute',
+                    'levels'=>'error',
+                    'filter'=>'CLogFilter',
+                ),
             ),
         ),
         'messages'=>array(
-           'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages'
+            'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages'
         ),
         'coreMessage'=>array(
             'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages'

+ 52 - 9
www/protected/controllers/HouseKeepingController.php

@@ -55,19 +55,62 @@ class HouseKeepingController extends AdminController
     public function actionEdit()
     {
         $status = intval(Yii::app()->request->getParam('status', 100));
+        $contract = intval(Yii::app()->request->getParam('contract', 100));
+        $type = intval(Yii::app()->request->getParam('type', 100));
+        $cart = intval(Yii::app()->request->getParam('cart', 100));
+        $skill = intval(Yii::app()->request->getParam('skill', 100));
+        $age = intval(Yii::app()->request->getParam('age', 0));
+        $tech = intval(Yii::app()->request->getParam('tech', ''));
+        $desc = intval(Yii::app()->request->getParam('desc', ''));
+        $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
+        $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
+        $status_time = intval(Yii::app()->request->getParam('status_time', ''));
+        $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
         $id = Yii::app()->request->getParam('id');
-        if (!$id) {
-            CommonFn::requestAjax(false, '');
+
+        if (!CommonFn::isMongoId($id)) {
+            CommonFn::requestAjax(false, '修改失败', array());
+        }
+        $h = HouseKeeping::get(new MongoId($id));
+
+        if (!empty($contract)) {
+            $h->contract = $contract;
+        }
+        if (!empty($type)) {
+            $h->type = $type;
+        }
+        if (!empty($cart)) {
+            $h->cart = $cart;
+        }
+        if (!empty($skill)) {
+            $h->skill = $skill;
+        }
+        if (!empty($age)) {
+            $h->age = $age;
+        }
+        if (!empty($desc)) {
+            $h->desc = $desc;
+        }
+        if (!empty($status)) {
+            $h->status = $status;
+        }
+        if (!empty($status_time)) {
+            $h->status_time = $status_time;
+        }
+        if (!empty($server_start_time)) {
+            $h->server_start_time = $server_start_time;
+        }
+        if (!empty($server_end_time)) {
+            $h->server_end_time = $server_end_time;
         }
-        if ($status == 100) {
-            CommonFn::requestAjax(false, '请选择状态');
+        if (!empty($yc_time)) {
+            $h->yc_time = $yc_time;
         }
-        $advisory = Advisory::model()->get(new MongoId($id));
-        $advisory->status = $status;
-        $success = $advisory->save();
-        if ($success) {
-            CommonFn::requestAjax(true, '修改成功');
+        if (!empty($tech)) {
+            $h->tech = $tech;
         }
+        $success = $h->save();
+        CommonFn::requestAjax($success, '修改成功', array());
 
     }
 

+ 156 - 0
www/protected/modules/j/controllers/HouseKeepingController.php

@@ -0,0 +1,156 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/1/9
+ * Time: 上午10:02
+ * description :
+ */
+class HouseKeepingController extends JBaseController
+{
+
+    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 = HouseKeeping::model()->findAll($criteria);
+        $rows = CommonFn::getRowsFromCursor($cursor);
+        $parsedRows = HouseKeeping::model()->parse($rows);
+        $total = $cursor->count();
+
+        echo CommonFn::composeDatagridData($parsedRows, $total);
+
+    }
+
+    public function actionEdit()
+    {
+        $status = intval(Yii::app()->request->getParam('status', 100));
+        $contract = intval(Yii::app()->request->getParam('contract', 100));
+        $type = intval(Yii::app()->request->getParam('type', 100));
+        $cart = intval(Yii::app()->request->getParam('cart', 100));
+        $skill = intval(Yii::app()->request->getParam('skill', 100));
+        $age = intval(Yii::app()->request->getParam('age', 0));
+        $tech = intval(Yii::app()->request->getParam('tech', ''));
+        $desc = intval(Yii::app()->request->getParam('desc', ''));
+        $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
+        $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
+        $status_time = intval(Yii::app()->request->getParam('status_time', ''));
+        $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
+        $id = Yii::app()->request->getParam('id');
+
+        if (!CommonFn::isMongoId($id)) {
+            CommonFn::requestAjax(false, '修改失败', array());
+        }
+        $h = HouseKeeping::get(new MongoId($id));
+
+        if (!empty($contract)) {
+            $h->contract = $contract;
+        }
+        if (!empty($type)) {
+            $h->type = $type;
+        }
+        if (!empty($cart)) {
+            $h->cart = $cart;
+        }
+        if (!empty($skill)) {
+            $h->skill = $skill;
+        }
+        if (!empty($age)) {
+            $h->age = $age;
+        }
+        if (!empty($desc)) {
+            $h->desc = $desc;
+        }
+        if (!empty($status)) {
+            $h->status = $status;
+        }
+        if (!empty($status_time)) {
+            $h->status_time = $status_time;
+        }
+        if (!empty($server_start_time)) {
+            $h->server_start_time = $server_start_time;
+        }
+        if (!empty($server_end_time)) {
+            $h->server_end_time = $server_end_time;
+        }
+        if (!empty($yc_time)) {
+            $h->yc_time = $yc_time;
+        }
+        if (!empty($tech)) {
+            $h->tech = $tech;
+        }
+        $success = $h->save();
+        CommonFn::requestAjax($success, '修改成功', array());
+
+    }
+
+    public function actionAdd()
+    {
+        $status = intval(Yii::app()->request->getParam('status', 100));
+        $contract = intval(Yii::app()->request->getParam('contract', 100));
+        $type = intval(Yii::app()->request->getParam('type', 100));
+        $cart = intval(Yii::app()->request->getParam('cart', 100));
+        $skill = intval(Yii::app()->request->getParam('skill', 100));
+        $age = intval(Yii::app()->request->getParam('age', 0));
+        $tech = intval(Yii::app()->request->getParam('tech', ''));
+        $desc = intval(Yii::app()->request->getParam('desc', ''));
+        $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
+        $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
+        $status_time = intval(Yii::app()->request->getParam('status_time', ''));
+        $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
+        $h = new HouseKeeping();
+        $h->user_name = '1';
+        $h->mobile = '15600266816';
+        $h->type = 1;
+        $h->cart = 1;
+        $h->address = '1dsfafsdf';
+        $h->server_start_time = time();
+        $h->server_end_time = time();
+        $h->skill = 1;
+        $h->yc_time = time();
+        $h->age = 18;
+        $h->desc = 'fasdf1';
+        $h->status = 1;
+        $h->status_time = time();
+        $h->tech = '12asdf';
+        $h->contract = 1;
+        $h->time = time();
+        $h->save();
+    }
+    public function actionUserAdd() {
+        $user_name = Yii::app()->getRequest()->getParam('user_name','');
+        $sex = Yii::app()->getRequest()->getParam('sex',1);
+        $card_id = Yii::app()->getRequest()->getParam('card_id',0);
+        $mobile = Yii::app()->getRequest()->getParam('mobile','');
+        $address = Yii::app()->getRequest()->getParam('address','');
+        $time = Yii::app()->getRequest()->getParam('time');
+        $register_time = time();
+
+        $userInfo = new UserInfo;
+        $userInfo->user_id = new MongoId();
+        $userInfo->user_name = $user_name;
+        $userInfo->time = $time;
+        $userInfo->sex = $sex;
+        $userInfo->card_id = $card_id;
+        $userInfo->mobile = $mobile;
+        $userInfo->address = $address;
+        $userInfo->register_time = $register_time;
+        $result = $userInfo->save();
+        CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$result);
+    }
+}

+ 118 - 0
www/protected/modules/j/controllers/WebController.php

@@ -0,0 +1,118 @@
+<?php
+class WebController extends O2oBaseController {
+
+	public function actionIndex() {
+
+		$signPackage = CommonWeixin::get_sign();
+		$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::getAccessInfo($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{
+			/* var_dump(array(
+					 'version' => '2015111601',
+					 'debug' => 'false',
+					 'signPackage' => $signPackage,
+					 'userId' => $userId,
+					 'appToken' => $appToken,
+			 ));exit;*/
+			$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 . '/j/web/index';
+		if($home_page){
+			$appURI = Yii::app()->request->baseUrl . '/j/web/index'.'&home_page='.$home_page;
+			$redirectURI = $redirectURI.'/'.$home_page;
+		}else{
+			$appURI = Yii::app()->request->baseUrl . '/j/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
+		));
+	}
+
+}

+ 24 - 0
www/protected/modules/j/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>

+ 111 - 0
www/protected/modules/j/views/web/index.php

@@ -0,0 +1,111 @@
+<?php $host = $_SERVER['HTTP_HOST']; /*资源路径设置*/ ?>
+<?php $newVersion = 2018010800;/*vue~资源版本号*/ ?>
+<!DOCTYPE html>
+<html>
+<head>
+  <title>壹管家</title>
+  <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+  <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-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">
+  <style media="screen">
+    html{
+      font-size: 120%;
+    }
+    body {
+      height: 100%;
+      width: 100%;
+      overflow-x: hidden;
+      font-size: 17px;
+      line-height: 21px;
+      color: #000;
+      background-color: #fff;
+    }
+
+    * {
+      margin: 0;
+      padding: 0;
+    }
+
+    ul, li {
+      list-style: none;
+      margin: 0;
+      padding: 0;
+    }
+
+    a {
+      text-decoration: initial;
+    }
+  </style>
+  <link rel="stylesheet" id="app_css" href="http://<?php echo $host ?>/webapp/o2o_new/dist/static/css/app.css?v=<?php echo $newVersion?>">
+  <!--vue_end-->
+  <!--  <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.0.min.js"></script>-->
+  <script type="text/javascript" src = 'http://webapi.amap.com/maps?v=1.3&key=ea4228b685c663ac62af7da3a0702c97'></script>
+<!--  <script type="text/javascript" src="https://dn-bughd-web.qbox.me/bughd.min.js" crossOrigin="anonymous"></script>
+    <script type="text/javascript">
+    window.bughd = window.bughd || function () {
+      };
+    bughd("create", {key: "aebe40c5d5b2975056629dc7980676ce"})
+  </script>-->
+</head>
+<body>
+<!--vue-->
+<div id=app></div>
+<script type=text/javascript id="manifest"
+        src="http://<?php echo $host ?>/webapp/o2o_new/dist/static/js/manifest.js?v=<?php echo $newVersion?>"></script>
+<script type=text/javascript id="vendor"
+        src="http://<?php echo $host ?>/webapp/o2o_new/dist/static/js/vendor.js?v=<?php echo $newVersion?>"></script>
+<script type=text/javascript id="appJs"
+        src="http://<?php echo $host ?>/webapp/o2o_new/dist/static/js/app.js?v=<?php echo $newVersion?>"></script>
+
+<!--vue-end-->
+<script type="text/javascript" id="wxMain" data-sign="<?php echo @htmlentities(json_encode($signPackage)); ?>"></script>
+<script type="text/javascript" defer>
+  (function () {
+    var ua = navigator.userAgent.toLowerCase();
+    <?php
+    if (isset($from_channel)) {
+      echo "var from_channel = '$from_channel';";
+      if (!empty($userId) && $from_channel == 'baidu') {
+        echo "var bd_userId = localStorage.setItem('bd_userId',  '" . $userId . "');";
+      }
+    }
+    ?>
+    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
+      <?php
+      if (!empty($userId) && !empty($appToken)) {
+        echo '
+        var wxUserID = localStorage.setItem("wxUserID",  "' . $userId . '");
+        var appToken = localStorage.setItem("appToken", "' . $appToken . '");
+        ';
+      }
+      ?>
+      var userID = localStorage.getItem('wxUserID');
+      var appToken = localStorage.getItem('appToken');
+      console.log(userID);
+      console.log(appToken);
+      if (!userID || !appToken) {
+        localStorage.clear();
+        location.href = '<?php echo Yii::app()->request->baseUrl . '/j/web/wxIndex'; ?>';
+      }
+      var uri = location.href
+      if (uri.indexOf('state=yiguanjia') > -1 && userID && appToken) {
+        window.location.href='http://common.yiguanjia.me/index.php?r=j/web/index';
+      }
+      document.write('<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"><\/script>');
+    }
+    if (location.hash == '#rd') {
+      location.hash = '';
+    }
+//    var debug = false;
+//    var main = '<?php //echo Yii::app()->request->baseUrl;?>///webapp/o2o_new/dist/js/main.js?v=2017053103';
+
+    /*if (debug) {
+      main = '\<\?php echo Yii::app()->request->baseUrl;?>/webapp/o2o/js/main.js?v=' + (new Date()).getTime();
+    }*/
+  })();
+</script>
+</body>
+</html>

+ 31 - 0
www/protected/modules/j/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>

+ 4 - 55
www/protected/modules/moonclub/controllers/POrderController.php

@@ -298,62 +298,11 @@ class POrderController extends AdminController
     }
 
     public function actionImportExcel()
-    {   $back = Yii::app()->request->urlReferrer;
-        $url = Yii::app()->request->getParam('url','');
-        $file = file_get_contents($url);
-        $tmp = __DIR__.'/'.time().'.xlsx';
-        $examp = fopen($tmp,'w+');
-        @fwrite($examp,$file);
-        @fclose($examp);
-        $excelFile  = $tmp;
-        date_default_timezone_set('Asia/Shanghai');
-        Yii::import('application.extensions.PHPExcel.PHPExcel', 1);
-        $phpexcel = new PHPExcel;
-        $excelReader = PHPExcel_IOFactory::createReader('Excel2007');
-        $phpexcel = $excelReader->load($excelFile)->getSheet(0);//载入文件并获取第一个sheet
-
-        $total_line = $phpexcel->getHighestRow();
-        $total_column = $phpexcel->getHighestColumn();
-
-        for ($row = 2; $row <= $total_line; $row++) {
-            $data = array();
-            for ($column = 'A'; $column <= $total_column; $column++) {
-                if ($column == 'A') {
-                    $tmp = trim($phpexcel->getCell($column . $row)->getValue());
-                    $tmp = explode(":",$tmp);
-                    $tmp = strtotime($tmp[0].'-'.$tmp[1].'-'.$tmp[2].' '.$tmp[3].':'.$tmp[4]);
-                    $data[] = $tmp;
-                } else {
-                    $data[] = trim($phpexcel->getCell($column . $row)->getValue());
-                }
-
-
-            }
-
-            $order = new POrder();
-
-            $criteria = new EMongoCriteria();
-
-            $criteria->user_name('==',$data[4]);
-            $userInfo = Employe::model()->find($criteria);
-            //获取服务人员信息
-            if ($userInfo) {
-                $order->service_employer = $userInfo->_id;//服务人员Id
-            } else {
-                CommonFn::requestAjax(false, '服务人员信息不存在');exit;
-            }
-
-            $order->order_time = intval($data[0]);//服务日期
-            $order->address['floor'] = $data[1];//楼号
-            $order->address['room'] = $data[2];//房号
-            $order->service_standards = $data[3];//服务标准
-            $order->status = 0;//已派单
-            $order->in_room_time = 0;
-            $order->out_room_time = 0;
+    {
 
-            $result = $order->save();
-        }
-        unlink($excelFile);
+        $back = Yii::app()->request->urlReferrer;
+        $url = Yii::app()->request->getParam('url','');
+        $res=Service::factory('ImportExcelService')->push($url);
         $this->redirect($back);
     }
 

+ 1 - 1
www/protected/modules/o2o/models/HouseKeeping.php

@@ -106,7 +106,7 @@
          $newRow['status_time'] = CommonFn::get_val_if_isset($row,'status_time','');
          $newRow['tech'] = CommonFn::get_val_if_isset($row,'tech','');
          $newRow['contract'] = CommonFn::get_val_if_isset($row,'contract','');
-         $newRow['contract_srt'] = self::$contract_option[intval($newRow['contract'])];
+         $newRow['contract_str'] = self::$contract_option[intval($newRow['contract'])];
          $newRow['type_str'] = self::$type_option[intval($newRow['type'])];
          $newRow['cart_str'] = self::$cart_options[intval($newRow['cart'])];
          $newRow['skill_str'] = self::$skill_options[intval($newRow['skill'])];

+ 1 - 1
www/protected/modules/y/controllers/DefaultController.php

@@ -1,6 +1,6 @@
 <?php
 
-class DefaultController extends JBaseController
+class DefaultController extends YBaseController
 {
 	public function actionIndex()
 	{

+ 78 - 0
www/protected/services/ImportExcelService.php

@@ -0,0 +1,78 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/11/28
+ * Time: 16:20
+ */
+class ImportExcelService extends Service
+{
+
+
+    /**
+     * @param $data 数据
+     * @param string $name 导出的excel名称
+     * @param $export 导出的类型  execute_export 执行订单汇总 order订单明细 tech保洁师明细
+     */
+    public function push($url) {
+        error_reporting(E_ALL);
+        date_default_timezone_set('Asia/Shanghai');
+        $file = file_get_contents($url);
+        $tmp = __DIR__.'/'.time().'.xlsx';
+        $examp = fopen($tmp,'w+');
+        @fwrite($examp,$file);
+        @fclose($examp);
+        $excelFile  = $tmp;
+        date_default_timezone_set('Asia/Shanghai');
+
+
+
+        $phpexcel = new PHPExcel;
+        $excelReader = PHPExcel_IOFactory::createReader('Excel2007');
+        $phpexcel = $excelReader->load($excelFile)->getSheet(0);//载入文件并获取第一个sheet
+
+        $total_line = $phpexcel->getHighestRow();
+        $total_column = $phpexcel->getHighestColumn();
+
+        for ($row = 2; $row <= $total_line; $row++) {
+            $data = array();
+            for ($column = 'A'; $column <= $total_column; $column++) {
+                if ($column == 'A') {
+                    $tmp = trim($phpexcel->getCell($column . $row)->getValue());
+                    $tmp = explode(":",$tmp);
+                    $tmp = strtotime($tmp[0].'-'.$tmp[1].'-'.$tmp[2].' '.$tmp[3].':'.$tmp[4]);
+                    $data[] = $tmp;
+                } else {
+                    $data[] = trim($phpexcel->getCell($column . $row)->getValue());
+                }
+
+
+            }
+
+            $order = new POrder();
+
+            $criteria = new EMongoCriteria();
+
+            $criteria->user_name('==',$data[4]);
+            $userInfo = Employe::model()->find($criteria);
+            //获取服务人员信息
+            if ($userInfo) {
+                $order->service_employer = $userInfo->_id;//服务人员Id
+            } else {
+                CommonFn::requestAjax(false, '服务人员信息不存在');exit;
+            }
+
+            $order->order_time = intval($data[0]);//服务日期
+            $order->address['floor'] = $data[1];//楼号
+            $order->address['room'] = $data[2];//房号
+            $order->service_standards = $data[3];//服务标准
+            $order->status = 0;//已派单
+            $order->in_room_time = 0;
+            $order->out_room_time = 0;
+
+            $result = $order->save();
+        }
+        unlink($excelFile);
+    }
+
+}

+ 116 - 8
www/protected/views/houseKeeping/index.php

@@ -158,13 +158,25 @@
                     </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="status_time" type="text" name="status_time">
+                      <input type="hidden" id="status_time_str" name="status_time">
+                    </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="server_start_time" type="text" name="server_start_time">
+                      <input id="server_start_time" type="text">
+                      <input type="hidden" id="server_start_time_str" name="server_start_time">
                     </div>
                   </div>
                 </li>
@@ -175,6 +187,7 @@
                     </div>
                     <div class="box_flex f_content">
                       <input id="server_end_time" type="text" name="server_end_time">
+                      <input type="hidden" id="server_end_time_str" name="server_end_time">
                     </div>
                   </div>
                 </li>
@@ -185,6 +198,7 @@
                     </div>
                     <div class="box_flex f_content">
                       <input id="yc_time" type="text" name="yc_time" >
+                      <input type="hidden" id="yc_time_str" name="yc_time">
                     </div>
                   </div>
                 </li>
@@ -256,23 +270,87 @@
 
       }
     });
+    var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons[0].text = '确定';
+    buttons[0].handler=function(){
+      var vals = $('#server_start_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#server_start_time_str').val(  parseInt($('#server_start_time_str').val())-(parseInt($('#server_start_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#server_start_time_str').val())*1000);
+
+      $('#server_start_time').datetimebox('setText',formatDate(d));
+      $('#server_start_time').datetimebox('hidePanel');
+    };
+
     $('#server_start_time').datetimebox({
       required: false,
       showSeconds:false,
+      buttons:buttons,
+      onSelect: function(date){
+        $('#server_start_time_str').val(date.getTime()/1000);
+      }
     });
+    var buttons1 = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons1[0].text = '确定';
+    buttons1[0].handler=function(){
+      var vals = $('#status_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#status_time_str').val(  parseInt($('#status_time_str').val())-(parseInt($('#status_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#status_time_str').val())*1000);
+
+      $('#status_time').datetimebox('setText',formatDate(d));
+      $('#status_time').datetimebox('hidePanel');
+    };
+
+    $('#status_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      buttons:buttons1,
+      onSelect: function(date){
+        $('#status_time_str').val(date.getTime()/1000);
+      }
+    });
+    var buttons2 = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons2[0].text = '确定';
+    buttons2[0].handler=function(){
+      var vals = $('#server_end_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#server_end_time_str').val(  parseInt($('#server_end_time_str').val())-(parseInt($('#server_end_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#server_end_time_str').val())*1000);
+
+      $('#server_end_time').datetimebox('setText',formatDate(d));
+      $('#server_end_time').datetimebox('hidePanel');
+    };
     $('#server_end_time').datetimebox({
       required: false,
       showSeconds:false,
+      buttons:buttons2,
+      onSelect: function(date){
+        $('#server_end_time_str').val(date.getTime()/1000);
+      }
     });
+    var buttons3 = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons3[0].text = '确定';
+    buttons3[0].handler=function(){
+      var vals = $('#yc_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#yc_time_str').val(  parseInt($('#yc_time_str').val())-(parseInt($('#yc_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#yc_time_str').val())*1000);
+
+      $('#yc_time').datetimebox('setText',formatDate(d));
+      $('#yc_time').datetimebox('hidePanel');
+    };
     $('#yc_time').datetimebox({
       required: false,
       showSeconds:false,
+      buttons:buttons3,
+      onSelect: function(date){
+        $('#yc_time_str').val(date.getTime()/1000);
+      }
     });
 
 
 
-    var buttons = $.extend([], $.fn.datebox.defaults.buttons);
-    buttons[0].text = '确定';
 
     jq_setStatus.combobox({
       editable: false,
@@ -404,6 +482,15 @@
           return   month+"月"+date+"日"+hour+":00";
         }
         },
+        {field:'status_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";
+        }
+        },
         {field:'yc_time', title:'预产期', width:70,sortable:true,formatter: function(value, row){
           var now=new Date(value*1000);
 
@@ -420,7 +507,7 @@
         $('#id_str').html(data.id);
         $('#id').html(data.id);
         $('#user_name').html(data.user_name);
-        $('#server_start_time').datetimebox('setValue', parse_time(data,'server_start_time'));
+        $('#server_start_time').datetimebox('setValue', parse_time(data,'server_start_time'));$('#status_time').datetimebox('setValue', parse_time(data,'status_time'));
         $('#server_end_time').datetimebox('setValue', parse_time(data,'server_end_time'));
         $('#yc_time').datetimebox('setValue', parse_time(data,'yc_time'));
         $('#mobile').html(data.mobile);
@@ -428,7 +515,6 @@
         $('#age').val(data.age);
         $('#tech').val(data.tech);
         $('#desc').val(data.desc);
-        console.log(data)
         jq_content_form.form('load', data);
         $('#admins_edit_info').html('');
         if (data['action_user'] != ''){
@@ -437,8 +523,33 @@
           jq_action_info.html('');
         }
 
+      },
+      onLoadSuccess: function(){
+
+        $(this).datagrid('clearChecked');
+        jq_content_form.form('clear');
+        $('#id_str').html('');
+        $('#id').html('');
+        $('#user_name').html('');
+        $('#server_start_time').datetimebox('setValue', '');
+        $('#status_time').datetimebox('setValue', '');
+        $('#server_end_time').datetimebox('setValue', '');
+        $('#yc_time').datetimebox('setValue', '');
+        $('#mobile').html('');
+        $('#address').html('');
+        $('#age').val('');
+        $('#tech').val('');
+        $('#desc').val('');
+        jq_content_form.form('load', data);
+        $('#admins_edit_info').html('');
+
+        jq_action_info.html('');
+
+        jq_dg_content.datagrid('clearSelections');
+        jq_setStatus.combobox('setValue', 100);
       }
 
+
     });
 
     jq_filter_status.combobox({
@@ -529,9 +640,6 @@
   });
 
   function save_content(){
-    if ($('#recharge_id').val() == ""){
-      return false;
-    }
     $.messager.progress();
     jq_content_form.submit();
   }