Procházet zdrojové kódy

建筑计价代码

laiguoran před 6 roky
rodič
revize
916e96b1f1

+ 4 - 0
protected/config/routes.conf.php

@@ -665,6 +665,7 @@ $route['*']['/holidayattendance/day/:day/cate/:cate/type/:type/page/:pindex'] =
 
 // 建筑-CLD接口
 $route['*']['/api/building/category/staff/:cid'] = array('BuildingApiController', 'categoryStaff');
+$route['*']['/api/building/staff/list'] = array('BuildingApiController', 'StaffList');
 
 // 建筑激活码
 $route['*']['/building'] = array('BuildingController', 'index');
@@ -698,4 +699,7 @@ $route['*']['/building/setUserClient'] = array('BuildingController', 'setUserCli
 // 启动器-CLD接口
 $route['*']['/api/startup/keynum'] = array('StartUpController', 'getKeyNum');
 
+// 计量支付后台登录
+$route['*']['/api/auth'] = array('BuildingApiController', 'auth');
+
 ?>

+ 81 - 0
protected/controller/BuildingApiController.php

@@ -10,6 +10,10 @@ class BuildingApiController extends DooController {
 
 	public $staff;
 
+	public $authApp = 'scConstruct';
+
+	public $authToken = 'sc@ConS!tru@ct*88';
+
 	function __construct() {
 
 	}
@@ -22,6 +26,83 @@ class BuildingApiController extends DooController {
 		exit;
 	}
 
+	/**
+	 * 员工列表
+	 */
+	public function StaffList() {
+		Doo::loadModel('staff');
+		$staff = new staff();
+		$staffList = $staff->find(array('select' => 'sid,username,nature,cid,departmentID,category,qq,phone,telephone', 'where' => 'sid!=1 and nature!=4', 'asArray' => TRUE));
+		Doo::loadModel('department');
+
+		$department = new department();
+
+		foreach($staffList as $k => $v) {
+			$staffList[$k]['departmentName'] = $v['departmentID'] != 0 ? $department->getDepartmentByDid($v['departmentID'])['departmentName'] : '';
+		}
+		echo json_encode($staffList,true);
+		exit;
+	}
+
+	/**
+	 * 计量支付后台登录
+	 */
+	public function auth() {
+		if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['app']) && isset($_POST['time']) && isset($_POST['token'])) {
+			// 先判断token和time的加密是是否一致,防止被其它接口调用
+			$token = $this->getSignature($this->authToken.$_POST['time'], $this->authToken);
+			if ($_POST['app'] == $this->authApp && $_POST['token'] == $token) {
+				Doo::loadModel('staff');
+				$staff = new staff();
+
+				$staffInfo = $staff->getStaffByName($_POST['username']);
+				if (!empty($staffInfo) && $staffInfo['passwork'] == md5($_POST['password'])) {
+					echo json_encode(array('err' => 0, 'data' => array(
+						'username' => $staffInfo['username'],
+						'office' => $staffInfo['cid'],
+						'category' => $staffInfo['category'],
+						'email' => $staffInfo['email'],
+						'telephone' => $staffInfo['telephone'],
+						'qq' => $staffInfo['qq'],
+						'fixedphone' => $staffInfo['phone'],
+						'position' => $staffInfo['position']
+					)
+					));
+					exit;
+				}
+			}
+		}
+		echo json_encode(array('err' => '参数有误'));
+		exit;
+	}
+
+	// HMAC-SHA1+base64 加密方法
+	function getSignature($str, $key) {
+		$signature = "";
+		if (function_exists('hash_hmac')) {
+			$signature = base64_encode(hash_hmac("sha1", $str, $key, true));
+		} else {
+			$blocksize = 64;
+			$hashfunc = 'sha1';
+			if (strlen($key) > $blocksize) {
+				$key = pack('H*', $hashfunc($key));
+			}
+			$key = str_pad($key, $blocksize, chr(0x00));
+			$ipad = str_repeat(chr(0x36), $blocksize);
+			$opad = str_repeat(chr(0x5c), $blocksize);
+			$hmac = pack(
+				'H*', $hashfunc(
+					($key ^ $opad) . pack(
+						'H*', $hashfunc(
+							($key ^ $ipad) . $str
+						)
+					)
+				)
+			);
+			$signature = base64_encode($hmac);
+		}
+		return $signature;
+	}
 }
 
 ?>

+ 24 - 0
protected/controller/BuildingController.php

@@ -11,6 +11,30 @@ class BuildingController extends DooController {
 
     public $staff;
 
+    public function beforeRun($resource, $action) {
+        Doo::loadModel ( 'staff' );
+        $staff = new staff ();
+        $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
+
+        $accessModular = 'BUILD';
+        if (empty ( $detail ['cldAccessArray'] ))
+            die ( 'illegal request' );
+        else {
+
+            if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
+                if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
+                    $flag = true;
+                } else {
+                    $flag = false;
+                }
+            } else {
+                die ( 'illegal request' );
+            }
+        }
+        if (! $flag)
+            die ( 'illegal request' );
+    }
+
     function __construct() {
         if(isset($_COOKIE["staff"])){
             if(!empty($_COOKIE["staff"])){

+ 10 - 6
protected/controller/HolidayController.php

@@ -1,7 +1,7 @@
 <?php
 
 /**
- * @author ellisRan
+ * @author darkredz
  */
 
 class HolidayController extends DooController {
@@ -588,7 +588,7 @@ class HolidayController extends DooController {
 		$hday = new HDay();
 		$holiday = new Holiday();
 
-		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
+		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid where `CLD_staff`.nature!=4 group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
 		$query = Doo::db ()->query ( $sql );
 		$result = $query->fetchAll ();
 		$data['category'] = $result;
@@ -782,7 +782,7 @@ class HolidayController extends DooController {
 		$staff = new staff();
 		$hstaff = new HStaff();
 
-		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
+		$sql = 'SELECT `CLD_L_category`.cid,`CLD_L_category`.title,count(`CLD_staff`.sid) as count FROM `CLD_L_category` left join `CLD_staff` on `CLD_L_category`.cid=`CLD_staff`.cid where `CLD_staff`.nature!=4 group by `CLD_staff`.cid HAVING count(`CLD_staff`.sid)>0 order by count(`CLD_staff`.sid) desc';
 		$query = Doo::db ()->query ( $sql );
 		$result = $query->fetchAll ();
 		$data['category'] = $result;
@@ -1074,15 +1074,19 @@ class HolidayController extends DooController {
 		$hireRound = strtotime($hiredate) - $hireBiasDate*86400;
 		$month = date('m', $hireRound);
 		$date = date('d', $hireRound);
-		$monthday = intval($month).'月'.intval($date).'日';
+		$monthday = intval($month).'-'.intval($date);
 		$year = date('Y',time());
 		//每隔4年加一天
 		if(date('Y',($hireRound+(86400*365*$hadyear)+intval($hadyear/4)*86400)) < $year){
 			$lastyear = intval($year)-1;
-			return intval($lastyear).'年'.$monthday.'~'.intval($year).'年'.$monthday;
+			$startday = date('Y年m月d日', strtotime(intval($lastyear).'-'.$monthday));
+			$endday = date('Y年m月d日', strtotime(intval($year).'-'.$monthday)- 86400);
+			return $startday.'~'.$endday;
 		}else{
 			$nextyear = intval($year)+1;
-			return intval($year).'年'.$monthday.'~'.intval($nextyear).'年'.$monthday;
+			$startday = date('Y年m月d日', strtotime(intval($year).'-'.$monthday));
+			$endday = date('Y年m月d日', strtotime(intval($nextyear).'-'.$monthday) - 86400);
+			return $startday.'~'.$endday;
 		}
 	}
 

+ 1 - 5
protected/controller/StartUpController.php

@@ -18,7 +18,7 @@ class StartUpController extends DooController {
 		if (isset($_GET['num'])) {
 			Doo::loadModel('longle');
 			$longle = new longle();
-			$keynum = $longle->getOne(array('select' => 'key_num', 'where' => 'SerialNumber=?', 'param' => array($_GET['longle']), 'asArray' => TRUE));
+			$keynum = $longle->getOne(array('select' => 'key_num', 'where' => 'SerialNumber=?', 'param' => array($_GET['num']), 'asArray' => TRUE));
 			if (!empty($keynum)) {
 				echo json_encode(array('error' => 0, 'msg' => '', 'info' => $keynum['key_num']));
 				exit;
@@ -30,11 +30,7 @@ class StartUpController extends DooController {
 			echo json_encode(array('error' => 1, 'msg' => '参数有误'));
 			exit;
 		}
-
-
-
 	}
-
 }
 
 ?>

+ 1 - 1
protected/view/building-index.html

@@ -11,7 +11,7 @@
 		</div>
 		<div class="warpContent">
 			<div class="contactTab">
-				<a class="now" href="#">建筑激活</a>
+				<a class="now" href="#">建筑计价</a>
 				<div class="searchItem">
 					<input type="text" placeholder="输入建筑用户手机号进行搜索" id="search_mobile">
 					<input type="hidden" id="hidden_search" value="0">

+ 3 - 1
protected/view/menu.html

@@ -17,9 +17,11 @@
 </li>
 <!-- endif -->
 
-<li data-placement="right" data-toggle="ctooltip" data-original-title="建筑激活">
+<!-- if isShowMenu('BUILD') -->
+<li data-placement="right" data-toggle="ctooltip" data-original-title="建筑计价">
     <a href="/building" class="icon- <!-- if {{memu}}=="building" --> selected <!-- endif -->">e</a>
 </li>
+<!-- endif -->
 
 <!-- if isShowMenu('RECEIPTS') -->
 <li  data-placement="right" data-toggle="ctooltip" class="topLine <!-- if   getGlobals('NEW') != 0 || getGlobals('NEW2') != 0  --> news <!-- endif -->" data-original-title="费用管理"  >